From 084d55d855d008965f14b29ffdf75ad3f49b6892 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 5 Jun 2024 05:51:41 -0400 Subject: [PATCH] wip: only show prompt --- assets/config_menu.rml | 2 +- src/game/input.cpp | 4 ---- src/ui/ui_config.cpp | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/assets/config_menu.rml b/assets/config_menu.rml index 6de1fb4..f097f8b 100644 --- a/assets/config_menu.rml +++ b/assets/config_menu.rml @@ -34,7 +34,7 @@
-
+
General
diff --git a/src/game/input.cpp b/src/game/input.cpp index 09da9b5..d4b9582 100644 --- a/src/game/input.cpp +++ b/src/game/input.cpp @@ -155,10 +155,6 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) { return true; } - if (recompui::get_current_menu() != recompui::Menu::Config) { - recompui::set_current_menu(recompui::Menu::Config); - } - zelda64::open_quit_game_prompt(); recompui::activate_mouse(); break; diff --git a/src/ui/ui_config.cpp b/src/ui/ui_config.cpp index e6b9c1c..1aa4b31 100644 --- a/src/ui/ui_config.cpp +++ b/src/ui/ui_config.cpp @@ -10,6 +10,7 @@ #include "ultramodern/rt64_layer.hpp" ultramodern::GraphicsConfig new_options; +Rml::DataModelHandle config_menu_model_handle; Rml::DataModelHandle nav_help_model_handle; Rml::DataModelHandle general_model_handle; Rml::DataModelHandle controls_model_handle; @@ -18,6 +19,19 @@ Rml::DataModelHandle sound_options_model_handle; recompui::PromptContext prompt_context; +struct ConfigMenuContext { + bool hide_for_prompt; + void reset() { + hide_for_prompt = false; + } + ConfigMenuContext() { + reset(); + } +}; + +ConfigMenuContext config_menu_context; + + namespace recompui { const std::unordered_map button_variants { {ButtonVariant::Primary, "primary"}, @@ -252,7 +266,17 @@ void close_config_menu() { close_config_menu_impl(); } +bool menuWasOpenBeforeOpeningPrompt = false; void zelda64::open_quit_game_prompt() { + menuWasOpenBeforeOpeningPrompt = true; + if (recompui::get_current_menu() != recompui::Menu::Config) { + recompui::set_current_menu(recompui::Menu::Config); + menuWasOpenBeforeOpeningPrompt = false; + } + + config_menu_context.hide_for_prompt = !menuWasOpenBeforeOpeningPrompt; + config_menu_model_handle.DirtyVariable("hide_for_prompt"); + prompt_context.open_prompt( "Are you sure you want to quit?", "Any progress since your last save will be lost.", @@ -261,7 +285,13 @@ void zelda64::open_quit_game_prompt() { []() { ultramodern::quit(); }, - []() {}, + []() { + if (!menuWasOpenBeforeOpeningPrompt) { + recompui::set_current_menu(recompui::Menu::None); + } + config_menu_context.hide_for_prompt = false; + config_menu_model_handle.DirtyVariable("hide_for_prompt"); + }, recompui::ButtonVariant::Error, recompui::ButtonVariant::Tertiary, true, @@ -972,6 +1002,10 @@ public: } void make_bindings(Rml::Context* context) override { + Rml::DataModelConstructor constructor = context->CreateDataModel("config_menu_model"); + constructor.Bind("hide_for_prompt", &config_menu_context.hide_for_prompt); + config_menu_model_handle = constructor.GetModelHandle(); + // initially set cont state for ui help recomp::config_menu_set_cont_or_kb(recompui::get_cont_active()); make_nav_help_bindings(context);