Got a simple GUI layout working for the most part.
This commit is contained in:
parent
4520e20ab7
commit
a13704fe33
3 changed files with 21 additions and 15 deletions
|
@ -1,7 +1,3 @@
|
||||||
|
|
||||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
|
||||||
// the LICENSE file.
|
|
||||||
#include <stdlib.h> // for EXIT_SUCCESS
|
#include <stdlib.h> // for EXIT_SUCCESS
|
||||||
#include <chrono> // for milliseconds
|
#include <chrono> // for milliseconds
|
||||||
#include <thread> // for sleep_for, thread
|
#include <thread> // for sleep_for, thread
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
|
||||||
// the LICENSE file.
|
|
||||||
#include <stdlib.h> // for EXIT_SUCCESS
|
#include <stdlib.h> // for EXIT_SUCCESS
|
||||||
#include <chrono> // for milliseconds
|
#include <chrono> // for milliseconds
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
29
gui.cpp
29
gui.cpp
|
@ -33,10 +33,10 @@ int GUI::main_loop(GameEngine &game, std::function<bool()> runner) {
|
||||||
|
|
||||||
auto status = Renderer([&] {
|
auto status = Renderer([&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
paragraph(fmt::format("HP {}", game.hit_points)),
|
text(fmt::format("HP {}", game.hit_points)),
|
||||||
separator(),
|
separator(),
|
||||||
hbox({
|
hbox({
|
||||||
text("HP"),
|
text("HP "),
|
||||||
gauge(game.hit_points / 100.0f),
|
gauge(game.hit_points / 100.0f),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -52,20 +52,33 @@ int GUI::main_loop(GameEngine &game, std::function<bool()> runner) {
|
||||||
return vbox(output);
|
return vbox(output);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto scrollable_content = Renderer(content,
|
auto game_stuff = Renderer([&] {
|
||||||
|
return vbox({
|
||||||
|
text("Welcome to...Turing's Tarpit!"),
|
||||||
|
separator(),
|
||||||
|
hbox({
|
||||||
|
text("left") | border | flex ,
|
||||||
|
text("middle") | border | flex,
|
||||||
|
text("right") | border | flex,
|
||||||
|
}) | yflex_grow
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
auto build_log = Renderer(content,
|
||||||
[&, content] {
|
[&, content] {
|
||||||
return content->Render()
|
return content->Render()
|
||||||
| focusPositionRelative(scroll_x, scroll_y)
|
| focusPositionRelative(scroll_x, scroll_y)
|
||||||
| frame | flex;
|
| frame | flex;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto component = Renderer(scrollable_content, [&] {
|
auto component = Renderer(build_log, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
status->Render(),
|
game_stuff->Render() | flex,
|
||||||
separator(),
|
separator(),
|
||||||
scrollable_content->Render() | vscroll_indicator | yframe | size(HEIGHT, LESS_THAN, 20),
|
build_log->Render() | vscroll_indicator | yframe | flex,
|
||||||
}) |
|
separator(),
|
||||||
border;
|
status->Render()
|
||||||
|
}) | border;
|
||||||
});
|
});
|
||||||
|
|
||||||
component |= CatchEvent([&](Event) -> bool {
|
component |= CatchEvent([&](Event) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue