aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorLittleboy2011-03-31 06:14:30 -0400
committerJulien2011-06-16 10:30:31 -0400
commit0fd56852b65aed463d79cddc9545511107296809 (patch)
tree1826142c8ee6ee2d6f708f7df4dda40fb381c9da /backends
parentc0ec09ac66162d253ab16e1fb9b3a85dfdd176d7 (diff)
downloadscummvm-rg350-0fd56852b65aed463d79cddc9545511107296809.tar.gz
scummvm-rg350-0fd56852b65aed463d79cddc9545511107296809.tar.bz2
scummvm-rg350-0fd56852b65aed463d79cddc9545511107296809.zip
BACKENDS: Add support for custom game icon (recent items list and icon overlay)
Diffstat (limited to 'backends')
-rw-r--r--backends/taskbar/win32/win32-taskbar.cpp60
-rw-r--r--backends/taskbar/win32/win32-taskbar.h3
2 files changed, 58 insertions, 5 deletions
diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp
index 1ddbde10bc..85c87f3680 100644
--- a/backends/taskbar/win32/win32-taskbar.cpp
+++ b/backends/taskbar/win32/win32-taskbar.cpp
@@ -31,12 +31,18 @@
#include <SDKDDKVer.h>
#include <shlobj.h>
+// For Bitmap and overlay icons
+#include <gdiplus.h>
+using namespace Gdiplus;
+
+// For HWND
+#include <SDL_syswm.h>
+
#include "backends/taskbar/win32/win32-taskbar.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
-
-#include <SDL_syswm.h>
+#include "common/file.h"
// System.Title property key, values taken from http://msdn.microsoft.com/en-us/library/bb787584.aspx
const PROPERTYKEY PKEY_Title = { /* fmtid = */ { 0xF29F85E0, 0x4FF9, 0x1068, { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } }, /* propID = */ 2 };
@@ -82,7 +88,25 @@ void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Commo
if (_taskbar == NULL)
return;
- warning("[Win32TaskbarManager::setOverlayIcon] Not implemented");
+ if (name.empty()) {
+ _taskbar->SetOverlayIcon(getHwnd(), NULL, L"");
+ return;
+ }
+
+ // Compute full icon path
+ Common::String path = getIconPath(name);
+ if (path.empty())
+ return;
+
+ HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
+
+ // Sets the overlay icon
+ LPWSTR desc = ansiToUnicode(description.c_str());
+ _taskbar->SetOverlayIcon(getHwnd(), pIcon, desc);
+
+ DestroyIcon(pIcon);
+
+ delete[] desc;
}
void Win32TaskbarManager::setProgressValue(int completed, int total) {
@@ -119,7 +143,17 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St
// Set link properties.
link->SetPath(path);
link->SetArguments(game);
- link->SetIconLocation(path, 0); // There's no way to get a game-specific icon, is there?
+
+ Common::String iconPath = getIconPath(name);
+ if (iconPath.empty()) {
+ link->SetIconLocation(path, 0); // No game-specific icon available
+ } else {
+ LPWSTR icon = ansiToUnicode(iconPath.c_str());
+
+ link->SetIconLocation(icon, 0);
+
+ delete[] icon;
+ }
// The link's display name must be set via property store.
IPropertyStore* propStore;
@@ -144,6 +178,24 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St
}
}
+Common::String Win32TaskbarManager::getIconPath(Common::String target) {
+ // Get extra path
+ Common::String extra = ConfMan.get("extrapath");
+
+ Common::String filename = target + ".ico";
+ Common::String path = extra + filename;
+
+ if (!Common::File::exists(filename)) {
+ // Try with the game id instead of the domain name
+ filename = ConfMan.get("gameid") + ".ico";
+
+ if (!Common::File::exists(filename))
+ return "";
+ }
+
+ return extra + filename;
+}
+
bool Win32TaskbarManager::isWin7OrLater() {
OSVERSIONINFOEX versionInfo;
DWORDLONG conditionMask = 0;
diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h
index d0871d36d2..bdd45a942d 100644
--- a/backends/taskbar/win32/win32-taskbar.h
+++ b/backends/taskbar/win32/win32-taskbar.h
@@ -48,9 +48,10 @@ public:
virtual void addRecent(const Common::String &name, const Common::String &description);
private:
- HWND _hwnd;
ITaskbarList3 *_taskbar;
+ Common::String getIconPath(Common::String target);
+
// Helper functions
bool isWin7OrLater();
LPWSTR ansiToUnicode(const char *s);