There's now a GUI that shows up when you interact with stairs down.
This commit is contained in:
parent
e63a8dd920
commit
269af02993
3 changed files with 41 additions and 0 deletions
24
gui.cpp
24
gui.cpp
|
@ -30,6 +30,24 @@ using namespace std::chrono_literals;
|
|||
using namespace ftxui;
|
||||
using namespace components;
|
||||
|
||||
void NextLevelUI::create_render() {
|
||||
has_border = true;
|
||||
$no_button = Button("NO, I'M NOT", []{ fmt::println("no don't go down"); });
|
||||
$yes_button = Button("YES, I'M READY", []{ fmt::println("Going down."); });
|
||||
|
||||
$render = Renderer([&] {
|
||||
return vflow({
|
||||
paragraph($message) | border,
|
||||
$no_button->Render(),
|
||||
$yes_button->Render()
|
||||
}) | flex;
|
||||
});
|
||||
|
||||
set_renderer($render);
|
||||
add($yes_button);
|
||||
add($no_button);
|
||||
}
|
||||
|
||||
void DeathUI::create_render() {
|
||||
has_border = true;
|
||||
$exit_button = Button("EXIT", []{ std::exit(0); });
|
||||
|
@ -211,6 +229,7 @@ void GUI::create_renderer() {
|
|||
$status_ui.create_render();
|
||||
$inventory_ui.create_render();
|
||||
$death_ui.create_render();
|
||||
$next_level_ui.create_render();
|
||||
|
||||
$active_panels = {&$map_view, &$status_ui};
|
||||
}
|
||||
|
@ -269,6 +288,7 @@ void GUI::handle_world_events() {
|
|||
auto& device = std::any_cast<Device&>(data);
|
||||
$status_ui.log(format("Up stairs has test {}.",
|
||||
(bool)device.config["test"]));
|
||||
toggle_modal(&$next_level_ui, $next_level);
|
||||
} break;
|
||||
default:
|
||||
$status_ui.log(format("INVALID EVENT! {},{}", evt, entity));
|
||||
|
@ -441,6 +461,10 @@ void GUI::render_scene() {
|
|||
draw_paused();
|
||||
$death_ui.render();
|
||||
$renderer.draw($death_ui);
|
||||
} else if($next_level) {
|
||||
draw_paused();
|
||||
$next_level_ui.render();
|
||||
$renderer.draw($next_level_ui);
|
||||
} else {
|
||||
$map_view.render();
|
||||
$renderer.draw($map_view);
|
||||
|
|
15
gui.hpp
15
gui.hpp
|
@ -59,6 +59,19 @@ class DeathUI : public Panel {
|
|||
void create_render();
|
||||
};
|
||||
|
||||
class NextLevelUI : public Panel {
|
||||
public:
|
||||
Component $render = nullptr;
|
||||
Component $yes_button = nullptr;
|
||||
Component $no_button = nullptr;
|
||||
std::string $message = "Are you ready to go further down?";
|
||||
|
||||
NextLevelUI() :
|
||||
Panel(INVENTORY_PIXEL_X, INVENTORY_PIXEL_Y, INVENTORY_WIDTH, INVENTORY_HEIGHT) {}
|
||||
|
||||
void create_render();
|
||||
};
|
||||
|
||||
class InventoryUI : public Panel {
|
||||
public:
|
||||
|
||||
|
@ -117,10 +130,12 @@ class GUI {
|
|||
MapViewUI $map_view;
|
||||
InventoryUI $inventory_ui;
|
||||
DeathUI $death_ui;
|
||||
NextLevelUI $next_level_ui;
|
||||
Canvas $canvas;
|
||||
bool $inventory_open = false;
|
||||
bool $player_died = false;
|
||||
bool $modal_shown = false;
|
||||
bool $next_level = false;
|
||||
Component $test_button;
|
||||
SoundManager $sounds;
|
||||
SFMLRender $renderer;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
TODAY'S GOAL:
|
||||
|
||||
* GUI needs to become a statemachine now. Too many panels open at too many times.
|
||||
* Panels should be able to take a width/height and center theirself for me
|
||||
* Linux on Arch catch2 fails with catch2-main missing and xwayland displays weird when small (gentoo plasma6 wayland).
|
||||
* Position needs three types of collision: full, false, and none.
|
||||
* Stairs \u2ac5 for stairs down, and \u2259 stairs up
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue