All of the UIs should be cleared out, and that just leaves the tests.

This commit is contained in:
Zed A. Shaw 2025-08-19 23:58:42 -04:00
parent d5ff57e025
commit 564f9842a2
23 changed files with 126 additions and 145 deletions

View file

@ -3,6 +3,7 @@
#include "constants.hpp"
#include "events.hpp"
#include <optional>
#include "game_level.hpp"
namespace gui {
using namespace guecs;
@ -17,21 +18,23 @@ namespace gui {
$gui.init();
}
inline void make_clickable_area(GameLevel& level, guecs::UI &gui, const std::string &name) {
inline void make_clickable_area(std::shared_ptr<DinkyECS::World> world, guecs::UI &gui, const std::string &name) {
auto area = gui.entity(name);
gui.set<Clickable>(area, {
[&](auto) {
level.world->send<Events::GUI>(Events::GUI::AIM_CLICK, area, {});
world->send<Events::GUI>(Events::GUI::AIM_CLICK, area, {});
}
});
}
void OverlayUI::init() {
auto world = Game::current_world();
// gui.init is in the constructor
make_clickable_area($level, $gui, "top");
make_clickable_area($level, $gui, "middle");
make_clickable_area($level, $gui, "bottom");
make_clickable_area(world, $gui, "top");
make_clickable_area(world, $gui, "middle");
make_clickable_area(world, $gui, "bottom");
}
void OverlayUI::render(sf::RenderWindow& window) {
@ -55,8 +58,7 @@ namespace gui {
$gui.close<Text>(region);
}
void OverlayUI::update_level(GameLevel level) {
$level = level;
void OverlayUI::update_level() {
init();
}
}