asset details (WIP)
This commit is contained in:
+2
-2
@@ -29,7 +29,7 @@ public abstract class PackerAbstractBankWalker<R> {
|
||||
}
|
||||
|
||||
protected abstract Set<String> getSupportedMimeTypes();
|
||||
protected abstract PackerProbeResult processFileProbe(PackerFileProbe fileProbe, R requirements);
|
||||
protected abstract PackerProbeResult processFileProbe(PackerFileProbe fileProbe, Path assetRoot, R requirements);
|
||||
|
||||
private Optional<PackerFileProbe> getFileProbeIfSupported(
|
||||
final Path filePath,
|
||||
@@ -79,7 +79,7 @@ public abstract class PackerAbstractBankWalker<R> {
|
||||
cachedEntry.get().diagnostics()));
|
||||
continue;
|
||||
}
|
||||
probeResults.add(processFileProbe(fileProbe, requirements));
|
||||
probeResults.add(processFileProbe(fileProbe, assetRoot, requirements));
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
diagnostics.add(new PackerDiagnostic(
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ public class PackerSoundBankWalker extends PackerAbstractBankWalker<PackerSoundB
|
||||
@Override
|
||||
protected PackerProbeResult processFileProbe(
|
||||
final PackerFileProbe fileProbe,
|
||||
final java.nio.file.Path assetRoot,
|
||||
final PackerSoundBankRequirements requirements) {
|
||||
final List<PackerDiagnostic> diagnostics = new ArrayList<>();
|
||||
return new PackerProbeResult(fileProbe, Map.of(), diagnostics);
|
||||
|
||||
+27
-7
@@ -31,6 +31,7 @@ public class PackerTileBankWalker extends PackerAbstractBankWalker<PackerTileBan
|
||||
@Override
|
||||
protected PackerProbeResult processFileProbe(
|
||||
final PackerFileProbe fileProbe,
|
||||
final Path assetRoot,
|
||||
final PackerTileBankRequirements requirements) {
|
||||
final List<PackerDiagnostic> diagnostics = new ArrayList<>();
|
||||
|
||||
@@ -123,16 +124,20 @@ public class PackerTileBankWalker extends PackerAbstractBankWalker<PackerTileBan
|
||||
|
||||
final var tile = new PackerTileIndexedV1(image.getWidth(), image.getHeight(), paletteIndices);
|
||||
final var palette = buildPalette(paletteIndexByRgb);
|
||||
serializeProbeArtifacts(fileProbe, tile, palette, diagnostics);
|
||||
// Disabled for now: derived tile/palette JSON artifacts are not emitted during normal walks.
|
||||
// If we want filesystem-side debug artifacts again, uncomment the call below.
|
||||
// serializeProbeArtifacts(fileProbe, assetRoot, tile, palette, diagnostics);
|
||||
return new PackerProbeResult(fileProbe, Map.of("tile", tile, "palette", palette), diagnostics);
|
||||
}
|
||||
|
||||
/*
|
||||
private void serializeProbeArtifacts(
|
||||
final PackerFileProbe fileProbe,
|
||||
final Path assetRoot,
|
||||
final PackerTileIndexedV1 tile,
|
||||
final PackerPaletteV1 palette,
|
||||
final List<PackerDiagnostic> diagnostics) {
|
||||
final Path basePath = baseOutputPath(fileProbe.path());
|
||||
final Path basePath = baseOutputPath(assetRoot, fileProbe.path());
|
||||
final Path tileOutputPath = Path.of(basePath + ".tile.json");
|
||||
final Path paletteOutputPath = Path.of(basePath + ".palette.json");
|
||||
|
||||
@@ -152,17 +157,32 @@ public class PackerTileBankWalker extends PackerAbstractBankWalker<PackerTileBan
|
||||
}
|
||||
}
|
||||
|
||||
private Path baseOutputPath(final Path sourcePath) {
|
||||
private Path baseOutputPath(final Path assetRoot, final Path sourcePath) {
|
||||
final Path assetsRoot = assetsRoot(assetRoot);
|
||||
final Path relativeSourcePath = assetsRoot.relativize(sourcePath.toAbsolutePath().normalize());
|
||||
final String fileName = sourcePath.getFileName().toString();
|
||||
final int extensionStart = fileName.lastIndexOf('.');
|
||||
final String outputBaseName = extensionStart > 0 ? fileName.substring(0, extensionStart) : fileName;
|
||||
final Path parent = sourcePath.getParent();
|
||||
if (parent == null) {
|
||||
return Path.of(outputBaseName);
|
||||
final Path relativeParent = relativeSourcePath.getParent();
|
||||
final Path outputRoot = assetsRoot.resolve(".prometeu");
|
||||
if (relativeParent == null) {
|
||||
return outputRoot.resolve(outputBaseName);
|
||||
}
|
||||
return parent.resolve(outputBaseName);
|
||||
return outputRoot.resolve(relativeParent).resolve(outputBaseName);
|
||||
}
|
||||
|
||||
private Path assetsRoot(final Path assetRoot) {
|
||||
Path current = assetRoot.toAbsolutePath().normalize();
|
||||
while (current != null && current.getFileName() != null) {
|
||||
if ("assets".equals(current.getFileName().toString())) {
|
||||
return current;
|
||||
}
|
||||
current = current.getParent();
|
||||
}
|
||||
throw new IllegalStateException("Unable to resolve assets root for tile artifact output: " + assetRoot);
|
||||
}
|
||||
*/
|
||||
|
||||
private Map<String, Object> toTilePayload(final PackerTileIndexedV1 tile) {
|
||||
final List<Integer> indices = new ArrayList<>(tile.paletteIndices().length);
|
||||
for (final byte value : tile.paletteIndices()) {
|
||||
|
||||
Reference in New Issue
Block a user