From 677c74d59ffe43e618911f84c2dd4302cd11478f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:12:51 +0000 Subject: ZVISION: Now onMouse functions handle return results and processing control list from end to beginning --- engines/zvision/script_manager.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 28850857df..c8ef86556a 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -392,28 +392,31 @@ void ScriptManager::killSideFxType(SideFX::SideFXType type) { void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return; - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos); + for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { + if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos)) + return; } } void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return; - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos); + for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { + if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos)) + return; } } bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return false; - bool cursorWasChanged = false; - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos); + + for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { + if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos)) + return true; } - return cursorWasChanged; + return false; } void ScriptManager::onKeyDown(Common::KeyState keyState) { -- cgit v1.2.3