From 92a1ffd73593a058dc39596fa631ef9aa31b95f1 Mon Sep 17 00:00:00 2001 From: bQUARKz Date: Thu, 19 Mar 2026 12:07:25 +0000 Subject: [PATCH] asset details (WIP) --- .../controls/banks/StudioDualListView.java | 18 +- ...setDetailsBankCompositionDualListView.java | 95 +++++++++ .../resources/themes/default-prometeu.css | 39 ++++ test-projects/main/.studio/activities.json | 200 +++++++++--------- 4 files changed, 251 insertions(+), 101 deletions(-) diff --git a/prometeu-studio/src/main/java/p/studio/controls/banks/StudioDualListView.java b/prometeu-studio/src/main/java/p/studio/controls/banks/StudioDualListView.java index 3df740c8..7160997b 100644 --- a/prometeu-studio/src/main/java/p/studio/controls/banks/StudioDualListView.java +++ b/prometeu-studio/src/main/java/p/studio/controls/banks/StudioDualListView.java @@ -176,11 +176,17 @@ public abstract class StudioDualListView extends HBox { setGraphic(null); return; } + final Node graphic = itemGraphic(item); + if (graphic != null) { + setText(null); + setGraphic(indexed ? createIndexedGraphic(graphic, getIndex()) : graphic); + return; + } final String text = indexed ? (getIndex() + 1) + ". " + itemText(item) : itemText(item); setText(text); - setGraphic(itemGraphic(item)); + setGraphic(null); } }; } @@ -215,4 +221,14 @@ public abstract class StudioDualListView extends HBox { listView.scrollTo(focusedIndex); } } + + private Node createIndexedGraphic(Node graphic, int index) { + final Label chip = new Label((index + 1) + "."); + chip.getStyleClass().add("studio-dual-list-index-chip"); + final HBox wrapper = new HBox(8, chip, graphic); + wrapper.getStyleClass().add("studio-dual-list-indexed-cell"); + wrapper.setAlignment(Pos.CENTER_LEFT); + HBox.setHgrow(graphic, Priority.ALWAYS); + return wrapper; + } } diff --git a/prometeu-studio/src/main/java/p/studio/workspaces/assets/details/bank/AssetDetailsBankCompositionDualListView.java b/prometeu-studio/src/main/java/p/studio/workspaces/assets/details/bank/AssetDetailsBankCompositionDualListView.java index ee0eb61e..7bff6fb1 100644 --- a/prometeu-studio/src/main/java/p/studio/workspaces/assets/details/bank/AssetDetailsBankCompositionDualListView.java +++ b/prometeu-studio/src/main/java/p/studio/workspaces/assets/details/bank/AssetDetailsBankCompositionDualListView.java @@ -1,10 +1,20 @@ package p.studio.workspaces.assets.details.bank; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; import p.studio.controls.banks.StudioDualListView; import p.studio.Container; import p.studio.utilities.i18n.I18n; import p.studio.workspaces.assets.messages.AssetWorkspaceBankCompositionFile; +import java.util.Collection; +import java.util.Map; + public final class AssetDetailsBankCompositionDualListView extends StudioDualListView { public AssetDetailsBankCompositionDualListView() { setLeftTitle(Container.i18n().text(I18n.ASSETS_DETAILS_BANK_COMPOSITION_AVAILABLE)); @@ -18,4 +28,89 @@ public final class AssetDetailsBankCompositionDualListView extends StudioDualLis } return item.displayName() + " [" + item.path() + "]"; } + + @Override + protected Node itemGraphic(AssetWorkspaceBankCompositionFile item) { + final String dimensions = tileDimensions(item.metadata()); + final String colors = tileColorCount(item.metadata()); + if (dimensions == null && colors == null) { + return null; + } + + final Label nameLabel = new Label(item.displayName()); + nameLabel.getStyleClass().add("assets-details-bank-file-name"); + nameLabel.setWrapText(true); + nameLabel.setMaxWidth(Double.MAX_VALUE); + + final Region spacer = new Region(); + HBox.setHgrow(spacer, Priority.ALWAYS); + + final VBox metaColumn = new VBox(2); + metaColumn.setAlignment(Pos.CENTER_RIGHT); + metaColumn.getStyleClass().add("assets-details-bank-file-meta"); + + if (dimensions != null) { + final Label dimensionsLabel = new Label(dimensions); + dimensionsLabel.getStyleClass().add("assets-details-bank-file-dimensions"); + metaColumn.getChildren().add(dimensionsLabel); + } + if (colors != null) { + final Label colorsLabel = new Label(colors); + colorsLabel.getStyleClass().add("assets-details-bank-file-colors"); + metaColumn.getChildren().add(colorsLabel); + } + + final HBox root = new HBox(10, nameLabel, spacer, metaColumn); + root.setAlignment(Pos.CENTER_LEFT); + root.getStyleClass().add("assets-details-bank-file-cell"); + return root; + } + + private String tileDimensions(Map metadata) { + final Map tile = nestedMap(metadata, "tile"); + if (tile == null) { + return null; + } + final Integer width = asInteger(tile.get("width")); + final Integer height = asInteger(tile.get("height")); + if (width == null || height == null) { + return null; + } + return width + "x" + height; + } + + private String tileColorCount(Map metadata) { + final Map palette = nestedMap(metadata, "palette"); + if (palette == null) { + return null; + } + final Object originalArgb8888 = palette.get("originalArgb8888"); + if (originalArgb8888 instanceof Collection colors) { + return colors.size() + " colors"; + } + return null; + } + + @SuppressWarnings("unchecked") + private Map nestedMap(Map metadata, String key) { + final Object value = metadata.get(key); + if (value instanceof Map nested) { + return (Map) nested; + } + return null; + } + + private Integer asInteger(Object value) { + if (value instanceof Number number) { + return number.intValue(); + } + if (value instanceof String text) { + try { + return Integer.parseInt(text); + } catch (NumberFormatException ignored) { + return null; + } + } + return null; + } } diff --git a/prometeu-studio/src/main/resources/themes/default-prometeu.css b/prometeu-studio/src/main/resources/themes/default-prometeu.css index 34abe39d..b1195ccc 100644 --- a/prometeu-studio/src/main/resources/themes/default-prometeu.css +++ b/prometeu-studio/src/main/resources/themes/default-prometeu.css @@ -697,6 +697,30 @@ -fx-alignment: top-left; } +.assets-details-bank-file-cell { + -fx-alignment: center-left; +} + +.assets-details-bank-file-name { + -fx-text-fill: #eef4fb; + -fx-font-size: 12px; +} + +.assets-details-bank-file-meta { + -fx-alignment: center-right; +} + +.assets-details-bank-file-dimensions { + -fx-text-fill: #b7d8f6; + -fx-font-size: 11px; + -fx-font-weight: bold; +} + +.assets-details-bank-file-colors { + -fx-text-fill: #8fa5bc; + -fx-font-size: 10px; +} + .assets-details-contract-column { -fx-spacing: 8; -fx-min-width: 0; @@ -901,6 +925,21 @@ -fx-min-height: 0; } +.studio-dual-list-indexed-cell { + -fx-alignment: center-left; +} + +.studio-dual-list-index-chip { + -fx-background-color: #172331; + -fx-border-color: #35516c; + -fx-background-radius: 999; + -fx-border-radius: 999; + -fx-text-fill: #eef7ff; + -fx-font-size: 10px; + -fx-font-weight: bold; + -fx-padding: 2 7 2 7; +} + .studio-asset-capacity-meter-track { -fx-background-color: #10161d; -fx-background-radius: 0; diff --git a/test-projects/main/.studio/activities.json b/test-projects/main/.studio/activities.json index 4aa8db4e..5b3435ca 100644 --- a/test-projects/main/.studio/activities.json +++ b/test-projects/main/.studio/activities.json @@ -1158,6 +1158,106 @@ "message" : "Asset scan diagnostics updated.", "severity" : "INFO", "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: bla", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: one-more-atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: ui_atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: one-more-atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: bbb2", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: ui_atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: Bigode", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Asset scan started", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "7 assets loaded", + "severity" : "SUCCESS", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Asset scan diagnostics updated.", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: bla", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: one-more-atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: ui_atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: one-more-atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: bbb2", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: ui_atlas", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Discovered asset: Bigode", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Asset scan started", + "severity" : "INFO", + "sticky" : false +}, { + "source" : "Assets", + "message" : "7 assets loaded", + "severity" : "SUCCESS", + "sticky" : false +}, { + "source" : "Assets", + "message" : "Asset scan diagnostics updated.", + "severity" : "INFO", + "sticky" : false }, { "source" : "Assets", "message" : "Discovered asset: sound", @@ -2398,104 +2498,4 @@ "message" : "Asset scan started", "severity" : "INFO", "sticky" : false -}, { - "source" : "Assets", - "message" : "7 assets loaded", - "severity" : "SUCCESS", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Asset scan diagnostics updated.", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: bla", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: one-more-atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: ui_atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: one-more-atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: bbb2", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: ui_atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: Bigode", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Asset scan started", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "7 assets loaded", - "severity" : "SUCCESS", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Asset scan diagnostics updated.", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: bla", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: one-more-atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: ui_atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: one-more-atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: bbb2", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: ui_atlas", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Discovered asset: Bigode", - "severity" : "INFO", - "sticky" : false -}, { - "source" : "Assets", - "message" : "Asset scan started", - "severity" : "INFO", - "sticky" : false } ] \ No newline at end of file