feat(ui): add persistent bilingual settings and combat HUD

This commit is contained in:
2026-11-12 18:01:54 +08:00
parent 0857e291d5
commit 97fbf187e3
54 changed files with 3046 additions and 52 deletions
+17 -3
View File
@@ -42,6 +42,7 @@ namespace Ironspore
{
get; private set;
}
public SettingsService Settings { get; private set; }
public readonly List<string> SelectedCargo = new List<string>();
public bool MenuOpen { get; private set; } = true;
public bool Paused
@@ -76,9 +77,11 @@ namespace Ironspore
Active = this;
GameLocalization.Initialize(localization);
Application.targetFrameRate = 120;
mainStore = new ProfileStore(Path.Combine(Application.persistentDataPath, "Ironspore", "profile.json"));
mainStore = new ProfileStore(Path.Combine(GameDataPaths.DirectoryPath, "profile.json"));
Store = mainStore;
Input = Instantiate(inputTemplate);
var defaults = SettingsService.RuntimeDefaults();
Settings = new SettingsService(new SettingsStore(Path.Combine(GameDataPaths.DirectoryPath, "settings.json"), defaults), Input, defaults);
Input.Enable();
World = gameObject.AddComponent<WarzoneDirector>();
Hud = gameObject.AddComponent<GameHud>();
@@ -148,7 +151,7 @@ namespace Ironspore
public void StartTrial()
{
Trial = true;
Store = new ProfileStore(Path.Combine(Application.persistentDataPath, "Ironspore", "range.json"));
Store = new ProfileStore(Path.Combine(GameDataPaths.DirectoryPath, "range.json"));
Store.Begin(SelectedChassis, InitialEquipment, chassis[SelectedChassis].armor, 1739);
EnterField();
}
@@ -169,7 +172,10 @@ namespace Ironspore
Pilot = World.Player;
SetMenu(false);
Hud.ShowField();
Notify(Trial ? "notice.range" : "notice.enter");
if (Trial)
Notify("notice.range", Settings.Bindings.Display("View"), Settings.Bindings.Display("Interact"));
else
Notify("notice.enter");
}
public void SetMenu(bool open)
{
@@ -209,6 +215,8 @@ namespace Ironspore
{
if (Time.unscaledTime > noticeUntil)
noticeMessage = null;
if (Hud && (Hud.SettingsOpen || Hud.MenuInputConsumedThisFrame))
return;
if (!InField || !Pilot || ending)
return;
if (Action("Pause").WasPressedThisFrame())
@@ -416,6 +424,11 @@ namespace Ironspore
}
void OnApplicationFocus(bool focus)
{
if (!focus && Hud && Hud.SettingsOpen)
{
Hud.CancelSettingsInput();
return;
}
if (!focus && InField && Hud)
{
Paused = true;
@@ -434,6 +447,7 @@ namespace Ironspore
}
void OnDestroy()
{
Settings?.Dispose();
if (Input)
Destroy(Input);
Time.timeScale = 1;