Bring over my bag of shit shaders and use one as a placeholder for the build status indicator.
This commit is contained in:
parent
8f3a3c10c2
commit
d4d8c780a4
20 changed files with 708 additions and 9 deletions
23
gui.cpp
23
gui.cpp
|
@ -12,6 +12,7 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "sound.hpp"
|
||||
#include "shaders.hpp"
|
||||
|
||||
using std::string, std::vector;
|
||||
|
||||
|
@ -27,7 +28,7 @@ GUI::GUI(SFMLBackend &backend) : sfml(backend) {
|
|||
"[_|_|_|_|_]"
|
||||
"[hp_bar]");
|
||||
|
||||
$gui.world().set_the<Background>({$gui.$parser, ColorValue::DARK_MID});
|
||||
$gui.world().set_the<Background>({$gui.$parser, {0,0,0,0}});
|
||||
|
||||
for(auto& [name, cell] : $gui.cells()) {
|
||||
auto ent = $gui.entity(name);
|
||||
|
@ -41,7 +42,9 @@ GUI::GUI(SFMLBackend &backend) : sfml(backend) {
|
|||
$gui.set<Textual>(status, {L""});
|
||||
|
||||
auto log = $gui.entity("log");
|
||||
$gui.set<Textual>(log, {L"LOG"});
|
||||
auto& rect = $gui.get<Rectangle>(log);
|
||||
rect.color = {255,255,255,255};
|
||||
$gui.set<Effect>(log, {1000.0, "build_status"});
|
||||
|
||||
auto clock = $gui.entity("clock");
|
||||
$gui.set<Label>(clock, {L"00:00:00", 110});
|
||||
|
@ -72,6 +75,7 @@ void GUI::main_loop() {
|
|||
}
|
||||
|
||||
void GUI::build_success() {
|
||||
$hit_error = false;
|
||||
$gui.show_sprite("face", "build_success");
|
||||
sound::stop("building");
|
||||
sound::play("build_success");
|
||||
|
@ -79,6 +83,7 @@ void GUI::build_success() {
|
|||
}
|
||||
|
||||
void GUI::build_failed(bool play_sound, const string &command) {
|
||||
$hit_error = true;
|
||||
$gui.show_sprite("face", "build_failed");
|
||||
sound::stop("building");
|
||||
|
||||
|
@ -89,7 +94,18 @@ void GUI::build_failed(bool play_sound, const string &command) {
|
|||
output(fmt::format("!!! BUILD FAILED. Your command correct? '{}'", command));
|
||||
}
|
||||
|
||||
void GUI::update_status(GameEngine &game) {
|
||||
void GUI::update_status(GameEngine &game, size_t line_length, bool is_error) {
|
||||
|
||||
auto log = $gui.entity("log");
|
||||
auto& effect = $gui.get<guecs::Effect>(log);
|
||||
effect.$shader->setUniform("line_length", (int)line_length);
|
||||
if(!$hit_error && is_error) {
|
||||
$hit_error = is_error;
|
||||
}
|
||||
|
||||
effect.$shader->setUniform("is_error", $hit_error);
|
||||
effect.run();
|
||||
|
||||
$status = fmt::format(L"HP {}\nRounds {}\nStreaks {}\nDeaths {}",
|
||||
game.hit_points, game.rounds,
|
||||
game.streak, game.deaths);
|
||||
|
@ -107,6 +123,7 @@ void GUI::you_died() {
|
|||
}
|
||||
|
||||
void GUI::building() {
|
||||
$hit_error = false;
|
||||
$gui.show_sprite("face", "building");
|
||||
output("############# START ############");
|
||||
output(">>>> Will it Build?");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue