diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-07-11 20:05:44 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-07-11 20:05:44 +0200 |
commit | abde0f51b3062c158fb52e9dfff23d21d3be03d1 (patch) | |
tree | 4af561ea9e8cd3f7f981cce9817cf57f3e353787 /src/resources/wallpaper.cpp | |
parent | 93e1a2a9e5f379945a6efb24598319b605be1dfa (diff) | |
download | mana-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/wallpaper.cpp')
-rw-r--r-- | src/resources/wallpaper.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
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(); |