mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Initial implementation of the Asset Browser tool.
This commit is contained in:
parent
3ae140e328
commit
1e5b9f4782
38 changed files with 8518 additions and 0 deletions
|
|
@ -0,0 +1,112 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
function AssetBrowser_addModuleWindow::onGainFirstResponder(%this)
|
||||
{
|
||||
%this-->moduleName.setFirstResponder();
|
||||
}
|
||||
|
||||
function AssetBrowser_addModuleWindow::close()
|
||||
{
|
||||
Canvas.popDialog(AssetBrowser_addModule);
|
||||
eval(AssetBrowser_addModuleWindow.callbackFunction);
|
||||
}
|
||||
|
||||
function AssetBrowser_addModuleWindow::CreateNewModule(%this)
|
||||
{
|
||||
%newModuleName = %this-->moduleName.getText();
|
||||
|
||||
if(%newModuleName $= "")
|
||||
return;
|
||||
|
||||
echo("Creating a new Module named: " @ %newModuleName);
|
||||
|
||||
%moduleFilePath = "data/" @ %newModuleName;
|
||||
%moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".module";
|
||||
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".cs";
|
||||
|
||||
%newModule = new ModuleDefinition()
|
||||
{
|
||||
ModuleId = %newModuleName;
|
||||
versionId = 1;
|
||||
ScriptFile = %newModuleName @ ".cs";
|
||||
CreateFunction="onCreate";
|
||||
DestroyFunction="onDestroy";
|
||||
Group = "Game";
|
||||
|
||||
new DeclaredAssets()
|
||||
{
|
||||
Extension = "asset.taml";
|
||||
Recurse = true;
|
||||
};
|
||||
};
|
||||
|
||||
TAMLWrite(%newModule, %moduleDefinitionFilePath);
|
||||
|
||||
//Now generate the script file for it
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%moduleScriptFilePath))
|
||||
{
|
||||
%file.writeline("function " @ %newModuleName @ "::onCreate(%this)\n{\n\n}\n");
|
||||
%file.writeline("function " @ %newModuleName @ "::onDestroy(%this)\n{\n\n}\n");
|
||||
|
||||
//todo, pre-write any event functions of interest
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
//force a refresh of our modules list
|
||||
ModuleDatabase.ignoreLoadedGroups(true);
|
||||
ModuleDatabase.scanModules();
|
||||
%success = ModuleDatabase.loadExplicit(%newModuleName, 1);
|
||||
ModuleDatabase.ignoreLoadedGroups(false);
|
||||
|
||||
//force a reload of the Module lists
|
||||
NewAssetModuleList.refresh();
|
||||
GameObjectModuleList.refresh();
|
||||
ImportAssetModuleList.refresh();
|
||||
|
||||
AssetBrowser.newModuleId = %newModuleName;
|
||||
|
||||
Canvas.popDialog(AssetBrowser_addModule);
|
||||
eval(AssetBrowser_addModuleWindow.callbackFunction);
|
||||
}
|
||||
|
||||
function AssetBrowserModuleList::onWake(%this)
|
||||
{
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function AssetBrowserModuleList::refresh(%this)
|
||||
{
|
||||
%this.clear();
|
||||
|
||||
//First, get our list of modules
|
||||
%moduleList = ModuleDatabase.findModules();
|
||||
|
||||
%count = getWordCount(%moduleList);
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%moduleName = getWord(%moduleList, %i);
|
||||
%this.add(%moduleName.ModuleId, %i);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
function AssetBrowser_addPackageWindow::onGainFirstResponder(%this)
|
||||
{
|
||||
%this-->packageName.setFirstResponder();
|
||||
}
|
||||
|
||||
function AssetBrowser_addPackageWindow::close()
|
||||
{
|
||||
Canvas.popDialog(AssetBrowser_addPackage);
|
||||
eval(AssetBrowser_addPackageWindow.callbackFunction);
|
||||
}
|
||||
|
||||
function AssetBrowser_addPackageWindow::CreateNewPackage(%this)
|
||||
{
|
||||
%newPackageName = %this-->packageName.getText();
|
||||
|
||||
if(%newPackageName $= "")
|
||||
return;
|
||||
|
||||
echo("Creating a new package named: " @ %newPackageName);
|
||||
|
||||
%moduleFilePath = "data/" @ %newPackageName;
|
||||
%moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newPackageName @ ".module";
|
||||
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newPackageName @ ".cs";
|
||||
|
||||
%newPackage = new ModuleDefinition()
|
||||
{
|
||||
ModuleId = %newPackageName;
|
||||
versionId = 1;
|
||||
ScriptFile = %newPackageName @ ".cs";
|
||||
CreateFunction="onCreate";
|
||||
DestroyFunction="onDestroy";
|
||||
Group = "Game";
|
||||
|
||||
new DeclaredAssets()
|
||||
{
|
||||
Extension = "asset.taml";
|
||||
Recurse = true;
|
||||
};
|
||||
};
|
||||
|
||||
TAMLWrite(%newPackage, %moduleDefinitionFilePath);
|
||||
|
||||
//Now generate the script file for it
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%moduleScriptFilePath))
|
||||
{
|
||||
%file.writeline("function " @ %newPackageName @ "::onCreate(%this)\n{\n\n}\n");
|
||||
%file.writeline("function " @ %newPackageName @ "::onDestroy(%this)\n{\n\n}\n");
|
||||
|
||||
//todo, pre-write any event functions of interest
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
//force a refresh of our modules list
|
||||
ModuleDatabase.ignoreLoadedGroups(true);
|
||||
ModuleDatabase.scanModules();
|
||||
%success = ModuleDatabase.loadExplicit(%newPackageName, 1);
|
||||
ModuleDatabase.ignoreLoadedGroups(false);
|
||||
|
||||
//force a reload of the package lists
|
||||
NewAssetPackageList.refresh();
|
||||
GameObjectPackageList.refresh();
|
||||
ImportAssetPackageList.refresh();
|
||||
|
||||
Canvas.popDialog(AssetBrowser_addPackage);
|
||||
eval(AssetBrowser_addPackageWindow.callbackFunction);
|
||||
}
|
||||
|
||||
function AssetBrowserPackageList::onWake(%this)
|
||||
{
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function AssetBrowserPackageList::refresh(%this)
|
||||
{
|
||||
%this.clear();
|
||||
|
||||
//First, get our list of modules
|
||||
%moduleList = ModuleDatabase.findModules();
|
||||
|
||||
%count = getWordCount(%moduleList);
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%moduleName = getWord(%moduleList, %i);
|
||||
%this.add(%moduleName.ModuleId, %i);
|
||||
}
|
||||
}
|
||||
1304
Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.cs
Normal file
1304
Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.cs
Normal file
File diff suppressed because it is too large
Load diff
1525
Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs
Normal file
1525
Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,472 @@
|
|||
function ImportAssetConfigList::onSelect( %this, %id, %text )
|
||||
{
|
||||
//Apply our settings to the assets
|
||||
echo("Changed our import config!");
|
||||
AssetBrowser.importAssetUnprocessedListArray.empty();
|
||||
AssetBrowser.importAssetUnprocessedListArray.duplicate(AssetBrowser.importAssetNewListArray);
|
||||
AssetBrowser.importAssetFinalListArray.empty();
|
||||
|
||||
ImportAssetWindow.activeImportConfigIndex = %id;
|
||||
ImportAssetWindow.activeImportConfig = ImportAssetWindow.importConfigsList.getKey(%id);
|
||||
ImportAssetWindow.refresh();
|
||||
}
|
||||
|
||||
function ImportAssetOptionsWindow::findMissingFile(%this, %assetItem)
|
||||
{
|
||||
if(%assetItem.assetType $= "Model")
|
||||
%filters = "Shape Files(*.dae, *.cached.dts)|*.dae;*.cached.dts";
|
||||
else if(%assetItem.assetType $= "Image")
|
||||
%filters = "Images Files(*.jpg,*.png,*.tga,*.bmp,*.dds)|*.jpg;*.png;*.tga;*.bmp;*.dds";
|
||||
|
||||
%dlg = new OpenFileDialog()
|
||||
{
|
||||
Filters = %filters;
|
||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||
DefaultFile = "";
|
||||
ChangePath = true;
|
||||
OverwritePrompt = true;
|
||||
forceRelativePath = false;
|
||||
//MultipleFiles = true;
|
||||
};
|
||||
|
||||
%ret = %dlg.Execute();
|
||||
|
||||
if ( %ret )
|
||||
{
|
||||
$Pref::WorldEditor::LastPath = filePath( %dlg.FileName );
|
||||
%fullPath = %dlg.FileName;//makeRelativePath( %dlg.FileName, getMainDotCSDir() );
|
||||
}
|
||||
|
||||
%dlg.delete();
|
||||
|
||||
if ( !%ret )
|
||||
return;
|
||||
|
||||
%assetItem.filePath = %fullPath;
|
||||
|
||||
ImportAssetWindow.refresh();
|
||||
}
|
||||
|
||||
//
|
||||
function ImportAssetOptionsWindow::editImportSettings(%this, %assetItem)
|
||||
{
|
||||
ImportAssetOptionsWindow.setVisible(1);
|
||||
ImportAssetOptionsWindow.selectWindow();
|
||||
|
||||
ImportOptionsList.clearFields();
|
||||
|
||||
%assetType = %assetItem.assetType;
|
||||
%filePath = %assetItem.filePath;
|
||||
%assetName = %assetItem.assetName;
|
||||
%assetConfigObj = %assetItem.importConfig;
|
||||
|
||||
ImportOptionsList.startGroup("Asset");
|
||||
ImportOptionsList.addField("AssetName", "Asset Name", "string", "", "NewAsset", "", %assetItem);
|
||||
ImportOptionsList.endGroup();
|
||||
|
||||
if(%assetType $= "Model")
|
||||
{
|
||||
//Get the shape info, so we know what we're doing with the mesh
|
||||
%shapeInfo = GetShapeInfo(%filePath);
|
||||
%meshItem = %shapeInfo.findItemByName("Meshes");
|
||||
%matItem = %shapeInfo.findItemByName("Materials");
|
||||
|
||||
%meshCount = %shapeInfo.getItemValue(%meshItem);
|
||||
%matCount = %shapeInfo.getItemValue(%matItem);
|
||||
|
||||
%firstMat = %shapeInfo.getChild(%matItem);
|
||||
echo("Mesh's first material texture path is: " @ %shapeInfo.getItemValue(%firstMat));
|
||||
|
||||
if(%meshCount > 0)
|
||||
{
|
||||
ImportOptionsList.startGroup("Mesh");
|
||||
ImportOptionsList.addField("AutogenCollisions", "Auto-gen Collisions", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("CollapseSubmeshes", "Collapse Submeshes", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("UpAxisOverride", "Up-Axis Override", "list", "", "Z_AXIS", "Z_AXIS,Y_AXIS,X_AXIS", %assetConfigObj);
|
||||
ImportOptionsList.addField("OverrideScale", "Override Scale", "float", "", "1.0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("IgnoreNodeScale", "IgnoreNodeScaling", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("AdjustCenter", "Adjust Center", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("CollapseSubmeshes", "Collapse Submeshes", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("AdjustFloor", "Adjust Floor", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("LODType", "LOD Type", "list", "", "TrailingNumber", "TrailingNumber,DetectDTS", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
}
|
||||
|
||||
if(%matItem > 0)
|
||||
{
|
||||
ImportOptionsList.startGroup("Material");
|
||||
ImportOptionsList.addCallbackField("ImportMaterials", "Import Materials", "bool", "", "1", "", "ImportMaterialsChanged", %assetConfigObj);
|
||||
ImportOptionsList.addField("UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
}
|
||||
}
|
||||
else if(%assetType $= "Material")
|
||||
{
|
||||
ImportOptionsList.startGroup("Material");
|
||||
ImportOptionsList.addField("CreateComposites", "Create Composite Textures", "bool", "", "1", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
}
|
||||
else if(%assetType $= "Image")
|
||||
{
|
||||
ImportOptionsList.startGroup("Formatting");
|
||||
ImportOptionsList.addField("ImageType", "Image Type", "string", "", "Diffuse", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("TextureFiltering", "Texture Filtering", "list", "", "Bilinear", "None,Bilinear,Trilinear", %assetConfigObj);
|
||||
ImportOptionsList.addField("UseMips", "Use Mips", "bool", "", "1", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("IsHDR", "Is HDR", "bool", "", "0", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
|
||||
ImportOptionsList.startGroup("Scaling");
|
||||
ImportOptionsList.addField("Scaling", "Scaling", "float", "", "1.0", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
|
||||
ImportOptionsList.startGroup("Compression");
|
||||
ImportOptionsList.addField("IsCompressed", "Is Compressed", "bool", "", "1", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
|
||||
ImportOptionsList.startGroup("Material");
|
||||
ImportOptionsList.addField("GenerateMaterialOnImport", "Generate Material On Import", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsList.addField("PopulateMaterialMaps", "Populate Material Maps", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsList.addField("UseDiffuseSuffixOnOriginImg", "Use Diffuse Suffix for Origin Image", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsList.addField("UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsList.endGroup();
|
||||
}
|
||||
else if(%assetType $= "Sound")
|
||||
{
|
||||
ImportOptionsList.startGroup("Adjustment");
|
||||
ImportOptionsList.addField("VolumeAdjust", "VolumeAdjustment", "float", "", "1.0", "", %assetConfigObj);
|
||||
ImportOptionsList.addField("PitchAdjust", "PitchAdjustment", "float", "", "1.0", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
|
||||
ImportOptionsList.startGroup("Compression");
|
||||
ImportOptionsList.addField("IsCompressed", "Is Compressed", "bool", "", "1", "", %assetConfigObj);
|
||||
ImportOptionsList.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
function ImportAssetOptionsWindow::deleteImportingAsset(%this, %assetItem)
|
||||
{
|
||||
%assetIndex = AssetBrowser.importAssetNewListArray.getIndexFromKey(%assetItem);
|
||||
AssetBrowser.importAssetNewListArray.erase(%assetIndex);
|
||||
|
||||
//check if we have any child assets and remove them as well
|
||||
for(%i=0; %i < AssetBrowser.importAssetNewListArray.count(); %i++)
|
||||
{
|
||||
%asset = AssetBrowser.importAssetNewListArray.getKey(%i);
|
||||
if(%asset.ParentAssetItem == %assetItem)
|
||||
{
|
||||
AssetBrowser.importAssetNewListArray.erase(%i);
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
|
||||
%assetIndex = AssetBrowser.importAssetFinalListArray.getIndexFromKey(%assetItem);
|
||||
AssetBrowser.importAssetFinalListArray.erase(%assetIndex);
|
||||
|
||||
//check if we have any child assets and remove them as well
|
||||
for(%i=0; %i < AssetBrowser.importAssetFinalListArray.count(); %i++)
|
||||
{
|
||||
%asset = AssetBrowser.importAssetFinalListArray.getKey(%i);
|
||||
if(%asset.ParentAssetItem == %assetItem)
|
||||
{
|
||||
AssetBrowser.importAssetFinalListArray.erase(%i);
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
|
||||
ImportAssetWindow.refresh();
|
||||
ImportAssetOptionsWindow.setVisible(0);
|
||||
}
|
||||
|
||||
function ImportAssetOptionsWindow::saveAssetOptions(%this)
|
||||
{
|
||||
ImportAssetWindow.refresh();
|
||||
ImportAssetOptionsWindow.setVisible(0);
|
||||
}
|
||||
|
||||
function ImportOptionsList::ImportMaterialsChanged(%this, %fieldName, %newValue, %ownerObject)
|
||||
{
|
||||
echo("CHANGED IF OUR IMPORTED MATERIALS WERE HAPPENING!");
|
||||
}
|
||||
|
||||
function ImportAssetConfigEditorWindow::populateConfigList(%this, %optionsObj)
|
||||
{
|
||||
AssetImportConfigName.setText(%optionsObj.Name);
|
||||
|
||||
ImportOptionsConfigList.clear();
|
||||
|
||||
ImportOptionsConfigList.startGroup("Mesh");
|
||||
ImportOptionsConfigList.addCallbackField("ImportMesh", "Import Mesh", "bool", "", "1", "", "ToggleImportMesh", %optionsObj);
|
||||
ImportOptionsConfigList.addField("DoUpAxisOverride", "Do Up-axis Override", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("UpAxisOverride", "Up-axis Override", "list", "", "Z_AXIS", "X_AXIS,Y_AXIS,Z_AXIS", %optionsObj);
|
||||
ImportOptionsConfigList.addField("DoScaleOverride", "Do Scale Override", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("ScaleOverride", "Scale Override", "float", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("IgnoreNodeScale", "Ignore Node Scale", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("AdjustCenter", "Adjust Center", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("AdjustFloor", "Adjust Floor", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("CollapseSubmeshes", "Collapse Submeshes", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("LODType", "LOD Type", "list", "", "TrailingNumber", "TrailingNumber,DetectDTS", %optionsObj);
|
||||
//ImportOptionsConfigList.addField("TrailingNumber", "Trailing Number", "float", "", "2", "", %optionsObj, "Mesh");
|
||||
ImportOptionsConfigList.addField("ImportedNodes", "Imported Nodes", "command", "", "", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("IgnoreNodes", "Ignore Nodes", "command", "", "", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("ImportMeshes", "Import Meshes", "command", "", "", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("IgnoreMeshes", "Imported Meshes", "command", "", "", "", %optionsObj);
|
||||
ImportOptionsConfigList.endGroup();
|
||||
|
||||
//Materials
|
||||
ImportOptionsConfigList.startGroup("Material");
|
||||
ImportOptionsConfigList.addField("ImportMaterials", "Import Materials", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("CreateComposites", "Create Composites", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("UseDiffuseSuffixOnOriginImg", "Use Diffuse Suffix for Origin Image", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("IgnoreMaterials", "Ignore Materials", "command", "", "", "", %optionsObj);
|
||||
ImportOptionsConfigList.endGroup();
|
||||
|
||||
//Animations
|
||||
ImportOptionsConfigList.startGroup("Animations");
|
||||
ImportOptionsConfigList.addField("ImportAnimations", "Import Animations", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("SeparateAnimations", "Separate Animations", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("SeparateAnimationPrefix", "Separate Animation Prefix", "string", "", "", "", %optionsObj);
|
||||
ImportOptionsConfigList.endGroup();
|
||||
|
||||
//Collision
|
||||
ImportOptionsConfigList.startGroup("Collision");
|
||||
ImportOptionsConfigList.addField("GenerateCollisions", "Generate Collisions", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("GenCollisionType", "Generate Collision Type", "list", "", "CollisionMesh", "CollisionMesh,ConvexHull", %optionsObj);
|
||||
ImportOptionsConfigList.addField("CollisionMeshPrefix", "CollisionMesh Prefix", "string", "", "Col", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("GenerateLOSCollisions", "Generate LOS Collisions", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("GenLOSCollisionType", "Generate LOS Collision Type", "list", "", "CollisionMesh", "CollisionMesh,ConvexHull", %optionsObj);
|
||||
ImportOptionsConfigList.addField("LOSCollisionMeshPrefix", "LOS CollisionMesh Prefix", "string", "", "LOS", "", %optionsObj);
|
||||
ImportOptionsConfigList.endGroup();
|
||||
|
||||
//Images
|
||||
ImportOptionsConfigList.startGroup("Image");
|
||||
ImportOptionsConfigList.addField("ImageType", "Image Type", "list", "", "N/A", "N/A,Diffuse,Normal,Specular,Metalness,Roughness,AO,Composite,GUI", %optionsObj);
|
||||
ImportOptionsConfigList.addField("DiffuseTypeSuffixes", "Diffuse Type Suffixes", "command", "", "_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("NormalTypeSuffixes", "Normal Type Suffixes", "command", "", "_NORMAL,_NORM", "", %optionsObj);
|
||||
|
||||
if(EditorSettings.lightingModel $= "Legacy")
|
||||
{
|
||||
ImportOptionsConfigList.addField("SpecularTypeSuffixes", "Specular Type Suffixes", "command", "", "_SPECULAR,_SPEC", "", %optionsObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImportOptionsConfigList.addField("MetalnessTypeSuffixes", "Metalness Type Suffixes", "command", "", "_METAL,_MET,_METALNESS,_METALLIC", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("RoughnessTypeSuffixes", "Roughness Type Suffixes", "command", "", "_ROUGH,_ROUGHNESS", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("SmoothnessTypeSuffixes", "Smoothness Type Suffixes", "command", "", "_SMOOTH,_SMOOTHNESS", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("AOTypeSuffixes", "AO Type Suffixes", "command", "", "_AO,_AMBIENT,_AMBIENTOCCLUSION", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("CompositeTypeSuffixes", "Composite Type Suffixes", "command", "", "_COMP,_COMPOSITE", "", %optionsObj);
|
||||
}
|
||||
|
||||
ImportOptionsConfigList.addField("TextureFilteringMode", "Texture Filtering Mode", "list", "", "Bilinear", "None,Bilinear,Trilinear", %optionsObj);
|
||||
ImportOptionsConfigList.addField("UseMips", "Use Mipmaps", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("IsHDR", "Is HDR", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("Scaling", "Scaling", "float", "", "1.0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("Compressed", "Is Compressed", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("GenerateMaterialOnImport", "Generate Material On Import", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("PopulateMaterialMaps", "Populate Material Maps", "bool", "", "1", "", %optionsObj);
|
||||
ImportOptionsConfigList.endGroup();
|
||||
|
||||
//Sounds
|
||||
ImportOptionsConfigList.startGroup("Sound");
|
||||
ImportOptionsConfigList.addField("VolumeAdjust", "Volume Adjustment", "float", "", "1.0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("PitchAdjust", "Pitch Adjustment", "float", "", "1.0", "", %optionsObj);
|
||||
ImportOptionsConfigList.addField("Compressed", "Is Compressed", "bool", "", "0", "", %optionsObj);
|
||||
ImportOptionsConfigList.endGroup();
|
||||
}
|
||||
|
||||
function ImportAssetConfigEditorWindow::addNewConfig(%this)
|
||||
{
|
||||
ImportAssetConfigEditorWindow.setVisible(1);
|
||||
ImportAssetConfigEditorWindow.selectWindow();
|
||||
|
||||
%optionsObj = new ScriptObject(){};
|
||||
|
||||
ImportAssetWindow.importConfigsList.add(%optionsObj);
|
||||
|
||||
//Initial, blank configuration
|
||||
%optionsObj.ImportMesh = true;
|
||||
%optionsObj.DoUpAxisOverride = false;
|
||||
%optionsObj.UpAxisOverride = "Z_AXIS";
|
||||
%optionsObj.DoScaleOverride = false;
|
||||
%optionsObj.ScaleOverride = 1.0;
|
||||
%optionsObj.IgnoreNodeScale = false;
|
||||
%optionsObj.AdjustCenter = false;
|
||||
%optionsObj.AdjustFloor = false;
|
||||
%optionsObj.CollapseSubmeshes = false;
|
||||
%optionsObj.LODType = "TrailingNumber";
|
||||
//%optionsObj.TrailingNumber = 2;
|
||||
%optionsObj.ImportedNodes = "";
|
||||
%optionsObj.IgnoreNodes = "";
|
||||
%optionsObj.ImportMeshes = "";
|
||||
%optionsObj.IgnoreMeshes = "";
|
||||
|
||||
//Materials
|
||||
%optionsObj.ImportMaterials = true;
|
||||
%optionsObj.CreateComposites = true;
|
||||
%optionsObj.UseDiffuseSuffixOnOriginImg = true;
|
||||
%optionsObj.UseExistingMaterials = true;
|
||||
|
||||
//Animations
|
||||
%optionsObj.ImportAnimations = true;
|
||||
%optionsObj.SeparateAnimations = true;
|
||||
%optionsObj.SeparateAnimationPrefix = "";
|
||||
|
||||
//Collision
|
||||
%optionsObj.GenerateCollisions = true;
|
||||
%optionsObj.GenCollisionType = "CollisionMesh";
|
||||
%optionsObj.CollisionMeshPrefix = "Col";
|
||||
%optionsObj.GenerateLOSCollisions = true;
|
||||
%optionsObj.GenLOSCollisionType = "CollisionMesh";
|
||||
%optionsObj.LOSCollisionMeshPrefix = "LOS";
|
||||
|
||||
//Images
|
||||
%optionsObj.ImageType = "N/A";
|
||||
%optionsObj.DiffuseTypeSuffixes = "_ALBEDO;_DIFFUSE;_ALB;_DIF;_COLOR;_COL;_BASECOLOR;_BASE_COLOR";
|
||||
%optionsObj.NormalTypeSuffixes = "_NORMAL;_NORM";
|
||||
%optionsObj.SpecularTypeSuffixes = "_SPECULAR;_SPEC";
|
||||
%optionsObj.MetalnessTypeSuffixes = "_METAL;_MET;_METALNESS;_METALLIC";
|
||||
%optionsObj.RoughnessTypeSuffixes = "_ROUGH;_ROUGHNESS";
|
||||
%optionsObj.SmoothnessTypeSuffixes = "_SMOOTH;_SMOOTHNESS";
|
||||
%optionsObj.AOTypeSuffixes = "_AO;_AMBIENT;_AMBIENTOCCLUSION";
|
||||
%optionsObj.CompositeTypeSuffixes = "_COMP;_COMPOSITE";
|
||||
%optionsObj.TextureFilteringMode = "Bilinear";
|
||||
%optionsObj.UseMips = true;
|
||||
%optionsObj.IsHDR = false;
|
||||
%optionsObj.Scaling = 1.0;
|
||||
%optionsObj.Compressed = true;
|
||||
%optionsObj.GenerateMaterialOnImport = true;
|
||||
%optionsObj.PopulateMaterialMaps = true;
|
||||
|
||||
//Sounds
|
||||
%optionsObj.VolumeAdjust = 1.0;
|
||||
%optionsObj.PitchAdjust = 1.0;
|
||||
%optionsObj.Compressed = false;
|
||||
|
||||
//Hook in the UI
|
||||
%this.populateConfigList(%optionsObj);
|
||||
}
|
||||
|
||||
function ImportAssetConfigEditorWindow::editConfig(%this)
|
||||
{
|
||||
ImportAssetConfigEditorWindow.setVisible(1);
|
||||
ImportAssetConfigEditorWindow.selectWindow();
|
||||
|
||||
%this.populateConfigList(ImportAssetWindow.activeImportConfig);
|
||||
}
|
||||
|
||||
function ImportAssetConfigEditorWindow::deleteConfig(%this)
|
||||
{
|
||||
ImportAssetWindow.importConfigsList.erase(ImportAssetWindow.activeImportConfigIndex);
|
||||
ImportAssetConfigList.setSelected(0); //update it
|
||||
|
||||
ImportAssetConfigEditorWindow.saveAssetOptionsConfig();
|
||||
}
|
||||
|
||||
function ImportAssetConfigEditorWindow::saveAssetOptionsConfig(%this)
|
||||
{
|
||||
%xmlDoc = new SimXMLDocument();
|
||||
|
||||
%xmlDoc.pushNewElement("AssetImportConfigs");
|
||||
|
||||
for(%i = 0; %i < ImportAssetWindow.importConfigsList.count(); %i++)
|
||||
{
|
||||
%configObj = ImportAssetWindow.importConfigsList.getKey(%i);
|
||||
|
||||
%xmlDoc.pushNewElement("Config");
|
||||
|
||||
if(%configObj.Name $= "")
|
||||
%configObj.Name = AssetImportConfigName.getText();
|
||||
|
||||
%xmlDoc.setAttribute("Name", %configObj.Name);
|
||||
|
||||
%xmlDoc.pushNewElement("Mesh");
|
||||
%xmlDoc.setAttribute("ImportMesh", %configObj.ImportMesh);
|
||||
%xmlDoc.setAttribute("DoUpAxisOverride", %configObj.DoUpAxisOverride);
|
||||
%xmlDoc.setAttribute("UpAxisOverride", %configObj.UpAxisOverride);
|
||||
%xmlDoc.setAttribute("DoScaleOverride", %configObj.DoScaleOverride);
|
||||
%xmlDoc.setAttribute("ScaleOverride", %configObj.ScaleOverride);
|
||||
%xmlDoc.setAttribute("IgnoreNodeScale", %configObj.IgnoreNodeScale);
|
||||
%xmlDoc.setAttribute("AdjustCenter", %configObj.AdjustCenter);
|
||||
%xmlDoc.setAttribute("AdjustFloor", %configObj.AdjustFloor);
|
||||
%xmlDoc.setAttribute("CollapseSubmeshes", %configObj.CollapseSubmeshes);
|
||||
%xmlDoc.setAttribute("LODType", %configObj.LODType);
|
||||
%xmlDoc.setAttribute("ImportedNodes", %configObj.ImportedNodes);
|
||||
%xmlDoc.setAttribute("IgnoreNodes", %configObj.IgnoreNodes);
|
||||
%xmlDoc.setAttribute("ImportMeshes", %configObj.ImportMeshes);
|
||||
%xmlDoc.setAttribute("IgnoreMeshes", %configObj.IgnoreMeshes);
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.pushNewElement("Materials");
|
||||
%xmlDoc.setAttribute("ImportMaterials", %configObj.ImportMaterials);
|
||||
%xmlDoc.setAttribute("CreateComposites", %configObj.CreateComposites);
|
||||
%xmlDoc.setAttribute("UseDiffuseSuffixOnOriginImg", %configObj.UseDiffuseSuffixOnOriginImg);
|
||||
%xmlDoc.setAttribute("UseExistingMaterials", %configObj.UseExistingMaterials);
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.pushNewElement("Animations");
|
||||
%xmlDoc.setAttribute("ImportAnimations", %configObj.ImportAnimations);
|
||||
%xmlDoc.setAttribute("SeparateAnimations", %configObj.SeparateAnimations);
|
||||
%xmlDoc.setAttribute("SeparateAnimationPrefix", %configObj.SeparateAnimationPrefix);
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.pushNewElement("Collisions");
|
||||
%xmlDoc.setAttribute("GenerateCollisions", %configObj.GenerateCollisions);
|
||||
%xmlDoc.setAttribute("GenCollisionType", %configObj.GenCollisionType);
|
||||
%xmlDoc.setAttribute("CollisionMeshPrefix", %configObj.CollisionMeshPrefix);
|
||||
%xmlDoc.setAttribute("GenerateLOSCollisions", %configObj.GenerateLOSCollisions);
|
||||
%xmlDoc.setAttribute("GenLOSCollisionType", %configObj.GenLOSCollisionType);
|
||||
%xmlDoc.setAttribute("LOSCollisionMeshPrefix", %configObj.LOSCollisionMeshPrefix);
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.pushNewElement("Images");
|
||||
%xmlDoc.setAttribute("ImageType", %configObj.ImageType);
|
||||
%xmlDoc.setAttribute("DiffuseTypeSuffixes", %configObj.DiffuseTypeSuffixes);
|
||||
%xmlDoc.setAttribute("NormalTypeSuffixes", %configObj.NormalTypeSuffixes);
|
||||
%xmlDoc.setAttribute("SpecularTypeSuffixes", %configObj.SpecularTypeSuffixes);
|
||||
%xmlDoc.setAttribute("MetalnessTypeSuffixes", %configObj.MetalnessTypeSuffixes);
|
||||
%xmlDoc.setAttribute("RoughnessTypeSuffixes", %configObj.RoughnessTypeSuffixes);
|
||||
%xmlDoc.setAttribute("SmoothnessTypeSuffixes", %configObj.SmoothnessTypeSuffixes);
|
||||
%xmlDoc.setAttribute("AOTypeSuffixes", %configObj.AOTypeSuffixes);
|
||||
%xmlDoc.setAttribute("CompositeTypeSuffixes", %configObj.CompositeTypeSuffixes);
|
||||
%xmlDoc.setAttribute("TextureFilteringMode", %configObj.TextureFilteringMode);
|
||||
%xmlDoc.setAttribute("UseMips", %configObj.UseMips);
|
||||
%xmlDoc.setAttribute("IsHDR", %configObj.IsHDR);
|
||||
%xmlDoc.setAttribute("Scaling", %configObj.Scaling);
|
||||
%xmlDoc.setAttribute("Compressed", %configObj.Compressed);
|
||||
%xmlDoc.setAttribute("GenerateMaterialOnImport", %configObj.GenerateMaterialOnImport);
|
||||
%xmlDoc.setAttribute("PopulateMaterialMaps", %configObj.PopulateMaterialMaps);
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.pushNewElement("Sounds");
|
||||
%xmlDoc.setAttribute("VolumeAdjust", %configObj.VolumeAdjust);
|
||||
%xmlDoc.setAttribute("PitchAdjust", %configObj.PitchAdjust);
|
||||
%xmlDoc.setAttribute("Compressed", %configObj.Compressed);
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.popElement();
|
||||
}
|
||||
|
||||
%xmlDoc.popElement();
|
||||
|
||||
%xmlDoc.saveFile($AssetBrowser::importConfigsFile);
|
||||
|
||||
ImportAssetConfigEditorWindow.setVisible(0);
|
||||
ImportAssetWindow.reloadImportOptionConfigs();
|
||||
}
|
||||
|
||||
function ImportOptionsConfigList::ToggleImportMesh(%this, %fieldName, %newValue, %ownerObject)
|
||||
{
|
||||
%this.setFieldEnabled("DoUpAxisOverride", %newValue);
|
||||
%this.setFieldEnabled("UpAxisOverride", %newValue);
|
||||
%this.setFieldEnabled("DoScaleOverride", %newValue);
|
||||
%this.setFieldEnabled("ScaleOverride", %newValue);
|
||||
%this.setFieldEnabled("IgnoreNodeScale", %newValue);
|
||||
%this.setFieldEnabled("AdjustCenter", %newValue);
|
||||
%this.setFieldEnabled("AdjustFloor", %newValue);
|
||||
%this.setFieldEnabled("CollapseSubmeshes", %newValue);
|
||||
%this.setFieldEnabled("LODType", %newValue);
|
||||
%this.setFieldEnabled("ImportedNodes", %newValue);
|
||||
%this.setFieldEnabled("IgnoreNodes", %newValue);
|
||||
%this.setFieldEnabled("ImportMeshes", %newValue);
|
||||
%this.setFieldEnabled("IgnoreMeshes", %newValue);
|
||||
}
|
||||
371
Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs
Normal file
371
Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs
Normal file
|
|
@ -0,0 +1,371 @@
|
|||
function AssetBrowser_editAsset::saveAsset(%this)
|
||||
{
|
||||
%file = AssetDatabase.getAssetFilePath(%this.editedAssetId);
|
||||
%success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
Canvas.popDialog(AssetBrowser_editAsset);
|
||||
}
|
||||
|
||||
function AssetBrowser::editAsset(%this)
|
||||
{
|
||||
//Find out what type it is
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%assetType = %assetDef.getClassName();
|
||||
|
||||
if(%assetType $= "MaterialAsset")
|
||||
{
|
||||
//if(EditorSettings.materialEditMode $= "MaterialEditor")
|
||||
//{
|
||||
%assetDef.materialDefinitionName.reload();
|
||||
|
||||
EditorGui.setEditor(MaterialEditorPlugin);
|
||||
|
||||
MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
|
||||
MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName );
|
||||
|
||||
AssetBrowser.hideDialog();
|
||||
/*}
|
||||
else
|
||||
{
|
||||
Canvas.pushDialog(ShaderEditor);
|
||||
ShaderEditorGraph.loadGraph(%assetDef.shaderGraph);
|
||||
$ShaderGen::targetShaderFile = filePath(%assetDef.shaderGraph) @"/"@fileBase(%assetDef.shaderGraph);
|
||||
}*/
|
||||
}
|
||||
else if(%assetType $= "StateMachineAsset")
|
||||
{
|
||||
eval("AssetBrowser.tempAsset = new " @ %assetDef.getClassName() @ "();");
|
||||
AssetBrowser.tempAsset.assignFieldsFrom(%assetDef);
|
||||
|
||||
SMAssetEditInspector.inspect(AssetBrowser.tempAsset);
|
||||
AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
|
||||
AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < SMAssetEditInspector.getCount(); %i++)
|
||||
{
|
||||
%caption = SMAssetEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
||||
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
||||
{
|
||||
SMAssetEditInspector.remove(SMAssetEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
|
||||
Canvas.pushDialog(StateMachineEditor);
|
||||
StateMachineEditor.loadStateMachineAsset(EditAssetPopup.assetId);
|
||||
StateMachineEditor-->Window.text = "State Machine Editor ("@EditAssetPopup.assetId@")";
|
||||
}
|
||||
else if(%assetType $= "ComponentAsset")
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%scriptFile = %assetDef.scriptFile;
|
||||
|
||||
EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
|
||||
}
|
||||
else if(%assetType $= "GameObjectAsset")
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%scriptFile = %assetDef.scriptFilePath;
|
||||
|
||||
EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
|
||||
}
|
||||
else if(%assetType $= "ScriptAsset")
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%scriptFile = %assetDef.scriptFilePath;
|
||||
|
||||
EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
|
||||
}
|
||||
else if(%assetType $= "ShapeAsset")
|
||||
{
|
||||
%this.hideDialog();
|
||||
ShapeEditorPlugin.openShapeAsset(EditAssetPopup.assetId);
|
||||
}
|
||||
else if(%assetType $= "ShapeAnimationAsset")
|
||||
{
|
||||
%this.hideDialog();
|
||||
ShapeEditorPlugin.openShapeAsset(EditAssetPopup.assetId);
|
||||
}
|
||||
else if(%assetType $= "LevelAsset")
|
||||
{
|
||||
schedule( 1, 0, "EditorOpenMission", %assetDef.LevelFile);
|
||||
}
|
||||
else if(%assetType $= "GUIAsset")
|
||||
{
|
||||
if(!isObject(%assetDef.assetName))
|
||||
{
|
||||
exec(%assetDef.GUIFilePath);
|
||||
exec(%assetDef.mScriptFilePath);
|
||||
}
|
||||
|
||||
GuiEditContent(%assetDef.assetName);
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::editAssetInfo(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_editAsset);
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
|
||||
eval("AssetBrowser.tempAsset = new " @ %assetDef.getClassName() @ "();");
|
||||
AssetBrowser.tempAsset.assignFieldsFrom(%assetDef);
|
||||
|
||||
AssetEditInspector.inspect(AssetBrowser.tempAsset);
|
||||
AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
|
||||
AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
|
||||
{
|
||||
%caption = AssetEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
||||
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
||||
{
|
||||
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
function AssetBrowser::refreshAsset(%this, %assetId)
|
||||
{
|
||||
if(%assetId $= "")
|
||||
{
|
||||
//if we have no passed-in asset ID, we're probably going through the popup menu, so get our edit popup id
|
||||
%assetId = EditAssetPopup.assetId;
|
||||
}
|
||||
|
||||
AssetDatabase.refreshAsset(%assetId);
|
||||
AssetBrowser.refreshPreviews();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
function AssetBrowser::renameAsset(%this)
|
||||
{
|
||||
//Find out what type it is
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
|
||||
%curFirstResponder = AssetBrowser.getFirstResponder();
|
||||
|
||||
if(%curFirstResponder != 0)
|
||||
%curFirstResponder.clearFirstResponder();
|
||||
|
||||
AssetBrowser.selectedAssetPreview-->AssetNameLabel.setActive(true);
|
||||
AssetBrowser.selectedAssetPreview-->AssetNameLabel.setFirstResponder();
|
||||
}
|
||||
|
||||
function AssetNameField::onReturn(%this)
|
||||
{
|
||||
//if the name is different to the asset's original name, rename it!
|
||||
%newName = %this.getText();
|
||||
if(%this.originalAssetName !$= %this.getText())
|
||||
{
|
||||
%moduleName = AssetBrowser.selectedModule;
|
||||
|
||||
//do a rename!
|
||||
%success = AssetDatabase.renameDeclaredAsset(%moduleName @ ":" @ %this.originalAssetName, %moduleName @ ":" @ %this.getText());
|
||||
|
||||
if(%success)
|
||||
{
|
||||
%newAssetId = %moduleName @ ":" @ %this.getText();
|
||||
%assetPath = AssetDatabase.getAssetFilePath(%newAssetId);
|
||||
|
||||
//Rename any associated files as well
|
||||
%assetDef = AssetDatabase.acquireAsset(%newAssetId);
|
||||
%assetType = %assetDef.getClassName();
|
||||
|
||||
//rename the file to match
|
||||
%path = filePath(%assetPath);
|
||||
|
||||
if(%assetType $= "ComponentAsset")
|
||||
{
|
||||
%oldScriptFilePath = %assetDef.scriptFile;
|
||||
%scriptFilePath = filePath(%assetDef.scriptFile);
|
||||
%scriptExt = fileExt(%assetDef.scriptFile);
|
||||
|
||||
%newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
|
||||
%newAssetFile = %path @ "/" @ %this.getText() @ ".asset.taml";
|
||||
|
||||
%assetDef.componentName = %newName;
|
||||
%assetDef.scriptFile = %newScriptFileName;
|
||||
|
||||
TamlWrite(%assetDef, %newAssetFile);
|
||||
fileDelete(%assetPath);
|
||||
|
||||
pathCopy(%oldScriptFilePath, %newScriptFileName);
|
||||
fileDelete(%oldScriptFilePath);
|
||||
|
||||
//Go through our scriptfile and replace the old namespace with the new
|
||||
%editedFileContents = "";
|
||||
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %newScriptFileName ) )
|
||||
{
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %this.originalAssetName, %newName) @ "\n";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%newScriptFileName);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
exec(%newScriptFileName);
|
||||
}
|
||||
else if(%assetType $= "StateMachineAsset")
|
||||
{
|
||||
%oldScriptFilePath = %assetDef.stateMachineFile;
|
||||
%scriptFilePath = filePath(%assetDef.stateMachineFile);
|
||||
%scriptExt = fileExt(%assetDef.stateMachineFile);
|
||||
|
||||
%newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
|
||||
%newAssetFile = %path @ "/" @ %this.getText() @ ".asset.taml";
|
||||
|
||||
%assetDef.stateMachineFile = %newScriptFileName;
|
||||
|
||||
TamlWrite(%assetDef, %newAssetFile);
|
||||
fileDelete(%assetPath);
|
||||
|
||||
pathCopy(%oldScriptFilePath, %newScriptFileName);
|
||||
fileDelete(%oldScriptFilePath);
|
||||
}
|
||||
else if(%assetType $= "GameObjectAsset")
|
||||
{
|
||||
%oldScriptFilePath = %assetDef.scriptFilePath;
|
||||
%scriptFilePath = filePath(%assetDef.scriptFilePath);
|
||||
%scriptExt = fileExt(%assetDef.scriptFilePath);
|
||||
|
||||
%oldGOFilePath = %assetDef.TAMLFilePath;
|
||||
|
||||
%newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
|
||||
%newAssetFile = %path @ "/" @ %this.getText() @ ".asset.taml";
|
||||
%newGOFile = %path @ "/" @ %this.getText() @ ".taml";
|
||||
|
||||
%assetDef.gameObjectName = %newName;
|
||||
%assetDef.scriptFilePath = %newScriptFileName;
|
||||
%assetDef.TAMLFilePath = %newGOFile;
|
||||
|
||||
TamlWrite(%assetDef, %newAssetFile);
|
||||
fileDelete(%assetPath);
|
||||
|
||||
pathCopy(%oldScriptFilePath, %newScriptFileName);
|
||||
fileDelete(%oldScriptFilePath);
|
||||
|
||||
pathCopy(%oldGOFilePath, %newGOFile);
|
||||
fileDelete(%oldGOFilePath);
|
||||
|
||||
//Go through our scriptfile and replace the old namespace with the new
|
||||
%editedFileContents = "";
|
||||
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %newScriptFileName ) )
|
||||
{
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %this.originalAssetName, %newName) @ "\n";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%newScriptFileName);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
exec(%newScriptFileName);
|
||||
|
||||
//Rename in the TAML file as well
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %newGOFile ) )
|
||||
{
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %this.originalAssetName, %newName) @ "\n";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%newGOFile);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%this.clearFirstResponder();
|
||||
%this.setActive(false);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
function AssetBrowser::duplicateAsset(%this)
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
|
||||
%this.setupCreateNewAsset(%assetDef.getClassName(), AssetBrowser.selectedModule);
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteAsset(%this)
|
||||
{
|
||||
//Find out what type it is
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%assetType = %assetDef.getClassName();
|
||||
|
||||
MessageBoxOKCancel("Warning!", "This will delete the selected asset and the files associated to it, do you wish to continue?",
|
||||
"AssetBrowser.confirmDeleteAsset();", "");
|
||||
}
|
||||
|
||||
function AssetBrowser::confirmDeleteAsset(%this)
|
||||
{
|
||||
%currentSelectedItem = AssetBrowserFilterTree.getSelectedItem();
|
||||
%currentItemParent = AssetBrowserFilterTree.getParentItem(%currentSelectedItem);
|
||||
|
||||
AssetDatabase.deleteAsset(EditAssetPopup.assetId, false);
|
||||
|
||||
%this.loadFilters();
|
||||
|
||||
if(!AssetBrowserFilterTree.selectItem(%currentSelectedItem))
|
||||
{
|
||||
//if it failed, that means we deleted the last item in that category, and we need to do the parent
|
||||
AssetBrowserFilterTree.selectItem(%currentItemParent);
|
||||
AssetBrowserFilterTree.expandItem(%currentItemParent);
|
||||
}
|
||||
}
|
||||
127
Templates/BaseGame/game/tools/assetBrowser/scripts/editModule.cs
Normal file
127
Templates/BaseGame/game/tools/assetBrowser/scripts/editModule.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
//
|
||||
function AssetBrowser::CreateNewModule(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_AddModule);
|
||||
AssetBrowser_addModuleWindow.selectWindow();
|
||||
|
||||
AssetBrowser_addModuleWindow.callbackFunction = "AssetBrowser.loadFilters();";
|
||||
}
|
||||
|
||||
function AssetBrowser_editModule::saveModule(%this)
|
||||
{
|
||||
//Check what special actions we may need to do, such as renames
|
||||
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
|
||||
|
||||
%oldModuleName = %moduleDef.ModuleID;
|
||||
|
||||
if(%oldModuleName !$= AssetBrowser.tempModule.ModuleID)
|
||||
{
|
||||
//rename the script file and script namespaces
|
||||
%oldScriptFilePath = "data/" @ %oldModuleName @ "/" @ %moduleDef.scriptFile;
|
||||
%newscriptFilePath = "data/" @ AssetBrowser.tempModule.ModuleID @ "/";
|
||||
%scriptExt = fileExt(%moduleDef.scriptFile);
|
||||
|
||||
%newScriptFileName = %newscriptFilePath @ "/" @ AssetBrowser.tempModule.ModuleID @ %scriptExt;
|
||||
%newScriptFileOldName = %newscriptFilePath @ "/" @ %oldModuleName @ %scriptExt;
|
||||
|
||||
%moduleDef.ModuleId = AssetBrowser.tempModule.ModuleID;
|
||||
%moduleDef.scriptFile = AssetBrowser.tempModule.ModuleID @ %scriptExt;
|
||||
|
||||
ModuleDatabase.copyModule(%moduleDef, AssetBrowser.tempModule.ModuleID, "data/" @ AssetBrowser.tempModule.ModuleID);
|
||||
|
||||
//Go through our scriptfile and replace the old namespace with the new
|
||||
%editedFileContents = "";
|
||||
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %newScriptFileOldName ) )
|
||||
{
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %oldModuleName, AssetBrowser.tempModule.ModuleID) @ "\n";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%newScriptFileName);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
%success = fileDelete(%newScriptFileOldName);
|
||||
|
||||
ModuleDatabase.unloadExplicit(%oldModuleName);
|
||||
|
||||
%success = fileDelete("data/" @ %oldModuleName);
|
||||
|
||||
ModuleDatabase.loadExplicit(AssetBrowser.tempModule.ModuleID);
|
||||
}
|
||||
|
||||
//Now, update the module file itself
|
||||
//%file = ModuleDatabase.getAssetFilePath(%moduleDef.ModuleID);
|
||||
//%success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
Canvas.popDialog(AssetBrowser_editModule);
|
||||
}
|
||||
|
||||
function AssetBrowser::editModuleInfo(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_editModule);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
|
||||
|
||||
AssetBrowser.tempModule = new ModuleDefinition();
|
||||
AssetBrowser.tempModule.assignFieldsFrom(%moduleDef);
|
||||
|
||||
ModuleEditInspector.inspect(AssetBrowser.tempModule);
|
||||
AssetBrowser_editModule.editedModuleId = AssetBrowser.selectedModule;
|
||||
AssetBrowser_editModule.editedModule = AssetBrowser.tempModule;
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < ModuleEditInspector.getCount(); %i++)
|
||||
{
|
||||
%caption = ModuleEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "BuildId" || %caption $= "type" || %caption $= "Dependencies" || %caption $= "scriptFile"
|
||||
|| %caption $= "AssetTagsManifest" || %caption $= "ScopeSet" || %caption $= "ModulePath"
|
||||
|| %caption $= "ModuleFile" || %caption $= "ModuleFilePath" || %caption $= "ModuleScriptFilePath" )
|
||||
{
|
||||
ModuleEditInspector.remove(ModuleEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::renameModule(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::reloadModule(%this)
|
||||
{
|
||||
ModuleDatabase.unregisterModule(AssetBrowser.SelectedModule, 1);
|
||||
ModuleDatabase.loadExplicit(AssetBrowser.SelectedModule);
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteModule(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::RefreshModuleDependencies(%this)
|
||||
{
|
||||
//Iterate through all our modules
|
||||
|
||||
//then, iterate through the module's assets
|
||||
|
||||
//if an asset has a module that isn't us, queue that into the dependencies list
|
||||
}
|
||||
127
Templates/BaseGame/game/tools/assetBrowser/scripts/fieldTypes.cs
Normal file
127
Templates/BaseGame/game/tools/assetBrowser/scripts/fieldTypes.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
function GuiVariableInspector::onInspectorFieldModified(%this, %targetObj, %fieldName, %index, %oldValue, %newValue)
|
||||
{
|
||||
echo("FIELD CHANGED: " @ %fieldName @ " from " @ %oldValue @ " to " @ %newValue);
|
||||
}
|
||||
|
||||
function GuiInspectorVariableGroup::onConstructField(%this, %fieldName, %fieldLabel, %fieldTypeName, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %ownerObj)
|
||||
{
|
||||
%makeCommand = %this @ ".build" @ %fieldTypeName @ "Field(\""@ %fieldName @ "\",\"" @ %fieldLabel @ "\",\"" @ %fieldDesc @ "\",\"" @
|
||||
%fieldDefaultVal @ "\",\"" @ %fieldDataVals @ "\",\"" @ %ownerObj @"\");";
|
||||
eval(%makeCommand);
|
||||
}
|
||||
|
||||
function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %ownerObj)
|
||||
{
|
||||
%extent = 200;
|
||||
|
||||
%fieldCtrl = %this.createInspectorField();
|
||||
|
||||
%extent = %this.stack.getExtent();
|
||||
|
||||
%width = mRound(%extent/2);
|
||||
%height = 20;
|
||||
%inset = 10;
|
||||
|
||||
/*%container = new GuiControl() {
|
||||
canSaveDynamicFields = "0";
|
||||
Profile = "EditorContainerProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "0 0";
|
||||
Extent = %extent.x SPC %height;
|
||||
MinExtent = "8 2";
|
||||
canSave = "0";
|
||||
Visible = "1";
|
||||
hovertime = "100";
|
||||
tooltip = %tooltip;
|
||||
tooltipProfile = "EditorToolTipProfile";
|
||||
};
|
||||
|
||||
%labelControl = new GuiTextCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
Profile = "EditorFontHLBold";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = %inset SPC "0";
|
||||
Extent = %width + %inset SPC %height;
|
||||
MinExtent = "8 2";
|
||||
canSave = "0";
|
||||
Visible = "1";
|
||||
hovertime = "100";
|
||||
tooltip = %tooltip;
|
||||
tooltipProfile = "EditorToolTipProfile";
|
||||
text = %fieldLabel;
|
||||
maxLength = "1024";
|
||||
};*/
|
||||
|
||||
%editControl = new GuiPopUpMenuCtrl() {
|
||||
class = "guiInspectorListField";
|
||||
maxPopupHeight = "200";
|
||||
sbUsesNAColor = "0";
|
||||
reverseTextList = "0";
|
||||
bitmapBounds = "16 16";
|
||||
maxLength = "1024";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiPopUpMenuProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = %fieldCtrl.edit.position;
|
||||
Extent = %fieldCtrl.edit.extent;
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
tooltip = %tooltip;
|
||||
text = %fieldDefaultVal;
|
||||
hovertime = "1000";
|
||||
ownerObject = %ownerObj;
|
||||
fieldName = %fieldName;
|
||||
};
|
||||
|
||||
//set the field value
|
||||
if(getSubStr(%this.fieldName, 0, 1) $= "$")
|
||||
{
|
||||
if(%fieldName $= "")
|
||||
%editControl.setText(%fieldName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//regular variable
|
||||
%setCommand = %editControl @ ".setText(" @ %ownerObj @ "." @ %fieldName @ ");";
|
||||
eval(%setCommand);
|
||||
}
|
||||
|
||||
%listCount = getTokenCount(%fieldDataVals, ",");
|
||||
|
||||
for(%i=0; %i < %listCount; %i++)
|
||||
{
|
||||
%entryText = getToken(%fieldDataVals, ",", %i);
|
||||
%editControl.add(%entryText);
|
||||
}
|
||||
|
||||
%fieldCtrl.setCaption(%fieldLabel);
|
||||
%fieldCtrl.setEditControl(%editControl);
|
||||
|
||||
%this.addInspectorField(%fieldCtrl);
|
||||
}
|
||||
|
||||
function guiInspectorListField::onSelect( %this, %id, %text )
|
||||
{
|
||||
if(getSubStr(%this.fieldName, 0, 1) $= "$")
|
||||
{
|
||||
//ah, a global var, just do it straight, then
|
||||
%setCommand = %this.fieldName @ " = \"" @ %text @ "\";";
|
||||
}
|
||||
else
|
||||
{
|
||||
//regular variable
|
||||
%setCommand = %this.ownerObject @ "." @ %this.fieldName @ " = \"" @ %text @ "\";";
|
||||
}
|
||||
eval(%setCommand);
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
function GameObjectModuleList::onWake(%this)
|
||||
{
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function GameObjectModuleList::refresh(%this)
|
||||
{
|
||||
%this.clear();
|
||||
|
||||
//First, get our list of modules
|
||||
%moduleList = ModuleDatabase.findModules();
|
||||
|
||||
%count = getWordCount(%moduleList);
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%moduleName = getWord(%moduleList, %i);
|
||||
%this.add(%moduleName.ModuleId, %i);
|
||||
}
|
||||
}
|
||||
|
||||
function GameObjectCreatorPkgBtn::onClick(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_AddModule);
|
||||
AssetBrowser_addModuleWindow.selectWindow();
|
||||
}
|
||||
|
||||
function GameObjectCreateBtn::onClick(%this)
|
||||
{
|
||||
%className = GameObjectCreatorName.getText();
|
||||
|
||||
if(%className $= "")
|
||||
{
|
||||
error("Attempted to make a new Game Object with no name!");
|
||||
Canvas.popDialog(GameObjectCreator);
|
||||
return;
|
||||
}
|
||||
|
||||
//First, find out if this one already exists. If so, we're obviously merely updating it
|
||||
//also, exec any components that may exist
|
||||
//find all GameObjectAssets
|
||||
%assetQuery = new AssetQuery();
|
||||
if(!AssetDatabase.findAssetType(%assetQuery, "GameObjectAsset"))
|
||||
return; //if we didn't find ANY, just exit
|
||||
|
||||
%count = %assetQuery.getCount();
|
||||
|
||||
%createNew = true;
|
||||
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%assetId = %assetQuery.getAsset(%i);
|
||||
|
||||
%gameObjectAsset = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
if(%gameObjectAsset.gameObjectName $= %className)
|
||||
{
|
||||
%createNew = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
%selectedEntity = GameObjectCreator.selectedEntity;
|
||||
|
||||
%selectedEntity.class = %className;
|
||||
Inspector.inspect(%selectedEntity);
|
||||
|
||||
if(%createNew)
|
||||
{
|
||||
//get the selected module data
|
||||
%moduleName = GameObjectModuleList.getText();
|
||||
|
||||
%selectedEntity.gameObjectAsset = %moduleName @ ":" @ %className;
|
||||
|
||||
%path = "data/" @ %moduleName @ "/gameObjects/";
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%path @ "\\" @ %className @ ".cs"))
|
||||
{
|
||||
%file.writeline("function " @ %className @ "::onAdd(%this)\n{\n\n}\n");
|
||||
%file.writeline("function " @ %className @ "::onRemove(%this)\n{\n\n}\n");
|
||||
|
||||
//todo, pre-write any event functions of interest
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
//set up the paths
|
||||
%tamlPath = %path @ %className @ ".taml";
|
||||
%scriptPath = %path @ %className @ ".cs";
|
||||
saveGameObject(%className, %tamlPath, %scriptPath);
|
||||
|
||||
%asset = new GameObjectAsset()
|
||||
{
|
||||
AssetName = %className;
|
||||
VersionId = 1;
|
||||
gameObjectName=%className;
|
||||
TAMLFilePath = %tamlPath;
|
||||
scriptFilePath = %scriptPath;
|
||||
};
|
||||
%assetPath = %path @ %className @ ".asset.taml";
|
||||
|
||||
//now, add the script file and a ref to the taml into our SGO manifest so we can readily spawn it later.
|
||||
TamlWrite(%selectedEntity, %tamlpath);
|
||||
TamlWrite(%asset, %assetPath);
|
||||
|
||||
GameObjectCreator.selectedEntity = "";
|
||||
|
||||
Canvas.popDialog(GameObjectCreator);
|
||||
|
||||
//Load it
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName,1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %assetPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
%moduleDef = AssetDatabase.getAssetModule(%assetId);
|
||||
%moduleName = %moduleDef.ModuleId;
|
||||
%path = "data/" @ %moduleName @ "/gameObjects/";
|
||||
|
||||
%selectedEntity.gameObjectAsset = %moduleName @ ":" @ %className;
|
||||
|
||||
%tamlPath = %path @ %className @ ".taml";
|
||||
TamlWrite(%selectedEntity, %tamlpath);
|
||||
|
||||
GameObjectCreator.selectedEntity = "";
|
||||
|
||||
Canvas.popDialog(GameObjectCreator);
|
||||
}
|
||||
}
|
||||
663
Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.cs
Normal file
663
Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.cs
Normal file
|
|
@ -0,0 +1,663 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
function CreateAssetButton::onClick(%this)
|
||||
{
|
||||
AddNewAssetPopup.showPopup(Canvas);
|
||||
}
|
||||
|
||||
function AssetBrowser_newAsset::onWake(%this)
|
||||
{
|
||||
NewAssetModuleList.refresh();
|
||||
//NewComponentParentClass.setText("Component");
|
||||
}
|
||||
|
||||
function AssetBrowser_newAssetWindow::onClose(%this)
|
||||
{
|
||||
NewAssetPropertiesInspector.clearFields();
|
||||
Canvas.popDialog(AssetBrowser_newAsset);
|
||||
}
|
||||
|
||||
function NewAssetTypeList::onWake(%this)
|
||||
{
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function NewAssetTypeList::refresh(%this)
|
||||
{
|
||||
%this.clear();
|
||||
|
||||
//TODO: make this more automated
|
||||
//%this.add("GameObject", 0);
|
||||
%this.add("Component", 0);
|
||||
%this.add("Image", 1);
|
||||
%this.add("Material", 2);
|
||||
%this.add("Shape", 3);
|
||||
%this.add("Sound", 4);
|
||||
%this.add("State Machine", 5);
|
||||
}
|
||||
|
||||
function NewAssetTypeList::onSelected(%this)
|
||||
{
|
||||
%assetType = %this.getText();
|
||||
|
||||
if(%assetType $= "Component")
|
||||
{
|
||||
NewComponentAssetSettings.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
function NewAssetModuleBtn::onClick(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_AddModule);
|
||||
AssetBrowser_addModuleWindow.selectWindow();
|
||||
}
|
||||
|
||||
function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_newAsset);
|
||||
|
||||
AssetBrowser_newAssetWindow.text = "New" SPC %assetType SPC "Asset";
|
||||
|
||||
NewAssetPropertiesInspector.clear();
|
||||
|
||||
NewAssetModuleList.setText(%moduleName);
|
||||
|
||||
//get rid of the old one if we had one.
|
||||
if(isObject(%this.newAssetSettings))
|
||||
%this.newAssetSettings.delete();
|
||||
|
||||
%this.newAssetSettings = new ScriptObject();
|
||||
|
||||
%this.newAssetSettings.assetType = %assetType;
|
||||
%this.newAssetSettings.moduleName = %moduleName;
|
||||
|
||||
%shortAssetTypeName = strreplace(%assetType, "Asset", "");
|
||||
|
||||
NewAssetPropertiesInspector.startGroup("General");
|
||||
NewAssetPropertiesInspector.addField("assetName", "New Asset Name", "String", "Name of the new asset", "New" @ %shortAssetTypeName, "", %this.newAssetSettings);
|
||||
//NewAssetPropertiesInspector.addField("AssetType", "New Asset Type", "List", "Type of the new asset", %assetType, "Component,Image,Material,Shape,Sound,State Machine", %newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.addField("friendlyName", "Friendly Name", "String", "Human-readable name of new asset", "", "", %this.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.addField("description", "Description", "Command", "Description of the new asset", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
|
||||
if(%assetType $= "ComponentAsset")
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Components");
|
||||
NewAssetPropertiesInspector.addField("parentClass", "New Asset Parent Class", "String", "Name of the new asset's parent class", "Component", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("componentGroup", "Component Group", "String", "Name of the group of components this component asset belongs to", "", "", %this.newAssetSettings);
|
||||
//NewAssetPropertiesInspector.addField("componentName", "Component Name", "String", "Name of the new component", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
else if(%assetType $= "LevelAsset")
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Level");
|
||||
NewAssetPropertiesInspector.addField("levelPreviewImage", "LevePreviewImage", "Image", "Preview Image for the level", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
else if(%assetType $= "ScriptAsset")
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Script");
|
||||
NewAssetPropertiesInspector.addField("isServerScript", "Is Server Script", "bool", "Is this script used on the server?", "1", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
/*else if(%assetType $= "ShapeAnimationAsset")
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Animation");
|
||||
NewAssetPropertiesInspector.addField("sourceFile", "Source File", "filename", "Source file this animation will pull from", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("animationName", "Animation Name", "string", "Name of the animation clip when used in a shape", "", "", %this.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.addField("startFrame", "Starting Frame", "int", "Source file this animation will pull from", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("endFrame", "Ending Frame", "int", "Source file this animation will pull from", "", "", %this.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.addField("padRotation", "Pad Rotations", "bool", "Source file this animation will pull from", "0", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("padTransforms", "Pad Transforms", "bool", "Source file this animation will pull from", "0", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}*/
|
||||
|
||||
return;
|
||||
|
||||
if(%moduleName $= "")
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_selectModule);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetBrowser.SelectedModule = %moduleName;
|
||||
|
||||
if(%assetType $= "MaterialAsset")
|
||||
{
|
||||
createNewMaterialAsset("NewMaterial", %moduleName);
|
||||
}
|
||||
else if(%assetType $= "StateMachineAsset")
|
||||
{
|
||||
createNewStateMachineAsset("NewStateMachine", %moduleName);
|
||||
}
|
||||
else if(%assetType $= "ScriptAsset")
|
||||
{
|
||||
createNewScriptAsset("NewScriptAsset", %moduleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//We do a quick validation that mandatory fields are filled in before passing along to the asset-type specific function
|
||||
function CreateNewAsset()
|
||||
{
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
if(%assetName $= "")
|
||||
{
|
||||
MessageBoxOK( "Error", "Attempted to make a new asset with no name!");
|
||||
return;
|
||||
}
|
||||
|
||||
//get the selected module data
|
||||
%moduleName = NewAssetModuleList.getText();
|
||||
|
||||
if(%moduleName $= "")
|
||||
{
|
||||
MessageBoxOK( "Error", "Attempted to make a new asset with no module!");
|
||||
return;
|
||||
}
|
||||
|
||||
AssetBrowser.newAssetSettings.moduleName = %moduleName;
|
||||
|
||||
%assetType = AssetBrowser.newAssetSettings.assetType;
|
||||
if(%assetType $= "")
|
||||
{
|
||||
MessageBoxOK( "Error", "Attempted to make a new asset with no type!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(%assetType $= "ComponentAsset")
|
||||
{
|
||||
//Canvas.popDialog(AssetBrowser_newComponentAsset);
|
||||
//AssetBrowser_newComponentAsset-->AssetBrowserModuleList.setText(AssetBrowser.selectedModule);
|
||||
%assetFilePath = createNewComponentAsset(%assetName, %path);
|
||||
}
|
||||
else if(%assetType $= "MaterialAsset")
|
||||
{
|
||||
%assetFilePath = createNewMaterialAsset();
|
||||
}
|
||||
else if(%assetType $= "StateMachineAsset")
|
||||
{
|
||||
%assetFilePath = createNewStateMachineAsset();
|
||||
}
|
||||
else if(%assetType $= "GUIAsset")
|
||||
{
|
||||
%assetFilePath = createNewGUIAsset();
|
||||
}
|
||||
else if(%assetType $= "LevelAsset")
|
||||
{
|
||||
%assetFilePath = createNewLevelAsset();
|
||||
}
|
||||
else if(%assetType $= "ScriptAsset")
|
||||
{
|
||||
%assetFilePath = createNewScriptAsset();
|
||||
}
|
||||
else if(%assetType $= "ShapeAnimationAsset")
|
||||
{
|
||||
%assetFilePath = createShapeAnimationAsset();
|
||||
}
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newAsset);
|
||||
|
||||
//Load it
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName,1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %assetFilePath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
}
|
||||
|
||||
function createNewComponentAsset()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%tamlpath = %modulePath @ "/components/" @ %assetName @ ".asset.taml";
|
||||
%scriptPath = %modulePath @ "/components/" @ %assetName @ ".cs";
|
||||
|
||||
%asset = new ComponentAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
componentName = %assetName;
|
||||
componentClass = AssetBrowser.newAssetSettings.parentClass;
|
||||
friendlyName = AssetBrowser.newAssetSettings.friendlyName;
|
||||
componentType = AssetBrowser.newAssetSettings.componentGroup;
|
||||
description = AssetBrowser.newAssetSettings.description;
|
||||
scriptFile = %scriptPath;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
//TODO: enable ability to auto-embed a header for copyright or whatnot
|
||||
%file.writeline("//onAdd is called when the component is created and then added to it's owner entity.\n");
|
||||
%file.writeline("//You would also add any script-defined component fields via addComponentField().\n");
|
||||
%file.writeline("function " @ %assetName @ "::onAdd(%this)\n{\n\n}\n");
|
||||
%file.writeline("//onAdd is called when the component is removed and deleted from it's owner entity.");
|
||||
%file.writeline("function " @ %assetName @ "::onRemove(%this)\n{\n\n}\n");
|
||||
%file.writeline("//onClientConnect is called any time a new client connects to the server.");
|
||||
%file.writeline("function " @ %assetName @ "::onClientConnect(%this, %client)\n{\n\n}\n");
|
||||
%file.writeline("//onClientDisconnect is called any time a client disconnects from the server.");
|
||||
%file.writeline("function " @ %assetName @ "::onClientDisonnect(%this, %client)\n{\n\n}\n");
|
||||
%file.writeline("//update is called when the component does an update tick.\n");
|
||||
%file.writeline("function " @ %assetName @ "::Update(%this)\n{\n\n}\n");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newComponentAsset);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "Components");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function createNewMaterialAsset()
|
||||
{
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%tamlpath = %modulePath @ "/materials/" @ %assetName @ ".asset.taml";
|
||||
%sgfPath = %modulePath @ "/materials/" @ %assetName @ ".sgf";
|
||||
|
||||
%asset = new MaterialAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
shaderData = "";
|
||||
shaderGraph = %sgfPath;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "Materials");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function createNewScriptAsset()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%tamlpath = %modulePath @ "/scripts/" @ %assetName @ ".asset.taml";
|
||||
%scriptPath = %modulePath @ "/scripts/" @ %assetName @ ".cs";
|
||||
|
||||
%asset = new ScriptAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
scriptFilePath = %scriptPath;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "Scripts");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
%file.close();
|
||||
}
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function createNewStateMachineAsset()
|
||||
{
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetQuery = new AssetQuery();
|
||||
|
||||
%matchingAssetCount = AssetDatabase.findAssetName(%assetQuery, %assetName);
|
||||
|
||||
%i=1;
|
||||
while(%matchingAssetCount > 0)
|
||||
{
|
||||
%newAssetName = %assetName @ %i;
|
||||
%i++;
|
||||
|
||||
%matchingAssetCount = AssetDatabase.findAssetName(%assetQuery, %newAssetName);
|
||||
}
|
||||
|
||||
%assetName = %newAssetName;
|
||||
|
||||
%assetQuery.delete();
|
||||
|
||||
%tamlpath = "data/" @ %moduleName @ "/stateMachines/" @ %assetName @ ".asset.taml";
|
||||
%smFilePath = "data/" @ %moduleName @ "/stateMachines/" @ %assetName @ ".xml";
|
||||
|
||||
%asset = new StateMachineAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
stateMachineFile = %smFilePath;
|
||||
};
|
||||
|
||||
%xmlDoc = new SimXMLDocument();
|
||||
%xmlDoc.saveFile(%smFilePath);
|
||||
%xmlDoc.delete();
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
//Now write our XML file
|
||||
%xmlFile = new FileObject();
|
||||
%xmlFile.openForWrite(%smFilePath);
|
||||
%xmlFile.writeLine("<StateMachine>");
|
||||
%xmlFile.writeLine("</StateMachine>");
|
||||
%xmlFile.close();
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "StateMachines");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function createNewGUIAsset()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%tamlpath = %modulePath @ "/GUIs/" @ %assetName @ ".asset.taml";
|
||||
%guipath = %modulePath @ "/GUIs/" @ %assetName @ ".gui";
|
||||
%scriptPath = %modulePath @ "/GUIs/" @ %assetName @ ".cs";
|
||||
|
||||
%asset = new GUIAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
scriptFilePath = %scriptPath;
|
||||
guiFilePath = %guipath;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%guipath))
|
||||
{
|
||||
%file.writeline("//--- OBJECT WRITE BEGIN ---");
|
||||
%file.writeline("%guiContent = new GuiControl(" @ %assetName @ ") {");
|
||||
%file.writeline(" position = \"0 0\";");
|
||||
%file.writeline(" extent = \"100 100\";");
|
||||
%file.writeline("};");
|
||||
%file.writeline("//--- OBJECT WRITE END ---");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
%file.writeline("function " @ %assetName @ "::onWake(%this)\n{\n\n}\n");
|
||||
%file.writeline("function " @ %assetName @ "::onSleep(%this)\n{\n\n}\n");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
//load the gui
|
||||
exec(%guipath);
|
||||
exec(%scriptPath);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "GUIs");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function createNewLevelAsset()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%tamlpath = %modulePath @ "/levels/" @ %assetName @ ".asset.taml";
|
||||
%levelPath = %modulePath @ "/levels/" @ %assetName @ ".mis";
|
||||
|
||||
%asset = new LevelAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
LevelFile = %levelPath;
|
||||
LevelDescription = AssetBrowser.newAssetSettings.levelDescription;
|
||||
PreviewImage = AssetBrowser.newAssetSettings.levelPreviewImage;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
if(!pathCopy("tools/levels/BlankRoom.mis", %levelPath, false))
|
||||
{
|
||||
echo("Unable to copy template level file!");
|
||||
}
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "Levels");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function createNewShapeAnimationAsset()
|
||||
{
|
||||
%dlg = new OpenFileDialog()
|
||||
{
|
||||
Filters = "Animation Files(*.dae, *.cached.dts)|*.dae;*.cached.dts";
|
||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||
DefaultFile = "";
|
||||
ChangePath = false;
|
||||
OverwritePrompt = true;
|
||||
forceRelativePath = false;
|
||||
//MultipleFiles = true;
|
||||
};
|
||||
|
||||
%ret = %dlg.Execute();
|
||||
|
||||
if ( %ret )
|
||||
{
|
||||
$Pref::WorldEditor::LastPath = filePath( %dlg.FileName );
|
||||
%fullPath = %dlg.FileName;
|
||||
}
|
||||
|
||||
%dlg.delete();
|
||||
|
||||
if ( !%ret )
|
||||
return;
|
||||
|
||||
/*%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%tamlpath = %modulePath @ "/levels/" @ %assetName @ ".asset.taml";
|
||||
%levelPath = %modulePath @ "/levels/" @ %assetName @ ".mis";
|
||||
|
||||
%asset = new ShapeAnimationAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
LevelFile = %levelPath;
|
||||
LevelDescription = AssetBrowser.newAssetSettings.levelDescription;
|
||||
PreviewImage = AssetBrowser.newAssetSettings.levelPreviewImage;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
if(!pathCopy("tools/levels/BlankRoom.mis", %levelPath, false))
|
||||
{
|
||||
echo("Unable to copy template level file!");
|
||||
}
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.loadFilters();
|
||||
|
||||
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
|
||||
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "Levels");
|
||||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
return %tamlpath;*/
|
||||
}
|
||||
|
||||
function ParentComponentList::onWake(%this)
|
||||
{
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function ParentComponentList::refresh(%this)
|
||||
{
|
||||
%this.clear();
|
||||
|
||||
%assetQuery = new AssetQuery();
|
||||
if(!AssetDatabase.findAssetType(%assetQuery, "ComponentAsset"))
|
||||
return; //if we didn't find ANY, just exit
|
||||
|
||||
// Find all the types.
|
||||
%count = %assetQuery.getCount();
|
||||
|
||||
/*%categories = "";
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%assetId = %assetQuery.getAsset(%i);
|
||||
|
||||
%componentAsset = AssetDatabase.acquireAsset(%assetId);
|
||||
%componentName = %componentAsset.componentName;
|
||||
|
||||
if(%componentName $= "")
|
||||
%componentName = %componentAsset.componentClass;
|
||||
|
||||
%this.add(%componentName, %i);
|
||||
}*/
|
||||
|
||||
%categories = "";
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%assetId = %assetQuery.getAsset(%i);
|
||||
|
||||
%componentAsset = AssetDatabase.acquireAsset(%assetId);
|
||||
%componentClass = %componentAsset.componentClass;
|
||||
if (!isInList(%componentClass, %categories))
|
||||
%categories = %categories TAB %componentClass;
|
||||
}
|
||||
|
||||
%categories = trim(%categories);
|
||||
|
||||
%index = 0;
|
||||
%categoryCount = getFieldCount(%categories);
|
||||
for (%i = 0; %i < %categoryCount; %i++)
|
||||
{
|
||||
%category = getField(%categories, %i);
|
||||
%this.addCategory(%category);
|
||||
|
||||
for (%j = 0; %j < %count; %j++)
|
||||
{
|
||||
%assetId = %assetQuery.getAsset(%j);
|
||||
|
||||
%componentAsset = AssetDatabase.acquireAsset(%assetId);
|
||||
%componentName = %componentAsset.componentName;
|
||||
%componentClass = %componentAsset.componentClass;
|
||||
|
||||
if (%componentClass $= %category)
|
||||
{
|
||||
if(%componentName !$= "")
|
||||
%this.add(" "@%componentName, %i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Game Object creation
|
||||
//----------------------------------------------------------
|
||||
function EWorldEditor::createGameObject( %this )
|
||||
{
|
||||
GameObjectCreatorObjectName.text = "";
|
||||
|
||||
%activeSelection = %this.getActiveSelection();
|
||||
if( %activeSelection.getCount() == 0 )
|
||||
return;
|
||||
|
||||
GameObjectCreator.selectedEntity = %activeSelection.getObject( 0 );
|
||||
|
||||
Canvas.pushDialog(GameObjectCreator);
|
||||
}
|
||||
154
Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.cs
Normal file
154
Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.cs
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
function AssetBrowser::buildPopupMenus(%this)
|
||||
{
|
||||
if( !isObject( AddNewModulePopup ) )
|
||||
{
|
||||
new PopupMenu( AddNewModulePopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
isPopup = true;
|
||||
|
||||
item[ 0 ] = "Create New Module" TAB "" TAB "AssetBrowser.CreateNewModule();";
|
||||
item[ 1 ] = "Refresh Module Dependencies" TAB "" TAB "AssetBrowser.RefreshModuleDependencies();";
|
||||
};
|
||||
}
|
||||
|
||||
if( !isObject( EditAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
item[ 0 ] = "Edit Asset" TAB "" TAB "AssetBrowser.editAsset();";
|
||||
item[ 1 ] = "Rename Asset" TAB "" TAB "AssetBrowser.renameAsset();";
|
||||
item[ 2 ] = "Refresh Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
|
||||
item[ 3 ] = "Asset Properties" TAB "" TAB "AssetBrowser.editAssetInfo();";
|
||||
item[ 4 ] = "-";
|
||||
Item[ 5 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";
|
||||
item[ 6 ] = "-";
|
||||
item[ 7 ] = "Re-Import Asset" TAB "" TAB "AssetBrowser.reImportAsset();";
|
||||
item[ 8 ] = "-";
|
||||
item[ 9 ] = "Delete Asset" TAB "" TAB "AssetBrowser.deleteAsset();";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
if( !isObject( AddNewComponentAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( AddNewComponentAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
//item[ 0 ] = "Create Component" TAB "" TAB "Canvas.pushDialog(AssetBrowser_newComponentAsset); AssetBrowser_newComponentAsset-->NewComponentPackageList.setText(AssetBrowser.selectedModule);";
|
||||
item[ 0 ] = "Component" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ComponentAsset\", AssetBrowser.selectedModule);";
|
||||
|
||||
//list other common component types here to shortcut the creation process
|
||||
};
|
||||
}
|
||||
|
||||
if( !isObject( AddNewScriptAssetPopup ) )
|
||||
{
|
||||
%this.AddNewScriptAssetPopup = new PopupMenu( AddNewScriptAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
item[ 0 ] = "Create Component" TAB AddNewComponentAssetPopup;
|
||||
item[ 1 ] = "Create Script" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ScriptAsset\", AssetBrowser.selectedModule);";
|
||||
item[ 2 ] = "Create State Machine" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"StateMachineAsset\", AssetBrowser.selectedModule);";
|
||||
//item[ 3 ] = "-";
|
||||
//item[ 3 ] = "Create Game Object" TAB "" TAB "AssetBrowser.createNewGameObjectAsset(\"NewGameObject\", AssetBrowser.selectedModule);";
|
||||
};
|
||||
//%this.AddNewScriptAssetPopup.insertSubMenu(0, "Create Component", AddNewComponentAssetPopup);
|
||||
}
|
||||
|
||||
if( !isObject( AddNewArtAssetPopup ) )
|
||||
{
|
||||
%this.AddNewArtAssetPopup = new PopupMenu( AddNewArtAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
item[ 0 ] = "Create Material" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"MaterialAsset\", AssetBrowser.selectedModule);";//"createNewMaterialAsset(\"NewMaterial\", AssetBrowser.selectedModule);";
|
||||
item[ 1 ] = "Create Image" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ImageAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewImageAsset(\"NewImage\", AssetBrowser.selectedModule);";
|
||||
item[ 2 ] = "-";
|
||||
item[ 3 ] = "Create Shape" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"Shape\", AssetBrowser.selectedModule);";
|
||||
item[ 4 ] = "Create Shape Animation" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ShapeAnimationAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewShapeAnimationAsset(\"NewShapeAnimation\", AssetBrowser.selectedModule);";
|
||||
item[ 5 ] = "-";
|
||||
item[ 6 ] = "Create GUI" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"GUIAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewGUIAsset(\"NewGUI\", AssetBrowser.selectedModule);";
|
||||
item[ 7 ] = "-";
|
||||
item[ 8 ] = "Create Post Effect" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"PostEffectAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewPostEffectAsset(\"NewPostEffect\", AssetBrowser.selectedModule);";
|
||||
item[ 9 ] = "-";
|
||||
item[ 10 ] = "Create Sound" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"SoundAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewSoundAsset(\"NewSound\", AssetBrowser.selectedModule);";
|
||||
item[ 11 ] = "-";
|
||||
item[ 12 ] = "Create Particle Effect" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ParticleEffectAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewParticleEffectAsset(\"NewParticleEffect\", AssetBrowser.selectedModule);";
|
||||
};
|
||||
}
|
||||
|
||||
if( !isObject( AddNewAssetPopup ) )
|
||||
{
|
||||
%this.AddNewAssetPopup = new PopupMenu( AddNewAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
item[0] = "Create Code Asset" TAB AddNewScriptAssetPopup;
|
||||
item[1] = "-";
|
||||
item[2] = "Create Art Asset" TAB AddNewArtAssetPopup;
|
||||
item[3] = "-";
|
||||
item[4] = "Create Level" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewLevelAsset(\"NewLevel\", AssetBrowser.selectedModule);";
|
||||
};
|
||||
}
|
||||
|
||||
if( !isObject( EditModulePopup ) )
|
||||
{
|
||||
new PopupMenu( EditModulePopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
item[ 0 ] = "Create New Asset" TAB AddNewAssetPopup;
|
||||
item[ 1 ] = "Reload Module" TAB "" TAB "AssetBrowser.reloadModule();";
|
||||
Item[ 2 ] = "-";
|
||||
Item[ 3 ] = "Edit Module" TAB "" TAB "AssetBrowser.editModuleInfo();";
|
||||
Item[ 4 ] = "-";
|
||||
Item[ 5 ] = "Duplicate Module" TAB "" TAB "AssetBrowser.copyModule();";
|
||||
Item[ 6 ] = "-";
|
||||
Item[ 7 ] = "Delete Module" TAB "" TAB "AssetBrowser.deleteModule();";
|
||||
};
|
||||
}
|
||||
|
||||
//Some assets are not yet ready/implemented, so disable their creation here
|
||||
AddNewArtAssetPopup.enableItem(3, false); //shape
|
||||
AddNewArtAssetPopup.enableItem(4, false); //shape animation
|
||||
AddNewArtAssetPopup.enableItem(8, false); //post effect
|
||||
AddNewArtAssetPopup.enableItem(10, false); //sound asset
|
||||
AddNewArtAssetPopup.enableItem(12, false); //particle effect
|
||||
|
||||
AddNewScriptAssetPopup.enableItem(2, false); //state machine
|
||||
}
|
||||
|
||||
function AddNewScriptAssetPopupMenu::onSelectItem(%this, %id, %text)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
function AddNewScriptAssetPopupMenu::setupDefaultState(%this)
|
||||
{
|
||||
// Setup camera speed gui's. Both menu and editorgui
|
||||
%this.setupGuiControls();
|
||||
|
||||
Parent::setupDefaultState(%this);
|
||||
}
|
||||
|
||||
function AddNewScriptAssetPopupMenu::setupGuiControls(%this)
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
function AssetBrowser_selectModule::onWake(%this)
|
||||
{
|
||||
AssetBrowser_SelectModuleWindow-->ModuleList.refresh();
|
||||
}
|
||||
|
||||
function SelectModule_NewAssetModuleBtn::onClick(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_AddModule);
|
||||
AssetBrowser_addModuleWindow.selectWindow();
|
||||
|
||||
AssetBrowser_AddModule.callback = "AssetBrowser_selectModule.newModuleAdded();";
|
||||
}
|
||||
|
||||
function AssetBrowser_selectModule::newModuleAdded(%this)
|
||||
{
|
||||
AssetBrowser_SelectModuleWindow-->ModuleList.refresh();
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
function AssetBrowser_selectPackage::onWake(%this)
|
||||
{
|
||||
AssetBrowser_SelectPackageWindow-->packageList.refresh();
|
||||
}
|
||||
|
||||
function SelectPackage_NewAssetPackageBtn::onClick(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_AddPackage);
|
||||
AssetBrowser_addPackageWindow.selectWindow();
|
||||
|
||||
AssetBrowser_AddPackage.callback = "AssetBrowser_selectPackage.newPackageAdded();";
|
||||
}
|
||||
|
||||
function AssetBrowser_selectPackage::newPackageAdded(%this)
|
||||
{
|
||||
AssetBrowser_SelectPackageWindow-->packageList.refresh();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue