summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-25 11:31:02 -0600
committerIra Rice <irarice@gmail.com>2009-03-25 11:31:02 -0600
commite0be7afc936c39e2b0e1db84a13653cfd78a6035 (patch)
treef5e99fa2f4f2d7c1c7149bd66e410798ae632735 /src/gui/window.cpp
parentf6e7a477681109aea040456e3f4ebd0f65645ecc (diff)
downloadmana-e0be7afc936c39e2b0e1db84a13653cfd78a6035.tar.gz
mana-e0be7afc936c39e2b0e1db84a13653cfd78a6035.tar.bz2
mana-e0be7afc936c39e2b0e1db84a13653cfd78a6035.tar.xz
mana-e0be7afc936c39e2b0e1db84a13653cfd78a6035.zip
Modified skin loading to save and load a skin's XML path, as well as
modified the skin loading method to take a default value, in case the value in the configuration file fails to load for one reason or another. While this doesn't directly expose skinning on a per window basis to the user at the moment, it does allow people to change what skins get loaded with which windows now without needing to modify the code. TODO: Determine a decent approach to allowing the user to change their window skins in game, as well as moving all widget skin loading to the skin class (for instance, the button skins, progressbar skins, etc.) so that different skin configurations can use different widget skins. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 75820521..642fdeb8 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -48,6 +48,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std
mParent(parent),
mLayout(NULL),
mWindowName("window"),
+ mDefaultSkinPath(skin),
mShowTitle(true),
mModal(modal),
mCloseButton(false),
@@ -74,7 +75,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std
setTitleBarHeight(20);
// Loads the skin
- mSkin = skinLoader->load(skin);
+ mSkin = skinLoader->load(skin, mDefaultSkinPath);
// Add this window to the window container
windowContainer->add(this);
@@ -476,12 +477,20 @@ void Window::mouseDragged(gcn::MouseEvent &event)
void Window::loadWindowState()
{
const std::string &name = mWindowName;
+ const std::string skinName = config.getValue(name + "Skin",
+ mSkin->getFilePath());
assert(!name.empty());
setPosition((int) config.getValue(name + "WinX", mDefaultX),
(int) config.getValue(name + "WinY", mDefaultY));
setVisible((bool) config.getValue(name + "Visible", false));
+ if (skinName.compare(mSkin->getFilePath()) != 0)
+ {
+ mSkin->instances--;
+ mSkin = skinLoader->load(skinName, mDefaultSkinPath);
+ }
+
if (mGrip)
{
int width = (int) config.getValue(name + "WinWidth", mDefaultWidth);
@@ -512,6 +521,7 @@ void Window::saveWindowState()
config.setValue(mWindowName + "WinX", getX());
config.setValue(mWindowName + "WinY", getY());
config.setValue(mWindowName + "Visible", isVisible());
+ config.setValue(mWindowName + "Skin", mSkin->getFilePath());
if (mGrip)
{