diff --git a/gui.cpp b/gui.cpp index 3485a7e..de8c10a 100644 --- a/gui.cpp +++ b/gui.cpp @@ -84,8 +84,6 @@ void StatusUI::create_render() { GUI::GUI(DinkyECS::World &world, Map& game_map) : $game_map(game_map), $status_ui(world), - $map_view(), - $inventory_ui(), $lights(game_map.width(), game_map.height()), $world(world), $sounds("./assets"), @@ -105,7 +103,6 @@ void GUI::resize_map(int new_size) { $renderer.resize_grid(new_size, $map_view); // set canvas to best size $canvas = Canvas($map_view.width * 2, $map_view.height * 4); - dbc::log("WHY IS RESIZING LIGHTS STILL WORKING?!!!!!!!!!!!!!!!"); } void GUI::save_world() { @@ -123,6 +120,9 @@ void GUI::create_renderer() { $status_ui.create_render(); $inventory_ui.create_render(); + // don't activate this one + + $panels = {&$map_view, &$status_ui}; } void GUI::handle_world_events() { @@ -209,9 +209,11 @@ bool GUI::handle_ui_events() { } else if(KB::isKeyPressed(KB::I)) { // yes, using an if to avoid double grabbing screen if($show_modal) { + $panels = {&$map_view, &$status_ui}; $show_modal = false; } else { pause_screen(); + $panels = {&$inventory_ui}; $show_modal = true; } } else if(KB::isKeyPressed(KB::P)) { @@ -224,12 +226,16 @@ bool GUI::handle_ui_events() { } else if(KB::isKeyPressed(KB::Enter)) { $status_ui.key_press(Event::Return); } - } else if($renderer.mouse_position($status_ui, pos)) { - if(MOUSE::isButtonPressed(MOUSE::Left)) { - $status_ui.mouse_click(Mouse::Button::Left, pos); - event_happened = true; - } else { - $status_ui.mouse_release(Mouse::Button::Left, pos); + } else { + for(Panel *panel : $panels) { + if($renderer.mouse_position(*panel, pos)) { + if(MOUSE::isButtonPressed(MOUSE::Left)) { + panel->mouse_click(Mouse::Button::Left, pos); + event_happened = true; + } else { + panel->mouse_release(Mouse::Button::Left, pos); + } + } } } } diff --git a/gui.hpp b/gui.hpp index 1d97ab3..56230c3 100644 --- a/gui.hpp +++ b/gui.hpp @@ -89,6 +89,7 @@ class GUI { SoundManager $sounds; SFMLRender $renderer; UnDumbTSS $paused; + std::vector $panels; public: GUI(DinkyECS::World& world, Map& game_map); diff --git a/panel.cpp b/panel.cpp index e3a3cbf..a0ca051 100644 --- a/panel.cpp +++ b/panel.cpp @@ -36,6 +36,7 @@ const std::wstring& Panel::to_string() { } void Panel::mouse_click(ftxui::Mouse::Button btn, Point pos) { + fmt::println("CLICK AT {},{}", pos.x, pos.y); ftxui::Mouse mev{ .button=btn, .motion=ftxui::Mouse::Motion::Pressed,