From 76f3dbfe6446905fa54f4904b18355f87b244b57 Mon Sep 17 00:00:00 2001 From: Edgar Date: Thu, 24 Sep 2020 18:52:31 +0200 Subject: [PATCH] fix scrolling triggering zoom --- src/game/editor/editor.cpp | 43 ++++++++++++++++++++------------------ src/game/editor/editor.h | 2 ++ src/game/editor/popups.cpp | 3 +++ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index b2992ba95..69f45fea9 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -5899,26 +5899,6 @@ void CEditor::Render() } } - if(m_Dialog == DIALOG_NONE && UI()->MouseInside(&View)) - { - // Determines in which direction to zoom. - int Zoom = 0; - if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) - Zoom--; - if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) - Zoom++; - - if(Zoom != 0) - { - float OldLevel = m_ZoomLevel; - m_ZoomLevel = clamp(m_ZoomLevel + Zoom * 20, 50, 2000); - if(g_Config.m_EdZoomTarget) - ZoomMouseTarget((float)m_ZoomLevel / OldLevel); - } - } - - m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000); - m_WorldZoom = m_ZoomLevel/100.0f; float Brightness = 0.25f; if(m_GuiActive) @@ -6109,6 +6089,27 @@ void CEditor::Render() UiDoPopupMenu(); + if(m_Dialog == DIALOG_NONE && !m_MouseInsidePopup && UI()->MouseInside(&View)) + { + // Determines in which direction to zoom. + int Zoom = 0; + if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) + Zoom--; + if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) + Zoom++; + + if(Zoom != 0) + { + float OldLevel = m_ZoomLevel; + m_ZoomLevel = clamp(m_ZoomLevel + Zoom * 20, 50, 2000); + if(g_Config.m_EdZoomTarget) + ZoomMouseTarget((float)m_ZoomLevel / OldLevel); + } + } + + m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000); + m_WorldZoom = m_ZoomLevel/100.0f; + if(m_GuiActive) RenderStatusbar(StatusBar); @@ -6147,6 +6148,8 @@ void CEditor::Render() Graphics()->QuadsEnd(); Graphics()->WrapNormal(); } + + m_MouseInsidePopup = false; } static int UndoStepsListdirCallback(const char *pName, int IsDir, int StorageType, void *pUser) diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 3fea2a056..803ed3c03 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -662,6 +662,7 @@ public: m_PopupEventActivated = false; m_PopupEventWasActivated = false; + m_MouseInsidePopup = false; m_FileDialogStorageType = 0; m_pFileDialogTitle = 0; @@ -818,6 +819,7 @@ public: int m_PopupEventType; int m_PopupEventActivated; int m_PopupEventWasActivated; + bool m_MouseInsidePopup; bool m_LargeLayerWasWarned; bool m_PreventUnusedTilesWasWarned; int m_AllowPlaceUnusedTiles; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 5c8a1ee6f..7628b64b3 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -52,6 +52,9 @@ void CEditor::UiDoPopupMenu() bool Inside = UI()->MouseInside(&s_UiPopups[i].m_Rect); UI()->SetHotItem(&s_UiPopups[i].m_pId); + if(Inside) + m_MouseInsidePopup = true; + if(UI()->ActiveItem() == &s_UiPopups[i].m_pId) { if(!UI()->MouseButton(0))