moar refactors

This commit is contained in:
marauder2k7 2024-12-25 20:23:22 +00:00
parent 4d893f51cf
commit 22037bf94f
10 changed files with 65 additions and 60 deletions

View file

@ -278,9 +278,6 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void)
mBackgroundCancel = false; // Added
mReverseTextList = false; // Added - Don't reverse text list if displaying up
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, 0);
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, 1);
mBitmapBounds.set(16, 16); // Added
mIdMax = -1;
mBackground = NULL;
@ -302,8 +299,7 @@ void GuiPopUpMenuCtrl::initPersistFields(void)
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiPopUpMenuCtrl), _setBitmaps, defaultProtectedGetFn, "");
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiPopUpMenuCtrl), _setBitmaps, defaultProtectedGetFn, "");
addProtectedField("BitmapAsset", TypeImageAssetPtrRefactor, Offset(mBitmapAsset, GuiPopUpMenuCtrl), _setBitmaps, &defaultProtectedGetFn, "@brief ""Bitmap"" ""asset \"\".");
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrl));
@ -473,9 +469,6 @@ bool GuiPopUpMenuCtrl::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();
@ -592,8 +585,8 @@ void GuiPopUpMenuCtrl::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
{
@ -898,17 +891,17 @@ void GuiPopUpMenuCtrl::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?
@ -948,11 +941,11 @@ void GuiPopUpMenuCtrl::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?
@ -984,11 +977,11 @@ void GuiPopUpMenuCtrl::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?

View file

@ -126,9 +126,8 @@ protected:
NumBitmapModes = 2
};
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, NumBitmapModes, onBitmapChanged);
DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrl, Bitmap);
void onBitmapChanged() {}
DECLARE_IMAGEASSET_ARRAY_REFACTOR(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
Point2I mBitmapBounds; // Added
S32 mIdMax;

View file

@ -353,7 +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");
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(Bitmap, NumBitmapModes, GuiPopUpMenuCtrlEx, "Name of bitmap asset to use")
addProtectedField("BitmapAsset", TypeImageAssetPtrRefactor, Offset(mBitmapAsset, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "@brief ""Bitmap"" ""asset \"Name of bitmap asset to use\".");
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrlEx), "Boundaries of bitmap displayed");
addField("hotTrackCallback", TypeBool, Offset(mHotTrackItems, GuiPopUpMenuCtrlEx),
@ -780,7 +780,15 @@ static S32 QSORT_CALLBACK idCompare(const void *a,const void *b)
GuiPopUpMenuCtrlEx::Entry *ea = (GuiPopUpMenuCtrlEx::Entry *) (a);
GuiPopUpMenuCtrlEx::Entry *eb = (GuiPopUpMenuCtrlEx::Entry *) (b);
return ( (ea->id < eb->id) ? -1 : ((ea->id > eb->id) ? 1 : 0) );
}
}
bool GuiPopUpMenuCtrlEx::_setBitmaps(void* obj, const char* index, const char* data)
{
GuiPopUpMenuCtrlEx* object = static_cast<GuiPopUpMenuCtrlEx*>(obj);
object->setBitmap(data);
return true;
}
//------------------------------------------------------------------------------
// Added

View file

@ -143,6 +143,8 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
virtual void removeChildren();
virtual void repositionPopup();
static bool _setBitmaps(void* obj, const char* index, const char* data);
public:
GuiPopUpMenuCtrlEx(void);
~GuiPopUpMenuCtrlEx();