gui types using image_asset

This commit is contained in:
marauder2k7 2024-12-21 23:02:23 +00:00
parent fa8110ce8f
commit f519cff6ff
25 changed files with 184 additions and 266 deletions

View file

@ -78,8 +78,6 @@ GuiCursor::GuiCursor()
mHotSpot.set(0,0);
mRenderOffset.set(0.0f,0.0f);
mExtent.set(1,1);
INIT_ASSET(Bitmap);
}
GuiCursor::~GuiCursor()
@ -92,8 +90,7 @@ void GuiCursor::initPersistFields()
addField("hotSpot", TypePoint2I, Offset(mHotSpot, GuiCursor), "The location of the cursor's hot spot (which pixel carries the click).");
addField("renderOffset",TypePoint2F, Offset(mRenderOffset, GuiCursor), "Offset of the bitmap, where 0 signifies left edge of the bitmap, 1, the right. Similarly for the Y-component.");
addProtectedField("bitmapName", TypeImageFilename, Offset(mBitmapName, GuiCursor), _setBitmapData, &defaultProtectedGetFn, "File name of the bitmap for the cursor.");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
Parent::initPersistFields();
}
@ -114,21 +111,21 @@ void GuiCursor::onRemove()
void GuiCursor::render(const Point2I &pos)
{
if (mBitmap)
if (mBitmapAsset.notNull())
{
mExtent.set(mBitmap->getWidth(), mBitmap->getHeight());
mExtent.set(getBitmap()->getWidth(), getBitmap()->getHeight());
}
// Render the cursor centered according to dimensions of texture
S32 texWidth = mBitmap.getWidth();
S32 texHeight = mBitmap.getHeight();
S32 texWidth = getBitmap()->getWidth();
S32 texHeight = getBitmap()->getHeight();
Point2I renderPos = pos;
renderPos.x -= (S32)( texWidth * mRenderOffset.x );
renderPos.y -= (S32)( texHeight * mRenderOffset.y );
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmap(mBitmap, renderPos);
GFX->getDrawUtil()->drawBitmap(getBitmap(), renderPos);
}
//------------------------------------------------------------------------------

View file

@ -348,8 +348,7 @@ class GuiCursor : public SimObject
private:
typedef SimObject Parent;
DECLARE_IMAGEASSET(GuiCursor, Bitmap, onImageChanged, GFXGuiCursorProfile);
DECLARE_ASSET_SETGET(GuiCursor, Bitmap);
DECLARE_IMAGEASSET_REFACTOR(GuiCursor, Bitmap, GFXGuiCursorProfile)
Point2I mHotSpot;
Point2F mRenderOffset;
@ -367,8 +366,6 @@ public:
bool onAdd(void) override;
void onRemove() override;
void render(const Point2I &pos);
void onImageChanged() {}
};
/// A GuiControlProfile is used by every GuiObject and is akin to a