Merge pull request #1207 from Areloch/ImageAssetArrayInspectorFix

Fixes the handling of imageAssets for array'd field types, as well asfixing the editor behavior of guiBitmapCtrl so the imageAssets correctly update the fields upon editing
This commit is contained in:
Brian Roberts 2024-02-04 15:49:20 -06:00 committed by GitHub
commit 3fd4cbdb89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 4 deletions

View file

@ -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);

View file

@ -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();