summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/graphics/sprites/CMakeLists.txt2
-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/chat.cpp25
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/gui.cpp1
-rw-r--r--src/gui/help.cpp6
-rw-r--r--src/gui/itempopup.cpp6
-rw-r--r--src/gui/theme.cpp30
-rw-r--r--src/gui/widgets/whispertab.cpp5
-rw-r--r--src/item.cpp11
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/map.cpp22
-rw-r--r--src/net/manaserv/beinghandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp6
-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.cpp2
-rw-r--r--src/resources/npcdb.cpp1
-rw-r--r--src/resources/spritedef.cpp17
-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
30 files changed, 192 insertions, 89 deletions
diff --git a/data/graphics/sprites/CMakeLists.txt b/data/graphics/sprites/CMakeLists.txt
index 1d98772d..db0c4087 100644
--- a/data/graphics/sprites/CMakeLists.txt
+++ b/data/graphics/sprites/CMakeLists.txt
@@ -3,4 +3,4 @@ SET(FILES
error.xml
)
-INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/graphics/sprits)
+INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/graphics/sprites)
diff --git a/src/being.cpp b/src/being.cpp
index 5583b8c2..56c2c69a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1153,7 +1153,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 75bb6c22..f06fd2bc 100644
--- a/src/being.h
+++ b/src/being.h
@@ -100,7 +100,13 @@ class Being : public ActorSprite, 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 fac3c5b7..b64f9a89 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -112,6 +112,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 */
ChatLogger *chatLogger; /**< Chat log object */
KeyboardConfig keyboard;
@@ -746,6 +747,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..d8b11034 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)
- return;
+ if (useResManager)
+ mConfigPath = "PhysFS://" + filename;
else
- fclose(testFile);
-
- xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
+ mConfigPath = filename;
- if (!doc) return;
+ if (!doc.rootNode())
+ {
+ logger->log("Couldn't open configuration file: %s", filename.c_str());
+ return;
+ }
- 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 cf0769de..3aa093a6 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -936,7 +936,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/chat.cpp b/src/gui/chat.cpp
index 6ad45fc8..103a2647 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -119,7 +119,7 @@ ChatWindow::~ChatWindow()
{
config.setValue("ReturnToggles", mReturnToggles);
delete mRecorder;
- delete_all(mWhispers);
+ removeAllWhispers();
delete mItemLinkHandler;
}
@@ -235,10 +235,6 @@ bool ChatWindow::isInputFocused() const
void ChatWindow::removeTab(ChatTab *tab)
{
- // Prevent removal of the local chat tab
- if (tab == localChatTab)
- return;
-
mChatTabs->removeTab(tab);
}
@@ -260,6 +256,25 @@ void ChatWindow::removeWhisper(const std::string &nick)
mWhispers.erase(tempNick);
}
+void ChatWindow::removeAllWhispers()
+{
+ TabMap::iterator iter;
+ std::list<ChatTab*> tabs;
+
+ for (iter = mWhispers.begin(); iter != mWhispers.end(); ++iter)
+ {
+ tabs.push_back(iter->second);
+ }
+
+ for (std::list<ChatTab*>::iterator it = tabs.begin();
+ it != tabs.end(); ++it)
+ {
+ delete *it;
+ }
+
+ mWhispers.clear();
+}
+
void ChatWindow::chatInput(const std::string &msg)
{
ChatTab *tab = getFocused();
diff --git a/src/gui/chat.h b/src/gui/chat.h
index d6378907..db5fe293 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -202,6 +202,8 @@ class ChatWindow : public Window,
void removeWhisper(const std::string &nick);
+ void removeAllWhispers();
+
void autoComplete();
std::string autoCompleteHistory(std::string partName);
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 5e89bc35..03e6e380 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -102,8 +102,10 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
if (showImage)
{
ResourceManager *resman = ResourceManager::getInstance();
- Image *image = resman->getImage("graphics/items/" +
- item.getDisplay().image);
+ Image *image = resman->getImage(
+ paths.getValue("itemIcons", "graphics/items/")
+ + item.getDisplay().image);
+
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/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 89ff72d3..685d28ab 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -42,7 +42,8 @@ WhisperTab::WhisperTab(const std::string &nick) :
WhisperTab::~WhisperTab()
{
- chatWindow->removeWhisper(mNick);
+ if (chatWindow)
+ chatWindow->removeWhisper(mNick);
}
void WhisperTab::handleInput(const std::string &msg)
@@ -120,4 +121,4 @@ void WhisperTab::saveToLogFile(std::string &msg)
{
if (chatLogger)
chatLogger->log(getNick(), msg);
-} \ No newline at end of file
+}
diff --git a/src/item.cpp b/src/item.cpp
index 19bb7c23..6e55ad0a 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),
@@ -58,13 +59,17 @@ void Item::setId(int id)
ResourceManager *resman = ResourceManager::getInstance();
SpriteDisplay display = getInfo().getDisplay();
- std::string imagePath = "graphics/items/" + display.image;
+ std::string imagePath = paths.getValue("itemIcons", "graphics/items/")
+ + display.image;
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 bcebbfd4..5a62ea3d 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -973,9 +973,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/map.cpp b/src/map.cpp
index 33bbccb1..f5214420 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -472,25 +472,15 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type,
}
}
-class ContainsGidFunctor
-{
- public:
- bool operator() (const Tileset *set) const
- {
- return (set->getFirstGid() <= gid &&
- gid - set->getFirstGid() < (int)set->size());
- }
- int gid;
-} containsGid;
-
Tileset *Map::getTilesetWithGid(int gid) const
{
- containsGid.gid = gid;
-
- Tilesets::const_iterator i = find_if(mTilesets.begin(), mTilesets.end(),
- containsGid);
+ Tileset *s = NULL;
+ for (Tilesets::const_iterator it = mTilesets.begin(),
+ it_end = mTilesets.end(); it < it_end && (*it)->getFirstGid() <= gid;
+ it++)
+ s = *it;
- return (i == mTilesets.end()) ? NULL : *i;
+ return s;
}
void Map::blockTile(int x, int y, BlockType type)
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 57830680..f499ff0a 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -231,7 +231,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 bc03cc25..fa823a11 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -29,6 +29,7 @@
#include "log.h"
#include "particle.h"
#include "playerinfo.h"
+#include "configuration.h"
#include "gui/chat.h"
#include "gui/gui.h"
@@ -142,7 +143,10 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
PlayerInfo::setAttribute(LEVEL, msg.readInt16());
PlayerInfo::setAttribute(CHAR_POINTS, msg.readInt16());
PlayerInfo::setAttribute(CORR_POINTS, 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/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 205268e5..bfa19cf1 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>
@@ -116,8 +117,9 @@ void ItemDB::load()
mUnknown = new ItemInfo;
mUnknown->setName(_("Unknown item"));
mUnknown->setDisplay(SpriteDisplay());
- 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 0732bb19..ed062acf 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -31,6 +31,8 @@
#include "utils/gettext.h"
#include "utils/xml.h"
+#include "configuration.h"
+
#define OLD_TMWATHENA_OFFSET 1002
namespace
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 4f0ee10d..ec22c225 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -27,6 +27,7 @@
#include "utils/dtor.h"
#include "utils/xml.h"
+#include "configuration.h"
namespace
{
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 03787569..383e8a27 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -30,12 +30,15 @@
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
-#include "utils/dtor.h"
+#include "configuration.h"
+
#include "utils/xml.h"
#include <set>
-SpriteReference *SpriteReference::Empty = new SpriteReference("error.xml", 0);
+SpriteReference *SpriteReference::Empty = new SpriteReference(
+ paths.getValue("spriteErrorFile", "error.xml"),
+ 0);
Action *SpriteDef::getAction(SpriteAction action) const
{
@@ -64,9 +67,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
{
@@ -281,7 +287,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;
}