implements PR-07e assets refactor cleanup and regression coverage
This commit is contained in:
parent
288178c44e
commit
4c8190cc31
@ -1,11 +0,0 @@
|
||||
package p.studio.events;
|
||||
|
||||
import p.studio.projects.ProjectReference;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record StudioAssetsDetailsRedrawRequestedEvent(ProjectReference project) implements StudioEvent {
|
||||
public StudioAssetsDetailsRedrawRequestedEvent {
|
||||
Objects.requireNonNull(project, "project");
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package p.studio.events;
|
||||
|
||||
import p.studio.projects.ProjectReference;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record StudioAssetsNavigatorRedrawRequestedEvent(ProjectReference project) implements StudioEvent {
|
||||
public StudioAssetsNavigatorRedrawRequestedEvent {
|
||||
Objects.requireNonNull(project, "project");
|
||||
}
|
||||
}
|
||||
@ -746,51 +746,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
|
||||
workspaceBus.publish(new StudioAssetsAssetSummaryPatchedEvent(projectReference, updatedSummary));
|
||||
}
|
||||
|
||||
private Node createStagedMutationPanel(AssetWorkspaceMutationPreview preview) {
|
||||
final VBox panel = new VBox(10);
|
||||
panel.getStyleClass().add("assets-mutation-panel");
|
||||
|
||||
final Label title = new Label(Container.i18n().format(I18n.ASSETS_MUTATION_PREVIEW_TITLE, actionLabel(preview.action())));
|
||||
title.getStyleClass().add("assets-mutation-panel-title");
|
||||
panel.getChildren().add(title);
|
||||
panel.getChildren().add(createMutationSection(
|
||||
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_AFFECTED_ASSET),
|
||||
createAffectedAssetContent(preview)));
|
||||
|
||||
final AssetWorkspaceMutationImpactViewModel impacts = AssetWorkspaceMutationImpactViewModel.from(preview);
|
||||
panel.getChildren().add(createMutationSection(
|
||||
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_REGISTRY_IMPACT),
|
||||
createMutationChangesContent(impacts.registryChanges(), Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_REGISTRY_IMPACT))));
|
||||
panel.getChildren().add(createMutationSection(
|
||||
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_WORKSPACE_IMPACT),
|
||||
createMutationChangesContent(impacts.workspaceChanges(), Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_WORKSPACE_IMPACT))));
|
||||
panel.getChildren().add(createMutationSection(
|
||||
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_BLOCKERS),
|
||||
createMutationMessages(preview.blockers(), "assets-mutation-message-blocker", Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_BLOCKERS))));
|
||||
panel.getChildren().add(createMutationSection(
|
||||
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_WARNINGS),
|
||||
createMutationMessages(preview.warnings(), "assets-mutation-message-warning", Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_WARNINGS))));
|
||||
panel.getChildren().add(createMutationSection(
|
||||
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_SAFE_FIXES),
|
||||
createMutationMessages(preview.safeFixes(), "assets-mutation-message-safe-fix", Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_SAFE_FIXES))));
|
||||
|
||||
final HBox actions = new HBox(8);
|
||||
final Button cancel = new Button(Container.i18n().text(I18n.ASSETS_MUTATION_CANCEL));
|
||||
cancel.getStyleClass().addAll("studio-button", "studio-button-cancel");
|
||||
cancel.setOnAction(event -> {
|
||||
stagedMutationPreview = null;
|
||||
requestDetailsRedraw();
|
||||
});
|
||||
final Button apply = new Button(Container.i18n().text(I18n.ASSETS_MUTATION_APPLY));
|
||||
apply.getStyleClass().addAll("studio-button", "studio-button-primary");
|
||||
apply.setDisable(!preview.canApply());
|
||||
apply.setOnAction(event -> applyStagedMutation(preview));
|
||||
actions.getChildren().addAll(cancel, apply);
|
||||
panel.getChildren().add(actions);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Node createMutationSection(String title, Node content) {
|
||||
final VBox section = new VBox(6);
|
||||
final Label label = new Label(title);
|
||||
@ -918,10 +873,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private boolean containsInput(AssetWorkspaceAssetDetails details, Path input) {
|
||||
return details.inputsByRole().values().stream().flatMap(List::stream).anyMatch(input::equals);
|
||||
}
|
||||
|
||||
static String readPreviewText(Path input) {
|
||||
try {
|
||||
final String text = Files.readString(input);
|
||||
@ -931,40 +882,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
|
||||
}
|
||||
}
|
||||
|
||||
private String extensionOf(Path input) {
|
||||
final String fileName = input.getFileName().toString();
|
||||
final int dot = fileName.lastIndexOf('.');
|
||||
if (dot < 0 || dot == fileName.length() - 1) {
|
||||
return "";
|
||||
}
|
||||
return fileName.substring(dot + 1).toLowerCase();
|
||||
}
|
||||
|
||||
private boolean isImage(String extension) {
|
||||
return extension.equals("png")
|
||||
|| extension.equals("jpg")
|
||||
|| extension.equals("jpeg")
|
||||
|| extension.equals("gif")
|
||||
|| extension.equals("bmp");
|
||||
}
|
||||
|
||||
private boolean isText(String extension) {
|
||||
return extension.equals("json")
|
||||
|| extension.equals("txt")
|
||||
|| extension.equals("pal")
|
||||
|| extension.equals("csv")
|
||||
|| extension.equals("yaml")
|
||||
|| extension.equals("yml")
|
||||
|| extension.equals("xml")
|
||||
|| extension.equals("pbs");
|
||||
}
|
||||
|
||||
private boolean isAudio(String extension) {
|
||||
return extension.equals("wav")
|
||||
|| extension.equals("ogg")
|
||||
|| extension.equals("mp3");
|
||||
}
|
||||
|
||||
private Node createSectionMessage(String text) {
|
||||
final Label label = new Label(text);
|
||||
label.setWrapText(true);
|
||||
@ -993,35 +910,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
|
||||
return value ? Container.i18n().text(I18n.ASSETS_VALUE_YES) : Container.i18n().text(I18n.ASSETS_VALUE_NO);
|
||||
}
|
||||
|
||||
private String assetRowToneClass(String assetFamily) {
|
||||
return "assets-workspace-asset-row-tone-" + assetFamilyTone(assetFamily);
|
||||
}
|
||||
|
||||
private String assetNameToneClass(String assetFamily) {
|
||||
return "assets-workspace-asset-name-tone-" + assetFamilyTone(assetFamily);
|
||||
}
|
||||
|
||||
private String assetFamilyTone(String assetFamily) {
|
||||
final String family = assetFamily == null ? "" : assetFamily.toLowerCase(Locale.ROOT);
|
||||
if (family.contains("image") || family.contains("sprite") || family.contains("tile")) {
|
||||
return "image";
|
||||
}
|
||||
if (family.contains("sound") || family.contains("audio") || family.contains("music")) {
|
||||
return "audio";
|
||||
}
|
||||
if (family.contains("palette") || family.contains("color")) {
|
||||
return "palette";
|
||||
}
|
||||
if (family.contains("font") || family.contains("text") || family.contains("script")) {
|
||||
return "text";
|
||||
}
|
||||
return "generic";
|
||||
}
|
||||
|
||||
private Path assetsRoot() {
|
||||
return projectReference.rootPath().resolve("assets").toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
private Path projectRoot() {
|
||||
return projectReference.rootPath().toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user