mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
overlay: make overlay toggle behavior more consistent (#743)
Clean up how various overlay toggle shortcuts work with the main menu visible.
This commit is contained in:
@@ -827,14 +827,8 @@ bool overlay::SpiceOverlay::update_cursor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void overlay::SpiceOverlay::toggle_active() {
|
void overlay::SpiceOverlay::toggle_active() {
|
||||||
|
|
||||||
// invert active state
|
// invert active state
|
||||||
this->active = !this->active;
|
this->active = !this->active;
|
||||||
|
|
||||||
// get rid of main menu if it was visible
|
|
||||||
if (this->window_main_menu) {
|
|
||||||
this->window_main_menu->set_active(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void overlay::SpiceOverlay::show_main_menu() {
|
void overlay::SpiceOverlay::show_main_menu() {
|
||||||
@@ -844,12 +838,17 @@ void overlay::SpiceOverlay::show_main_menu() {
|
|||||||
if (this->window_main_menu->get_active()) {
|
if (this->window_main_menu->get_active()) {
|
||||||
// window already visible - close the window
|
// window already visible - close the window
|
||||||
this->window_main_menu->set_active(false);
|
this->window_main_menu->set_active(false);
|
||||||
|
// if the overlay was not visible when this came into view, turn off overlay as well
|
||||||
|
if (!this->overlay_active_when_main_menu_shown) {
|
||||||
|
this->set_active(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ImGui::IsPopupOpen(0, ImGuiPopupFlags_AnyPopup)) {
|
if (ImGui::IsPopupOpen(0, ImGuiPopupFlags_AnyPopup)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->overlay_active_when_main_menu_shown = this->get_active();
|
||||||
if (this->get_active()) {
|
if (this->get_active()) {
|
||||||
if (!ImGui::IsAnyItemActive() && !ImGui::IsAnyItemFocused()) {
|
if (!ImGui::IsAnyItemActive() && !ImGui::IsAnyItemFocused()) {
|
||||||
this->window_main_menu->set_active(true);
|
this->window_main_menu->set_active(true);
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ namespace overlay {
|
|||||||
bool active = false;
|
bool active = false;
|
||||||
bool toggle_down = false;
|
bool toggle_down = false;
|
||||||
bool main_menu_down = false;
|
bool main_menu_down = false;
|
||||||
|
bool overlay_active_when_main_menu_shown = false;
|
||||||
bool fps_down = false;
|
bool fps_down = false;
|
||||||
bool hotkey_toggle = false;
|
bool hotkey_toggle = false;
|
||||||
bool hotkey_toggle_last = false;
|
bool hotkey_toggle_last = false;
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ void overlay::Window::update() {
|
|||||||
|
|
||||||
// if the overlay is hidden just reactivate it
|
// if the overlay is hidden just reactivate it
|
||||||
if (!this->overlay->get_active()) {
|
if (!this->overlay->get_active()) {
|
||||||
|
|
||||||
|
// but don't let the main menu occlude it if it was previously visible
|
||||||
|
if (this->overlay->window_main_menu) {
|
||||||
|
this->overlay->window_main_menu->set_active(false);
|
||||||
|
}
|
||||||
|
|
||||||
this->active = true;
|
this->active = true;
|
||||||
this->overlay->set_active(true);
|
this->overlay->set_active(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ namespace overlay::windows {
|
|||||||
void ExitPrompt::update() {
|
void ExitPrompt::update() {
|
||||||
Window::update();
|
Window::update();
|
||||||
|
|
||||||
// allow the popup to be reopened the next time the menu is shown
|
// allow the popup to be reopened the next time the menu is shown.
|
||||||
if (!this->active) {
|
// also reset while the overlay is hidden: new_frame() doesn't submit the
|
||||||
|
// popup then, so ImGui closes it and it must be re-opened when shown again
|
||||||
|
if (!this->active || !this->overlay->get_active()) {
|
||||||
this->popup_opened = false;
|
this->popup_opened = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user