Das G3-HUD steht im Spiel; die Abnahme (U3D) folgt. - U3B: alle Bereiche und Komponenten aus Godot übertragen (LuneHud, Lanes, Bossgrotte, nächste Welle, Kaufkarten, Armee, Held mit Items und Talenten, Angriffschampions, Team, Ereignisse, Minimap, Tooltip, Optionen, Partieende). Porträts aus den echten Modellen, einmal gerendert. - Offene G3-Punkte umgesetzt: „1 WELLE“ als Band am Porträtrand, Schadens- und Rüstungssymbole auf den Karten, Armeewert, Heldenporträts auf der Minimap. Befehlsplatz für die Ultimates der geplanten Helden reserviert (verborgen). - U3C: LuneGame verdrahtet Befehle (gleiche Schnittstelle wie die Bots), Bereit mit 1-s-Sperre nach dem Kampf, Tempo und Pause, Tasten wie in G3, Kamera-Ziele, Auswahl im Feld, Planungsvorschau und Aufstellungsflächen. Ersetzt die U2-Debug-Anzeige. Bot-Partien und Benchmark unverändert. - Szenen- und Bibliotheksbauer idempotent: Animator-Controller und Post-Processing-Profil werden an Ort und Stelle aktualisiert. Die Szene bekommt bei jedem Bau neue Objekt-IDs, der Inhalt ist gleich. - Prüfung (Port von verify_g3, Teile A–H): 699 Prüfungen ohne Fehler. EditMode 23/23, PlayMode 12/12, Fingerabdrücke der Bot-Partien unverändert (DCE95C96556F3A1A, 7B8E43AEFC0D60C5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
3.3 KiB
C#
108 lines
3.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Luneraria.UI
|
|
{
|
|
/// <summary>
|
|
/// Player preferences of the HUD and options (port of scripts/autoload/preferences.gd as far as
|
|
/// the HUD uses it): UI size, reduced motion, volume, mute, full screen. Stored in PlayerPrefs.
|
|
/// Tests can set values without touching the stored ones (Persist = false).
|
|
/// </summary>
|
|
public static class LunePreferences
|
|
{
|
|
public static event Action Changed;
|
|
/// <summary>False in tests: values change for the session only.</summary>
|
|
public static bool Persist = true;
|
|
|
|
static float _uiScale = -1f;
|
|
static int _reducedMotion = -1;
|
|
static float _volume = -1f;
|
|
static int _muted = -1;
|
|
static int _fullscreen = -1;
|
|
|
|
public static float UiScale
|
|
{
|
|
get
|
|
{
|
|
if (_uiScale < 0f)
|
|
_uiScale = PlayerPrefs.GetFloat("lune.ui_scale", 1f);
|
|
return _uiScale;
|
|
}
|
|
set { _uiScale = value; Save("lune.ui_scale", value); }
|
|
}
|
|
|
|
public static bool ReducedMotion
|
|
{
|
|
get
|
|
{
|
|
if (_reducedMotion < 0)
|
|
_reducedMotion = PlayerPrefs.GetInt("lune.reduced_motion", 0);
|
|
return _reducedMotion == 1;
|
|
}
|
|
set { _reducedMotion = value ? 1 : 0; Save("lune.reduced_motion", _reducedMotion); }
|
|
}
|
|
|
|
public static float Volume
|
|
{
|
|
get
|
|
{
|
|
if (_volume < 0f)
|
|
_volume = PlayerPrefs.GetFloat("lune.volume", .8f);
|
|
return _volume;
|
|
}
|
|
set { _volume = Mathf.Clamp01(value); Save("lune.volume", _volume); }
|
|
}
|
|
|
|
public static bool Muted
|
|
{
|
|
get
|
|
{
|
|
if (_muted < 0)
|
|
_muted = PlayerPrefs.GetInt("lune.muted", 0);
|
|
return _muted == 1;
|
|
}
|
|
set { _muted = value ? 1 : 0; Save("lune.muted", _muted); }
|
|
}
|
|
|
|
public static bool Fullscreen
|
|
{
|
|
get
|
|
{
|
|
if (_fullscreen < 0)
|
|
_fullscreen = PlayerPrefs.GetInt("lune.fullscreen", Screen.fullScreen ? 1 : 0);
|
|
return _fullscreen == 1;
|
|
}
|
|
set { _fullscreen = value ? 1 : 0; Save("lune.fullscreen", _fullscreen); }
|
|
}
|
|
|
|
static void Save(string key, float value)
|
|
{
|
|
if (Persist)
|
|
PlayerPrefs.SetFloat(key, value);
|
|
Changed?.Invoke();
|
|
}
|
|
|
|
static void Save(string key, int value)
|
|
{
|
|
if (Persist)
|
|
PlayerPrefs.SetInt(key, value);
|
|
Changed?.Invoke();
|
|
}
|
|
|
|
/// <summary>Writes pending values (Godot Preferences.commit).</summary>
|
|
public static void Commit()
|
|
{
|
|
if (Persist)
|
|
PlayerPrefs.Save();
|
|
}
|
|
|
|
/// <summary>Session values back to defaults (tests).</summary>
|
|
public static void ResetSession(float uiScale = 1f, bool reducedMotion = false)
|
|
{
|
|
Persist = false;
|
|
_uiScale = uiScale;
|
|
_reducedMotion = reducedMotion ? 1 : 0;
|
|
Changed?.Invoke();
|
|
}
|
|
}
|
|
}
|