summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
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.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
9 files changed, 72 insertions, 20 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 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