gui image asset refactor

bitmap button popup ctrl ex
This commit is contained in:
marauder2k7 2024-12-22 17:03:44 +00:00
parent f519cff6ff
commit 4d893f51cf
6 changed files with 95 additions and 75 deletions

View file

@ -329,9 +329,6 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void)
mBackgroundCancel = false; // Added
mReverseTextList = false; // Added - Don't reverse text list if displaying up
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, Normal);
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, Depressed);
mBitmapBounds.set(16, 16); // Added
mHotTrackItems = false;
mIdMax = -1;
@ -356,8 +353,7 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "File name of bitmap to use");
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "Name of bitmap asset to use");
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(Bitmap, NumBitmapModes, GuiPopUpMenuCtrlEx, "Name of bitmap asset to use")
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrlEx), "Boundaries of bitmap displayed");
addField("hotTrackCallback", TypeBool, Offset(mHotTrackItems, GuiPopUpMenuCtrlEx),
@ -368,14 +364,6 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
Parent::initPersistFields();
}
bool GuiPopUpMenuCtrlEx::_setBitmaps(void* obj, const char* index, const char* data)
{
GuiPopUpMenuCtrlEx* object = static_cast<GuiPopUpMenuCtrlEx*>(obj);
object->setBitmap(data);
return true;
}
//------------------------------------------------------------------------------
ConsoleDocFragment _GuiPopUpMenuCtrlExAdd(
"@brief Adds an entry to the list\n\n"
@ -690,9 +678,6 @@ bool GuiPopUpMenuCtrlEx::onWake()
if ( !Parent::onWake() )
return false;
// Set the bitmap for the popup.
setBitmap(getBitmap(Normal));
// Now update the Form Control's bitmap array, and possibly the child's too
mProfile->constructBitmapArray();
@ -818,8 +803,8 @@ void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
dStrcpy(p, "_d", pLen);
_setBitmap((StringTableEntry)buffer, Depressed);
if (!mBitmap[Depressed])
mBitmap[Depressed] = mBitmap[Normal];
if (mBitmapAsset[Depressed].isNull())
mBitmapAsset[Depressed] = mBitmapAsset[Normal];
}
else
{
@ -1096,17 +1081,17 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
}
// Draw a bitmap over the background?
if ( mBitmap[Depressed] )
if ( mBitmapAsset[Depressed].notNull() )
{
RectI rect(offset, mBitmapBounds);
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch(mBitmap[Depressed], rect );
drawUtil->drawBitmapStretch(getBitmap(Depressed), rect );
}
else if (mBitmap[Normal])
else if (mBitmapAsset[Normal].notNull())
{
RectI rect(offset, mBitmapBounds);
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
}
// Do we render a bitmap border or lines?
@ -1140,11 +1125,11 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
}
// Draw a bitmap over the background?
if (mBitmap[Normal])
if (mBitmapAsset[Normal].notNull())
{
RectI rect( offset, mBitmapBounds );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
}
// Do we render a bitmap border or lines?
@ -1170,11 +1155,11 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
}
// Draw a bitmap over the background?
if (mBitmap[Normal])
if (mBitmapAsset[Normal].notNull())
{
RectI rect(offset, mBitmapBounds);
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
}
// Do we render a bitmap border or lines?