Merge pull request #763 from Areloch/MiscFixes2022049

Misc FIxes for 2022/04/09
This commit is contained in:
Brian Roberts 2022-04-10 22:15:19 -05:00 committed by GitHub
commit 4ffa367240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 149 additions and 42 deletions

View file

@ -174,11 +174,6 @@ void MaterialAsset::initializeAsset()
return; return;
} }
if (mMatDefinitionName == StringTable->insert("DetailBlue"))
{
bool asdfsd = true;
}
if (size() != 0 && mScriptPath == StringTable->EmptyString()) if (size() != 0 && mScriptPath == StringTable->EmptyString())
{ {
mLoadedState = EmbeddedDefinition; mLoadedState = EmbeddedDefinition;

View file

@ -1633,7 +1633,7 @@ void AssetImporter::processImageAsset(AssetImportObject* assetItem)
{ {
String diffuseToken = StringUnit::getUnit(activeImportConfig->DiffuseTypeSuffixes, 0, ",;\t"); String diffuseToken = StringUnit::getUnit(activeImportConfig->DiffuseTypeSuffixes, 0, ",;\t");
assetItem->assetName = assetItem->assetName + diffuseToken; assetItem->assetName = assetItem->assetName + diffuseToken;
assetItem->cleanAssetName = assetItem->assetName; //assetItem->cleanAssetName = assetItem->assetName;
} }
else else
{ {
@ -1642,7 +1642,7 @@ void AssetImporter::processImageAsset(AssetImportObject* assetItem)
if ((materialAsset && materialAsset->assetName.compare(assetItem->assetName) == 0) || activeImportConfig->AlwaysAddImageSuffix) if ((materialAsset && materialAsset->assetName.compare(assetItem->assetName) == 0) || activeImportConfig->AlwaysAddImageSuffix)
{ {
assetItem->assetName = assetItem->assetName + activeImportConfig->AddedImageSuffix; assetItem->assetName = assetItem->assetName + activeImportConfig->AddedImageSuffix;
assetItem->cleanAssetName = assetItem->assetName; //assetItem->cleanAssetName = assetItem->assetName;
} }
} }
@ -1673,8 +1673,8 @@ void AssetImporter::processImageAsset(AssetImportObject* assetItem)
if(assetItem->assetName == assetItem->cleanAssetName && activeImportConfig->AlwaysAddImageSuffix) if(assetItem->assetName == assetItem->cleanAssetName && activeImportConfig->AlwaysAddImageSuffix)
{ {
assetItem->assetName = assetItem->assetName + activeImportConfig->AddedImageSuffix; if (!assetItem->assetName.endsWith(activeImportConfig->AddedImageSuffix.c_str()))
assetItem->cleanAssetName = assetItem->assetName; assetItem->assetName = assetItem->assetName + activeImportConfig->AddedImageSuffix;
} }
assetItem->importStatus = AssetImportObject::Processed; assetItem->importStatus = AssetImportObject::Processed;
@ -1727,7 +1727,8 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
//If there was no existing assetId, then lets see if it already exists in a legacy file, like a materials.cs or materials.tscript //If there was no existing assetId, then lets see if it already exists in a legacy file, like a materials.cs or materials.tscript
//If it does, we'll just make our asset point to that instead of a new file //If it does, we'll just make our asset point to that instead of a new file
Material* mat = MATMGR->getMaterialDefinitionByName(assetName); Material* mat;
Sim::findObject(assetName, mat);
if (!mat) if (!mat)
mat = MATMGR->getMaterialDefinitionByMapTo(assetName); mat = MATMGR->getMaterialDefinitionByMapTo(assetName);
@ -1752,8 +1753,8 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
{ {
if (activeImportConfig->AlwaysAddMaterialSuffix) //we only opt to force on the suffix if we're not obligating using the original material defs if (activeImportConfig->AlwaysAddMaterialSuffix) //we only opt to force on the suffix if we're not obligating using the original material defs
{ {
assetItem->assetName += activeImportConfig->AddedMaterialSuffix; if(!assetItem->assetName.endsWith(activeImportConfig->AddedMaterialSuffix.c_str()))
assetItem->cleanAssetName = assetItem->assetName; assetItem->assetName += activeImportConfig->AddedMaterialSuffix;
} }
if (activeImportConfig->PopulateMaterialMaps) if (activeImportConfig->PopulateMaterialMaps)
@ -1936,7 +1937,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
if (newImageAssetObj->assetName == assetItem->assetName) if (newImageAssetObj->assetName == assetItem->assetName)
{ {
newImageAssetObj->assetName += StringUnit::getUnit(suffixList.c_str(), 0, ",;\t"); newImageAssetObj->assetName += StringUnit::getUnit(suffixList.c_str(), 0, ",;\t");
newImageAssetObj->cleanAssetName = newImageAssetObj->assetName; //newImageAssetObj->cleanAssetName = newImageAssetObj->assetName;
} }
newImageAssetObj->imageSuffixType = ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes::Albedo); newImageAssetObj->imageSuffixType = ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes::Albedo);
@ -1954,7 +1955,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
if (matchedImageTypes[t]->assetName == assetItem->assetName) if (matchedImageTypes[t]->assetName == assetItem->assetName)
{ {
matchedImageTypes[t]->assetName += StringUnit::getUnit(suffixList.c_str(), 0, ",;\t"); matchedImageTypes[t]->assetName += StringUnit::getUnit(suffixList.c_str(), 0, ",;\t");
matchedImageTypes[t]->cleanAssetName = matchedImageTypes[t]->assetName; //matchedImageTypes[t]->cleanAssetName = matchedImageTypes[t]->assetName;
} }
} }
} }
@ -2000,8 +2001,8 @@ void AssetImporter::processShapeAsset(AssetImportObject* assetItem)
if (activeImportConfig->AlwaysAddShapeSuffix) if (activeImportConfig->AlwaysAddShapeSuffix)
{ {
assetItem->assetName += activeImportConfig->AddedShapeSuffix; if(!assetItem->assetName.endsWith(activeImportConfig->AddedShapeSuffix.c_str()))
assetItem->cleanAssetName = assetItem->assetName; assetItem->assetName += activeImportConfig->AddedShapeSuffix;
} }
S32 meshCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_meshCount"), nullptr)); S32 meshCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_meshCount"), nullptr));
@ -2094,8 +2095,8 @@ void AssetImporter::processShapeAnimationAsset(AssetImportObject* assetItem)
if (activeImportConfig->AlwaysAddShapeAnimationSuffix) if (activeImportConfig->AlwaysAddShapeAnimationSuffix)
{ {
assetItem->assetName += activeImportConfig->AddedShapeAnimationSuffix; if (!assetItem->assetName.endsWith(activeImportConfig->AddedShapeAnimationSuffix.c_str()))
assetItem->cleanAssetName = assetItem->assetName; assetItem->assetName += activeImportConfig->AddedShapeAnimationSuffix;
} }
S32 animCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_animCount"), nullptr)); S32 animCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_animCount"), nullptr));
@ -2237,8 +2238,8 @@ void AssetImporter::processSoundAsset(AssetImportObject* assetItem)
if (activeImportConfig->AlwaysAddSoundSuffix) if (activeImportConfig->AlwaysAddSoundSuffix)
{ {
assetItem->assetName += activeImportConfig->AddedSoundSuffix; if (!assetItem->assetName.endsWith(activeImportConfig->AddedSoundSuffix.c_str()))
assetItem->cleanAssetName = assetItem->assetName; assetItem->assetName += activeImportConfig->AddedSoundSuffix;
} }
assetItem->importStatus = AssetImportObject::Processed; assetItem->importStatus = AssetImportObject::Processed;
@ -2618,6 +2619,8 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath, String typ
else else
{ {
importAssets(); importAssets();
acquireAssets();
} }
dumpActivityLog(); dumpActivityLog();
@ -2729,10 +2732,6 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
tss->setShapeAssetId(assetId); tss->setShapeAssetId(assetId);
} }
} }
//Go ahead and force the asset to load now just to kick it for immediate use
AssetBase* assetDef = AssetDatabase.acquireAsset<AssetBase>(assetId);
AssetDatabase.releaseAsset(assetId);
} }
else else
{ {
@ -2757,6 +2756,34 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
dumpActivityLog(); dumpActivityLog();
} }
void AssetImporter::acquireAssets(AssetImportObject* assetItem)
{
Vector<AssetImportObject*> itemList = importingAssets;
if (assetItem != nullptr)
itemList = assetItem->childAssetItems;
for (U32 i = 0; i < itemList.size(); i++)
{
AssetImportObject* item = itemList[i];
if (item->importStatus == AssetImportObject::Skipped ||
item->importStatus == AssetImportObject::NotProcessed ||
item->importStatus == AssetImportObject::Error)
continue;
//recurse if needed, we want to process child items first for dependency reasons
acquireAssets(item);
//Go ahead and force the asset to load now just to kick it for immediate use
String assetId = item->moduleName + ":" + item->assetName;
if (AssetDatabase.isDeclaredAsset(assetId))
{
AssetBase* assetDef = AssetDatabase.acquireAsset<AssetBase>(assetId);
AssetDatabase.releaseAsset(assetId);
}
}
}
// //
// Type-specific import logic // Type-specific import logic
// //
@ -2916,7 +2943,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
{ {
Material* newMat = new Material(); Material* newMat = new Material();
newMat->registerObject(assetName); newMat->registerObject(assetName);
newMat->mMapTo = assetName; newMat->mMapTo = assetItem->cleanAssetName;
bool hasRoughness = false; bool hasRoughness = false;
for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) for (U32 i = 0; i < assetItem->childAssetItems.size(); i++)

View file

@ -914,6 +914,12 @@ public:
/// </summary> /// </summary>
Torque::Path importShapeAnimationAsset(AssetImportObject* assetItem); Torque::Path importShapeAnimationAsset(AssetImportObject* assetItem);
/// <summary>
/// Iterates over all the items in the current session and acquires them, which jumpstarts the loading/init'ng process on them, making the available for use immediately
/// <para>@param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children</para>
/// </summary>
void acquireAssets(AssetImportObject* assetItem = nullptr);
// //
/// <summary> /// <summary>
/// Gets the currently active import configuration /// Gets the currently active import configuration

View file

@ -92,7 +92,9 @@ DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObje
DefineEngineMethod(AssetImporter, importAssets, void, (),, DefineEngineMethod(AssetImporter, importAssets, void, (),,
"Runs the actual import action on the items.") "Runs the actual import action on the items.")
{ {
return object->importAssets(); object->importAssets();
object->acquireAssets();
} }
DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),, DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),,

View file

@ -892,4 +892,20 @@ DefineEngineFunction( createPath, bool, ( const char* path ),,
return Platform::createPath( pathName ); return Platform::createPath( pathName );
} }
DefineEngineFunction(deleteDirectory, bool, (const char* path), ,
"@brief Delete a directory from the hard drive\n\n"
"@param path Name and path of the folder to delete\n"
"@note THERE IS NO RECOVERY FROM THIS. Deleted files are gone for good.\n"
"@return True if file was successfully deleted\n"
"@ingroup FileSystem")
{
static char fileName[1024];
static char sandboxFileName[1024];
Con::expandScriptFilename(fileName, sizeof(fileName), path);
Platform::makeFullPathName(fileName, sandboxFileName, sizeof(sandboxFileName));
return Platform::deleteDirectory(sandboxFileName);
}
#endif // TORQUE_TOOLS #endif // TORQUE_TOOLS

View file

@ -240,10 +240,15 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
{ {
// If there is a bitmap array then render using it. // If there is a bitmap array then render using it.
// Otherwise use a standard fill. // Otherwise use a standard fill.
if(mProfile->mUseBitmapArray && mProfile->mBitmapArrayRects.size()) if (mProfile->mUseBitmapArray && mProfile->mBitmapArrayRects.size())
{
renderBitmapArray(boundsRect, stateMouseOver); renderBitmapArray(boundsRect, stateMouseOver);
}
else else
renderSlightlyRaisedBox(boundsRect, mProfile); {
drawer->drawRectFill(boundsRect, mProfile->mFillColorHL);
drawer->drawRect(boundsRect, mProfile->mBorderColorHL);
}
} }
else else
{ {
@ -258,8 +263,16 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
} }
else else
{ {
drawer->drawRectFill(boundsRect, mProfile->mFillColorNA); if (mActive)
drawer->drawRect(boundsRect, mProfile->mBorderColorNA); {
drawer->drawRectFill(boundsRect, mProfile->mFillColor);
drawer->drawRect(boundsRect, mProfile->mBorderColor);
}
else
{
drawer->drawRectFill(boundsRect, mProfile->mFillColorNA);
drawer->drawRect(boundsRect, mProfile->mBorderColorNA);
}
} }
} }
@ -302,7 +315,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
} }
else else
{ {
iconRect.set( offset + mButtonMargin, getExtent() - (mButtonMargin * 2) ); iconRect.set( offset + mButtonMargin, getExtent() - (Point2I(mAbs(mButtonMargin.x), mAbs(mButtonMargin.y)) * 2) );
if ( mMakeIconSquare ) if ( mMakeIconSquare )
{ {
@ -313,6 +326,20 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
iconRect.extent.x = iconRect.extent.y; iconRect.extent.x = iconRect.extent.y;
} }
if (mIconLocation == IconLocRight)
{
iconRect.point.x = (offset.x + getWidth()) - iconRect.extent.x + mButtonMargin.x;
}
else if (mIconLocation == IconLocLeft)
{
//default state presumes left positioning
}
else if (mIconLocation == IconLocCenter)
{
iconRect.point.x = offset.x + (getWidth() / 2) - (iconRect.extent.x / 2) + mButtonMargin.x;
iconRect.point.y = offset.y + (getHeight() / 2) - (iconRect.extent.y / 2) + mButtonMargin.y;
}
drawer->drawBitmapStretch( mBitmap, iconRect ); drawer->drawBitmapStretch( mBitmap, iconRect );
} }
} }

View file

@ -146,12 +146,14 @@ void GuiDecoyCtrl::onMouseMove(const GuiEvent &event)
GuiControl *tempControl = parent->findHitControl(localPoint); GuiControl *tempControl = parent->findHitControl(localPoint);
//the decoy control has the responsibility of keeping track of the decoyed controls status //the decoy control has the responsibility of keeping track of the decoyed controls status
if(mMouseOverDecoy == false && mDecoyReference != NULL) if(mMouseOverDecoy == false && mDecoyReference != NULL &&
!mDecoyReference->isDeleted() && !mDecoyReference->isRemoved())
{ {
tempControl->onMouseEnter(event); tempControl->onMouseEnter(event);
mMouseOverDecoy = true; mMouseOverDecoy = true;
} }
else if(tempControl != mDecoyReference && mDecoyReference != NULL) else if(tempControl != mDecoyReference && mDecoyReference != NULL &&
!mDecoyReference->isDeleted() && !mDecoyReference->isRemoved())
{ {
mDecoyReference->onMouseLeave(event); mDecoyReference->onMouseLeave(event);
mMouseOverDecoy = false; mMouseOverDecoy = false;

View file

@ -200,7 +200,7 @@ function OptionsMenu::apply(%this)
//for updates //for updates
if ( %targetVar $= "$pref::Video::displayDevice" ) if ( %targetVar $= "$pref::Video::displayDevice" )
{ {
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." ); schedule(32, 0, "MessageBoxOK", "Change requires restart", "Please restart the game for a display device change to take effect.");
} }
else if(startsWith(%targetVar, "$pref::PostFX::")) else if(startsWith(%targetVar, "$pref::PostFX::"))
{ {
@ -349,11 +349,6 @@ function populateDisplaySettingsList()
OptionName.setText(""); OptionName.setText("");
OptionDescription.setText(""); OptionDescription.setText("");
//First, lets double-check the active device is accurate. Sometimes the default value in our prefs doesn't match the active one
%displayDevice = getDisplayDeviceType();
if($changingDisplayDevice !$= "")
%displayDevice = $changingDisplayDevice;
%apiList = ""; %apiList = "";
%apiCount = GFXInit::getAdapterCount(); %apiCount = GFXInit::getAdapterCount();
%apiIdx = 0; %apiIdx = 0;
@ -374,7 +369,11 @@ function populateDisplaySettingsList()
trim(%apiList); trim(%apiList);
OptionsMenuSettingsList.addOptionRow("Display API", "$pref::Video::DisplayAPI", %apiList, false, "", true, "The display API used for rendering.", %displayDevice); %displayDevice = OptionsMenu.getOptionVariableValue("$pref::Video::displayDevice");
if(%displayDevice $= "")
%displayDevice = getDisplayDeviceType();
OptionsMenuSettingsList.addOptionRow("Display API", "$pref::Video::displayDevice", %apiList, false, "", true, "The display API used for rendering.", %displayDevice);
%numDevices = Canvas.getMonitorCount(); %numDevices = Canvas.getMonitorCount();
%devicesList = ""; %devicesList = "";
@ -977,6 +976,8 @@ function MenuOptionsButton::onChange(%this)
OptionName.setText(%optionName); OptionName.setText(%optionName);
OptionDescription.setText(%tooltipText); OptionDescription.setText(%tooltipText);
if(%optionMode == 0)
{
%currentValue = %this.getCurrentOption(); %currentValue = %this.getCurrentOption();
if(%currentValue !$= "") if(%currentValue !$= "")
{ {
@ -995,6 +996,20 @@ function MenuOptionsButton::onChange(%this)
} }
else else
OptionsMenu.unappliedChanges.setValue("\"" @ %saveReadyValue @ "\"", %prefIndex); OptionsMenu.unappliedChanges.setValue("\"" @ %saveReadyValue @ "\"", %prefIndex);
}
}
else if(%optionMode == 1)
{
%currentValue = %this.getValue();
%prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetVar);
if(%prefIndex == -1)
{
echo("Setting UnappliedChanges via add: key:" @ %targetVar @", value: " @ %currentValue);
OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %currentValue @ "\"" );
}
else
OptionsMenu.unappliedChanges.setValue("\"" @ %currentValue @ "\"", %prefIndex);
} }
//Update the UI in case there's responsive logic //Update the UI in case there's responsive logic

View file

@ -462,10 +462,17 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData,
if(isObject(%assetDef.materialDefinitionName)) if(isObject(%assetDef.materialDefinitionName))
{ {
//real fast, we'll be 100% sure that the image resource we need is loaded
%diffuseMapAssetId = %assetDef.materialDefinitionName.getDiffuseMapAsset(0);
if(AssetDatabase.isDeclaredAsset(%diffuseMapAssetId))
{
%diffuseMapAsset = AssetDatabase.acquireAsset(%diffuseMapAssetId);
AssetDatabase.releaseAsset(%diffuseMapAssetId);
}
%previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape"); %previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
%generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %assetDef.materialDefinitionName); %generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %assetDef.materialDefinitionName);
pathCopy(%generatedFilePath, %previewFilePath); pathCopy(%generatedFilePath, %previewFilePath, false);
fileDelete(%generatedFilePath); fileDelete(%generatedFilePath);
if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName)) if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))

View file

@ -290,12 +290,21 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %f
{ {
displayEditorLoadingGui("Generating Shape Asset Preview..."); displayEditorLoadingGui("Generating Shape Asset Preview...");
//real fast, we'll be 100% sure that the image resource we need is loaded
%matSlot0AssetId = %assetDef.materialSlot0;
if(AssetDatabase.isDeclaredAsset(%matSlot0AssetId))
{
%matAsset = AssetDatabase.acquireAsset(%matSlot0AssetId);
AssetDatabase.releaseAsset(%matSlot0AssetId);
}
//This is slightly hacky, but we're going to utilize the imposter/last detail system //This is slightly hacky, but we're going to utilize the imposter/last detail system
//to generate our previews for us and then clean up the unneeded bits //to generate our previews for us and then clean up the unneeded bits
%filePath = %assetDef.generateCachedPreviewImage(); %filePath = %assetDef.generateCachedPreviewImage();
pathCopy(%filePath, %previewFilePath); pathCopy(%filePath, %previewFilePath, false);
fileDelete(%filePath); //cleanup fileDelete(%filePath); //cleanup
if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName)) if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))

View file

@ -237,6 +237,7 @@ function AssetBrowser::buildPopupMenus(%this)
AddNewArtAssetPopup.enableItem(7, false); //shape animation AddNewArtAssetPopup.enableItem(7, false); //shape animation
AddNewArtAssetPopup.enableItem(13, false); //sound asset AddNewArtAssetPopup.enableItem(13, false); //sound asset
AddNewArtAssetPopup.enableItem(15, false); //particle effect AddNewArtAssetPopup.enableItem(15, false); //particle effect
AddNewArtAssetPopup.enableItem(17, false); //cubemap
if( !isObject( EditFolderPopup ) ) if( !isObject( EditFolderPopup ) )
{ {