Added settings.ini

This commit is contained in:
2025-11-23 19:08:35 +01:00
parent adec55526e
commit f0a6b0d974
9 changed files with 258 additions and 26 deletions

View File

@ -6,6 +6,7 @@
#include <SDL3/SDL.h>
#include <algorithm>
#include <cctype>
#include "../core/Settings.h"
OptionsState::OptionsState(StateContext& ctx) : State(ctx) {}
@ -233,18 +234,36 @@ void OptionsState::toggleFullscreen() {
if (ctx.fullscreenFlag) {
*ctx.fullscreenFlag = nextState;
}
// Save setting
Settings::instance().setFullscreen(nextState);
Settings::instance().save();
}
void OptionsState::toggleMusic() {
Audio::instance().toggleMute();
// If muted, music is disabled. If not muted, music is enabled.
// Note: Audio::instance().isMuted() returns true if muted.
// But Audio class doesn't expose isMuted directly in header usually?
// Let's assume toggleMute toggles internal state.
// We can track it via ctx.musicEnabled if it's synced.
bool enabled = true;
if (ctx.musicEnabled) {
*ctx.musicEnabled = !*ctx.musicEnabled;
enabled = *ctx.musicEnabled;
}
// Save setting
Settings::instance().setMusicEnabled(enabled);
Settings::instance().save();
}
void OptionsState::toggleSoundFx() {
bool next = !SoundEffectManager::instance().isEnabled();
SoundEffectManager::instance().setEnabled(next);
// Save setting
Settings::instance().setSoundEnabled(next);
Settings::instance().save();
}
void OptionsState::exitToMenu() {