2026-11-08 12:57:20 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using GladiatorIdle.Gfx;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using D = GladiatorIdle.Gfx.Draw;
|
|
|
|
|
|
|
|
|
|
namespace GladiatorIdle.Arena
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Einstellungen über jedem Bildschirm: Lautstärken (Musik, Effekte, Erzählstimme), Ton an/aus,
|
|
|
|
|
/// Vollbild, Sprache, Erzählstimme, Effekte reduzieren. Jede Änderung wird sofort gespeichert.
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal sealed class SettingsOverlay
|
|
|
|
|
{
|
|
|
|
|
readonly Ui _ui = new();
|
|
|
|
|
readonly Action _toggleFullscreen;
|
|
|
|
|
public bool Open { get; set; }
|
|
|
|
|
|
|
|
|
|
public SettingsOverlay(Action toggleFullscreen) => _toggleFullscreen = toggleFullscreen;
|
|
|
|
|
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
/// Bildrate geändert: Grafik neu einstellen (VSync, feste Rate).
|
|
|
|
|
public Action ApplyGraphics = () => { };
|
|
|
|
|
|
|
|
|
|
/// Einführung: null = kein Spielstand, true = schon gesehen; ReplayTutorial schaltet sie wieder ein.
|
|
|
|
|
public Func<bool?> Tutorial = () => null;
|
|
|
|
|
public Action ReplayTutorial = () => { };
|
|
|
|
|
|
2026-11-08 12:57:20 +01:00
|
|
|
public void Update(Input input, Matrix ui)
|
|
|
|
|
{
|
|
|
|
|
_ui.Begin(input, ui);
|
|
|
|
|
if (input.Pressed(Microsoft.Xna.Framework.Input.Keys.Escape)) { Open = false; input.PrevKeys = input.Keys; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Text ohne vorangestelltes Symbol (die Schrift hat keine Emoji).
|
|
|
|
|
static string Plain(string s) => new string(s.SkipWhile(c => !char.IsLetter(c)).ToArray());
|
|
|
|
|
|
|
|
|
|
static void Save()
|
|
|
|
|
{
|
|
|
|
|
AppSettings.Save();
|
|
|
|
|
AppSettings.ApplyVolumes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Draw(SpriteBatch sb, float scale, Vector2 offset)
|
|
|
|
|
{
|
|
|
|
|
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
|
|
|
|
|
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
|
|
|
|
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.6f);
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
var r = new RectangleF(Camera.W / 2 - 420, 24, 840, 1032);
|
2026-11-08 12:57:20 +01:00
|
|
|
Ui.Panel(sb, r, D.Gold, 0.97f);
|
|
|
|
|
float x = r.X + 50, y = r.Y + 60, w = r.Width - 100;
|
|
|
|
|
D.Text(sb, Assets.Serif, 40, L.t("main.settings").ToUpperInvariant(), new Vector2(r.Center.X, y), D.Gold, Align.Center);
|
|
|
|
|
|
|
|
|
|
// Audio
|
|
|
|
|
y += 70;
|
|
|
|
|
D.Text(sb, Assets.SansBold, 18, L.t("settings.sec.audio"), new Vector2(x, y), D.Dim);
|
|
|
|
|
y += 40;
|
|
|
|
|
Volume(sb, x, y, w, L.t("settings.row.music"), () => AppSettings.MusicVolume, v => AppSettings.MusicVolume = v); y += 56;
|
|
|
|
|
Volume(sb, x, y, w, L.t("settings.row.sfx"), () => AppSettings.SfxVolume, v => AppSettings.SfxVolume = v); y += 56;
|
|
|
|
|
Volume(sb, x, y, w, L.t("settings.vol.voice"), () => AppSettings.VoiceVolume, v => AppSettings.VoiceVolume = v); y += 56;
|
|
|
|
|
Toggle(sb, x, y, w, Plain(L.t(AppSettings.Muted ? "settings.muted" : "settings.sound.on")), !AppSettings.Muted,
|
|
|
|
|
() => { AppSettings.Muted = !AppSettings.Muted; if (!AppSettings.Muted) SoundManager.StartAmbient(); });
|
|
|
|
|
y += 56;
|
|
|
|
|
Toggle(sb, x, y, w, L.t("settings.narration"), AppSettings.Narration, () => AppSettings.Narration = !AppSettings.Narration);
|
|
|
|
|
|
|
|
|
|
// Anzeige
|
|
|
|
|
y += 80;
|
|
|
|
|
D.Text(sb, Assets.SansBold, 18, L.t("settings.sec.display"), new Vector2(x, y), D.Dim);
|
|
|
|
|
y += 40;
|
|
|
|
|
Toggle(sb, x, y, w, L.t("settings.fullscreen"), AppSettings.Fullscreen, _toggleFullscreen);
|
|
|
|
|
y += 56;
|
|
|
|
|
Toggle(sb, x, y, w, L.t("settings.reducemotion"), AppSettings.ReduceMotion, () => AppSettings.ReduceMotion = !AppSettings.ReduceMotion);
|
|
|
|
|
y += 56;
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
Toggle(sb, x, y, w, L.t("settings.antialias"), AppSettings.AntiAlias, () => AppSettings.AntiAlias = !AppSettings.AntiAlias);
|
|
|
|
|
y += 56;
|
|
|
|
|
Toggle(sb, x, y, w, L.t("settings.bloom"), AppSettings.Bloom, () => AppSettings.Bloom = !AppSettings.Bloom);
|
|
|
|
|
y += 56;
|
|
|
|
|
D.Text(sb, Assets.Sans, 22, L.t("settings.framerate"), new Vector2(x, y), D.Sand);
|
|
|
|
|
var rates = new[] { "settings.fps.vsync", "settings.fps.120", "settings.fps.max" };
|
|
|
|
|
for (int i = 0; i < rates.Length; i++)
|
|
|
|
|
if (_ui.Button(sb, new RectangleF(x + w - 3 * 150 - 20 + i * 160, y - 22, 150, 44), L.t(rates[i]), selected: AppSettings.FrameLimit == i, size: 18)
|
|
|
|
|
&& AppSettings.FrameLimit != i)
|
|
|
|
|
{ AppSettings.FrameLimit = i; Save(); ApplyGraphics(); }
|
|
|
|
|
y += 56;
|
2026-11-08 12:57:20 +01:00
|
|
|
D.Text(sb, Assets.Sans, 22, L.t("settings.row.language"), new Vector2(x, y), D.Sand);
|
|
|
|
|
var langs = new[] { (L.Lang.De, "Deutsch"), (L.Lang.En, "English"), (L.Lang.Es, "Español") }; // i18n-ok
|
|
|
|
|
for (int i = 0; i < langs.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var (lang, name) = langs[i];
|
|
|
|
|
if (_ui.Button(sb, new RectangleF(x + w - 3 * 150 - 20 + i * 160, y - 22, 150, 44), name, selected: L.Current == lang, size: 18))
|
|
|
|
|
if (L.Current != lang && DevShot.Lang == null) L.Set(lang);
|
|
|
|
|
}
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
y += 70;
|
|
|
|
|
if (Tutorial() is bool seen)
|
|
|
|
|
{
|
|
|
|
|
D.Text(sb, Assets.Sans, 22, L.t("settings.tutorial"), new Vector2(x, y), D.Sand);
|
|
|
|
|
if (_ui.Button(sb, new RectangleF(x + w - 300, y - 22, 300, 44), L.t(seen ? "settings.tutorial.replay" : "settings.tutorial.next"), seen, size: 18))
|
|
|
|
|
ReplayTutorial();
|
|
|
|
|
}
|
2026-11-08 12:57:20 +01:00
|
|
|
|
|
|
|
|
if (_ui.Button(sb, new RectangleF(r.Center.X - 160, r.Bottom - 100, 320, 64), L.t("select.back"), selected: true, size: 26))
|
|
|
|
|
Open = false;
|
|
|
|
|
D.Text(sb, Assets.Sans, 15, $"{Credits.COPYRIGHT} · {Credits.MAIL}", new Vector2(r.Center.X, r.Bottom - 20), D.Dim, Align.Center); // i18n-ok
|
|
|
|
|
sb.End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Volume(SpriteBatch sb, float x, float y, float w, string label, Func<int> get, Action<int> set)
|
|
|
|
|
{
|
|
|
|
|
D.Text(sb, Assets.Sans, 22, label, new Vector2(x, y), D.Sand);
|
|
|
|
|
var steps = AppSettings.VolumeSteps;
|
|
|
|
|
for (int i = 0; i < steps.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
int v = steps[i];
|
|
|
|
|
var r = new RectangleF(x + w - steps.Length * 86 + i * 86, y - 20, 78, 40);
|
|
|
|
|
if (_ui.Button(sb, r, v.ToString(NumberFormat.Culture), selected: get() == v, size: 17)) { set(v); Save(); SoundManager.PlayClick(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Toggle(SpriteBatch sb, float x, float y, float w, string label, bool on, Action flip)
|
|
|
|
|
{
|
|
|
|
|
D.Text(sb, Assets.Sans, 22, label, new Vector2(x, y), D.Sand);
|
|
|
|
|
if (_ui.Button(sb, new RectangleF(x + w - 170, y - 20, 170, 40), L.t(on ? "settings.on" : "settings.off"), selected: on, size: 18))
|
|
|
|
|
{
|
|
|
|
|
flip();
|
|
|
|
|
Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|