From 154c584d44d689f0a7b521b49c5ce245a52fb992 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 16:09:20 -0400 Subject: BACKENDS: Enhance Win32TaskbarManager::getIconPath() We now look for an iconsPath configuration variable with the path to the icons folder. In addition, we look if there is an "icons" subfolder (useful when using extrapath to store icons) --- backends/taskbar/win32/win32-taskbar.cpp | 35 +++++++++++++++++++++++--------- backends/taskbar/win32/win32-taskbar.h | 7 +++++++ 2 files changed, 32 insertions(+), 10 deletions(-) (limited to 'backends/taskbar') diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 3754a03c76..0cfd81e3f2 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -201,20 +201,35 @@ 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"; + // We first try to look for a iconspath configuration variable then + // fallback to the extra path + // + // Icons can be either in a subfolder named "icons" or directly in the path + + Common::String iconsPath = ConfMan.get("iconspath"); + Common::String extraPath = ConfMan.get("extrapath"); + +#define TRY_ICON_PATH(path) { \ + Common::FSNode node((path)); \ + if (node.exists()) \ + return (path); \ +} - if (!Common::File::exists(filename)) { - // Try with the game id instead of the domain name - filename = ConfMan.get("gameid") + ".ico"; + if (!iconsPath.empty()) { + TRY_ICON_PATH(iconsPath + "/" + target + ".ico"); + TRY_ICON_PATH(iconsPath + "/" + ConfMan.get("gameid") + ".ico"); + TRY_ICON_PATH(iconsPath + "/icons/" + target + ".ico"); + TRY_ICON_PATH(iconsPath + "/icons/" + ConfMan.get("gameid") + ".ico"); + } - if (!Common::File::exists(filename)) - return ""; + if (!extraPath.empty()) { + TRY_ICON_PATH(extraPath + "/" + target + ".ico"); + TRY_ICON_PATH(extraPath + "/" + ConfMan.get("gameid") + ".ico"); + TRY_ICON_PATH(extraPath + "/icons/" + target + ".ico"); + TRY_ICON_PATH(extraPath + "/icons/" + ConfMan.get("gameid") + ".ico"); } - return extra + filename; + return ""; } bool Win32TaskbarManager::isWin7OrLater() { diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h index 0fc219e816..3415a79bd7 100644 --- a/backends/taskbar/win32/win32-taskbar.h +++ b/backends/taskbar/win32/win32-taskbar.h @@ -46,6 +46,13 @@ public: private: ITaskbarList3 *_taskbar; + /** + * Get the path to an icon for the game + * + * @param target The game target + * + * @return The icon path (or "" if no icon was found) + */ Common::String getIconPath(Common::String target); // Helper functions -- cgit v1.2.3