mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Shift file handling in importer to a standardized function
Added santizing of strings to filenames, object names and asset names for the importer process Added sanitizeString console function for above Added processing of terrainBlock object's fields for importer Added check to avoid updateTSShapeLoadProgress spam Adjusted folderPrefix logic to walk up directory to find assetName that isn't already in use.
This commit is contained in:
parent
190343cbc7
commit
48e994f7bd
5 changed files with 227 additions and 137 deletions
|
|
@ -574,6 +574,40 @@ DefineEngineFunction( stripChars, const char*, ( const char* str, const char* ch
|
|||
return( ret );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
DefineEngineFunction(sanitizeString, const char*, (const char* str), ,
|
||||
"Sanitizes a string of common name issues, such as:\n"
|
||||
"Starting with numbers, replacing spaces with _, and removing any name un-compliant characters such as .,- etc\n"
|
||||
"@param str The string to sanitize.\n"
|
||||
"@return A version of @a str with all occurrences of invalid characters removed.\n\n"
|
||||
"@tsexample\n"
|
||||
"cleanString( \"123 .-_abc\"); // Returns \"__abc\"."
|
||||
"@endtsexample\n"
|
||||
"@ingroup Strings")
|
||||
{
|
||||
String processedString = str;
|
||||
|
||||
U32 start;
|
||||
U32 end;
|
||||
String firstNumber = String::GetFirstNumber(processedString, start, end);
|
||||
if (!firstNumber.isEmpty() && processedString.startsWith(firstNumber.c_str()))
|
||||
processedString = processedString.replace(firstNumber, "");
|
||||
|
||||
processedString = processedString.replace(" ", "_");
|
||||
|
||||
U32 len = processedString.length() + 1;
|
||||
char* ret = Con::getReturnBuffer(len);
|
||||
dStrcpy(ret, processedString.c_str(), len);
|
||||
|
||||
U32 pos = dStrcspn(ret, "-+*/%$&<26>=()[].?\\\"#,;!~<>|<7C>^{}");
|
||||
while (pos < dStrlen(ret))
|
||||
{
|
||||
dStrcpy(ret + pos, ret + pos + 1, len - pos);
|
||||
pos = dStrcspn(ret, "-+*/%$&<26>=()[].?\\\"#,;!~<>|<7C>^{}");
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( strlwr, const char*, ( const char* str ),,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue