1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 10:24:37 +02:00

SurfaceCollection: Removed alpha flag.

In the existing code the alpha flag is always true, so there is no point
in passing it around.
This commit is contained in:
Maarten ter Huurne 2011-06-02 05:52:47 +02:00
parent af3ed78496
commit 44ca4e3460
2 changed files with 16 additions and 17 deletions

View File

@ -28,9 +28,9 @@
using std::endl;
using std::string;
SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) {
this->defaultAlpha = defaultAlpha;
setSkin(skin);
SurfaceCollection::SurfaceCollection()
: skin("default")
{
}
SurfaceCollection::~SurfaceCollection() {}
@ -68,7 +68,7 @@ Surface *SurfaceCollection::add(Surface *s, const string &path) {
return s;
}
Surface *SurfaceCollection::add(const string &path, bool alpha) {
Surface *SurfaceCollection::add(const string &path) {
DEBUG("Adding surface: '%s'\n", path.c_str());
if (exists(path)) del(path);
@ -80,12 +80,12 @@ Surface *SurfaceCollection::add(const string &path, bool alpha) {
return NULL;
} else if (!fileExists(filePath)) return NULL;
Surface *s = new Surface(filePath, "", alpha);
Surface *s = new Surface(filePath, "");
surfaces[path] = s;
return s;
}
Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
Surface *SurfaceCollection::addSkinRes(const string &path) {
DEBUG("Adding skin surface: '%s'\n", path.c_str());
if (path.empty()) return NULL;
@ -94,7 +94,7 @@ Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
string skinpath = getSkinFilePath(path);
if (skinpath.empty())
return NULL;
Surface *s = new Surface(skinpath, "", alpha);
Surface *s = new Surface(skinpath, "", true);
if (s != NULL)
surfaces[path] = s;
return s;
@ -125,7 +125,7 @@ void SurfaceCollection::move(const string &from, const string &to) {
Surface *SurfaceCollection::operator[](const string &key) {
SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end())
return add(key, defaultAlpha);
return add(key);
else
return i->second;
}
@ -135,7 +135,7 @@ Surface *SurfaceCollection::skinRes(const string &key) {
SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end())
return addSkinRes(key, defaultAlpha);
return addSkinRes(key);
else
return i->second;
}

View File

@ -33,13 +33,8 @@ Hash Map of surfaces that loads surfaces not already loaded and reuses already l
@author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
*/
class SurfaceCollection {
private:
SurfaceHash surfaces;
std::string skin;
public:
SurfaceCollection(
bool defaultAlpha = true, const std::string &skin = "default");
SurfaceCollection();
~SurfaceCollection();
void setSkin(const std::string &skin);
@ -49,8 +44,8 @@ public:
void debug();
Surface *add(Surface *s, const std::string &path);
Surface *add(const std::string &path, bool alpha=true);
Surface *addSkinRes(const std::string &path, bool alpha=true);
Surface *add(const std::string &path);
Surface *addSkinRes(const std::string &path);
void del(const std::string &path);
void clear();
void move(const std::string &from, const std::string &to);
@ -58,6 +53,10 @@ public:
Surface *operator[](const std::string &);
Surface *skinRes(const std::string &);
private:
SurfaceHash surfaces;
std::string skin;
};
#endif