Make PropertiesPanel inspection read-only
This commit is contained in:
parent
137c7180b6
commit
cd497836b3
4 changed files with 48 additions and 32 deletions
Binary file not shown.
|
|
@ -13,6 +13,7 @@ RequireEveRuntimeBootstrap(root);
|
|||
RequireNoRendererLocalConsole(root);
|
||||
RequireNoRendererLocalDebugPanels(root);
|
||||
RequireMainMenuSettingsCommit(root);
|
||||
RequirePropertiesPanelReadOnlyInspector(root);
|
||||
|
||||
await using var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-state-verify");
|
||||
|
||||
|
|
@ -455,6 +456,7 @@ Console.WriteLine("Eve runtime bootstrap: operations surface mounts through UI T
|
|||
Console.WriteLine("Renderer-local console authority: deleted; UI commands flow through Eve command documents");
|
||||
Console.WriteLine("Renderer-local debug panels: obsolete uGUI field tester authority is deleted");
|
||||
Console.WriteLine("Main-menu settings authority: gameplay and graphics settings return through typed player-settings commits");
|
||||
Console.WriteLine("PropertiesPanel inspector authority: reflection inspection is read-only display");
|
||||
|
||||
static void RequireCount(AetheriaMigrationLedger ledger, string documentType, int actual)
|
||||
{
|
||||
|
|
@ -717,6 +719,36 @@ static void RequireMainMenuSettingsCommit(string root)
|
|||
}
|
||||
}
|
||||
|
||||
static void RequirePropertiesPanelReadOnlyInspector(string root)
|
||||
{
|
||||
var propertiesPanelPath = Path.Combine(root, "Assets", "Scripts", "UI", "Properties Panel", "PropertiesPanel.cs");
|
||||
if (!File.Exists(propertiesPanelPath))
|
||||
{
|
||||
throw new InvalidOperationException("Cannot verify PropertiesPanel inspector authority; PropertiesPanel.cs is missing.");
|
||||
}
|
||||
|
||||
var source = File.ReadAllText(propertiesPanelPath);
|
||||
var forbiddenSymbols = new[]
|
||||
{
|
||||
"readWrite",
|
||||
"field.SetValue",
|
||||
"f => field.SetValue",
|
||||
"i => field.SetValue",
|
||||
"b => field.SetValue"
|
||||
};
|
||||
|
||||
var hits = forbiddenSymbols
|
||||
.Where(symbol => source.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
|
||||
if (hits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"PropertiesPanel reflection inspection still has renderer-local write authority: " +
|
||||
string.Join(", ", hits));
|
||||
}
|
||||
}
|
||||
|
||||
static string ExtractMethodBody(string source, string methodName)
|
||||
{
|
||||
var signature = "private void " + methodName + "()";
|
||||
|
|
|
|||
|
|
@ -700,11 +700,11 @@ public class PropertiesPanel : MonoBehaviour
|
|||
RefreshValues();
|
||||
}
|
||||
|
||||
public void Inspect(object obj, bool inspectablesOnly = false, bool readWrite = false, bool topLevel = true)
|
||||
public void Inspect(object obj, bool inspectablesOnly = false, bool topLevel = true)
|
||||
{
|
||||
var fields = obj.GetType().GetFields();
|
||||
foreach (var field in fields)
|
||||
Inspect(obj, field, inspectablesOnly, readWrite);
|
||||
Inspect(obj, field, inspectablesOnly);
|
||||
|
||||
// if(topLevel)
|
||||
// foreach (var field in _propertyFields)
|
||||
|
|
@ -713,7 +713,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
RefreshValues();
|
||||
}
|
||||
|
||||
public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false, bool readWrite = false)
|
||||
public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false)
|
||||
{
|
||||
var inspectable = field.GetCustomAttribute<InspectableAttribute>();
|
||||
if (inspectable == null && inspectablesOnly) return;
|
||||
|
|
@ -721,49 +721,27 @@ public class PropertiesPanel : MonoBehaviour
|
|||
|
||||
if (type == typeof(float))
|
||||
{
|
||||
if (readWrite)
|
||||
{
|
||||
if (inspectable is InspectableRangedFloatAttribute ranged)
|
||||
AddField(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
ranged.Min, ranged.Max);
|
||||
else
|
||||
AddField(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
} else AddProperty(field.Name.SplitCamelCase(), () => ((float) field.GetValue(obj)).ToString("0.##"));
|
||||
AddProperty(field.Name.SplitCamelCase(), () => ((float) field.GetValue(obj)).ToString("0.##"));
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
if (readWrite)
|
||||
{
|
||||
if (inspectable is InspectableRangedIntAttribute ranged)
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
ranged.Min, ranged.Max);
|
||||
else
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
} else AddProperty(field.Name.SplitCamelCase(), () => ((int) field.GetValue(obj)).ToString());
|
||||
AddProperty(field.Name.SplitCamelCase(), () => ((int) field.GetValue(obj)).ToString());
|
||||
}
|
||||
else if (type.IsEnum)
|
||||
{
|
||||
if (readWrite)
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), i => field.SetValue(obj, i),
|
||||
Enum.GetNames(field.FieldType));
|
||||
else
|
||||
AddProperty(field.Name.SplitCamelCase(), () => Enum.GetName(type, field.GetValue(obj)).SplitCamelCase());
|
||||
AddProperty(field.Name.SplitCamelCase(), () => Enum.GetName(type, field.GetValue(obj)).SplitCamelCase());
|
||||
}
|
||||
else if (type == typeof(string))
|
||||
{
|
||||
if (readWrite)
|
||||
AddField(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj), i => field.SetValue(obj, i));
|
||||
else
|
||||
AddProperty(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj));
|
||||
AddProperty(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj));
|
||||
}
|
||||
//else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c));
|
||||
else if (field.FieldType == typeof(bool)) AddField(field.Name, () => (bool) field.GetValue(obj), b => field.SetValue(obj, b));
|
||||
else if (field.FieldType == typeof(bool)) AddProperty(field.Name.SplitCamelCase(), () => ((bool) field.GetValue(obj)).ToString());
|
||||
else if (type.GetCustomAttribute<InspectableAttribute>() != null)
|
||||
{
|
||||
// if(!_propertyFields.Any() || !_propertyFields.Last().gameObject.name.ToUpper().Contains("DIVIDER"))
|
||||
// _propertyFields.Add(Divider.Instantiate<Prototype>());
|
||||
var list = AddList(field.Name);
|
||||
list.Inspect(field.GetValue(obj), inspectablesOnly, readWrite, false);
|
||||
list.Inspect(field.GetValue(obj), inspectablesOnly, false);
|
||||
}
|
||||
else
|
||||
Debug.Log($"Field \"{field.Name}\" has unknown type {field.FieldType.Name}. No inspector was generated.");
|
||||
|
|
|
|||
|
|
@ -1364,6 +1364,10 @@ First Aetheria surfaces to publish:
|
|||
`FieldShieldTest.unity` script binding. Future field prototype controls
|
||||
should be provider-owned Eve/prototype commands or local simulation code,
|
||||
not a `PropertiesPanel` mutating `FieldDriver` directly.
|
||||
- Done: delete `PropertiesPanel` reflection write authority. The legacy
|
||||
inspector can still project object fields for display, but `readWrite`
|
||||
mode and `FieldInfo.SetValue` mutation are gone; renderer-local object
|
||||
edits must become provider-owned typed commands or local simulation code.
|
||||
- Replace the next concrete uGUI screen with an Eve-owned surface.
|
||||
- Move the staged packages into the Eve repo once its worktree is clean, then
|
||||
import them back into Aetheria from Eve instead of carrying a local copy.
|
||||
|
|
@ -1675,7 +1679,9 @@ Do not add behavior to `ItemData` or resurrect `RuntimeItemProjectionEntry`.
|
|||
The typed state spine, direct behavior factories, and migration quarantine
|
||||
exist; the next cuts should remove remaining live predicates that still need
|
||||
legacy DTO vocabulary, keep package-level MessagePack/JSON at explicit
|
||||
boundaries, and replace runtime/operator UI truth with Eve surfaces. Any
|
||||
boundaries, and replace runtime/operator UI truth with Eve surfaces. The old
|
||||
`PropertiesPanel` reflection inspector is display-only; do not restore writable
|
||||
inspection as a shortcut around typed command/state ownership. Any
|
||||
predicate that still needs legacy DTO objects must earn that dependency by
|
||||
using behavior objects or simulation-only methods that typed facets do not yet
|
||||
expose.
|
||||
|
|
|
|||
Loading…
Reference in a new issue