summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp3
-rw-r--r--src/being.h8
-rw-r--r--src/client.cpp4
-rw-r--r--src/configuration.cpp25
-rw-r--r--src/configuration.h8
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/gui.cpp1
-rw-r--r--src/gui/help.cpp6
-rw-r--r--src/gui/itempopup.cpp4
-rw-r--r--src/gui/theme.cpp30
-rw-r--r--src/item.cpp11
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/monster.cpp8
-rw-r--r--src/net/manaserv/beinghandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp6
-rw-r--r--src/npc.cpp4
-rw-r--r--src/player.cpp10
-rw-r--r--src/resources/emotedb.cpp10
-rw-r--r--src/resources/itemdb.cpp6
-rw-r--r--src/resources/iteminfo.cpp3
-rw-r--r--src/resources/mapreader.cpp5
-rw-r--r--src/resources/monsterdb.cpp3
-rw-r--r--src/resources/monsterinfo.cpp4
-rw-r--r--src/resources/npcdb.cpp4
-rw-r--r--src/resources/spritedef.cpp12
-rw-r--r--src/resources/wallpaper.cpp46
-rw-r--r--src/resources/wallpaper.h2
-rw-r--r--src/sound.cpp9
-rw-r--r--src/statuseffect.cpp7
29 files changed, 176 insertions, 72 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 5c737c0c..d2dfc855 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1022,7 +1022,8 @@ void Being::load()
// we can go.
int hairstyles = 1;
- while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) != "error.xml")
+ while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) !=
+ paths.getValue("spriteErrorFile", "error.xml"))
hairstyles++;
mNumberOfHairstyles = hairstyles;
diff --git a/src/being.h b/src/being.h
index 3d3dfa71..71b3e2cf 100644
--- a/src/being.h
+++ b/src/being.h
@@ -113,7 +113,13 @@ class Being : public Sprite, public ConfigListener
/**
* Directions, to be used as bitmask values
*/
- enum { DOWN = 1, LEFT = 2, UP = 4, RIGHT = 8 };
+ enum BeingDirection
+ {
+ DOWN = 1,
+ LEFT = 2,
+ UP = 4,
+ RIGHT = 8
+ };
/**
* Constructor.
diff --git a/src/client.cpp b/src/client.cpp
index 4b6d3744..ac10112e 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -109,6 +109,7 @@ LoginData loginData;
Configuration config; /**< XML file configuration reader */
Configuration branding; /**< XML branding information reader */
+Configuration paths; /**< XML default paths information reader */
Logger *logger; /**< Log object */
KeyboardConfig keyboard;
@@ -727,6 +728,9 @@ int Client::exec()
false);
}
+ // Read default paths file 'data/paths.xml'
+ paths.init("paths.xml", true);
+
// Load XML databases
ColorDB::load();
ItemDB::load();
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 1310d642..cd31fed7 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -137,33 +137,30 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
}
}
-void Configuration::init(const std::string &filename)
+void Configuration::init(const std::string &filename, bool useResManager)
{
- mConfigPath = filename;
+ XML::Document doc(filename, useResManager);
- // Do not attempt to read config from non-existant file
- FILE *testFile = fopen(filename.c_str(), "r");
- if (!testFile)
+ if (!doc.rootNode())
+ {
+ logger->log("Couldn't open configuration file: %s", filename.c_str());
return;
- else
- fclose(testFile);
-
- xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
+ }
- if (!doc) return;
+ if (useResManager)
+ mConfigPath = "PhysFS://" + filename;
+ else
+ mConfigPath = filename;
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
+ xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration"))
{
logger->log("Warning: No configuration file (%s)", filename.c_str());
- xmlFreeDoc(doc);
return;
}
initFromXML(rootNode);
-
- xmlFreeDoc(doc);
}
void ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
diff --git a/src/configuration.h b/src/configuration.h
index a0c896a5..908d13a4 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -197,9 +197,10 @@ class Configuration : public ConfigurationObject
/**
* Reads config file and parse all options into memory.
*
- * \param filename path to config file
+ * @param filename path to config file
+ * @param useResManager Make use of the resource manager.
*/
- void init(const std::string &filename);
+ void init(const std::string &filename, bool useResManager = false);
/**
* Writes the current settings back to the config file.
@@ -244,10 +245,11 @@ class Configuration : public ConfigurationObject
typedef ListenerMap::iterator ListenerMapIterator;
ListenerMap mListenerMap;
- std::string mConfigPath; /**< Location of config file */
+ std::string mConfigPath; /**< Location of config file */
};
extern Configuration branding;
extern Configuration config;
+extern Configuration paths;
#endif
diff --git a/src/game.cpp b/src/game.cpp
index 79f21863..ec5e6b13 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -928,7 +928,8 @@ void Game::changeMap(const std::string &mapPath)
mMapName = mapPath;
- std::string fullMap = "maps/" + mapPath + ".tmx";
+ std::string fullMap = paths.getValue("maps", "maps/")
+ + mMapName + ".tmx";
ResourceManager *resman = ResourceManager::getInstance();
if (!resman->exists(fullMap))
fullMap += ".gz";
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index e2354386..df2ddadf 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -107,6 +107,7 @@ Gui::Gui(Graphics *graphics):
const int fontSize = (int) config.getValue("fontSize", 11);
std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
std::string path = resman->getPath(fontFile);
+
try
{
mGuiFont = new TrueTypeFont(path, fontSize);
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 9d237f18..f3c6a0af 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/scrollarea.h"
#include "resources/resourcemanager.h"
+#include "configuration.h"
#include "utils/gettext.h"
@@ -93,8 +94,11 @@ void HelpWindow::loadHelp(const std::string &helpFile)
void HelpWindow::loadFile(const std::string &file)
{
ResourceManager *resman = ResourceManager::getInstance();
+ std::string helpPath = branding.getValue("helpPath", "");
+ if (helpPath.empty())
+ helpPath = paths.getValue("help", "help/");
std::vector<std::string> lines =
- resman->loadTextFile("help/" + file + ".txt");
+ resman->loadTextFile(helpPath + file + ".txt");
for (unsigned int i = 0; i < lines.size(); ++i)
{
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 2618810b..0cde9395 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -102,7 +102,9 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
if (showImage)
{
ResourceManager *resman = ResourceManager::getInstance();
- Image *image = resman->getImage("graphics/items/" + item.getImageName());
+ Image *image = resman->getImage(
+ paths.getValue("itemIcons", "graphics/items/")
+ + item.getImageName());
mIcon->setImage(image);
if (image)
{
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index e46616e0..12de1f91 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -40,11 +40,22 @@
#include <algorithm>
-#define GUI_ROOT "graphics/gui/"
-
+static std::string defaultThemePath;
std::string Theme::mThemePath;
Theme *Theme::mInstance = 0;
+// Set the theme path...
+static void initDefaultThemePath()
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ defaultThemePath = branding.getValue("guiThemePath", "");
+
+ if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath))
+ return;
+ else
+ defaultThemePath = "graphics/gui/";
+}
+
Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
const std::string &filePath,
const std::string &name):
@@ -55,8 +66,7 @@ Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
mCloseImage(close),
mStickyImageUp(stickyUp),
mStickyImageDown(stickyDown)
-{
-}
+{}
Skin::~Skin()
{
@@ -99,6 +109,8 @@ Theme::Theme():
mMinimumOpacity(-1.0f),
mProgressColors(ProgressColors(THEME_PROG_END))
{
+ initDefaultThemePath();
+
config.addListener("guialpha", this);
loadColors();
@@ -313,7 +325,7 @@ bool Theme::tryThemePath(std::string themePath)
{
if (!themePath.empty())
{
- themePath = GUI_ROOT + themePath;
+ themePath = defaultThemePath + themePath;
if (PHYSFS_exists(themePath.c_str()))
{
mThemePath = themePath;
@@ -331,7 +343,7 @@ void Theme::prepareThemePath()
// Try theme from branding
if (!tryThemePath(branding.getValue("theme", "")))
// Use default
- mThemePath = GUI_ROOT;
+ mThemePath = defaultThemePath;
instance()->loadColors(mThemePath);
}
@@ -356,7 +368,7 @@ std::string Theme::resolveThemePath(const std::string &path)
return getThemePath() + "/" + path;
// Backup
- return std::string(GUI_ROOT) + "/" + path;
+ return std::string(defaultThemePath) + "/" + path;
}
Image *Theme::getImageFromTheme(const std::string &path)
@@ -508,11 +520,11 @@ static int readProgressType(const std::string &type)
void Theme::loadColors(std::string file)
{
- if (file == GUI_ROOT)
+ if (file == defaultThemePath)
return; // No need to reload
if (file == "")
- file = GUI_ROOT;
+ file = defaultThemePath;
file += "/colors.xml";
diff --git a/src/item.cpp b/src/item.cpp
index 79ccd2c3..b434387e 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -26,6 +26,7 @@
#include "resources/image.h"
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
+#include "configuration.h"
Item::Item(int id, int quantity, bool equipment, bool equipped):
mImage(0),
@@ -57,13 +58,17 @@ void Item::setId(int id)
mDrawImage->decRef();
ResourceManager *resman = ResourceManager::getInstance();
- std::string imagePath = "graphics/items/" + getInfo().getImageName();
+ std::string imagePath = paths.getValue("itemIcons", "graphics/items/")
+ + getInfo().getImageName();
mImage = resman->getImage(imagePath);
mDrawImage = resman->getImage(imagePath);
if (!mImage)
- mImage = Theme::getImageFromTheme("unknown-item.png");
+ mImage = Theme::getImageFromTheme(paths.getValue("unknownItemFile",
+ "unknown-item.png"));
if (!mDrawImage)
- mDrawImage = Theme::getImageFromTheme("unknown-item.png");
+ mDrawImage = Theme::getImageFromTheme(
+ paths.getValue("unknownItemFile",
+ "unknown-item.png"));
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index b06ea456..9c64c6dc 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -1035,9 +1035,7 @@ void LocalPlayer::attack(Being *target, bool keep)
sound.playSfx(soundFile);
}
else
- {
- sound.playSfx("sfx/fist-swish.ogg");
- }
+ sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg"));
Net::getPlayerHandler()->attack(target->getId());
if ((Net::getNetworkType() == ServerInfo::TMWATHENA) && !keep)
diff --git a/src/monster.cpp b/src/monster.cpp
index d25c6c90..ca156821 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -34,6 +34,7 @@
#include "resources/monsterdb.h"
#include "resources/monsterinfo.h"
+#include "configuration.h"
Monster::Monster(int id, int subtype, Map *map):
Being(id, subtype, map),
@@ -132,14 +133,17 @@ void Monster::setSubtype(Uint16 subtype)
for (std::list<std::string>::const_iterator i = sprites.begin();
i != sprites.end(); i++)
{
- std::string file = "graphics/sprites/" + *i;
+ std::string file = paths.getValue("sprites",
+ "graphics/sprites/") + *i;
mSprites.push_back(AnimatedSprite::load(file));
}
// Ensure that something is shown
if (mSprites.size() == 0)
{
- mSprites.push_back(AnimatedSprite::load("graphics/sprites/error.xml"));
+ mSprites.push_back(AnimatedSprite::load(
+ paths.getValue("sprites", "graphics/sprites/") +
+ paths.getValue("spriteErrorFile", "error.xml") ));
}
if (Particle::enabled)
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index b08af749..8df9a8ab 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -232,7 +232,7 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
}
if (speed)
{
- /**
+ /*
* The being's speed is transfered in tiles per second * 10
* to keep it transferable in a Byte.
* We set it back to tiles per second and in a float.
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index f6207800..2347fee2 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -29,6 +29,7 @@
#include "log.h"
#include "particle.h"
#include "npc.h"
+#include "configuration.h"
#include "gui/chat.h"
#include "gui/gui.h"
@@ -141,7 +142,10 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
player_node->setLevel(msg.readInt16());
player_node->setCharacterPoints(msg.readInt16());
player_node->setCorrectionPoints(msg.readInt16());
- Particle* effect = particleEngine->addEffect("graphics/particles/levelup.particle.xml", 0, 0);
+ Particle* effect = particleEngine->addEffect(
+ paths.getValue("particles", "graphics/particles/")
+ + paths.getValue("levelUpEffectFile", "levelup.particle.xml"),
+ 0, 0);
player_node->controlParticle(effect);
} break;
diff --git a/src/npc.cpp b/src/npc.cpp
index cdfe5193..a3c26618 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -36,6 +36,7 @@
#include "net/npchandler.h"
#include "resources/npcdb.h"
+#include "configuration.h"
NPC::NPC(int id, int subtype, Map *map):
Player(id, subtype, map, true)
@@ -68,7 +69,8 @@ void NPC::setSubtype(Uint16 subtype)
i != info.sprites.end();
i++)
{
- std::string file = "graphics/sprites/" + (*i)->sprite;
+ std::string file = paths.getValue("sprites",
+ "graphics/sprites/") + (*i)->sprite;
int variant = (*i)->variant;
mSprites.push_back(AnimatedSprite::load(file, variant));
mSpriteIDs.push_back(0);
diff --git a/src/player.cpp b/src/player.cpp
index 1f706cb8..e6102b6a 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -118,8 +118,10 @@ void Player::logic()
default: break;
}
Particle *p;
- p = particleEngine->addEffect("graphics/particles/" +
- particleEffect, 0, 0, rotation);
+ p = particleEngine->addEffect(
+ paths.getValue("particles",
+ "graphics/particles/")
+ + particleEffect, 0, 0, rotation);
controlParticle(p);
}
@@ -193,8 +195,8 @@ void Player::setSprite(int slot, int id, const std::string &color,
if (!color.empty())
filename += "|" + color;
- equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
- filename);
+ equipmentSprite = AnimatedSprite::load(
+ paths.getValue("sprites", "graphics/sprites/") + filename);
}
if (equipmentSprite)
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index fddab500..c24e760b 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -24,6 +24,7 @@
#include "log.h"
#include "utils/xml.h"
+#include "configuration.h"
namespace
{
@@ -41,7 +42,8 @@ void EmoteDB::load()
mLastEmote = 0;
EmoteSprite *unknownSprite = new EmoteSprite;
- unknownSprite->sprite = AnimatedSprite::load("error.xml");
+ unknownSprite->sprite = AnimatedSprite::load(
+ paths.getValue("spriteErrorFile", "error.xml") );
unknownSprite->name = "unknown";
mUnknown.sprites.push_back(unknownSprite);
@@ -76,8 +78,10 @@ void EmoteDB::load()
if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
{
EmoteSprite *currentSprite = new EmoteSprite;
- std::string file = "graphics/sprites/" + (std::string)
- (const char*) spriteNode->xmlChildrenNode->content;
+ std::string file = paths.getValue("sprites",
+ "graphics/sprites/")
+ + (std::string) (const char*)
+ spriteNode->xmlChildrenNode->content;
currentSprite->sprite = AnimatedSprite::load(file,
XML::getProperty(spriteNode, "variant", 0));
currentInfo->sprites.push_back(currentSprite);
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 077012c7..3fdee021 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -30,6 +30,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
+#include "configuration.h"
#include <libxml/tree.h>
@@ -115,8 +116,9 @@ void ItemDB::load()
mUnknown = new ItemInfo;
mUnknown->setName(_("Unknown item"));
mUnknown->setImageName("");
- mUnknown->setSprite("error.xml", GENDER_MALE);
- mUnknown->setSprite("error.xml", GENDER_FEMALE);
+ std::string errFile = paths.getValue("spriteErrorFile", "error.xml");
+ mUnknown->setSprite(errFile, GENDER_MALE);
+ mUnknown->setSprite(errFile, GENDER_FEMALE);
XML::Document doc("items.xml");
xmlNodePtr rootNode = doc.rootNode();
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 5fb1ff82..4b1d82ea 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -22,6 +22,7 @@
#include "resources/iteminfo.h"
#include "resources/itemdb.h"
+#include "configuration.h"
const std::string &ItemInfo::getSprite(Gender gender) const
{
@@ -68,7 +69,7 @@ void ItemInfo::setWeaponType(int type)
void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
{
- mSounds[event].push_back("sfx/" + filename);
+ mSounds[event].push_back(paths.getValue("sfx", "sfx/") + filename);
}
const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index e8a2bd20..a8582c9b 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -323,7 +323,10 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
if (config.getValue("showWarps", 1))
{
map->addParticleEffect(
- "graphics/particles/warparea.particle.xml",
+ paths.getValue("particles",
+ "graphics/particles/")
+ + paths.getValue("portalEffectFile",
+ "warparea.particle.xml"),
objX, objY, objW, objH);
}
}
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 5a796f5f..b08d87f2 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -30,6 +30,7 @@
#include "utils/xml.h"
#include "net/net.h"
+#include "configuration.h"
#define OLD_TMWATHENA_OFFSET 1002
@@ -45,7 +46,7 @@ void MonsterDB::load()
if (mLoaded)
unload();
- mUnknown.addSprite("error.xml");
+ mUnknown.addSprite(paths.getValue("spriteErrorFile", "error.xml"));
logger->log("Initializing monster database...");
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp
index 9104c721..12cdbe3e 100644
--- a/src/resources/monsterinfo.cpp
+++ b/src/resources/monsterinfo.cpp
@@ -23,6 +23,7 @@
#include "utils/dtor.h"
#include "utils/gettext.h"
+#include "configuration.h"
MonsterInfo::MonsterInfo():
mName(_("unnamed")),
@@ -45,7 +46,8 @@ void MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename)
mSounds[event] = new std::vector<std::string>;
}
- mSounds[event]->push_back("sfx/" + filename);
+ mSounds[event]->push_back(paths.getValue("sfx", "sfx/")
+ + filename);
}
const std::string &MonsterInfo::getSound(MonsterSoundEvent event) const
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index bc36a3b4..21a2e9a1 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -24,6 +24,7 @@
#include "log.h"
#include "utils/xml.h"
+#include "configuration.h"
namespace
{
@@ -38,7 +39,8 @@ void NPCDB::load()
unload();
NPCsprite *unknownSprite = new NPCsprite;
- unknownSprite->sprite = "error.xml";
+ unknownSprite->sprite = paths.getValue("spriteErrorFile",
+ "error.xml");
unknownSprite->variant = 0;
mUnknown.sprites.push_back(unknownSprite);
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 55b38546..c524c43c 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -30,6 +30,8 @@
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
+#include "configuration.h"
+
#include "utils/xml.h"
#include <set>
@@ -61,9 +63,12 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
{
logger->log("Error, failed to parse %s", animationFile.c_str());
- if (animationFile != "graphics/sprites/error.xml")
+ std::string errorFile = paths.getValue("sprites", "graphics/sprites")
+ + paths.getValue("spriteErrorFile",
+ "error.xml");
+ if (animationFile != errorFile)
{
- return load("graphics/sprites/error.xml", 0);
+ return load(errorFile, 0);
}
else
{
@@ -278,7 +283,8 @@ void SpriteDef::includeSprite(xmlNodePtr includeNode)
if (filename.empty())
return;
- XML::Document doc("graphics/sprites/" + filename);
+ XML::Document doc(paths.getValue("sprites", "graphics/sprites/")
+ + filename);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite"))
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index f57f429d..22bbda9c 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -21,9 +21,11 @@
#include "resources/wallpaper.h"
+#include "resources/resourcemanager.h"
#include "log.h"
#include "utils/stringutils.h"
+#include "configuration.h"
#include <physfs.h>
@@ -32,9 +34,6 @@
#include <time.h>
#include <vector>
-#define WALLPAPER_FOLDER "graphics/images/"
-#define WALLPAPER_BASE "login_wallpaper.png"
-
struct WallpaperData
{
std::string filename;
@@ -45,6 +44,37 @@ struct WallpaperData
static std::vector<WallpaperData> wallpaperData;
static bool haveBackup; // Is the backup (no size given) version available?
+static std::string wallpaperPath;
+static std::string wallpaperFile;
+
+// Search for the wallpaper path values sequentially..
+static void initDefaultWallpaperPaths()
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+
+ // Init the path
+ wallpaperPath = branding.getValue("wallpapersPath", "");
+
+ if (!wallpaperPath.empty() && resman->isDirectory(wallpaperPath))
+ return;
+ else
+ wallpaperPath = paths.getValue("wallpapers", "");
+
+ if (wallpaperPath.empty() || !resman->isDirectory(wallpaperPath))
+ wallpaperPath = "graphics/images/";
+
+ // Init the default file
+ wallpaperFile = branding.getValue("wallpaperFile", "");
+
+ if (!wallpaperFile.empty() && resman->isDirectory(wallpaperFile))
+ return;
+ else
+ wallpaperFile = paths.getValue("wallpaperFile", "");
+
+ if (wallpaperFile.empty() || !resman->isDirectory(wallpaperFile))
+ wallpaperFile = "login_wallpaper.png";
+}
+
bool wallpaperCompare(WallpaperData a, WallpaperData b)
{
int aa = a.width * a.height;
@@ -57,7 +87,9 @@ void Wallpaper::loadWallpapers()
{
wallpaperData.clear();
- char **imgs = PHYSFS_enumerateFiles(WALLPAPER_FOLDER);
+ initDefaultWallpaperPaths();
+
+ char **imgs = PHYSFS_enumerateFiles(wallpaperPath.c_str());
for (char **i = imgs; *i != NULL; i++)
{
@@ -65,7 +97,7 @@ void Wallpaper::loadWallpapers()
int height;
// If the backup file is found, we tell it.
- if (strncmp (*i, WALLPAPER_BASE, strlen(*i)) == 0)
+ if (strncmp (*i, wallpaperFile.c_str(), strlen(*i)) == 0)
haveBackup = true;
// If the image format is terminated by: "_<width>x<height>.png"
@@ -86,7 +118,7 @@ void Wallpaper::loadWallpapers()
if (sscanf(*i, filename.c_str(), &width, &height) == 2)
{
WallpaperData wp;
- wp.filename = WALLPAPER_FOLDER;
+ wp.filename = wallpaperPath;
wp.filename.append(*i);
wp.width = width;
wp.height = height;
@@ -132,7 +164,7 @@ std::string Wallpaper::getWallpaper(int width, int height)
// Return the backup file if everything else failed...
if (haveBackup)
- return std::string(WALLPAPER_FOLDER WALLPAPER_BASE);
+ return std::string(wallpaperPath + wallpaperFile);
// Return an empty string if everything else failed
return std::string();
diff --git a/src/resources/wallpaper.h b/src/resources/wallpaper.h
index 8ecb8542..bb640d1e 100644
--- a/src/resources/wallpaper.h
+++ b/src/resources/wallpaper.h
@@ -37,7 +37,7 @@ class Wallpaper
static void loadWallpapers();
/**
- * Returns the larget wallpaper for the given resolution, or the
+ * Returns the largest wallpaper for the given resolution, or the
* default wallpaper if none are found.
*
* @param width the desired width
diff --git a/src/sound.cpp b/src/sound.cpp
index 95860992..241e25e4 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -27,6 +27,8 @@
#include "resources/resourcemanager.h"
#include "resources/soundeffect.h"
+#include "configuration.h"
+
Sound::Sound():
mInstalled(false),
mSfxVolume(100),
@@ -149,7 +151,9 @@ static Mix_Music *loadMusic(const std::string &filename)
// it to a temporary physical file so that SDL_mixer can stream it.
logger->log("Loading music \"%s\" from temporary file tempMusic.ogg",
path.c_str());
- bool success = resman->copyFile("music/" + filename, "tempMusic.ogg");
+ bool success = resman->copyFile(
+ paths.getValue("music", "music/")
+ + filename, "tempMusic.ogg");
if (success)
path = resman->getPath("tempMusic.ogg");
else
@@ -235,7 +239,8 @@ void Sound::playSfx(const std::string &path)
return;
ResourceManager *resman = ResourceManager::getInstance();
- SoundEffect *sample = resman->getSoundEffect(path);
+ SoundEffect *sample = resman->getSoundEffect(
+ paths.getValue("sfx", "sfx/") + path);
if (sample)
{
logger->log("Sound::playSfx() Playing: %s", path.c_str());
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 6ab0b8fa..1f913f4a 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -28,6 +28,8 @@
#include "utils/xml.h"
+#include "configuration.h"
+
#include <map>
#define STATUS_EFFECTS_FILE "status-effects.xml"
@@ -68,7 +70,7 @@ AnimatedSprite *StatusEffect::getIcon()
else
{
AnimatedSprite *sprite = AnimatedSprite::load(
- "graphics/sprites/" + mIcon);
+ paths.getValue("sprites", "graphics/sprites/") + mIcon);
if (false && sprite)
{
sprite->play(ACTION_DEFAULT);
@@ -123,8 +125,7 @@ void StatusEffect::load()
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects"))
{
- logger->log("Error loading status effects file: "
- STATUS_EFFECTS_FILE);
+ logger->log("Error loading status effects file: " STATUS_EFFECTS_FILE);
return;
}