You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
62 lines
1.5 KiB
#include "gui.hpp"
|
|
#include <stdlib.h> // for EXIT_SUCCESS
|
|
#include <chrono> // for milliseconds
|
|
#include <fmt/core.h>
|
|
#include <memory> // for allocator, shared_ptr
|
|
#include <string> // for operator+, to_string
|
|
#include <vector>
|
|
#include <SFML/Audio.hpp>
|
|
#include <nlohmann/json.hpp>
|
|
#include "builder.hpp"
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include "sound.hpp"
|
|
|
|
using std::string, std::vector;
|
|
|
|
GUI::GUI(SFMLBackend &backend) : gui(backend) {
|
|
}
|
|
|
|
void GUI::output(const string msg) {
|
|
// _lines.push_back(msg);
|
|
std::cout << msg << std::endl;
|
|
}
|
|
|
|
void GUI::main_loop() {
|
|
gui.handle_events();
|
|
gui.update_entities();
|
|
gui.update_log(_lines);
|
|
}
|
|
|
|
void GUI::build_success() {
|
|
gui.change_face("build_success");
|
|
sound::stop("building");
|
|
sound::play("build_success");
|
|
output("BUILD FINISHED!");
|
|
}
|
|
|
|
void GUI::build_failed(bool play_sound, const string &command) {
|
|
gui.change_face("build_failed");
|
|
sound::stop("building");
|
|
|
|
if(play_sound) {
|
|
sound::play("build_failed");
|
|
}
|
|
|
|
output(fmt::format("!!! BUILD FAILED. Your command correct? '{}'", command));
|
|
}
|
|
|
|
void GUI::you_died() {
|
|
gui.change_face("you_died");
|
|
sound::stop("building");
|
|
sound::play("you_died");
|
|
output("!!!! YOU DIED! !!!! Learn to code luser.");
|
|
output("YOU DIED!");
|
|
}
|
|
|
|
void GUI::building() {
|
|
gui.change_face("building");
|
|
output("############# START ############");
|
|
output(">>>> Will it Build?");
|
|
sound::play("building");
|
|
}
|
|
|