Updates ImageAsset usage to utilize AssetRef, and standardizes the setter/getter functions and naming conventions, as well as the ability to use and bind named targets.

This commit is contained in:
JeffR 2026-06-16 17:39:30 -05:00
parent a858d8624e
commit 34e3f78a22
82 changed files with 1451 additions and 951 deletions

View file

@ -67,7 +67,8 @@ void GuiChunkedBitmapCtrl::initPersistFields()
{
docsURL;
addGroup("GuiChunkedBitmapCtrl");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap to render to the control.");
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiChunkedBitmapCtrl))
.doc("This is the bitmap asset to render to the control.");
addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file "
"or a bitmap stored in \"variable\"");
@ -92,6 +93,21 @@ GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
mTile = false;
}
void GuiChunkedBitmapCtrl::_setBitmap(StringTableEntry _in)
{
if (mBitmapAssetRef.assetId == _in)
return;
if (ImageAsset::isNamedTarget(_in))
{
mBitmapAssetRef.assetId = _in;
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
return;
}
mBitmapAssetRef = _in;
}
void GuiChunkedBitmapCtrl::setBitmap(const char *name)
{
bool awake = mAwake;

View file

@ -17,7 +17,7 @@ private:
protected:
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
AssetRef<ImageAsset> mBitmapAssetRef;
bool mUseVariable;
bool mTile;
@ -36,5 +36,9 @@ public:
void setBitmap(const char *name);
void _setBitmap(StringTableEntry _in);
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
void onRender(Point2I offset, const RectI &updateRect) override;
};

View file

@ -131,15 +131,31 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
void GuiProgressBitmapCtrl::initPersistFields()
{
docsURL;
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiProgressBitmapCtrl, "Bitmap file to use for rendering the progress bar.\n\n"
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiProgressBitmapCtrl))
.doc("Bitmap asset to use for rendering the progress bar.\n\n"
"If the profile assigned to the control already has a bitmap assigned, this property need not be "
"set in which case the bitmap from the profile is used.");
Parent::initPersistFields();
}
//-----------------------------------------------------------------------------
void GuiProgressBitmapCtrl::_setBitmap(StringTableEntry _in)
{
if (mBitmapAssetRef.assetId == _in)
return;
if (ImageAsset::isNamedTarget(_in))
{
mBitmapAssetRef.assetId = _in;
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
return;
}
mBitmapAssetRef = _in;
}
void GuiProgressBitmapCtrl::setBitmap( const char* name )
{
bool awake = mAwake;

View file

@ -47,7 +47,7 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
F32 mProgress;
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
AssetRef<ImageAsset> mBitmapAssetRef;
bool mUseVariable;
bool mTile;
@ -59,6 +59,10 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
GuiProgressBitmapCtrl();
void setBitmap( const char* name );
void _setBitmap(StringTableEntry _in);
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
//console related methods
const char *getScriptValue() override;