diff options
Diffstat (limited to 'src/gui/popup.cpp')
-rw-r--r-- | src/gui/popup.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index d44dbc93..6d57081f 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -42,6 +42,7 @@ Popup::Popup(const std::string& name, Window *parent, const std::string& skin): mParent(parent), mPopupName(name), + mDefaultSkinPath(skin), mMinWidth(100), mMinHeight(40), mMaxWidth(INT_MAX), @@ -57,7 +58,7 @@ Popup::Popup(const std::string& name, Window *parent, instances++; // Loads the skin - mSkin = skinLoader->load(skin); + mSkin = skinLoader->load(skin, mDefaultSkinPath); // Add this window to the window container windowContainer->add(this); @@ -70,6 +71,8 @@ Popup::~Popup() { logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str()); + savePopupConfiguration(); + while (!mWidgets.empty()) { gcn::Widget *w = mWidgets.front(); @@ -87,6 +90,34 @@ void Popup::setWindowContainer(WindowContainer *wc) windowContainer = wc; } +void Popup::loadPopupConfiguration() +{ + if (mPopupName.empty()) + return; + + const std::string &name = mPopupName; + const std::string &skinName = config.getValue(name + "Skin", + mSkin->getFilePath()); + + if (skinName.compare(mSkin->getFilePath()) != 0) + { + mSkin->instances--; + mSkin = skinLoader->load(skinName, mDefaultSkinPath); + } +} + +void Popup::savePopupConfiguration() +{ + if (mPopupName.empty()) + return; + + const std::string &name = mPopupName; + + // Saves the skin path in a config file (which allows for skins to be + // changed from the default path) + config.setValue(name + "Skin", mSkin->getFilePath()); +} + void Popup::draw(gcn::Graphics *graphics) { if (!isVisible()) |