MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / updatePreviewImage

Method updatePreviewImage

Engine/source/T3D/assets/MaterialAsset.cpp:601–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599}
600
601void GuiInspectorTypeMaterialAssetPtr::updatePreviewImage()
602{
603 const char* previewImage;
604 if (mInspector->getInspectObject() != nullptr)
605 previewImage = mInspector->getInspectObject()->getDataField(mCaption, NULL);
606 else
607 previewImage = Con::getVariable(mVariableName);
608
609 //if what we're working with isn't even a valid asset, don't present like we found a good one
610 if (!AssetDatabase.isDeclaredAsset(previewImage))
611 {
612 mPreviewImage->_setBitmap(StringTable->EmptyString());
613 return;
614 }
615
616 String matPreviewAssetId = String(previewImage) + "_PreviewImage";
617 matPreviewAssetId.replace(":", "_");
618 matPreviewAssetId = "ToolsModule:" + matPreviewAssetId;
619 if (AssetDatabase.isDeclaredAsset(matPreviewAssetId.c_str()))
620 {
621 mPreviewImage->setBitmap(StringTable->insert(matPreviewAssetId.c_str()));
622 }
623 else
624 {
625 if (AssetDatabase.isDeclaredAsset(previewImage))
626 {
627 MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(previewImage);
628 if (matAsset && matAsset->getMaterialDefinition())
629 {
630 mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->mDiffuseMapAssetId[0]);
631 }
632 }
633 }
634
635 if (mPreviewImage->getBitmapAsset().isNull())
636 mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
637}
638
639void GuiInspectorTypeMaterialAssetPtr::setPreviewImage(StringTableEntry assetId)
640{

Callers

nothing calls this directly

Calls 12

getVariableFunction · 0.85
getDataFieldMethod · 0.80
isDeclaredAssetMethod · 0.80
_setBitmapMethod · 0.80
EmptyStringMethod · 0.80
replaceMethod · 0.80
StringClass · 0.50
c_strMethod · 0.45
setBitmapMethod · 0.45
insertMethod · 0.45
getMaterialDefinitionMethod · 0.45
isNullMethod · 0.45

Tested by

no test coverage detected