From 21bf8ea8c03928f92ef7f1cb84589708304eb83c Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Thu, 23 Nov 2023 19:51:22 +0100 Subject: [PATCH] Texture Viewer: Show "face" instead of "slice" for cubemaps --- .../data/viewer/texture/TextureViewerPanel.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/decima-ext-texture-viewer/src/main/java/com/shade/decima/ui/data/viewer/texture/TextureViewerPanel.java b/modules/decima-ext-texture-viewer/src/main/java/com/shade/decima/ui/data/viewer/texture/TextureViewerPanel.java index 3e893af4..ecf388c4 100644 --- a/modules/decima-ext-texture-viewer/src/main/java/com/shade/decima/ui/data/viewer/texture/TextureViewerPanel.java +++ b/modules/decima-ext-texture-viewer/src/main/java/com/shade/decima/ui/data/viewer/texture/TextureViewerPanel.java @@ -35,6 +35,8 @@ public class TextureViewerPanel extends JComponent implements PropertyChangeList public static final float ZOOM_MAX_LEVEL = (float) Math.pow(2, 7); public static final float RANGE_PRECISION = 1e3f; + private static final String[] CUBEMAP_FACE_NAMES = {"X+", "X-", "Y+", "Y-", "Z+", "Z-"}; + protected final ImagePanelViewport imageViewport; protected final ImagePanel imagePanel; protected final JLabel statusLabel; @@ -70,7 +72,7 @@ protected void customizeCellRenderer(@NotNull JList list, @No if (provider != null) { final int width = Math.max(provider.getMaxWidth() >> value, 1); final int height = Math.max(provider.getMaxHeight() >> value, 1); - append("%dx%d".formatted(width, height), TextAttributes.REGULAR_ATTRIBUTES); + append("%d - %dx%d".formatted(value, width, height), TextAttributes.REGULAR_ATTRIBUTES); } else { append("?", TextAttributes.REGULAR_ATTRIBUTES); } @@ -82,12 +84,14 @@ protected void customizeCellRenderer(@NotNull JList list, @No sliceCombo.setRenderer(new ColoredListCellRenderer<>() { @Override protected void customizeCellRenderer(@NotNull JList list, @NotNull Integer value, int index, boolean selected, boolean focused) { - append("Slice: ", TextAttributes.GRAYED_SMALL_ATTRIBUTES); - - if (imagePanel.getProvider() != null) { - append(String.valueOf(value), TextAttributes.REGULAR_ATTRIBUTES); + if (imagePanel.getProvider() == null) { + append("Slice: ?", TextAttributes.REGULAR_ATTRIBUTES); + } else if (imagePanel.getProvider().getType() == ImageProvider.Type.CUBEMAP) { + append("Face: ", TextAttributes.GRAYED_SMALL_ATTRIBUTES); + append(CUBEMAP_FACE_NAMES[value], TextAttributes.REGULAR_ATTRIBUTES); } else { - append("?", TextAttributes.REGULAR_ATTRIBUTES); + append("Slice: ", TextAttributes.GRAYED_SMALL_ATTRIBUTES); + append(String.valueOf(value), TextAttributes.REGULAR_ATTRIBUTES); } } });