From c7ba544c94dfaa56aad433dcc295e558ee952bfb Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Thu, 9 Jul 2020 08:46:17 -0700 Subject: [PATCH] Disabled scroll in editor when user is interacting with the top menu. --- code/redalert/scroll.cpp | 6 +++++- code/redalert/sidebareditor.cpp | 7 +++++++ code/redalert/sidebareditor.h | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/code/redalert/scroll.cpp b/code/redalert/scroll.cpp index 1de3d07..4ab9560 100644 --- a/code/redalert/scroll.cpp +++ b/code/redalert/scroll.cpp @@ -109,7 +109,11 @@ void ScrollClass::AI(KeyNumType &input, int x, int y) int screen_width = SeenBuff.Get_Width(); int screen_height = SeenBuff.Get_Height(); - bool at_screen_edge = (y == 0 || x == 0 || x >= screen_width - 1 || y >= screen_height - 1); + bool at_screen_edge = false; + + if (!Debug_Map || !Debug_LockScroll) { + at_screen_edge = (y == 0 || x == 0 || x >= screen_width - 1 || y >= screen_height - 1); + } /* ** Verify that the mouse is over a scroll region. diff --git a/code/redalert/sidebareditor.cpp b/code/redalert/sidebareditor.cpp index ede4c6d..aaad1a9 100644 --- a/code/redalert/sidebareditor.cpp +++ b/code/redalert/sidebareditor.cpp @@ -4,6 +4,8 @@ #include "function.h" #include "image.h" +bool Debug_LockScroll = false; + void SidebarEditor::init() { metalplt = LoadEditorImage("metalplt.shp"); @@ -36,10 +38,12 @@ void SidebarEditor::draw_it(void) { ImGuiStyle& style = ImGui::GetStyle(); style.FramePadding = ImVec2(0, 0); + Debug_LockScroll = false; if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu("File")) { + Debug_LockScroll = true; if (ImGui::MenuItem("New Scenario")) { mainmenu_selection = 0; } if (ImGui::MenuItem("Load Scenario")) { mainmenu_selection = 1; } if (ImGui::MenuItem("Save Scenario")) { mainmenu_selection = 2; } @@ -48,6 +52,7 @@ void SidebarEditor::draw_it(void) { } if (ImGui::BeginMenu("Map")) { + Debug_LockScroll = true; if (ImGui::MenuItem("Size Map")) { mainmenu_selection = 3; } if (ImGui::MenuItem("Scenario Options")) { mainmenu_selection = 5; } if (ImGui::MenuItem("AI Options")) { mainmenu_selection = 6; } @@ -55,12 +60,14 @@ void SidebarEditor::draw_it(void) { } if (ImGui::BeginMenu("Objects")) { + Debug_LockScroll = true; if (ImGui::MenuItem("Add Game Object")) { mainmenu_selection = 4; } ImGui::EndMenu(); } if (ImGui::BeginMenu("Run")) { + Debug_LockScroll = true; if (ImGui::MenuItem("Play Scenario")) { mainmenu_selection = 7; } ImGui::EndMenu(); } diff --git a/code/redalert/sidebareditor.h b/code/redalert/sidebareditor.h index 856727b..1c369ae 100644 --- a/code/redalert/sidebareditor.h +++ b/code/redalert/sidebareditor.h @@ -13,4 +13,6 @@ private: Image_t* LoadEditorImage(const char* name); private: Image_t* metalplt; -}; \ No newline at end of file +}; + +extern bool Debug_LockScroll; \ No newline at end of file