Can now use -g to set a goal.

This commit is contained in:
Zed A. Shaw 2025-04-24 13:00:40 -04:00
parent 3d4ddde96e
commit 210b0e4d21
7 changed files with 40 additions and 13 deletions

19
gui.cpp
View file

@ -16,8 +16,9 @@
using std::string, std::vector;
GUI::GUI(int timer_seconds) :
GUI::GUI(int timer_seconds, const std::wstring &g) :
$timer_seconds(timer_seconds),
$goal(g),
$window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Turing's Tarpit")
{
using namespace guecs;
@ -26,11 +27,11 @@ GUI::GUI(int timer_seconds) :
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
$gui.layout(
"[*%(200,300)face|_|*%(100,300)status|*%(200,500)log|_]"
"[*%(200,500)log|_|*%(100,300)status|*%(200,300)face|_]"
"[_|_|_|_|_]"
"[_|_|_|_|_]"
"[*%(300,200)clock|_|_|_|_]"
"[_|_|_|_|_]"
"[_|_|*%(300,100)goal|_|_]"
"[_|_|*%(300,100)clock|_|_]"
"[hp_bar]");
$gui.world().set_the<Background>({$gui.$parser, {0,0,0,0}});
@ -52,7 +53,15 @@ GUI::GUI(int timer_seconds) :
$gui.set<Effect>($log, {(float)$timer_seconds, "build_status"});
auto clock = $gui.entity("clock");
$gui.set<Label>(clock, {L"00:00:00", 110});
auto& clock_rect = $gui.get<Rectangle>(clock);
clock_rect.color = ColorValue::BLACK;
$gui.set<Label>(clock, {L"00:00:00", 60});
auto goal = $gui.entity("goal");
std::wstring msg = fmt::format(L"Complete '{}' in:", $goal);
auto& goal_rect = $gui.get<Rectangle>(goal);
goal_rect.color = ColorValue::BLACK;
$gui.set<Label>(goal, {msg, 30});
$hp_bar = $gui.entity("hp_bar");
$gui.set<Meter>($hp_bar, {1.0f, {10, ColorValue::LIGHT_DARK}});