Browse Source

Asset Manager Update

This updates the asset manager to work better with the project manager by only allowing assets to be added to non-synced modules. Asset dialogs also open the project folder. Each asset now has a unique asset extension.
Peter Robinson 3 years ago
parent
commit
b42cfd8a37

+ 17 - 3
editor/AssetAdmin/NewAnimationAssetDialog.cs

@@ -105,7 +105,7 @@ function NewAnimationAssetDialog::Validate(%this)
 		%this.moduleNameBox.setText(%modSig);
 		%this.moduleNameBox.setText(%modSig);
 		%this.prevFolder = %folderPath;
 		%this.prevFolder = %folderPath;
 	}
 	}
-	%assetPath = %folderPath @ %assetName @ ".asset.taml";
+	%assetPath = pathConcat(%folderPath, %assetName @ ".animation.taml");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%assetID = %moduleName @ ":" @ %assetName;
 	%assetID = %moduleName @ ":" @ %assetName;
@@ -127,6 +127,20 @@ function NewAnimationAssetDialog::Validate(%this)
 		%this.feedback.setText("You can only create an animation asset inside of a module.");
 		%this.feedback.setText("You can only create an animation asset inside of a module.");
 		return false;
 		return false;
 	}
 	}
+	else
+	{
+		%module = ModuleDatabase.findModule(%moduleName, %moduleVersion);
+		if(!isObject(%module))
+		{
+			%this.feedback.setText("There was a problem finding the module for this asset.");
+			return false;
+		}
+		else if(%module.Synchronized)
+		{
+			%this.feedback.setText("You cannot add assets to a library module. Updates to the module would remove your assets. Instead, create your own module and add assets to it. Remember to have your module scan for assets.");
+			return false;
+		}
+	}
 
 
 	%button = AssetAdmin.Dictionary["AnimationAsset"].getButton(%assetID);
 	%button = AssetAdmin.Dictionary["AnimationAsset"].getButton(%assetID);
 	if(isObject(%button))
 	if(isObject(%button))
@@ -136,7 +150,7 @@ function NewAnimationAssetDialog::Validate(%this)
 	}
 	}
 
 
 	%this.createButton.active = true;
 	%this.createButton.active = true;
-	%this.feedback.setText("Press the Create button to open the new asset for editing.");
+	%this.feedback.setText("Press the Create button to open the new asset for editing. Your new asset will have the extension animation.taml. You must have your module scan the asset's folder for this extension.");
 	return true;
 	return true;
 }
 }
 
 
@@ -152,7 +166,7 @@ function NewAnimationAssetDialog::onCreate(%this)
 	{
 	{
 		%folderPath = %this.getFolderPath();
 		%folderPath = %this.getFolderPath();
 		%assetName = %this.assetNameBox.getText();
 		%assetName = %this.assetNameBox.getText();
-		%assetPath = %folderPath @ %assetName @ ".asset.taml";
+		%assetPath = pathConcat(%folderPath, %assetName @ ".animation.taml");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%assetID = %moduleName @ ":" @ %assetName;
 		%assetID = %moduleName @ ":" @ %assetName;

+ 17 - 3
editor/AssetAdmin/NewAudioAssetDialog.cs

@@ -90,7 +90,7 @@ function NewAudioAssetDialog::Validate(%this)
 		%this.moduleNameBox.setText(%modSig);
 		%this.moduleNameBox.setText(%modSig);
 		%this.prevFile = %file;
 		%this.prevFile = %file;
 	}
 	}
-	%assetPath = filePath(%file) @ "/" @ %assetName @ ".asset.taml";
+	%assetPath = pathConcat(filePath(%file), %assetName @ ".audio.taml");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%assetID = %moduleName @ ":" @ %assetName;
 	%assetID = %moduleName @ ":" @ %assetName;
@@ -119,6 +119,20 @@ function NewAudioAssetDialog::Validate(%this)
 		%this.feedback.setText("You can only create an audio asset inside of a module.");
 		%this.feedback.setText("You can only create an audio asset inside of a module.");
 		return false;
 		return false;
 	}
 	}
+	else
+	{
+		%module = ModuleDatabase.findModule(%moduleName, %moduleVersion);
+		if(!isObject(%module))
+		{
+			%this.feedback.setText("There was a problem finding the module for this asset.");
+			return false;
+		}
+		else if(%module.Synchronized)
+		{
+			%this.feedback.setText("You cannot add assets to a library module. Updates to the module would remove your assets. Instead, create your own module and add assets to it. Remember to have your module scan for assets.");
+			return false;
+		}
+	}
 
 
 	%button = AssetAdmin.Dictionary["AudioAsset"].getButton(%assetID);
 	%button = AssetAdmin.Dictionary["AudioAsset"].getButton(%assetID);
 	if(isObject(%button))
 	if(isObject(%button))
@@ -128,7 +142,7 @@ function NewAudioAssetDialog::Validate(%this)
 	}
 	}
 
 
 	%this.createButton.active = true;
 	%this.createButton.active = true;
-	%this.feedback.setText("Press the Create button to open the new asset for editing.");
+	%this.feedback.setText("Press the Create button to open the new asset for editing. Your new asset will have the extension audio.taml. You must have your module scan the asset's folder for this extension.");
 	return true;
 	return true;
 }
 }
 
 
@@ -144,7 +158,7 @@ function NewAudioAssetDialog::onCreate(%this)
 	{
 	{
 		%file = makeFullPath(%this.imageFileBox.getText());
 		%file = makeFullPath(%this.imageFileBox.getText());
 		%assetName = %this.assetNameBox.getText();
 		%assetName = %this.assetNameBox.getText();
-		%assetPath = filePath(%file) @ "/" @ %assetName @ ".asset.taml";
+		%assetPath = pathConcat(filePath(%file), %assetName @ ".audio.taml");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%assetID = %moduleName @ ":" @ %assetName;
 		%assetID = %moduleName @ ":" @ %assetName;

+ 17 - 3
editor/AssetAdmin/NewFontAssetDialog.cs

@@ -90,7 +90,7 @@ function NewFontAssetDialog::Validate(%this)
 		%this.moduleNameBox.setText(%modSig);
 		%this.moduleNameBox.setText(%modSig);
 		%this.prevFile = %file;
 		%this.prevFile = %file;
 	}
 	}
-	%assetPath = filePath(%file) @ "/" @ %assetName @ ".asset.taml";
+	%assetPath = pathConcat(filePath(%file), %assetName @ ".font.taml");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%assetID = %moduleName @ ":" @ %assetName;
 	%assetID = %moduleName @ ":" @ %assetName;
@@ -119,6 +119,20 @@ function NewFontAssetDialog::Validate(%this)
 		%this.feedback.setText("You can only create a font asset inside of a module.");
 		%this.feedback.setText("You can only create a font asset inside of a module.");
 		return false;
 		return false;
 	}
 	}
+	else
+	{
+		%module = ModuleDatabase.findModule(%moduleName, %moduleVersion);
+		if(!isObject(%module))
+		{
+			%this.feedback.setText("There was a problem finding the module for this asset.");
+			return false;
+		}
+		else if(%module.Synchronized)
+		{
+			%this.feedback.setText("You cannot add assets to a library module. Updates to the module would remove your assets. Instead, create your own module and add assets to it. Remember to have your module scan for assets.");
+			return false;
+		}
+	}
 
 
 	%button = AssetAdmin.Dictionary["FontAsset"].getButton(%assetID);
 	%button = AssetAdmin.Dictionary["FontAsset"].getButton(%assetID);
 	if(isObject(%button))
 	if(isObject(%button))
@@ -128,7 +142,7 @@ function NewFontAssetDialog::Validate(%this)
 	}
 	}
 
 
 	%this.createButton.active = true;
 	%this.createButton.active = true;
-	%this.feedback.setText("Press the Create button to open the new asset for editing.");
+	%this.feedback.setText("Press the Create button to open the new asset for editing. Your new asset will have the extension font.taml. You must have your module scan the asset's folder for this extension.");
 	return true;
 	return true;
 }
 }
 
 
@@ -144,7 +158,7 @@ function NewFontAssetDialog::onCreate(%this)
 	{
 	{
 		%file = makeFullPath(%this.imageFileBox.getText());
 		%file = makeFullPath(%this.imageFileBox.getText());
 		%assetName = %this.assetNameBox.getText();
 		%assetName = %this.assetNameBox.getText();
-		%assetPath = filePath(%file) @ "/" @ %assetName @ ".asset.taml";
+		%assetPath = pathConcat(filePath(%file), %assetName @ ".font.taml");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%assetID = %moduleName @ ":" @ %assetName;
 		%assetID = %moduleName @ ":" @ %assetName;

+ 17 - 3
editor/AssetAdmin/NewImageAssetDialog.cs

@@ -90,7 +90,7 @@ function NewImageAssetDialog::Validate(%this)
 		%this.moduleNameBox.setText(%modSig);
 		%this.moduleNameBox.setText(%modSig);
 		%this.prevFile = %file;
 		%this.prevFile = %file;
 	}
 	}
-	%assetPath = filePath(%file) @ "/" @ %assetName @ ".asset.taml";
+	%assetPath = pathConcat(filePath(%file), %assetName @ ".image.taml");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%assetID = %moduleName @ ":" @ %assetName;
 	%assetID = %moduleName @ ":" @ %assetName;
@@ -126,6 +126,20 @@ function NewImageAssetDialog::Validate(%this)
 		%this.feedback.setText("You can only create an image asset inside of a module.");
 		%this.feedback.setText("You can only create an image asset inside of a module.");
 		return false;
 		return false;
 	}
 	}
+	else
+	{
+		%module = ModuleDatabase.findModule(%moduleName, %moduleVersion);
+		if(!isObject(%module))
+		{
+			%this.feedback.setText("There was a problem finding the module for this asset.");
+			return false;
+		}
+		else if(%module.Synchronized)
+		{
+			%this.feedback.setText("You cannot add assets to a library module. Updates to the module would remove your assets. Instead, create your own module and add assets to it. Remember to have your module scan for assets.");
+			return false;
+		}
+	}
 
 
 	%button = AssetAdmin.Dictionary["ImageAsset"].getButton(%assetID);
 	%button = AssetAdmin.Dictionary["ImageAsset"].getButton(%assetID);
 	if(isObject(%button))
 	if(isObject(%button))
@@ -135,7 +149,7 @@ function NewImageAssetDialog::Validate(%this)
 	}
 	}
 
 
 	%this.createButton.active = true;
 	%this.createButton.active = true;
-	%this.feedback.setText("Press the Create button to open the new asset for editing.");
+	%this.feedback.setText("Press the Create button to open the new asset for editing. Your new asset will have the extension image.taml. You must have your module scan the asset's folder for this extension.");
 	return true;
 	return true;
 }
 }
 
 
@@ -151,7 +165,7 @@ function NewImageAssetDialog::onCreate(%this)
 	{
 	{
 		%file = makeFullPath(%this.imageFileBox.getText());
 		%file = makeFullPath(%this.imageFileBox.getText());
 		%assetName = %this.assetNameBox.getText();
 		%assetName = %this.assetNameBox.getText();
-		%assetPath = filePath(%file) @ "/" @ %assetName @ ".asset.taml";
+		%assetPath = pathConcat(filePath(%file), %assetName @ ".image.taml");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%assetID = %moduleName @ ":" @ %assetName;
 		%assetID = %moduleName @ ":" @ %assetName;

+ 17 - 3
editor/AssetAdmin/NewParticleAssetDialog.cs

@@ -116,7 +116,7 @@ function NewParticleAssetDialog::Validate(%this)
 		%this.moduleNameBox.setText(%modSig);
 		%this.moduleNameBox.setText(%modSig);
 		%this.prevFolder = %folderPath;
 		%this.prevFolder = %folderPath;
 	}
 	}
-	%assetPath = %folderPath @ %assetName @ ".asset.taml";
+	%assetPath = pathConcat(%folderPath, %assetName @ ".particle.taml");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 	%assetID = %moduleName @ ":" @ %assetName;
 	%assetID = %moduleName @ ":" @ %assetName;
@@ -138,6 +138,20 @@ function NewParticleAssetDialog::Validate(%this)
 		%this.feedback.setText("You can only create a particle asset inside of a module.");
 		%this.feedback.setText("You can only create a particle asset inside of a module.");
 		return false;
 		return false;
 	}
 	}
+	else
+	{
+		%module = ModuleDatabase.findModule(%moduleName, %moduleVersion);
+		if(!isObject(%module))
+		{
+			%this.feedback.setText("There was a problem finding the module for this asset.");
+			return false;
+		}
+		else if(%module.Synchronized)
+		{
+			%this.feedback.setText("You cannot add assets to a library module. Updates to the module would remove your assets. Instead, create your own module and add assets to it. Remember to have your module scan for assets.");
+			return false;
+		}
+	}
 
 
 	%button = AssetAdmin.Dictionary["ParticleAsset"].getButton(%assetID);
 	%button = AssetAdmin.Dictionary["ParticleAsset"].getButton(%assetID);
 	if(isObject(%button))
 	if(isObject(%button))
@@ -147,7 +161,7 @@ function NewParticleAssetDialog::Validate(%this)
 	}
 	}
 
 
 	%this.createButton.active = true;
 	%this.createButton.active = true;
-	%this.feedback.setText("Press the Create button to open the new asset for editing.");
+	%this.feedback.setText("Press the Create button to open the new asset for editing. Your new asset will have the extension particle.taml. You must have your module scan the asset's folder for this extension.");
 	return true;
 	return true;
 }
 }
 
 
@@ -163,7 +177,7 @@ function NewParticleAssetDialog::onCreate(%this)
 	{
 	{
 		%folderPath = %this.getFolderPath();
 		%folderPath = %this.getFolderPath();
 		%assetName = %this.assetNameBox.getText();
 		%assetName = %this.assetNameBox.getText();
-		%assetPath = %folderPath @ %assetName @ ".asset.taml";
+		%assetPath = pathConcat(%folderPath, %assetName @ ".particle.taml");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleName = getUnit(%this.moduleNameBox.getText(), 0, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%moduleVersion = getUnit(%this.moduleNameBox.getText(), 1, "_");
 		%assetID = %moduleName @ ":" @ %assetName;
 		%assetID = %moduleName @ ":" @ %assetName;

+ 4 - 2
editor/EditorCore/EditorForm.cs

@@ -77,13 +77,14 @@ function EditorForm::createFileOpenItem(%this, %label, %filters, %dialogTitle)
 
 
 function EditorForm::getFilePath(%this, %filter, %title, %textEdit)
 function EditorForm::getFilePath(%this, %filter, %title, %textEdit)
 {
 {
+	%path = pathConcat(getMainDotCsDir(), ProjectManager.getProjectFolder());
 	%dialog = new OpenFileDialog()
 	%dialog = new OpenFileDialog()
 	{
 	{
 		Filters = %filter;
 		Filters = %filter;
 		ChangePath = false;
 		ChangePath = false;
 		MultipleFiles = false;
 		MultipleFiles = false;
 		DefaultFile = "";
 		DefaultFile = "";
-		defaultPath = "./";
+		defaultPath = %path;
 		title = %title;
 		title = %title;
 	};
 	};
 	%result = %dialog.execute();
 	%result = %dialog.execute();
@@ -121,12 +122,13 @@ function EditorForm::createFolderOpenItem(%this, %label, %dialogTitle)
 
 
 function EditorForm::getFolderPath(%this, %title, %textEdit)
 function EditorForm::getFolderPath(%this, %title, %textEdit)
 {
 {
+	%path = pathConcat(getMainDotCsDir(), ProjectManager.getProjectFolder());
 	%dialog = new OpenFolderDialog()
 	%dialog = new OpenFolderDialog()
 	{
 	{
 		Filters = "All Files|*.*";
 		Filters = "All Files|*.*";
 		ChangePath = false;
 		ChangePath = false;
 		DefaultFile = "";
 		DefaultFile = "";
-		defaultPath = "./";
+		defaultPath = %path;
 		title = %title;
 		title = %title;
 	};
 	};
 	%result = %dialog.execute();
 	%result = %dialog.execute();

+ 11 - 3
library/BlankGame/module.taml

@@ -11,11 +11,19 @@
 	Dependencies="Audio=1">
 	Dependencies="Audio=1">
 		<DeclaredAssets
 		<DeclaredAssets
 			Path="sprites"
 			Path="sprites"
-			Extension="asset.taml"
+			Extension="image.taml"
+			Recurse="true"/>
+		<DeclaredAssets
+			Path="sprites"
+			Extension="animation.taml"
+			Recurse="true"/>
+		<DeclaredAssets
+			Path="gui"
+			Extension="image.taml"
 			Recurse="true"/>
 			Recurse="true"/>
 		<DeclaredAssets
 		<DeclaredAssets
 			Path="gui"
 			Path="gui"
-			Extension="asset.taml"
+			Extension="animation.taml"
 			Recurse="true"/>
 			Recurse="true"/>
 		<DeclaredAssets
 		<DeclaredAssets
 			Path="fonts"
 			Path="fonts"
@@ -23,7 +31,7 @@
 			Recurse="true"/>
 			Recurse="true"/>
 		<DeclaredAssets
 		<DeclaredAssets
 			Path="particles"
 			Path="particles"
-			Extension="asset.taml"
+			Extension="particle.taml"
 			Recurse="true"/>
 			Recurse="true"/>
 		<DeclaredAssets
 		<DeclaredAssets
 			Path="music"
 			Path="music"