Rework the GUI so it uses SFMLBackend by moving the SoundQuip into SFMLBackend.

This commit is contained in:
Zed A. Shaw 2024-09-10 22:40:02 -04:00
parent 1badbd5942
commit c0ad0c8d23
4 changed files with 39 additions and 38 deletions

View file

@ -9,11 +9,33 @@
#include <SFML/Graphics/Text.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Window/Event.hpp>
#include <nlohmann/json.hpp>
#include "sfmlbackend.hpp"
using namespace fmt;
using namespace nlohmann;
using namespace ImGui;
using std::string;
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();
}
void SFMLBackend::ImGui_setup() {
bool res = SFML::Init(window);
fmt::println("IMGUI returned {}", res);