From 1179d6eb43cf24f694874a479d32e3e8a39ecc2a Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 8 Apr 2026 11:32:49 -0400 Subject: [PATCH] More refinement of the UIStack. --- src/gui/fsm.cpp | 6 +++--- src/gui/uistack.hpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gui/fsm.cpp b/src/gui/fsm.cpp index c6e4f85..646d18d 100644 --- a/src/gui/fsm.cpp +++ b/src/gui/fsm.cpp @@ -49,8 +49,8 @@ namespace gui { $main_ui.init(); $loot_ui.init(); - for(auto& name : $screens.screens.keys()) { - $screens.screens[name]->init(); + for(auto& name : $screens.names()) { + $screens.at(name)->init(); } // BUG: maybe this is a function on main_ui? @@ -584,7 +584,7 @@ namespace gui { if(level.index < levels_to_win) { show_scene("NEXT_LEVEL"); - $screens.current_ui()->set_text(fmt::format("ENTERING\nLEVEL\n{}", level.index+2)); + $screens.active_ui()->set_text(fmt::format("ENTERING\nLEVEL\n{}", level.index+2)); state(State::NEXT_LEVEL_SCENE); } else { show_scene("WIN"); diff --git a/src/gui/uistack.hpp b/src/gui/uistack.hpp index 384a12b..d414d1d 100644 --- a/src/gui/uistack.hpp +++ b/src/gui/uistack.hpp @@ -77,14 +77,22 @@ namespace gui { update_active(screens.end() - 1); } - const std::string& current_name() { + const std::string& active_name() { dbc::check($active != nullptr, "you didn't set active"); return (*$current).first; } - std::shared_ptr current_ui() { + std::shared_ptr active_ui() { dbc::check($active != nullptr, "you didn't set active"); return (*$current).second; } + + std::shared_ptr at(const std::string& name) { + return screens.at(name); + } + + const UIStackMap::key_container_type& names() { + return screens.keys(); + } }; }