Studio and Packer RGBA8888 Asset Pipeline Alignment
Intrepid/Prometeu/Studio/pipeline/head Build started...
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.03% (17116/28043)
* Branch Coverage: 51.80% (6569/12681)
* Lines of Code: 28043
* Cyclomatic Complexity: 11219
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 16, passed: 580
Intrepid/Prometeu/Studio/pipeline/head Build started...
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.03% (17116/28043)
* Branch Coverage: 51.80% (6569/12681)
* Lines of Code: 28043
* Cyclomatic Complexity: 11219
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 16, passed: 580
This commit is contained in:
+28
-15
@@ -337,12 +337,12 @@ public final class AssetDetailsPaletteOverhaulingCoordinator {
|
||||
final List<Integer> argb = record.colors().stream()
|
||||
.map(AssetDetailsPaletteOverhaulingCoordinator::htmlToArgb8888)
|
||||
.toList();
|
||||
final List<Integer> rgb565 = record.colors().stream()
|
||||
.map(AssetDetailsPaletteOverhaulingCoordinator::htmlToRgb565)
|
||||
final List<Integer> rgba = record.colors().stream()
|
||||
.map(AssetDetailsPaletteOverhaulingCoordinator::htmlToRgba8888)
|
||||
.toList();
|
||||
final Map<String, Object> palette = Map.of(
|
||||
"originalArgb8888", argb,
|
||||
"convertedRgb565", rgb565);
|
||||
"rgba8888", rgba);
|
||||
final Map<String, Object> metadata = new LinkedHashMap<>();
|
||||
metadata.put("palette", palette);
|
||||
metadata.put("paletteId", record.paletteId());
|
||||
@@ -452,7 +452,7 @@ public final class AssetDetailsPaletteOverhaulingCoordinator {
|
||||
}
|
||||
|
||||
private static ColorSample toColorSample(String htmlColor) {
|
||||
final int rgb = Integer.parseInt(normalizeHtmlColor(htmlColor).substring(1), 16);
|
||||
final int rgb = Integer.parseInt(normalizeHtmlColor(htmlColor).substring(1, 7), 16);
|
||||
final double red = ((rgb >> 16) & 0xFF) / 255.0;
|
||||
final double green = ((rgb >> 8) & 0xFF) / 255.0;
|
||||
final double blue = (rgb & 0xFF) / 255.0;
|
||||
@@ -504,25 +504,38 @@ public final class AssetDetailsPaletteOverhaulingCoordinator {
|
||||
if (left == null || right == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(left.get("originalArgb8888"), right.get("originalArgb8888"))
|
||||
&& Objects.equals(left.get("convertedRgb565"), right.get("convertedRgb565"));
|
||||
final Object leftRgba = left.get("rgba8888");
|
||||
final Object rightRgba = right.get("rgba8888");
|
||||
if (leftRgba != null || rightRgba != null) {
|
||||
return Objects.equals(leftRgba, rightRgba);
|
||||
}
|
||||
return Objects.equals(left.get("originalArgb8888"), right.get("originalArgb8888"));
|
||||
}
|
||||
|
||||
private static int htmlToArgb8888(String htmlColor) {
|
||||
final int rgb = Integer.parseInt(normalizeHtmlColor(htmlColor).substring(1), 16);
|
||||
return 0xFF000000 | rgb;
|
||||
final String normalized = normalizeHtmlColor(htmlColor);
|
||||
final int rgb = Integer.parseInt(normalized.substring(1, 7), 16);
|
||||
final int alpha = normalized.length() == 9
|
||||
? Integer.parseInt(normalized.substring(7, 9), 16)
|
||||
: 0xFF;
|
||||
return (alpha << 24) | rgb;
|
||||
}
|
||||
|
||||
private static int htmlToRgb565(String htmlColor) {
|
||||
final int rgb = Integer.parseInt(normalizeHtmlColor(htmlColor).substring(1), 16);
|
||||
final int red = (rgb >> 16) & 0xFF;
|
||||
final int green = (rgb >> 8) & 0xFF;
|
||||
final int blue = rgb & 0xFF;
|
||||
return ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
|
||||
private static int htmlToRgba8888(String htmlColor) {
|
||||
final String normalized = normalizeHtmlColor(htmlColor);
|
||||
final int rgb = Integer.parseInt(normalized.substring(1, 7), 16);
|
||||
final int alpha = normalized.length() == 9
|
||||
? Integer.parseInt(normalized.substring(7, 9), 16)
|
||||
: 0xFF;
|
||||
return (rgb << 8) | alpha;
|
||||
}
|
||||
|
||||
private static String normalizeHtmlColor(String color) {
|
||||
return Objects.requireNonNull(color, "color").trim().toUpperCase();
|
||||
final String normalized = Objects.requireNonNull(color, "color").trim().toUpperCase();
|
||||
if (!normalized.matches("^#[0-9A-F]{6}([0-9A-F]{2})?$")) {
|
||||
throw new IllegalArgumentException("color must use #RRGGBB or #RRGGBBAA format");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
private static AssetWorkspaceBankCompositionFile fileByPath(List<AssetWorkspaceBankCompositionFile> files, String path) {
|
||||
|
||||
+11
-10
@@ -45,7 +45,7 @@ public final class AssetDetailsPaletteOverhaulingDualListView extends StudioDual
|
||||
final HBox strip = new HBox(0);
|
||||
strip.getStyleClass().add("assets-details-palette-strip");
|
||||
final List<Integer> colors = paletteDisplayColors(item.metadata());
|
||||
for (int index = 0; index < 15; index++) {
|
||||
for (int index = 0; index < 16; index++) {
|
||||
final Region swatch = new Region();
|
||||
swatch.getStyleClass().add("assets-details-palette-swatch");
|
||||
swatch.setMinSize(12.0d, 18.0d);
|
||||
@@ -63,10 +63,10 @@ public final class AssetDetailsPaletteOverhaulingDualListView extends StudioDual
|
||||
if (!(paletteValue instanceof Map<?, ?> palette)) {
|
||||
return List.of();
|
||||
}
|
||||
final Object convertedValue = palette.get("convertedRgb565");
|
||||
final Object convertedValue = palette.get("rgba8888");
|
||||
if (convertedValue instanceof List<?> converted) {
|
||||
return ((List<Integer>) converted).stream()
|
||||
.map(this::rgb565ToArgb8888)
|
||||
.map(this::rgba8888ToArgb8888)
|
||||
.toList();
|
||||
}
|
||||
return List.of();
|
||||
@@ -91,14 +91,15 @@ public final class AssetDetailsPaletteOverhaulingDualListView extends StudioDual
|
||||
return String.format("#%02X%02X%02X", red, green, blue);
|
||||
}
|
||||
|
||||
private int rgb565ToArgb8888(Integer rgb565) {
|
||||
if (rgb565 == null) {
|
||||
private int rgba8888ToArgb8888(Integer rgba8888) {
|
||||
if (rgba8888 == null) {
|
||||
return 0x00000000;
|
||||
}
|
||||
final int value = rgb565 & 0xFFFF;
|
||||
final int red = ((value >> 11) & 0x1F) * 255 / 31;
|
||||
final int green = ((value >> 5) & 0x3F) * 255 / 63;
|
||||
final int blue = (value & 0x1F) * 255 / 31;
|
||||
return 0xFF000000 | (red << 16) | (green << 8) | blue;
|
||||
final int value = rgba8888;
|
||||
final int red = (value >>> 24) & 0xFF;
|
||||
final int green = (value >>> 16) & 0xFF;
|
||||
final int blue = (value >>> 8) & 0xFF;
|
||||
final int alpha = value & 0xFF;
|
||||
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-17
@@ -88,7 +88,7 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
paletteStrip.setMinWidth(PREVIEW_FRAME_SIZE);
|
||||
paletteStrip.setPrefWidth(PREVIEW_FRAME_SIZE);
|
||||
paletteStrip.setMaxWidth(PREVIEW_FRAME_SIZE);
|
||||
for (int index = 0; index < 15; index++) {
|
||||
for (int index = 0; index < 16; index++) {
|
||||
final Region swatch = new Region();
|
||||
swatch.getStyleClass().add("assets-details-palette-preview-swatch");
|
||||
swatch.setMinSize(16.0d, 26.0d);
|
||||
@@ -199,10 +199,10 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
if (palette == null) {
|
||||
return List.of();
|
||||
}
|
||||
final Object converted = palette.get("convertedRgb565");
|
||||
final Object converted = palette.get("rgba8888");
|
||||
if (converted instanceof List<?> list) {
|
||||
return ((List<Integer>) list).stream()
|
||||
.map(this::rgb565ToArgb8888)
|
||||
.map(this::rgba8888ToArgb8888)
|
||||
.toList();
|
||||
}
|
||||
return List.of();
|
||||
@@ -214,6 +214,12 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
if (palette == null) {
|
||||
return List.of();
|
||||
}
|
||||
final Object rgba = palette.get("rgba8888");
|
||||
if (rgba instanceof List<?> list) {
|
||||
return ((List<Integer>) list).stream()
|
||||
.map(this::rgba8888ToArgb8888)
|
||||
.toList();
|
||||
}
|
||||
final Object original = palette.get("originalArgb8888");
|
||||
if (original instanceof List<?> list) {
|
||||
return (List<Integer>) list;
|
||||
@@ -229,7 +235,7 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
final Map<String, Integer> indicesByColor = new java.util.LinkedHashMap<>();
|
||||
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
||||
final Integer index = asInteger(entry.getKey());
|
||||
if (index == null || index <= 0 || !(entry.getValue() instanceof String color) || color.isBlank()) {
|
||||
if (index == null || index < 0 || !(entry.getValue() instanceof String color) || color.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
indicesByColor.put(color.trim().toUpperCase(), index);
|
||||
@@ -245,21 +251,20 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
}
|
||||
|
||||
private int paletteIndexToArgb(List<Integer> colors, int paletteIndex) {
|
||||
if (paletteIndex <= 0) {
|
||||
if (paletteIndex < 0) {
|
||||
return 0x00000000;
|
||||
}
|
||||
return colorAt(colors, paletteIndex - 1);
|
||||
return colorAt(colors, paletteIndex);
|
||||
}
|
||||
|
||||
private int schemaPaletteIndex(int tilePaletteIndex, List<Integer> sourceColors, Map<String, Integer> schemaIndicesByColor) {
|
||||
if (tilePaletteIndex <= 0 || sourceColors.isEmpty() || schemaIndicesByColor.isEmpty()) {
|
||||
if (tilePaletteIndex < 0 || sourceColors.isEmpty() || schemaIndicesByColor.isEmpty()) {
|
||||
return tilePaletteIndex;
|
||||
}
|
||||
final int sourceColorIndex = tilePaletteIndex - 1;
|
||||
if (sourceColorIndex < 0 || sourceColorIndex >= sourceColors.size()) {
|
||||
if (tilePaletteIndex >= sourceColors.size()) {
|
||||
return 0;
|
||||
}
|
||||
return schemaIndicesByColor.getOrDefault(cssColor(sourceColors.get(sourceColorIndex)), 0);
|
||||
return schemaIndicesByColor.getOrDefault(materialColorKey(sourceColors.get(tilePaletteIndex)), 0);
|
||||
}
|
||||
|
||||
private int colorAt(List<Integer> colors, int index) {
|
||||
@@ -281,6 +286,16 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
return String.format("#%02X%02X%02X", red, green, blue);
|
||||
}
|
||||
|
||||
private String materialColorKey(int argb) {
|
||||
final int alpha = (argb >>> 24) & 0xFF;
|
||||
final int red = (argb >>> 16) & 0xFF;
|
||||
final int green = (argb >>> 8) & 0xFF;
|
||||
final int blue = argb & 0xFF;
|
||||
return alpha == 0xFF
|
||||
? String.format("#%02X%02X%02X", red, green, blue)
|
||||
: String.format("#%02X%02X%02X%02X", red, green, blue, alpha);
|
||||
}
|
||||
|
||||
private javafx.scene.paint.Color toFxColor(int argb) {
|
||||
final int alpha = (argb >>> 24) & 0xFF;
|
||||
if (alpha == 0) {
|
||||
@@ -292,14 +307,15 @@ public final class AssetDetailsPaletteOverhaulingPreviewPane extends VBox {
|
||||
return javafx.scene.paint.Color.rgb(red, green, blue, alpha / 255.0d);
|
||||
}
|
||||
|
||||
private int rgb565ToArgb8888(Integer rgb565) {
|
||||
if (rgb565 == null) {
|
||||
private int rgba8888ToArgb8888(Integer rgba8888) {
|
||||
if (rgba8888 == null) {
|
||||
return 0x00000000;
|
||||
}
|
||||
final int value = rgb565 & 0xFFFF;
|
||||
final int red = ((value >> 11) & 0x1F) * 255 / 31;
|
||||
final int green = ((value >> 5) & 0x3F) * 255 / 63;
|
||||
final int blue = (value & 0x1F) * 255 / 31;
|
||||
return 0xFF000000 | (red << 16) | (green << 8) | blue;
|
||||
final int value = rgba8888;
|
||||
final int red = (value >>> 24) & 0xFF;
|
||||
final int green = (value >>> 16) & 0xFF;
|
||||
final int blue = (value >>> 8) & 0xFF;
|
||||
final int alpha = value & 0xFF;
|
||||
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ public final class AssetDetailsPaletteWizardDialog {
|
||||
editableStrip.getChildren().setAll(editableColors.stream().map(this::swatch).toList());
|
||||
nameField.setPromptText(AssetDetailsPaletteOverhaulingCoordinator.generatedDisplayName(editableColors));
|
||||
indexItems.setAll(java.util.stream.IntStream.range(0, editableColors.size())
|
||||
.mapToObj(index -> (index + 1) + " -> " + editableColors.get(index))
|
||||
.mapToObj(index -> index + " -> " + editableColors.get(index))
|
||||
.toList());
|
||||
final boolean duplicate = schema != null && coordinator.duplicatePaletteExists(paletteId, schema.schemaId(), editableColors);
|
||||
summaryLabel.setText(duplicate
|
||||
|
||||
+37
-13
@@ -164,7 +164,7 @@ public final class AssetDetailsColorSchemaCoordinator {
|
||||
List<String> orderedColors) {
|
||||
final Map<Integer, String> materialIndices = new LinkedHashMap<>();
|
||||
for (int index = 0; index < orderedColors.size(); index += 1) {
|
||||
materialIndices.put(index + 1, normalizeHtmlColor(orderedColors.get(index)));
|
||||
materialIndices.put(index, normalizeHtmlColor(orderedColors.get(index)));
|
||||
}
|
||||
final List<AssetStudioGlyphMaterialArtifactBinding> bindings = assignedTiles.stream()
|
||||
.map(file -> new AssetStudioGlyphMaterialArtifactBinding(artifactId(file), fingerprint(file)))
|
||||
@@ -217,20 +217,44 @@ public final class AssetDetailsColorSchemaCoordinator {
|
||||
if (palette == null) {
|
||||
return List.of();
|
||||
}
|
||||
final Object originalColors = palette.get("originalArgb8888");
|
||||
if (!(originalColors instanceof Iterable<?> iterable)) {
|
||||
return List.of();
|
||||
}
|
||||
final List<String> colors = new ArrayList<>();
|
||||
for (Object item : iterable) {
|
||||
if (!(item instanceof Number number)) {
|
||||
continue;
|
||||
final Object rgbaColors = palette.get("rgba8888");
|
||||
if (rgbaColors instanceof Iterable<?> rgbaIterable) {
|
||||
for (Object item : rgbaIterable) {
|
||||
if (!(item instanceof Number number)) {
|
||||
continue;
|
||||
}
|
||||
final int value = number.intValue();
|
||||
final int alpha = value & 0xFF;
|
||||
colors.add(alpha == 0xFF
|
||||
? String.format(
|
||||
"#%02X%02X%02X",
|
||||
(value >>> 24) & 0xFF,
|
||||
(value >>> 16) & 0xFF,
|
||||
(value >>> 8) & 0xFF)
|
||||
: String.format(
|
||||
"#%02X%02X%02X%02X",
|
||||
(value >>> 24) & 0xFF,
|
||||
(value >>> 16) & 0xFF,
|
||||
(value >>> 8) & 0xFF,
|
||||
alpha));
|
||||
}
|
||||
if (!colors.isEmpty()) {
|
||||
return List.copyOf(colors);
|
||||
}
|
||||
}
|
||||
final Object originalColors = palette.get("originalArgb8888");
|
||||
if (originalColors instanceof Iterable<?> argbIterable) {
|
||||
for (Object item : argbIterable) {
|
||||
if (!(item instanceof Number number)) {
|
||||
continue;
|
||||
}
|
||||
colors.add(String.format(
|
||||
"#%02X%02X%02X",
|
||||
(number.intValue() >> 16) & 0xFF,
|
||||
(number.intValue() >> 8) & 0xFF,
|
||||
number.intValue() & 0xFF));
|
||||
}
|
||||
colors.add(String.format(
|
||||
"#%02X%02X%02X",
|
||||
(number.intValue() >> 16) & 0xFF,
|
||||
(number.intValue() >> 8) & 0xFF,
|
||||
number.intValue() & 0xFF));
|
||||
}
|
||||
return List.copyOf(colors);
|
||||
}
|
||||
|
||||
+2
-2
@@ -193,7 +193,7 @@ public final class AssetDetailsColorSchemaGroupsControl extends StudioFormSectio
|
||||
workspaceBus.publish(new StudioAssetLogEvent("color-schema-groups", "Apply failed: schema must contain at least one tile."));
|
||||
return;
|
||||
}
|
||||
if (orderedColors.size() > 15) {
|
||||
if (orderedColors.size() > 16) {
|
||||
workspaceBus.publish(new StudioAssetLogEvent(
|
||||
"color-schema-groups",
|
||||
Container.i18n().text(I18n.ASSETS_COLOR_SCHEMA_DIALOG_TOO_MANY_COLORS)));
|
||||
@@ -326,7 +326,7 @@ public final class AssetDetailsColorSchemaGroupsControl extends StudioFormSectio
|
||||
final List<String> orderedColors = draft.orderedColors();
|
||||
schemaTitleLabel.setText(draft.schemaId() + (draft.existingSchema() ? "" : " (new)"));
|
||||
paletteCounterLabel.setText(Container.i18n().format(I18n.ASSETS_COLOR_SCHEMA_DIALOG_COLOR_COUNT, orderedColors.size()));
|
||||
warningLabel.setText(orderedColors.size() > 15
|
||||
warningLabel.setText(orderedColors.size() > 16
|
||||
? Container.i18n().text(I18n.ASSETS_COLOR_SCHEMA_DIALOG_TOO_MANY_COLORS)
|
||||
: "");
|
||||
paletteStrip.getChildren().setAll(orderedColors.stream().map(this::swatch).toList());
|
||||
|
||||
+12
-9
@@ -31,23 +31,26 @@ public record AssetStudioGlyphMaterialPalette(
|
||||
colors = List.copyOf(Objects.requireNonNull(colors, "colors"));
|
||||
}
|
||||
|
||||
public List<Integer> convertedRgb565Colors() {
|
||||
public List<Integer> convertedRgba8888Colors() {
|
||||
final List<Integer> converted = new ArrayList<>(colors.size());
|
||||
for (String color : colors) {
|
||||
converted.add(convertHtmlRgbToRgb565(color));
|
||||
converted.add(convertHtmlRgbToRgba8888(color));
|
||||
}
|
||||
return List.copyOf(converted);
|
||||
}
|
||||
|
||||
static int convertHtmlRgbToRgb565(String htmlRgb) {
|
||||
static int convertHtmlRgbToRgba8888(String htmlRgb) {
|
||||
final String value = Objects.requireNonNull(htmlRgb, "htmlRgb").trim();
|
||||
if (!value.matches("^#[0-9A-Fa-f]{6}$")) {
|
||||
throw new IllegalArgumentException("htmlRgb must use #RRGGBB format");
|
||||
|
||||
if (!value.matches("^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$")) {
|
||||
throw new IllegalArgumentException("htmlRgb must use #RRGGBB or #RRGGBBAA format");
|
||||
}
|
||||
|
||||
final int rgb = Integer.parseInt(value.substring(1), 16);
|
||||
final int red = (rgb >> 16) & 0xFF;
|
||||
final int green = (rgb >> 8) & 0xFF;
|
||||
final int blue = rgb & 0xFF;
|
||||
return ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
|
||||
if (value.length() == 9) {
|
||||
return rgb;
|
||||
}
|
||||
|
||||
return (rgb << 8) | 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -242,7 +242,7 @@ public final class AssetStudioMetadataService {
|
||||
try {
|
||||
final int index = Integer.parseInt(entry.getKey());
|
||||
final String color = normalizeHtmlColor(entry.getValue().asText(null));
|
||||
if (index >= 1 && index <= 15 && color != null) {
|
||||
if (index >= 0 && index <= 15 && color != null) {
|
||||
materialIndices.put(index, color);
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
@@ -302,7 +302,7 @@ public final class AssetStudioMetadataService {
|
||||
if (indices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int expected = 1;
|
||||
int expected = 0;
|
||||
for (Integer index : new java.util.TreeSet<>(indices)) {
|
||||
if (index == null || index != expected) {
|
||||
return false;
|
||||
@@ -317,7 +317,7 @@ public final class AssetStudioMetadataService {
|
||||
return null;
|
||||
}
|
||||
final String normalized = value.trim().toUpperCase();
|
||||
return normalized.matches("^#[0-9A-F]{6}$") ? normalized : null;
|
||||
return normalized.matches("^#[0-9A-F]{6}([0-9A-F]{2})?$") ? normalized : null;
|
||||
}
|
||||
|
||||
private AssetStudioSceneBankMetadata defaultSceneBankMetadata(Path supportFile) {
|
||||
|
||||
@@ -250,7 +250,7 @@ assets.colorSchema.removeBlocked=Schema {0} cannot be removed while palettes sti
|
||||
assets.colorSchema.dialog.availableTiles=Available Tiles
|
||||
assets.colorSchema.dialog.assignedTiles=Assigned Tiles
|
||||
assets.colorSchema.dialog.colorCount=Color count: {0}
|
||||
assets.colorSchema.dialog.tooManyColors=Color Schema Groups support at most 15 visible indices.
|
||||
assets.colorSchema.dialog.tooManyColors=Color Schema Groups support at most 16 visible indices.
|
||||
assets.details.codecConfiguration.empty=This codec does not expose configuration fields yet.
|
||||
assets.details.metadata.empty=This asset does not expose metadata fields yet.
|
||||
assets.addWizard.title=Add Asset
|
||||
|
||||
+5
-5
@@ -37,7 +37,7 @@ final class AssetDetailsPaletteOverhaulingCoordinatorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void initialSelectionStillMatchesBuildFacingPipelinePalettePayload() {
|
||||
void initialSelectionMatchesPersistedPackerPipelinePalettePayload() {
|
||||
final AssetDetailsPaletteOverhaulingCoordinator coordinator = new AssetDetailsPaletteOverhaulingCoordinator();
|
||||
final AssetStudioGlyphMaterialPalette persisted = new AssetStudioGlyphMaterialPalette(
|
||||
"palette-1",
|
||||
@@ -56,8 +56,8 @@ final class AssetDetailsPaletteOverhaulingCoordinatorTest {
|
||||
List.of(persisted),
|
||||
null),
|
||||
List.of(Map.of(
|
||||
"originalArgb8888", List.of(0xFFFF0000, 0xFF00FF00),
|
||||
"convertedRgb565", List.of(0xF800, 0x07E0)))));
|
||||
"index", 0,
|
||||
"rgba8888", List.of(0xFF0000FF, 0x00FF00FF)))));
|
||||
|
||||
assertEquals(1, coordinator.viewModel().selectedFiles().size());
|
||||
assertEquals("palette-1", coordinator.viewModel().selectedFiles().getFirst().metadata().get("paletteId"));
|
||||
@@ -283,7 +283,7 @@ final class AssetDetailsPaletteOverhaulingCoordinatorTest {
|
||||
null),
|
||||
List.of(Map.of(
|
||||
"originalArgb8888", List.of(0xFF112233, 0xFF445566),
|
||||
"convertedRgb565", List.of(0x1106, 0x42AC)))));
|
||||
"rgba8888", List.of(0x112233FF, 0x445566FF)))));
|
||||
|
||||
final AssetStudioGlyphMaterialMetadata metadata = coordinator.removePalette("palette-1");
|
||||
|
||||
@@ -440,6 +440,6 @@ final class AssetDetailsPaletteOverhaulingCoordinatorTest {
|
||||
"paletteIndices", List.of(0, 1, 2, 0)),
|
||||
"palette", Map.of(
|
||||
"originalArgb8888", List.of(0xFFFF0000, 0xFF00FF00),
|
||||
"convertedRgb565", List.of(0xF800, 0x07E0))));
|
||||
"rgba8888", List.of(0xFF0000FF, 0x00FF00FF))));
|
||||
}
|
||||
}
|
||||
|
||||
+18
-2
@@ -47,6 +47,22 @@ final class AssetDetailsColorSchemaCoordinatorTest {
|
||||
assertEquals(List.of(), AssetDetailsColorSchemaCoordinator.tileColors(tile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void tileColorsPreserveRgbaAlphaWhenAvailable() {
|
||||
final AssetWorkspaceBankCompositionFile tile = new AssetWorkspaceBankCompositionFile(
|
||||
"a.png",
|
||||
"a.png",
|
||||
64L,
|
||||
1L,
|
||||
"fp-a",
|
||||
Map.of(
|
||||
"artifactId", "artifact-a",
|
||||
"tile", Map.of("width", 8, "height", 8, "paletteIndices", List.of(0, 1)),
|
||||
"palette", Map.of("rgba8888", List.of(0x00000000, 0xFF0000FF))));
|
||||
|
||||
assertEquals(List.of("#00000000", "#FF0000"), AssetDetailsColorSchemaCoordinator.tileColors(tile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createFlowUsesSelectedFingerprintWhenCurrentFileFingerprintIsMissing() {
|
||||
final AssetDetailsColorSchemaCoordinator coordinator = new AssetDetailsColorSchemaCoordinator();
|
||||
@@ -95,7 +111,7 @@ final class AssetDetailsColorSchemaCoordinatorTest {
|
||||
|
||||
final AssetStudioGlyphMaterialSchema schema = updated.schemas().getFirst();
|
||||
assertEquals(2, schema.version());
|
||||
assertEquals(Map.of(1, "#FF0000", 2, "#00FF00"), schema.materialIndices());
|
||||
assertEquals(Map.of(0, "#FF0000", 1, "#00FF00"), schema.materialIndices());
|
||||
assertEquals(List.of("artifact-a", "artifact-b"), schema.artifactBindings().stream().map(AssetStudioGlyphMaterialArtifactBinding::artifactId).toList());
|
||||
}
|
||||
|
||||
@@ -204,7 +220,7 @@ final class AssetDetailsColorSchemaCoordinatorTest {
|
||||
Map.of(
|
||||
"artifactId", artifactId,
|
||||
"tile", Map.of("width", 8, "height", 8, "paletteIndices", List.of(1, 1, 1)),
|
||||
"palette", Map.of("originalArgb8888", argb, "convertedRgb565", List.of())));
|
||||
"palette", Map.of("originalArgb8888", argb, "rgba8888", List.of())));
|
||||
}
|
||||
|
||||
private AssetWorkspaceBankCompositionFile selectedArtifactOnly(String path, String artifactId, String fingerprint) {
|
||||
|
||||
+8
-8
@@ -51,7 +51,7 @@ final class AssetStudioMetadataServiceTest {
|
||||
"schema-1",
|
||||
AssetStudioGlyphMaterialSchemaStatus.OK,
|
||||
2,
|
||||
Map.of(1, "#8B4513", 2, "#00AA00"),
|
||||
Map.of(0, "#8B4513", 1, "#00AA0000"),
|
||||
List.of(
|
||||
new AssetStudioGlyphMaterialArtifactBinding("artifact-1", "fp-1"),
|
||||
new AssetStudioGlyphMaterialArtifactBinding("artifact-2", "fp-2")))),
|
||||
@@ -60,7 +60,7 @@ final class AssetStudioMetadataServiceTest {
|
||||
"Forest",
|
||||
"schema-1",
|
||||
2,
|
||||
List.of("#8B4513", "#00AA00"))),
|
||||
List.of("#8B4513", "#00AA0000"))),
|
||||
null);
|
||||
service.writeGlyphMaterialMetadata(assetRoot, metadata);
|
||||
|
||||
@@ -69,22 +69,22 @@ final class AssetStudioMetadataServiceTest {
|
||||
assertNotNull(snapshot.glyphMaterialMetadata());
|
||||
assertEquals(1, snapshot.glyphMaterialMetadata().schemas().size());
|
||||
assertEquals("schema-1", snapshot.glyphMaterialMetadata().schemas().getFirst().schemaId());
|
||||
assertEquals("#8B4513", snapshot.glyphMaterialMetadata().schemas().getFirst().materialIndices().get(1));
|
||||
assertEquals("#8B4513", snapshot.glyphMaterialMetadata().schemas().getFirst().materialIndices().get(0));
|
||||
assertEquals(1, snapshot.glyphMaterialMetadata().palettes().size());
|
||||
assertEquals("Forest", snapshot.glyphMaterialMetadata().palettes().getFirst().displayName());
|
||||
assertEquals(List.of("#8B4513", "#00AA00"), snapshot.glyphMaterialMetadata().palettes().getFirst().colors());
|
||||
assertEquals(List.of("#8B4513", "#00AA0000"), snapshot.glyphMaterialMetadata().palettes().getFirst().colors());
|
||||
}
|
||||
|
||||
@Test
|
||||
void keepsHtmlRgbAsCanonicalGlyphMaterialColorAndDerivesRgb565() {
|
||||
void keepsHtmlRgbAsCanonicalGlyphMaterialColorAndDerivesRgba8888() {
|
||||
final AssetStudioGlyphMaterialPalette palette = new AssetStudioGlyphMaterialPalette(
|
||||
"palette-1",
|
||||
"schema-1",
|
||||
1,
|
||||
List.of("#FF0000", "#00FF00", "#0000FF"));
|
||||
List.of("#FF0000", "#00FF00", "#0000FF", "#00000000"));
|
||||
|
||||
assertEquals(List.of("#FF0000", "#00FF00", "#0000FF"), palette.colors());
|
||||
assertEquals(List.of(0xF800, 0x07E0, 0x001F), palette.convertedRgb565Colors());
|
||||
assertEquals(List.of("#FF0000", "#00FF00", "#0000FF", "#00000000"), palette.colors());
|
||||
assertEquals(List.of(0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0x00000000), palette.convertedRgba8888Colors());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user