mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Merge pull request #719 from Areloch/UpdatedProjectImporter
Updated project importer
This commit is contained in:
commit
d14ffc8714
14 changed files with 3092 additions and 2788 deletions
|
|
@ -102,7 +102,7 @@ void GUIAsset::initPersistFields()
|
||||||
&setScriptFile, &getScriptFile, "Path to the script file for the gui");
|
&setScriptFile, &getScriptFile, "Path to the script file for the gui");
|
||||||
|
|
||||||
addProtectedField("GUIFile", TypeAssetLooseFilePath, Offset(mGUIFile, GUIAsset),
|
addProtectedField("GUIFile", TypeAssetLooseFilePath, Offset(mGUIFile, GUIAsset),
|
||||||
&setScriptFile, &getScriptFile, "Path to the gui file");
|
&setGUIFile, &getGUIFile, "Path to the gui file");
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -623,8 +623,8 @@ const char* ShapeAsset::generateCachedPreviewImage(S32 resolution, String overri
|
||||||
|
|
||||||
String dumpPath = String(mFilePath) + "_Preview.dds";
|
String dumpPath = String(mFilePath) + "_Preview.dds";
|
||||||
|
|
||||||
char* returnBuffer = Con::getReturnBuffer(dumpPath.length());
|
char* returnBuffer = Con::getReturnBuffer(128);
|
||||||
dSprintf(returnBuffer, dumpPath.length(), "%s", dumpPath.c_str());
|
dSprintf(returnBuffer, 128, "%s", dumpPath.c_str());
|
||||||
|
|
||||||
/*FileStream stream;
|
/*FileStream stream;
|
||||||
if (stream.open(dumpPath, Torque::FS::File::Write))
|
if (stream.open(dumpPath, Torque::FS::File::Write))
|
||||||
|
|
|
||||||
|
|
@ -2099,22 +2099,28 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m
|
||||||
String imgFileName = AssetImporter::findImagePath(testFilePath.getPath() + "/" + testFilePath.getFileName());
|
String imgFileName = AssetImporter::findImagePath(testFilePath.getPath() + "/" + testFilePath.getFileName());
|
||||||
if (imgFileName.isNotEmpty())
|
if (imgFileName.isNotEmpty())
|
||||||
filePath = imgFileName;
|
filePath = imgFileName;
|
||||||
|
else
|
||||||
|
filePath = ""; //no luck, so we just won't try importing in the image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
matAssetItem = addImportingAsset("MaterialAsset", shapePathBase + "/" + matName, assetItem, matName);
|
matAssetItem = addImportingAsset("MaterialAsset", shapePathBase + "/" + matName, assetItem, matName);
|
||||||
AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
|
|
||||||
|
|
||||||
String suffixType;
|
if (!filePath.isEmpty())
|
||||||
String suffix = parseImageSuffixes(imageAssetItem->assetName, &suffixType);
|
|
||||||
if (suffix.isNotEmpty())
|
|
||||||
{
|
{
|
||||||
imageAssetItem->imageSuffixType = suffixType;
|
AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
|
||||||
}
|
|
||||||
else
|
String suffixType;
|
||||||
{
|
String suffix = parseImageSuffixes(imageAssetItem->assetName, &suffixType);
|
||||||
//we'll assume it's albedo
|
if (suffix.isNotEmpty())
|
||||||
imageAssetItem->imageSuffixType = "Albedo";
|
{
|
||||||
|
imageAssetItem->imageSuffixType = suffixType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//we'll assume it's albedo
|
||||||
|
imageAssetItem->imageSuffixType = "Albedo";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,11 @@ ImplementEnumType(_TamlFormatMode,
|
||||||
|
|
||||||
FileStream stream;
|
FileStream stream;
|
||||||
|
|
||||||
|
if (StringTable->insert("c://.asset.taml") == StringTable->insert(mFilePathBuffer))
|
||||||
|
{
|
||||||
|
bool asdfasdf = true;
|
||||||
|
}
|
||||||
|
|
||||||
// File opened?
|
// File opened?
|
||||||
if (!stream.open(mFilePathBuffer, Torque::FS::File::Write))
|
if (!stream.open(mFilePathBuffer, Torque::FS::File::Write))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -256,8 +256,10 @@ DefineEngineFunction(TamlWrite, bool, (SimObject* simObject, const char* filenam
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No, so warn.
|
#ifdef TORQUE_DEBUG
|
||||||
Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
|
// No, so warn.
|
||||||
|
Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn-off auto-formatting.
|
// Turn-off auto-formatting.
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
<Setting name="LOSCollisionMeshPrefix">LOS</Setting>
|
<Setting name="LOSCollisionMeshPrefix">LOS</Setting>
|
||||||
</Group>
|
</Group>
|
||||||
<Group name="General">
|
<Group name="General">
|
||||||
<Setting name="AddDirectoryPrefixToAssetName">1</Setting>
|
<Setting name="AddDirectoryPrefixToAssetName">0</Setting>
|
||||||
<Setting name="AutomaticallyPromptMissingFiles">0</Setting>
|
<Setting name="AutomaticallyPromptMissingFiles">0</Setting>
|
||||||
<Setting name="DuplicateAutoResolution">FolderPrefix</Setting>
|
<Setting name="DuplicateAutoResolution">FolderPrefix</Setting>
|
||||||
<Setting name="PreventImportWithErrors">1</Setting>
|
<Setting name="PreventImportWithErrors">1</Setting>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,7 @@
|
||||||
|
<GUIAsset
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
AssetName="pre40ImporterGuis"
|
||||||
|
GUIFile="@assetFile=pre40ImporterGuis.gui"
|
||||||
|
ScriptFile="@assetFile=pre40ImporterGuis.tscript"
|
||||||
|
VersionId="1" />
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
//--- OBJECT WRITE BEGIN ---
|
||||||
|
new GuiContainer(Pre40ImporterPage0) {
|
||||||
|
margin = "0 0 0 0";
|
||||||
|
padding = "0 0 0 0";
|
||||||
|
anchorTop = "1";
|
||||||
|
anchorBottom = "0";
|
||||||
|
anchorLeft = "1";
|
||||||
|
anchorRight = "0";
|
||||||
|
position = "1 1";
|
||||||
|
extent = "539 429";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "width";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "GuiDefaultProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "1";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "1";
|
||||||
|
|
||||||
|
new GuiMLTextCtrl() {
|
||||||
|
lineSpacing = "2";
|
||||||
|
allowColorChars = "0";
|
||||||
|
maxChars = "-1";
|
||||||
|
text = "Next, we'll import in content files, such as image, models and sounds.";
|
||||||
|
useURLMouseCursor = "0";
|
||||||
|
position = "111 21";
|
||||||
|
extent = "328 28";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "ToolsGuiMLTextProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "0";
|
||||||
|
};
|
||||||
|
new GuiMLTextCtrl() {
|
||||||
|
lineSpacing = "2";
|
||||||
|
allowColorChars = "0";
|
||||||
|
maxChars = "-1";
|
||||||
|
text = "Processing...";
|
||||||
|
useURLMouseCursor = "0";
|
||||||
|
position = "152 141";
|
||||||
|
extent = "245 14";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "ToolsGuiDefaultProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
|
internalName = "processingText";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
new GuiContainer(Pre40ImporterPage1) {
|
||||||
|
margin = "0 0 0 0";
|
||||||
|
padding = "0 0 0 0";
|
||||||
|
anchorTop = "1";
|
||||||
|
anchorBottom = "0";
|
||||||
|
anchorLeft = "1";
|
||||||
|
anchorRight = "0";
|
||||||
|
position = "1 1";
|
||||||
|
extent = "539 429";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "width";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "GuiDefaultProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "1";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "1";
|
||||||
|
|
||||||
|
new GuiMLTextCtrl() {
|
||||||
|
lineSpacing = "2";
|
||||||
|
allowColorChars = "0";
|
||||||
|
maxChars = "-1";
|
||||||
|
text = "Now, we'll import in script-based files such as guis, levels and scripts.";
|
||||||
|
useURLMouseCursor = "0";
|
||||||
|
position = "111 21";
|
||||||
|
extent = "328 28";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "ToolsGuiMLTextProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "0";
|
||||||
|
};
|
||||||
|
new GuiMLTextCtrl() {
|
||||||
|
lineSpacing = "2";
|
||||||
|
allowColorChars = "0";
|
||||||
|
maxChars = "-1";
|
||||||
|
text = "Processing...";
|
||||||
|
useURLMouseCursor = "0";
|
||||||
|
position = "152 141";
|
||||||
|
extent = "245 14";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "ToolsGuiDefaultProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
|
internalName = "processingText";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
//--- OBJECT WRITE END ---
|
||||||
|
|
@ -0,0 +1,99 @@
|
||||||
|
//==============================================================================
|
||||||
|
// We first copy over binary files(images, shapes, sounds, etc) to the destination
|
||||||
|
// module, then run the processing/import on them to generate the assets
|
||||||
|
//==============================================================================
|
||||||
|
function Pre40ImporterPage0::openPage(%this)
|
||||||
|
{
|
||||||
|
ProjectImportWindow-->nextButton.setActive(false);
|
||||||
|
%this-->processingText.setText("Processing...");
|
||||||
|
Canvas.repaint();
|
||||||
|
|
||||||
|
//copy binary files over
|
||||||
|
for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
|
||||||
|
{
|
||||||
|
%file = $ProjectImporter::FileList.getKey(%i);
|
||||||
|
%rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
|
||||||
|
if(%rootFileSectionObject.binaryFile == true)
|
||||||
|
{
|
||||||
|
%filePath = filePath(%file);
|
||||||
|
%fileName = %rootFileSectionObject.fileName;
|
||||||
|
%fileBase = %rootFileSectionObject.fileBase;
|
||||||
|
%fileExt = %rootFileSectionObject.fileExt;
|
||||||
|
|
||||||
|
//filter out some unneeded folders
|
||||||
|
%slashCount = getTokenCount(%filePath, "/");
|
||||||
|
%topFolder = getToken(%filePath, "/", %slashCount-1);
|
||||||
|
if(%topFolder $= "")
|
||||||
|
%topFolder = getToken(%filePath, "/", %slashCount-2);
|
||||||
|
|
||||||
|
if(%topFolder $= "creator" || %topFolder $= "tools" || %topFolder $= "web")
|
||||||
|
{
|
||||||
|
%file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
%targetFilePath = strReplace(%file, $ProjectImporter::sourceContentFolder, $ProjectImporter::modulePath);
|
||||||
|
|
||||||
|
%sanitizedFilename = sanitizeString(%fileBase);
|
||||||
|
if(startsWith(%sanitizedFilename, "_"))
|
||||||
|
{
|
||||||
|
%sanitizedFilename = substr(%sanitizedFilename, 1, -1);
|
||||||
|
}
|
||||||
|
if(%sanitizedFilename !$= %fileBase)
|
||||||
|
{
|
||||||
|
%targetFilePath = filePath(%targetFilePath) @ "/" @ %sanitizedFilename @ %fileExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
%targetFolder = filePath(%targetFilePath);
|
||||||
|
|
||||||
|
if(!isDirectory(%targetFolder))
|
||||||
|
{
|
||||||
|
DirectoryHandler::createFolder(0, %targetFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!pathCopy(%file, %targetFilePath, false))
|
||||||
|
{
|
||||||
|
$ProjectImporter::log.add("Legacy Project Importer, failed to copy file: " @ %file @ " to destination: " @ %targetFilePath);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
%rootFileSectionObject.localPath = %targetFilePath;
|
||||||
|
|
||||||
|
//If it was an asset definition file, go ahead and register it
|
||||||
|
if(%rootFileSectionObject.isAssetFile)
|
||||||
|
{
|
||||||
|
%moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%targetFilePath).ModuleId;
|
||||||
|
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||||
|
|
||||||
|
AssetDatabase.addDeclaredAsset(%moduleDef, %targetFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Now, we need to do some initial importing processing
|
||||||
|
T3Dpre4ProjectImporter.doContentImport();
|
||||||
|
|
||||||
|
//Once that's done, update the text of the UI
|
||||||
|
%this-->processingText.setText("Done!");
|
||||||
|
ProjectImportWindow-->nextButton.setActive(true);
|
||||||
|
Canvas.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
// This page actually invokes the processing of the script-based files and objects
|
||||||
|
//==============================================================================
|
||||||
|
function Pre40ImporterPage1::openPage(%this)
|
||||||
|
{
|
||||||
|
ProjectImportWindow-->nextButton.setActive(false);
|
||||||
|
%this-->processingText.setText("Processing...");
|
||||||
|
Canvas.repaint();
|
||||||
|
|
||||||
|
//Now, we need to do some initial importing processing
|
||||||
|
T3Dpre4ProjectImporter.doScriptImport();
|
||||||
|
|
||||||
|
//Once that's done, update the text of the UI
|
||||||
|
%this-->processingText.setText("Done!");
|
||||||
|
ProjectImportWindow-->nextButton.setActive(true);
|
||||||
|
Canvas.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -24,11 +24,6 @@ function initializeProjectImporter()
|
||||||
echo(" % - Initializing Project Importer");
|
echo(" % - Initializing Project Importer");
|
||||||
|
|
||||||
exec("./scripts/projectImporter." @ $TorqueScriptFileExtension);
|
exec("./scripts/projectImporter." @ $TorqueScriptFileExtension);
|
||||||
|
|
||||||
//Versioned actions
|
|
||||||
exec("./scripts/pre40/T3Dpre4ProjectImporter." @ $TorqueScriptFileExtension);
|
|
||||||
|
|
||||||
|
|
||||||
exec("./guis/projectImporter.gui");
|
exec("./guis/projectImporter.gui");
|
||||||
|
|
||||||
new ScriptObject( ProjectImporterPlugin )
|
new ScriptObject( ProjectImporterPlugin )
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue