Edit node values as curves, folded sections and suggestions in the studio

Nested settings fold into sections and lists of objects into items. Curve
values show a sparkline and open a points or shape editor, and a number or
range can be made a curve. Blocks, resources and roles are suggested while
typing, and string lists are typed as a, b. The studio asks the bridge for
the platform and pack lists (suggestions endpoint).

No terrain, pin, golden or digest moved; the files written are the same JSON.

v3: db53f834a
This commit is contained in:
piexel committed 2026-11-10 13:34:32 +01:00
1 parent dbfc1d0c34
commit 7eb45cebf6
20 files changed
+1403 -99

No files matched your search

@@ -38,7 +38,7 @@ import java.util.function.Function;
* The registries of the platform Iris runs on, as validators read them: the same lists studio completes options from.
* Each registry is read once, when a validator first asks for it.
*/
final class IrisPlatformRegistryIds implements PlatformRegistries {
public final class IrisPlatformRegistryIds implements PlatformRegistries {
private static final String DEFAULT_NAMESPACE = "minecraft:";
private final IrisPlatform platform;
@@ -49,7 +49,7 @@ final class IrisPlatformRegistryIds implements PlatformRegistries {
}
/** The bound platform's registries; empty when no platform is bound, such as in a build. */
static Optional<PlatformRegistries> ofBoundPlatform() {
public static Optional<PlatformRegistries> ofBoundPlatform() {
return IrisPlatforms.isBound() ? Optional.of(new IrisPlatformRegistryIds(IrisPlatforms.get())) : Optional.empty();
}
@@ -38,6 +38,7 @@ import art.arcane.iris.core.studio.saved.SavedWorlds;
import art.arcane.iris.core.studio.scene.StudioEditors;
import art.arcane.iris.core.studio.scene.StudioPatterns;
import art.arcane.iris.core.studio.scene.StudioScenes;
import art.arcane.iris.core.studio.scene.StudioSuggestions;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.render.RenderType;
import art.arcane.iris.engine.object.world.region.IrisRegion;
@@ -236,6 +237,7 @@ public final class StudioBridge implements AutoCloseable {
case "scene-file" -> sendJson(exchange, STATUS_OK, sceneFile(get(exchange).engine(), query));
case "scene-edit" -> sendJson(exchange, STATUS_OK, sceneEdit(exchange, query));
case "scene-write" -> sendJson(exchange, STATUS_OK, sceneWrite(exchange, query));
case "suggestions" -> sendJson(exchange, STATUS_OK, suggestions(get(exchange).engine(), query));
case "scene-entries" -> sendJson(exchange, STATUS_OK, sceneEntries(get(exchange).engine(), query));
case "scene-bake" -> sendJson(exchange, STATUS_OK, sceneBake(get(exchange).engine(), query));
case "scene" -> sendBytes(exchange, "application/octet-stream", scene(get(exchange).engine(), query));
@@ -403,6 +405,17 @@ public final class StudioBridge implements AutoCloseable {
}
}
// What a setting naming a platform entry (reference) or a pack resource (resource) may be typed as.
private static List<String> suggestions(Engine engine, Query query) {
try {
return query.has("reference")
? StudioSuggestions.ofReference(query.text("reference"))
: StudioSuggestions.ofResource(engine, query.text("resource"));
} catch (NoSuchElementException unknown) {
throw new RequestError(STATUS_NOT_FOUND, unknown.getMessage());
}
}
private static BakeRun sceneBake(Engine engine, Query query) {
String key = query.text("key");
try {
@@ -0,0 +1,75 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.studio.scene;
import art.arcane.iris.core.modules.IrisPackResources;
import art.arcane.iris.core.modules.IrisPlatformRegistryIds;
import art.arcane.iris.engine.framework.Engine;
import com.volmit.config.Reference;
import com.volmit.resource.ResourceId;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
/** What the studio offers while an author types a setting that names something: the platform's entries of a reference, or the pack's resources of a kind. */
public final class StudioSuggestions {
private StudioSuggestions() {
}
/**
* The ids of the platform's registry {@code referenceName} names, sorted.
*
* @throws NoSuchElementException when there is no such reference
*/
public static List<String> ofReference(String referenceName) {
Reference reference;
try {
reference = Reference.valueOf(referenceName);
} catch (IllegalArgumentException unknown) {
throw new NoSuchElementException("No reference named " + referenceName);
}
return IrisPlatformRegistryIds.ofBoundPlatform()
.map(registries -> sortedKeys(registries.ids(reference), null))
.orElse(List.of());
}
/**
* The keys of the pack's resources of the kind {@code kindId} names, as the pack writes them, sorted.
*
* @throws NoSuchElementException when the pack has no such kind
*/
public static List<String> ofResource(Engine engine, String kindId) {
IrisPackResources resources = engine.getData().getPackResources();
try {
return sortedKeys(resources.ids(ResourceId.parse(kindId)), resources.packId().namespace());
} catch (IllegalArgumentException unknown) {
throw new NoSuchElementException(unknown.getMessage());
}
}
/** {@code ids} as written, sorted: a resource of the pack's own namespace by its path, any other id in full. */
static List<String> sortedKeys(Collection<ResourceId> ids, String packNamespace) {
return ids.stream()
.map(id -> id.namespace().equals(packNamespace) ? id.path() : id.toString())
.distinct()
.sorted()
.toList();
}
}
@@ -0,0 +1,31 @@
package art.arcane.iris.core.studio.scene;
import com.volmit.resource.ResourceId;
import org.junit.Test;
import java.util.List;
import java.util.NoSuchElementException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
public class StudioSuggestionsTest {
@Test
public void thePacksOwnResourcesAreOfferedByPathAndOthersInFull() {
List<ResourceId> ids = List.of(ResourceId.parse("overworld:birch"), ResourceId.parse("other:oak"), ResourceId.parse("overworld:conifer/pine"));
assertEquals(List.of("birch", "conifer/pine", "other:oak"), StudioSuggestions.sortedKeys(ids, "overworld"));
}
@Test
public void platformEntriesAreOfferedInFull() {
List<ResourceId> ids = List.of(ResourceId.parse("minecraft:stone"), ResourceId.parse("minecraft:dirt"));
assertEquals(List.of("minecraft:dirt", "minecraft:stone"), StudioSuggestions.sortedKeys(ids, null));
}
@Test
public void aReferenceThatDoesNotExistIsRefused() {
assertThrows(NoSuchElementException.class, () -> StudioSuggestions.ofReference("NOT_A_REFERENCE"));
}
}