Skip to content

Commit 8189225

Browse files
Fixed the hide all button not doing anything in the menu bar
1 parent e881332 commit 8189225

3 files changed

Lines changed: 36 additions & 33 deletions

File tree

SourceFiles/GuiGlobalConstants.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,38 @@ class GuiGlobalConstants
9898
is_window_controller_open = prev_is_window_controller_open;
9999
}
100100

101+
// Method to set the hide_all state and update panels accordingly
102+
static void SetHideAll(bool hide)
103+
{
104+
if (hide)
105+
{
106+
if (!hide_all) {
107+
SaveCurrentStates();
108+
}
109+
hide_all = true;
110+
is_dat_browser_open = false;
111+
is_dat_browser_resizeable = false;
112+
is_dat_browser_movable = false;
113+
is_left_panel_open = false;
114+
is_right_panel_open = false;
115+
is_hex_editor_open = false;
116+
is_text_panel_open = false;
117+
is_audio_controller_open = false;
118+
is_texture_panel_open = false;
119+
is_picking_panel_open = false;
120+
is_compare_panel_open = false;
121+
is_custom_file_info_editor_open = false;
122+
is_extract_panel_open = false;
123+
is_byte_search_panel_open = false;
124+
is_pathfinding_panel_open = false;
125+
}
126+
else
127+
{
128+
RestorePreviousStates();
129+
hide_all = false;
130+
}
131+
}
132+
101133
// Method to reset all panels to default visibility
102134
static void ResetToDefaults()
103135
{

SourceFiles/draw_gui_window_controller.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,10 @@ void draw_gui_window_controller()
4747

4848
// Checkbox to hide or show all windows
4949
CheckAndResetHideAll();
50-
if (ImGui::Checkbox("Hide All", &GuiGlobalConstants::hide_all))
50+
bool temp_hide_all = GuiGlobalConstants::hide_all;
51+
if (ImGui::Checkbox("Hide All", &temp_hide_all))
5152
{
52-
if (GuiGlobalConstants::hide_all)
53-
{
54-
GuiGlobalConstants::SaveCurrentStates();
55-
56-
GuiGlobalConstants::is_dat_browser_open = !GuiGlobalConstants::hide_all;
57-
GuiGlobalConstants::is_dat_browser_movable = !GuiGlobalConstants::hide_all;
58-
GuiGlobalConstants::is_dat_browser_resizeable = !GuiGlobalConstants::hide_all;
59-
GuiGlobalConstants::is_dat_browser_open = !GuiGlobalConstants::hide_all;
60-
GuiGlobalConstants::is_left_panel_open = !GuiGlobalConstants::hide_all;
61-
GuiGlobalConstants::is_right_panel_open = !GuiGlobalConstants::hide_all;
62-
GuiGlobalConstants::is_hex_editor_open = !GuiGlobalConstants::hide_all;
63-
GuiGlobalConstants::is_text_panel_open = !GuiGlobalConstants::hide_all;
64-
GuiGlobalConstants::is_audio_controller_open = !GuiGlobalConstants::hide_all;
65-
GuiGlobalConstants::is_texture_panel_open = !GuiGlobalConstants::hide_all;
66-
GuiGlobalConstants::is_picking_panel_open = !GuiGlobalConstants::hide_all;
67-
GuiGlobalConstants::is_compare_panel_open = !GuiGlobalConstants::hide_all;
68-
GuiGlobalConstants::is_custom_file_info_editor_open = !GuiGlobalConstants::hide_all;
69-
GuiGlobalConstants::is_extract_panel_open = !GuiGlobalConstants::hide_all;
70-
GuiGlobalConstants::is_byte_search_panel_open = !GuiGlobalConstants::hide_all;
71-
GuiGlobalConstants::is_pathfinding_panel_open = !GuiGlobalConstants::hide_all;
72-
}
73-
else
74-
{
75-
GuiGlobalConstants::RestorePreviousStates();
76-
}
53+
GuiGlobalConstants::SetHideAll(temp_hide_all);
7754
GuiGlobalConstants::SaveSettings();
7855
}
7956

SourceFiles/draw_ui.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,7 @@ void draw_ui(std::map<int, std::unique_ptr<DATManager>>& dat_managers, int& dat_
8484
}
8585
ImGui::Separator();
8686
if (ImGui::MenuItem("Hide All", NULL, GuiGlobalConstants::hide_all)) {
87-
if (GuiGlobalConstants::hide_all) {
88-
GuiGlobalConstants::RestorePreviousStates();
89-
GuiGlobalConstants::hide_all = false;
90-
} else {
91-
GuiGlobalConstants::SaveCurrentStates();
92-
GuiGlobalConstants::hide_all = true;
93-
}
87+
GuiGlobalConstants::SetHideAll(!GuiGlobalConstants::hide_all);
9488
GuiGlobalConstants::SaveSettings();
9589
}
9690
ImGui::EndMenu();

0 commit comments

Comments
 (0)