summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-26 01:09:02 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-27 19:40:32 +0100
commitf19b3786f3f000a84c8080594e398686e0298ca4 (patch)
tree11420b0a1301be25b27767559ce727c849933f5a
parent5836fb4abac52c53dbdc51d15e030b14eb46fb40 (diff)
downloadmana-client-f19b3786f3f000a84c8080594e398686e0298ca4.tar.gz
mana-client-f19b3786f3f000a84c8080594e398686e0298ca4.tar.bz2
mana-client-f19b3786f3f000a84c8080594e398686e0298ca4.tar.xz
mana-client-f19b3786f3f000a84c8080594e398686e0298ca4.zip
Made the windows app able to load .ico files at runtime.
Now the icon extension is computed against the os, except for mac where the behaviour is left untouched. This means that the 'icons/mana' appIcon branding parameter will now load icons/mana.png files for unices, and icons/mana.ico for Windows. Reviewed-by: Trapdoor. Resolves: Mana-Mantis: #135.
-rw-r--r--src/client.cpp22
-rw-r--r--src/defaults.cpp2
2 files changed, 18 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 71e0c5d3..f61b5612 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -336,17 +336,29 @@ Client::Client(const Options &options):
// Add the local data directory to PhysicsFS search path
resman->addToSearchPath(mLocalDataDir, false);
+ std::string iconFile = branding.getValue("appIcon", "icons/mana");
+#ifdef WIN32
+ iconFile += ".ico";
+#else
+ iconFile += ".png";
+#endif
+ iconFile = resman->getPath(iconFile);
+ logger->log("Loading icon from file: %s", iconFile.c_str());
#ifdef WIN32
static SDL_SysWMinfo pInfo;
SDL_GetWMInfo(&pInfo);
- HICON icon = LoadIcon(GetModuleHandle(NULL), "A");
+ // Attempt to load icon from .ico file
+ HICON icon = (HICON) LoadImage(NULL,
+ iconFile.c_str(),
+ IMAGE_ICON, 64, 64, LR_LOADFROMFILE);
+ // If it's failing, we load the default resource file.
+ if (!icon)
+ icon = LoadIcon(GetModuleHandle(NULL), "A");
+
if (icon)
- {
SetClassLong(pInfo.window, GCL_HICON, (LONG) icon);
- }
#else
- mIcon = IMG_Load(resman->getPath(
- branding.getValue("appIcon", "icons/mana.png")).c_str());
+ mIcon = IMG_Load(iconFile.c_str());
if (mIcon)
{
SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
diff --git a/src/defaults.cpp b/src/defaults.cpp
index f41645a9..e0e48d60 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -132,7 +132,7 @@ DefaultsData* getBrandingDefaults()
AddDEF(brandingData, "wallpapersPath", "");
AddDEF(brandingData, "wallpapersFile", "");
AddDEF(brandingData, "appName", "Mana");
- AddDEF(brandingData, "appIcon", "icons/mana.png");
+ AddDEF(brandingData, "appIcon", "icons/mana");
AddDEF(brandingData, "loginMusic", "Magick - Real.ogg");
AddDEF(brandingData, "defaultServer", "");
AddDEF(brandingData, "defaultPort", DEFAULT_PORT);