Rework the GUI so it uses SFMLBackend by moving the SoundQuip into SFMLBackend.
This commit is contained in:
parent
1badbd5942
commit
c0ad0c8d23
4 changed files with 39 additions and 38 deletions
20
gui.cpp
20
gui.cpp
|
@ -8,7 +8,6 @@
|
|||
#include <SFML/Audio.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include "sfmlbackend.hpp"
|
||||
#include "builder.hpp"
|
||||
|
||||
using std::string, std::vector;
|
||||
|
@ -17,25 +16,6 @@ using namespace fmt;
|
|||
using namespace nlohmann;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void SoundQuip::load(json &data, const char *file_key) {
|
||||
auto audio = data["audio"];
|
||||
json::string_t file_name = audio[file_key].template get<string>();
|
||||
|
||||
if(!buffer.loadFromFile(file_name)) {
|
||||
println("Failed to load sound: {} with file {}", file_key, file_name);
|
||||
}
|
||||
|
||||
sound.setBuffer(buffer);
|
||||
}
|
||||
|
||||
void SoundQuip::play() {
|
||||
sound.play();
|
||||
}
|
||||
|
||||
void SoundQuip::stop() {
|
||||
sound.stop();
|
||||
}
|
||||
|
||||
GUI::GUI() {
|
||||
std::ifstream infile(".tarpit.json");
|
||||
json data = json::parse(infile);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue