The gui can now pop open a modal based on clicking a button but I need to manage focus next.
This commit is contained in:
parent
34c84343db
commit
64855f3c90
6 changed files with 80 additions and 45 deletions
24
gui.cpp
24
gui.cpp
|
@ -34,6 +34,7 @@ GUI::GUI(DinkyECS::World &world, Map& game_map) :
|
|||
$log({{"Welcome to the game!"}}),
|
||||
$status_ui(SCREEN_X, SCREEN_Y, 0, 0),
|
||||
$map_view(0, 0, GAME_MAP_POS, 0, false),
|
||||
$modal_test(SCREEN_X/2, SCREEN_Y/4, 800, 200, false),
|
||||
$view_port{0,0},
|
||||
$world(world),
|
||||
$sounds("./assets"),
|
||||
|
@ -70,7 +71,24 @@ void GUI::create_renderer() {
|
|||
return canvas($canvas);
|
||||
}));
|
||||
|
||||
auto test_button = Button("TEST", [&]{ println("pressed"); });
|
||||
auto modal_buttons = Container::Horizontal({
|
||||
Button("OK", [&]{ println("OK pressed"); }),
|
||||
Button("CANCEL", [&]{ println("CANCEL pressed"); }),
|
||||
});
|
||||
|
||||
$modal_test.set_renderer(Renderer([&, modal_buttons] {
|
||||
return hbox({
|
||||
hflow(
|
||||
vbox(
|
||||
text("Hello!"),
|
||||
modal_buttons->Render()
|
||||
))}) | border;
|
||||
}));
|
||||
|
||||
auto test_button = Container::Horizontal({
|
||||
Button("Open Test Modal", [&]{ $show_modal = true; }),
|
||||
Button("Close It", [&]{ $show_modal = false; }),
|
||||
});
|
||||
|
||||
auto status_rend = Renderer(test_button, [&, test_button, player]{
|
||||
const auto& player_combat = $world.get<Combat>(player.entity);
|
||||
|
@ -214,6 +232,10 @@ void GUI::render_scene() {
|
|||
$renderer.draw_text($status_ui);
|
||||
$renderer.draw_grid($map_view);
|
||||
|
||||
if($show_modal) {
|
||||
$renderer.draw_text($modal_test);
|
||||
}
|
||||
|
||||
$renderer.display();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue