[Scummvm-git-logs] scummvm master -> beafbca04d1b97b4f87e74a46fc86f24d97c7f69
sev-
noreply at scummvm.org
Tue Jun 7 23:38:21 UTC 2022
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:
beafbca04d GUI: Extract vanilla game title for using in the grid. Bug #13551
Commit: beafbca04d1b97b4f87e74a46fc86f24d97c7f69
https://github.com/scummvm/scummvm/commit/beafbca04d1b97b4f87e74a46fc86f24d97c7f69
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-06-08T01:37:32+02:00
Commit Message:
GUI: Extract vanilla game title for using in the grid. Bug #13551
Changed paths:
gui/launcher.cpp
gui/launcher.h
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index c16eed5957e..3ebb0f3fa52 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -162,10 +162,11 @@ bool LauncherFilterMatcher(void *boss, int idx, const Common::U32String &item, C
return invert ? !result : result;
}
-LauncherDialog::LauncherDialog(const Common::String &dialogName)
+LauncherDialog::LauncherDialog(const Common::String &dialogName, LauncherChooser *chooser)
: Dialog(dialogName), _title(dialogName), _browser(nullptr),
_loadDialog(nullptr), _searchClearButton(nullptr), _searchDesc(nullptr),
- _grpChooserDesc(nullptr), _grpChooserPopup(nullptr), _groupBy(kGroupByNone)
+ _grpChooserDesc(nullptr), _grpChooserPopup(nullptr), _groupBy(kGroupByNone),
+ _launcherChooser(chooser)
#ifndef DISABLE_FANCY_THEMES
, _logo(nullptr), _searchPic(nullptr), _groupPic(nullptr)
#endif // !DISABLE_FANCY_THEMES
@@ -852,13 +853,31 @@ bool LauncherDialog::checkModifier(int checkedModifier) {
#pragma mark -
-LauncherChooser::LauncherChooser() : _impl(nullptr) {}
+LauncherChooser::LauncherChooser() : _impl(nullptr) {
+ genGameList();
+}
LauncherChooser::~LauncherChooser() {
delete _impl;
_impl = nullptr;
}
+static Common::String buildQualifiedGameName(const Common::String &engineId, const Common::String &gameId) {
+ return Common::String::format("%s:%s", engineId.c_str(), gameId.c_str());
+}
+
+void LauncherChooser::genGameList() {
+ const PluginList &plugins = EngineMan.getPlugins();
+ for (auto iter = plugins.begin(); iter != plugins.end(); ++iter) {
+ const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+
+ PlainGameList list = metaEngine.getSupportedGames();
+ for (auto v = list.begin(); v != list.end(); ++v) {
+ _games[buildQualifiedGameName(metaEngine.getEngineId(), v->gameId)] = v->description;
+ }
+ }
+}
+
#ifndef DISABLE_LAUNCHERDISPLAY_GRID
LauncherDisplayType getRequestedLauncherType() {
const Common::String &userConfig = ConfMan.get("gui_launcher_chooser", Common::ConfigManager::kApplicationDomain);
@@ -874,7 +893,7 @@ LauncherDisplayType getRequestedLauncherType() {
class LauncherSimple : public LauncherDialog {
public:
- LauncherSimple(const Common::String &title);
+ LauncherSimple(const Common::String &title, LauncherChooser *chooser);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
void handleKeyDown(Common::KeyState state) override;
@@ -895,7 +914,7 @@ private:
#ifndef DISABLE_LAUNCHERDISPLAY_GRID
class LauncherGrid : public LauncherDialog {
public:
- LauncherGrid(const Common::String &title);
+ LauncherGrid(const Common::String &title, LauncherChooser *chooser);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
void handleKeyDown(Common::KeyState state) override;
@@ -924,14 +943,14 @@ void LauncherChooser::selectLauncher() {
switch (requestedType) {
case kLauncherDisplayGrid:
- _impl = new LauncherGrid("LauncherGrid");
+ _impl = new LauncherGrid("LauncherGrid", this);
break;
default:
// fallthrough intended
case kLauncherDisplayList:
#endif // !DISABLE_LAUNCHERDISPLAY_GRID
- _impl = new LauncherSimple("Launcher");
+ _impl = new LauncherSimple("Launcher", this);
#ifndef DISABLE_LAUNCHERDISPLAY_GRID
break;
}
@@ -955,8 +974,8 @@ int LauncherChooser::runModal() {
#pragma mark -
-LauncherSimple::LauncherSimple(const Common::String &title)
- : LauncherDialog(title),
+LauncherSimple::LauncherSimple(const Common::String &title, LauncherChooser *chooser)
+ : LauncherDialog(title, chooser),
_list(nullptr) {
build();
}
@@ -1282,8 +1301,8 @@ void LauncherSimple::updateButtons() {
#pragma mark -
#ifndef DISABLE_LAUNCHERDISPLAY_GRID
-LauncherGrid::LauncherGrid(const Common::String &title)
- : LauncherDialog(title),
+LauncherGrid::LauncherGrid(const Common::String &title, LauncherChooser *chooser)
+ : LauncherDialog(title, chooser),
_grid(nullptr) {
build();
}
@@ -1476,19 +1495,21 @@ void LauncherGrid::updateListing() {
description = g.description;
}
+ Common::String gameid;
+ if (!iter->_value.tryGetVal("gameid", gameid))
+ gameid = iter->_key;
+
+ Common::String engineid;
+ engineid = iter->_value.getValOrDefault("engineid");
+
// Strip platform language from the title.
- size_t extraPos = description.findLastOf("(");
- if (extraPos != Common::String::npos)
- title = Common::String(description.c_str(), extraPos);
+ Common::String key = buildQualifiedGameName(engineid, gameid);
- if (description.empty()) {
- Common::String gameid;
- if (!iter->_value.tryGetVal("gameid", gameid)) {
- gameid = iter->_key;
- }
+ if (_launcherChooser->getGameList()->contains(key))
+ title = _launcherChooser->getGameList()->getVal(key);
+ if (description.empty())
description = Common::String::format("Unknown (target %s, gameid %s)", iter->_key.c_str(), gameid.c_str());
- }
if (title.empty())
title = description;
diff --git a/gui/launcher.h b/gui/launcher.h
index c31dc0af4a5..55f12b37af3 100644
--- a/gui/launcher.h
+++ b/gui/launcher.h
@@ -81,10 +81,11 @@ class StaticTextWidget;
class EditTextWidget;
class SaveLoadChooser;
class PopUpWidget;
+class LauncherChooser;
class LauncherDialog : public Dialog {
public:
- LauncherDialog(const Common::String &dialogName);
+ LauncherDialog(const Common::String &dialogName, LauncherChooser *chooser);
~LauncherDialog() override;
void rebuild();
@@ -123,6 +124,7 @@ protected:
Common::String _title;
Common::String _search;
MetadataParser _metadataParser;
+ LauncherChooser *_launcherChooser = nullptr;
#ifndef DISABLE_LAUNCHERDISPLAY_GRID
ButtonWidget *_listButton;
@@ -193,6 +195,7 @@ private:
class LauncherChooser {
protected:
LauncherDialog *_impl;
+ Common::StringMap _games;
public:
LauncherChooser();
@@ -200,6 +203,11 @@ public:
int runModal();
void selectLauncher();
+
+ Common::StringMap *getGameList() { return &_games; }
+
+private:
+ void genGameList();
};
} // End of namespace GUI
More information about the Scummvm-git-logs
mailing list