Add Unity Norn plugin host proof
This commit is contained in:
parent
84fd4933aa
commit
3d8ca4676f
8 changed files with 120 additions and 18 deletions
|
|
@ -11,8 +11,10 @@ Plugin semantics enter through runtime plugin hosts. The package includes a
|
|||
first-party `sai.vn` host proof for `vn.stage`, dialogue panels, action rails,
|
||||
and story command projection. Sai still owns story state and command semantics;
|
||||
Unity only owns native projection and emits `gamecult.eve.command.v1` requests.
|
||||
`norn.graph` and `tex.math` still pass through as generic Eve component
|
||||
structure until they gain explicit Unity plugin hosts.
|
||||
The package also includes a `norn.graph` host proof for `embed.norn`; Norn still
|
||||
owns graph layout and graph semantics, while Unity owns the embedded graph shell
|
||||
and command emission. `tex.math` still passes through as generic Eve component
|
||||
structure until it gains an explicit Unity plugin host.
|
||||
|
||||
This package lives in the Eve repository as the shared Unity lowering target.
|
||||
Aetheria and other Unity consumers should import it from Eve instead of
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ namespace GameCult.Eve.UnityUIToolkit
|
|||
EmbeddedDocumentResolver = embeddedDocumentResolver;
|
||||
PluginHosts = pluginHosts ?? new IEveUiToolkitPluginHost[]
|
||||
{
|
||||
new SaiVisualNovelUiToolkitPluginHost()
|
||||
new SaiVisualNovelUiToolkitPluginHost(),
|
||||
new NornGraphUiToolkitPluginHost()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace GameCult.Eve.UnityUIToolkit
|
||||
{
|
||||
public sealed class NornGraphUiToolkitPluginHost : IEveUiToolkitPluginHost
|
||||
{
|
||||
public string PluginId => "norn.graph";
|
||||
|
||||
public IReadOnlyList<string> Capabilities { get; } = new[]
|
||||
{
|
||||
"embed.norn"
|
||||
};
|
||||
|
||||
public bool CanLower(EveSurfaceComponent component)
|
||||
{
|
||||
return string.Equals(component.Kind, "embed.norn", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public VisualElement Lower(
|
||||
EveSurfaceComponent component,
|
||||
EveSurfaceDocument document,
|
||||
Action<EveSurfaceCommandRequest>? commandSink)
|
||||
{
|
||||
var graph = new VisualElement();
|
||||
graph.AddToClassList("eve-plugin-host");
|
||||
graph.AddToClassList("eve-plugin-norn-graph");
|
||||
graph.AddToClassList("norn-graph");
|
||||
graph.style.flexDirection = FlexDirection.Column;
|
||||
|
||||
var title = component.GetProp("label", component.GetProp("title", "Norn graph"));
|
||||
var titleLabel = new Label(title);
|
||||
titleLabel.AddToClassList("norn-graph-title");
|
||||
titleLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
|
||||
graph.Add(titleLabel);
|
||||
|
||||
var mode = component.GetProp("mode", component.GetProp("layoutMode", "embedded"));
|
||||
var modeLabel = new Label(mode);
|
||||
modeLabel.AddToClassList("norn-graph-mode");
|
||||
graph.Add(modeLabel);
|
||||
|
||||
var focusCommand = component.GetProp("command", component.GetProp("focusCommand", "graph.focus"));
|
||||
graph.RegisterCallback<ClickEvent>(_ => EmitGraphCommand(document, component, focusCommand, commandSink));
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
private static void EmitGraphCommand(
|
||||
EveSurfaceDocument document,
|
||||
EveSurfaceComponent component,
|
||||
string command,
|
||||
Action<EveSurfaceCommandRequest>? commandSink)
|
||||
{
|
||||
if (commandSink == null || string.IsNullOrWhiteSpace(command))
|
||||
return;
|
||||
|
||||
commandSink(new EveSurfaceCommandRequest(
|
||||
document.ProviderId,
|
||||
document.Surface.Id,
|
||||
ResolveOperation(document, command),
|
||||
CultMesh.OperationPayload(component.Props),
|
||||
DateTimeOffset.UtcNow,
|
||||
"unity-uitoolkit"));
|
||||
}
|
||||
|
||||
private static CultMeshOperationInvocationDescriptor ResolveOperation(
|
||||
EveSurfaceDocument document,
|
||||
string command)
|
||||
{
|
||||
foreach (var template in document.Commands)
|
||||
{
|
||||
if (string.Equals(template.Command, command, StringComparison.Ordinal))
|
||||
return CultMesh.OperationInvocation(template.Operation);
|
||||
}
|
||||
|
||||
return CultMesh.OperationInvocation(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 729936c97f3c45f7bba0fcd6de8b40f5
|
||||
|
|
@ -22,13 +22,16 @@
|
|||
"story.jump"
|
||||
],
|
||||
"host": "SaiVisualNovelUiToolkitPluginHost"
|
||||
},
|
||||
{
|
||||
"pluginId": "norn.graph",
|
||||
"capabilities": [
|
||||
"embed.norn"
|
||||
],
|
||||
"host": "NornGraphUiToolkitPluginHost"
|
||||
}
|
||||
],
|
||||
"unsupportedPlugins": [
|
||||
{
|
||||
"pluginId": "norn.graph",
|
||||
"reason": "Unity UI Toolkit currently preserves embed.norn as generic Eve structure; no Norn graph plugin host or layout adapter exists in this runtime."
|
||||
},
|
||||
{
|
||||
"pluginId": "tex.math",
|
||||
"reason": "Unity UI Toolkit currently preserves embed.tex as generic Eve structure; no TeX render plugin host exists in this runtime."
|
||||
|
|
|
|||
Loading…
Reference in a new issue