using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace GladiatorIdle { /// /// Dauerhafte Spieler-Einstellungen (%AppData%\GladiatorIdle\settings.txt, key=value). /// internal static class AppSettings { /// Stufen der Lautstärke-Knöpfe (Einstellungen) public static readonly int[] VolumeSteps = { 0, 25, 50, 75, 100 }; /// Gespeicherte Lautstärke (und Stummschaltung) an den SoundManager geben. public static void ApplyVolumes() { SoundManager.MusicLevel = MusicVolume / 100f; SoundManager.SfxLevel = SfxVolume / 100f; SoundManager.VoiceLevel = VoiceVolume / 100f; // Testläufe bleiben stumm (Program schaltet den Ton dort ab) if (!DevShot.Active && SoundManager.Enabled == Muted) SoundManager.Enabled = !Muted; } public static bool Fullscreen { get; set; } = true; /// Lautstärke in Prozent (0–100): Musik, Soundeffekte und Erzählstimme getrennt. public static int MusicVolume { get; set; } = 100; public static int SfxVolume { get; set; } = 100; public static int VoiceVolume { get; set; } = 100; /// Aller Ton aus (Taste M / Schalter in den Einstellungen); bleibt über Neustarts. public static bool Muted { get; set; } /// Textgröße im Spiel: 1 = 100 %, 2 = 115 %, 3 = 130 %. public static int TextScale { get; set; } = 1; /// Weniger Bewegung: keine Partikel, schwebenden Zahlen, Kamera-Ruck, Kampf-Clips. public static bool ReduceMotion { get; set; } /// Kantenglättung (MSAA 4×). public static bool AntiAlias { get; set; } = true; /// Nachleuchten heller Stellen (Feuer, Funken, Sonne). public static bool Bloom { get; set; } = true; /// Bildrate: 0 = an den Bildschirm gebunden (VSync), 1 = 120 Bilder/s, 2 = unbegrenzt. public static int FrameLimit { get; set; } /// Tipps im Spiel (Sprechblasen bei neuen Bereichen). public static bool Hints { get; set; } = true; /// Film-Zwischenszene beim Aufstieg in eine neue Arena (Kapitel). public static bool ChapterScenes { get; set; } = true; /// Champion-Kämpfe automatisch austragen statt selbst in Echtzeit. public static bool AutoChampion { get; set; } /// Erzählstimme (liest Intro und Kapitel vor). public static bool Narration { get; set; } = true; /// Tipps, die schon gezeigt wurden (jeder kommt nur einmal). public static HashSet HintsSeen { get; } = new(); static string FilePath => Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GladiatorIdle", "settings.txt"); public static void Load() { try { if (!File.Exists(FilePath)) return; foreach (string line in File.ReadAllLines(FilePath)) { var parts = line.Split('=', 2); if (parts.Length != 2) continue; string key = parts[0].Trim(), val = parts[1].Trim(); switch (key) { case "fullscreen": Fullscreen = val == "1"; break; case "hints": Hints = val == "1"; break; case "narration": Narration = val == "1"; break; case "chapterscenes": ChapterScenes = val == "1"; break; case "autochampion": AutoChampion = val == "1"; break; case "musicvol": if (int.TryParse(val, out int mv)) MusicVolume = Math.Clamp(mv, 0, 100); break; case "sfxvol": if (int.TryParse(val, out int sv)) SfxVolume = Math.Clamp(sv, 0, 100); break; case "voicevol": if (int.TryParse(val, out int vv)) VoiceVolume = Math.Clamp(vv, 0, 100); break; case "muted": Muted = val == "1"; break; case "reducemotion": ReduceMotion = val == "1"; break; case "antialias": AntiAlias = val == "1"; break; case "bloom": Bloom = val == "1"; break; case "framelimit": if (int.TryParse(val, out int fl)) FrameLimit = Math.Clamp(fl, 0, 2); break; case "textscale": if (int.TryParse(val, out int ts)) TextScale = Math.Clamp(ts, 1, 3); break; case "hintsseen": foreach (var id in val.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)) HintsSeen.Add(id); break; } } } catch { /* kaputte Datei → Standardwerte */ } Narration = VoiceVolume > 0; } public static void Save() { // Testläufe (--shot/--playtest) dürfen die Einstellungen des Spielers nie ändern if (DevShot.Active) return; try { Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!); File.WriteAllText(FilePath, $"fullscreen={(Fullscreen ? 1 : 0)}\n" + $"hints={(Hints ? 1 : 0)}\n" + $"narration={(Narration ? 1 : 0)}\n" + $"chapterscenes={(ChapterScenes ? 1 : 0)}\n" + $"autochampion={(AutoChampion ? 1 : 0)}\n" + $"musicvol={MusicVolume}\n" + $"sfxvol={SfxVolume}\n" + $"voicevol={VoiceVolume}\n" + $"muted={(Muted ? 1 : 0)}\n" + $"reducemotion={(ReduceMotion ? 1 : 0)}\n" + $"antialias={(AntiAlias ? 1 : 0)}\n" + $"bloom={(Bloom ? 1 : 0)}\n" + $"framelimit={FrameLimit}\n" + $"textscale={TextScale}\n" + $"hintsseen={string.Join(",", HintsSeen.OrderBy(x => x))}\n"); } catch { /* nicht speicherbar → nur für diese Sitzung */ } } /// Gespeicherten Fortschritt löschen (Spielstand, gesehene Tipps). Einstellungen bleiben. /// Testläufe löschen nichts. public static void ResetProgress() { if (DevShot.Active) { DevShot.Log("reset progress (skipped in test)"); return; } HintsSeen.Clear(); GameState.DeleteSave(); Save(); } } }