complete Studio core and JavaFX boundary migration
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 64.01% (20482/31999)
* Branch Coverage: 54.22% (8240/15196)
* Lines of Code: 31999
* Cyclomatic Complexity: 13164
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 715
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 64.01% (20482/31999)
* Branch Coverage: 54.22% (8240/15196)
* Lines of Code: 31999
* Cyclomatic Complexity: 13164
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 715
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public record AssetActionAvailability(String action, boolean enabled, boolean visible, String reason) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AssetBankComposition(
|
||||
List<AssetBankFile> availableFiles,
|
||||
List<AssetBankFile> selectedFiles,
|
||||
long measuredBankSizeBytes) {
|
||||
public AssetBankComposition {
|
||||
availableFiles = List.copyOf(availableFiles);
|
||||
selectedFiles = List.copyOf(selectedFiles);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record AssetBankFile(
|
||||
String path,
|
||||
String displayName,
|
||||
long size,
|
||||
long lastModified,
|
||||
String fingerprint,
|
||||
Map<String, Object> metadata) {
|
||||
public AssetBankFile {
|
||||
metadata = Map.copyOf(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public enum AssetBuildParticipation {
|
||||
INCLUDED,
|
||||
EXCLUDED
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public enum AssetCapacityLevel {
|
||||
SAFE,
|
||||
WARNING,
|
||||
EXHAUSTED
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AssetCapacityPolicy {
|
||||
AssetCapacityState evaluate(
|
||||
AssetFamily assetFamily,
|
||||
int artifactCount,
|
||||
Map<String, String> outputMetadata,
|
||||
Map<String, Object> outputPipeline,
|
||||
long usedBytes);
|
||||
|
||||
int maxArtifactsForGlyphBank(Map<String, String> outputMetadata);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetCapacityState(
|
||||
double progress,
|
||||
AssetCapacityLevel level,
|
||||
boolean blocked,
|
||||
String labelText,
|
||||
String hintText) {
|
||||
|
||||
public AssetCapacityState {
|
||||
progress = Math.max(0.0d, Math.min(1.0d, progress));
|
||||
level = Objects.requireNonNullElse(level, AssetCapacityLevel.SAFE);
|
||||
labelText = Objects.requireNonNullElse(labelText, "");
|
||||
hintText = Objects.requireNonNullElse(hintText, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AssetCatalog {
|
||||
List<AssetSummary> list(ProjectReference projectReference, boolean deepSync);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AssetCommands {
|
||||
AssetMutationResult create(
|
||||
ProjectReference project,
|
||||
String assetRoot,
|
||||
String assetName,
|
||||
AssetFamily assetFamily,
|
||||
String outputFormat,
|
||||
String outputCodec,
|
||||
boolean preloadEnabled);
|
||||
|
||||
AssetMutationResult move(ProjectReference project, AssetReference assetReference, String targetRoot);
|
||||
|
||||
AssetMutationResult register(ProjectReference project, AssetReference assetReference);
|
||||
|
||||
AssetMutationResult delete(ProjectReference project, AssetReference assetReference);
|
||||
|
||||
AssetMutationResult updateBuildParticipation(
|
||||
ProjectReference project,
|
||||
AssetReference assetReference,
|
||||
boolean includeInBuild);
|
||||
|
||||
AssetUpdateResult updateContract(
|
||||
ProjectReference project,
|
||||
AssetReference assetReference,
|
||||
boolean preload,
|
||||
String outputCodec,
|
||||
Map<String, String> codecFieldValues,
|
||||
Map<String, String> metadataFieldValues);
|
||||
|
||||
AssetUpdateResult applyBankComposition(
|
||||
ProjectReference project,
|
||||
AssetReference assetReference,
|
||||
List<String> selectedPaths);
|
||||
|
||||
AssetUpdateResult applyPaletteOverhauling(
|
||||
ProjectReference project,
|
||||
AssetReference assetReference,
|
||||
List<Map<String, Object>> selectedPalettes);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AssetConfigurationField(
|
||||
String key,
|
||||
String label,
|
||||
String fieldType,
|
||||
String value,
|
||||
boolean required,
|
||||
List<String> options) {
|
||||
public AssetConfigurationField {
|
||||
options = List.copyOf(options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Provides the asset creation choices owned by the configured packing provider. */
|
||||
public interface AssetCreationCatalog {
|
||||
List<AssetFamily> supportedFamilies();
|
||||
|
||||
List<String> supportedFormats(AssetFamily family);
|
||||
|
||||
List<String> availableCodecs(String outputFormat);
|
||||
|
||||
boolean supports(String outputFormat, String outputCodec);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
public interface AssetDetails {
|
||||
AssetDetailsSnapshot get(ProjectReference project, AssetReference assetReference);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public record AssetDetailsSnapshot(
|
||||
AssetSummary summary,
|
||||
List<AssetActionAvailability> actions,
|
||||
String outputFormat,
|
||||
String outputCodec,
|
||||
List<String> availableOutputCodecs,
|
||||
Map<String, List<AssetConfigurationField>> codecConfigurationFieldsByCodec,
|
||||
List<AssetConfigurationField> metadataFields,
|
||||
Map<String, Object> outputPipeline,
|
||||
AssetBankComposition bankComposition,
|
||||
List<Map<String, Object>> pipelinePalettes,
|
||||
List<AssetDiagnostic> diagnostics) {
|
||||
public AssetDetailsSnapshot {
|
||||
actions = List.copyOf(actions);
|
||||
availableOutputCodecs = List.copyOf(availableOutputCodecs);
|
||||
codecConfigurationFieldsByCodec = Map.copyOf(codecConfigurationFieldsByCodec);
|
||||
metadataFields = List.copyOf(metadataFields);
|
||||
outputPipeline = Map.copyOf(outputPipeline);
|
||||
pipelinePalettes = List.copyOf(pipelinePalettes);
|
||||
diagnostics = List.copyOf(diagnostics);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public record AssetDiagnostic(
|
||||
String severity,
|
||||
String category,
|
||||
String message,
|
||||
Path evidencePath,
|
||||
boolean blocking) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public record AssetEmittedArtifact(String label, Path path, boolean canonical, long sizeBytes) {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public enum AssetFamily {
|
||||
GLYPH_BANK("glyph_bank"),
|
||||
SCENE_BANK("scene_bank"),
|
||||
SOUND_BANK("sound_bank"),
|
||||
UNKNOWN("unknown");
|
||||
|
||||
private final String manifestType;
|
||||
|
||||
AssetFamily(String manifestType) {
|
||||
this.manifestType = manifestType;
|
||||
}
|
||||
|
||||
public String manifestType() {
|
||||
return manifestType;
|
||||
}
|
||||
|
||||
public boolean matchesQuery(String normalizedQuery) {
|
||||
return manifestType.contains(normalizedQuery);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetMutationResult(
|
||||
AssetOperationStatus status,
|
||||
String summary,
|
||||
AssetReference assetReference,
|
||||
Path assetRoot,
|
||||
Path manifestPath) {
|
||||
|
||||
public AssetMutationResult {
|
||||
Objects.requireNonNull(status, "status");
|
||||
summary = Objects.requireNonNullElse(summary, "").trim();
|
||||
assetRoot = assetRoot == null ? null : assetRoot.toAbsolutePath().normalize();
|
||||
manifestPath = manifestPath == null ? null : manifestPath.toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
public boolean successful() {
|
||||
return status == AssetOperationStatus.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public enum AssetOperationStatus {
|
||||
SUCCESS,
|
||||
PARTIAL,
|
||||
FAILED
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public record AssetPackDiagnostic(String severity, String message, boolean blocking) {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AssetPackExecution(
|
||||
AssetOperationStatus status,
|
||||
String summary,
|
||||
String canonicalArtifactName,
|
||||
int packedAssetCount,
|
||||
long elapsedMillis,
|
||||
List<AssetEmittedArtifact> emittedArtifacts) {
|
||||
public AssetPackExecution {
|
||||
emittedArtifacts = List.copyOf(emittedArtifacts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AssetPackSummary(
|
||||
AssetOperationStatus status,
|
||||
String summary,
|
||||
int totalIncludedAssetCount,
|
||||
List<AssetPackSummaryItem> assets) {
|
||||
public AssetPackSummary {
|
||||
assets = List.copyOf(assets);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record AssetPackSummaryItem(
|
||||
int assetId,
|
||||
String assetName,
|
||||
AssetFamily assetFamily,
|
||||
int artifactCount,
|
||||
Map<String, String> outputMetadata,
|
||||
Map<String, Object> outputPipeline) {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AssetPackValidation(
|
||||
AssetOperationStatus status,
|
||||
String summary,
|
||||
List<AssetPackValidationItem> assets) {
|
||||
public AssetPackValidation {
|
||||
assets = List.copyOf(assets);
|
||||
}
|
||||
|
||||
public boolean canPack() {
|
||||
return assets.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
public record AssetPackValidationItem(
|
||||
int assetId,
|
||||
String assetName,
|
||||
Path assetPath,
|
||||
long lastModified,
|
||||
List<AssetPackDiagnostic> diagnostics) {
|
||||
public AssetPackValidationItem {
|
||||
diagnostics = List.copyOf(diagnostics);
|
||||
}
|
||||
|
||||
public boolean blocked() {
|
||||
return diagnostics.stream().anyMatch(AssetPackDiagnostic::blocking);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
import p.studio.api.operation.OperationHandle;
|
||||
|
||||
public interface AssetPacking {
|
||||
OperationHandle<AssetSyncResult> deepSync(ProjectReference project);
|
||||
|
||||
OperationHandle<AssetPackSummary> summarize(ProjectReference project);
|
||||
|
||||
OperationHandle<AssetPackValidation> validate(ProjectReference project);
|
||||
|
||||
OperationHandle<AssetPackExecution> pack(ProjectReference project);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/** Stable Studio identity for an asset, independent of the backing asset provider. */
|
||||
public record AssetReference(String value) {
|
||||
private static final String ASSET_ID_PREFIX = "asset:id:";
|
||||
private static final String ASSET_ROOT_PREFIX = "asset:root:";
|
||||
|
||||
public AssetReference {
|
||||
value = Objects.requireNonNull(value, "value").trim();
|
||||
if (value.isBlank()) {
|
||||
throw new IllegalArgumentException("value must not be blank");
|
||||
}
|
||||
}
|
||||
|
||||
public static AssetReference of(String value) {
|
||||
return new AssetReference(value);
|
||||
}
|
||||
|
||||
public static AssetReference forAssetId(int assetId) {
|
||||
if (assetId <= 0) {
|
||||
throw new IllegalArgumentException("assetId must be positive");
|
||||
}
|
||||
return new AssetReference(ASSET_ID_PREFIX + assetId);
|
||||
}
|
||||
|
||||
public static AssetReference forRelativeAssetRoot(String relativeAssetRoot) {
|
||||
final String normalized = Objects.requireNonNull(relativeAssetRoot, "relativeAssetRoot").trim();
|
||||
if (normalized.isBlank()) {
|
||||
throw new IllegalArgumentException("relativeAssetRoot must not be blank");
|
||||
}
|
||||
return new AssetReference(ASSET_ROOT_PREFIX + normalized);
|
||||
}
|
||||
|
||||
public boolean isAssetIdReference() {
|
||||
return value.startsWith(ASSET_ID_PREFIX);
|
||||
}
|
||||
|
||||
public boolean isAssetRootReference() {
|
||||
return value.startsWith(ASSET_ROOT_PREFIX);
|
||||
}
|
||||
|
||||
public String rawValue() {
|
||||
if (isAssetIdReference()) {
|
||||
return value.substring(ASSET_ID_PREFIX.length());
|
||||
}
|
||||
if (isAssetRootReference()) {
|
||||
return value.substring(ASSET_ROOT_PREFIX.length());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public enum AssetRegistrationState {
|
||||
REGISTERED,
|
||||
UNREGISTERED
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetSummary(
|
||||
AssetReference reference,
|
||||
String name,
|
||||
AssetRegistrationState registrationState,
|
||||
AssetBuildParticipation buildParticipation,
|
||||
Integer assetId,
|
||||
AssetFamily family,
|
||||
Path root,
|
||||
boolean preload,
|
||||
boolean hasDiagnostics) {
|
||||
|
||||
public AssetSummary {
|
||||
Objects.requireNonNull(reference, "reference");
|
||||
name = Objects.requireNonNull(name, "name").trim();
|
||||
Objects.requireNonNull(registrationState, "registrationState");
|
||||
Objects.requireNonNull(buildParticipation, "buildParticipation");
|
||||
family = Objects.requireNonNullElse(family, AssetFamily.UNKNOWN);
|
||||
root = Objects.requireNonNull(root, "root").toAbsolutePath().normalize();
|
||||
if (name.isBlank()) {
|
||||
throw new IllegalArgumentException("name must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetSyncResult(AssetOperationStatus status, String summary) {
|
||||
public AssetSyncResult {
|
||||
Objects.requireNonNull(status, "status");
|
||||
summary = Objects.requireNonNullElse(summary, "").trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
public record AssetUpdateResult(boolean success, String errorMessage) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspacePreparation(boolean success, Path assetsRoot, String message) {
|
||||
public AssetWorkspacePreparation {
|
||||
assetsRoot = Objects.requireNonNull(assetsRoot, "assetsRoot").toAbsolutePath().normalize();
|
||||
message = Objects.requireNonNullElse(message, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface AssetWorkspaceStorage {
|
||||
Path assetsRoot(ProjectReference projectReference);
|
||||
|
||||
AssetWorkspacePreparation prepare(ProjectReference projectReference);
|
||||
|
||||
boolean assetManifestExists(ProjectReference projectReference, String relativeAssetRoot);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package p.studio.api.assets.bank;
|
||||
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceAssetDetails;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AssetBankCompositionSession {
|
||||
void replaceDetails(AssetWorkspaceAssetDetails details);
|
||||
boolean ready();
|
||||
void beginEdit();
|
||||
void apply();
|
||||
void reset();
|
||||
void cancel();
|
||||
void moveToSelected(List<AssetWorkspaceBankCompositionFile> files);
|
||||
void moveToAvailable(List<AssetWorkspaceBankCompositionFile> files);
|
||||
void moveUp(int selectedIndex);
|
||||
void moveDown(int selectedIndex);
|
||||
AssetBankCompositionState state();
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p.studio.api.assets.bank;
|
||||
|
||||
public interface AssetBankCompositionSessionFactory {
|
||||
AssetBankCompositionSession createSession();
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package p.studio.api.assets.bank;
|
||||
|
||||
import p.studio.api.assets.AssetCapacityState;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetBankCompositionState(
|
||||
boolean editing,
|
||||
boolean dirty,
|
||||
List<AssetWorkspaceBankCompositionFile> availableFiles,
|
||||
List<AssetWorkspaceBankCompositionFile> selectedFiles,
|
||||
AssetCapacityState capacityState) {
|
||||
|
||||
public AssetBankCompositionState {
|
||||
availableFiles = List.copyOf(Objects.requireNonNull(availableFiles, "availableFiles"));
|
||||
selectedFiles = List.copyOf(Objects.requireNonNull(selectedFiles, "selectedFiles"));
|
||||
capacityState = Objects.requireNonNull(capacityState, "capacityState");
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import p.studio.api.assets.AssetFamily;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface AssetMetadataService {
|
||||
AssetStudioMetadataSnapshot read(Path assetRoot, AssetFamily assetFamily);
|
||||
|
||||
AssetMetadataWriteResult writeSceneBankMetadata(Path assetRoot, AssetStudioSceneBankMetadata metadata);
|
||||
|
||||
AssetMetadataWriteResult writeGlyphSpecialization(Path assetRoot, AssetStudioGlyphSpecialization specialization);
|
||||
|
||||
AssetMetadataWriteResult writeGlyphMaterialMetadata(Path assetRoot, AssetStudioGlyphMaterialMetadata metadata);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetMetadataWriteResult(boolean successful, String message) {
|
||||
public AssetMetadataWriteResult {
|
||||
message = Objects.requireNonNullElse(message, "");
|
||||
}
|
||||
|
||||
public static AssetMetadataWriteResult success() {
|
||||
return new AssetMetadataWriteResult(true, "");
|
||||
}
|
||||
|
||||
public static AssetMetadataWriteResult failure(String message) {
|
||||
return new AssetMetadataWriteResult(false, message);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetStudioGlyphMaterialArtifactBinding(
|
||||
String artifactId,
|
||||
String fingerprint) {
|
||||
|
||||
public AssetStudioGlyphMaterialArtifactBinding {
|
||||
artifactId = Objects.requireNonNull(artifactId, "artifactId").trim();
|
||||
fingerprint = Objects.requireNonNull(Objects.requireNonNullElse(fingerprint, ""), "fingerprint").trim();
|
||||
if (artifactId.isBlank()) {
|
||||
throw new IllegalArgumentException("artifactId must not be blank");
|
||||
}
|
||||
if (fingerprint.isBlank()) {
|
||||
throw new IllegalArgumentException("fingerprint must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public record AssetStudioGlyphMaterialMetadata(
|
||||
List<AssetStudioGlyphMaterialSchema> schemas,
|
||||
List<AssetStudioGlyphMaterialPalette> palettes,
|
||||
Path supportFile) {
|
||||
|
||||
public AssetStudioGlyphMaterialMetadata {
|
||||
schemas = List.copyOf(Objects.requireNonNull(schemas, "schemas"));
|
||||
palettes = List.copyOf(Objects.requireNonNull(palettes, "palettes"));
|
||||
supportFile = supportFile == null ? null : supportFile.toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
public Optional<AssetStudioGlyphMaterialSchema> findSchema(String schemaId) {
|
||||
return schemas.stream().filter(schema -> schema.schemaId().equals(schemaId)).findFirst();
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetStudioGlyphMaterialPalette(
|
||||
String paletteId,
|
||||
String displayName,
|
||||
String schemaId,
|
||||
int version,
|
||||
List<String> colors) {
|
||||
|
||||
public AssetStudioGlyphMaterialPalette(String paletteId, String schemaId, int version, List<String> colors) {
|
||||
this(paletteId, null, schemaId, version, colors);
|
||||
}
|
||||
|
||||
public AssetStudioGlyphMaterialPalette {
|
||||
paletteId = Objects.requireNonNull(paletteId, "paletteId").trim();
|
||||
displayName = displayName == null || displayName.trim().isBlank() ? null : displayName.trim();
|
||||
schemaId = Objects.requireNonNull(schemaId, "schemaId").trim();
|
||||
if (paletteId.isBlank()) {
|
||||
throw new IllegalArgumentException("paletteId must not be blank");
|
||||
}
|
||||
if (schemaId.isBlank()) {
|
||||
throw new IllegalArgumentException("schemaId must not be blank");
|
||||
}
|
||||
if (version <= 0) {
|
||||
throw new IllegalArgumentException("version must be positive");
|
||||
}
|
||||
colors = List.copyOf(Objects.requireNonNull(colors, "colors"));
|
||||
}
|
||||
|
||||
public List<Integer> convertedRgba8888Colors() {
|
||||
final List<Integer> converted = new ArrayList<>(colors.size());
|
||||
for (String color : colors) {
|
||||
converted.add(convertHtmlRgbToRgba8888(color));
|
||||
}
|
||||
return List.copyOf(converted);
|
||||
}
|
||||
|
||||
static int convertHtmlRgbToRgba8888(String htmlRgb) {
|
||||
final String value = Objects.requireNonNull(htmlRgb, "htmlRgb").trim();
|
||||
|
||||
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);
|
||||
if (value.length() == 9) {
|
||||
return rgb;
|
||||
}
|
||||
|
||||
return (rgb << 8) | 0xFF;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetStudioGlyphMaterialSchema(
|
||||
String schemaId,
|
||||
AssetStudioGlyphMaterialSchemaStatus status,
|
||||
int version,
|
||||
Map<Integer, String> materialIndices,
|
||||
List<AssetStudioGlyphMaterialArtifactBinding> artifactBindings) {
|
||||
|
||||
public AssetStudioGlyphMaterialSchema {
|
||||
schemaId = Objects.requireNonNull(schemaId, "schemaId").trim();
|
||||
status = Objects.requireNonNull(status, "status");
|
||||
if (schemaId.isBlank()) {
|
||||
throw new IllegalArgumentException("schemaId must not be blank");
|
||||
}
|
||||
if (version <= 0) {
|
||||
throw new IllegalArgumentException("version must be positive");
|
||||
}
|
||||
materialIndices = Map.copyOf(new LinkedHashMap<>(Objects.requireNonNull(materialIndices, "materialIndices")));
|
||||
artifactBindings = List.copyOf(Objects.requireNonNull(artifactBindings, "artifactBindings"));
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
public enum AssetStudioGlyphMaterialSchemaStatus {
|
||||
OK("ok"),
|
||||
INCONSISTENT("inconsistent");
|
||||
|
||||
private final String manifestValue;
|
||||
|
||||
AssetStudioGlyphMaterialSchemaStatus(String manifestValue) {
|
||||
this.manifestValue = manifestValue;
|
||||
}
|
||||
|
||||
public String manifestValue() {
|
||||
return manifestValue;
|
||||
}
|
||||
|
||||
public static AssetStudioGlyphMaterialSchemaStatus fromManifestValue(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
for (AssetStudioGlyphMaterialSchemaStatus candidate : values()) {
|
||||
if (candidate.manifestValue.equalsIgnoreCase(value.trim())) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum AssetStudioGlyphSpecialization {
|
||||
NONE("none"),
|
||||
TILESET("tileset"),
|
||||
SPRITES("sprites"),
|
||||
UI("ui");
|
||||
|
||||
private final String manifestValue;
|
||||
|
||||
AssetStudioGlyphSpecialization(String manifestValue) {
|
||||
this.manifestValue = manifestValue;
|
||||
}
|
||||
|
||||
public String manifestValue() {
|
||||
return manifestValue;
|
||||
}
|
||||
|
||||
public static AssetStudioGlyphSpecialization fromManifestValue(String value) {
|
||||
if (value == null) {
|
||||
return NONE;
|
||||
}
|
||||
final String normalized = value.trim().toLowerCase(Locale.ROOT);
|
||||
for (AssetStudioGlyphSpecialization candidate : values()) {
|
||||
if (candidate.manifestValue.equals(normalized)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetStudioMetadataSnapshot(
|
||||
AssetStudioGlyphSpecialization glyphSpecialization,
|
||||
AssetStudioSceneBankMetadata sceneBankMetadata,
|
||||
AssetStudioGlyphMaterialMetadata glyphMaterialMetadata) {
|
||||
|
||||
public AssetStudioMetadataSnapshot {
|
||||
glyphSpecialization = Objects.requireNonNullElse(glyphSpecialization, AssetStudioGlyphSpecialization.NONE);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetStudioSceneBankMetadata(
|
||||
int mapWidth,
|
||||
int mapHeight,
|
||||
int layerCount,
|
||||
List<AssetStudioSceneLayerBinding> layerBindings,
|
||||
Path supportFile) {
|
||||
|
||||
public AssetStudioSceneBankMetadata {
|
||||
layerBindings = List.copyOf(Objects.requireNonNull(layerBindings, "layerBindings"));
|
||||
supportFile = Objects.requireNonNull(supportFile, "supportFile").toAbsolutePath().normalize();
|
||||
if (mapWidth <= 0 || mapHeight <= 0) {
|
||||
throw new IllegalArgumentException("map dimensions must be positive");
|
||||
}
|
||||
if (layerCount != 4) {
|
||||
throw new IllegalArgumentException("layerCount must stay fixed at 4");
|
||||
}
|
||||
if (layerBindings.size() != layerCount) {
|
||||
throw new IllegalArgumentException("layerBindings must match layerCount");
|
||||
}
|
||||
}
|
||||
|
||||
public long enabledLayerCount() {
|
||||
return layerBindings.stream().filter(AssetStudioSceneLayerBinding::enabled).count();
|
||||
}
|
||||
|
||||
public AssetStudioSceneBankMetadata withUpdatedBindings(final List<AssetStudioSceneLayerBinding> assetStudioSceneLayerBindings) {
|
||||
return new AssetStudioSceneBankMetadata(
|
||||
mapWidth,
|
||||
mapHeight,
|
||||
layerCount,
|
||||
assetStudioSceneLayerBindings,
|
||||
supportFile);
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetStudioSceneLayerBinding(
|
||||
boolean enabled,
|
||||
int index,
|
||||
String layerName,
|
||||
int width,
|
||||
int height,
|
||||
String tilemap,
|
||||
String tilesetAssetRoot,
|
||||
float parallaxFactorX,
|
||||
float parallaxFactorY,
|
||||
int defaultPaletteId,
|
||||
List<AssetStudioSceneTile> tiles) {
|
||||
public AssetStudioSceneLayerBinding {
|
||||
layerName = Objects.requireNonNull(layerName, "layerName").trim();
|
||||
tilemap = Objects.requireNonNull(tilemap, "tilemap").trim();
|
||||
tilesetAssetRoot = Objects.requireNonNull(tilesetAssetRoot, "tilesetAssetRoot").trim();
|
||||
tiles = List.copyOf(Objects.requireNonNull(tiles, "tiles"));
|
||||
if (index <= 0) {
|
||||
throw new IllegalArgumentException("index must be positive");
|
||||
}
|
||||
if (layerName.isBlank()) {
|
||||
throw new IllegalArgumentException("layerName must not be blank");
|
||||
}
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw new IllegalArgumentException("layer dimensions must be positive");
|
||||
}
|
||||
if (tilemap.isBlank()) {
|
||||
throw new IllegalArgumentException("tilemap must not be blank");
|
||||
}
|
||||
if (!Float.isFinite(parallaxFactorX) || parallaxFactorX < 0.0f) {
|
||||
throw new IllegalArgumentException("parallaxFactorX must be finite and non-negative");
|
||||
}
|
||||
if (!Float.isFinite(parallaxFactorY) || parallaxFactorY < 0.0f) {
|
||||
throw new IllegalArgumentException("parallaxFactorY must be finite and non-negative");
|
||||
}
|
||||
if (defaultPaletteId < 0) {
|
||||
throw new IllegalArgumentException("defaultPaletteId must be non-negative");
|
||||
}
|
||||
if (tiles.size() != width * height) {
|
||||
throw new IllegalArgumentException("tiles must match width * height");
|
||||
}
|
||||
}
|
||||
|
||||
public AssetStudioSceneLayerBinding(
|
||||
boolean enabled,
|
||||
int index,
|
||||
String layerName,
|
||||
int width,
|
||||
int height,
|
||||
String tilemap,
|
||||
String tilesetAssetRoot,
|
||||
float parallaxFactorX,
|
||||
float parallaxFactorY,
|
||||
int defaultPaletteId) {
|
||||
this(
|
||||
enabled,
|
||||
index,
|
||||
layerName,
|
||||
width,
|
||||
height,
|
||||
tilemap,
|
||||
tilesetAssetRoot,
|
||||
parallaxFactorX,
|
||||
parallaxFactorY,
|
||||
defaultPaletteId,
|
||||
blankTiles(width, height, defaultPaletteId));
|
||||
}
|
||||
|
||||
private static List<AssetStudioSceneTile> blankTiles(int width, int height, int defaultPaletteId) {
|
||||
final List<AssetStudioSceneTile> tiles = new ArrayList<>(width * height);
|
||||
for (int index = 0; index < width * height; index += 1) {
|
||||
tiles.add(AssetStudioSceneTile.inactive(defaultPaletteId));
|
||||
}
|
||||
return List.copyOf(tiles);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package p.studio.api.assets.metadata;
|
||||
|
||||
public record AssetStudioSceneTile(
|
||||
boolean active,
|
||||
int glyphId,
|
||||
int paletteId,
|
||||
boolean flipX,
|
||||
boolean flipY) {
|
||||
|
||||
public AssetStudioSceneTile {
|
||||
if (glyphId < 0) {
|
||||
throw new IllegalArgumentException("glyphId must be non-negative");
|
||||
}
|
||||
if (paletteId < 0) {
|
||||
throw new IllegalArgumentException("paletteId must be non-negative");
|
||||
}
|
||||
}
|
||||
|
||||
public static AssetStudioSceneTile inactive(int paletteId) {
|
||||
return new AssetStudioSceneTile(false, 0, Math.max(0, paletteId), false, false);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package p.studio.api.assets.palette;
|
||||
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialMetadata;
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialSchema;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceAssetDetails;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AssetPaletteSession {
|
||||
void replaceDetails(AssetWorkspaceAssetDetails details);
|
||||
void replaceMaterialMetadata(AssetStudioGlyphMaterialMetadata metadata);
|
||||
boolean ready();
|
||||
AssetWorkspaceAssetDetails details();
|
||||
void beginEdit();
|
||||
void apply();
|
||||
void reset();
|
||||
void cancel();
|
||||
void moveToSelected(List<AssetWorkspaceBankCompositionFile> files);
|
||||
void moveToAvailable(List<AssetWorkspaceBankCompositionFile> files);
|
||||
void selectPreviewTile(AssetWorkspaceBankCompositionFile file);
|
||||
void selectPreviewPalette(AssetWorkspaceBankCompositionFile file);
|
||||
AssetPaletteState state();
|
||||
List<AssetStudioGlyphMaterialSchema> readySchemas();
|
||||
String nextPaletteId();
|
||||
boolean duplicatePaletteExists(String paletteId, String schemaId, List<String> colors);
|
||||
AssetStudioGlyphMaterialMetadata upsertPalette(
|
||||
String paletteId, String displayName, String schemaId, List<String> colors);
|
||||
AssetStudioGlyphMaterialMetadata removePalette(String paletteId);
|
||||
AssetWorkspaceBankCompositionFile paletteFileById(String paletteId);
|
||||
boolean paletteIsOriginal(AssetWorkspaceBankCompositionFile file);
|
||||
String generatedDisplayName(List<String> colors);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package p.studio.api.assets.palette;
|
||||
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetPaletteState(
|
||||
boolean editing,
|
||||
boolean dirty,
|
||||
List<AssetWorkspaceBankCompositionFile> previewTileFiles,
|
||||
List<AssetWorkspaceBankCompositionFile> allFiles,
|
||||
List<AssetWorkspaceBankCompositionFile> availableFiles,
|
||||
List<AssetWorkspaceBankCompositionFile> selectedFiles,
|
||||
AssetWorkspaceBankCompositionFile previewTileFile,
|
||||
AssetWorkspaceBankCompositionFile previewPaletteFile,
|
||||
int renderableFileCount) {
|
||||
|
||||
public AssetPaletteState {
|
||||
previewTileFiles = List.copyOf(Objects.requireNonNull(previewTileFiles, "previewTileFiles"));
|
||||
allFiles = List.copyOf(Objects.requireNonNull(allFiles, "allFiles"));
|
||||
availableFiles = List.copyOf(Objects.requireNonNull(availableFiles, "availableFiles"));
|
||||
selectedFiles = List.copyOf(Objects.requireNonNull(selectedFiles, "selectedFiles"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package p.studio.api.assets.scene;
|
||||
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceAssetDetails;
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
public interface SceneBankWorkflow {
|
||||
SceneBankWorkflowResult inspect(ProjectReference projectReference, AssetWorkspaceAssetDetails details);
|
||||
|
||||
SceneBankWorkflowResult validate(ProjectReference projectReference, AssetWorkspaceAssetDetails details);
|
||||
|
||||
SceneBankWorkflowResult accept(ProjectReference projectReference, AssetWorkspaceAssetDetails details);
|
||||
|
||||
SceneBankWorkflowResult inspectLayer(ProjectReference projectReference, AssetWorkspaceAssetDetails details, int layerIndex);
|
||||
|
||||
SceneBankWorkflowResult validateLayer(ProjectReference projectReference, AssetWorkspaceAssetDetails details, int layerIndex);
|
||||
|
||||
SceneBankWorkflowResult acceptLayer(ProjectReference projectReference, AssetWorkspaceAssetDetails details, int layerIndex);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package p.studio.api.assets.scene;
|
||||
|
||||
import p.studio.api.assets.AssetDiagnostic;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceSceneBankValidation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record SceneBankWorkflowResult(
|
||||
boolean success,
|
||||
String message,
|
||||
AssetWorkspaceSceneBankValidation validation,
|
||||
List<AssetDiagnostic> diagnostics) {
|
||||
|
||||
public SceneBankWorkflowResult {
|
||||
message = Objects.requireNonNullElse(message, "");
|
||||
validation = Objects.requireNonNullElse(validation, AssetWorkspaceSceneBankValidation.NOT_APPLICABLE);
|
||||
diagnostics = List.copyOf(Objects.requireNonNullElse(diagnostics, List.of()));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.assets.schema;
|
||||
|
||||
import p.studio.api.assets.palette.AssetPaletteSession;
|
||||
|
||||
public interface AssetColorSchemaFactory {
|
||||
AssetColorSchemaSession createSession();
|
||||
|
||||
AssetColorSchemaRules rules();
|
||||
|
||||
AssetPaletteSession createPaletteSession();
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package p.studio.api.assets.schema;
|
||||
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialSchema;
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialSchemaStatus;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AssetColorSchemaRules {
|
||||
AssetStudioGlyphMaterialSchemaStatus effectiveStatus(
|
||||
AssetStudioGlyphMaterialSchema schema,
|
||||
List<AssetWorkspaceBankCompositionFile> selectedTiles);
|
||||
|
||||
boolean supportsSchemaAuthoring(AssetWorkspaceBankCompositionFile file);
|
||||
|
||||
String artifactId(AssetWorkspaceBankCompositionFile file);
|
||||
|
||||
String fingerprint(AssetWorkspaceBankCompositionFile file);
|
||||
|
||||
List<String> tileColors(AssetWorkspaceBankCompositionFile file);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package p.studio.api.assets.schema;
|
||||
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialMetadata;
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialSchema;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceAssetDetails;
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AssetColorSchemaSession {
|
||||
void replaceDetails(AssetWorkspaceAssetDetails details);
|
||||
void replaceMaterialMetadata(AssetStudioGlyphMaterialMetadata metadata);
|
||||
boolean ready();
|
||||
void beginEdit();
|
||||
void apply();
|
||||
void reset();
|
||||
void cancel();
|
||||
void selectSchema(String schemaId);
|
||||
void createSchema();
|
||||
void markSelectedSchemaForRemoval();
|
||||
void moveToAssigned(List<AssetWorkspaceBankCompositionFile> files);
|
||||
void moveToAvailable(List<AssetWorkspaceBankCompositionFile> files);
|
||||
void moveAssignedUp(int index);
|
||||
void moveAssignedDown(int index);
|
||||
AssetColorSchemaState state();
|
||||
AssetStudioGlyphMaterialMetadata metadata();
|
||||
List<AssetStudioGlyphMaterialSchema> schemas();
|
||||
List<AssetWorkspaceBankCompositionFile> selectedTiles();
|
||||
List<AssetWorkspaceBankCompositionFile> availableTilesForCreate();
|
||||
List<AssetWorkspaceBankCompositionFile> availableTilesForEdit(String schemaId);
|
||||
boolean canRemove(String schemaId);
|
||||
Optional<AssetStudioGlyphMaterialSchema> findSchema(String schemaId);
|
||||
AssetStudioGlyphMaterialMetadata upsertSchema(
|
||||
String schemaId,
|
||||
List<AssetWorkspaceBankCompositionFile> assignedTiles,
|
||||
List<String> orderedColors);
|
||||
AssetStudioGlyphMaterialMetadata removeSchema(String schemaId);
|
||||
String nextSchemaId();
|
||||
int unassignedTileCount();
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package p.studio.api.assets.schema;
|
||||
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceBankCompositionFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetColorSchemaState(
|
||||
boolean editing,
|
||||
boolean dirty,
|
||||
String schemaId,
|
||||
boolean existingSchema,
|
||||
boolean removeRequested,
|
||||
List<AssetWorkspaceBankCompositionFile> availableTiles,
|
||||
List<AssetWorkspaceBankCompositionFile> assignedTiles,
|
||||
List<String> orderedColors) {
|
||||
|
||||
public AssetColorSchemaState {
|
||||
availableTiles = List.copyOf(Objects.requireNonNull(availableTiles, "availableTiles"));
|
||||
assignedTiles = List.copyOf(Objects.requireNonNull(assignedTiles, "assignedTiles"));
|
||||
orderedColors = List.copyOf(Objects.requireNonNull(orderedColors, "orderedColors"));
|
||||
}
|
||||
|
||||
public boolean selected() {
|
||||
return schemaId != null && !schemaId.isBlank();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.assets.tiled;
|
||||
|
||||
public enum SceneTmxExportDisposition {
|
||||
OVERWRITE,
|
||||
KEEP_BOTH
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package p.studio.api.assets.tiled;
|
||||
|
||||
import p.studio.api.assets.metadata.AssetStudioSceneLayerBinding;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record TiledAssetGenerationResult(
|
||||
boolean success,
|
||||
String message,
|
||||
List<AssetStudioSceneLayerBinding> updatedBindings,
|
||||
List<Path> writtenFiles) {
|
||||
|
||||
public TiledAssetGenerationResult {
|
||||
message = Objects.requireNonNullElse(message, "");
|
||||
writtenFiles = List.copyOf(Objects.requireNonNullElse(writtenFiles, List.of()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package p.studio.api.assets.tiled;
|
||||
|
||||
import p.studio.api.assets.workspace.AssetWorkspaceAssetDetails;
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
public interface TiledAssetService {
|
||||
boolean sceneTmxExists(AssetWorkspaceAssetDetails details);
|
||||
|
||||
TiledAssetGenerationResult exportTilesetTsx(AssetWorkspaceAssetDetails details);
|
||||
|
||||
TiledAssetGenerationResult exportSceneBankTmx(
|
||||
ProjectReference projectReference,
|
||||
AssetWorkspaceAssetDetails details,
|
||||
SceneTmxExportDisposition disposition);
|
||||
|
||||
TiledAssetGenerationResult importSceneBankTmx(
|
||||
ProjectReference projectReference,
|
||||
AssetWorkspaceAssetDetails details);
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspaceAssetAction(
|
||||
String action,
|
||||
boolean enabled,
|
||||
boolean visible,
|
||||
String reason) {
|
||||
|
||||
public AssetWorkspaceAssetAction {
|
||||
action = Objects.requireNonNull(action, "action").trim();
|
||||
reason = reason == null ? null : reason.trim();
|
||||
if (reason != null && reason.isBlank()) {
|
||||
reason = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
import p.studio.api.assets.AssetConfigurationField;
|
||||
import p.studio.api.assets.AssetDiagnostic;
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphMaterialMetadata;
|
||||
import p.studio.api.assets.metadata.AssetStudioSceneBankMetadata;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspaceAssetDetails(
|
||||
AssetWorkspaceAssetSummary summary,
|
||||
List<AssetWorkspaceAssetAction> actions,
|
||||
String outputFormat,
|
||||
String outputCodec,
|
||||
List<String> availableOutputCodecs,
|
||||
Map<String, List<AssetConfigurationField>> codecConfigurationFieldsByCodec,
|
||||
List<AssetConfigurationField> metadataFields,
|
||||
Map<String, Object> outputPipeline,
|
||||
AssetWorkspaceBankCompositionDetails bankComposition,
|
||||
List<Map<String, Object>> pipelinePalettes,
|
||||
AssetStudioGlyphMaterialMetadata glyphMaterialMetadata,
|
||||
AssetStudioSceneBankMetadata sceneBankMetadata,
|
||||
AssetWorkspaceSceneBankValidation sceneBankValidation,
|
||||
List<AssetDiagnostic> diagnostics) {
|
||||
|
||||
public AssetWorkspaceAssetDetails {
|
||||
Objects.requireNonNull(summary, "summary");
|
||||
actions = List.copyOf(Objects.requireNonNull(actions, "actions"));
|
||||
outputFormat = Objects.requireNonNullElse(outputFormat, "UNKNOWN");
|
||||
outputCodec = Objects.requireNonNullElse(outputCodec, "UNKNOWN");
|
||||
availableOutputCodecs = List.copyOf(Objects.requireNonNull(availableOutputCodecs, "availableOutputCodecs"));
|
||||
codecConfigurationFieldsByCodec = Map.copyOf(Objects.requireNonNull(codecConfigurationFieldsByCodec, "codecConfigurationFieldsByCodec"));
|
||||
metadataFields = List.copyOf(Objects.requireNonNull(metadataFields, "metadataFields"));
|
||||
outputPipeline = Map.copyOf(Objects.requireNonNull(outputPipeline, "outputPipeline"));
|
||||
bankComposition = Objects.requireNonNull(bankComposition, "bankComposition");
|
||||
pipelinePalettes = List.copyOf(Objects.requireNonNull(pipelinePalettes, "pipelinePalettes"));
|
||||
sceneBankValidation = Objects.requireNonNullElse(sceneBankValidation, AssetWorkspaceSceneBankValidation.NOT_APPLICABLE);
|
||||
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
}
|
||||
|
||||
public AssetWorkspaceAssetDetails withBankComposition(AssetWorkspaceBankCompositionDetails bankComposition) {
|
||||
return new AssetWorkspaceAssetDetails(
|
||||
summary,
|
||||
actions,
|
||||
outputFormat,
|
||||
outputCodec,
|
||||
availableOutputCodecs,
|
||||
codecConfigurationFieldsByCodec,
|
||||
metadataFields,
|
||||
outputPipeline,
|
||||
bankComposition,
|
||||
pipelinePalettes,
|
||||
glyphMaterialMetadata,
|
||||
sceneBankMetadata,
|
||||
sceneBankValidation,
|
||||
diagnostics);
|
||||
}
|
||||
|
||||
public AssetWorkspaceAssetDetails withGlyphMaterialMetadata(AssetStudioGlyphMaterialMetadata glyphMaterialMetadata) {
|
||||
return new AssetWorkspaceAssetDetails(
|
||||
summary,
|
||||
actions,
|
||||
outputFormat,
|
||||
outputCodec,
|
||||
availableOutputCodecs,
|
||||
codecConfigurationFieldsByCodec,
|
||||
metadataFields,
|
||||
outputPipeline,
|
||||
bankComposition,
|
||||
pipelinePalettes,
|
||||
glyphMaterialMetadata,
|
||||
sceneBankMetadata,
|
||||
sceneBankValidation,
|
||||
diagnostics);
|
||||
}
|
||||
|
||||
public AssetWorkspaceAssetDetails withSceneBankMetadata(AssetStudioSceneBankMetadata sceneBankMetadata) {
|
||||
return new AssetWorkspaceAssetDetails(
|
||||
summary,
|
||||
actions,
|
||||
outputFormat,
|
||||
outputCodec,
|
||||
availableOutputCodecs,
|
||||
codecConfigurationFieldsByCodec,
|
||||
metadataFields,
|
||||
outputPipeline,
|
||||
bankComposition,
|
||||
pipelinePalettes,
|
||||
glyphMaterialMetadata,
|
||||
sceneBankMetadata,
|
||||
sceneBankValidation,
|
||||
diagnostics);
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
public enum AssetWorkspaceAssetState {
|
||||
REGISTERED,
|
||||
UNREGISTERED
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
import p.studio.api.assets.AssetReference;
|
||||
import p.studio.api.assets.AssetFamily;
|
||||
import p.studio.api.assets.metadata.AssetStudioGlyphSpecialization;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspaceAssetSummary(
|
||||
AssetReference assetReference,
|
||||
String assetName,
|
||||
AssetWorkspaceAssetState state,
|
||||
AssetWorkspaceBuildParticipation buildParticipation,
|
||||
Integer assetId,
|
||||
AssetFamily assetFamily,
|
||||
AssetStudioGlyphSpecialization glyphSpecialization,
|
||||
Path assetRoot,
|
||||
boolean preload,
|
||||
boolean hasDiagnostics) {
|
||||
|
||||
public AssetWorkspaceAssetSummary {
|
||||
Objects.requireNonNull(assetReference, "assetReference");
|
||||
assetName = Objects.requireNonNull(assetName, "assetName").trim();
|
||||
Objects.requireNonNull(state, "state");
|
||||
Objects.requireNonNull(buildParticipation, "buildParticipation");
|
||||
assetFamily = Objects.requireNonNullElse(assetFamily, AssetFamily.UNKNOWN);
|
||||
glyphSpecialization = Objects.requireNonNullElse(glyphSpecialization, AssetStudioGlyphSpecialization.NONE);
|
||||
assetRoot = Objects.requireNonNull(assetRoot, "assetRoot").toAbsolutePath().normalize();
|
||||
if (assetName.isBlank()) {
|
||||
throw new IllegalArgumentException("assetName must not be blank");
|
||||
}
|
||||
if (state == AssetWorkspaceAssetState.REGISTERED && assetId == null) {
|
||||
throw new IllegalArgumentException("registered asset must expose assetId");
|
||||
}
|
||||
if (state == AssetWorkspaceAssetState.UNREGISTERED && buildParticipation != AssetWorkspaceBuildParticipation.EXCLUDED) {
|
||||
throw new IllegalArgumentException("unregistered asset must stay excluded from build participation");
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspaceBankCompositionDetails(
|
||||
List<AssetWorkspaceBankCompositionFile> availableFiles,
|
||||
List<AssetWorkspaceBankCompositionFile> selectedFiles,
|
||||
long measuredBankSizeBytes) {
|
||||
|
||||
public static final AssetWorkspaceBankCompositionDetails EMPTY =
|
||||
new AssetWorkspaceBankCompositionDetails(List.of(), List.of(), 0L);
|
||||
|
||||
public AssetWorkspaceBankCompositionDetails {
|
||||
availableFiles = List.copyOf(Objects.requireNonNull(availableFiles, "availableFiles"));
|
||||
selectedFiles = List.copyOf(Objects.requireNonNull(selectedFiles, "selectedFiles"));
|
||||
if (measuredBankSizeBytes < 0L) {
|
||||
throw new IllegalArgumentException("measuredBankSizeBytes must be non-negative");
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspaceBankCompositionFile(
|
||||
String path,
|
||||
String displayName,
|
||||
long size,
|
||||
long lastModified,
|
||||
String fingerprint,
|
||||
Map<String, Object> metadata) {
|
||||
|
||||
public AssetWorkspaceBankCompositionFile {
|
||||
path = Objects.requireNonNull(path, "path").trim();
|
||||
displayName = Objects.requireNonNull(displayName, "displayName").trim();
|
||||
if (path.isBlank()) {
|
||||
throw new IllegalArgumentException("path must not be blank");
|
||||
}
|
||||
if (displayName.isBlank()) {
|
||||
throw new IllegalArgumentException("displayName must not be blank");
|
||||
}
|
||||
if (size < 0L) {
|
||||
throw new IllegalArgumentException("size must be non-negative");
|
||||
}
|
||||
if (lastModified < 0L) {
|
||||
throw new IllegalArgumentException("lastModified must be non-negative");
|
||||
}
|
||||
fingerprint = fingerprint == null || fingerprint.isBlank() ? null : fingerprint;
|
||||
metadata = Map.copyOf(new LinkedHashMap<>(Objects.requireNonNull(metadata, "metadata")));
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
public enum AssetWorkspaceBuildParticipation {
|
||||
INCLUDED,
|
||||
EXCLUDED
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
public enum AssetWorkspaceSceneBankStatus {
|
||||
NOT_APPLICABLE,
|
||||
PENDING_VALIDATION,
|
||||
VALIDATED_PENDING_ACCEPTANCE,
|
||||
READY,
|
||||
VALIDATION_FAILED
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package p.studio.api.assets.workspace;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetWorkspaceSceneBankValidation(
|
||||
AssetWorkspaceSceneBankStatus status,
|
||||
boolean pendingExternalChanges,
|
||||
boolean canAccept,
|
||||
String currentFingerprint,
|
||||
String validatedFingerprint,
|
||||
String acceptedFingerprint) {
|
||||
|
||||
public static final AssetWorkspaceSceneBankValidation NOT_APPLICABLE = new AssetWorkspaceSceneBankValidation(
|
||||
AssetWorkspaceSceneBankStatus.NOT_APPLICABLE,
|
||||
false,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
"");
|
||||
|
||||
public AssetWorkspaceSceneBankValidation {
|
||||
status = Objects.requireNonNullElse(status, AssetWorkspaceSceneBankStatus.NOT_APPLICABLE);
|
||||
currentFingerprint = Objects.requireNonNullElse(currentFingerprint, "");
|
||||
validatedFingerprint = Objects.requireNonNullElse(validatedFingerprint, "");
|
||||
acceptedFingerprint = Objects.requireNonNullElse(acceptedFingerprint, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.api.diagnostic;
|
||||
|
||||
public enum DiagnosticSeverity {
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package p.studio.api.diagnostic;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record StudioDiagnostic(String code, DiagnosticSeverity severity, String message) {
|
||||
public StudioDiagnostic {
|
||||
Objects.requireNonNull(code, "code");
|
||||
Objects.requireNonNull(severity, "severity");
|
||||
Objects.requireNonNull(message, "message");
|
||||
if (code.isBlank()) {
|
||||
throw new IllegalArgumentException("code must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
import p.studio.api.operation.OperationHandle;
|
||||
|
||||
public interface ExecutionController extends AutoCloseable {
|
||||
OperationHandle<ExecutionSnapshot> play();
|
||||
|
||||
void stop();
|
||||
|
||||
default void shutdown() {
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
import p.studio.api.project.ProjectLocalStudioSetup;
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
public interface ExecutionControllerFactory {
|
||||
ExecutionController create(ProjectReference project, ProjectLocalStudioSetup setup, ExecutionSession session);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ExecutionLogEntry(
|
||||
long sequence,
|
||||
Instant timestamp,
|
||||
ExecutionLogSource source,
|
||||
ExecutionLogSeverity severity,
|
||||
String message) {
|
||||
|
||||
public ExecutionLogEntry {
|
||||
if (sequence <= 0L) {
|
||||
throw new IllegalArgumentException("sequence must be positive");
|
||||
}
|
||||
timestamp = timestamp == null ? Instant.now() : timestamp;
|
||||
Objects.requireNonNull(source, "source");
|
||||
Objects.requireNonNull(severity, "severity");
|
||||
message = Objects.requireNonNull(message, "message").trim();
|
||||
if (message.isBlank()) {
|
||||
throw new IllegalArgumentException("message must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
public enum ExecutionLogSeverity {
|
||||
INFO,
|
||||
ERROR
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
public enum ExecutionLogSource {
|
||||
BUILD,
|
||||
PACK_VALIDATION,
|
||||
PACK,
|
||||
MANIFEST,
|
||||
RUNTIME
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
import p.studio.api.operation.OperationSubscription;
|
||||
import p.studio.api.shipper.ShipperLogEntry;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface ExecutionSession extends AutoCloseable {
|
||||
ExecutionSnapshot snapshot();
|
||||
|
||||
OperationSubscription subscribe(Consumer<ExecutionSnapshot> listener);
|
||||
|
||||
void beginPreparationCycle();
|
||||
|
||||
void transitionToPrepareFailed();
|
||||
|
||||
void transitionToConnecting();
|
||||
|
||||
void transitionToRunning();
|
||||
|
||||
void transitionToRuntimeFailed();
|
||||
|
||||
void transitionToStopped();
|
||||
|
||||
void resetToIdle();
|
||||
|
||||
void appendShipperLog(ShipperLogEntry entry);
|
||||
|
||||
void appendRuntimeLog(ExecutionLogSeverity severity, String message);
|
||||
|
||||
void appendRuntimeLog(ExecutionLogSeverity severity, String message, Instant timestamp);
|
||||
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ExecutionSnapshot(ExecutionState state, List<ExecutionLogEntry> logs) {
|
||||
public ExecutionSnapshot {
|
||||
Objects.requireNonNull(state, "state");
|
||||
logs = List.copyOf(Objects.requireNonNull(logs, "logs"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.execution;
|
||||
|
||||
public enum ExecutionState {
|
||||
IDLE,
|
||||
PREPARING,
|
||||
PREPARE_FAILED,
|
||||
CONNECTING,
|
||||
RUNNING,
|
||||
RUNTIME_FAILED,
|
||||
STOPPED
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.api.operation;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public interface OperationExecutor {
|
||||
<R> OperationHandle<R> submit(String summary, Callable<R> operation);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p.studio.api.operation;
|
||||
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface OperationHandle<R> {
|
||||
OperationId id();
|
||||
|
||||
OperationSnapshot snapshot();
|
||||
|
||||
CompletionStage<R> completion();
|
||||
|
||||
boolean cancel();
|
||||
|
||||
OperationSubscription subscribe(Consumer<OperationSnapshot> subscriber);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package p.studio.api.operation;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record OperationId(String value) {
|
||||
public OperationId {
|
||||
Objects.requireNonNull(value, "value");
|
||||
if (value.isBlank()) {
|
||||
throw new IllegalArgumentException("value must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package p.studio.api.operation;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
public record OperationSnapshot(
|
||||
OperationId id,
|
||||
OperationState state,
|
||||
Instant updatedAt,
|
||||
String summary) {
|
||||
public OperationSnapshot {
|
||||
Objects.requireNonNull(id, "id");
|
||||
Objects.requireNonNull(state, "state");
|
||||
Objects.requireNonNull(updatedAt, "updatedAt");
|
||||
summary = Objects.requireNonNullElse(summary, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package p.studio.api.operation;
|
||||
|
||||
public enum OperationState {
|
||||
PENDING,
|
||||
RUNNING,
|
||||
SUCCEEDED,
|
||||
FAILED,
|
||||
CANCELLED
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.operation;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface OperationSubscription extends AutoCloseable {
|
||||
@Override
|
||||
void close();
|
||||
|
||||
default void unsubscribe() {
|
||||
close();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.preferences;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectActivityHistoryStore {
|
||||
List<ProjectActivityRecord> load(ProjectReference projectReference);
|
||||
|
||||
void save(ProjectReference projectReference, List<ProjectActivityRecord> entries);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.preferences;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record ProjectActivityRecord(String source, String message, String severity, boolean sticky) {
|
||||
public ProjectActivityRecord {
|
||||
source = Objects.requireNonNull(source, "source");
|
||||
message = Objects.requireNonNull(message, "message");
|
||||
severity = Objects.requireNonNull(severity, "severity");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package p.studio.api.preferences;
|
||||
|
||||
public record WindowGeometry(double x, double y, double width, double height, boolean maximized) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.preferences;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface WindowStateStore {
|
||||
Optional<WindowGeometry> load(ProjectReference projectReference);
|
||||
|
||||
void save(ProjectReference projectReference, WindowGeometry geometry);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface KnownProjects {
|
||||
List<ProjectReference> listKnownProjects();
|
||||
|
||||
void remember(ProjectReference projectReference);
|
||||
|
||||
void forget(ProjectReference projectReference);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectCatalog {
|
||||
Path projectsRoot();
|
||||
|
||||
List<ProjectReference> listProjects();
|
||||
|
||||
ProjectReference openProject(Path projectPath);
|
||||
|
||||
ProjectReference openProjectManifest(Path manifestPath);
|
||||
|
||||
ProjectReference createProject(ProjectCreationRequest request);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public record ProjectCreationRequest(
|
||||
String projectName,
|
||||
Path parentLocation,
|
||||
String languageId,
|
||||
int stdlib,
|
||||
ProjectTarget target,
|
||||
String sourceRoot,
|
||||
int indentationWidth,
|
||||
String runtimePath) {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectLanguageCatalog {
|
||||
List<ProjectLanguageTemplate> listLanguageTemplates();
|
||||
|
||||
default ProjectLanguageTemplate defaultTemplate() {
|
||||
return listLanguageTemplates().stream().findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException("no frontend languages are registered"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ProjectLanguageTemplate(
|
||||
String languageId,
|
||||
List<StdlibOption> stdlibOptions,
|
||||
StdlibOption defaultStdlib,
|
||||
List<String> sourceRoots,
|
||||
String defaultSourceRoot) {
|
||||
public ProjectLanguageTemplate {
|
||||
languageId = Objects.requireNonNull(languageId, "languageId");
|
||||
stdlibOptions = List.copyOf(stdlibOptions);
|
||||
Objects.requireNonNull(defaultStdlib, "defaultStdlib");
|
||||
sourceRoots = List.copyOf(sourceRoots);
|
||||
defaultSourceRoot = Objects.requireNonNull(defaultSourceRoot, "defaultSourceRoot");
|
||||
}
|
||||
|
||||
public enum Stability {
|
||||
DEFAULT,
|
||||
STABLE,
|
||||
EXPERIMENTAL
|
||||
}
|
||||
|
||||
public record StdlibOption(int version, Stability stability) {
|
||||
public StdlibOption {
|
||||
Objects.requireNonNull(stability, "stability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return switch (stability) {
|
||||
case DEFAULT -> version + " (default)";
|
||||
case STABLE -> version + " (stable)";
|
||||
case EXPERIMENTAL -> version + " (experimental)";
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
public record ProjectLocalStudioSetup(
|
||||
String prometeuRuntimePath,
|
||||
EditorIndentationSetup editorIndentation) {
|
||||
public ProjectLocalStudioSetup {
|
||||
prometeuRuntimePath = normalizeText(prometeuRuntimePath);
|
||||
editorIndentation = editorIndentation == null
|
||||
? EditorIndentationSetup.defaults()
|
||||
: editorIndentation.normalize();
|
||||
}
|
||||
|
||||
public static ProjectLocalStudioSetup defaults() {
|
||||
return new ProjectLocalStudioSetup(null, EditorIndentationSetup.defaults());
|
||||
}
|
||||
|
||||
private static String normalizeText(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
final String trimmed = value.trim();
|
||||
return trimmed.isEmpty() ? null : trimmed;
|
||||
}
|
||||
|
||||
public record EditorIndentationSetup(String mode, Integer width) {
|
||||
private static final String DEFAULT_MODE = "spaces";
|
||||
private static final int DEFAULT_WIDTH = 4;
|
||||
|
||||
public EditorIndentationSetup {
|
||||
mode = normalizeMode(mode);
|
||||
width = width == null || width <= 0 ? DEFAULT_WIDTH : width;
|
||||
}
|
||||
|
||||
public static EditorIndentationSetup defaults() {
|
||||
return new EditorIndentationSetup(DEFAULT_MODE, DEFAULT_WIDTH);
|
||||
}
|
||||
|
||||
public EditorIndentationSetup normalize() {
|
||||
return new EditorIndentationSetup(mode, width);
|
||||
}
|
||||
|
||||
public String statusLabel() {
|
||||
return "tabs".equals(mode) ? "Tabs: " + width : "Spaces: " + width;
|
||||
}
|
||||
|
||||
public String tabInsertion() {
|
||||
return " ".repeat(width);
|
||||
}
|
||||
|
||||
private static String normalizeMode(String value) {
|
||||
if (value == null) {
|
||||
return DEFAULT_MODE;
|
||||
}
|
||||
return switch (value.trim().toLowerCase()) {
|
||||
case "tabs" -> "tabs";
|
||||
default -> DEFAULT_MODE;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public record ProjectLocalStudioState(int version, ShellLayout shellLayout, OpenShellState openShellState) {
|
||||
public static final int CURRENT_VERSION = 1;
|
||||
|
||||
public ProjectLocalStudioState {
|
||||
version = version <= 0 ? CURRENT_VERSION : version;
|
||||
shellLayout = shellLayout == null ? ShellLayout.defaults() : shellLayout.normalize();
|
||||
openShellState = openShellState == null ? OpenShellState.defaults() : openShellState.normalize();
|
||||
}
|
||||
|
||||
public static ProjectLocalStudioState defaults() {
|
||||
return new ProjectLocalStudioState(CURRENT_VERSION, ShellLayout.defaults(), OpenShellState.defaults());
|
||||
}
|
||||
|
||||
public ProjectLocalStudioState withShellLayout(ShellLayout value) {
|
||||
return new ProjectLocalStudioState(version, value, openShellState);
|
||||
}
|
||||
|
||||
public ProjectLocalStudioState withOpenShellState(OpenShellState value) {
|
||||
return new ProjectLocalStudioState(version, shellLayout, value);
|
||||
}
|
||||
|
||||
public record ShellLayout(AssetsLayoutState assetsLayout) {
|
||||
public ShellLayout {
|
||||
assetsLayout = assetsLayout == null ? AssetsLayoutState.defaults() : assetsLayout.normalize();
|
||||
}
|
||||
|
||||
public static ShellLayout defaults() {
|
||||
return new ShellLayout(AssetsLayoutState.defaults());
|
||||
}
|
||||
|
||||
private ShellLayout normalize() {
|
||||
return new ShellLayout(assetsLayout);
|
||||
}
|
||||
}
|
||||
|
||||
public record AssetsLayoutState(List<Double> contentSplitDividers) {
|
||||
public AssetsLayoutState {
|
||||
contentSplitDividers = normalizeDividerPositions(contentSplitDividers);
|
||||
}
|
||||
|
||||
public static AssetsLayoutState defaults() {
|
||||
return new AssetsLayoutState(List.of());
|
||||
}
|
||||
|
||||
private AssetsLayoutState normalize() {
|
||||
return new AssetsLayoutState(contentSplitDividers);
|
||||
}
|
||||
}
|
||||
|
||||
public record OpenShellState(String selectedWorkspaceId) {
|
||||
public OpenShellState {
|
||||
selectedWorkspaceId = normalizeText(selectedWorkspaceId);
|
||||
if ("EDITOR".equals(selectedWorkspaceId)) {
|
||||
selectedWorkspaceId = "ASSETS";
|
||||
}
|
||||
}
|
||||
|
||||
public static OpenShellState defaults() {
|
||||
return new OpenShellState(null);
|
||||
}
|
||||
|
||||
private OpenShellState normalize() {
|
||||
return new OpenShellState(selectedWorkspaceId);
|
||||
}
|
||||
}
|
||||
|
||||
private static String normalizeText(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
final String trimmed = value.trim();
|
||||
return trimmed.isEmpty() ? null : trimmed;
|
||||
}
|
||||
|
||||
private static List<Double> normalizeDividerPositions(List<Double> values) {
|
||||
if (values == null || values.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
final List<Double> normalized = new ArrayList<>();
|
||||
for (Double value : values) {
|
||||
if (value != null && !value.isNaN() && !value.isInfinite()) {
|
||||
normalized.add(Math.max(0.0d, Math.min(1.0d, value)));
|
||||
}
|
||||
}
|
||||
return List.copyOf(normalized);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ProjectReference(
|
||||
String name,
|
||||
String version,
|
||||
String languageId,
|
||||
int stdlibVersion,
|
||||
ProjectTarget target,
|
||||
Path rootPath) {
|
||||
public ProjectReference {
|
||||
name = requireText(name, "name");
|
||||
version = requireText(version, "version");
|
||||
languageId = requireText(languageId, "languageId");
|
||||
if (stdlibVersion <= 0) {
|
||||
throw new IllegalArgumentException("stdlibVersion must be positive");
|
||||
}
|
||||
Objects.requireNonNull(target, "target");
|
||||
rootPath = Objects.requireNonNull(rootPath, "rootPath").toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private static String requireText(String value, String label) {
|
||||
final String normalized = Objects.requireNonNull(value, label).trim();
|
||||
if (normalized.isEmpty()) {
|
||||
throw new IllegalArgumentException(label + " must not be blank");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
public enum ProjectTarget {
|
||||
Game("Game"),
|
||||
Shell("Shell");
|
||||
|
||||
private final String reference;
|
||||
|
||||
ProjectTarget(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String exportReferenceName() {
|
||||
return reference;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.studio.api.project;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ProjectWorkspaceInitializer {
|
||||
void initialize(ProjectReference project);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package p.studio.api.runtime;
|
||||
|
||||
import p.studio.api.execution.ExecutionLogSeverity;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
public record RuntimeLogEntry(ExecutionLogSeverity severity, String message, Instant timestamp) {
|
||||
public RuntimeLogEntry {
|
||||
Objects.requireNonNull(severity, "severity");
|
||||
message = Objects.requireNonNull(message, "message").trim();
|
||||
if (message.isBlank()) throw new IllegalArgumentException("message must not be blank");
|
||||
timestamp = timestamp == null ? Instant.now() : timestamp;
|
||||
}
|
||||
|
||||
public static RuntimeLogEntry info(String message) {
|
||||
return new RuntimeLogEntry(ExecutionLogSeverity.INFO, message, Instant.now());
|
||||
}
|
||||
|
||||
public static RuntimeLogEntry error(String message) {
|
||||
return new RuntimeLogEntry(ExecutionLogSeverity.ERROR, message, Instant.now());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package p.studio.api.session;
|
||||
|
||||
import p.studio.api.execution.ExecutionSession;
|
||||
import p.studio.api.project.ProjectLocalStudioSetup;
|
||||
import p.studio.api.project.ProjectLocalStudioState;
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
public interface ProjectSession extends AutoCloseable {
|
||||
ProjectReference projectReference();
|
||||
|
||||
ProjectLocalStudioState projectLocalStudioState();
|
||||
|
||||
ProjectLocalStudioSetup projectLocalStudioSetup();
|
||||
|
||||
ExecutionSession executionSession();
|
||||
|
||||
void replaceProjectLocalStudioState(ProjectLocalStudioState state);
|
||||
|
||||
void saveProjectLocalStudioState();
|
||||
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.api.session;
|
||||
|
||||
import p.studio.api.project.ProjectReference;
|
||||
|
||||
public interface ProjectSessionFactory {
|
||||
ProjectSession open(ProjectReference projectReference);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user