diff --git a/builder.cpp b/builder.cpp index bbeaf9d..6ff4f09 100644 --- a/builder.cpp +++ b/builder.cpp @@ -117,6 +117,8 @@ void Builder::START(BuildEvent) { wid = fileWatcher->addWatch(git_path, listener, true); fileWatcher->watch(); + gui.update_status(game); + state(BuildState::WAITING); } @@ -167,6 +169,8 @@ void Builder::READING(BuildEvent) { } void Builder::DONE(BuildEvent) { + gui.update_status(game); + if(game.is_dead()) { gui.you_died(); } diff --git a/guecs.cpp b/guecs.cpp index 360fe6b..aee67a8 100644 --- a/guecs.cpp +++ b/guecs.cpp @@ -206,9 +206,10 @@ namespace guecs { }); $world.query([&](auto ent, auto& cell, const auto &meter) { - float level = std::clamp(meter.percent, 0.0f, 1.0f) * float(cell.w); + int pad = meter.bar.padding * 2; + float level = std::clamp(meter.percent, 0.0f, 1.0f) * float(cell.w - pad); // ZED: this 6 is a border width, make it a thing - meter.bar.shape->setSize({std::max(level, 0.0f), float(cell.h - 6)}); + meter.bar.shape->setSize({std::max(level, 0.0f), float(cell.h - pad)}); render_helper(window, ent, true, meter.bar.shape); }); @@ -264,7 +265,11 @@ namespace guecs { void UI::show_sprite(string region, string sprite_name) { auto ent = entity(region); - if(!has(ent)) { + if(has(ent)) { + auto& to_show = get(ent); + auto sprite_texture = textures::get(sprite_name); + to_show.sprite->setTexture(*sprite_texture.texture); + } else { Sprite to_show{sprite_name}; auto& cell = cell_for(ent); to_show.init(cell); diff --git a/guecs.hpp b/guecs.hpp index be2b431..0e9d7e1 100644 --- a/guecs.hpp +++ b/guecs.hpp @@ -68,7 +68,7 @@ namespace guecs { struct Meter { float percent = 1.0f; - Rectangle bar; + Rectangle bar{}; void init(lel::Cell& cell); }; @@ -225,8 +225,6 @@ namespace guecs { void show_sprite(string region, string sprite_name); void show_text(string region, wstring content); - void update_text(string region, wstring content); - void update_label(string region, wstring content); void show_label(string region, wstring content); }; diff --git a/gui.cpp b/gui.cpp index 9d6921b..fe8713d 100644 --- a/gui.cpp +++ b/gui.cpp @@ -2,6 +2,7 @@ #include // for EXIT_SUCCESS #include // for milliseconds #include +#include #include // for allocator, shared_ptr #include // for operator+, to_string #include @@ -19,7 +20,7 @@ GUI::GUI(SFMLBackend &backend) : sfml(backend) { $gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); $gui.layout( - "[*%(200,300)face|_|*%(100,300)stats|*%(200,500)log|_]" + "[*%(200,300)face|_|*%(100,300)status|*%(200,500)log|_]" "[_|_|_|_|_]" "[_|_|_|_|_]" "[*%(300,200)clock|_|_|_|_]" @@ -36,8 +37,8 @@ GUI::GUI(SFMLBackend &backend) : sfml(backend) { auto face = $gui.entity("face"); $gui.set(face, {"building"}); - auto stats = $gui.entity("stats"); - $gui.set(stats, {L"STATS"}); + auto status = $gui.entity("status"); + $gui.set(status, {L""}); auto log = $gui.entity("log"); $gui.set(log, {L"LOG"}); @@ -45,8 +46,8 @@ GUI::GUI(SFMLBackend &backend) : sfml(backend) { auto clock = $gui.entity("clock"); $gui.set