diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 98ec3d775..080401588 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4103,8 +4103,8 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "HandleCurrentShipSettingsSurfaceCommand(", "AetheriaEveUnitySurfaceHost.RenderRuntime(", "AetheriaEveUnitySurfaceHost.Hide(_shipSettingsSurfaceDocument)", - "AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurfaceState(", - "ProjectCurrentShipSettingsSurfaceState(", + "AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurface(", + "AetheriaRuntimeShipSettingsSurfaceBuilder.Project(", "AetheriaRuntimeShipSettingsSurfaceCommands.TryRead(request, out var command)", "AetheriaRuntimeShipSettingsCommandKind.DecrementShutdownThreshold", "AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold", @@ -4143,7 +4143,8 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "switch (request.Command)", "var entity = GameManager.CurrentEntity", "GameManager.CurrentEntity == null", - "RenderCurrentShipSettingsSurface(GameManager.CurrentEntity)" + "RenderCurrentShipSettingsSurface(GameManager.CurrentEntity)", + "new AetheriaRuntimeShipSettingsSurfaceState(" }; var hits = forbiddenSymbols @@ -4170,6 +4171,7 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "public static class AetheriaRuntimeShipSettingsSurfaceCommands", "public static bool TryRead(", "AetheriaRuntimeShipSettingsSurfaceState", + "public static AetheriaRuntimeShipSettingsSurfaceState Project(", "public static AetheriaRuntimeSurfaceDocument Build(" }; var missingBuilderSymbols = requiredBuilderSymbols diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index cca23edf5..1588ac899 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -179,7 +179,7 @@ public class InventoryMenu : MonoBehaviour transform, _shipSettingsSurfaceDocument, "Aetheria Inventory Ship Settings Surface", - AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurfaceState(entity)), + AetheriaRuntimeShipSettingsSurfaceBuilder.Build(ProjectCurrentShipSettingsSurface(entity)), HandleCurrentShipSettingsSurfaceCommand, _shipSettingsSurfaceChrome); } @@ -238,14 +238,12 @@ public class InventoryMenu : MonoBehaviour AetheriaEveUnitySurfaceHost.Hide(_shipSettingsSurfaceDocument); } - private static AetheriaRuntimeShipSettingsSurfaceState ProjectCurrentShipSettingsSurfaceState(Entity entity) + private static AetheriaRuntimeShipSettingsSurfaceState ProjectCurrentShipSettingsSurface(Entity entity) { - return new AetheriaRuntimeShipSettingsSurfaceState( + return AetheriaRuntimeShipSettingsSurfaceBuilder.Project( entity?.Name ?? "", - entity == null - ? "" - : ActionGameManager.RuntimePlayerSettings.Format(entity.Settings.ShutdownPerformance), - DateTime.UtcNow.ToString("O")); + entity?.Settings?.ShutdownPerformance ?? 0f, + ActionGameManager.RuntimePlayerSettings.Format); } private void RenderCargoItemDetailsSurface(ItemInstance item) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs index fe2e875e4..d8d06c45b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeShipSettingsSurfaceBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using GameCult.Eve.Surface; @@ -30,6 +31,23 @@ namespace GameCult.Aetheria.State.Verse public const string ResetShutdownThreshold = "aetheria.inventory.current_ship_settings.shutdown.reset"; public const string Close = "aetheria.inventory.current_ship_settings.close"; + public static AetheriaRuntimeShipSettingsSurfaceState Project( + string shipName, + float shutdownPerformance, + Func formatShutdownPerformance, + DateTime updatedAtUtc = default(DateTime)) + { + if (updatedAtUtc == default(DateTime)) + updatedAtUtc = DateTime.UtcNow; + + return new AetheriaRuntimeShipSettingsSurfaceState( + shipName, + formatShutdownPerformance == null + ? shutdownPerformance.ToString("0.###", CultureInfo.InvariantCulture) + : formatShutdownPerformance(shutdownPerformance), + updatedAtUtc.ToString("O", CultureInfo.InvariantCulture)); + } + public static AetheriaRuntimeSurfaceDocument Build( AetheriaRuntimeShipSettingsSurfaceState state, long version = 1)