diff options
Diffstat (limited to 'engines/wintermute/wintermute.cpp')
-rw-r--r-- | engines/wintermute/wintermute.cpp | 78 |
1 files changed, 36 insertions, 42 deletions
diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index c9726e150a..89a6f1b3e0 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -34,6 +34,7 @@ #include "engines/util.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/debugger.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/base_engine.h" @@ -48,6 +49,9 @@ namespace Wintermute { // This might not be the prettiest solution WintermuteEngine::WintermuteEngine() : Engine(g_system) { _game = new AdGame(""); + _debugger = nullptr; + _trigDebug = false; + _gameDescription = nullptr; } WintermuteEngine::WintermuteEngine(OSystem *syst, const ADGameDescription *desc) @@ -55,6 +59,7 @@ WintermuteEngine::WintermuteEngine(OSystem *syst, const ADGameDescription *desc) // Put your engine in a sane state, but do nothing big yet; // in particular, do not load data from files; rather, if you // need to do such things, do them from init(). + ConfMan.registerDefault("show_fps","false"); // Do not initialize graphics here @@ -70,14 +75,16 @@ WintermuteEngine::WintermuteEngine(OSystem *syst, const ADGameDescription *desc) DebugMan.addDebugChannel(kWintermuteDebugAudio, "audio", "audio-playback-related issues"); DebugMan.addDebugChannel(kWintermuteDebugGeneral, "general", "various issues not covered by any of the above"); - _game = NULL; + _game = nullptr; + _debugger = nullptr; + _trigDebug = false; } WintermuteEngine::~WintermuteEngine() { // Dispose your resources here deinit(); delete _game; - delete _console; + delete _debugger; // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); @@ -106,7 +113,7 @@ Common::Error WintermuteEngine::run() { } // Create debugger console. It requires GFX to be initialized - _console = new Console(this); + _debugger = new Console(this); // DebugMan.enableDebugChannel("enginelog"); debugC(1, kWintermuteDebugLog, "Engine Debug-LOG enabled"); @@ -133,31 +140,9 @@ int WintermuteEngine::init() { return 1; } BaseEngine::instance().setGameRef(_game); - BasePlatform::initialize(_game, 0, NULL); + BasePlatform::initialize(this, _game, 0, nullptr); - bool windowedMode = !ConfMan.getBool("fullscreen"); - - if (ConfMan.hasKey("debug_mode")) { - if (ConfMan.getBool("debug_mode")) { - _game->DEBUG_DebugEnable("./wme.log"); - } - } - - if (ConfMan.hasKey("show_fps")) { - _game->_debugShowFPS = ConfMan.getBool("show_fps"); - } else { - _game->_debugShowFPS = false; - } - - if (ConfMan.hasKey("disable_smartcache")) { - _game->_smartCache = ConfMan.getBool("disable_smartcache"); - } else { - _game->_smartCache = true; - } - - if (!_game->_smartCache) { - _game->LOG(0, "Smart cache is DISABLED"); - } + _game->initConfManSettings(); // load general game settings _game->initialize1(); @@ -168,7 +153,7 @@ int WintermuteEngine::init() { if (DID_FAIL(_game->loadSettings("startup.settings"))) { _game->LOG(0, "Error loading game settings."); delete _game; - _game = NULL; + _game = nullptr; warning("Some of the essential files are missing. Please reinstall."); return 2; @@ -176,15 +161,13 @@ int WintermuteEngine::init() { _game->initialize2(); - bool ret; + bool ret = _game->initRenderer(); - // initialize the renderer - ret = _game->_renderer->initRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); if (DID_FAIL(ret)) { _game->LOG(ret, "Error initializing renderer. Exiting."); delete _game; - _game = NULL; + _game = nullptr; return 3; } @@ -200,10 +183,10 @@ int WintermuteEngine::init() { // load game uint32 dataInitStart = g_system->getMillis(); - if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { + if (DID_FAIL(_game->loadGameSettingsFile())) { _game->LOG(ret, "Error loading game file. Exiting."); delete _game; - _game = NULL; + _game = nullptr; return false; } @@ -230,14 +213,24 @@ int WintermuteEngine::messageLoop() { uint32 diff = 0; const uint32 maxFPS = 60; - const uint32 frameTime = (uint32)((1.0 / maxFPS) * 1000); + const uint32 frameTime = 2 * (uint32)((1.0 / maxFPS) * 1000); while (!done) { + if (!_game) { + break; + } + _debugger->onFrame(); + Common::Event event; while (_system->getEventManager()->pollEvent(event)) { BasePlatform::handleEvent(&event); } - if (_game && _game->_renderer->_active && _game->_renderer->_ready) { + if (_trigDebug) { + _debugger->attach(); + _trigDebug = false; + } + + if (_game && _game->_renderer->_active && _game->_renderer->isReady()) { _game->displayContent(); _game->displayQuickMsg(); @@ -250,28 +243,29 @@ int WintermuteEngine::messageLoop() { } // ***** flip - if (!_game->_suspendedRendering) { + if (!_game->getSuspendedRendering()) { _game->_renderer->flip(); } - if (_game->_loading) { + if (_game->getIsLoading()) { _game->loadGame(_game->_scheduledLoadSlot); } prevTime = time; } - if (_game->_quitting) { + if (_game && _game->_quitting) { break; } } if (_game) { delete _game; - _game = NULL; + _game = nullptr; } return 0; } void WintermuteEngine::deinit() { BaseEngine::destroy(); + BasePlatform::deinit(); } Common::Error WintermuteEngine::loadGameState(int slot) { @@ -295,9 +289,9 @@ bool WintermuteEngine::canLoadGameStateCurrently() { bool WintermuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { bool retVal = false; caption = name = "(invalid)"; - Common::SeekableReadStream *stream = NULL; + Common::SeekableReadStream *stream = nullptr; // Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it - BaseFileManager *fileMan = new BaseFileManager(Common::UNK_LANG); + BaseFileManager *fileMan = new BaseFileManager(Common::UNK_LANG, true); fileMan->registerPackages(fslist); stream = fileMan->openFile("startup.settings", false, false); |