Fix decorator palettes and stale theme on swapped panels

- Decorator palettes no longer look up a layer they don't have
- Sidebar and inspector panels pick up a theme switch made while they were off screen
This commit is contained in:
piexel committed 2026-10-25 16:00:17 +01:00
1 parent 29cca99947
commit ff6668a48b
3 files changed
+38 -20

No files matched your search

@@ -50,14 +50,15 @@ abstract class BiomePalettePlacement {
RNG postRandom = new RNG(engine.getSeedManager().getPost()); RNG postRandom = new RNG(engine.getSeedManager().getPost());
int seaLevel = seaLevel(engine.getDimension()); int seaLevel = seaLevel(engine.getDimension());
int index = palette.index(); int index = palette.index();
IrisBiomePaletteLayer layer = palette.layerIn(biome);
return switch (palette.kind()) { return switch (palette.kind()) {
case LAYER -> new StackedLayer(layer, index, biome.getLayerHeightGenerators(terrainRandom, data), terrainRandom, data); case LAYER -> new StackedLayer(palette.layerIn(biome), index, biome.getLayerHeightGenerators(terrainRandom, data),
case SEA_LAYER -> new StackedLayer(layer, index, biome.getLayerSeaHeightGenerators(terrainRandom, data), terrainRandom, data); terrainRandom, data);
case CAVE_CEILING_LAYER -> new StackedLayer(layer, index, biome.getCaveCeilingLayerHeightGenerators(carveRandom, data), case SEA_LAYER -> new StackedLayer(palette.layerIn(biome), index, biome.getLayerSeaHeightGenerators(terrainRandom, data),
carveRandom, data); terrainRandom, data);
case WALL -> new SingleBlocks(layer, data, carveRandom, seaLevel); case CAVE_CEILING_LAYER -> new StackedLayer(palette.layerIn(biome), index,
case SLAB -> new SingleBlocks(layer, data, postRandom, seaLevel); biome.getCaveCeilingLayerHeightGenerators(carveRandom, data), carveRandom, data);
case WALL -> new SingleBlocks(palette.layerIn(biome), data, carveRandom, seaLevel);
case SLAB -> new SingleBlocks(palette.layerIn(biome), data, postRandom, seaLevel);
case DECORATOR -> new Decorations(palette.decoratorIn(biome), engine.getSeedManager().getComponent(), seaLevel, data); case DECORATOR -> new Decorations(palette.decoratorIn(biome), engine.getSeedManager().getComponent(), seaLevel, data);
}; };
} }
@@ -260,14 +260,13 @@ public final class MapWindow implements MapCanvas.Listener {
canvas.showView(view); canvas.showView(view);
canvas.setActive(true); canvas.setActive(true);
showControls(mapControls); showControls(mapControls);
inspectorSlot.removeAll();
if (view == MapView.REGIONS) { if (view == MapView.REGIONS) {
showRegionExplorer(previousView); showRegionExplorer(previousView);
} else if (view == MapView.BIOMES) { } else if (view == MapView.BIOMES) {
showBiomeExplorer(); showBiomeExplorer();
} else { } else {
useSidebar(viewListScroll); useSidebar(viewListScroll);
inspectorSlot.add(legendPanel, BorderLayout.CENTER); useInspector(legendPanel);
} }
showCard(MAP_CARD); showCard(MAP_CARD);
canvas.requestFocusInWindow(); canvas.requestFocusInWindow();
@@ -293,9 +292,9 @@ public final class MapWindow implements MapCanvas.Listener {
// The region and biome views share how the map draws its picks, so their switches show the same choice. // The region and biome views share how the map draws its picks, so their switches show the same choice.
private void showPickInspector(PickInspectorPanel inspector) { private void showPickInspector(PickInspectorPanel inspector) {
inspector.selectDisplay(canvas.pickDisplay()); inspector.selectDisplay(canvas.pickDisplay());
pickInspectorSplit.setTopComponent(inspector); pickInspectorSplit.setTopComponent(StudioTheme.matchTheme(inspector));
pickInspectorSplit.setBottomComponent(legendPanel); pickInspectorSplit.setBottomComponent(StudioTheme.matchTheme(legendPanel));
inspectorSlot.add(pickInspectorSplit, BorderLayout.CENTER); useInspector(pickInspectorSplit);
} }
private void stylePickInspectorSplit() { private void stylePickInspectorSplit() {
@@ -316,8 +315,7 @@ public final class MapWindow implements MapCanvas.Listener {
canvas.setActive(false); canvas.setActive(false);
showControls(explorerControls); showControls(explorerControls);
useSidebar(viewListAbove(paletteExplorer.paletteSidebar())); useSidebar(viewListAbove(paletteExplorer.paletteSidebar()));
inspectorSlot.removeAll(); useInspector(paletteExplorer.paletteInspector());
inspectorSlot.add(paletteExplorer.paletteInspector(), BorderLayout.CENTER);
showCard(PALETTES_CARD); showCard(PALETTES_CARD);
EventQueue.invokeLater(() -> viewList.select(currentView)); EventQueue.invokeLater(() -> viewList.select(currentView));
if (firstOpen) { if (firstOpen) {
@@ -331,8 +329,7 @@ public final class MapWindow implements MapCanvas.Listener {
canvas.setActive(false); canvas.setActive(false);
showControls(explorerControls); showControls(explorerControls);
useSidebar(viewListAbove(explorer.browser())); useSidebar(viewListAbove(explorer.browser()));
inspectorSlot.removeAll(); useInspector(explorer.overview());
inspectorSlot.add(explorer.overview(), BorderLayout.CENTER);
showCard(view.name()); showCard(view.name());
EventQueue.invokeLater(() -> viewList.select(currentView)); EventQueue.invokeLater(() -> viewList.select(currentView));
if (firstOpen) { if (firstOpen) {
@@ -352,8 +349,7 @@ public final class MapWindow implements MapCanvas.Listener {
canvas.setActive(false); canvas.setActive(false);
showControls(worldControls, explorerControls); showControls(worldControls, explorerControls);
useSidebar(viewListScroll); useSidebar(viewListScroll);
inspectorSlot.removeAll(); useInspector(worldExplorer.legend());
inspectorSlot.add(worldExplorer.legend(), BorderLayout.CENTER);
showCard(WORLD_CARD); showCard(WORLD_CARD);
worldExplorer.show(worldCenterX, worldCenterZ, firstOpen || mapMoved); worldExplorer.show(worldCenterX, worldCenterZ, firstOpen || mapMoved);
} }
@@ -430,7 +426,7 @@ public final class MapWindow implements MapCanvas.Listener {
private JSplitPane viewListAbove(JComponent explorerSidebar) { private JSplitPane viewListAbove(JComponent explorerSidebar) {
boolean firstUse = explorerSplit.getBottomComponent() == null; boolean firstUse = explorerSplit.getBottomComponent() == null;
explorerSplit.setTopComponent(viewListScroll); explorerSplit.setTopComponent(viewListScroll);
explorerSplit.setBottomComponent(explorerSidebar); explorerSplit.setBottomComponent(StudioTheme.matchTheme(explorerSidebar));
if (firstUse) { if (firstUse) {
EventQueue.invokeLater(this::fitViewListAboveExplorer); EventQueue.invokeLater(this::fitViewListAboveExplorer);
} }
@@ -549,7 +545,12 @@ public final class MapWindow implements MapCanvas.Listener {
private void useSidebar(JComponent component) { private void useSidebar(JComponent component) {
sidebar.removeAll(); sidebar.removeAll();
sidebar.add(component, BorderLayout.CENTER); sidebar.add(StudioTheme.matchTheme(component), BorderLayout.CENTER);
}
private void useInspector(JComponent component) {
inspectorSlot.removeAll();
inspectorSlot.add(StudioTheme.matchTheme(component), BorderLayout.CENTER);
} }
private void showCard(String card) { private void showCard(String card) {
@@ -26,6 +26,8 @@ import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.configuration.IrisSettings; import art.arcane.iris.configuration.IrisSettings;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.Color; import java.awt.Color;
@@ -64,6 +66,7 @@ final class StudioTheme {
static final int OVERLAY_ARC = 10; static final int OVERLAY_ARC = 10;
private static final boolean DARK_WITHOUT_SYSTEM_PREFERENCE = true; private static final boolean DARK_WITHOUT_SYSTEM_PREFERENCE = true;
private static final String MATCHED_DARK_PROPERTY = "iris.studio.matchedDark";
private static final AtomicBoolean INSTALLED = new AtomicBoolean(); private static final AtomicBoolean INSTALLED = new AtomicBoolean();
private static final ExecutorService SYSTEM_CHECK = Executors.newSingleThreadExecutor(runnable -> { private static final ExecutorService SYSTEM_CHECK = Executors.newSingleThreadExecutor(runnable -> {
Thread thread = new Thread(runnable, "Iris Theme Check"); Thread thread = new Thread(runnable, "Iris Theme Check");
@@ -188,6 +191,19 @@ final class StudioTheme {
}; };
} }
/**
* A theme switch only reaches components inside a window, so a panel swapped out at the time keeps the old theme until
* this brings it up to date. Call it when putting a panel back on screen.
*/
static <T extends JComponent> T matchTheme(T component) {
if (Boolean.valueOf(dark).equals(component.getClientProperty(MATCHED_DARK_PROPERTY))) {
return component;
}
SwingUtilities.updateComponentTreeUI(component);
component.putClientProperty(MATCHED_DARK_PROPERTY, dark);
return component;
}
private static void switchTo(boolean nextDark) { private static void switchTo(boolean nextDark) {
if (nextDark == dark) { if (nextDark == dark) {
return; return;