1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 21:05:27 +03:00

Minimize namespace pollution by SurfaceCollection class.

This commit is contained in:
Maarten ter Huurne 2010-07-28 03:08:26 +02:00
parent d082f7f280
commit c84fea65a2
3 changed files with 23 additions and 17 deletions

View File

@ -32,6 +32,8 @@
#include "utilities.h" #include "utilities.h"
#include "touchscreen.h" #include "touchscreen.h"
#include "inputmanager.h" #include "inputmanager.h"
#include "asfont.h"
#include "surface.h"
const int MAX_VOLUME_SCALE_FACTOR = 200; const int MAX_VOLUME_SCALE_FACTOR = 200;
// Default values - going to add settings adjustment, saving, loading and such // Default values - going to add settings adjustment, saving, loading and such

View File

@ -19,8 +19,12 @@
***************************************************************************/ ***************************************************************************/
#include "surfacecollection.h" #include "surfacecollection.h"
#include "surface.h"
#include "utilities.h"
using namespace std; using std::cout;
using std::endl;
using std::string;
SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) { SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) {
surfaces.set_empty_key(" "); surfaces.set_empty_key(" ");

View File

@ -21,12 +21,11 @@
#define SURFACECOLLECTION_H #define SURFACECOLLECTION_H
#include <google/dense_hash_map> #include <google/dense_hash_map>
#include <string>
#include "surface.h" class Surface;
#include "utilities.h"
using google::dense_hash_map; typedef google::dense_hash_map<std::string, Surface *> SurfaceHash;
typedef dense_hash_map<string, Surface *> SurfaceHash;
/** /**
Hash Map of surfaces that loads surfaces not already loaded and reuses already loaded ones. Hash Map of surfaces that loads surfaces not already loaded and reuses already loaded ones.
@ -36,28 +35,29 @@ Hash Map of surfaces that loads surfaces not already loaded and reuses already l
class SurfaceCollection { class SurfaceCollection {
private: private:
SurfaceHash surfaces; SurfaceHash surfaces;
string skin; std::string skin;
public: public:
SurfaceCollection(bool defaultAlpha=true, const string &skin="default"); SurfaceCollection(
bool defaultAlpha = true, const std::string &skin = "default");
~SurfaceCollection(); ~SurfaceCollection();
void setSkin(const string &skin); void setSkin(const std::string &skin);
string getSkinFilePath(const string &file); std::string getSkinFilePath(const std::string &file);
bool defaultAlpha; bool defaultAlpha;
void debug(); void debug();
Surface *add(Surface *s, const string &path); Surface *add(Surface *s, const std::string &path);
Surface *add(const string &path, bool alpha=true); Surface *add(const std::string &path, bool alpha=true);
Surface *addSkinRes(const string &path, bool alpha=true); Surface *addSkinRes(const std::string &path, bool alpha=true);
void del(const string &path); void del(const std::string &path);
void clear(); void clear();
void move(const string &from, const string &to); void move(const std::string &from, const std::string &to);
bool exists(const string &path); bool exists(const std::string &path);
Surface *operator[](const string &); Surface *operator[](const std::string &);
Surface *skinRes(const string &); Surface *skinRes(const std::string &);
}; };
#endif #endif