From 908e784957ec3cf01bc54a5c76c18f5ed6a8faa6 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 18 Aug 2013 15:28:16 -0500 Subject: ZVISION: Allow controls to be enabled or disabled --- engines/zvision/control.h | 9 +++++++-- engines/zvision/script_manager.cpp | 21 +++++++++++++++++++++ engines/zvision/script_manager.h | 3 +++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/zvision/control.h b/engines/zvision/control.h index 2d5426c0c4..b374383a45 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -35,11 +35,16 @@ class ZVision; class Control { public: + Control() : _key(0), _enabled(false) {} virtual ~Control() {} - virtual bool execute(ZVision *engine) = 0; + virtual bool enable(ZVision *engine) = 0; + virtual bool disable(ZVision *engine) { return true; } + +public: + uint32 _key; protected: - uint32 key; + bool _enabled; // Static member functions public: diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 8a1d1c98ed..13f30ca0d2 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -185,6 +185,22 @@ void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) { _globalState[key] += valueToAdd; } +bool ScriptManager::enableControl(uint32 key) { + if (!_activeControls.contains(key)) { + return false; + } else { + return _activeControls[key]->enable(_engine); + } +} + +bool ScriptManager::disableControl(uint32 key) { + if (!_activeControls.contains(key)) { + return false; + } else { + return _activeControls[key]->disable(_engine); + } +} + void ScriptManager::addActionNode(const Common::SharedPtr &node) { _activeNodes.push_back(node); } @@ -225,6 +241,11 @@ void ScriptManager::changeLocationIntern() { _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); // Add all the local puzzles to the stack to be checked + // Enable all the controls + for (Common::HashMap::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + (*iter)._value->enable(_engine); + } + for (Common::List::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) { // Reset any Puzzles that have the flag ONCE_PER_INST if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) { diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 3d64727506..7012ee0c5e 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -84,6 +84,9 @@ public: void setStateValue(uint32 key, uint value); void addToStateValue(uint32 key, uint valueToAdd); + bool enableControl(uint32 key); + bool disableControl(uint32 key); + void addActionNode(const Common::SharedPtr &node); void changeLocation(char world, char room, char node, char view, uint32 offset); -- cgit v1.2.3