Skip to content

Commit

Permalink
Auto hook up and save files when imporitng and meta data does not align
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Ski committed Oct 9, 2024
1 parent a8b2f06 commit 25fb2d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class AssetRepository extends BaseAssetRepository implements Observer {
private ObjectSet<FileHandle> newFilesSeen = new ObjectSet<>();


public static boolean dragAndDropping = false;

public <T> GameAsset<T> getAssetForUniqueIdentifier (UUID uuid, GameAssetType type) {
if (uniqueIdentifierGameAssetMap.containsKey(type)) {
if (uniqueIdentifierGameAssetMap.get(type).containsKey(uuid)) {
Expand Down Expand Up @@ -1305,8 +1307,15 @@ public GameAsset<?> createOrUpdateGameAssetForType (GameAssetType assetTypeFromE
}

VFXProjectData projectData = VFXProjectSerializer.readTalosTLSProject(value.handle, getTalosContext().getIdentifier());


((GameAsset<VFXProjectData>) gameAssetOut).setResourcePayload(projectData);

if (dragAndDropping) {
Toasts.getInstance().showInfoToast("Auto saved imported VFX " + value.handle.name());;
AssetRepository.getInstance().saveGameAssetResourceJsonToFile(gameAssetOut);
}

//This is mega hack. Only because we will be making it into DynamicNodeStage later
ParticleNodeEditorApp app = new ParticleNodeEditorApp();
app.loadProject(projectData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ private void handlePayloadDropToDirectory(GlobalDragAndDrop.BaseDragAndDropPaylo
}

if (!files.isEmpty()) {
AssetRepository.dragAndDropping = true;
asyncHandleFiles(files, targetDir, copy, 0);
}
}
Expand Down Expand Up @@ -571,6 +572,8 @@ private void asyncHandleFiles(Array<FileHandle> files, FileHandle targetDir, boo
// Note: fileHandle is current directory open in view
projectExplorerWidget.expand(fileHandle.path());
projectExplorerWidget.select(fileHandle.path());

AssetRepository.dragAndDropping = false;
});
} else {
moveFileHandle(source, targetDir, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static <U> GameAsset<U> readAsset (Json json, JsonValue jsonValue) {
return asset;
} else {
GameAsset<U> assetForUniqueIdentifier = baseAssetRepository.getAssetForUniqueIdentifier(uuid, type);
if (assetForUniqueIdentifier == null) {
if (assetForUniqueIdentifier == null || assetForUniqueIdentifier.isNonFound()) {
if (identifier != null) {
GameAsset<U> asset = baseAssetRepository.getAssetForIdentifier(identifier, type);
if (asset == null) {
Expand Down

0 comments on commit 25fb2d1

Please sign in to comment.