From 1066bce086162b5f21dc7de8bc7dd9f852984b52 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 17 Jun 2026 01:50:15 +0100 Subject: [PATCH] Move equipped item inventory controls onto Eve surfaces --- Aetheria.State.Verify/Program.cs | 97 +++- Assets/Scenes/ARPG.unity | 2 - Assets/Scripts/Gameplay/ActionGameManager.cs | 71 +++ Assets/Scripts/UI/Menu/InventoryMenu.cs | 453 ++++++++++++++++++- docs/aetheria-perfect-machine-map.md | 27 +- 5 files changed, 616 insertions(+), 34 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 90ce86226..f6bf7a801 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -37,6 +37,7 @@ RequireSectorMapZoneDetailsUseEveSurface(root); RequireRuntimeMenuTabsUseEveSurface(root); RequireInventoryShipSettingsUseEveSurface(root); RequireInventoryCargoItemDetailsUseEveSurface(root); +RequireInventoryEquippedItemDetailsUseEveSurface(root); RequireTradeCargoSelectorUseEveSurface(root); RequireTradeFilterAndRowActionsUseEveSurface(root); RequireTradeItemDetailsUseEveSurface(root); @@ -510,6 +511,7 @@ Console.WriteLine("Sector-map zone details shell: zone inspection lowers through Console.WriteLine("Runtime menu tab shell: MenuPanel owns tab metadata and lowers navigation through an Eve UI Toolkit surface"); Console.WriteLine("Inventory ship-settings shell: background ship tuning lowers through an Eve UI Toolkit surface instead of PropertiesPanel.AddField"); Console.WriteLine("Inventory cargo-item shell: cargo item inspection lowers through an Eve UI Toolkit surface instead of PropertiesPanel.Inspect"); +Console.WriteLine("Inventory equipped-item shell: equipped item inspection and weapon-group controls lower through an Eve UI Toolkit surface instead of PropertiesPanel.Inspect"); Console.WriteLine("Trade cargo-selector shell: target cargo selection lowers through an Eve UI Toolkit surface instead of ContextMenu.AddOption"); Console.WriteLine("Trade filter and row-action shells: filter selection and buy-quantity entry lower through Eve UI Toolkit surfaces instead of ContextMenu dropdowns"); Console.WriteLine("Trade item-details shell: typed item inspection lowers through an Eve UI Toolkit surface instead of PropertiesPanel.Inspect"); @@ -2700,19 +2702,100 @@ static void RequireInventoryCargoItemDetailsUseEveSurface(string root) { throw new InvalidOperationException("InventoryMenu cargo click path no longer routes item inspection through the Eve surface."); } +} - var propertiesInspectCount = CountOccurrences(source, "PropertiesPanel.Inspect(item);"); - if (propertiesInspectCount != 1) +static void RequireInventoryEquippedItemDetailsUseEveSurface(string root) +{ + var inventoryMenuPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryMenu.cs"); + var actionGameManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs"); + if (!File.Exists(inventoryMenuPath)) { - throw new InvalidOperationException( - $"InventoryMenu should keep exactly one equipped-item PropertiesPanel inspect path for now; found {propertiesInspectCount}."); + throw new InvalidOperationException("Cannot verify inventory equipped-item shell; InventoryMenu.cs is missing."); } - var propertiesSetActiveCount = CountOccurrences(source, "PropertiesPanel.gameObject.SetActive(true);"); - if (propertiesSetActiveCount != 1) + if (!File.Exists(actionGameManagerPath)) + { + throw new InvalidOperationException("Cannot verify inventory equipped-item shell; ActionGameManager.cs is missing."); + } + + var source = File.ReadAllText(inventoryMenuPath); + var requiredSymbols = new[] + { + "EquippedItemDetailsSurfaceId", + "RenderEquippedItemDetailsSurface(", + "HandleEquippedItemDetailsSurfaceCommand(", + "ResolveEquippedItemDetailsSurfaceDocument(", + "BuildEquippedItemDetailsSurfaceDefinition(", + "BuildEquippedItemControlCard(", + "BuildEquippedItemWeaponGroupCard(", + "BuildEquippedItemActionBarCards(", + "BuildItemBehaviorCards(", + "CommandButton(", + "TextField(", + "CloseEquippedItemDetailsCommand", + "ToggleEquippedItemOverrideShutdownCommand", + "SetEquippedItemTargetTemperatureCommand", + "ToggleEquippedItemWeaponGroupCommand", + "BindEquippedItemWeaponGroupCommand", + "ClearEquippedItemActionBarBindingCommand", + "new EveUiToolkitSurfaceLowerer()" + }; + + var missingSymbols = requiredSymbols + .Where(symbol => !source.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (missingSymbols.Length > 0) { throw new InvalidOperationException( - $"InventoryMenu should keep exactly one equipped-item PropertiesPanel activation path for now; found {propertiesSetActiveCount}."); + "InventoryMenu no longer lowers equipped-item inspection through an Eve surface shell: " + + string.Join(", ", missingSymbols)); + } + + if (!source.Contains("RenderEquippedItemDetailsSurface(item);", StringComparison.Ordinal)) + { + throw new InvalidOperationException("InventoryMenu equipped-item click path no longer routes inspection through the Eve surface."); + } + + var forbiddenSymbols = new[] + { + "public PropertiesPanel PropertiesPanel;", + "PropertiesPanel.GameManager = GameManager;", + "PropertiesPanel.gameObject.SetActive(true);", + "PropertiesPanel.Inspect(item);" + }; + + var hits = forbiddenSymbols + .Where(symbol => source.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (hits.Length > 0) + { + throw new InvalidOperationException( + "InventoryMenu still owns equipped-item inspection through the old PropertiesPanel shell: " + + string.Join(", ", hits)); + } + + var actionGameManagerSource = File.ReadAllText(actionGameManagerPath); + var requiredActionBarSymbols = new[] + { + "GetActionBarSlotCount(", + "GetActionBarSlotLabel(", + "GetActionBarBindingLabel(", + "CommitWeaponGroupActionBarBinding(", + "CommitClearActionBarBinding(", + "QueueRunCheckpoint(\"action-bar-binding\")" + }; + + var missingActionBarSymbols = requiredActionBarSymbols + .Where(symbol => !actionGameManagerSource.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (missingActionBarSymbols.Length > 0) + { + throw new InvalidOperationException( + "ActionGameManager no longer exposes the equipped-item action-bar binding authority surface: " + + string.Join(", ", missingActionBarSymbols)); } } diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index c0fc7fadf..b554e6477 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -30096,9 +30096,7 @@ MonoBehaviour: InventoryPanels: - {fileID: 1897237531} - {fileID: 1010491577} - PropertiesPanel: {fileID: 7399108074413661592} GameManager: {fileID: 1009503729} - DragParent: {fileID: 245842385} Dialog: {fileID: 620555924} --- !u!1 &1998350928 GameObject: diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 430847ace..7c4d99c76 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -742,6 +742,56 @@ public class ActionGameManager : MonoBehaviour return true; } + public int GetActionBarSlotCount() + { + return _actionBarSlots?.Count ?? 0; + } + + public string GetActionBarSlotLabel(int slotIndex) + { + var slot = ResolveActionBarSlot(slotIndex); + return slot == null ? "" : GetActionBarSlotLabel(slot); + } + + public string GetActionBarBindingLabel(int slotIndex) + { + var slot = ResolveActionBarSlot(slotIndex); + return slot?.Binding switch + { + ActionBarWeaponGroupBinding weaponGroup => $"G{weaponGroup.Group + 1}", + ActionBarConsumableBinding consumable => consumable.Target?.Name ?? "Consumable", + ActionBarGearBinding gear => RuntimeCatalog?.FindItem(gear.Item?.EquippableItem?.ItemKey ?? "")?.Name ?? "Gear", + _ => "Empty" + }; + } + + public bool CommitWeaponGroupActionBarBinding(int slotIndex, int groupIndex) + { + var slot = ResolveActionBarSlot(slotIndex); + if (slot == null || + CurrentEntity?.WeaponGroups == null || + groupIndex < 0 || + groupIndex >= CurrentEntity.WeaponGroups.Length) + { + return false; + } + + slot.Binding = new ActionBarWeaponGroupBinding(CurrentEntity, slot, groupIndex); + QueueRunCheckpoint("action-bar-binding"); + return true; + } + + public bool CommitClearActionBarBinding(int slotIndex) + { + var slot = ResolveActionBarSlot(slotIndex); + if (slot == null) + return false; + + slot.Binding = null; + QueueRunCheckpoint("action-bar-binding"); + return true; + } + private void RestoreActionBarBindingsFromTypedRun( IReadOnlyList bindings) { @@ -872,6 +922,27 @@ public class ActionGameManager : MonoBehaviour } } + private ActionBarSlot ResolveActionBarSlot(int slotIndex) + { + return _actionBarSlots != null && + slotIndex >= 0 && + slotIndex < _actionBarSlots.Count + ? _actionBarSlots[slotIndex] + : null; + } + + private static string GetActionBarSlotLabel(ActionBarSlot slot) + { + var controlPath = slot?.ControlPath ?? ""; + if (string.IsNullOrWhiteSpace(controlPath)) + return "Action Bar"; + + var slashIndex = controlPath.LastIndexOf('/'); + return slashIndex >= 0 && slashIndex < controlPath.Length - 1 + ? controlPath.Substring(slashIndex + 1) + : controlPath; + } + private AetheriaRuntimeCatalogItem FindTypedActionBarConsumable(ItemInstance item) { var typedItem = FindTypedActionBarItem(item); diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index 46e000913..2c97b166f 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -3,8 +3,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ using System; -using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Linq; using GameCult.Aetheria.State.Unity; using GameCult.Eve.Surface; @@ -13,8 +13,6 @@ using UnityEngine; using UniRx; using UniRx.Triggers; using Unity.Mathematics; -using UnityEngine.InputSystem; -using UnityEngine.UI; using UnityEngine.UIElements; public class InventoryMenu : MonoBehaviour @@ -30,12 +28,17 @@ public class InventoryMenu : MonoBehaviour private const string CloseShipSettingsCommand = "aetheria.inventory.current_ship_settings.close"; private const string CargoItemDetailsSurfaceId = "aetheria.inventory.cargo_item_details"; private const string CloseCargoItemDetailsCommand = "aetheria.inventory.cargo_item_details.close"; + private const string EquippedItemDetailsSurfaceId = "aetheria.inventory.equipped_item_details"; + private const string CloseEquippedItemDetailsCommand = "aetheria.inventory.equipped_item_details.close"; + private const string ToggleEquippedItemOverrideShutdownCommand = "aetheria.inventory.equipped_item_details.override_shutdown.toggle"; + private const string SetEquippedItemTargetTemperatureCommand = "aetheria.inventory.equipped_item_details.target_temperature.set"; + private const string ToggleEquippedItemWeaponGroupCommand = "aetheria.inventory.equipped_item_details.weapon_group.toggle"; + private const string BindEquippedItemWeaponGroupCommand = "aetheria.inventory.equipped_item_details.weapon_group.bind"; + private const string ClearEquippedItemActionBarBindingCommand = "aetheria.inventory.equipped_item_details.action_bar.clear"; private const float ShutdownThresholdStep = 0.05f; public InventoryPanel[] InventoryPanels; - public PropertiesPanel PropertiesPanel; public ActionGameManager GameManager; - public RectTransform DragParent; public ConfirmationDialog Dialog; // public ClickCatcher Background; @@ -44,9 +47,11 @@ public class InventoryMenu : MonoBehaviour private int2 _selectedPosition; private InventoryPanel _selectedPanel; private ItemInstance _selectedItem; + private EquippedItem _selectedEquippedItem; private int2[] _selectedCells; private UIDocument _shipSettingsSurfaceDocument; private UIDocument _cargoItemDetailsSurfaceDocument; + private UIDocument _equippedItemDetailsSurfaceDocument; // private List _backgroundSubscriptions; // private ItemInstance _dragItem; @@ -90,12 +95,12 @@ public class InventoryMenu : MonoBehaviour { HideCurrentShipSettingsSurface(); HideCargoItemDetailsSurface(); + HideEquippedItemDetailsSurface(); // Background.gameObject.SetActive(false); } void Start() { - PropertiesPanel.GameManager = GameManager; foreach (var panel in InventoryPanels) { panel.OnClickAsObservable().Subscribe(e => @@ -108,6 +113,7 @@ public class InventoryMenu : MonoBehaviour if (e.clickCount == 2) { HideCargoItemDetailsSurface(); + HideEquippedItemDetailsSurface(); ClearSelectedItemSelection(); var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0]; if (CommitCargoItemTransfer(cargoEvent.CargoBay, otherPanel, item)) @@ -123,7 +129,7 @@ public class InventoryMenu : MonoBehaviour { HideCurrentShipSettingsSurface(); HideCargoItemDetailsSurface(); - PropertiesPanel.gameObject.SetActive(false); + HideEquippedItemDetailsSurface(); ClearSelectedItemSelection(); _selectedPanel = panel; _selectedPosition = cargoEvent.CargoBay.Cargo[item]; @@ -143,6 +149,7 @@ public class InventoryMenu : MonoBehaviour if (e.clickCount == 2) { HideCargoItemDetailsSurface(); + HideEquippedItemDetailsSurface(); ClearSelectedItemSelection(); var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0]; if (CommitEquippedItemTransfer(entityEvent.Entity, item, otherPanel)) @@ -158,15 +165,14 @@ public class InventoryMenu : MonoBehaviour { HideCurrentShipSettingsSurface(); HideCargoItemDetailsSurface(); - PropertiesPanel.gameObject.SetActive(true); ClearSelectedItemSelection(); - - PropertiesPanel.Inspect(item); _selectedPanel = panel; _selectedPosition = item.Position; _selectedItem = item.EquippableItem; + _selectedEquippedItem = item; _selectedCells = GetSelectedCells(item.EquippableItem, _selectedPosition); ApplySelectedCellHighlight(); + RenderEquippedItemDetailsSurface(item); // TODO: SFX: Success } } @@ -188,7 +194,7 @@ public class InventoryMenu : MonoBehaviour return; HideCargoItemDetailsSurface(); - PropertiesPanel.gameObject.SetActive(false); + HideEquippedItemDetailsSurface(); ClearSelectedItemSelection(); var document = ResolveShipSettingsSurfaceDocument(); @@ -286,6 +292,8 @@ public class InventoryMenu : MonoBehaviour if (item == null || typedItem == null) return; + HideEquippedItemDetailsSurface(); + var document = ResolveCargoItemDetailsSurfaceDocument(); document.gameObject.SetActive(true); @@ -349,6 +357,327 @@ public class InventoryMenu : MonoBehaviour _cargoItemDetailsSurfaceDocument.gameObject.SetActive(false); } + private void RenderEquippedItemDetailsSurface(EquippedItem item) + { + var typedItem = FindTypedInventoryItem(item?.EquippableItem); + if (item?.EquippableItem == null || typedItem == null) + return; + + var document = ResolveEquippedItemDetailsSurfaceDocument(); + document.gameObject.SetActive(true); + + var root = document.rootVisualElement; + root.Clear(); + root.style.flexGrow = 1; + root.style.position = Position.Absolute; + root.style.left = 0; + root.style.top = 0; + root.style.right = 0; + root.style.bottom = 0; + root.style.alignItems = Align.FlexStart; + root.style.justifyContent = Justify.FlexStart; + root.pickingMode = PickingMode.Ignore; + + var shell = new VisualElement(); + shell.style.width = 460; + shell.style.maxWidth = 560; + shell.style.backgroundColor = new Color(0.08f, 0.1f, 0.14f, 0.94f); + shell.style.borderTopLeftRadius = 8; + shell.style.borderTopRightRadius = 8; + shell.style.borderBottomLeftRadius = 8; + shell.style.borderBottomRightRadius = 8; + shell.style.paddingLeft = 18; + shell.style.paddingRight = 18; + shell.style.paddingTop = 18; + shell.style.paddingBottom = 18; + shell.style.borderLeftWidth = 1; + shell.style.borderRightWidth = 1; + shell.style.borderTopWidth = 1; + shell.style.borderBottomWidth = 1; + shell.style.borderLeftColor = new Color(0.3f, 0.47f, 0.71f, 0.8f); + shell.style.borderRightColor = new Color(0.3f, 0.47f, 0.71f, 0.8f); + shell.style.borderTopColor = new Color(0.3f, 0.47f, 0.71f, 0.8f); + shell.style.borderBottomColor = new Color(0.3f, 0.47f, 0.71f, 0.8f); + shell.pickingMode = PickingMode.Position; + root.Add(shell); + + var lowerer = new EveUiToolkitSurfaceLowerer(); + shell.Add(lowerer.Lower(BuildEquippedItemDetailsSurfaceDefinition(item, typedItem), HandleEquippedItemDetailsSurfaceCommand)); + } + + private void HandleEquippedItemDetailsSurfaceCommand(EveSurfaceCommandRequest request) + { + var item = _selectedEquippedItem; + if (item?.EquippableItem == null) + { + HideEquippedItemDetailsSurface(); + ClearSelectedItemSelection(); + return; + } + + switch (request.Command) + { + case CloseEquippedItemDetailsCommand: + HideEquippedItemDetailsSurface(); + ClearSelectedItemSelection(); + return; + case ToggleEquippedItemOverrideShutdownCommand: + GameManager.CommitEquippedItemOverrideShutdown(item, !item.EquippableItem.OverrideShutdown); + RenderEquippedItemDetailsSurface(item); + return; + case SetEquippedItemTargetTemperatureCommand: + if (TryReadPayloadInt(request, "behaviorIndex", out var behaviorIndex) && + behaviorIndex >= 0 && + behaviorIndex < (item.Behaviors?.Length ?? 0) && + item.Behaviors[behaviorIndex] is Thermotoggle thermotoggle && + thermotoggle.Adjustable && + TryReadPayloadFloat(request, "value", out var targetTemperature)) + { + GameManager.CommitThermotoggleTargetTemperature(thermotoggle, targetTemperature); + RenderEquippedItemDetailsSurface(item); + return; + } + + Debug.LogWarning("Unable to apply equipped-item target temperature command."); + RenderEquippedItemDetailsSurface(item); + return; + case ToggleEquippedItemWeaponGroupCommand: + if (TryReadPayloadInt(request, "group", out var groupIndex)) + { + var assigned = !IsWeaponGroupAssigned(item, groupIndex); + if (GameManager.CommitWeaponGroupMembership(item, groupIndex, assigned)) + { + RenderEquippedItemDetailsSurface(item); + return; + } + } + + Debug.LogWarning("Unable to toggle equipped-item weapon group membership."); + return; + case BindEquippedItemWeaponGroupCommand: + if (TryReadPayloadInt(request, "group", out var bindGroupIndex) && + TryReadPayloadInt(request, "slot", out var slotIndex) && + GameManager.CommitWeaponGroupActionBarBinding(slotIndex, bindGroupIndex)) + { + RenderEquippedItemDetailsSurface(item); + return; + } + + Debug.LogWarning("Unable to bind equipped-item weapon group to action bar."); + return; + case ClearEquippedItemActionBarBindingCommand: + if (TryReadPayloadInt(request, "slot", out var clearSlotIndex) && + GameManager.CommitClearActionBarBinding(clearSlotIndex)) + { + RenderEquippedItemDetailsSurface(item); + return; + } + + Debug.LogWarning("Unable to clear equipped-item action bar binding."); + return; + default: + Debug.LogWarning($"Unknown inventory equipped item details command: {request.Command}"); + return; + } + } + + private void HideEquippedItemDetailsSurface() + { + if (_equippedItemDetailsSurfaceDocument == null) + return; + + _equippedItemDetailsSurfaceDocument.rootVisualElement.Clear(); + _equippedItemDetailsSurfaceDocument.gameObject.SetActive(false); + } + + private UIDocument ResolveEquippedItemDetailsSurfaceDocument() + { + if (_equippedItemDetailsSurfaceDocument != null) + return _equippedItemDetailsSurfaceDocument; + + var host = new GameObject("Aetheria Inventory Equipped Item Details Surface"); + host.transform.SetParent(transform, false); + var document = host.AddComponent(); + document.sortingOrder = 1002; + host.SetActive(false); + _equippedItemDetailsSurfaceDocument = document; + return document; + } + + private EveSurfaceDocument BuildEquippedItemDetailsSurfaceDefinition(EquippedItem item, AetheriaRuntimeCatalogItem typedItem) + { + var children = new List + { + Card( + $"{EquippedItemDetailsSurfaceId}.summary", + BuildEquippedItemTitle(item, typedItem), + Text( + $"{EquippedItemDetailsSurfaceId}.description", + typedItem.Description ?? "No typed item description is available."), + Text( + $"{EquippedItemDetailsSurfaceId}.note", + "InventoryMenu still owns cell selection. This surface replaces the old equipped-item PropertiesPanel shell, including weapon-group and behavior controls."), + Metric( + $"{EquippedItemDetailsSurfaceId}.manufacturer", + "Manufacturer", + ActionGameManager.RuntimeCatalog?.GetManufacturer(typedItem)?.Name ?? "GameCult"), + Metric( + $"{EquippedItemDetailsSurfaceId}.mass", + "Mass", + ActionGameManager.RuntimePlayerSettings.Format((float)typedItem.Mass))), + Card( + $"{EquippedItemDetailsSurfaceId}.status.card", + "Status", + Metric( + $"{EquippedItemDetailsSurfaceId}.durability", + "Durability", + item.EquippableItem.Durability < .01f + ? "Item Destroyed!" + : $"{(int)(item.EquippableItem.Durability / GetMaxDurability(typedItem, item.EquippableItem) * 100)}%"), + Metric( + $"{EquippedItemDetailsSurfaceId}.temperature", + "Temperature", + ActionGameManager.RuntimePlayerSettings.FormatTemperature(item.Temperature)), + Metric( + $"{EquippedItemDetailsSurfaceId}.thermal_range", + "Thermal Range", + FormatTemperatureRange(typedItem))) + }; + + foreach (var behaviorCard in BuildItemBehaviorCards(EquippedItemDetailsSurfaceId, typedItem, item.EquippableItem)) + { + children.Add(behaviorCard); + } + + children.Add(BuildEquippedItemControlCard(item)); + + if (item.GetBehavior() != null) + { + children.Add(BuildEquippedItemWeaponGroupCard(item)); + children.AddRange(BuildEquippedItemActionBarCards(item)); + } + + children.Add(ButtonRow( + $"{EquippedItemDetailsSurfaceId}.actions", + Button($"{EquippedItemDetailsSurfaceId}.close", "Close", CloseEquippedItemDetailsCommand))); + + return new EveSurfaceDocument( + ShipSettingsSurfaceType, + ShipSettingsSurfaceSchema, + ShipSettingsSurfaceProviderId, + ShipSettingsSurfaceProviderKind, + "Inventory Equipped Item Details", + version: 1, + DateTime.UtcNow.ToString("O"), + new EveSurfaceTree( + EquippedItemDetailsSurfaceId, + Node( + $"{EquippedItemDetailsSurfaceId}.root", + "surface", + Array.Empty<(string Key, string Value)>(), + children.ToArray()), + Array.Empty()), + new[] + { + new EveCommandTemplate(CloseEquippedItemDetailsCommand, "Close", "unity-uitoolkit"), + new EveCommandTemplate(ToggleEquippedItemOverrideShutdownCommand, "Toggle Override Shutdown", "unity-uitoolkit"), + new EveCommandTemplate(SetEquippedItemTargetTemperatureCommand, "Set Target Temperature", "unity-uitoolkit"), + new EveCommandTemplate(ToggleEquippedItemWeaponGroupCommand, "Toggle Weapon Group", "unity-uitoolkit"), + new EveCommandTemplate(BindEquippedItemWeaponGroupCommand, "Bind Weapon Group", "unity-uitoolkit"), + new EveCommandTemplate(ClearEquippedItemActionBarBindingCommand, "Clear Action Bar Binding", "unity-uitoolkit") + }); + } + + private EveSurfaceComponent BuildEquippedItemControlCard(EquippedItem item) + { + var children = new List + { + Metric( + $"{EquippedItemDetailsSurfaceId}.controls.override_shutdown.metric", + "Override Shutdown", + item.EquippableItem.OverrideShutdown ? "Enabled" : "Disabled"), + ButtonRow( + $"{EquippedItemDetailsSurfaceId}.controls.override_shutdown.actions", + Button( + $"{EquippedItemDetailsSurfaceId}.controls.override_shutdown.toggle", + item.EquippableItem.OverrideShutdown ? "Disable Override" : "Enable Override", + ToggleEquippedItemOverrideShutdownCommand)) + }; + + for (var i = 0; i < (item.Behaviors?.Length ?? 0); i++) + { + if (item.Behaviors[i] is not Thermotoggle thermotoggle || !thermotoggle.Adjustable) + continue; + + children.Add(Metric( + $"{EquippedItemDetailsSurfaceId}.controls.thermotoggle.{i}.metric", + $"Target Temperature {i + 1}", + ActionGameManager.RuntimePlayerSettings.FormatTemperature(thermotoggle.TargetTemperature))); + children.Add(TextField( + $"{EquippedItemDetailsSurfaceId}.controls.thermotoggle.{i}.input", + $"Target Temperature {i + 1}", + SetEquippedItemTargetTemperatureCommand, + thermotoggle.TargetTemperature.ToString(CultureInfo.InvariantCulture), + ("behaviorIndex", i.ToString(CultureInfo.InvariantCulture)))); + } + + return Card( + $"{EquippedItemDetailsSurfaceId}.controls.card", + "Controls", + children.ToArray()); + } + + private EveSurfaceComponent BuildEquippedItemWeaponGroupCard(EquippedItem item) + { + var groupButtons = Enumerable.Range(0, item.Entity?.WeaponGroups?.Length ?? 0) + .Select(groupIndex => CommandButton( + $"{EquippedItemDetailsSurfaceId}.weapon_groups.{groupIndex}", + IsWeaponGroupAssigned(item, groupIndex) ? $"G{groupIndex + 1} On" : $"G{groupIndex + 1} Off", + ToggleEquippedItemWeaponGroupCommand, + ("group", groupIndex.ToString(CultureInfo.InvariantCulture)))) + .ToArray(); + + return Card( + $"{EquippedItemDetailsSurfaceId}.weapon_groups.card", + "Weapon Groups", + Text( + $"{EquippedItemDetailsSurfaceId}.weapon_groups.note", + "Toggle membership directly; action-bar group binding is handled below."), + ButtonRow($"{EquippedItemDetailsSurfaceId}.weapon_groups.actions", groupButtons)); + } + + private IEnumerable BuildEquippedItemActionBarCards(EquippedItem item) + { + for (var slotIndex = 0; slotIndex < GameManager.GetActionBarSlotCount(); slotIndex++) + { + var bindButtons = Enumerable.Range(0, item.Entity?.WeaponGroups?.Length ?? 0) + .Select(groupIndex => CommandButton( + $"{EquippedItemDetailsSurfaceId}.action_bar.{slotIndex}.group.{groupIndex}", + $"G{groupIndex + 1}", + BindEquippedItemWeaponGroupCommand, + ("slot", slotIndex.ToString(CultureInfo.InvariantCulture)), + ("group", groupIndex.ToString(CultureInfo.InvariantCulture)))) + .Concat(new[] + { + CommandButton( + $"{EquippedItemDetailsSurfaceId}.action_bar.{slotIndex}.clear", + "Clear", + ClearEquippedItemActionBarBindingCommand, + ("slot", slotIndex.ToString(CultureInfo.InvariantCulture))) + }) + .ToArray(); + + yield return Card( + $"{EquippedItemDetailsSurfaceId}.action_bar.{slotIndex}.card", + $"Action Bar {GameManager.GetActionBarSlotLabel(slotIndex)}", + Metric( + $"{EquippedItemDetailsSurfaceId}.action_bar.{slotIndex}.binding", + "Current", + GameManager.GetActionBarBindingLabel(slotIndex)), + ButtonRow($"{EquippedItemDetailsSurfaceId}.action_bar.{slotIndex}.actions", bindButtons)); + } + } + private UIDocument ResolveCargoItemDetailsSurfaceDocument() { if (_cargoItemDetailsSurfaceDocument != null) @@ -462,6 +791,14 @@ public class InventoryMenu : MonoBehaviour private IEnumerable BuildCargoItemBehaviorCards( AetheriaRuntimeCatalogItem typedItem, EquippableItem equippableItem) + { + return BuildItemBehaviorCards(CargoItemDetailsSurfaceId, typedItem, equippableItem); + } + + private IEnumerable BuildItemBehaviorCards( + string surfaceId, + AetheriaRuntimeCatalogItem typedItem, + EquippableItem equippableItem) { foreach (var behavior in typedItem.BehaviorPayloads ?? Array.Empty()) { @@ -471,10 +808,10 @@ public class InventoryMenu : MonoBehaviour var modifier = ReadTypedPerformanceStat(FindTypedBehaviorField(behavior, 2)?.Value); var modifierType = ReadTypedEnum(FindTypedBehaviorField(behavior, 3)?.Value, StatModifierType.Constant); yield return Card( - $"{CargoItemDetailsSurfaceId}.behavior.{behavior.Kind}.stat_modifier", + $"{surfaceId}.behavior.{behavior.Kind}.stat_modifier", "Stat Modifier", Metric( - $"{CargoItemDetailsSurfaceId}.behavior.{behavior.Kind}.target", + $"{surfaceId}.behavior.{behavior.Kind}.target", $"{statReference.target.SplitCamelCase()}:{statReference.stat.SplitCamelCase()}", $"{(modifierType == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.RuntimePlayerSettings.Format(GameManager.ItemManager.Evaluate(modifier, equippableItem))}")); continue; @@ -485,7 +822,7 @@ public class InventoryMenu : MonoBehaviour continue; var fields = metadata.DisplayFields - .Select(field => BuildCargoItemBehaviorMetric(behavior, field, equippableItem)) + .Select(field => BuildItemBehaviorMetric(surfaceId, behavior, field, equippableItem)) .Where(metric => metric != null) .ToArray(); @@ -493,7 +830,7 @@ public class InventoryMenu : MonoBehaviour continue; yield return Card( - $"{CargoItemDetailsSurfaceId}.behavior.{behavior.Kind}", + $"{surfaceId}.behavior.{behavior.Kind}", behavior.Kind.FormatTypeName(), fields); } @@ -503,6 +840,15 @@ public class InventoryMenu : MonoBehaviour AetheriaRuntimeBehaviorPayload behavior, AetheriaRuntimeBehaviorFieldMetadata field, EquippableItem equippableItem) + { + return BuildItemBehaviorMetric(CargoItemDetailsSurfaceId, behavior, field, equippableItem); + } + + private EveSurfaceComponent BuildItemBehaviorMetric( + string surfaceId, + AetheriaRuntimeBehaviorPayload behavior, + AetheriaRuntimeBehaviorFieldMetadata field, + EquippableItem equippableItem) { var payloadField = FindTypedBehaviorField(behavior, field.Key); if (payloadField == null) @@ -528,7 +874,7 @@ public class InventoryMenu : MonoBehaviour } return Metric( - $"{CargoItemDetailsSurfaceId}.behavior.{behavior.Kind}.{field.Key}", + $"{surfaceId}.behavior.{behavior.Kind}.{field.Key}", field.Name.SplitCamelCase(), value); } @@ -612,6 +958,44 @@ public class InventoryMenu : MonoBehaviour return Node(id, "control.button", new[] { ("label", label), ("command", command) }); } + private static EveSurfaceComponent CommandButton( + string id, + string label, + string command, + params (string Key, string Value)[] props) + { + var buttonProps = new List<(string Key, string Value)> + { + ("label", label), + ("command", command) + }; + + if (props != null && props.Length > 0) + buttonProps.AddRange(props); + + return Node(id, "control.button", buttonProps); + } + + private static EveSurfaceComponent TextField( + string id, + string label, + string command, + string value, + params (string Key, string Value)[] props) + { + var fieldProps = new List<(string Key, string Value)> + { + ("label", label), + ("command", command), + ("value", value ?? "") + }; + + if (props != null && props.Length > 0) + fieldProps.AddRange(props); + + return Node(id, "control.text", fieldProps); + } + private static EveSurfaceComponent ButtonRow( string id, params EveSurfaceComponent[] children) @@ -632,6 +1016,36 @@ public class InventoryMenu : MonoBehaviour children ?? Array.Empty()); } + private string BuildEquippedItemTitle(EquippedItem item, AetheriaRuntimeCatalogItem typedItem) + { + var (tier, upgrades) = GameManager.ItemManager.GetTier(item.EquippableItem); + return $"{typedItem?.Name ?? "Unknown Item"} ({tier.Name}{new string('+', upgrades)})"; + } + + private static bool IsWeaponGroupAssigned(EquippedItem item, int groupIndex) + { + return item?.Entity?.WeaponGroups != null && + groupIndex >= 0 && + groupIndex < item.Entity.WeaponGroups.Length && + item.Entity.WeaponGroups[groupIndex].items.Contains(item); + } + + private static bool TryReadPayloadInt(EveSurfaceCommandRequest request, string key, out int value) + { + value = 0; + return request?.Payload != null && + request.Payload.TryGetValue(key, out var raw) && + int.TryParse(raw, NumberStyles.Integer, CultureInfo.InvariantCulture, out value); + } + + private static bool TryReadPayloadFloat(EveSurfaceCommandRequest request, string key, out float value) + { + value = 0f; + return request?.Payload != null && + request.Payload.TryGetValue(key, out var raw) && + float.TryParse(raw, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out value); + } + private bool CommitCargoItemTransfer(EquippedCargoBay origin, InventoryPanel destination, ItemInstance item) { if (destination.DisplayedEntity != null && item is EquippableItem equippableItem) @@ -648,6 +1062,7 @@ public class InventoryMenu : MonoBehaviour ClearSelectedCellHighlight(); _selectedPanel = null; _selectedItem = null; + _selectedEquippedItem = null; _selectedCells = null; _selectedPosition = default; } @@ -821,5 +1236,11 @@ public class InventoryMenu : MonoBehaviour Destroy(_cargoItemDetailsSurfaceDocument.gameObject); _cargoItemDetailsSurfaceDocument = null; } + + if (_equippedItemDetailsSurfaceDocument != null) + { + Destroy(_equippedItemDetailsSurfaceDocument.gameObject); + _equippedItemDetailsSurfaceDocument = null; + } } } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 4a2c2e476..bc0eddd82 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -133,8 +133,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. Trade typed-item inspection now lowers through a local Eve/UI Toolkit surface instead of routing spreadsheet row clicks into `PropertiesPanel.Inspect`. Inventory cargo-item inspection now lowers through a local Eve/UI Toolkit - surface instead of routing cargo clicks into `PropertiesPanel.Inspect`, - while equipped-item inspection still owns the old live-control shell. + surface instead of routing cargo clicks into `PropertiesPanel.Inspect`. + Inventory equipped-item inspection now also lowers through a local + Eve/UI Toolkit surface, with `InventoryMenu` owning weapon-group toggles, + action-bar group binding, override shutdown, and thermotoggle target + temperature controls directly instead of routing them through + `PropertiesPanel`. - The combat schematic HUD uses typed runtime catalog weapon facets for its static weapon icon strip; missing typed weapon facets no longer fall back to legacy `WeaponItemData`. Schematic weapon-row selection now uses typed @@ -1596,10 +1600,13 @@ First Aetheria surfaces to publish: trade rows, but spreadsheet row clicks no longer route through the old `PropertiesPanel` shell. - Done: replace `InventoryMenu` cargo-item inspection with an Eve-owned UI - Toolkit surface. Inventory still owns selected-cell highlighting, and the - equipped-item path still owns the old live-control `PropertiesPanel` - shell for weapon groups and behavior controls, but cargo clicks no longer - route through `PropertiesPanel.Inspect`. + Toolkit surface. Inventory still owns selected-cell highlighting, but + cargo clicks no longer route through `PropertiesPanel.Inspect`. + - Done: replace `InventoryMenu` equipped-item inspection with an Eve-owned + Toolkit surface. `InventoryMenu` now owns weapon-group toggles, + action-bar group binding, override shutdown, and thermotoggle controls + directly; the old live-control `PropertiesPanel` shell is gone from the + inventory path. - Done: move the shared `org.gamecult.eve.surface` and `org.gamecult.eve.unity-uitoolkit` packages into the Eve repo and retarget Aetheria to import them from there instead of carrying local staged @@ -1983,9 +1990,11 @@ First Aetheria surfaces to publish: spreadsheet row clicks into `PropertiesPanel.Inspect(...)`. - Inventory cargo-item inspection now lowers through a shared UI Toolkit `UIDocument` host and a local Eve surface document instead of routing cargo - clicks into `PropertiesPanel.Inspect(...)`; the equipped-item path still - retains the old live-control shell until weapon-group and behavior controls - are moved cleanly. + clicks into `PropertiesPanel.Inspect(...)`. +- Inventory equipped-item inspection now lowers through a shared UI Toolkit + `UIDocument` host and a local Eve surface document, with `InventoryMenu` + owning weapon-group toggles, action-bar group binding, override shutdown, + and thermotoggle controls directly instead of `PropertiesPanel.Inspect(...)`. - Keyboard display layout parsing is no longer JSON-backed: `InputDisplayLayout` builds its static ANSI-104 display projection from typed `InputLayout` rows/columns. The dead commented Ink `ToJson` write path and