Remove most of the image/sound managing stuff.
This commit is contained in:
parent
1be770d62d
commit
e78340a0cd
10 changed files with 34 additions and 110 deletions
26
gui.cpp
26
gui.cpp
|
@ -10,21 +10,11 @@
|
|||
#include "builder.hpp"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "sound.hpp"
|
||||
|
||||
using std::string, std::vector;
|
||||
|
||||
using namespace nlohmann;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
GUI::GUI(SFMLBackend &backend) : gui(backend) {
|
||||
std::ifstream infile(".tarpit.json");
|
||||
json data = json::parse(infile);
|
||||
|
||||
// json load the config file
|
||||
you_died_sound.load(data, "you_died");
|
||||
build_success_sound.load(data, "build_success");
|
||||
build_failed_sound.load(data, "build_failed");
|
||||
building_sound.load(data, "building", true);
|
||||
}
|
||||
|
||||
void GUI::output(const string msg) {
|
||||
|
@ -40,17 +30,17 @@ void GUI::main_loop() {
|
|||
|
||||
void GUI::build_success() {
|
||||
gui.change_face("build_success");
|
||||
building_sound.stop();
|
||||
build_success_sound.play();
|
||||
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");
|
||||
building_sound.stop();
|
||||
sound::stop("building");
|
||||
|
||||
if(play_sound) {
|
||||
build_failed_sound.play();
|
||||
sound::play("build_failed");
|
||||
}
|
||||
|
||||
output(fmt::format("!!! BUILD FAILED. Your command correct? '{}'", command));
|
||||
|
@ -58,8 +48,8 @@ void GUI::build_failed(bool play_sound, const string &command) {
|
|||
|
||||
void GUI::you_died() {
|
||||
gui.change_face("you_died");
|
||||
building_sound.stop();
|
||||
you_died_sound.play();
|
||||
sound::stop("building");
|
||||
sound::play("you_died");
|
||||
output("!!!! YOU DIED! !!!! Learn to code luser.");
|
||||
output("YOU DIED!");
|
||||
}
|
||||
|
@ -68,5 +58,5 @@ void GUI::building() {
|
|||
gui.change_face("building");
|
||||
output("############# START ############");
|
||||
output(">>>> Will it Build?");
|
||||
building_sound.play();
|
||||
sound::play("building");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue