From 22d69f362f1ad9ca958c42208540381c894cafdb Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 13 Nov 2026 09:53:30 +0100 Subject: [PATCH] Make the Caves view a viewer only The Caves view no longer edits cave files. It shows each cave at the chosen size and variant, and redraws when a file is saved. The form, creating caves from the studio and EditableSceneView.showsNodes() are gone. --- api/README.md | 3 +- .../com/volmit/tooling/EditableSceneView.java | 8 --- .../iris/core/studio/bridge/StudioBridge.java | 6 +- .../iris/core/studio/scene/StudioEditors.java | 5 -- .../iris/modules/carve/CaveScenesTest.java | 24 ++----- .../arcane/iris/modules/carve/CaveGraph.java | 70 ------------------- .../arcane/iris/modules/carve/CaveScenes.java | 41 +---------- studio/src/renderer/src/bridge/types.ts | 2 - .../src/renderer/src/studio/SceneStudio.tsx | 6 +- 9 files changed, 14 insertions(+), 151 deletions(-) delete mode 100644 module/src/main/java/art/arcane/iris/modules/carve/CaveGraph.java diff --git a/api/README.md b/api/README.md index 9084a6acb..1e15bcf9e 100644 --- a/api/README.md +++ b/api/README.md @@ -550,8 +550,7 @@ final class RuinScenes implements SceneView { settings (`NodeSettings`, shown as the pack's schema describes their type), the nodes it holds and the `Edits` the studio may make (a child list to move nodes into, whether it moves, the `Addition`s it offers). Places in the file are `JsonPath`s of `Key` and `Index` steps. The studio writes the file itself, rewriting only what changes; the - view never writes. A view whose file reads as one node of settings returns false from `showsNodes()`, and the - studio shows that node's settings beside the scene instead of a graph. A view whose entries the studio may create and delete returns a `SceneCreation` from + view never writes. A view whose entries the studio may create and delete returns a `SceneCreation` from `creation()`: the resource kind of its files, the starter JSON of a new entry and the text other files name an entry by; the studio does the writing, listing of uses and trashing. - Absent values are empty, never blank or `-1`: an entry without a group, a node that draws no part of the scene diff --git a/api/api/src/main/java/com/volmit/tooling/EditableSceneView.java b/api/api/src/main/java/com/volmit/tooling/EditableSceneView.java index b915cd2e4..c6ac55faf 100644 --- a/api/api/src/main/java/com/volmit/tooling/EditableSceneView.java +++ b/api/api/src/main/java/com/volmit/tooling/EditableSceneView.java @@ -21,14 +21,6 @@ public interface EditableSceneView extends SceneView { */ NodeGraph graph(PackWorld world, String key, JsonText text); - /** - * Whether the studio shows the file's graph as nodes under the scene, which is the default. A view whose file reads - * as one node of settings says no, and the studio shows those settings beside the scene instead. - */ - default boolean showsNodes() { - return true; - } - /** How the studio creates and removes entries of this view; empty when it may not, which is the default. */ default Optional creation() { return Optional.empty(); diff --git a/core/src/main/java/art/arcane/iris/core/studio/bridge/StudioBridge.java b/core/src/main/java/art/arcane/iris/core/studio/bridge/StudioBridge.java index ec0ca126e..22c660039 100644 --- a/core/src/main/java/art/arcane/iris/core/studio/bridge/StudioBridge.java +++ b/core/src/main/java/art/arcane/iris/core/studio/bridge/StudioBridge.java @@ -385,7 +385,7 @@ public final class StudioBridge implements AutoCloseable { boolean editable = editors.edits(view.id()); SceneSizesWire sizes = scenes.sizes(view.id()).map(SceneSizesWire::of).orElse(null); return new SceneViewInfo(view.id(), view.label(), view.description(), editable, editable && editors.creates(view.id()), - editable && editors.showsNodes(view.id()), scenes.isBaked(view.id()), scenes.hasParts(view.id()), sizes); + scenes.isBaked(view.id()), scenes.hasParts(view.id()), sizes); }).toList(); } @@ -922,8 +922,8 @@ public final class StudioBridge implements AutoCloseable { /** A scene view as the studio lists it; {@code editable} when its entries can be edited as nodes, {@code creatable} when they can also be created and deleted, {@code baked} when their bake can be timed, {@code parts} when the blocks of a scene can be told by the part that placed them. */ /** @param sizes null when the view's entries each have a size of their own */ - private record SceneViewInfo(String id, String label, String description, boolean editable, boolean creatable, boolean nodes, - boolean baked, boolean parts, SceneSizesWire sizes) { + private record SceneViewInfo(String id, String label, String description, boolean editable, boolean creatable, boolean baked, + boolean parts, SceneSizesWire sizes) { } private record SceneSizesWire(List blocksAcross, int opening) { diff --git a/core/src/main/java/art/arcane/iris/core/studio/scene/StudioEditors.java b/core/src/main/java/art/arcane/iris/core/studio/scene/StudioEditors.java index ca19b56fa..0c5887db1 100644 --- a/core/src/main/java/art/arcane/iris/core/studio/scene/StudioEditors.java +++ b/core/src/main/java/art/arcane/iris/core/studio/scene/StudioEditors.java @@ -119,11 +119,6 @@ public final class StudioEditors { return save(viewId, key, file, text); } - /** Whether the studio shows the files of {@code viewId} as nodes, rather than as one node's settings beside the scene. */ - public boolean showsNodes(String viewId) { - return views.ask(viewId, "tell whether its files show as nodes", EditableSceneView::showsNodes); - } - /** Whether entries of {@code viewId} can be created and removed from the studio. */ public boolean creates(String viewId) { return views.ask(viewId, "tell whether entries are created", view -> view.creation().isPresent()); diff --git a/core/src/test/java/art/arcane/iris/modules/carve/CaveScenesTest.java b/core/src/test/java/art/arcane/iris/modules/carve/CaveScenesTest.java index ce875c2f6..a12830b2b 100644 --- a/core/src/test/java/art/arcane/iris/modules/carve/CaveScenesTest.java +++ b/core/src/test/java/art/arcane/iris/modules/carve/CaveScenesTest.java @@ -5,11 +5,10 @@ import art.arcane.iris.engine.object.TestSettings; import com.volmit.geometry.BlockPosition; import com.volmit.object.GeneratedObject; import com.volmit.object.ObjectBlock; -import com.volmit.tooling.GraphNode; -import com.volmit.tooling.JsonText; -import com.volmit.tooling.NodeGraph; +import com.volmit.tooling.EditableSceneView; import com.volmit.tooling.SceneEntry; import com.volmit.tooling.SceneRequest; +import com.volmit.tooling.SceneView; import org.junit.Test; import java.util.HashSet; @@ -88,22 +87,9 @@ public class CaveScenesTest { } @Test - public void aCaveFileIsOneNodeWithASectionForEachPart() { - NodeGraph graph = view.graph(world, "deep/mixed", JsonText.parse(MIXED)); - - assertFalse(view.showsNodes()); - GraphNode cave = graph.roots().getFirst(); - assertEquals("mixed", cave.title()); - assertTrue(cave.children().isEmpty()); - assertEquals(List.of("Cave", "Tunnel", "Cavern", "Pillars"), cave.settings().stream().map(GraphNode.NodeSettings::title).toList()); - } - - @Test - public void anUnwrittenPartHasASectionSoSettingItWritesIt() { - NodeGraph graph = view.graph(world, "tunnels", JsonText.parse(TUNNELS_ONLY)); - - assertEquals(List.of("Cave", "Tunnel", "Cavern (unset)", "Pillars (unset)"), - graph.roots().getFirst().settings().stream().map(GraphNode.NodeSettings::title).toList()); + public void theViewOnlyShowsCavesAndEditsNone() { + SceneView registered = view; + assertFalse(registered instanceof EditableSceneView); } private GeneratedObject scene(String key, int variant, int size) { diff --git a/module/src/main/java/art/arcane/iris/modules/carve/CaveGraph.java b/module/src/main/java/art/arcane/iris/modules/carve/CaveGraph.java deleted file mode 100644 index de1e9d226..000000000 --- a/module/src/main/java/art/arcane/iris/modules/carve/CaveGraph.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Servers - * Copyright (c) 2026 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.modules.carve; - -import com.volmit.tooling.GraphNode; -import com.volmit.tooling.GraphNode.Edits; -import com.volmit.tooling.GraphNode.NodeSettings; -import com.volmit.tooling.JsonPath; -import com.volmit.tooling.JsonText; -import com.volmit.tooling.NodeGraph; - -import java.util.List; -import java.util.OptionalInt; -import java.util.Set; - -/** - * A cave file as one node of settings, a section each for the cave, its tunnels, its caverns and their pillars. Every - * section is there, written or not, since setting a value in one writes it into the file. - */ -final class CaveGraph { - private static final String TUNNEL = "tunnel"; - private static final String CAVERN = "cavern"; - private static final String PILLARS = "pillars"; - private static final String UNWRITTEN = " (unset)"; - private static final Set NONE_ELSEWHERE = Set.of(); - - private CaveGraph() { - } - - /** @throws IllegalArgumentException when the file does not hold an object */ - static NodeGraph of(String name, JsonText text) { - if (!(text.root() instanceof JsonText.Obj root)) { - throw new IllegalArgumentException("The file does not hold an object"); - } - JsonPath tunnelPath = JsonPath.ROOT.member(TUNNEL); - JsonPath cavernPath = JsonPath.ROOT.member(CAVERN); - JsonPath pillarsPath = cavernPath.member(PILLARS); - List sections = List.of( - new NodeSettings("Cave", JsonPath.ROOT, Cave.class, Set.of(TUNNEL, CAVERN)), - new NodeSettings(titled("Tunnel", root.get(TUNNEL).isPresent()), tunnelPath, CaveTunnel.class, NONE_ELSEWHERE), - new NodeSettings(titled("Cavern", root.get(CAVERN).isPresent()), cavernPath, CaveCavern.class, Set.of(PILLARS)), - new NodeSettings(titled("Pillars", hasMember(root, CAVERN, PILLARS)), pillarsPath, CavePillars.class, NONE_ELSEWHERE)); - GraphNode cave = new GraphNode("Cave", name, JsonPath.ROOT, OptionalInt.empty(), List.of(), sections, List.of(), Edits.NONE); - return new NodeGraph(List.of(cave)); - } - - private static String titled(String section, boolean written) { - return written ? section : section + UNWRITTEN; - } - - private static boolean hasMember(JsonText.Obj root, String member, String inner) { - return root.get(member).orElse(null) instanceof JsonText.Obj object && object.get(inner).isPresent(); - } -} diff --git a/module/src/main/java/art/arcane/iris/modules/carve/CaveScenes.java b/module/src/main/java/art/arcane/iris/modules/carve/CaveScenes.java index 983cf7810..f86cd3a42 100644 --- a/module/src/main/java/art/arcane/iris/modules/carve/CaveScenes.java +++ b/module/src/main/java/art/arcane/iris/modules/carve/CaveScenes.java @@ -20,14 +20,10 @@ package art.arcane.iris.modules.carve; import com.volmit.object.GeneratedObject; import com.volmit.resource.ResourceId; -import com.volmit.tooling.EditableSceneView; -import com.volmit.tooling.JsonText; -import com.volmit.tooling.NodeGraph; -import com.volmit.tooling.SceneCreation; import com.volmit.tooling.SceneEntry; -import com.volmit.tooling.SceneFile; import com.volmit.tooling.SceneRequest; import com.volmit.tooling.SceneSizes; +import com.volmit.tooling.SceneView; import com.volmit.world.PackWorld; import java.util.LinkedHashMap; @@ -38,19 +34,11 @@ import java.util.Optional; /** * The studio's Caves view: every cave of the pack's {@code caves/} folder carved over a square of the world under a * flat surface, the carved space drawn as blocks so its shape shows. Each variant is the same cave elsewhere in the - * world. A cave's settings are shown beside it, and the studio redraws the cave as they change. + * world. A viewer only: caves are written in their files, and the studio redraws a cave when its file is saved. */ -public final class CaveScenes implements EditableSceneView { +public final class CaveScenes implements SceneView { private static final ResourceId ID = ResourceId.parse("iris:carve/caves"); private static final char FOLDER_SEPARATOR = '/'; - /** Other files name a cave by its bare key, in a {@code caves} list. */ - private static final String REFERENCE_PREFIX = ""; - private static final String STARTER = """ - { - "tunnel": {"width": {"min": 4, "max": 7}, "stretch": 96} - } - """; - private static final SceneCreation CREATION = new SceneCreation(CaveResources.CAVES, STARTER, REFERENCE_PREFIX); @Override public ResourceId id() { @@ -91,29 +79,6 @@ public final class CaveScenes implements EditableSceneView { return Optional.of(world.state(Previews.class, ignored -> new Previews()).of(world, new Place(id, request.variant(), size), cave)); } - @Override - public Optional fileOf(PackWorld world, String key) { - ResourceId id = world.resources().idOf(key); - return world.resources().ids(CaveResources.CAVES).contains(id) - ? Optional.of(new SceneFile(CaveResources.CAVES, id)) - : Optional.empty(); - } - - @Override - public NodeGraph graph(PackWorld world, String key, JsonText text) { - return CaveGraph.of(key.substring(key.lastIndexOf(FOLDER_SEPARATOR) + 1), text); - } - - @Override - public boolean showsNodes() { - return false; - } - - @Override - public Optional creation() { - return Optional.of(CREATION); - } - private static SceneEntry entryOf(ResourceId id) { String path = id.path(); int lastSeparator = path.lastIndexOf(FOLDER_SEPARATOR); diff --git a/studio/src/renderer/src/bridge/types.ts b/studio/src/renderer/src/bridge/types.ts index 8f96477cc..fd440af25 100644 --- a/studio/src/renderer/src/bridge/types.ts +++ b/studio/src/renderer/src/bridge/types.ts @@ -40,8 +40,6 @@ export interface SceneEntry { export interface SceneViewInfo extends ModuleViewInfo { editable: boolean creatable: boolean - /** Whether an editable view's files show as nodes under the scene; else as one node's settings beside it. */ - nodes: boolean baked: boolean parts: boolean /** The sizes the scenes can be built at, or null when each entry has its own. */ diff --git a/studio/src/renderer/src/studio/SceneStudio.tsx b/studio/src/renderer/src/studio/SceneStudio.tsx index da27118b0..0efd569f5 100644 --- a/studio/src/renderer/src/studio/SceneStudio.tsx +++ b/studio/src/renderer/src/studio/SceneStudio.tsx @@ -65,10 +65,8 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce const bakeTiming = useBakeTiming(client, view.id, entry?.key ?? null, view.baked, packRevision, tell) const editor = useNodeEditor(client, view.id, view.editable ? (entry?.key ?? null) : null, packRevision, tell) - const editsAsForm = view.editable && !view.nodes const [selectedPath, setSelectedPath] = useState(null) - const roots = editor.state?.roots ?? null - const selected = roots === null ? null : editsAsForm ? (roots[0] ?? null) : selectedPath !== null ? nodeWithPath(roots, selectedPath) : null + const selected = editor.state?.roots != null && selectedPath !== null ? nodeWithPath(editor.state.roots, selectedPath) : null const values = useMemo(() => (editor.state === null ? undefined : parsedText(editor.state.text)), [editor.state]) const suggestions = useMemo(() => new SuggestionStore((of) => client.suggestions(of)), [client, packRevision]) @@ -133,7 +131,7 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce onSize={(next) => setChosenSize({ viewId: view.id, size: next })} onPick={view.parts ? pickPart : undefined} /> - {view.editable && !editsAsForm && entry !== null && ( + {view.editable && entry !== null && (