From 7d8801d24fbb6179ef662e61008b81d1d8873a09 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 17 Jun 2026 05:38:58 +0100 Subject: [PATCH] Cut confirmation dialog loose from properties panel --- Aetheria.State.Verify/Program.cs | 142 ++++++++++++++++++++ Assets/Prefabs/UI/Main Menu Canvas.prefab | 26 ---- Assets/Scenes/ARPG.unity | 25 ---- Assets/Scripts/UI/ConfirmationDialog.cs | 152 ++++++++++++++++++---- docs/aetheria-perfect-machine-map.md | 4 + 5 files changed, 274 insertions(+), 75 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 00a403724..f6e488f61 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -34,6 +34,7 @@ RequireNoRendererLocalDebugPanels(root); RequireMainMenuSettingsCommit(root); RequireMainMenuRootUsesEveSurface(root); RequireMainMenuSettingsShellUsesEveSurface(root); +RequireConfirmationDialogOwnsMinimalPromptShell(root); RequireSectorMapZoneDetailsUseEveSurface(root); RequireRuntimeMenuTabsUseEveSurface(root); RequireInventoryShipSettingsUseEveSurface(root); @@ -510,6 +511,7 @@ Console.WriteLine("Renderer-local debug panels: obsolete uGUI field tester autho Console.WriteLine("Main-menu settings authority: player name, gameplay, and graphics settings return through typed player-settings commits"); Console.WriteLine("Main-menu root shell: root navigation lowers through an Eve UI Toolkit surface instead of the legacy PropertiesPanel/fade shell"); Console.WriteLine("Main-menu settings shell: settings/input/audio subpages lower through Eve UI Toolkit surfaces instead of PropertiesPanel buttons"); +Console.WriteLine("Confirmation dialog shell: runtime prompts no longer inherit the generic PropertiesPanel machinery"); Console.WriteLine("Sector-map zone details shell: zone inspection lowers through an Eve UI Toolkit surface instead of PropertiesPanel rows"); 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"); @@ -2588,6 +2590,146 @@ static void RequireMainMenuRootUsesEveSurface(string root) } } +static void RequireConfirmationDialogOwnsMinimalPromptShell(string root) +{ + var dialogPath = Path.Combine(root, "Assets", "Scripts", "UI", "ConfirmationDialog.cs"); + if (!File.Exists(dialogPath)) + { + throw new InvalidOperationException("Cannot verify confirmation dialog shell; ConfirmationDialog.cs is missing."); + } + + var source = File.ReadAllText(dialogPath); + var requiredSymbols = new[] + { + "public class ConfirmationDialog : MonoBehaviour", + "public TextMeshProUGUI Title;", + "public RectTransform Content;", + "public Property Property;", + "public InputField InputField;", + "public void Clear()", + "public Property AddProperty(Func read)", + "public void AddField(string name, Func read, Action write)", + "public void AddField(string name, Func read, Action write)" + }; + + var missingSymbols = requiredSymbols + .Where(symbol => !source.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (missingSymbols.Length > 0) + { + throw new InvalidOperationException( + "ConfirmationDialog no longer owns the minimal prompt shell contract: " + + string.Join(", ", missingSymbols)); + } + + var forbiddenSymbols = new[] + { + ": PropertiesPanel", + "OnPropertyAdded", + "RefreshPropertyValues", + "PropertyLabel", + "Dropdown", + "RangedFloatField", + "BoolField", + "EnumField", + "StatSheet" + }; + + var hits = forbiddenSymbols + .Where(symbol => source.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (hits.Length > 0) + { + throw new InvalidOperationException( + "ConfirmationDialog still drags generic PropertiesPanel machinery into the prompt shell: " + + string.Join(", ", hits)); + } + + var prefabBlock = ReadSerializedMonoBehaviourBlock( + Path.Combine(root, "Assets", "Prefabs", "UI", "Main Menu Canvas.prefab"), + "83488dc4b5e58cd40b4d1c4ee98207b5"); + var sceneBlock = ReadSerializedMonoBehaviourBlock( + Path.Combine(root, "Assets", "Scenes", "ARPG.unity"), + "83488dc4b5e58cd40b4d1c4ee98207b5"); + + var forbiddenSerializedFields = new[] + { + "Spacer:", + "Dropdown:", + "Section:", + "List:", + "PropertyLabel:", + "Attribute:", + "RangedFloatField:", + "ProgressField:", + "EnumField:", + "BoolField:", + "PropertyButton:", + "ButtonField:", + "IncrementField:", + "StatSheet:", + "CurveField:", + "SelectedChild:", + "GameManager:" + }; + + foreach (var (label, block) in new[] { ("Main Menu Canvas.prefab", prefabBlock), ("ARPG.unity", sceneBlock) }) + { + var blockHits = forbiddenSerializedFields + .Where(symbol => block.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (blockHits.Length > 0) + { + throw new InvalidOperationException( + $"ConfirmationDialog still serializes dead PropertiesPanel fields in {label}: " + + string.Join(", ", blockHits)); + } + } +} + +static string ReadSerializedMonoBehaviourBlock(string path, string scriptGuid) +{ + if (!File.Exists(path)) + { + throw new InvalidOperationException($"Cannot inspect serialized MonoBehaviour block; file is missing: {path}"); + } + + var lines = File.ReadAllLines(path); + var scriptLine = $"guid: {scriptGuid}"; + for (var index = 0; index < lines.Length; index++) + { + if (!lines[index].Contains(scriptLine, StringComparison.Ordinal)) + { + continue; + } + + var start = index; + while (start >= 0 && !lines[start].StartsWith("--- !u!114 ", StringComparison.Ordinal)) + { + start--; + } + + if (start < 0) + { + break; + } + + var end = start + 1; + while (end < lines.Length && !lines[end].StartsWith("--- !u!", StringComparison.Ordinal)) + { + end++; + } + + return string.Join(Environment.NewLine, lines.Skip(start).Take(end - start)); + } + + throw new InvalidOperationException( + $"Cannot inspect serialized MonoBehaviour block for script guid {scriptGuid} in {path}."); +} + static void RequireSectorMapZoneDetailsUseEveSurface(string root) { var sectorRendererPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "SectorRenderer.cs"); diff --git a/Assets/Prefabs/UI/Main Menu Canvas.prefab b/Assets/Prefabs/UI/Main Menu Canvas.prefab index 1939b09ae..37317d336 100644 --- a/Assets/Prefabs/UI/Main Menu Canvas.prefab +++ b/Assets/Prefabs/UI/Main Menu Canvas.prefab @@ -759,38 +759,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 83488dc4b5e58cd40b4d1c4ee98207b5, type: 3} m_Name: m_EditorClassIdentifier: - Spacer: {fileID: 0} - Dropdown: {fileID: 0} Title: {fileID: 4533226043829246278} - Section: {fileID: 1026668114703092140, guid: 3a149ea40b43fbf47b51ec165cb04e5f, type: 3} - List: {fileID: 6914334813923144328, guid: 93e63e3a8b352a04897123288d70f04b, type: 3} Property: {fileID: 9159917045172241898, guid: be88722a74d512d45a454fe91327a389, type: 3} - PropertyLabel: {fileID: 279061376544739623, guid: 5b8c5126640066e4fabe6e65b7225b3b, - type: 3} - Attribute: {fileID: 4447025208748278043, guid: 5e3a258a5b91c8246b20962ba6eccb09, - type: 3} InputField: {fileID: 6586910564433979167, guid: fb49ef180533e3e488fa39d80cc2423a, type: 3} - RangedFloatField: {fileID: 1663396771457720812, guid: c214f62d8f2188140b96ed12798034c8, - type: 3} - ProgressField: {fileID: 256436433275418348, guid: e6524d59d9bc67545b0eb1304bfb9d4b, - type: 3} - EnumField: {fileID: 1444953514731475975, guid: f19a14cd178d48f49ace9ad217bea2ed, - type: 3} - BoolField: {fileID: 7661950293931311388, guid: 001ad6a15f0d582458d359c0ae4405ed, - type: 3} - PropertyButton: {fileID: 4311087511401681413, guid: 99bde06e2f0ca504bb95f2a4e3429462, - type: 3} - ButtonField: {fileID: 6566784227922820057, guid: 6db1feb4cda7b8c419384cd42c85a5c4, - type: 3} - IncrementField: {fileID: 5486709585343280439, guid: 9c14c92a1a08b0a4fb4f6aa6f8504082, - type: 3} - StatSheet: {fileID: 0} - CurveField: {fileID: 0} Content: {fileID: 4533226043449861658} - SelectedChild: {fileID: 0} - GameManager: {fileID: 0} CancelClickCatcher: {fileID: 725430339668194415} ButtonGroup: {fileID: 4533226044611060155} Cancel: {fileID: 1044359407629948051} diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index 49c77dd51..4bac00783 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -9857,37 +9857,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 83488dc4b5e58cd40b4d1c4ee98207b5, type: 3} m_Name: m_EditorClassIdentifier: - Spacer: {fileID: 0} - Dropdown: {fileID: 178733681} Title: {fileID: 738229278} - Section: {fileID: 1026668114703092140, guid: 3a149ea40b43fbf47b51ec165cb04e5f, type: 3} - List: {fileID: 6914334813923144328, guid: 93e63e3a8b352a04897123288d70f04b, type: 3} Property: {fileID: 9159917045172241898, guid: be88722a74d512d45a454fe91327a389, type: 3} - PropertyLabel: {fileID: 279061376544739623, guid: 5b8c5126640066e4fabe6e65b7225b3b, - type: 3} - Attribute: {fileID: 4447025208748278043, guid: 5e3a258a5b91c8246b20962ba6eccb09, - type: 3} InputField: {fileID: 6586910564433979167, guid: fb49ef180533e3e488fa39d80cc2423a, type: 3} - RangedFloatField: {fileID: 1663396771457720812, guid: c214f62d8f2188140b96ed12798034c8, - type: 3} - ProgressField: {fileID: 256436433275418348, guid: e6524d59d9bc67545b0eb1304bfb9d4b, - type: 3} - EnumField: {fileID: 1444953514731475975, guid: f19a14cd178d48f49ace9ad217bea2ed, - type: 3} - BoolField: {fileID: 7661950293931311388, guid: 001ad6a15f0d582458d359c0ae4405ed, - type: 3} - PropertyButton: {fileID: 4311087511401681413, guid: 99bde06e2f0ca504bb95f2a4e3429462, - type: 3} - ButtonField: {fileID: 6566784227922820057, guid: 6db1feb4cda7b8c419384cd42c85a5c4, - type: 3} - IncrementField: {fileID: 5486709585343280439, guid: 9c14c92a1a08b0a4fb4f6aa6f8504082, - type: 3} - StatSheet: {fileID: 0} - CurveField: {fileID: 0} Content: {fileID: 620555923} - GameManager: {fileID: 0} CancelClickCatcher: {fileID: 1420548305} ButtonGroup: {fileID: 947321577} Cancel: {fileID: 1176624628} diff --git a/Assets/Scripts/UI/ConfirmationDialog.cs b/Assets/Scripts/UI/ConfirmationDialog.cs index cb5b8044f..e32480f94 100644 --- a/Assets/Scripts/UI/ConfirmationDialog.cs +++ b/Assets/Scripts/UI/ConfirmationDialog.cs @@ -1,27 +1,33 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * 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 TMPro; +using UniRx; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; -using UniRx; -public class ConfirmationDialog : PropertiesPanel +public class ConfirmationDialog : MonoBehaviour { + public TextMeshProUGUI Title; + public RectTransform Content; + public Property Property; + public InputField InputField; public ClickCatcher CancelClickCatcher; public GameObject ButtonGroup; public Button Cancel; public Button Confirm; public TextMeshProUGUI ConfirmText; public TextMeshProUGUI CancelText; - + public bool LockDialog { get; set; } + private readonly List _entries = new(); + private readonly List _refreshers = new(); private Action _onCancel; private Action _onConfirm; @@ -30,23 +36,97 @@ public class ConfirmationDialog : PropertiesPanel Cancel.onClick.AddListener(() => End()); Confirm.onClick.AddListener(() => End(true)); if (CancelClickCatcher != null) - CancelClickCatcher.OnClick.Subscribe(data => - { - if (!LockDialog) End(); - }); - - OnPropertyAdded += go => { - go.SetActive(true); - go.transform.SetSiblingIndex(Title.transform.GetSiblingIndex() + 1); - }; + CancelClickCatcher.OnClick.Subscribe(_ => + { + if (!LockDialog) + { + End(); + } + }); + } + gameObject.SetActive(false); } - + + private void Update() + { + RefreshValues(); + } + + public void Clear() + { + foreach (var entry in _entries) + { + Destroy(entry); + } + + _entries.Clear(); + _refreshers.Clear(); + Title.text = "Properties"; + } + + public Property AddProperty(Func read) + { + if (read == null) + { + throw new ArgumentException("Attempted to add confirmation-dialog property with null read function!"); + } + + var property = Instantiate(Property, Content ?? (RectTransform)transform); + _refreshers.Add(() => property.Label.text = read()); + property.Label.text = read(); + RegisterEntry(property.gameObject); + return property; + } + + public Property AddProperty(string text) + { + var property = Instantiate(Property, Content ?? (RectTransform)transform); + property.Label.text = text; + RegisterEntry(property.gameObject); + return property; + } + + public void AddField(string name, Func read, Action write) + { + var field = Instantiate(InputField, Content ?? (RectTransform)transform); + field.Label.text = name; + field.Field.contentType = TMP_InputField.ContentType.Standard; + field.Field.onValueChanged.AddListener(write.Invoke); + _refreshers.Add(() => SyncField(field.Field, read())); + SyncField(field.Field, read()); + RegisterEntry(field.gameObject); + } + + public void AddField(string name, Func read, Action write) + { + var field = Instantiate(InputField, Content ?? (RectTransform)transform); + field.Label.text = name; + field.Field.contentType = TMP_InputField.ContentType.IntegerNumber; + field.Field.onValueChanged.AddListener(value => + { + if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsed)) + { + write(parsed); + } + }); + _refreshers.Add(() => SyncField(field.Field, read().ToString(CultureInfo.InvariantCulture))); + SyncField(field.Field, read().ToString(CultureInfo.InvariantCulture)); + RegisterEntry(field.gameObject); + } + public void End(bool success = false) { - if(success) _onConfirm?.Invoke(); - else _onCancel?.Invoke(); + if (success) + { + _onConfirm?.Invoke(); + } + else + { + _onCancel?.Invoke(); + } + CancelClickCatcher?.gameObject.SetActive(false); gameObject.SetActive(false); ActionGameManager.Instance?.Input.Global.Enable(); @@ -59,19 +139,43 @@ public class ConfirmationDialog : PropertiesPanel public void Show(Action onConfirm = null, Action onCancel = null, string confirmText = "OK", string cancelText = "Cancel") { + RefreshValues(); gameObject.SetActive(true); - + _onConfirm = onConfirm; - Confirm.gameObject.SetActive(onConfirm!=null); + Confirm.gameObject.SetActive(onConfirm != null); ConfirmText.text = confirmText; - + _onCancel = onCancel; - Cancel.gameObject.SetActive(onCancel!=null); + Cancel.gameObject.SetActive(onCancel != null); CancelText.text = cancelText; - - ButtonGroup.SetActive(onConfirm!=null || onCancel!=null); - + + ButtonGroup.SetActive(onConfirm != null || onCancel != null); + CancelClickCatcher?.gameObject.SetActive(true); ActionGameManager.Instance?.Input.Global.Disable(); } + + private void RegisterEntry(GameObject entry) + { + _entries.Add(entry); + entry.SetActive(true); + entry.transform.SetSiblingIndex(Title.transform.GetSiblingIndex() + _entries.Count); + } + + private void RefreshValues() + { + foreach (var refresh in _refreshers) + { + refresh(); + } + } + + private static void SyncField(TMP_InputField field, string value) + { + if (!string.Equals(field.text, value, StringComparison.Ordinal)) + { + field.SetTextWithoutNotify(value); + } + } } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index af43f59ef..24e14d78f 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1613,6 +1613,10 @@ First Aetheria surfaces to publish: copies. - Done: delete the old IMGUI DB inspector; it is no longer a blocker on the live UI migration path. + - Done: cut `ConfirmationDialog` loose from generic `PropertiesPanel` + inheritance. Runtime prompts still use local uGUI content prefabs for now, + but the dialog only owns prompt text and text/integer entry instead of + serializing the whole dead inspector field zoo. - Then replace runtime HUD/menu/inventory/map screens. 7. Purge