summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-26 01:09:02 +0100
committerAndrei Karas <akaras@inbox.ru>2011-01-27 21:28:29 +0200
commita7c8ff3aaaa7903db4bd126cb3504a8bf441034e (patch)
treef88117df110fc186eaf6865fd72b2dcee78b70d5 /src/client.cpp
parentf4482e7c411dcc4bfdaedf6f3d5a47dc125f62a5 (diff)
downloadmv-a7c8ff3aaaa7903db4bd126cb3504a8bf441034e.tar.gz
mv-a7c8ff3aaaa7903db4bd126cb3504a8bf441034e.tar.bz2
mv-a7c8ff3aaaa7903db4bd126cb3504a8bf441034e.tar.xz
mv-a7c8ff3aaaa7903db4bd126cb3504a8bf441034e.zip
Made the windows app able to load .ico files at runtime.
Now the icon extension is computed against the os. This means that the 'icons/mana' appIcon branding parameter will now load icons/mana.png files for unices and mac, and icons/mana.ico for Windows. Reviewed-by: Trapdoor. Resolves: Mana-Mantis: #135.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 0039ce025..d17ea73bc 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -352,15 +352,30 @@ Client::Client(const Options &options):
//resman->selectSkin();
+ 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/manaplus.png")).c_str());
+ mIcon = IMG_Load(iconFile.c_str());
if (mIcon)
{
SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);