ULTIMA8: Support changing options during runtime

No options are defined yet, but they will be moved over from the current engine options.
This commit is contained in:
Matthew Jimenez 2021-02-13 11:55:58 -06:00
parent 82b603ba7e
commit b69122c768
5 changed files with 52 additions and 3 deletions

View File

@ -93,7 +93,17 @@ Common::KeymapArray UltimaMetaEngine::initKeymaps(const char *target) const {
return Common::KeymapArray();
}
Common::String UltimaMetaEngine::getGameId(const char *target) {
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

@ -33,7 +33,7 @@ private:
/**
* Gets the game Id given a target string
*/
static Common::String getGameId(const char *target);
static Common::String getGameId(const Common::String& target);
public:
const char *getName() const override;
@ -50,6 +50,11 @@ public:
*/
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

@ -122,6 +122,17 @@ static const KeybindingRecord DEBUG_KEYS[] = {
};
#endif
static const ExtraGuiOption COMMON_OPTIONS[] = {
{ nullptr, nullptr, nullptr, false }
};
static const ExtraGuiOption U8_OPTIONS[] = {
{ nullptr, nullptr, nullptr, false }
};
static const ExtraGuiOption CRUSADER_OPTIONS[] = {
{ nullptr, nullptr, nullptr, false }
};
Common::KeymapArray MetaEngine::initKeymaps(const Common::String &gameId, bool isMenuActive) {
Common::KeymapArray keymapArray;
@ -210,6 +221,22 @@ 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 keymaps
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

@ -24,6 +24,7 @@
#define ULTIMA_ULTIMA8_META_ENGINE
#include "backends/keymapper/keymapper.h"
#include "engines/metaengine.h"
namespace Ultima {
namespace Ultima8 {
@ -66,6 +67,11 @@ 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
*/

View File

@ -185,7 +185,8 @@ bool Ultima8Engine::hasFeature(EngineFeature f) const {
(f == kSupportsSubtitleOptions) ||
(f == kSupportsReturnToLauncher) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime);
(f == kSupportsSavingDuringRuntime) ||
(f == kSupportsChangingOptionsDuringRuntime);
}
bool Ultima8Engine::startup() {