summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-27 21:50:25 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-28 10:30:45 -0700
commit500ee24e22aae7b457118d152b4480e99969092e (patch)
treeea0e7e3869a80fbc86cffe97136b926cc7149bdd
parent64e742acdb9b0dd9c44bced91766f5ea1aa9de4c (diff)
downloadmana-500ee24e22aae7b457118d152b4480e99969092e.tar.gz
mana-500ee24e22aae7b457118d152b4480e99969092e.tar.bz2
mana-500ee24e22aae7b457118d152b4480e99969092e.tar.xz
mana-500ee24e22aae7b457118d152b4480e99969092e.zip
Make the gui more themeable and distribute two themes
The older gray theme and the new wood theme are available as themes. The gray theme needs some new graphics for hilights. Add a theme option for branding and add path/to/branding/data to the PhysFS search path. Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Chuck Miller
-rw-r--r--data/graphics/gui/button.pngbin1463 -> 374 bytes
-rw-r--r--data/graphics/gui/button_disabled.pngbin1463 -> 313 bytes
-rw-r--r--data/graphics/gui/buttonhi.pngbin1530 -> 374 bytes
-rw-r--r--data/graphics/gui/buttonpress.pngbin1558 -> 377 bytes
-rw-r--r--data/graphics/gui/checkbox.pngbin537 -> 696 bytes
-rw-r--r--data/graphics/gui/close_button.pngbin769 -> 650 bytes
-rw-r--r--data/graphics/gui/deepbox.pngbin560 -> 219 bytes
-rw-r--r--data/graphics/gui/gui.xml19
-rw-r--r--data/graphics/gui/hscroll_left_default.pngbin478 -> 358 bytes
-rw-r--r--data/graphics/gui/hscroll_left_highlight.pngbin479 -> 364 bytes
-rw-r--r--data/graphics/gui/hscroll_left_pressed.pngbin470 -> 349 bytes
-rw-r--r--data/graphics/gui/hscroll_right_default.pngbin444 -> 340 bytes
-rw-r--r--data/graphics/gui/hscroll_right_highlight.pngbin484 -> 359 bytes
-rw-r--r--data/graphics/gui/hscroll_right_pressed.pngbin468 -> 350 bytes
-rw-r--r--data/graphics/gui/item_shortcut_bgr.pngbin1463 -> 284 bytes
-rw-r--r--data/graphics/gui/radioin.pngbin636 -> 454 bytes
-rw-r--r--data/graphics/gui/radioout.pngbin528 -> 380 bytes
-rw-r--r--data/graphics/gui/resize.pngbin670 -> 443 bytes
-rw-r--r--data/graphics/gui/selection.pngbin739 -> 740 bytes
-rw-r--r--data/graphics/gui/slider.pngbin486 -> 485 bytes
-rw-r--r--data/graphics/gui/sticky_button.pngbin746 -> 526 bytes
-rw-r--r--data/graphics/gui/tab.pngbin1352 -> 329 bytes
-rw-r--r--data/graphics/gui/tabselected.pngbin1437 -> 313 bytes
-rw-r--r--data/graphics/gui/vscroll_down_default.pngbin489 -> 367 bytes
-rw-r--r--data/graphics/gui/vscroll_down_highlight.pngbin486 -> 382 bytes
-rw-r--r--data/graphics/gui/vscroll_down_pressed.pngbin475 -> 376 bytes
-rw-r--r--data/graphics/gui/vscroll_grey.pngbin436 -> 338 bytes
-rw-r--r--data/graphics/gui/vscroll_up_default.pngbin484 -> 377 bytes
-rw-r--r--data/graphics/gui/vscroll_up_highlight.pngbin481 -> 376 bytes
-rw-r--r--data/graphics/gui/vscroll_up_pressed.pngbin462 -> 364 bytes
-rw-r--r--data/graphics/gui/window.pngbin25969 -> 3410 bytes
-rw-r--r--docs/example.mana1
-rw-r--r--src/client.cpp43
-rw-r--r--src/client.h4
-rw-r--r--src/gui/emotepopup.cpp6
-rw-r--r--src/gui/gui.cpp5
-rw-r--r--src/gui/skilldialog.cpp3
-rw-r--r--src/gui/skin.cpp80
-rw-r--r--src/gui/skin.h19
-rw-r--r--src/gui/specialswindow.cpp3
-rw-r--r--src/gui/speechbubble.cpp3
-rw-r--r--src/gui/widgets/avatarlistbox.cpp5
-rw-r--r--src/gui/widgets/button.cpp12
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/dropdown.cpp12
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/itemcontainer.cpp6
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/playerbox.cpp6
-rw-r--r--src/gui/widgets/popup.h2
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/progressindicator.cpp7
-rw-r--r--src/gui/widgets/radiobutton.cpp16
-rw-r--r--src/gui/widgets/resizegrip.cpp6
-rw-r--r--src/gui/widgets/resizegrip.h2
-rw-r--r--src/gui/widgets/scrollarea.cpp24
-rw-r--r--src/gui/widgets/slider.cpp6
-rw-r--r--src/gui/widgets/tab.cpp12
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/window.h2
-rw-r--r--src/item.cpp6
-rw-r--r--src/localplayer.cpp24
-rw-r--r--src/resources/resourcemanager.cpp3
-rw-r--r--src/text.cpp4
64 files changed, 229 insertions, 136 deletions
diff --git a/data/graphics/gui/button.png b/data/graphics/gui/button.png
index 4f6a5a81..9ebbea63 100644
--- a/data/graphics/gui/button.png
+++ b/data/graphics/gui/button.png
Binary files differ
diff --git a/data/graphics/gui/button_disabled.png b/data/graphics/gui/button_disabled.png
index 2a8fdf43..0ce3aa6f 100644
--- a/data/graphics/gui/button_disabled.png
+++ b/data/graphics/gui/button_disabled.png
Binary files differ
diff --git a/data/graphics/gui/buttonhi.png b/data/graphics/gui/buttonhi.png
index 24c09718..c4772634 100644
--- a/data/graphics/gui/buttonhi.png
+++ b/data/graphics/gui/buttonhi.png
Binary files differ
diff --git a/data/graphics/gui/buttonpress.png b/data/graphics/gui/buttonpress.png
index d192534a..e9cd1765 100644
--- a/data/graphics/gui/buttonpress.png
+++ b/data/graphics/gui/buttonpress.png
Binary files differ
diff --git a/data/graphics/gui/checkbox.png b/data/graphics/gui/checkbox.png
index b68893fc..669ecf03 100644
--- a/data/graphics/gui/checkbox.png
+++ b/data/graphics/gui/checkbox.png
Binary files differ
diff --git a/data/graphics/gui/close_button.png b/data/graphics/gui/close_button.png
index a4f802e0..f87cc2a9 100644
--- a/data/graphics/gui/close_button.png
+++ b/data/graphics/gui/close_button.png
Binary files differ
diff --git a/data/graphics/gui/deepbox.png b/data/graphics/gui/deepbox.png
index 6b63168a..084b5f61 100644
--- a/data/graphics/gui/deepbox.png
+++ b/data/graphics/gui/deepbox.png
Binary files differ
diff --git a/data/graphics/gui/gui.xml b/data/graphics/gui/gui.xml
index 015c6ce3..f27dbc7f 100644
--- a/data/graphics/gui/gui.xml
+++ b/data/graphics/gui/gui.xml
@@ -1,19 +1,18 @@
<skinset name="Default" image="window.png">
<widget type="Window">
- <!-- <option name="padding" value="5" /> -->
<!-- Top Row -->
- <part type="top-left-corner" xpos="0" ypos="0" width="10" height="10" />
- <part type="top-edge" xpos="11" ypos="0" width="127" height="10" />
- <part type="top-right-corner" xpos="139" ypos="0" width="12" height="10" />
+ <part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
+ <part type="top-edge" xpos="4" ypos="0" width="32" height="4" />
+ <part type="top-right-corner" xpos="36" ypos="0" width="4" height="4" />
<!-- Middle Row -->
- <part type="left-edge" xpos="0" ypos="11" width="10" height="81" />
- <part type="bg-quad" xpos="11" ypos="11" width="127" height="81" />
- <part type="right-edge" xpos="139" ypos="11" width="12" height="81" />
+ <part type="left-edge" xpos="0" ypos="4" width="4" height="216" />
+ <part type="bg-quad" xpos="4" ypos="4" width="32" height="216" />
+ <part type="right-edge" xpos="36" ypos="4" width="4" height="216" />
<!-- Bottom Row -->
- <part type="bottom-left-corner" xpos="0" ypos="93" width="10" height="12" />
- <part type="bottom-edge" xpos="11" ypos="93" width="127" height="12" />
- <part type="bottom-right-corner" xpos="139" ypos="93" width="12" height="12" />
+ <part type="bottom-left-corner" xpos="0" ypos="220" width="4" height="4" />
+ <part type="bottom-edge" xpos="4" ypos="220" width="32" height="4" />
+ <part type="bottom-right-corner" xpos="36" ypos="220" width="4" height="4" />
</widget>
</skinset>
diff --git a/data/graphics/gui/hscroll_left_default.png b/data/graphics/gui/hscroll_left_default.png
index 07e5e078..2f763d30 100644
--- a/data/graphics/gui/hscroll_left_default.png
+++ b/data/graphics/gui/hscroll_left_default.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_left_highlight.png b/data/graphics/gui/hscroll_left_highlight.png
index c77427f8..6be5ae25 100644
--- a/data/graphics/gui/hscroll_left_highlight.png
+++ b/data/graphics/gui/hscroll_left_highlight.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_left_pressed.png b/data/graphics/gui/hscroll_left_pressed.png
index 081eaa3a..b8ebcb46 100644
--- a/data/graphics/gui/hscroll_left_pressed.png
+++ b/data/graphics/gui/hscroll_left_pressed.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_default.png b/data/graphics/gui/hscroll_right_default.png
index ee74c071..33fdddd0 100644
--- a/data/graphics/gui/hscroll_right_default.png
+++ b/data/graphics/gui/hscroll_right_default.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_highlight.png b/data/graphics/gui/hscroll_right_highlight.png
index 9f8911e4..e9e633ea 100644
--- a/data/graphics/gui/hscroll_right_highlight.png
+++ b/data/graphics/gui/hscroll_right_highlight.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_pressed.png b/data/graphics/gui/hscroll_right_pressed.png
index 6ef987a5..53972f2b 100644
--- a/data/graphics/gui/hscroll_right_pressed.png
+++ b/data/graphics/gui/hscroll_right_pressed.png
Binary files differ
diff --git a/data/graphics/gui/item_shortcut_bgr.png b/data/graphics/gui/item_shortcut_bgr.png
index 5b3c5e7c..0543e38a 100644
--- a/data/graphics/gui/item_shortcut_bgr.png
+++ b/data/graphics/gui/item_shortcut_bgr.png
Binary files differ
diff --git a/data/graphics/gui/radioin.png b/data/graphics/gui/radioin.png
index 8d0e5f74..12e027fe 100644
--- a/data/graphics/gui/radioin.png
+++ b/data/graphics/gui/radioin.png
Binary files differ
diff --git a/data/graphics/gui/radioout.png b/data/graphics/gui/radioout.png
index 70a25256..5eb67bd8 100644
--- a/data/graphics/gui/radioout.png
+++ b/data/graphics/gui/radioout.png
Binary files differ
diff --git a/data/graphics/gui/resize.png b/data/graphics/gui/resize.png
index dfe79ebf..6b31ac64 100644
--- a/data/graphics/gui/resize.png
+++ b/data/graphics/gui/resize.png
Binary files differ
diff --git a/data/graphics/gui/selection.png b/data/graphics/gui/selection.png
index a117a78a..78827daf 100644
--- a/data/graphics/gui/selection.png
+++ b/data/graphics/gui/selection.png
Binary files differ
diff --git a/data/graphics/gui/slider.png b/data/graphics/gui/slider.png
index df9abe56..465ad0e8 100644
--- a/data/graphics/gui/slider.png
+++ b/data/graphics/gui/slider.png
Binary files differ
diff --git a/data/graphics/gui/sticky_button.png b/data/graphics/gui/sticky_button.png
index 2708dd99..8c570573 100644
--- a/data/graphics/gui/sticky_button.png
+++ b/data/graphics/gui/sticky_button.png
Binary files differ
diff --git a/data/graphics/gui/tab.png b/data/graphics/gui/tab.png
index 689981a9..91eadf08 100644
--- a/data/graphics/gui/tab.png
+++ b/data/graphics/gui/tab.png
Binary files differ
diff --git a/data/graphics/gui/tabselected.png b/data/graphics/gui/tabselected.png
index 72a48973..e2983060 100644
--- a/data/graphics/gui/tabselected.png
+++ b/data/graphics/gui/tabselected.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_default.png b/data/graphics/gui/vscroll_down_default.png
index 0ec2a3ee..c4292489 100644
--- a/data/graphics/gui/vscroll_down_default.png
+++ b/data/graphics/gui/vscroll_down_default.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_highlight.png b/data/graphics/gui/vscroll_down_highlight.png
index d2934daa..ac88f7c7 100644
--- a/data/graphics/gui/vscroll_down_highlight.png
+++ b/data/graphics/gui/vscroll_down_highlight.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_pressed.png b/data/graphics/gui/vscroll_down_pressed.png
index 6aa44ba6..9dcc89f6 100644
--- a/data/graphics/gui/vscroll_down_pressed.png
+++ b/data/graphics/gui/vscroll_down_pressed.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_grey.png b/data/graphics/gui/vscroll_grey.png
index 3f65a883..f99da467 100644
--- a/data/graphics/gui/vscroll_grey.png
+++ b/data/graphics/gui/vscroll_grey.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_default.png b/data/graphics/gui/vscroll_up_default.png
index 73a4266f..1cecc351 100644
--- a/data/graphics/gui/vscroll_up_default.png
+++ b/data/graphics/gui/vscroll_up_default.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_highlight.png b/data/graphics/gui/vscroll_up_highlight.png
index 6fc3884d..7b5009f3 100644
--- a/data/graphics/gui/vscroll_up_highlight.png
+++ b/data/graphics/gui/vscroll_up_highlight.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_pressed.png b/data/graphics/gui/vscroll_up_pressed.png
index bfa8e175..2320ec42 100644
--- a/data/graphics/gui/vscroll_up_pressed.png
+++ b/data/graphics/gui/vscroll_up_pressed.png
Binary files differ
diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png
index 671b7740..f0ef1af4 100644
--- a/data/graphics/gui/window.png
+++ b/data/graphics/gui/window.png
Binary files differ
diff --git a/docs/example.mana b/docs/example.mana
index aa87b96f..9802c280 100644
--- a/docs/example.mana
+++ b/docs/example.mana
@@ -19,4 +19,5 @@ filename / path as a command line parameter
<option name="defaultUpdateHost" value="http://updates.themanaworld.org"/>
<option name="font" value="fonts/dejavusans.ttf" />
<option name="boldFont" value="fonts/dejavusans-bold.ttf" />
+ <option name="theme" value="wood" />
</configuration>
diff --git a/src/client.cpp b/src/client.cpp
index 9fa61364..a1b7a512 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -249,13 +249,6 @@ Client::Client(const Options &options):
"Exiting.", mLocalDataDir.c_str()));
}
- // Add the local data directory to PhysicsFS search path
- resman->addToSearchPath(mLocalDataDir, false);
-
- // Add the main data directories to our PhysicsFS search path
- if (!options.dataPath.empty())
- resman->addToSearchPath(options.dataPath, true);
- resman->addToSearchPath("data", true);
#if defined __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
@@ -267,10 +260,40 @@ Client::Client(const Options &options):
}
CFRelease(resourcesURL);
strncat(path, "/data", PATH_MAX - 1);
- resman->addToSearchPath(path, true);
+ resman->addToSearchPath(path, false);
+ mPackageDir = path;
+#else
+ resman->addToSearchPath(PKG_DATADIR "data", false);
+ mPackageDir = PKG_DATADIR "data";
+#endif
+
+ resman->addToSearchPath("data", false);
+
+ // Add branding/data to PhysFS search path
+ if (!options.brandingPath.empty())
+ {
+ std::string path = options.brandingPath;
+
+ // Strip blah.mana from the path
+#ifdef WIN32
+ int loc1 = path.find_last_of('/');
+ int loc2 = path.find_last_of('\\');
+ int loc = std::max(loc1, loc2);
#else
- resman->addToSearchPath(PKG_DATADIR "data", true);
+ int loc = path.find_last_of('/');
#endif
+ if (loc > 0)
+ path = path.substr(0, loc + 1);
+
+ resman->addToSearchPath(path + "data", false);
+ }
+
+ // Add the main data directories to our PhysicsFS search path
+ if (!options.dataPath.empty())
+ resman->addToSearchPath(options.dataPath, false);
+
+ // Add the local data directory to PhysicsFS search path
+ resman->addToSearchPath(mLocalDataDir, false);
#ifdef WIN32
static SDL_SysWMinfo pInfo;
@@ -319,6 +342,8 @@ Client::Client(const Options &options):
// Initialize for drawing
graphics->_beginDraw();
+ SkinLoader::prepareThemePath();
+
// Initialize the item shortcuts.
itemShortcut = new ItemShortcut;
diff --git a/src/client.h b/src/client.h
index 934ba9d2..233ee646 100644
--- a/src/client.h
+++ b/src/client.h
@@ -165,6 +165,9 @@ public:
static State getState()
{ return instance()->mState; }
+ static const std::string &getPackageDirectory()
+ { return instance()->mPackageDir; }
+
static const std::string &getConfigDirectory()
{ return instance()->mConfigDir; }
@@ -189,6 +192,7 @@ private:
Options mOptions;
+ std::string mPackageDir;
std::string mConfigDir;
std::string mLocalDataDir;
std::string mUpdateHost;
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 2711161e..e0c0a409 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -29,10 +29,11 @@
#include "localplayer.h"
#include "log.h"
+#include "gui/skin.h"
+
#include "resources/emotedb.h"
#include "resources/image.h"
#include "resources/iteminfo.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -56,8 +57,7 @@ EmotePopup::EmotePopup():
mEmotes.push_back(EmoteDB::getAnimation(i));
}
- ResourceManager *resman = ResourceManager::getInstance();
- mSelectionImage = resman->getImage("graphics/gui/selection.png");
+ mSelectionImage = SkinLoader::getImageFromTheme("selection.png");
if (!mSelectionImage)
logger->error("Unable to load selection.png");
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index e82a33b9..bc3eb675 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -209,9 +209,8 @@ void Gui::setUseCustomCursor(bool customCursor)
SDL_ShowCursor(SDL_DISABLE);
// Load the mouse cursor
- ResourceManager *resman = ResourceManager::getInstance();
- mMouseCursors =
- resman->getImageSet("graphics/gui/mouse.png", 40, 40);
+ mMouseCursors = SkinLoader::getImageSetFromTheme("mouse.png",
+ 40, 40);
if (!mMouseCursors)
logger->error("Unable to load mouse cursors.");
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 78c5c998..d53a1867 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -25,6 +25,7 @@
#include "log.h"
#include "gui/setup.h"
+#include "gui/skin.h"
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
@@ -85,7 +86,7 @@ struct SkillInfo
}
else
{
- icon = res->getImage("graphics/gui/unknown-item.png");
+ icon = SkinLoader::getImageFromTheme("unknown-item.png");
}
}
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index a682bf8f..22153720 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -23,22 +23,26 @@
#include "gui/skin.h"
+#include "client.h"
#include "configuration.h"
#include "configlistener.h"
#include "log.h"
#include "resources/image.h"
+#include "resources/imageset.h"
#include "resources/resourcemanager.h"
#include "utils/dtor.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
+#include <physfs.h>
+
#include <algorithm>
+std::string SkinLoader::mThemePath;
SkinLoader *SkinLoader::mInstance = 0;
-
class SkinConfigListener : public ConfigListener
{
public:
@@ -197,7 +201,7 @@ Skin *SkinLoader::readSkin(const std::string &filename)
logger->log("Loading skin '%s'.", filename.c_str());
- XML::Document doc(filename);
+ XML::Document doc(resolveThemePath(filename));
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset"))
@@ -215,8 +219,7 @@ Skin *SkinLoader::readSkin(const std::string &filename)
logger->log("SkinLoader::load(): <skinset> defines "
"'%s' as a skin image.", skinSetImage.c_str());
- ResourceManager *resman = ResourceManager::getInstance();
- Image *dBorders = resman->getImage("graphics/gui/" + skinSetImage);
+ Image *dBorders = SkinLoader::getImageFromTheme(skinSetImage);
ImageRect border;
// iterate <widget>'s
@@ -286,8 +289,8 @@ Skin *SkinLoader::readSkin(const std::string &filename)
logger->log("Finished loading skin.");
// Hard-coded for now until we update the above code to look for window buttons
- Image *closeImage = resman->getImage("graphics/gui/close_button.png");
- Image *sticky = resman->getImage("graphics/gui/sticky_button.png");
+ Image *closeImage = SkinLoader::getImageFromTheme("close_button.png");
+ Image *sticky = SkinLoader::getImageFromTheme("sticky_button.png");
Image *stickyImageUp = sticky->getSubImage(0, 0, 15, 15);
Image *stickyImageDown = sticky->getSubImage(15, 0, 15, 15);
sticky->decRef();
@@ -297,3 +300,68 @@ Skin *SkinLoader::readSkin(const std::string &filename)
skin->updateAlpha(mMinimumOpacity);
return skin;
}
+
+bool SkinLoader::tryThemePath(std::string themePath)
+{
+ if (!themePath.empty())
+ {
+ themePath = "graphics/gui/" + themePath;
+ if (PHYSFS_exists(themePath.c_str()))
+ {
+ mThemePath = themePath;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void SkinLoader::prepareThemePath()
+{
+ // Try theme from settings
+ if (tryThemePath(config.getValue("theme", "")))
+ return;
+
+ // Try theme from branding
+ if (tryThemePath(branding.getValue("theme", "")))
+ return;
+
+ // Use default
+ mThemePath = "graphics/gui";
+}
+
+std::string SkinLoader::resolveThemePath(const std::string &path)
+{
+ // Need to strip off any dye info for the existence tests
+ int pos = path.find('|');
+ std::string file;
+ if (pos > 0)
+ file = path.substr(0, pos);
+ else
+ file = path;
+
+ // Might be a valid path already
+ if (PHYSFS_exists(file.c_str()))
+ return path;
+
+ // Try the theme
+ file = getThemePath() + "/" + file;
+ if (PHYSFS_exists(file.c_str()))
+ return getThemePath() + "/" + path;
+
+ // Backup
+ return "graphics/gui/" + path;
+}
+
+Image *SkinLoader::getImageFromTheme(const std::string &path)
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ return resman->getImage(resolveThemePath(path));
+}
+
+ImageSet *SkinLoader::getImageSetFromTheme(const std::string &path,
+ int w, int h)
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ return resman->getImageSet(resolveThemePath(path), w, h);
+}
diff --git a/src/gui/skin.h b/src/gui/skin.h
index 15d55972..091d3001 100644
--- a/src/gui/skin.h
+++ b/src/gui/skin.h
@@ -31,6 +31,7 @@
class ConfigListener;
class Image;
+class ImageSet;
class Skin
{
@@ -101,11 +102,24 @@ class SkinLoader
static SkinLoader *instance();
static void deleteInstance();
+ static void prepareThemePath();
+ static std::string getThemePath() { return mThemePath; }
+
+ /**
+ * Returns the patch to the given gui resource relative to the theme
+ * or, if it isn't in the theme, relative to 'graphics/gui'.
+ */
+ static std::string resolveThemePath(const std::string &path);
+
+ static Image *getImageFromTheme(const std::string &path);
+ static ImageSet *getImageSetFromTheme(const std::string &path,
+ int w, int h);
+
/**
* Loads a skin.
*/
Skin *load(const std::string &filename,
- const std::string &defaultPath);
+ const std::string &defaultPath = getThemePath());
/**
* Updates the alpha values of all of the skins.
@@ -141,8 +155,11 @@ class SkinLoader
*/
ConfigListener *mSkinConfigListener;
+ static std::string mThemePath;
static SkinLoader *mInstance;
+ static bool tryThemePath(std::string themePath);
+
/**
* Tells if the current skins opacity
* should not get less than the given value
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 1513dcf1..3ca0f037 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -24,6 +24,7 @@
#include "log.h"
#include "gui/setup.h"
+#include "gui/skin.h"
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
@@ -219,7 +220,7 @@ SpecialEntry::SpecialEntry(SpecialInfo *info) :
if (!info->icon.empty())
mIcon = new Icon(info->icon);
else
- mIcon = new Icon("graphics/gui/unknown-item.png");
+ mIcon = new Icon(SkinLoader::resolveThemePath("unknown-item.png"));
mIcon->setPosition(1, 0);
add(mIcon);
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 3a87992b..f02965d1 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -25,6 +25,7 @@
#include "graphics.h"
#include "gui/gui.h"
+#include "gui/skin.h"
#include "gui/widgets/textbox.h"
@@ -33,7 +34,7 @@
#include <guichan/widgets/label.hpp>
SpeechBubble::SpeechBubble():
- Popup("Speech", "graphics/gui/speechbubble.xml")
+ Popup("Speech", "speechbubble.xml")
{
setContentSize(140, 46);
setMinWidth(29);
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index f5a9ea18..92386739 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -25,6 +25,7 @@
#include "gui/chat.h"
#include "gui/gui.h"
#include "gui/palette.h"
+#include "gui/skin.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
@@ -44,8 +45,8 @@ AvatarListBox::AvatarListBox(AvatarListModel *model):
if (instances == 1)
{
- onlineIcon = ResourceManager::getInstance()->getImage("graphics/gui/circle-green.png");
- offlineIcon = ResourceManager::getInstance()->getImage("graphics/gui/circle-gray.png");
+ onlineIcon = SkinLoader::getImageFromTheme("circle-green.png");
+ offlineIcon = SkinLoader::getImageFromTheme("circle-gray.png");
}
setWidth(200);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 6589c96e..36a47859 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -28,7 +28,6 @@
#include "gui/skin.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -54,10 +53,10 @@ struct ButtonData
};
static ButtonData const data[BUTTON_COUNT] = {
- { "graphics/gui/button.png", 0, 0 },
- { "graphics/gui/buttonhi.png", 9, 4 },
- { "graphics/gui/buttonpress.png", 16, 19 },
- { "graphics/gui/button_disabled.png", 25, 23 }
+ { "button.png", 0, 0 },
+ { "buttonhi.png", 9, 4 },
+ { "buttonpress.png", 16, 19 },
+ { "button_disabled.png", 25, 23 }
};
ImageRect Button::button[BUTTON_COUNT];
@@ -85,14 +84,13 @@ void Button::init()
if (mInstances == 0)
{
// Load the skin
- ResourceManager *resman = ResourceManager::getInstance();
Image *btn[BUTTON_COUNT];
int a, x, y, mode;
for (mode = 0; mode < BUTTON_COUNT; mode++)
{
- btn[mode] = resman->getImage(data[mode].file);
+ btn[mode] = SkinLoader::getImageFromTheme(data[mode].file);
a = 0;
for (y = 0; y < 3; y++)
{
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index dc6d94b3..d5253d7c 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -28,7 +28,6 @@
#include "gui/skin.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
int CheckBox::instances = 0;
float CheckBox::mAlpha = 1.0;
@@ -45,8 +44,7 @@ CheckBox::CheckBox(const std::string &caption, bool selected):
{
if (instances == 0)
{
- ResourceManager *resman = ResourceManager::getInstance();
- Image *checkBox = resman->getImage("graphics/gui/checkbox.png");
+ Image *checkBox = SkinLoader::getImageFromTheme("checkbox.png");
checkBoxNormal = checkBox->getSubImage(0, 0, 9, 10);
checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10);
checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10);
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 32b42553..eb0cdef2 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -32,7 +32,6 @@
#include "gui/widgets/scrollarea.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -54,17 +53,16 @@ DropDown::DropDown(gcn::ListModel *listModel):
if (instances == 0)
{
// Load the background skin
- ResourceManager *resman = ResourceManager::getInstance();
// Get the button skin
buttons[1][0] =
- resman->getImage("graphics/gui/vscroll_up_default.png");
+ SkinLoader::getImageFromTheme("vscroll_up_default.png");
buttons[0][0] =
- resman->getImage("graphics/gui/vscroll_down_default.png");
+ SkinLoader::getImageFromTheme("vscroll_down_default.png");
buttons[1][1] =
- resman->getImage("graphics/gui/vscroll_up_pressed.png");
+ SkinLoader::getImageFromTheme("vscroll_up_pressed.png");
buttons[0][1] =
- resman->getImage("graphics/gui/vscroll_down_pressed.png");
+ SkinLoader::getImageFromTheme("vscroll_down_pressed.png");
buttons[0][0]->setAlpha(mAlpha);
buttons[0][1]->setAlpha(mAlpha);
@@ -72,7 +70,7 @@ DropDown::DropDown(gcn::ListModel *listModel):
buttons[1][1]->setAlpha(mAlpha);
// get the border skin
- Image *boxBorder = resman->getImage("graphics/gui/deepbox.png");
+ Image *boxBorder = SkinLoader::getImageFromTheme("deepbox.png");
int gridx[4] = {0, 3, 28, 31};
int gridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 41be172f..dd13c679 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -32,10 +32,10 @@
#include "log.h"
#include "gui/palette.h"
+#include "gui/skin.h"
#include "resources/emotedb.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -49,9 +49,7 @@ EmoteShortcutContainer::EmoteShortcutContainer():
addMouseListener(this);
addWidgetListener(this);
- ResourceManager *resman = ResourceManager::getInstance();
-
- mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
+ mBackgroundImg = SkinLoader::getImageFromTheme("item_shortcut_bgr.png");
mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index f801822c..b4270912 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -32,6 +32,7 @@
#include "gui/outfitwindow.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
+#include "gui/skin.h"
#include "gui/viewport.h"
#include "net/net.h"
@@ -39,7 +40,6 @@
#include "resources/image.h"
#include "resources/iteminfo.h"
-#include "resources/resourcemanager.h"
#include "utils/stringutils.h"
@@ -67,9 +67,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mItemPopup = new ItemPopup;
setFocusable(true);
- ResourceManager *resman = ResourceManager::getInstance();
-
- mSelImg = resman->getImage("graphics/gui/selection.png");
+ mSelImg = SkinLoader::getImageFromTheme("selection.png");
if (!mSelImg)
logger->error("Unable to load selection.png");
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 66e053d8..92a3e7d0 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -32,11 +32,11 @@
#include "gui/inventorywindow.h"
#include "gui/itempopup.h"
#include "gui/palette.h"
+#include "gui/skin.h"
#include "gui/viewport.h"
#include "resources/image.h"
#include "resources/iteminfo.h"
-#include "resources/resourcemanager.h"
#include "utils/stringutils.h"
@@ -50,9 +50,7 @@ ItemShortcutContainer::ItemShortcutContainer():
mItemPopup = new ItemPopup;
- ResourceManager *resman = ResourceManager::getInstance();
-
- mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
+ mBackgroundImg = SkinLoader::getImageFromTheme("item_shortcut_bgr.png");
mMaxItems = itemShortcut->getItemCount();
mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 23da2afd..24395db7 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -26,8 +26,9 @@
#include "graphics.h"
#include "player.h"
+#include "gui/skin.h"
+
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -43,8 +44,7 @@ PlayerBox::PlayerBox(const Player *player):
if (instances == 0)
{
// Load the background skin
- ResourceManager *resman = ResourceManager::getInstance();
- Image *textbox = resman->getImage("graphics/gui/deepbox.png");
+ Image *textbox = SkinLoader::getImageFromTheme("deepbox.png");
int bggridx[4] = {0, 3, 28, 31};
int bggridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 449c2f7b..d63b59ca 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -55,7 +55,7 @@ class Popup : public Container
* @param skin The location where the Popup's skin XML can be found.
*/
Popup(const std::string &name = "",
- const std::string &skin = "graphics/gui/gui.xml");
+ const std::string &skin = "gui.xml");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index db2a8692..31c32132 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -30,7 +30,6 @@
#include "gui/skin.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -59,8 +58,7 @@ ProgressBar::ProgressBar(float progress,
if (mInstances == 0)
{
- ResourceManager *resman = ResourceManager::getInstance();
- Image *dBorders = resman->getImage("graphics/gui/vscroll_grey.png");
+ Image *dBorders = SkinLoader::getImageFromTheme("vscroll_grey.png");
mBorder.grid[0] = dBorders->getSubImage(0, 0, 4, 4);
mBorder.grid[1] = dBorders->getSubImage(4, 0, 3, 4);
mBorder.grid[2] = dBorders->getSubImage(7, 0, 4, 4);
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index d1b6bb87..f88f6045 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -20,6 +20,8 @@
#include "progressindicator.h"
+#include "gui/skin.h"
+
#include "resources/animation.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
@@ -31,9 +33,8 @@
ProgressIndicator::ProgressIndicator()
{
- ResourceManager *rm = ResourceManager::getInstance();
- ImageSet *images = rm->getImageSet("graphics/gui/progress-indicator.png",
- 32, 32);
+ ImageSet *images =
+ SkinLoader::getImageSetFromTheme("progress-indicator.png", 32, 32);
Animation *anim = new Animation;
for (ImageSet::size_type i = 0; i < images->size(); ++i)
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index adbc4dd7..41c8faf7 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -24,8 +24,9 @@
#include "configuration.h"
#include "graphics.h"
+#include "gui/skin.h"
+
#include "resources/image.h"
-#include "resources/resourcemanager.h"
int RadioButton::instances = 0;
float RadioButton::mAlpha = 1.0;
@@ -43,13 +44,12 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group,
{
if (instances == 0)
{
- ResourceManager *resman = ResourceManager::getInstance();
- radioNormal = resman->getImage("graphics/gui/radioout.png");
- radioChecked = resman->getImage("graphics/gui/radioin.png");
- radioDisabled = resman->getImage("graphics/gui/radioout.png");
- radioDisabledChecked = resman->getImage("graphics/gui/radioin.png");
- radioNormalHi = resman->getImage("graphics/gui/radioout_highlight.png");
- radioCheckedHi = resman->getImage("graphics/gui/radioin_highlight.png");
+ radioNormal = SkinLoader::getImageFromTheme("radioout.png");
+ radioChecked = SkinLoader::getImageFromTheme("radioin.png");
+ radioDisabled = SkinLoader::getImageFromTheme("radioout.png");
+ radioDisabledChecked = SkinLoader::getImageFromTheme("radioin.png");
+ radioNormalHi = SkinLoader::getImageFromTheme("radioout_highlight.png");
+ radioCheckedHi = SkinLoader::getImageFromTheme("radioin_highlight.png");
radioNormal->setAlpha(mAlpha);
radioChecked->setAlpha(mAlpha);
radioDisabled->setAlpha(mAlpha);
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index 106118da..d0b9b845 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -24,8 +24,9 @@
#include "configuration.h"
#include "graphics.h"
+#include "gui/skin.h"
+
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include <guichan/graphics.hpp>
@@ -38,8 +39,7 @@ ResizeGrip::ResizeGrip(const std::string &image)
if (mInstances == 0)
{
// Load the grip image
- ResourceManager *resman = ResourceManager::getInstance();
- gripImage = resman->getImage(image);
+ gripImage = SkinLoader::getImageFromTheme(image);
gripImage->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h
index 4cc195cc..5ef93f29 100644
--- a/src/gui/widgets/resizegrip.h
+++ b/src/gui/widgets/resizegrip.h
@@ -39,7 +39,7 @@ class ResizeGrip : public gcn::Widget
/**
* Constructor.
*/
- ResizeGrip(const std::string &image = "graphics/gui/resize.png");
+ ResizeGrip(const std::string &image = "resize.png");
/**
* Destructor.
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index b3e28329..dea99e8e 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -27,7 +27,6 @@
#include "gui/skin.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -96,8 +95,7 @@ void ScrollArea::init()
if (instances == 0)
{
// Load the background skin
- ResourceManager *resman = ResourceManager::getInstance();
- Image *textbox = resman->getImage("graphics/gui/deepbox.png");
+ Image *textbox = SkinLoader::getImageFromTheme("deepbox.png");
const int bggridx[4] = {0, 3, 28, 31};
const int bggridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
@@ -118,8 +116,8 @@ void ScrollArea::init()
textbox->decRef();
// Load vertical scrollbar skin
- Image *vscroll = resman->getImage("graphics/gui/vscroll_grey.png");
- Image *vscrollHi = resman->getImage("graphics/gui/vscroll_highlight.png");
+ Image *vscroll = SkinLoader::getImageFromTheme("vscroll_grey.png");
+ Image *vscrollHi = SkinLoader::getImageFromTheme("vscroll_highlight.png");
int vsgridx[4] = {0, 4, 7, 11};
int vsgridy[4] = {0, 4, 15, 19};
@@ -147,21 +145,21 @@ void ScrollArea::init()
vscrollHi->decRef();
buttons[UP][0] =
- resman->getImage("graphics/gui/vscroll_up_default.png");
+ SkinLoader::getImageFromTheme("vscroll_up_default.png");
buttons[DOWN][0] =
- resman->getImage("graphics/gui/vscroll_down_default.png");
+ SkinLoader::getImageFromTheme("vscroll_down_default.png");
buttons[LEFT][0] =
- resman->getImage("graphics/gui/hscroll_left_default.png");
+ SkinLoader::getImageFromTheme("hscroll_left_default.png");
buttons[RIGHT][0] =
- resman->getImage("graphics/gui/hscroll_right_default.png");
+ SkinLoader::getImageFromTheme("hscroll_right_default.png");
buttons[UP][1] =
- resman->getImage("graphics/gui/vscroll_up_pressed.png");
+ SkinLoader::getImageFromTheme("vscroll_up_pressed.png");
buttons[DOWN][1] =
- resman->getImage("graphics/gui/vscroll_down_pressed.png");
+ SkinLoader::getImageFromTheme("vscroll_down_pressed.png");
buttons[LEFT][1] =
- resman->getImage("graphics/gui/hscroll_left_pressed.png");
+ SkinLoader::getImageFromTheme("hscroll_left_pressed.png");
buttons[RIGHT][1] =
- resman->getImage("graphics/gui/hscroll_right_pressed.png");
+ SkinLoader::getImageFromTheme("hscroll_right_pressed.png");
}
instances++;
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index f02c6b5c..af36518a 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -27,7 +27,6 @@
#include "gui/skin.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
Image *Slider::hStart, *Slider::hMid, *Slider::hEnd, *Slider::hGrip;
Image *Slider::vStart, *Slider::vMid, *Slider::vEnd, *Slider::vGrip;
@@ -83,9 +82,8 @@ void Slider::init()
// Load resources
if (mInstances == 0)
{
- ResourceManager *resman = ResourceManager::getInstance();
- Image *slider = resman->getImage("graphics/gui/slider.png");
- Image *sliderHi = resman->getImage("graphics/gui/slider_hilight.png");
+ Image *slider = SkinLoader::getImageFromTheme("slider.png");
+ Image *sliderHi = SkinLoader::getImageFromTheme("slider_hilight.png");
x = 0; y = 0;
w = 15; h = 6;
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 68dc2190..17145eae 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -30,7 +30,6 @@
#include "gui/widgets/tabbedarea.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/dtor.h"
@@ -55,10 +54,10 @@ struct TabData
};
static TabData const data[TAB_COUNT] = {
- { "graphics/gui/tab.png", 0, 0 },
- { "graphics/gui/tab_hilight.png", 9, 4 },
- { "graphics/gui/tabselected.png", 16, 19 },
- { "graphics/gui/tab.png", 25, 23 }
+ { "tab.png", 0, 0 },
+ { "tab_hilight.png", 9, 4 },
+ { "tabselected.png", 16, 19 },
+ { "tab.png", 25, 23 }
};
ImageRect Tab::tabImg[TAB_COUNT];
@@ -91,14 +90,13 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- ResourceManager *resman = ResourceManager::getInstance();
Image *tab[TAB_COUNT];
int a, x, y, mode;
for (mode = 0; mode < TAB_COUNT; mode++)
{
- tab[mode] = resman->getImage(data[mode].file);
+ tab[mode] = SkinLoader::getImageFromTheme(data[mode].file);
a = 0;
for (y = 0; y < 3; y++)
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 278b4cb9..e599c37d 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -29,7 +29,6 @@
#include "gui/skin.h"
#include "resources/image.h"
-#include "resources/resourcemanager.h"
#include "utils/copynpaste.h"
#include "utils/dtor.h"
@@ -53,8 +52,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab):
if (instances == 0)
{
// Load the skin
- ResourceManager *resman = ResourceManager::getInstance();
- Image *textbox = resman->getImage("graphics/gui/deepbox.png");
+ Image *textbox = SkinLoader::getImageFromTheme("deepbox.png");
int gridx[4] = {0, 3, 28, 31};
int gridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index a54016bc..fd7fd6b7 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -57,7 +57,7 @@ class Window : public gcn::Window, gcn::WidgetListener
* @param skin The location where the window's skin XML can be found.
*/
Window(const std::string &caption = "Window", bool modal = false,
- Window *parent = NULL, const std::string &skin = "graphics/gui/gui.xml");
+ Window *parent = NULL, const std::string &skin = "gui.xml");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/item.cpp b/src/item.cpp
index e20ef57a..378c7efe 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -21,6 +21,8 @@
#include "item.h"
+#include "gui/skin.h"
+
#include "resources/image.h"
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
@@ -60,8 +62,8 @@ void Item::setId(int id)
mDrawImage = resman->getImage(imagePath);
if (!mImage)
- mImage = resman->getImage("graphics/gui/unknown-item.png");
+ mImage = SkinLoader::getImageFromTheme("unknown-item.png");
if (!mDrawImage)
- mDrawImage = resman->getImage("graphics/gui/unknown-item.png");
+ mDrawImage = SkinLoader::getImageFromTheme("unknown-item.png");
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 8ce03bba..750c8c45 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -43,6 +43,7 @@
#include "gui/ministatus.h"
#include "gui/palette.h"
#include "gui/skilldialog.h"
+#include "gui/skin.h"
#include "gui/statuswindow.h"
#include "gui/storagewindow.h"
@@ -1050,18 +1051,12 @@ void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId)
void LocalPlayer::initTargetCursor()
{
// Load target cursors
- loadTargetCursor("graphics/gui/target-cursor-blue-s.png", 44, 35,
- false, TC_SMALL);
- loadTargetCursor("graphics/gui/target-cursor-red-s.png", 44, 35,
- true, TC_SMALL);
- loadTargetCursor("graphics/gui/target-cursor-blue-m.png", 62, 44,
- false, TC_MEDIUM);
- loadTargetCursor("graphics/gui/target-cursor-red-m.png", 62, 44,
- true, TC_MEDIUM);
- loadTargetCursor("graphics/gui/target-cursor-blue-l.png", 82, 60,
- false, TC_LARGE);
- loadTargetCursor("graphics/gui/target-cursor-red-l.png", 82, 60,
- true, TC_LARGE);
+ loadTargetCursor("target-cursor-blue-s.png", 44, 35, false, TC_SMALL);
+ loadTargetCursor("target-cursor-red-s.png", 44, 35, true, TC_SMALL);
+ loadTargetCursor("target-cursor-blue-m.png", 62, 44, false, TC_MEDIUM);
+ loadTargetCursor("target-cursor-red-m.png", 62, 44, true, TC_MEDIUM);
+ loadTargetCursor("target-cursor-blue-l.png", 82, 60, false, TC_LARGE);
+ loadTargetCursor("target-cursor-red-l.png", 82, 60, true, TC_LARGE);
}
void LocalPlayer::loadTargetCursor(const std::string &filename,
@@ -1071,9 +1066,8 @@ void LocalPlayer::loadTargetCursor(const std::string &filename,
assert(size > -1);
assert(size < 3);
- ResourceManager *resman = ResourceManager::getInstance();
-
- ImageSet *currentImageSet = resman->getImageSet(filename, width, height);
+ ImageSet *currentImageSet = SkinLoader::getImageSetFromTheme(filename,
+ width, height);
Animation *anim = new Animation;
for (unsigned int i = 0; i < currentImageSet->size(); ++i)
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 8b5ecca3..24f346f7 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -21,6 +21,7 @@
#include "resources/resourcemanager.h"
+#include "client.h"
#include "log.h"
#include "resources/dye.h"
@@ -211,7 +212,7 @@ std::string ResourceManager::getPath(const std::string &file)
else
{
// if not found in search path return the default path
- path = std::string(PKG_DATADIR) + std::string("data") + "/" + file;
+ path = Client::getPackageDirectory() + "/" + file;
}
return path;
diff --git a/src/text.cpp b/src/text.cpp
index 0b6b77ea..ce09146f 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -28,6 +28,7 @@
#include "gui/gui.h"
#include "gui/palette.h"
+#include "gui/skin.h"
#include "resources/resourcemanager.h"
#include "resources/image.h"
@@ -49,8 +50,7 @@ Text::Text(const std::string &text, int x, int y,
if (textManager == 0)
{
textManager = new TextManager;
- ResourceManager *resman = ResourceManager::getInstance();
- Image *sbImage = resman->getImage("graphics/gui/bubble.png|W:#"
+ Image *sbImage = SkinLoader::getImageFromTheme("bubble.png|W:#"
+ config.getValue("speechBubblecolor", "000000"));
mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5);
mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5);