Advertise stat recipes from daemon editor surface
This commit is contained in:
parent
afcaadeff5
commit
458f40fddb
5 changed files with 63 additions and 7 deletions
|
|
@ -6344,6 +6344,7 @@ static void RequireDaemonVersePublication(string root)
|
||||||
"AetheriaRuntimeDaemonPublicationStore.PublishProviderAdvertisement",
|
"AetheriaRuntimeDaemonPublicationStore.PublishProviderAdvertisement",
|
||||||
"AetheriaRuntimeDaemonPublicationStore.PublishHealth",
|
"AetheriaRuntimeDaemonPublicationStore.PublishHealth",
|
||||||
"AetheriaRuntimeDaemonGameSurfaceBuilder.Build",
|
"AetheriaRuntimeDaemonGameSurfaceBuilder.Build",
|
||||||
|
"AetheriaRuntimeCatalogStore.ProjectStatRecipeSurfaceDocument(stateFilePath)",
|
||||||
"AetheriaRuntimeDaemonPublicationStore.PublishGameSurface",
|
"AetheriaRuntimeDaemonPublicationStore.PublishGameSurface",
|
||||||
"AetheriaRuntimeDaemonPublicationStore.PublishGameTuiSurface",
|
"AetheriaRuntimeDaemonPublicationStore.PublishGameTuiSurface",
|
||||||
"AetheriaRuntimeDaemonEditorSurfaceBuilder.Build",
|
"AetheriaRuntimeDaemonEditorSurfaceBuilder.Build",
|
||||||
|
|
@ -6466,6 +6467,9 @@ static void RequireDaemonVersePublication(string root)
|
||||||
"\"editor.daemon\"",
|
"\"editor.daemon\"",
|
||||||
"\"Verse Provider\"",
|
"\"Verse Provider\"",
|
||||||
"\"Witnesses\"",
|
"\"Witnesses\"",
|
||||||
|
"\"Designer Surfaces\"",
|
||||||
|
"AetheriaRuntimeSurfaceDocument",
|
||||||
|
"AetheriaRuntimeStatRecipeCommands.SurfaceId",
|
||||||
"\"Typed Commands\"",
|
"\"Typed Commands\"",
|
||||||
"AetheriaRuntimeDaemonCommandBoundaryEntry"
|
"AetheriaRuntimeDaemonCommandBoundaryEntry"
|
||||||
};
|
};
|
||||||
|
|
@ -6495,6 +6499,7 @@ static void RequireDaemonVersePublication(string root)
|
||||||
"AetheriaRuntimeDaemonSchemas.EditorSurface",
|
"AetheriaRuntimeDaemonSchemas.EditorSurface",
|
||||||
"AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId",
|
"AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId",
|
||||||
"AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId",
|
"AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId",
|
||||||
|
"AetheriaRuntimeStatRecipeCommands.SurfaceId",
|
||||||
"AetheriaRuntimeDaemonCommandKinds.TransferCargoItem",
|
"AetheriaRuntimeDaemonCommandKinds.TransferCargoItem",
|
||||||
"nameof(AetheriaRuntimeCargoTransferCommand)"
|
"nameof(AetheriaRuntimeCargoTransferCommand)"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,10 @@ public class DaemonRuntimeDocumentTests
|
||||||
Assert.AreEqual(42, editorSurface.Version);
|
Assert.AreEqual(42, editorSurface.Version);
|
||||||
Assert.IsTrue(ContainsSurfaceMetric(editorSurface.Surface.Root, "Verse", "aetheria.test"));
|
Assert.IsTrue(ContainsSurfaceMetric(editorSurface.Surface.Root, "Verse", "aetheria.test"));
|
||||||
Assert.IsTrue(ContainsSurfaceMetric(editorSurface.Surface.Root, "Status", "healthy"));
|
Assert.IsTrue(ContainsSurfaceMetric(editorSurface.Surface.Root, "Status", "healthy"));
|
||||||
|
Assert.IsTrue(ContainsSurfaceProp(
|
||||||
|
editorSurface.Surface.Root,
|
||||||
|
"surfaceId",
|
||||||
|
AetheriaRuntimeStatRecipeCommands.SurfaceId));
|
||||||
Assert.IsTrue(editorSurface.Commands.Any(command =>
|
Assert.IsTrue(editorSurface.Commands.Any(command =>
|
||||||
command.Command == "aetheria.daemon.commands.TransferCargoItem" &&
|
command.Command == "aetheria.daemon.commands.TransferCargoItem" &&
|
||||||
command.Transport == "cultmesh"));
|
command.Transport == "cultmesh"));
|
||||||
|
|
@ -2376,4 +2380,18 @@ public class DaemonRuntimeDocumentTests
|
||||||
|
|
||||||
return component.Children.Any(child => ContainsSurfaceMetric(child, label, value));
|
return component.Children.Any(child => ContainsSurfaceMetric(child, label, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool ContainsSurfaceProp(
|
||||||
|
AetheriaRuntimeSurfaceComponent component,
|
||||||
|
string key,
|
||||||
|
string value)
|
||||||
|
{
|
||||||
|
if (component.Props.TryGetValue(key, out var actual) &&
|
||||||
|
string.Equals(actual, value, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return component.Children.Any(child => ContainsSurfaceProp(child, key, value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,16 +69,15 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
surfaces.Add(ReadEveSurface(record.Payload));
|
surfaces.Add(ReadEveSurface(record.Payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaces.Add(ProjectStatRecipeSurface(stateFilePath));
|
surfaces.Add(AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||||
|
ProjectStatRecipeSurfaceDocument(stateFilePath)));
|
||||||
return surfaces;
|
return surfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EveSurfaceDocument ProjectStatRecipeSurface(string stateFilePath)
|
public static AetheriaRuntimeSurfaceDocument ProjectStatRecipeSurfaceDocument(string stateFilePath)
|
||||||
{
|
{
|
||||||
var state = ProjectStatRecipeSurfaceState(stateFilePath);
|
var state = ProjectStatRecipeSurfaceState(stateFilePath);
|
||||||
var document = AetheriaRuntimeStatRecipeSurfaceBuilder.Build(
|
return AetheriaRuntimeStatRecipeSurfaceBuilder.Build(state);
|
||||||
state);
|
|
||||||
return AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(document);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AetheriaRuntimeStatRecipeSurfaceState ProjectStatRecipeSurfaceState(string stateFilePath)
|
private static AetheriaRuntimeStatRecipeSurfaceState ProjectStatRecipeSurfaceState(string stateFilePath)
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,13 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
public static AetheriaRuntimeSurfaceDocument Build(
|
public static AetheriaRuntimeSurfaceDocument Build(
|
||||||
AetheriaRuntimeDaemonProviderAdvertisementDocument provider,
|
AetheriaRuntimeDaemonProviderAdvertisementDocument provider,
|
||||||
AetheriaRuntimeDaemonHealthDocument health,
|
AetheriaRuntimeDaemonHealthDocument health,
|
||||||
AetheriaRuntimeDaemonCommandBoundaryDocument commandBoundary)
|
AetheriaRuntimeDaemonCommandBoundaryDocument commandBoundary,
|
||||||
|
IReadOnlyList<AetheriaRuntimeSurfaceDocument>? designerSurfaces = null)
|
||||||
{
|
{
|
||||||
provider ??= new AetheriaRuntimeDaemonProviderAdvertisementDocument();
|
provider ??= new AetheriaRuntimeDaemonProviderAdvertisementDocument();
|
||||||
health ??= new AetheriaRuntimeDaemonHealthDocument();
|
health ??= new AetheriaRuntimeDaemonHealthDocument();
|
||||||
commandBoundary ??= AetheriaRuntimeDaemonCommandBoundaryDocument.Create(provider.DaemonId);
|
commandBoundary ??= AetheriaRuntimeDaemonCommandBoundaryDocument.Create(provider.DaemonId);
|
||||||
|
designerSurfaces ??= Array.Empty<AetheriaRuntimeSurfaceDocument>();
|
||||||
|
|
||||||
return new AetheriaRuntimeSurfaceDocument(
|
return new AetheriaRuntimeSurfaceDocument(
|
||||||
providerId: "aetheria.daemon",
|
providerId: "aetheria.daemon",
|
||||||
|
|
@ -94,6 +96,16 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
commandBoundary.Commands
|
commandBoundary.Commands
|
||||||
.Take(16)
|
.Take(16)
|
||||||
.Select((entry, index) => CommandRow(index, entry))
|
.Select((entry, index) => CommandRow(index, entry))
|
||||||
|
.ToArray())),
|
||||||
|
Node(
|
||||||
|
"aetheria.daemon.editor.designer_surfaces",
|
||||||
|
"card",
|
||||||
|
new[] { ("title", "Designer Surfaces") },
|
||||||
|
Row(
|
||||||
|
"aetheria.daemon.editor.designer_surfaces.rows",
|
||||||
|
designerSurfaces
|
||||||
|
.Where(surface => surface != null)
|
||||||
|
.Select((surface, index) => DesignerSurfaceRow(index, surface))
|
||||||
.ToArray()))),
|
.ToArray()))),
|
||||||
Array.Empty<AetheriaRuntimeSurfaceStyleToken>()),
|
Array.Empty<AetheriaRuntimeSurfaceStyleToken>()),
|
||||||
commands: commandBoundary.Commands
|
commands: commandBoundary.Commands
|
||||||
|
|
@ -104,6 +116,23 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
.ToArray());
|
.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static AetheriaRuntimeSurfaceComponent DesignerSurfaceRow(
|
||||||
|
int index,
|
||||||
|
AetheriaRuntimeSurfaceDocument surface)
|
||||||
|
{
|
||||||
|
return Node(
|
||||||
|
$"aetheria.daemon.editor.designer_surfaces.{index}",
|
||||||
|
"inspector.kv",
|
||||||
|
new[]
|
||||||
|
{
|
||||||
|
("title", surface.Title),
|
||||||
|
("surfaceId", surface.Surface.Id),
|
||||||
|
("provider", surface.ProviderId),
|
||||||
|
("kind", surface.ProviderKind),
|
||||||
|
("commands", surface.Commands.Count.ToString(CultureInfo.InvariantCulture))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static AetheriaRuntimeSurfaceComponent CommandRow(
|
private static AetheriaRuntimeSurfaceComponent CommandRow(
|
||||||
int index,
|
int index,
|
||||||
AetheriaRuntimeDaemonCommandBoundaryEntry entry)
|
AetheriaRuntimeDaemonCommandBoundaryEntry entry)
|
||||||
|
|
|
||||||
|
|
@ -165,10 +165,15 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
var gameTuiSurfacePath = AetheriaRuntimeDaemonPublicationStore.PublishGameTuiSurface(
|
var gameTuiSurfacePath = AetheriaRuntimeDaemonPublicationStore.PublishGameTuiSurface(
|
||||||
stateFilePath,
|
stateFilePath,
|
||||||
gameSurface);
|
gameSurface);
|
||||||
|
var designerSurfaces = new[]
|
||||||
|
{
|
||||||
|
AetheriaRuntimeCatalogStore.ProjectStatRecipeSurfaceDocument(stateFilePath)
|
||||||
|
};
|
||||||
var editorSurface = AetheriaRuntimeDaemonEditorSurfaceBuilder.Build(
|
var editorSurface = AetheriaRuntimeDaemonEditorSurfaceBuilder.Build(
|
||||||
providerAdvertisement,
|
providerAdvertisement,
|
||||||
health,
|
health,
|
||||||
commandBoundary);
|
commandBoundary,
|
||||||
|
designerSurfaces);
|
||||||
var editorSurfacePath = AetheriaRuntimeDaemonPublicationStore.PublishEditorSurface(
|
var editorSurfacePath = AetheriaRuntimeDaemonPublicationStore.PublishEditorSurface(
|
||||||
stateFilePath,
|
stateFilePath,
|
||||||
editorSurface);
|
editorSurface);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue