diff options
author | whiterandrek | 2018-06-13 13:28:24 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | d2218ad8cd7984871b37e572e464360fb6b5530c (patch) | |
tree | 970f8999513eafa8d7e7a4d4a3c34a3cb816455c | |
parent | 14cc810cef4c3ae46ffb62768c1cb79295a34720 (diff) | |
download | scummvm-rg350-d2218ad8cd7984871b37e572e464360fb6b5530c.tar.gz scummvm-rg350-d2218ad8cd7984871b37e572e464360fb6b5530c.tar.bz2 scummvm-rg350-d2218ad8cd7984871b37e572e464360fb6b5530c.zip |
PINK: Engine class code cleanup
-rw-r--r-- | engines/pink/pink.cpp | 74 | ||||
-rw-r--r-- | engines/pink/pink.h | 37 |
2 files changed, 58 insertions, 53 deletions
diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index dfa072bfdc..177e72cae8 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -20,8 +20,6 @@ * */ -#include <graphics/thumbnail.h> -#include <graphics/surface.h> #include "common/debug-channels.h" #include "common/winexe_pe.h" #include "common/config-manager.h" @@ -29,6 +27,8 @@ #include "engines/util.h" #include "graphics/cursorman.h" +#include "graphics/thumbnail.h" +#include "graphics/surface.h" #include "pink/pink.h" #include "pink/console.h" @@ -86,7 +86,6 @@ Common::Error PinkEngine::init() { return Common::kNoGameDataFoundError; setCursor(kLoadingCursor); - _system->showMouse(1); _orb.loadGame(this); @@ -123,11 +122,8 @@ Common::Error Pink::PinkEngine::run() { _actor->onRightButtonClick(event.mouse); break; case Common::EVENT_KEYDOWN: - _actor->onKeyboardButtonClick(event.kbd.keycode); + _actor->onKeyboardButtonClick(event.kbd.keycode); break; - // don't know why it is used in original - case Common::EVENT_LBUTTONUP: - case Common::EVENT_RBUTTONDOWN: default: break; } @@ -148,48 +144,53 @@ void PinkEngine::load(Archive &archive) { } void PinkEngine::initModule(const Common::String &moduleName, const Common::String &pageName, Archive *saveFile) { - if (_module) { - for (uint i = 0; i < _modules.size(); ++i) { - if (_module == _modules[i]) { - _modules[i] = new ModuleProxy(_module->getName()); + if (_module) + removeModule(); - delete _module; - _module = nullptr; + addModule(moduleName); + if (saveFile) + _module->loadState(*saveFile); - break; - } - } - } + _module->init(saveFile ? kLoadingSave : kLoadingNewGame, pageName); +} + +void PinkEngine::changeScene() { + setCursor(kLoadingCursor); + _director.clear(); + + if (!_nextModule.empty() && _nextModule != _module->getName()) + initModule(_nextModule, _nextPage, nullptr); + else + _module->changePage(_nextPage); +} + +void PinkEngine::addModule(const Common::String &moduleName) { + _module = new Module(this, moduleName); + + _orb.loadObject(_module, _module->getName()); for (uint i = 0; i < _modules.size(); ++i) { if (_modules[i]->getName() == moduleName) { - loadModule(i); - _module = static_cast<Module*>(_modules[i]); - if (saveFile) - _module->loadState(*saveFile); - _module->init( saveFile ? kLoadingSave : kLoadingNewGame, pageName); + delete _modules[i]; + _modules[i] = _module; break; } } } -void PinkEngine::changeScene(Page *page) { - setCursor(kLoadingCursor); - if (!_nextModule.empty() && _nextModule.compareTo(_module->getName())) { - initModule(_nextModule, _nextPage, nullptr); - } else { - assert(!_nextPage.empty()); - _module->changePage(_nextPage); +void PinkEngine::removeModule() { + for (uint i = 0; i < _modules.size(); ++i) { + if (_module == _modules[i]) { + _modules[i] = new ModuleProxy(_module->getName()); + delete _module; + _module = nullptr; + break; + } } } -void PinkEngine::loadModule(int index) { - Module *module = new Module(this, _modules[index]->getName()); - - _orb.loadObject(module, module->getName()); - - delete _modules[index]; - _modules[index] = module; +void PinkEngine::setVariable(Common::String &variable, Common::String &value) { + _variables[variable] = value; } bool PinkEngine::checkValueOfVariable(Common::String &variable, Common::String &value) { @@ -313,7 +314,6 @@ bool PinkEngine::hasFeature(Engine::EngineFeature f) const { void PinkEngine::pauseEngineIntern(bool pause) { Engine::pauseEngineIntern(pause); _director.pause(pause); - _system->showMouse(!pause); } bool PinkEngine::isPeril() { diff --git a/engines/pink/pink.h b/engines/pink/pink.h index 141f010f2c..f0225823eb 100644 --- a/engines/pink/pink.h +++ b/engines/pink/pink.h @@ -83,21 +83,26 @@ public: PinkEngine(OSystem *system, const ADGameDescription *desc); ~PinkEngine(); - virtual Common::Error run(); + Common::Error run() override; - virtual bool hasFeature(EngineFeature f) const; + bool hasFeature(EngineFeature f) const override; - virtual Common::Error loadGameState(int slot); - virtual bool canLoadGameStateCurrently(); + virtual Common::Error loadGameState(int slot) override; + bool canLoadGameStateCurrently() override; - virtual Common::Error saveGameState(int slot, const Common::String &desc); - virtual bool canSaveGameStateCurrently(); + Common::Error saveGameState(int slot, const Common::String &desc) override; + bool canSaveGameStateCurrently() override; - bool isPeril(); +protected: + virtual void pauseEngineIntern(bool pause) override; +public: void load(Archive &archive); - void initModule(const Common::String &moduleName, const Common::String &pageName, Archive *saveFile); - void changeScene(Page *page); + + void changeScene(); + + void setVariable(Common::String &variable, Common::String &value); + bool checkValueOfVariable(Common::String &variable, Common::String &value); OrbFile *getOrb() { return &_orb; } BroFile *getBro() { return _bro; } @@ -109,18 +114,18 @@ public: void setLeadActor(LeadActor *actor) { _actor = actor; }; void setCursor(uint cursorIndex); - void setVariable(Common::String &variable, Common::String &value) { _variables[variable] = value; } - bool checkValueOfVariable(Common::String &variable, Common::String &value); - -protected: - virtual void pauseEngineIntern(bool pause); - private: Common::Error init(); + bool loadCursors(); - void loadModule(int index); + void initModule(const Common::String &moduleName, const Common::String &pageName, Archive *saveFile); + void addModule(const Common::String &moduleName); + void removeModule(); + + bool isPeril(); +private: Console *_console; Common::RandomSource _rnd; Common::Array<Graphics::WinCursorGroup *> _cursors; |