Implementation of updated handling of Legacy Project importer to better seperate out importer versions as well as more explicit processing of incoming content

This commit is contained in:
JeffR 2022-01-20 01:14:43 -06:00
parent 3812ce2e82
commit ecd35df7e9
14 changed files with 3107 additions and 2663 deletions

View file

@ -102,7 +102,7 @@ void GUIAsset::initPersistFields()
&setScriptFile, &getScriptFile, "Path to the script file for the gui");
addProtectedField("GUIFile", TypeAssetLooseFilePath, Offset(mGUIFile, GUIAsset),
&setScriptFile, &getScriptFile, "Path to the gui file");
&setGUIFile, &getGUIFile, "Path to the gui file");
}
//------------------------------------------------------------------------------

View file

@ -623,8 +623,8 @@ const char* ShapeAsset::generateCachedPreviewImage(S32 resolution, String overri
String dumpPath = String(mFilePath) + "_Preview.dds";
char* returnBuffer = Con::getReturnBuffer(dumpPath.length());
dSprintf(returnBuffer, dumpPath.length(), "%s", dumpPath.c_str());
char* returnBuffer = Con::getReturnBuffer(128);
dSprintf(returnBuffer, 128, "%s", dumpPath.c_str());
/*FileStream stream;
if (stream.open(dumpPath, Torque::FS::File::Write))

View file

@ -2099,22 +2099,28 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m
String imgFileName = AssetImporter::findImagePath(testFilePath.getPath() + "/" + testFilePath.getFileName());
if (imgFileName.isNotEmpty())
filePath = imgFileName;
else
filePath = ""; //no luck, so we just won't try importing in the image
}
}
matAssetItem = addImportingAsset("MaterialAsset", shapePathBase + "/" + matName, assetItem, matName);
AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
String suffixType;
String suffix = parseImageSuffixes(imageAssetItem->assetName, &suffixType);
if (suffix.isNotEmpty())
if (!filePath.isEmpty())
{
imageAssetItem->imageSuffixType = suffixType;
}
else
{
//we'll assume it's albedo
imageAssetItem->imageSuffixType = "Albedo";
AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
String suffixType;
String suffix = parseImageSuffixes(imageAssetItem->assetName, &suffixType);
if (suffix.isNotEmpty())
{
imageAssetItem->imageSuffixType = suffixType;
}
else
{
//we'll assume it's albedo
imageAssetItem->imageSuffixType = "Albedo";
}
}
}
else

View file

@ -217,6 +217,11 @@ ImplementEnumType(_TamlFormatMode,
FileStream stream;
if (StringTable->insert("c://.asset.taml") == StringTable->insert(mFilePathBuffer))
{
bool asdfasdf = true;
}
// File opened?
if (!stream.open(mFilePathBuffer, Torque::FS::File::Write))
{

View file

@ -256,8 +256,10 @@ DefineEngineFunction(TamlWrite, bool, (SimObject* simObject, const char* filenam
}
else
{
// No, so warn.
Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
#ifdef TORQUE_DEBUG
// No, so warn.
Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
#endif
}
// Turn-off auto-formatting.

View file

@ -100,7 +100,7 @@
<Setting name="LOSCollisionMeshPrefix">LOS</Setting>
</Group>
<Group name="General">
<Setting name="AddDirectoryPrefixToAssetName">1</Setting>
<Setting name="AddDirectoryPrefixToAssetName">0</Setting>
<Setting name="AutomaticallyPromptMissingFiles">0</Setting>
<Setting name="DuplicateAutoResolution">FolderPrefix</Setting>
<Setting name="PreventImportWithErrors">1</Setting>

View file

@ -0,0 +1,7 @@
<GUIAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="pre40ImporterGuis"
GUIFile="@assetFile=pre40ImporterGuis.gui"
ScriptFile="@assetFile=pre40ImporterGuis.tscript"
VersionId="1" />

View file

@ -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 ---

View file

@ -0,0 +1,92 @@
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();
}
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();
}

View file

@ -24,11 +24,6 @@ function initializeProjectImporter()
echo(" % - Initializing Project Importer");
exec("./scripts/projectImporter." @ $TorqueScriptFileExtension);
//Versioned actions
exec("./scripts/pre40/T3Dpre4ProjectImporter." @ $TorqueScriptFileExtension);
exec("./guis/projectImporter.gui");
new ScriptObject( ProjectImporterPlugin )