[Scummvm-git-logs] scummvm branch-2-2 -> 28ecec9662d228227c2af1d9d61a7e897166d55d
SupSuper
supsuper at gmail.com
Wed Sep 9 02:18:04 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
28ecec9662 BACKENDS: Add support for qualified game IDs in taskbar icons
Commit: 28ecec9662d228227c2af1d9d61a7e897166d55d
https://github.com/scummvm/scummvm/commit/28ecec9662d228227c2af1d9d61a7e897166d55d
Author: SupSuper (supsuper at gmail.com)
Date: 2020-09-09T03:17:42+01:00
Commit Message:
BACKENDS: Add support for qualified game IDs in taskbar icons
Changed paths:
backends/taskbar/macosx/macosx-taskbar.h
backends/taskbar/macosx/macosx-taskbar.mm
backends/taskbar/win32/win32-taskbar.cpp
backends/taskbar/win32/win32-taskbar.h
common/taskbar.h
diff --git a/backends/taskbar/macosx/macosx-taskbar.h b/backends/taskbar/macosx/macosx-taskbar.h
index 145cbd4f3a..00d4cc5d80 100644
--- a/backends/taskbar/macosx/macosx-taskbar.h
+++ b/backends/taskbar/macosx/macosx-taskbar.h
@@ -42,8 +42,6 @@ public:
virtual void clearError();
private:
- Common::String getIconPath(const Common::String&);
-
void initApplicationIconView();
void clearApplicationIconView();
diff --git a/backends/taskbar/macosx/macosx-taskbar.mm b/backends/taskbar/macosx/macosx-taskbar.mm
index f6d3be55ce..4600ea7df5 100644
--- a/backends/taskbar/macosx/macosx-taskbar.mm
+++ b/backends/taskbar/macosx/macosx-taskbar.mm
@@ -27,8 +27,6 @@
#if defined(MACOSX) && defined(USE_TASKBAR)
#include "backends/taskbar/macosx/macosx-taskbar.h"
-#include "common/config-manager.h"
-#include "common/file.h"
#include "backends/platform/sdl/macosx/macosx-compat.h"
#include <AppKit/NSApplication.h>
#include <AppKit/NSImage.h>
@@ -119,7 +117,7 @@ void MacOSXTaskbarManager::setOverlayIcon(const Common::String &name, const Comm
return;
}
- Common::String path = getIconPath(name);
+ Common::String path = getIconPath(name, ".png");
if (path.empty())
return;
@@ -208,38 +206,6 @@ void MacOSXTaskbarManager::clearError() {
return;
}
-Common::String MacOSXTaskbarManager::getIconPath(const Common::String& target) {
- // 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 (!iconsPath.empty()) {
- TRY_ICON_PATH(iconsPath + "/" + target + ".png");
- TRY_ICON_PATH(iconsPath + "/" + ConfMan.get("gameid") + ".png");
- TRY_ICON_PATH(iconsPath + "/icons/" + target + ".png");
- TRY_ICON_PATH(iconsPath + "/icons/" + ConfMan.get("gameid") + ".png");
- }
-
- if (!extraPath.empty()) {
- TRY_ICON_PATH(extraPath + "/" + target + ".png");
- TRY_ICON_PATH(extraPath + "/" + ConfMan.get("gameid") + ".png");
- TRY_ICON_PATH(extraPath + "/icons/" + target + ".png");
- TRY_ICON_PATH(extraPath + "/icons/" + ConfMan.get("gameid") + ".png");
- }
-
- return "";
-}
-
void MacOSXTaskbarManager::addRecent(const Common::String &name, const Common::String &description) {
//warning("[MacOSXTaskbarManager::addRecent] Adding recent list entry: %s (%s)", name.c_str(), description.c_str());
@@ -258,7 +224,7 @@ void MacOSXTaskbarManager::addRecent(const Common::String &name, const Common::S
[dict setObject:(NSString *)desc forKey:@"description"];
// Icon
- Common::String iconPath = getIconPath(name);
+ Common::String iconPath = getIconPath(name, ".png");
if (!iconPath.empty()) {
CFStringRef icon = CFStringCreateWithCString(0, iconPath.c_str(), kCFStringEncodingASCII);
[dict setObject:(NSString *)icon forKey:@"icon"];
diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp
index 6542973716..f738e277a6 100644
--- a/backends/taskbar/win32/win32-taskbar.cpp
+++ b/backends/taskbar/win32/win32-taskbar.cpp
@@ -65,9 +65,7 @@
#include "backends/platform/sdl/win32/win32-window.h"
#include "backends/platform/sdl/win32/win32_wrapper.h"
-#include "common/config-manager.h"
#include "common/textconsole.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 };
@@ -120,7 +118,7 @@ void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Commo
}
// Compute full icon path
- Common::String path = getIconPath(name);
+ Common::String path = getIconPath(name, ".ico");
if (path.empty())
return;
@@ -293,7 +291,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St
link->SetPath(path);
link->SetArguments(game);
- Common::String iconPath = getIconPath(name);
+ Common::String iconPath = getIconPath(name, ".ico");
if (iconPath.empty()) {
link->SetIconLocation(path, 0); // No game-specific icon available
} else {
@@ -335,36 +333,4 @@ void Win32TaskbarManager::clearError() {
setProgressState(kTaskbarNoProgress);
}
-Common::String Win32TaskbarManager::getIconPath(Common::String target) {
- // 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 (!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 (!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 "";
-}
-
#endif
diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h
index aa7b5710b3..0742e63f4c 100644
--- a/backends/taskbar/win32/win32-taskbar.h
+++ b/backends/taskbar/win32/win32-taskbar.h
@@ -52,15 +52,6 @@ private:
// Count handling
HICON _icon;
int _count;
-
- /**
- * 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);
};
#endif
diff --git a/common/taskbar.h b/common/taskbar.h
index f1a9adb2d9..d5e62087ba 100644
--- a/common/taskbar.h
+++ b/common/taskbar.h
@@ -24,10 +24,13 @@
#define COMMON_TASKBAR_MANAGER_H
#include "common/scummsys.h"
-#include "common/str.h"
#if defined(USE_TASKBAR)
+#include "common/str.h"
+#include "common/config-manager.h"
+#include "common/file.h"
+
namespace Common {
/**
@@ -134,6 +137,54 @@ public:
* Clears the error notification
*/
virtual void clearError() {}
+
+protected:
+ /**
+ * Get the path to an icon for the game
+ *
+ * @param target The game target
+ * @param extension The icon extension
+ * @return The icon path (or "" if no icon was found)
+ */
+ Common::String getIconPath(const Common::String &target, const Common::String &extension) {
+ // 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");
+
+ Common::String targetIcon = target + extension;
+ Common::String qualifiedIcon = ConfMan.get("engineid") + "-" + ConfMan.get("gameid") + extension;
+ Common::String gameIcon = ConfMan.get("gameid") + extension;
+
+#define TRY_ICON_PATH(path) { \
+Common::FSNode node((path)); \
+if (node.exists()) \
+return (path); \
+}
+ if (!iconsPath.empty()) {
+ TRY_ICON_PATH(iconsPath + "/" + targetIcon);
+ TRY_ICON_PATH(iconsPath + "/" + qualifiedIcon);
+ TRY_ICON_PATH(iconsPath + "/" + gameIcon);
+ TRY_ICON_PATH(iconsPath + "/icons/" + targetIcon);
+ TRY_ICON_PATH(iconsPath + "/icons/" + qualifiedIcon);
+ TRY_ICON_PATH(iconsPath + "/icons/" + gameIcon);
+ }
+
+ if (!extraPath.empty()) {
+ TRY_ICON_PATH(extraPath + "/" + targetIcon);
+ TRY_ICON_PATH(extraPath + "/" + qualifiedIcon);
+ TRY_ICON_PATH(extraPath + "/" + gameIcon);
+ TRY_ICON_PATH(extraPath + "/icons/" + targetIcon);
+ TRY_ICON_PATH(extraPath + "/icons/" + qualifiedIcon);
+ TRY_ICON_PATH(extraPath + "/icons/" + gameIcon);
+ }
+#undef TRY_ICON_PATH
+
+ return "";
+ }
};
} // End of namespace Common
More information about the Scummvm-git-logs
mailing list