Skip to content

Commit

Permalink
revert code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
podulator committed Dec 20, 2019
1 parent 07bc16c commit 1329853
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/surfacecollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,31 @@ Surface *SurfaceCollection::addIcon(const string &path, bool alpha) {
return this->add(path, alpha, this->skin->iconsToGrayscale);
}

Surface *SurfaceCollection::skinRes(const string &key) {
TRACE("enter : %s", key.c_str());
if (key.empty()) return NULL;
SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end()) {
return addSkinRes(key, defaultAlpha);
}
return i->second;
}

// adds a skin resource, which ignores the greyscale skin setting flag
Surface *SurfaceCollection::addSkinRes(const std::string &path, bool alpha) {
return this->add(path, alpha, false);
if (path.empty()) return NULL;
if (exists(path)) return surfaces[path];

string skinpath = this->skin->getSkinFilePath(path);
if (skinpath.empty())
return NULL;

TRACE("Adding skin surface: '%s'", skinpath.c_str());
Surface *s = new Surface(skinpath, alpha);
if (NULL != s) {
surfaces[path] = s;
}
return s;
}

Surface *SurfaceCollection::add(const std::string &path, bool alpha, bool grayScale) {
Expand Down Expand Up @@ -129,12 +151,3 @@ Surface *SurfaceCollection::operator[](const string &key) {

return i->second;
}

Surface *SurfaceCollection::skinRes(const string &key) {
if (key.empty()) return NULL;
SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end())
return addSkinRes(key, defaultAlpha);

return i->second;
}

0 comments on commit 1329853

Please sign in to comment.