mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
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:
parent
7bca1dba53
commit
d50161d296
3 changed files with 61 additions and 20 deletions
|
|
@ -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 )
|
void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
{
|
{
|
||||||
|
|
@ -669,4 +714,10 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
|
||||||
return Parent::pointInControl(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));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,24 +122,8 @@ private:
|
||||||
AssetPtr<ImageAsset> mBitmapAsset;
|
AssetPtr<ImageAsset> mBitmapAsset;
|
||||||
String mBitmapFile;
|
String mBitmapFile;
|
||||||
public:
|
public:
|
||||||
void _setBitmap(StringTableEntry _in) {
|
void _setBitmap(StringTableEntry _in);
|
||||||
if (_in == NULL || _in == StringTable->EmptyString() || _in == "")
|
inline StringTableEntry _getBitmap(void) const {
|
||||||
{
|
|
||||||
mBitmapAsset = NULL;
|
|
||||||
mBitmapFile = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mBitmapAsset.getAssetId() == _in) return; if (!AssetDatabase.isDeclaredAsset(_in)) {
|
|
||||||
StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback; AssetQuery query; S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); if (foundAssetcount != 0) {
|
|
||||||
imageAssetId = query.mAssetList[0];
|
|
||||||
} mBitmapAsset = imageAssetId;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mBitmapAsset = _in;
|
|
||||||
mBitmapName = _in;
|
|
||||||
mBitmap = getBitmap();
|
|
||||||
}
|
|
||||||
}; inline StringTableEntry _getBitmap(void) const {
|
|
||||||
return mBitmapAsset.getAssetId();
|
return mBitmapAsset.getAssetId();
|
||||||
} GFXTexHandle getBitmap() {
|
} GFXTexHandle getBitmap() {
|
||||||
return mBitmapAsset.notNull() ? mBitmapAsset->getTexture(&GFXDefaultGUIProfile) : 0;
|
return mBitmapAsset.notNull() ? mBitmapAsset->getTexture(&GFXDefaultGUIProfile) : 0;
|
||||||
|
|
|
||||||
|
|
@ -464,4 +464,10 @@ void GuiIconButtonCtrl::renderBitmapArray(RectI &bounds, S32 state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ASSET_BINDS_REFACTOR(GuiIconButtonCtrl, Bitmap)
|
DefineEngineMethod(GuiIconButtonCtrl, getBitmap, StringTableEntry, (), , "get name") {
|
||||||
|
return object->getBitmapFile();
|
||||||
|
}DefineEngineMethod(GuiIconButtonCtrl, getBitmapAsset, StringTableEntry, (), , assetText(Bitmap, asset reference)) {
|
||||||
|
return object->_getBitmap();
|
||||||
|
}DefineEngineMethod(GuiIconButtonCtrl, setBitmap, void, (const char* assetName), , assetText(Bitmap, assignment.first tries asset then flat file.)) {
|
||||||
|
object->setBitmap(StringTable->insert(assetName));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue