menu i opcions de audio

This commit is contained in:
2026-04-05 00:07:10 +02:00
parent be4b62414e
commit 6d42f848a5
5 changed files with 233 additions and 86 deletions

View File

@@ -4,6 +4,7 @@
#include <iostream>
#include <string>
#include "core/jail/jail_audio.hpp"
#include "external/fkyaml_node.hpp"
#include "game/defaults.hpp"
#include "game/defines.hpp"
@@ -15,12 +16,23 @@ namespace Options {
config_file_path = path;
}
void applyAudio() {
const float master = audio.enabled ? audio.volume : 0.0F;
JA_EnableMusic(audio.music_enabled);
JA_EnableSound(audio.sound_enabled);
JA_SetMusicVolume(master * audio.music_volume);
JA_SetSoundVolume(master * audio.sound_volume);
}
// --- Funcions helper de càrrega ---
static void loadAudioConfigFromYaml(const fkyaml::node& yaml) {
if (!yaml.contains("audio")) return;
const auto& node = yaml["audio"];
if (node.contains("enabled"))
audio.enabled = node["enabled"].get_value<bool>();
if (node.contains("volume"))
audio.volume = node["volume"].get_value<float>();
@@ -219,6 +231,7 @@ namespace Options {
// AUDIO
file << "# AUDIO\n";
file << "audio:\n";
file << " enabled: " << (audio.enabled ? "true" : "false") << "\n";
file << " volume: " << audio.volume << "\n";
file << " music:\n";
file << " enabled: " << (audio.music_enabled ? "true" : "false") << "\n";