From 1e21cc678f52e7860efe36a374e55b583fb46db4 Mon Sep 17 00:00:00 2001 From: Areloch Date: Sun, 4 Feb 2024 14:45:19 -0600 Subject: [PATCH] Fixes the handling of imageAssets for array'd field types, as well as fixing the editor behavior of guiBitmapCtrl so the imageAssets correctly update the fields upon editing --- Engine/source/T3D/assets/ImageAsset.cpp | 8 ++++---- Engine/source/gui/controls/guiBitmapCtrl.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index af03cfe2d..ba559888d 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -482,13 +482,13 @@ GuiControl* GuiInspectorTypeImageAssetPtr::constructEditControl() if (mInspector->getInspectObject() != nullptr) { - dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ImageAsset\", \"AssetBrowser.changeAsset\", %s, %s);", - mInspector->getIdString(), mCaption); + dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ImageAsset\", \"AssetBrowser.changeAsset\", %s);", + getIdString()); mBrowseButton->setField("Command", szBuffer); setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString()); - previewImage = mInspector->getInspectObject()->getDataField(mCaption, NULL); + previewImage = getData(); } else { @@ -672,7 +672,7 @@ void GuiInspectorTypeImageAssetPtr::updatePreviewImage() { const char* previewImage; if (mInspector->getInspectObject() != nullptr) - previewImage = mInspector->getInspectObject()->getDataField(mCaption, NULL); + previewImage = getData(); else previewImage = Con::getVariable(mVariableName); diff --git a/Engine/source/gui/controls/guiBitmapCtrl.cpp b/Engine/source/gui/controls/guiBitmapCtrl.cpp index 18be526f1..783942d08 100644 --- a/Engine/source/gui/controls/guiBitmapCtrl.cpp +++ b/Engine/source/gui/controls/guiBitmapCtrl.cpp @@ -117,6 +117,19 @@ void GuiBitmapCtrl::onSleep() //------------------------------------- void GuiBitmapCtrl::inspectPostApply() { + //This is a little bit of a 'special case' handling for this class + //Because we don't do the normal protectedField setup for the bitmapName/bitmapAsset fields + //which would automatically update the internal values and bound content, we'll do it here manually + //to ensure it's updated before we force a refresh, which would thrash the new values + if (mBitmapName != StringTable->insert("texhandle")) + { + _setBitmap(mBitmapAssetId); + } + else + { + setBitmap(getBitmap()); + } + // if the extent is set to (0,0) in the gui editor and appy hit, this control will // set it's extent to be exactly the size of the bitmap (if present) Parent::inspectPostApply();