Improve handling of non-default script filenames

This commit is contained in:
Lukas Aldershaab 2021-01-07 12:01:09 +01:00
parent 099dd4f1f3
commit 9ccaa6d3ea
118 changed files with 534 additions and 528 deletions

View file

@ -46,13 +46,13 @@ function AssetBrowser_addModuleWindow::CreateNewModule(%this)
%moduleFilePath = "data/" @ %newModuleName;
%moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".module";
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".tscript";
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension;
%newModule = new ModuleDefinition()
{
ModuleId = %newModuleName;
versionId = 1;
ScriptFile = %newModuleName @ ".tscript";
ScriptFile = %newModuleName @ "." @ $TorqueScriptFileExtension;
CreateFunction="onCreate";
DestroyFunction="onDestroy";
Group = "Game";
@ -70,7 +70,7 @@ function AssetBrowser_addModuleWindow::CreateNewModule(%this)
%file = new FileObject();
%templateFile = new FileObject();
%moduleTemplateCodeFilePath = AssetBrowser.templateFilesPath @ "module.tscript.template";
%moduleTemplateCodeFilePath = AssetBrowser.templateFilesPath @ "module." @ $TorqueScriptFileExtension @ ".template";
if(%file.openForWrite(%moduleScriptFilePath) && %templateFile.openForRead(%moduleTemplateCodeFilePath))
{

View file

@ -41,13 +41,13 @@ function AssetBrowser_addPackageWindow::CreateNewPackage(%this)
%moduleFilePath = "data/" @ %newPackageName;
%moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newPackageName @ ".module";
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newPackageName @ ".tscript";
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newPackageName @ "." @ $TorqueScriptFileExtension;
%newPackage = new ModuleDefinition()
{
ModuleId = %newPackageName;
versionId = 1;
ScriptFile = %newPackageName @ ".tscript";
ScriptFile = %newPackageName @ "." @ $TorqueScriptFileExtension;
CreateFunction="onCreate";
DestroyFunction="onDestroy";
Group = "Game";

View file

@ -151,7 +151,7 @@ function getAssetTypeByFilename(%filePath)
return "ShapeAsset";
else if( isSoundFormat(%fileExt))
return "SoundAsset";
else if( %fileExt $= ".tscript" || %fileExt $= ".tscript.dso" )
else if( %fileExt $= "." @ $TorqueScriptFileExtension || %fileExt $= "." @ $TorqueScriptFileExtension @ ".dso" )
return "ScriptAsset";
else if( %fileExt $= ".gui" || %fileExt $= ".gui.dso" )
return "GUIAsset";
@ -188,7 +188,7 @@ function AssetBrowser::onDropFile( %this, %filePath )
%assetItem = %this.addImportingAsset("ShapeAsset", %filePath);
else if( isSoundFormat(%fileExt))
%assetItem = %this.addImportingAsset("SoundAsset", %filePath);
else if( %fileExt $= ".tscript" || %fileExt $= ".tscript.dso" )
else if( %fileExt $= "." @ $TorqueScriptFileExtension || %fileExt $= "." @ $TorqueScriptFileExtension @ ".dso" )
%assetItem = %this.addImportingAsset("ScriptAsset", %filePath);
else if( %fileExt $= ".gui" || %fileExt $= ".gui.dso" )
%assetItem = %this.addImportingAsset("GUIAsset", %filePath);
@ -238,13 +238,13 @@ function AssetBrowser::onDropZipFile(%this, %filePath)
%this.importAssetListArray.add("SoundAsset", %filePath);
else if( (%fileExt $= ".gui") || (%fileExt $= ".gui.dso"))
%this.importAssetListArray.add("GUIAsset", %filePath);
//else if( (%fileExt $= ".tscript") || (%fileExt $= ".dso"))
//else if( (%fileExt $= "." @ $TorqueScriptFileExtension) || (%fileExt $= ".dso"))
// %this.importAssetListArray.add("Script", %filePath);
else if( (%fileExt $= ".mis"))
%this.importAssetListArray.add("LevelAsset", %filePath);*/
// For now, if it's a .tscript file, we'll assume it's a behavior.
//if (fileExt(%fileFrom) !$= ".tscript")
//if (fileExt(%fileFrom) !$= "." @ $TorqueScriptFileExtension)
// continue;
%fileTo = expandFilename("^tools/assetBrowser/importTemp/") @ %fileFrom;
@ -286,13 +286,13 @@ function AssetBrowser::onDropFolder(%this, %filePath)
%this.importAssetListArray.add("SoundAsset", %filePath);
else if( (%fileExt $= ".gui") || (%fileExt $= ".gui.dso"))
%this.importAssetListArray.add("GUIAsset", %filePath);
//else if( (%fileExt $= ".tscript") || (%fileExt $= ".dso"))
//else if( (%fileExt $= "." @ $TorqueScriptFileExtension) || (%fileExt $= ".dso"))
// %this.importAssetListArray.add("Script", %filePath);
else if( (%fileExt $= ".mis"))
%this.importAssetListArray.add("LevelAsset", %filePath);
// For now, if it's a .tscript file, we'll assume it's a behavior.
if (fileExt(%fileFrom) !$= ".tscript")
if (fileExt(%fileFrom) !$= "." @ $TorqueScriptFileExtension)
continue;
%fileTo = expandFilename("^game/behaviors/") @ fileName(%fileFrom);
@ -942,7 +942,7 @@ function ImportAssetWindow::addNewImportingAsset(%this, %filterType)
%type = "ShapeAsset";
else if( isSoundFormat(%fileExt))
%type = "SoundAsset";
else if( %fileExt $= ".tscript" || %fileExt $= ".tscript.dso" )
else if( %fileExt $= "." @ $TorqueScriptFileExtension || %fileExt $= "." @ $TorqueScriptFileExtension @ ".dso" )
%type = "ScriptAsset";
else if( %fileExt $= ".gui" || %fileExt $= ".gui.dso" )
%type = "GUIAsset";

View file

@ -6,7 +6,7 @@ function AssetBrowser::createComponentAsset(%this)
%assetName = AssetBrowser.newAssetSettings.assetName;
%tamlpath = %modulePath @ "/components/" @ %assetName @ ".asset.taml";
%scriptPath = %modulePath @ "/components/" @ %assetName @ ".tscript";
%scriptPath = %modulePath @ "/components/" @ %assetName @ "." @ $TorqueScriptFileExtension;
%asset = new ComponentAsset()
{
@ -17,7 +17,7 @@ function AssetBrowser::createComponentAsset(%this)
friendlyName = AssetBrowser.newAssetSettings.friendlyName;
componentType = AssetBrowser.newAssetSettings.componentGroup;
description = AssetBrowser.newAssetSettings.description;
scriptFile = %assetName @ ".tscript";
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
};
TamlWrite(%asset, %tamlpath);
@ -25,7 +25,7 @@ function AssetBrowser::createComponentAsset(%this)
%file = new FileObject();
%templateFile = new FileObject();
%templateCodeFilePath = %this.templateFilesPath @ "componentFile.tscript.template";
%templateCodeFilePath = %this.templateFilesPath @ "componentFile." @ $TorqueScriptFileExtension @ ".template";
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%templateCodeFilePath))
{

View file

@ -14,10 +14,10 @@ function AssetBrowser::createGameObjectAsset(%this)
function AssetBrowser::editGameObjectAsset(%this, %assetDef)
{
//We have no dedicated GO editor for now, so just defer to the script editing aspect
%this.editGameObjectAssetScript(%assetDef);
%this.editGameObjectAsse" @ $TorqueScriptFileExtension @ "(%assetDef);
}
function AssetBrowser::editGameObjectAssetScript(%this, %assetDef)
function AssetBrowser::editGameObjectAsse" @ $TorqueScriptFileExtension @ "(%this, %assetDef)
{
%scriptFile = %assetDef.scriptFile;

View file

@ -9,13 +9,13 @@ function AssetBrowser::createGUIAsset(%this)
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
%guipath = %assetPath @ %assetName @ ".gui";
%scriptPath = %assetPath @ %assetName @ ".tscript";
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
%asset = new GUIAsset()
{
AssetName = %assetName;
versionId = 1;
scriptFile = %assetName @ ".tscript";
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
guiFile = %assetName @ ".gui";
};
@ -48,7 +48,7 @@ function AssetBrowser::createGUIAsset(%this)
warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI file!");
}
%scriptTemplateCodeFilePath = %this.templateFilesPath @ "guiFile.tscript.template";
%scriptTemplateCodeFilePath = %this.templateFilesPath @ "guiFile." @ $TorqueScriptFileExtension @ ".template";
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%scriptTemplateCodeFilePath))
{

View file

@ -29,7 +29,7 @@ function AssetBrowser::createLevelAsset(%this)
versionId = 1;
LevelFile = %assetName @ ".mis";
DecalsFile = %assetName @ ".mis.decals";
PostFXPresetFile = %assetName @ ".postfxpreset.tscript";
PostFXPresetFile = %assetName @ ".postfxpreset." @ $TorqueScriptFileExtension;
ForestFile = %assetName @ ".forest";
NavmeshFile = %assetName @ ".nav";
LevelName = AssetBrowser.newAssetSettings.levelName;

View file

@ -323,14 +323,14 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem)
%assetPath = AssetBrowser.dirHandler.currentAddress @ "/";
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
%sgfPath = %assetPath @ %assetName @ ".sgf";
%scriptPath = %assetPath @ %assetName @ ".tscript";
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
%newAsset = new MaterialAsset()
{
assetName = %assetName;
versionId = 1;
shaderGraph = %sgfPath;
scriptFile = %assetName @ ".tscript";
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
originalFilePath = %filePath;
materialDefinitionName = %assetName;
};

View file

@ -6,7 +6,7 @@ function AssetBrowser::createPostEffectAsset(%this)
%assetPath = AssetBrowser.dirHandler.currentAddress @ "/";
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
%scriptPath = %assetPath @ %assetName @ ".tscript";
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
%hlslPath = %assetPath @ %assetName @ "P.hlsl";
%glslPath = %assetPath @ %assetName @ "P.glsl";
@ -14,7 +14,7 @@ function AssetBrowser::createPostEffectAsset(%this)
{
AssetName = %assetName;
versionId = 1;
scriptFile = %assetName @ ".tscript";
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
hlslShader = %assetName @ "P.hlsl";
glslShader = %assetName @ "P.glsl";
};
@ -27,7 +27,7 @@ function AssetBrowser::createPostEffectAsset(%this)
%file = new FileObject();
%templateFile = new FileObject();
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFile.tscript.template";
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFile." @ $TorqueScriptFileExtension @ ".template";
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
{

View file

@ -8,13 +8,13 @@ function AssetBrowser::createScriptAsset(%this)
%assetPath = AssetBrowser.dirHandler.currentAddress @ "/";
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
%scriptPath = %assetPath @ %assetName @ ".tscript";
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
%asset = new ScriptAsset()
{
AssetName = %assetName;
versionId = 1;
scriptFile = %assetName @ ".tscript";
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
};
TamlWrite(%asset, %tamlpath);
@ -32,7 +32,7 @@ function AssetBrowser::createScriptAsset(%this)
return %tamlpath;
}
function AssetBrowser::editScriptAsset(%this, %assetDef)
function AssetBrowser::edi" @ $TorqueScriptFileExtension @ "Asset(%this, %assetDef)
{
%scriptFile = %assetDef.scriptFile;
@ -43,7 +43,7 @@ function AssetBrowser::duplicateScriptAsset(%this, %assetDef, %targetModule)
{
}
function AssetBrowser::importScriptAsset(%this, %assetId)
function AssetBrowser::impor" @ $TorqueScriptFileExtension @ "Asset(%this, %assetId)
{
}
@ -99,7 +99,7 @@ function AssetBrowser::buildScriptAssetPreview(%this, %assetDef, %previewData)
if(%assetDef.isServerSide)
%previewData.previewImage = "tools/assetBrowser/art/serverScriptIcon";
else
%previewData.previewImage = "tools/assetBrowser/art/clientScriptIcon";
%previewData.previewImage = "tools/assetBrowser/art/clien" @ $TorqueScriptFileExtension @ "Icon";
%previewData.assetFriendlyName = %assetDef.assetName;
%previewData.assetDesc = %assetDef.description;

View file

@ -9,13 +9,13 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
%assetPath = AssetBrowser.dirHandler.currentAddress @ "/";
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
%scriptPath = %assetPath @ %assetName @ ".tscript";
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
%asset = new TerrainMaterialAsset()
{
AssetName = %assetName;
versionId = 1;
scriptFile = %assetName @ ".tscript";
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
materialDefinitionName = %assetName;
};
@ -33,7 +33,7 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
%file = new FileObject();
%templateFile = new FileObject();
%templateFilePath = %this.templateFilesPath @ "terrainMaterial.tscript.template";
%templateFilePath = %this.templateFilesPath @ "terrainMaterial." @ $TorqueScriptFileExtension @ ".template";
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%templateFilePath))
{

View file

@ -232,7 +232,7 @@ function AssetBrowser::RefreshModuleDependencies(%this, %moduleDef)
//AssetBrowser.RefreshModuleDependencies(16823);
%modulePath = filePath(%moduleDef.ModuleFilePath);
%filePattern = "*.tscript" TAB "*.taml" TAB "*.mis";
%filePattern = "*." @ $TorqueScriptFileExtension TAB "*.taml" TAB "*.mis";
//First, wipe out any files inside the folder first
%file = makeFullPath(findFirstFileMultiExpr( %filePattern, true));

View file

@ -74,7 +74,7 @@ function GameObjectCreateBtn::onClick(%this)
%file = new FileObject();
if(%file.openForWrite(%path @ "\\" @ %className @ ".tscript"))
if(%file.openForWrite(%path @ "\\" @ %className @ "." @ $TorqueScriptFileExtension))
{
%file.writeline("function " @ %className @ "::onAdd(%this)\n{\n\n}\n");
%file.writeline("function " @ %className @ "::onRemove(%this)\n{\n\n}\n");
@ -86,7 +86,7 @@ function GameObjectCreateBtn::onClick(%this)
//set up the paths
%tamlPath = %path @ %className @ ".taml";
%scriptPath = %path @ %className @ ".tscript";
%scriptPath = %path @ %className @ "." @ $TorqueScriptFileExtension;
saveGameObject(%className, %tamlPath, %scriptPath);
%asset = new GameObjectAsset()

View file

@ -23,7 +23,7 @@ function LooseFileAuditWindow::buildPopupMenus(%this)
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Script Asset" TAB "" TAB "LooseFileAuditWindow.importScript();";
item[0] = "Make a Script Asset" TAB "" TAB "LooseFileAuditWindow.impor" @ $TorqueScriptFileExtension @ "();";
item[1] = "Make a PostFX Asset" TAB "" TAB "LooseFileAuditWindow.importPostFX();";
item[2] = "Make a Material Asset" TAB "" TAB "LooseFileAuditWindow.importMaterial();";
item[3] = "Make a Terrain Material Asset" TAB "" TAB "LooseFileAuditWindow.importTerrMat();";
@ -159,7 +159,7 @@ function LooseFileList::onRightMouseDown(%this, %itemId)
{
ImageLooseFilePopup.showPopup(Canvas);
}
else if(%ext $= ".tscript")
else if(%ext $= "." @ $TorqueScriptFileExtension)
{
ScriptLooseFilePopup.showPopup(Canvas);
}
@ -199,7 +199,7 @@ function LooseFileAuditWindow::importImage(%this)
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importScript(%this)
function LooseFileAuditWindow::impor" @ $TorqueScriptFileExtension @ "(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();

View file

@ -329,7 +329,7 @@ function AssetBrowser::buildPopupMenus(%this)
//isPopup = true;
item[ 0 ] = "Open GameObject Editor" TAB "" TAB "echo(\"Not yet implemented.\");";
item[ 1 ] = "Edit GameObject Script" TAB "" TAB "AssetBrowser.editGameObjectAssetScript(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
item[ 1 ] = "Edit GameObject Script" TAB "" TAB "AssetBrowser.editGameObjectAsse" @ $TorqueScriptFileExtension @ "(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
item[ 2 ] = "-";
item[ 3 ] = "Apply Instance to GameObject" TAB "" TAB "AssetBrowser.applyInstanceToGameObject(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
item[ 4 ] = "Reset Instance to GameObject" TAB "" TAB "echo(\"Not yet implemented.\");";