ENGINES: Allow implementing registerDefaultSettings in the MetaEngine class
This commit is contained in:
parent
afe9a804f6
commit
2f99746d8d
10 changed files with 56 additions and 44 deletions
|
@ -198,6 +198,13 @@ static Common::Error runGame(const Plugin *plugin, const Plugin *enginePlugin, O
|
|||
|
||||
// Create the game's MetaEngine.
|
||||
MetaEngine &metaEngine = enginePlugin->get<MetaEngine>();
|
||||
if (err.getCode() == Common::kNoError) {
|
||||
// Set default values for all of the custom engine options
|
||||
// Apparently some engines query them in their constructor, thus we
|
||||
// need to set this up before instance creation.
|
||||
metaEngine.registerDefaultSettings(target);
|
||||
}
|
||||
|
||||
err = metaEngine.createInstance(&system, &engine);
|
||||
|
||||
// Check for errors
|
||||
|
|
|
@ -193,7 +193,7 @@ public:
|
|||
*
|
||||
* @param target Name of a config manager target.
|
||||
*/
|
||||
virtual void registerDefaultSettings(const Common::String &target) const;
|
||||
void registerDefaultSettings(const Common::String &target) const;
|
||||
|
||||
/**
|
||||
* Return a GUI widget container for configuring the specified target options.
|
||||
|
@ -209,7 +209,7 @@ public:
|
|||
* @param name The name that the returned widget must use.
|
||||
* @param target Name of a config manager target.
|
||||
*/
|
||||
virtual GUI::OptionsContainerWidget *buildEngineOptionsWidgetStatic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const;
|
||||
GUI::OptionsContainerWidget *buildEngineOptionsWidgetStatic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -378,6 +378,14 @@ public:
|
|||
*/
|
||||
virtual Common::Array<Common::Keymap *> initKeymaps(const char *target) const;
|
||||
|
||||
/**
|
||||
* Register the default values for the settings that the engine uses into the
|
||||
* configuration manager.
|
||||
*
|
||||
* @param target Name of a config manager target.
|
||||
*/
|
||||
virtual void registerDefaultSettings(const Common::String &target) const {}
|
||||
|
||||
/**
|
||||
* Return a GUI widget container for configuring the specified target options.
|
||||
*
|
||||
|
|
|
@ -103,8 +103,6 @@ public:
|
|||
}
|
||||
|
||||
DetectedGame toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo) const override;
|
||||
|
||||
void registerDefaultSettings(const Common::String &target) const override;
|
||||
};
|
||||
|
||||
DetectedGame MohawkMetaEngineDetection::toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo) const {
|
||||
|
@ -135,18 +133,4 @@ DetectedGame MohawkMetaEngineDetection::toDetectedGame(const ADDetectedGame &adG
|
|||
return game;
|
||||
}
|
||||
|
||||
void MohawkMetaEngineDetection::registerDefaultSettings(const Common::String &target) const {
|
||||
Common::String gameId = ConfMan.get("gameid", target);
|
||||
|
||||
if (gameId == "myst" || gameId == "makingofmyst") {
|
||||
return Mohawk::MohawkMetaEngine_Myst::registerDefaultSettings();
|
||||
}
|
||||
|
||||
if (gameId == "riven") {
|
||||
return Mohawk::MohawkMetaEngine_Riven::registerDefaultSettings();
|
||||
}
|
||||
|
||||
return AdvancedMetaEngineDetection::registerDefaultSettings(target);
|
||||
}
|
||||
|
||||
REGISTER_PLUGIN_STATIC(MOHAWK_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, MohawkMetaEngineDetection);
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "mohawk/mohawk.h"
|
||||
#include "mohawk/dialogs.h"
|
||||
#include "mohawk/livingbooks.h"
|
||||
#include "mohawk/riven_metaengine.h"
|
||||
#include "mohawk/myst_metaengine.h"
|
||||
|
||||
#ifdef ENABLE_CSTIME
|
||||
#include "mohawk/cstime.h"
|
||||
|
@ -137,6 +139,8 @@ public:
|
|||
|
||||
Common::KeymapArray initKeymaps(const char *target) const override;
|
||||
|
||||
|
||||
void registerDefaultSettings(const Common::String &target) const override;
|
||||
GUI::OptionsContainerWidget *buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
|
||||
};
|
||||
|
||||
|
@ -303,6 +307,20 @@ Common::Error MohawkMetaEngine::createInstance(OSystem *syst, Engine **engine, c
|
|||
return Common::kNoError;
|
||||
}
|
||||
|
||||
void MohawkMetaEngine::registerDefaultSettings(const Common::String &target) const {
|
||||
Common::String gameId = ConfMan.get("gameid", target);
|
||||
|
||||
if (gameId == "myst" || gameId == "makingofmyst") {
|
||||
return Mohawk::MohawkMetaEngine_Myst::registerDefaultSettings();
|
||||
}
|
||||
|
||||
if (gameId == "riven") {
|
||||
return Mohawk::MohawkMetaEngine_Riven::registerDefaultSettings();
|
||||
}
|
||||
|
||||
return MetaEngine::registerDefaultSettings(target);
|
||||
}
|
||||
|
||||
GUI::OptionsContainerWidget *MohawkMetaEngine::buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
|
||||
Common::String gameId = ConfMan.get("gameid", target);
|
||||
|
||||
|
|
|
@ -246,15 +246,6 @@ public:
|
|||
virtual const DebugChannelDef *getDebugChannels() const override {
|
||||
return debugFlagList;
|
||||
}
|
||||
|
||||
virtual void registerDefaultSettings(const Common::String &target) const override;
|
||||
};
|
||||
|
||||
void NancyMetaEngineDetection::registerDefaultSettings(const Common::String &target) const {
|
||||
ConfMan.setInt("music_volume", 54 * 255 / 100, target);
|
||||
ConfMan.setInt("speech_volume", 54 * 255 / 100, target);
|
||||
ConfMan.setInt("sfx_volume", 51 * 255 / 100, target);
|
||||
ConfMan.setBool("subtitles", true, target);
|
||||
}
|
||||
|
||||
REGISTER_PLUGIN_STATIC(NANCY_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, NancyMetaEngineDetection);
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
virtual Common::KeymapArray initKeymaps(const char *target) const override;
|
||||
|
||||
virtual void registerDefaultSettings(const Common::String &target) const override;
|
||||
virtual GUI::OptionsContainerWidget *buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
|
||||
};
|
||||
|
||||
|
@ -74,6 +75,13 @@ Common::Error NancyMetaEngine::createInstance(OSystem *syst, Engine **engine, co
|
|||
|
||||
int NancyMetaEngine::getMaximumSaveSlot() const { return 8; }
|
||||
|
||||
void NancyMetaEngine::registerDefaultSettings(const Common::String &target) const {
|
||||
ConfMan.setInt("music_volume", 54 * 255 / 100, target);
|
||||
ConfMan.setInt("speech_volume", 54 * 255 / 100, target);
|
||||
ConfMan.setInt("sfx_volume", 51 * 255 / 100, target);
|
||||
ConfMan.setBool("subtitles", true, target);
|
||||
}
|
||||
|
||||
GUI::OptionsContainerWidget *NancyMetaEngine::buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
|
||||
return new Nancy::NancyOptionsWidget(boss, name, target);
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ static const PlainGameDescriptor s_sciGameTitles[] = {
|
|||
} // End of namespace Sci
|
||||
|
||||
#include "sci/detection_tables.h"
|
||||
#include "sci/detection_options.h"
|
||||
|
||||
namespace Sci {
|
||||
|
||||
|
@ -183,7 +182,7 @@ static const char *directoryGlobs[] = {
|
|||
|
||||
class SciMetaEngineDetection : public AdvancedMetaEngineDetection {
|
||||
public:
|
||||
SciMetaEngineDetection() : AdvancedMetaEngineDetection(Sci::SciGameDescriptions, sizeof(ADGameDescription), s_sciGameTitles, optionsList) {
|
||||
SciMetaEngineDetection() : AdvancedMetaEngineDetection(Sci::SciGameDescriptions, sizeof(ADGameDescription), s_sciGameTitles) {
|
||||
_maxScanDepth = 3;
|
||||
_directoryGlobs = directoryGlobs;
|
||||
_matchFullPaths = true;
|
||||
|
@ -212,16 +211,8 @@ public:
|
|||
}
|
||||
|
||||
ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **extra) const override;
|
||||
void registerDefaultSettings(const Common::String &target) const override;
|
||||
};
|
||||
|
||||
void SciMetaEngineDetection::registerDefaultSettings(const Common::String &target) const {
|
||||
AdvancedMetaEngineDetection::registerDefaultSettings(target);
|
||||
|
||||
for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry)
|
||||
ConfMan.registerDefault(entry->configOption, entry->defaultState);
|
||||
}
|
||||
|
||||
ADDetectedGame SciMetaEngineDetection::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **extra) const {
|
||||
/**
|
||||
* Fallback detection for Sci heavily depends on engine resources, so it's not possible
|
||||
|
|
|
@ -31,13 +31,7 @@
|
|||
#include "sci/dialogs.h"
|
||||
#include "sci/sci.h"
|
||||
|
||||
/**
|
||||
* When detection is compiled dynamically, options end up in detection plugin and
|
||||
* engine cannot link to them so duplicate them in the engine in this case
|
||||
*/
|
||||
#ifndef DETECTION_STATIC
|
||||
#include "sci/detection_options.h"
|
||||
#endif
|
||||
|
||||
namespace Sci {
|
||||
|
||||
|
|
|
@ -284,6 +284,7 @@ public:
|
|||
// here fb detection has many engine dependencies.
|
||||
virtual ADDetectedGame fallbackDetectExtern(uint md5Bytes, const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **extra) const override;
|
||||
|
||||
void registerDefaultSettings(const Common::String &target) const override;
|
||||
GUI::OptionsContainerWidget *buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
|
||||
};
|
||||
|
||||
|
@ -708,6 +709,14 @@ ADDetectedGame SciMetaEngine::fallbackDetectExtern(uint md5Bytes, const FileMap
|
|||
return ADDetectedGame(&s_fallbackDesc);
|
||||
}
|
||||
|
||||
void SciMetaEngine::registerDefaultSettings(const Common::String &target) const {
|
||||
for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
|
||||
ConfMan.registerDefault(entry->option.configOption, entry->option.defaultState);
|
||||
|
||||
for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry)
|
||||
ConfMan.registerDefault(entry->configOption, entry->defaultState);
|
||||
}
|
||||
|
||||
GUI::OptionsContainerWidget *SciMetaEngine::buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
|
||||
return new OptionsWidget(boss, name, target);
|
||||
}
|
||||
|
|
|
@ -192,8 +192,10 @@ EditGameDialog::EditGameDialog(const String &domain)
|
|||
|
||||
const MetaEngineDetection &metaEngineDetection = metaEnginePlugin->get<MetaEngineDetection>();
|
||||
metaEngineDetection.registerDefaultSettings(_domain);
|
||||
if (enginePlugin)
|
||||
if (enginePlugin) {
|
||||
enginePlugin->get<MetaEngine>().registerDefaultSettings(_domain);
|
||||
_engineOptions = enginePlugin->get<MetaEngine>().buildEngineOptionsWidgetDynamic(tab, "GameOptions_Engine.Container", _domain);
|
||||
}
|
||||
if (!_engineOptions)
|
||||
_engineOptions = metaEngineDetection.buildEngineOptionsWidgetStatic(tab, "GameOptions_Engine.Container", _domain);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue