fix GuiBitmapButtonCtrl setBitmap script command

it was pointing at the macro method direct, not the bespoke case that *also* calls the macro method.
This commit is contained in:
AzaezelX 2025-12-25 17:47:31 -06:00
parent 7bca1dba53
commit d50161d296
3 changed files with 61 additions and 20 deletions

View file

@ -262,6 +262,51 @@ void GuiBitmapButtonCtrl::setAutoFitExtents( bool state )
}
//-----------------------------------------------------------------------------
void GuiBitmapButtonCtrl::_setBitmap(StringTableEntry _in)
{
if (mBitmapAsset.getAssetId() == _in)
return;
if (getBitmapFile() == _in)
return;
if (_in == 0 || !String::compare(_in, _getStringTable()->EmptyString()))
{
mBitmapAsset = 0;
mBitmapFile = "";
return;
}
if (!AssetDatabase.isDeclaredAsset(_in))
{
StringTableEntry imageAssetId = _getStringTable()->EmptyString();
AssetQuery query;
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in);
if (foundAssetcount != 0)
{
imageAssetId = query.mAssetList[0];
}
else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#'))
{
imageAssetId = ImageAsset::getAssetIdByFilename(_in);
if (imageAssetId == ImageAsset::smNoImageAssetFallback)
{
ImageAsset* privateImage = new ImageAsset();
privateImage->setImageFile(_in);
imageAssetId = AssetDatabase.addPrivateAsset(privateImage);
}
}
else {
Con::warnf("%s::%s: Could not find asset for: %s using fallback", "GuiBitmapButtonCtrl", "Bitmap", _in);
imageAssetId = ImageAsset::smNoImageAssetFallback;
} mBitmapAsset = imageAssetId;
mBitmapFile = _in;
}
else
{
mBitmapAsset = _in;
mBitmapFile = getBitmapFile();
}
}
void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
{
@ -669,4 +714,10 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
return Parent::pointInControl(parentCoordPoint);
}
DEF_ASSET_BINDS_REFACTOR(GuiBitmapButtonCtrl, Bitmap)
DefineEngineMethod(GuiBitmapButtonCtrl, getBitmap, StringTableEntry, (), , "get name") {
return object->getBitmapFile();
}DefineEngineMethod(GuiBitmapButtonCtrl, getBitmapAsset, StringTableEntry, (), , assetText(Bitmap, asset reference)) {
return object->_getBitmap();
}DefineEngineMethod(GuiBitmapButtonCtrl, setBitmap, void, (const char* assetName), , assetText(Bitmap, assignment.first tries asset then flat file.)) {
object->setBitmap(StringTable->insert(assetName));
}