BASE: add global debug flag

This commit is contained in:
ysj1173886760 2021-05-12 14:58:23 +08:00 committed by Eugene Sandulenko
parent 061fd12966
commit f07ceca9cb
2 changed files with 21 additions and 3 deletions

View File

@ -151,6 +151,18 @@ void saveLastLaunchedTarget(const Common::String &target) {
}
}
void debugFlagsRegister(const DebugChannelOptions &options) {
for (uint i = 0; i < options.size(); i++)
DebugMan.addDebugChannel(options[i].channel, options[i].name, options[i].description);
}
void debugFlagClear() {
// first we clear all the debug channels
// then we add the global debug flags
DebugMan.clearAllDebugChannels();
DebugMan.addDebugChannel(kDebugGlobalTest, "test", "test global debug flag");
}
// TODO: specify the possible return values here
static Common::Error runGame(const Plugin *plugin, const Plugin *enginePlugin, OSystem &system, const Common::String &edebuglevels) {
assert(plugin);
@ -191,10 +203,10 @@ static Common::Error runGame(const Plugin *plugin, const Plugin *enginePlugin, O
metaEngineDetection.registerDefaultSettings(target);
}
// clear the flag and add the global ones
debugFlagClear();
// before we instantiate the engine, we register debug channels for it
DebugChannelOptions debugChannelOptions = metaEngineDetection.getDebugChannelOptions();
for (uint i = 0; i < debugChannelOptions.size(); i++)
DebugMan.addDebugChannel(debugChannelOptions[i].channel, debugChannelOptions[i].name, debugChannelOptions[i].description);
debugFlagsRegister(metaEngineDetection.getDebugChannelOptions());
// Create the game's MetaEngine.
MetaEngine &metaEngine = enginePlugin->get<MetaEngine>();
@ -514,6 +526,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
system.getAudioCDManager();
MusicManager::instance();
Common::DebugManager::instance();
// set the global debug flags as soon as we instantiate the debug mannager
debugFlagClear();
// Init the event manager. As the virtual keyboard is loaded here, it must
// take place after the backend is initiated and the screen has been setup

View File

@ -163,6 +163,10 @@ enum GlobalDebugLevels {
kDebugLevelEventRec = 1 << 30
};
enum GlobalDebugFlags {
kDebugGlobalTest = 1 << 31
};
/** @} */
#endif