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

Method updatePreviewImage

Engine/source/T3D/assets/ImageAsset.cpp:674–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672}
673
674void GuiInspectorTypeImageAssetPtr::updatePreviewImage()
675{
676 const char* previewImage;
677 if (mInspector->getInspectObject() != nullptr)
678 previewImage = mInspector->getInspectObject()->getDataField(mCaption, NULL);
679 else
680 previewImage = Con::getVariable(mVariableName);
681
682 //if what we're working with isn't even a valid asset, don't present like we found a good one
683 if (!AssetDatabase.isDeclaredAsset(previewImage))
684 {
685 mPreviewImage->_setBitmap(StringTable->EmptyString());
686 return;
687 }
688
689 String imgPreviewAssetId = String(previewImage) + "_PreviewImage";
690 imgPreviewAssetId.replace(":", "_");
691 imgPreviewAssetId = "ToolsModule:" + imgPreviewAssetId;
692 if (AssetDatabase.isDeclaredAsset(imgPreviewAssetId.c_str()))
693 {
694 mPreviewImage->setBitmap(StringTable->insert(imgPreviewAssetId.c_str()));
695 }
696 else
697 {
698 if (AssetDatabase.isDeclaredAsset(previewImage))
699 {
700 ImageAsset* imgAsset = AssetDatabase.acquireAsset<ImageAsset>(previewImage);
701 if (imgAsset && imgAsset->isAssetValid())
702 {
703 mPreviewImage->_setBitmap(imgAsset->getAssetId());
704 }
705 }
706 }
707
708 if (mPreviewImage->getBitmapAsset().isNull())
709 mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
710}
711
712void GuiInspectorTypeImageAssetPtr::setPreviewImage(StringTableEntry assetId)
713{

Callers

nothing calls this directly

Calls 13

getVariableFunction · 0.85
getDataFieldMethod · 0.80
isDeclaredAssetMethod · 0.80
_setBitmapMethod · 0.80
EmptyStringMethod · 0.80
replaceMethod · 0.80
isAssetValidMethod · 0.80
StringClass · 0.50
c_strMethod · 0.45
setBitmapMethod · 0.45
insertMethod · 0.45
getAssetIdMethod · 0.45

Tested by

no test coverage detected