diff options
author | Ira Rice <shogun@odin.(none)> | 2009-03-25 09:55:44 -0600 |
---|---|---|
committer | Ira Rice <shogun@odin.(none)> | 2009-03-25 09:55:44 -0600 |
commit | f6e7a477681109aea040456e3f4ebd0f65645ecc (patch) | |
tree | 258380203c03ede0fdaf8e2c0009a03bb1da8523 /src/gui/skin.cpp | |
parent | 46a368e2f6fd8fcc30949c6676045e2005bd5bfa (diff) | |
download | mana-f6e7a477681109aea040456e3f4ebd0f65645ecc.tar.gz mana-f6e7a477681109aea040456e3f4ebd0f65645ecc.tar.bz2 mana-f6e7a477681109aea040456e3f4ebd0f65645ecc.tar.xz mana-f6e7a477681109aea040456e3f4ebd0f65645ecc.zip |
Moved the responsibility for skin alpha adjustment to the Skin class.
This fixes a break that occured where skins wouldn't update in real time
in the client, due to being passed a reference, rather than getting the
skin itself.
Signed-off-by: Ira Rice <shogun@odin.(none)>
Diffstat (limited to 'src/gui/skin.cpp')
-rw-r--r-- | src/gui/skin.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index d44c54a8..ac258175 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -19,8 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <algorithm> + #include "skin.h" +#include "../configuration.h" +#include "../configlistener.h" #include "../log.h" #include "../resources/image.h" @@ -30,6 +34,16 @@ #include "../utils/xml.h" SkinLoader* skinLoader = NULL; +ConfigListener *SkinLoader::skinConfigListener = NULL; + +class SkinConfigListener : public ConfigListener +{ + void optionChanged(const std::string &) + { + if (skinLoader) + skinLoader->updateAlpha(); + } +}; Skin::Skin(ImageRect skin, Image* close, std::string name): instances(0), @@ -51,6 +65,15 @@ Skin::~Skin() closeImage->decRef(); } +void Skin::updateAlpha() +{ + const float alpha = config.getValue("guialpha", 0.8); + + for_each(border.grid, border.grid + 9, + std::bind2nd(std::mem_fun(&Image::setAlpha), alpha)); + closeImage->setAlpha(alpha); +} + unsigned int Skin::getMinWidth() { return (border.grid[0]->getWidth() + border.grid[1]->getWidth()) + @@ -177,15 +200,34 @@ Skin* SkinLoader::load(const std::string &filename) Skin* skin = new Skin(border, closeImage); mSkins[filename] = skin; + + updateAlpha(); + return skin; } -SkinLoader::SkinLoader() +SkinLoader::SkinLoader() : + mSkins() { + skinConfigListener = new SkinConfigListener(); + // Send GUI alpha changed for initialization + skinConfigListener->optionChanged("guialpha"); + config.addListener("guialpha", skinConfigListener); } SkinLoader::~SkinLoader() { delete_all(mSkins); + config.removeListener("guialpha", skinConfigListener); + delete skinConfigListener; + skinConfigListener = NULL; +} + +void SkinLoader::updateAlpha() +{ + for (SkinIterator iter = mSkins.begin(); iter != mSkins.end(); ++iter) + { + iter->second->updateAlpha(); + } } |