From 6ee253a4d8dce2f8c45f8d8256b49505db9eff4e Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sun, 15 Sep 2013 14:44:33 -0500 Subject: ZVISION: Add focus support for the ScriptManager --- engines/zvision/script_manager.cpp | 17 ++++++++++++++++- engines/zvision/script_manager.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 8dd944b1e9..3126aee8bb 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -38,7 +38,8 @@ namespace ZVision { ScriptManager::ScriptManager(ZVision *engine) - : _engine(engine) { + : _engine(engine), + _currentlyFocusedControl(0) { } ScriptManager::~ScriptManager() { @@ -254,6 +255,20 @@ void ScriptManager::disableControl(uint32 key) { } } +void ScriptManager::focusControl(uint32 key) { + for (Common::List::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + uint32 controlKey = (*iter)->getKey(); + + if (controlKey == key) { + (*iter)->focus(); + } else if (controlKey == _currentlyFocusedControl) { + (*iter)->unfocus(); + } + } + + _currentlyFocusedControl = key; +} + void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { for (Common::List::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 274905f88d..349f259198 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -74,6 +74,8 @@ private: Location _currentLocation; + uint32 _currentlyFocusedControl; + public: void initialize(); void update(uint deltaTimeMillis); @@ -88,6 +90,8 @@ public: void enableControl(uint32 key); void disableControl(uint32 key); + void focusControl(uint32 key); + /** * Called when LeftMouse is pushed. * -- cgit v1.2.3