ULTIMA8: Move getExtraGuiOption() into UltimaMetaEngineDetection

This commit is contained in:
Cameron Cawley 2021-08-10 23:31:58 +01:00 committed by Eugene Sandulenko
parent c947dd350d
commit f24bffab48
6 changed files with 114 additions and 109 deletions

View File

@ -22,6 +22,7 @@
#include "base/plugins.h"
#include "common/config-manager.h"
#include "common/translation.h"
#include "ultima/detection.h"
@ -61,6 +62,79 @@ static const ADExtraGuiOptionsMap optionsList[] = {
AD_EXTRA_GUI_OPTIONS_TERMINATOR
};
static const ExtraGuiOption COMMON_OPTIONS[] = {
{
_s("Enable frame skipping"),
_s("Allow the game to skip animation frames when running too slow."),
"frameSkip",
false
},
{
_s("Enable frame limiting"),
_s("Limits the speed of the game to prevent running too fast."),
"frameLimit",
true
},
{
_s("Enable cheats"),
_s("Allow cheats by commands and a menu when player is clicked."),
"cheat",
false
},
{
_s("Enable high resolution"),
_s("Enable a higher resolution for the game"),
"usehighres",
false
},
{ nullptr, nullptr, nullptr, false }
};
static const ExtraGuiOption U8_OPTIONS[] = {
{
_s("Play foot step sounds"),
_s("Plays sound when the player moves."),
"footsteps",
true
},
{
_s("Enable jump to mouse position"),
_s("Jumping while not moving targets the mouse cursor rather than direction only."),
"targetedjump",
true
},
{
_s("Use original save/load screens"),
_s("Use the original save/load screens instead of the ScummVM ones"),
"originalsaveload",
false
},
{
_s("Enable font replacement"),
_s("Replaces game fonts with rendered fonts"),
"font_override",
false
},
{
_s("Enable font anti-aliasing"),
_s("When font anti-aliasing is enabled, the text is smoother."),
"font_antialiasing",
false
},
{ nullptr, nullptr, nullptr, false }
};
static const ExtraGuiOption CRUSADER_OPTIONS[] = {
{
// I18N: Silencer is the player-character in Crusader games, known as the Avatar in Ultima series.
_s("Camera moves with Silencer"),
_s("Camera tracks the player movement rather than snapping to defined positions."),
"camera_on_player",
true
},
{ nullptr, nullptr, nullptr, false }
};
} // End of namespace Ultima
UltimaMetaEngineDetection::UltimaMetaEngineDetection() : AdvancedMetaEngineDetection(Ultima::GAME_DESCRIPTIONS,
@ -70,4 +144,39 @@ UltimaMetaEngineDetection::UltimaMetaEngineDetection() : AdvancedMetaEngineDetec
_directoryGlobs = DIRECTORY_GLOBS;
}
Common::String UltimaMetaEngineDetection::getGameId(const Common::String& target) {
// Store a copy of the active domain
Common::String currDomain = ConfMan.getActiveDomainName();
// Switch to the given target domain and get it's game Id
ConfMan.setActiveDomain(target);
Common::String gameId = ConfMan.get("gameid");
// Switch back to the original domain and return the game Id
ConfMan.setActiveDomain(currDomain);
return gameId;
}
const ExtraGuiOptions UltimaMetaEngineDetection::getExtraGuiOptions(const Common::String &target) const {
// TODO: Use ADExtraGuiOptionsMap for all games
const Common::String gameId = getGameId(target);
if (gameId == "ultima8" || gameId == "remorse" || gameId == "regret") {
ExtraGuiOptions options;
for (const ExtraGuiOption *o = Ultima::COMMON_OPTIONS; o->configOption; ++o) {
options.push_back(*o);
}
// Game specific options
const ExtraGuiOption *game_options = (target.equals("ultima8") ? Ultima::U8_OPTIONS : Ultima::CRUSADER_OPTIONS);
for (const ExtraGuiOption *o = game_options; o->configOption; ++o) {
options.push_back(*o);
}
return options;
}
return MetaEngineDetection::getExtraGuiOptions(gameId);
}
REGISTER_PLUGIN_STATIC(ULTIMA_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, UltimaMetaEngineDetection);

View File

@ -87,6 +87,11 @@ public:
const char *getOriginalCopyright() const override {
return "Ultima Games (C) 1980-1995 Origin Systems Inc.";
}
const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override;
private:
static Common::String getGameId(const Common::String& target);
};
#endif

View File

@ -94,16 +94,6 @@ Common::KeymapArray UltimaMetaEngine::initKeymaps(const char *target) const {
return Common::KeymapArray();
}
const ExtraGuiOptions UltimaMetaEngine::getExtraGuiOptions(const Common::String& target) const
{
const Common::String gameId = getGameId(target);
if (gameId == "ultima8" || gameId == "remorse" || gameId == "regret")
return Ultima::Ultima8::MetaEngine::getExtraGuiOptions(gameId);
ExtraGuiOptions options;
return options;
}
Common::String UltimaMetaEngine::getGameId(const Common::String& target) {
// Store a copy of the active domain
Common::String currDomain = ConfMan.getActiveDomainName();

View File

@ -49,11 +49,6 @@ public:
* Initialize keymaps
*/
Common::KeymapArray initKeymaps(const char *target) const override;
/**
* Return the extra GUI options used by the target.
*/
const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override;
};
#endif

View File

@ -124,79 +124,6 @@ static const KeybindingRecord DEBUG_KEYS[] = {
};
#endif
static const ExtraGuiOption COMMON_OPTIONS[] = {
{
_s("Enable frame skipping"),
_s("Allow the game to skip animation frames when running too slow."),
"frameSkip",
false
},
{
_s("Enable frame limiting"),
_s("Limits the speed of the game to prevent running too fast."),
"frameLimit",
true
},
{
_s("Enable cheats"),
_s("Allow cheats by commands and a menu when player is clicked."),
"cheat",
false
},
{
_s("Enable high resolution"),
_s("Enable a higher resolution for the game"),
"usehighres",
false
},
{ nullptr, nullptr, nullptr, false }
};
static const ExtraGuiOption U8_OPTIONS[] = {
{
_s("Play foot step sounds"),
_s("Plays sound when the player moves."),
"footsteps",
true
},
{
_s("Enable jump to mouse position"),
_s("Jumping while not moving targets the mouse cursor rather than direction only."),
"targetedjump",
true
},
{
_s("Use original save/load screens"),
_s("Use the original save/load screens instead of the ScummVM ones"),
"originalsaveload",
false
},
{
_s("Enable font replacement"),
_s("Replaces game fonts with rendered fonts"),
"font_override",
false
},
{
_s("Enable font anti-aliasing"),
_s("When font anti-aliasing is enabled, the text is smoother."),
"font_antialiasing",
false
},
{ nullptr, nullptr, nullptr, false }
};
static const ExtraGuiOption CRUSADER_OPTIONS[] = {
{
// I18N: Silencer is the player-character in Crusader games, known as the Avatar in Ultima series.
_s("Camera moves with Silencer"),
_s("Camera tracks the player movement rather than snapping to defined positions."),
"camera_on_player",
true
},
{ nullptr, nullptr, nullptr, false }
};
Common::KeymapArray MetaEngine::initKeymaps(const Common::String &gameId, bool isMenuActive) {
Common::KeymapArray keymapArray;
@ -284,22 +211,6 @@ Common::KeymapArray MetaEngine::initKeymaps(const Common::String &gameId, bool i
return keymapArray;
}
const ExtraGuiOptions MetaEngine::getExtraGuiOptions(const Common::String& target) {
ExtraGuiOptions options;
for (const ExtraGuiOption *o = COMMON_OPTIONS; o->configOption; ++o) {
options.push_back(*o);
}
// Game specific options
const ExtraGuiOption *game_options = (target.equals("ultima8") ? U8_OPTIONS : CRUSADER_OPTIONS);
for (const ExtraGuiOption *o = game_options; o->configOption; ++o) {
options.push_back(*o);
}
return options;
}
void MetaEngine::setTextInputActive(bool isActive) {
Common::Keymapper *const mapper = g_engine->getEventManager()->getKeymapper();
mapper->setEnabled(!isActive);

View File

@ -67,11 +67,6 @@ public:
*/
static Common::KeymapArray initKeymaps(const Common::String &gameId, bool isMenuActive = false);
/**
* Return the extra GUI options used by the target.
*/
static const ExtraGuiOptions getExtraGuiOptions(const Common::String& target);
/**
* Execute an engine keymap press action
*/