summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-11 20:05:44 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-11 20:05:44 +0200
commitabde0f51b3062c158fb52e9dfff23d21d3be03d1 (patch)
tree4af561ea9e8cd3f7f981cce9817cf57f3e353787 /src/resources
parent93e1a2a9e5f379945a6efb24598319b605be1dfa (diff)
downloadmana-client-abde0f51b3062c158fb52e9dfff23d21d3be03d1.tar.gz
mana-client-abde0f51b3062c158fb52e9dfff23d21d3be03d1.tar.bz2
mana-client-abde0f51b3062c158fb52e9dfff23d21d3be03d1.tar.xz
mana-client-abde0f51b3062c158fb52e9dfff23d21d3be03d1.zip
Made the different hard-coded paths and files be now taken from the
data/paths.xml configuration file. Also added default gui theme path in branding and default wallpaper path and file searched respectively in the branding and paths.xml files. Hard-coded values are still used as fallbacks. Resolves: Manasource Mantis #148. Reviewed-by: jaxad0127.
Diffstat (limited to 'src/resources')
-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
10 files changed, 74 insertions, 21 deletions
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