Move RTS menu panel authority to daemon
This commit is contained in:
parent
e4b155576f
commit
b86635fda5
15 changed files with 361 additions and 195 deletions
|
|
@ -37,6 +37,7 @@ public static class AetheriaDocumentRegistry
|
|||
typeof(AetheriaZoneState),
|
||||
typeof(AetheriaEntitySnapshot),
|
||||
typeof(AetheriaVerseHostSettings),
|
||||
typeof(AetheriaMainMenuState),
|
||||
typeof(AetheriaEveCommandAcceptanceStatus),
|
||||
typeof(AetheriaRuntimeDaemonProviderAdvertisementDocument),
|
||||
typeof(AetheriaRuntimeDaemonHealthDocument),
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public sealed class AetheriaEveCommandAcceptanceReport
|
|||
public int AcceptedLoadoutTemplateCommands { get; set; }
|
||||
public int AcceptedVerseHostCommands { get; set; }
|
||||
public int AcceptedTradeValuePolicyCommands { get; set; }
|
||||
public int AcceptedMainMenuCommands { get; set; }
|
||||
public int RejectedCommands { get; set; }
|
||||
public string[] AcceptedCommandIds { get; set; } = [];
|
||||
public string[] RejectedCommandIds { get; set; } = [];
|
||||
|
|
@ -104,6 +105,19 @@ public static class AetheriaEveCommandBridge
|
|||
await ExecuteTradeValuePolicyCommandAsync(node, command).ConfigureAwait(false);
|
||||
report.AcceptedTradeValuePolicyCommands++;
|
||||
break;
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuContinueRun:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuNewGame:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuQuit:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowPlayerSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowVerseSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowInputSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuBackToMain:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuBackToSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuOpenRuntimeInputScreen:
|
||||
await ExecuteMainMenuCommandAsync(node, command).ConfigureAwait(false);
|
||||
report.AcceptedMainMenuCommands++;
|
||||
break;
|
||||
}
|
||||
|
||||
accepted.Add(command.CommandId ?? "");
|
||||
|
|
@ -352,6 +366,64 @@ public static class AetheriaEveCommandBridge
|
|||
}
|
||||
}
|
||||
|
||||
private static async Task ExecuteMainMenuCommandAsync(
|
||||
AetheriaStateNode node,
|
||||
AetheriaRuntimeEveCommandDocument command)
|
||||
{
|
||||
var state = await node.MutableDocument<AetheriaMainMenuState>(AetheriaStateNode.MainMenuStateKey).ReadAsync().ConfigureAwait(false) ??
|
||||
new AetheriaMainMenuState();
|
||||
var activeSurfaceId = ActiveMainMenuSurfaceFor(command.Kind, state.ActiveSurfaceId);
|
||||
state.ActiveSurfaceId = activeSurfaceId;
|
||||
state.LastCommandId = command.CommandId ?? "";
|
||||
state.LastCommand = command.Command ?? "";
|
||||
state.UpdatedAtUtc = string.IsNullOrWhiteSpace(command.IssuedAtUtc)
|
||||
? DateTimeOffset.UtcNow.ToString("O")
|
||||
: command.IssuedAtUtc;
|
||||
await node.MutableDocument<AetheriaMainMenuState>(AetheriaStateNode.MainMenuStateKey)
|
||||
.ReplaceAsync(state)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static string ActiveMainMenuSurfaceFor(
|
||||
AetheriaRuntimeEveCommandKind kind,
|
||||
string currentSurfaceId)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuBackToSettings:
|
||||
return AetheriaRuntimeMainMenuCommands.SettingsSurfaceId;
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowPlayerSettings:
|
||||
return AetheriaRuntimeMainMenuCommands.PlayerSettingsSurfaceId;
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowVerseSettings:
|
||||
return AetheriaRuntimeMainMenuCommands.VerseSettingsSurfaceId;
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuShowInputSettings:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuOpenRuntimeInputScreen:
|
||||
return AetheriaRuntimeMainMenuCommands.InputSettingsSurfaceId;
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuBackToMain:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuContinueRun:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuNewGame:
|
||||
case AetheriaRuntimeEveCommandKind.MainMenuQuit:
|
||||
return AetheriaRuntimeMainMenuCommands.RootSurfaceId;
|
||||
default:
|
||||
return NormalizeMainMenuSurfaceId(currentSurfaceId);
|
||||
}
|
||||
}
|
||||
|
||||
private static string NormalizeMainMenuSurfaceId(string surfaceId)
|
||||
{
|
||||
switch (surfaceId ?? "")
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommands.SettingsSurfaceId:
|
||||
case AetheriaRuntimeMainMenuCommands.InputSettingsSurfaceId:
|
||||
case AetheriaRuntimeMainMenuCommands.PlayerSettingsSurfaceId:
|
||||
case AetheriaRuntimeMainMenuCommands.VerseSettingsSurfaceId:
|
||||
return surfaceId;
|
||||
default:
|
||||
return AetheriaRuntimeMainMenuCommands.RootSurfaceId;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Cycle(string current, params string[] values)
|
||||
{
|
||||
if (values.Length == 0)
|
||||
|
|
|
|||
|
|
@ -259,6 +259,9 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
|
|||
public static CultRecordKey EveCommandAcceptanceStatusKey { get; } =
|
||||
new("global:aetheria.eve_command_acceptance_status.v1");
|
||||
|
||||
public static CultRecordKey MainMenuStateKey { get; } =
|
||||
new("global:aetheria.main_menu_state.v1");
|
||||
|
||||
public static CultRecordKey TradeValuePolicyKey { get; } =
|
||||
new(AetheriaTradeValuePolicy.RecordKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,4 +69,7 @@ public sealed class AetheriaEveCommandAcceptanceStatus
|
|||
|
||||
[Key(19)]
|
||||
public string[] AccountedCommandIds { get; set; } = [];
|
||||
|
||||
[Key(20)]
|
||||
public int AppliedMainMenuCommands { get; set; }
|
||||
}
|
||||
|
|
|
|||
26
Aetheria.State/Documents/AetheriaMainMenuState.cs
Normal file
26
Aetheria.State/Documents/AetheriaMainMenuState.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using GameCult.Caching;
|
||||
using MessagePack;
|
||||
|
||||
namespace Aetheria.State.Documents;
|
||||
|
||||
[CultDocument("aetheria.main_menu_state", "aetheria.main_menu_state.v1")]
|
||||
[CultGlobal]
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaMainMenuState
|
||||
{
|
||||
[Key(0)]
|
||||
[CultName]
|
||||
public string Name { get; set; } = "Aetheria main menu state";
|
||||
|
||||
[Key(1)]
|
||||
public string ActiveSurfaceId { get; set; } = "";
|
||||
|
||||
[Key(2)]
|
||||
public string LastCommandId { get; set; } = "";
|
||||
|
||||
[Key(3)]
|
||||
public string LastCommand { get; set; } = "";
|
||||
|
||||
[Key(4)]
|
||||
public string UpdatedAtUtc { get; set; } = "";
|
||||
}
|
||||
Loading…
Reference in a new issue