Hinter MatchOptions.Extended (Standard im Spiel, Schalter im Startbildschirm): Söldner-Einkommen (Angriffschampion +Preis/12 Einkommen dauerhaft), Kasernen (gefallener innerer Turm: Gegnerwellen +25 % und ein Monster mehr), Erschöpfung und Rückkauf (60 % Leben, Rückkauf 60 + 20 x Stufe), Mondsegen (Grottensieg +4 % je Stapel, Mondseele bei 4). Bots wählen mit erweiterten Regeln auch Sylvara und kaufen Helden zurück. Netz überträgt Regeln und neue Zustände. HUD: Einkommen, Kasernen-Symbol, Rückkauf, Segen im Teamkopf. Kern 531/531 (s1 31), EditMode 31/31, PlayMode 16/16, Verify 718/0, Selbsttest 30/30, Golden 0 Abweichungen, Fingerabdruck unverändert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
143 lines
4.8 KiB
C#
143 lines
4.8 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; since U5.4 also the
|
|
/// ambient occlusion (SSAO). Stored in PlayerPrefs. Tests can set values without touching the
|
|
/// stored ones (Persist = false); "-luneSsao 0|1" on the command line overrides the SSAO choice
|
|
/// for one session (benchmark).
|
|
/// </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;
|
|
static int _ambientOcclusion = -1;
|
|
static int _extendedRules = -1;
|
|
|
|
/// <summary>
|
|
/// S1: start matches with the extended rules (champion income, barracks, buyback,
|
|
/// Mondsegen; bots may pick Sylvara); on by default. Off = the reference rules of the port.
|
|
/// </summary>
|
|
public static bool ExtendedRules
|
|
{
|
|
get
|
|
{
|
|
if (_extendedRules < 0)
|
|
_extendedRules = PlayerPrefs.GetInt("lune.extended_rules", 1);
|
|
return _extendedRules == 1;
|
|
}
|
|
set { _extendedRules = value ? 1 : 0; Save("lune.extended_rules", _extendedRules); }
|
|
}
|
|
|
|
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); }
|
|
}
|
|
|
|
/// <summary>Screen-space ambient occlusion of the renderer (U5.4); on by default.</summary>
|
|
public static bool AmbientOcclusion
|
|
{
|
|
get
|
|
{
|
|
if (_ambientOcclusion < 0)
|
|
{
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
int at = Array.IndexOf(args, "-luneSsao");
|
|
_ambientOcclusion = at >= 0 && at + 1 < args.Length ? (args[at + 1] == "0" ? 0 : 1) : PlayerPrefs.GetInt("lune.ambient_occlusion", 1);
|
|
}
|
|
return _ambientOcclusion == 1;
|
|
}
|
|
set { _ambientOcclusion = value ? 1 : 0; Save("lune.ambient_occlusion", _ambientOcclusion); }
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|