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

@ -59,21 +59,10 @@ GuiBitmapCtrl::GuiBitmapCtrl(void)
: mStartPoint(0, 0), : mStartPoint(0, 0),
mColor(ColorI::WHITE), mColor(ColorI::WHITE),
mAngle(0), mAngle(0),
mWrap( false ) mWrap(false),
mBitmap(NULL),
mBitmapName(StringTable->EmptyString())
{ {
INIT_ASSET(Bitmap);
}
bool GuiBitmapCtrl::setBitmapName( void *object, const char *index, const char *data )
{
// Prior to this, you couldn't do bitmap.bitmap = "foo.jpg" and have it work.
// With protected console types you can now call the setBitmap function and
// make it load the image.
static_cast<GuiBitmapCtrl *>( object )->setBitmap( data );
// Return false because the setBitmap method will assign 'mBitmapName' to the
// argument we are specifying in the call.
return false;
} }
void GuiBitmapCtrl::initPersistFields() void GuiBitmapCtrl::initPersistFields()
@ -81,8 +70,7 @@ void GuiBitmapCtrl::initPersistFields()
docsURL; docsURL;
addGroup("Bitmap"); addGroup("Bitmap");
addField("Bitmap", TypeImageFilename, Offset(mBitmapName, GuiBitmapCtrl), assetDoc(Bitmap, docs), AbstractClassRep::FIELD_HideInInspectors); INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiBitmapCtrl, "The bitmap to render in this BitmapCtrl.")
addField("BitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiBitmapCtrl), assetDoc(Bitmap, asset docs.));
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl), "color mul"); addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl), "color mul");
addField("wrap", TypeBool, Offset(mWrap, GuiBitmapCtrl), addField("wrap", TypeBool, Offset(mWrap, GuiBitmapCtrl),
@ -101,40 +89,22 @@ bool GuiBitmapCtrl::onWake()
return false; return false;
setActive(true); setActive(true);
if (mBitmapName != StringTable->insert("texhandle"))
setBitmap(getBitmap());
return true; return true;
} }
void GuiBitmapCtrl::onSleep() void GuiBitmapCtrl::onSleep()
{ {
if ( mBitmapName != StringTable->insert("texhandle") )
mBitmap = NULL;
Parent::onSleep(); Parent::onSleep();
} }
//------------------------------------- //-------------------------------------
void GuiBitmapCtrl::inspectPostApply() void GuiBitmapCtrl::inspectPostApply()
{ {
//This is a little bit of a 'special case' handling for this class
//Because we don't do the normal protectedField setup for the bitmapName/bitmapAsset fields
//which would automatically update the internal values and bound content, we'll do it here manually
//to ensure it's updated before we force a refresh, which would thrash the new values
if (mBitmapName != StringTable->insert("texhandle"))
{
_setBitmap(mBitmapAssetId);
}
else
{
setBitmap(getBitmap());
}
// if the extent is set to (0,0) in the gui editor and appy hit, this control will // if the extent is set to (0,0) in the gui editor and appy hit, this control will
// set it's extent to be exactly the size of the bitmap (if present) // set it's extent to be exactly the size of the bitmap (if present)
Parent::inspectPostApply(); Parent::inspectPostApply();
if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mBitmap) if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mBitmapAsset.notNull())
{ {
setExtent(mBitmap->getWidth(), mBitmap->getHeight()); setExtent(mBitmap->getWidth(), mBitmap->getHeight());
} }
@ -142,10 +112,26 @@ void GuiBitmapCtrl::inspectPostApply()
void GuiBitmapCtrl::setBitmap(const char* name, bool resize) void GuiBitmapCtrl::setBitmap(const char* name, bool resize)
{ {
_setBitmap(StringTable->insert(name)); // coming in here we are probably getting a filename.
if (AssetDatabase.isDeclaredAsset(name))
if (mBitmap && resize)
{ {
_setBitmap(StringTable->insert(name));
}
else
{
StringTableEntry assetId = ImageAsset::getAssetIdByFilename(StringTable->insert(name));
if (assetId != StringTable->EmptyString())
_setBitmap(assetId);
else
return;
}
mBitmap = mBitmapAsset->getTexture(&GFXDefaultGUIProfile);
if (mBitmapAsset.notNull() && resize)
{
setExtent(mBitmap->getWidth(), mBitmap->getHeight()); setExtent(mBitmap->getWidth(), mBitmap->getHeight());
updateSizing(); updateSizing();
} }
@ -153,15 +139,6 @@ void GuiBitmapCtrl::setBitmap( const char *name, bool resize )
setUpdate(); setUpdate();
} }
void GuiBitmapCtrl::updateSizing()
{
if(!getParent())
return;
// updates our bounds according to our horizSizing and verSizing rules
RectI fakeBounds( getPosition(), getParent()->getExtent());
parentResized( fakeBounds, fakeBounds);
}
void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize) void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
{ {
mBitmap = handle; mBitmap = handle;
@ -176,8 +153,20 @@ void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
} }
} }
void GuiBitmapCtrl::updateSizing()
{
if (!getParent())
return;
// updates our bounds according to our horizSizing and verSizing rules
RectI fakeBounds(getPosition(), getParent()->getExtent());
parentResized(fakeBounds, fakeBounds);
}
void GuiBitmapCtrl::onRender(Point2I offset, const RectI& updateRect) void GuiBitmapCtrl::onRender(Point2I offset, const RectI& updateRect)
{ {
if (mBitmap.isNull() && mBitmapAsset.notNull())
mBitmap = getBitmap();
if (mBitmap) if (mBitmap)
{ {
GFX->getDrawUtil()->clearBitmapModulation(); GFX->getDrawUtil()->clearBitmapModulation();
@ -226,10 +215,10 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
void GuiBitmapCtrl::setValue(S32 x, S32 y) void GuiBitmapCtrl::setValue(S32 x, S32 y)
{ {
if (mBitmap) if (mBitmapAsset.notNull())
{ {
x += mBitmap->getWidth() / 2; x += mBitmapAsset->getTextureBitmapWidth() / 2;
y += mBitmap->getHeight() / 2; y += mBitmapAsset->getTextureBitmapHeight() / 2;
} }
while (x < 0) while (x < 0)
x += 256; x += 256;
@ -282,7 +271,7 @@ DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (),,
"Gets the current bitmap set for this control.\n\n" "Gets the current bitmap set for this control.\n\n"
"@hide") "@hide")
{ {
return object->getBitmap(); return object->_getBitmap();
} }
DefineEngineMethod(GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture), , DefineEngineMethod(GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture), ,

View file

@ -39,8 +39,7 @@ class GuiBitmapCtrl : public GuiControl
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded /// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
/// from a file but rather set explicitly on the control. /// from a file but rather set explicitly on the control.
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile); DECLARE_IMAGEASSET_REFACTOR(GuiBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_ASSET_SETGET(GuiBitmapCtrl, Bitmap);
Point2I mStartPoint; Point2I mStartPoint;
ColorI mColor; ColorI mColor;
@ -49,24 +48,21 @@ class GuiBitmapCtrl : public GuiControl
/// If true, bitmap tiles inside control. Otherwise stretches. /// If true, bitmap tiles inside control. Otherwise stretches.
bool mWrap; bool mWrap;
static bool setBitmapName( void *object, const char *index, const char *data );
static const char *getBitmapName( void *obj, const char *data );
void onImageChanged() {}
public: public:
GFXTexHandle mBitmap;
StringTableEntry mBitmapName;
GuiBitmapCtrl(); GuiBitmapCtrl();
static void initPersistFields(); static void initPersistFields();
void setBitmap(const char *name,bool resize = false);
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
// GuiControl. // GuiControl.
bool onWake() override; bool onWake() override;
void onSleep() override; void onSleep() override;
void inspectPostApply() override; void inspectPostApply() override;
void setBitmap(const char* name, bool resize = true);
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
void updateSizing(); void updateSizing();
void onRender(Point2I offset, const RectI& updateRect) override; void onRender(Point2I offset, const RectI& updateRect) override;

View file

@ -59,10 +59,6 @@ GuiGameSettingsCtrl::GuiGameSettingsCtrl() :
mCallbackOnB = mCallbackOnA; mCallbackOnB = mCallbackOnA;
mCallbackOnX = mCallbackOnA; mCallbackOnX = mCallbackOnA;
mCallbackOnY = mCallbackOnA; mCallbackOnY = mCallbackOnA;
INIT_ASSET(KeybindBitmap);
INIT_ASSET(PreviousBitmap);
INIT_ASSET(NextBitmap);
} }
GuiGameSettingsCtrl::~GuiGameSettingsCtrl() GuiGameSettingsCtrl::~GuiGameSettingsCtrl()
@ -193,7 +189,7 @@ void GuiGameSettingsCtrl::onRenderListOption(Point2I currentOffset)
arrowOffset.y = currentOffset.y + arrowOffsetY; arrowOffset.y = currentOffset.y + arrowOffsetY;
drawer->clearBitmapModulation(); drawer->clearBitmapModulation();
drawer->drawBitmapStretch(mPreviousBitmap, RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false); drawer->drawBitmapStretch(getPreviousBitmap(), RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false);
} }
else else
{ {
@ -214,7 +210,7 @@ void GuiGameSettingsCtrl::onRenderListOption(Point2I currentOffset)
arrowOffset.y = currentOffset.y + arrowOffsetY; arrowOffset.y = currentOffset.y + arrowOffsetY;
drawer->clearBitmapModulation(); drawer->clearBitmapModulation();
drawer->drawBitmapStretch(mNextBitmap, RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false); drawer->drawBitmapStretch(getNextBitmap(), RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false);
} }
else else
{ {
@ -376,7 +372,7 @@ void GuiGameSettingsCtrl::onRenderKeybindOption(Point2I currentOffset)
{ {
RectI rect(button, buttonSize); RectI rect(button, buttonSize);
drawer->clearBitmapModulation(); drawer->clearBitmapModulation();
drawer->drawBitmapStretch(mKeybindBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false); drawer->drawBitmapStretch(getKeybindBitmap(), rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
} }
//drawer->drawRectFill(button, ColorI::BLUE); //drawer->drawRectFill(button, ColorI::BLUE);
@ -454,22 +450,11 @@ bool GuiGameSettingsCtrl::onWake()
if( !Parent::onWake() ) if( !Parent::onWake() )
return false; return false;
_setNextBitmap(getNextBitmap());
_setPreviousBitmap(getPreviousBitmap());
_setKeybindBitmap(getKeybindBitmap());
return true; return true;
} }
void GuiGameSettingsCtrl::onSleep() void GuiGameSettingsCtrl::onSleep()
{ {
if (mNextBitmapAsset.notNull())
mNextBitmap = NULL;
if (mPreviousBitmapAsset.notNull())
mPreviousBitmap = NULL;
if (mKeybindBitmapAsset.notNull())
mKeybindBitmap = NULL;
Parent::onSleep(); Parent::onSleep();
} }
@ -840,9 +825,9 @@ IMPLEMENT_CALLBACK(GuiGameSettingsCtrl, onAxisEvent, void, (const char* device,
void GuiGameSettingsCtrl::initPersistFields() void GuiGameSettingsCtrl::initPersistFields()
{ {
docsURL; docsURL;
INITPERSISTFIELD_IMAGEASSET(KeybindBitmap, GuiGameSettingsCtrl, "Bitmap used to display the bound key for this keybind option."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(KeybindBitmap, GuiGameSettingsCtrl, "Bitmap used to display the bound key for this keybind option.");
INITPERSISTFIELD_IMAGEASSET(PreviousBitmap, GuiGameSettingsCtrl, "Bitmap used for the previous button when in list mode."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(PreviousBitmap, GuiGameSettingsCtrl, "Bitmap used for the previous button when in list mode.");
INITPERSISTFIELD_IMAGEASSET(NextBitmap, GuiGameSettingsCtrl, "Bitmap used for the next button when in list mode."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(NextBitmap, GuiGameSettingsCtrl, "Bitmap used for the next button when in list mode.");
addField("arrowSize", TypeS32, Offset(mArrowSize, GuiGameSettingsCtrl), addField("arrowSize", TypeS32, Offset(mArrowSize, GuiGameSettingsCtrl),
"Size of the arrow buttons' extents"); "Size of the arrow buttons' extents");

View file

@ -72,14 +72,9 @@ protected:
Point2F mRange; ///< When working as a slider, this sets our min/max range Point2F mRange; ///< When working as a slider, this sets our min/max range
//Keybind option //Keybind option
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, changeBitmap, GFXDefaultGUIProfile); DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, KeybindBitmap, GFXDefaultGUIProfile)
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, KeybindBitmap); DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, PreviousBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, NextBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, changeBitmap, GFXDefaultGUIProfile);
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, PreviousBitmap);
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, changeBitmap, GFXDefaultGUIProfile);
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, NextBitmap);
S32 mArrowSize; S32 mArrowSize;
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'. S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.
@ -89,8 +84,6 @@ protected:
bool mSelected; bool mSelected;
public: public:
void changeBitmap() {}
/// Sets the control as selected . Only controls that are enabled can be selected. /// Sets the control as selected . Only controls that are enabled can be selected.
virtual void setSelected(); virtual void setSelected();

View file

@ -78,8 +78,6 @@ GuiCursor::GuiCursor()
mHotSpot.set(0,0); mHotSpot.set(0,0);
mRenderOffset.set(0.0f,0.0f); mRenderOffset.set(0.0f,0.0f);
mExtent.set(1,1); mExtent.set(1,1);
INIT_ASSET(Bitmap);
} }
GuiCursor::~GuiCursor() 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("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."); 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_REFACTOR(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
Parent::initPersistFields(); Parent::initPersistFields();
} }
@ -114,21 +111,21 @@ void GuiCursor::onRemove()
void GuiCursor::render(const Point2I &pos) 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 // Render the cursor centered according to dimensions of texture
S32 texWidth = mBitmap.getWidth(); S32 texWidth = getBitmap()->getWidth();
S32 texHeight = mBitmap.getHeight(); S32 texHeight = getBitmap()->getHeight();
Point2I renderPos = pos; Point2I renderPos = pos;
renderPos.x -= (S32)( texWidth * mRenderOffset.x ); renderPos.x -= (S32)( texWidth * mRenderOffset.x );
renderPos.y -= (S32)( texHeight * mRenderOffset.y ); renderPos.y -= (S32)( texHeight * mRenderOffset.y );
GFX->getDrawUtil()->clearBitmapModulation(); GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmap(mBitmap, renderPos); GFX->getDrawUtil()->drawBitmap(getBitmap(), renderPos);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View file

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

View file

@ -67,7 +67,7 @@ void GuiChunkedBitmapCtrl::initPersistFields()
{ {
docsURL; docsURL;
addGroup("GuiChunkedBitmapCtrl"); addGroup("GuiChunkedBitmapCtrl");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap to render to the control."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap to render to the control.");
addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file " addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file "
"or a bitmap stored in \"variable\""); "or a bitmap stored in \"variable\"");
@ -88,8 +88,6 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl() GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
{ {
INIT_ASSET(Bitmap);
mUseVariable = false; mUseVariable = false;
mTile = false; mTile = false;
} }
@ -112,16 +110,6 @@ bool GuiChunkedBitmapCtrl::onWake()
if(!Parent::onWake()) if(!Parent::onWake())
return false; return false;
if( !mBitmap
&& ( ( mBitmapName && mBitmapName[ 0 ] )
|| ( mUseVariable && mConsoleVariable && mConsoleVariable[ 0 ] ) ) )
{
if ( mUseVariable )
mBitmap.set( Con::getVariable( mConsoleVariable ), &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
else
mBitmap.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
}
return true; return true;
} }
@ -167,10 +155,10 @@ void GuiChunkedBitmapCtrl::renderRegion(const Point2I &offset, const Point2I &ex
void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect) void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
{ {
if( mBitmap ) if( mBitmapAsset.notNull() )
{ {
RectI boundsRect( offset, getExtent()); RectI boundsRect( offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear ); GFX->getDrawUtil()->drawBitmapStretch(getBitmap(), boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear);
} }
renderChildControls(offset, updateRect); renderChildControls(offset, updateRect);

View file

@ -17,8 +17,7 @@ private:
protected: protected:
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile); DECLARE_IMAGEASSET_REFACTOR(GuiChunkedBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_ASSET_SETGET(GuiChunkedBitmapCtrl, Bitmap);
bool mUseVariable; bool mUseVariable;
bool mTile; bool mTile;
@ -38,6 +37,4 @@ public:
void setBitmap(const char *name); void setBitmap(const char *name);
void onRender(Point2I offset, const RectI &updateRect) override; void onRender(Point2I offset, const RectI &updateRect) override;
void onImageChanged() {}
}; };

View file

@ -124,7 +124,6 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
mNumberOfBitmaps(0), mNumberOfBitmaps(0),
mDim(0) mDim(0)
{ {
INIT_ASSET(Bitmap);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -132,7 +131,7 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
void GuiProgressBitmapCtrl::initPersistFields() void GuiProgressBitmapCtrl::initPersistFields()
{ {
docsURL; docsURL;
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiProgressBitmapCtrl, "Bitmap file to use for rendering the progress bar.\n\n" INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiProgressBitmapCtrl, "Bitmap file 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 " "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."); "set in which case the bitmap from the profile is used.");

View file

@ -47,22 +47,13 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
F32 mProgress; F32 mProgress;
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile); DECLARE_IMAGEASSET_REFACTOR(GuiProgressBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_ASSET_SETGET(GuiProgressBitmapCtrl, Bitmap);
bool mUseVariable; bool mUseVariable;
bool mTile; bool mTile;
S32 mNumberOfBitmaps; S32 mNumberOfBitmaps;
S32 mDim; S32 mDim;
static bool _setBitmap( void* object, const char* index, const char* data )
{
static_cast< GuiProgressBitmapCtrl* >( object )->setBitmap( data );
return false;
}
void onImageChanged() {}
public: public:
GuiProgressBitmapCtrl(); GuiProgressBitmapCtrl();

View file

@ -59,8 +59,6 @@ ConsoleDocClass( GuiMissionAreaCtrl,
GuiMissionAreaCtrl::GuiMissionAreaCtrl() GuiMissionAreaCtrl::GuiMissionAreaCtrl()
{ {
INIT_ASSET(HandleBitmap);
mHandleTextureSize = Point2I::Zero; mHandleTextureSize = Point2I::Zero;
mHandleTextureHalfSize = Point2F::Zero; mHandleTextureHalfSize = Point2F::Zero;
@ -90,7 +88,7 @@ void GuiMissionAreaCtrl::initPersistFields()
docsURL; docsURL;
addField( "squareBitmap", TypeBool, Offset(mSquareBitmap, GuiMissionAreaCtrl)); addField( "squareBitmap", TypeBool, Offset(mSquareBitmap, GuiMissionAreaCtrl));
INITPERSISTFIELD_IMAGEASSET(HandleBitmap, GuiMissionAreaCtrl, "Bitmap for the mission area handles.\n"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(HandleBitmap, GuiMissionAreaCtrl, "Bitmap for the mission area handles.\n");
addField( "missionBoundsColor", TypeColorI, Offset(mMissionBoundsColor, GuiMissionAreaCtrl)); addField( "missionBoundsColor", TypeColorI, Offset(mMissionBoundsColor, GuiMissionAreaCtrl));
addField( "cameraColor", TypeColorI, Offset(mCameraColor, GuiMissionAreaCtrl)); addField( "cameraColor", TypeColorI, Offset(mCameraColor, GuiMissionAreaCtrl));
@ -114,9 +112,9 @@ bool GuiMissionAreaCtrl::onAdd()
desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha); desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
mBlendStateBlock = GFX->createStateBlock( desc ); mBlendStateBlock = GFX->createStateBlock( desc );
if (!mHandleBitmap.isNull()) if (!mHandleBitmapAsset.isNull())
{ {
mHandleTextureSize = Point2I(mHandleBitmap->getWidth(), mHandleBitmap->getHeight() ); mHandleTextureSize = Point2I(getHandleBitmap()->getWidth(), getHandleBitmap()->getHeight());
mHandleTextureHalfSize = Point2F(mHandleTextureSize.x, mHandleTextureSize.y) * 0.5f; mHandleTextureHalfSize = Point2F(mHandleTextureSize.x, mHandleTextureSize.y) * 0.5f;
} }
else else
@ -418,7 +416,7 @@ void GuiMissionAreaCtrl::setArea(const RectI & area)
void GuiMissionAreaCtrl::drawHandle(const Point2F & pos) void GuiMissionAreaCtrl::drawHandle(const Point2F & pos)
{ {
Point2F pnt(pos.x-mHandleTextureHalfSize.x, pos.y-mHandleTextureHalfSize.y); Point2F pnt(pos.x-mHandleTextureHalfSize.x, pos.y-mHandleTextureHalfSize.y);
GFX->getDrawUtil()->drawBitmap(mHandleBitmap, pnt); GFX->getDrawUtil()->drawBitmap(getHandleBitmap(), pnt);
} }
void GuiMissionAreaCtrl::drawHandles(RectI & box) void GuiMissionAreaCtrl::drawHandles(RectI & box)

View file

@ -63,8 +63,7 @@ protected:
GFXStateBlockRef mBlendStateBlock; GFXStateBlockRef mBlendStateBlock;
GFXStateBlockRef mSolidStateBlock; GFXStateBlockRef mSolidStateBlock;
DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, onHandleBitmapChanged, GFXDefaultGUIProfile); DECLARE_IMAGEASSET_REFACTOR(GuiMissionAreaCtrl, HandleBitmap, GFXDefaultGUIProfile)
DECLARE_ASSET_SETGET(GuiMissionAreaCtrl, HandleBitmap);
Point2I mHandleTextureSize; Point2I mHandleTextureSize;
Point2F mHandleTextureHalfSize; Point2F mHandleTextureHalfSize;
@ -110,8 +109,6 @@ protected:
bool testWithinHandle(const Point2I & testPoint, S32 handleX, S32 handleY); bool testWithinHandle(const Point2I & testPoint, S32 handleX, S32 handleY);
S32 getHitHandles(const Point2I & mousePnt, const RectI & box); S32 getHitHandles(const Point2I & mousePnt, const RectI & box);
void onHandleBitmapChanged() {}
public: public:
GuiMissionAreaCtrl(); GuiMissionAreaCtrl();
virtual ~GuiMissionAreaCtrl(); virtual ~GuiMissionAreaCtrl();

View file

@ -1817,9 +1817,9 @@ WorldEditor::WorldEditor()
mPopupBackgroundColor.set(100,100,100); mPopupBackgroundColor.set(100,100,100);
mPopupTextColor.set(255,255,0); mPopupTextColor.set(255,255,0);
mSelectHandleAssetId = StringTable->insert("ToolsModule:SelectHandle"); mSelectHandleAsset = StringTable->insert("ToolsModule:SelectHandle_image");
mDefaultHandleAssetId = StringTable->insert("ToolsModule:DefaultHandle"); mDefaultHandleAsset = StringTable->insert("ToolsModule:DefaultHandle_image");
mLockedHandleAssetId = StringTable->insert("ToolsModule:LockedHandle"); mLockedHandleAsset = StringTable->insert("ToolsModule:LockedHandle_image");
mObjectTextColor.set(255,255,255); mObjectTextColor.set(255,255,255);
mObjectsUseBoxCenter = true; mObjectsUseBoxCenter = true;
@ -1905,9 +1905,9 @@ bool WorldEditor::onAdd()
// create the default class entry // create the default class entry
mDefaultClassEntry.mName = 0; mDefaultClassEntry.mName = 0;
mDefaultClassEntry.mIgnoreCollision = false; mDefaultClassEntry.mIgnoreCollision = false;
mDefaultClassEntry.mDefaultHandle = mDefaultHandle; mDefaultClassEntry.mDefaultHandle = getDefaultHandle();
mDefaultClassEntry.mSelectHandle = mSelectHandle; mDefaultClassEntry.mSelectHandle = getSelectHandle();
mDefaultClassEntry.mLockedHandle = mLockedHandle; mDefaultClassEntry.mLockedHandle = getLockedHandle();
if(!(mDefaultClassEntry.mDefaultHandle && mDefaultClassEntry.mSelectHandle && mDefaultClassEntry.mLockedHandle)) if(!(mDefaultClassEntry.mDefaultHandle && mDefaultClassEntry.mSelectHandle && mDefaultClassEntry.mLockedHandle))
return false; return false;
@ -2839,9 +2839,9 @@ void WorldEditor::initPersistFields()
addField( "renderObjHandle", TypeBool, Offset(mRenderObjHandle, WorldEditor) ); addField( "renderObjHandle", TypeBool, Offset(mRenderObjHandle, WorldEditor) );
addField( "renderSelectionBox", TypeBool, Offset(mRenderSelectionBox, WorldEditor) ); addField( "renderSelectionBox", TypeBool, Offset(mRenderSelectionBox, WorldEditor) );
INITPERSISTFIELD_IMAGEASSET(SelectHandle, WorldEditor, ""); INITPERSISTFIELD_IMAGEASSET_REFACTOR(SelectHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET(DefaultHandle, WorldEditor, ""); INITPERSISTFIELD_IMAGEASSET_REFACTOR(DefaultHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET(LockedHandle, WorldEditor, ""); INITPERSISTFIELD_IMAGEASSET_REFACTOR(LockedHandle, WorldEditor, "");
endGroup( "Rendering" ); endGroup( "Rendering" );

View file

@ -328,12 +328,9 @@ class WorldEditor : public EditTSCtrl
ColorI mPopupBackgroundColor; ColorI mPopupBackgroundColor;
ColorI mPopupTextColor; ColorI mPopupTextColor;
DECLARE_IMAGEASSET(WorldEditor, SelectHandle, onSelectHandleChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(WorldEditor, SelectHandle, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(WorldEditor, SelectHandle); DECLARE_IMAGEASSET_REFACTOR(WorldEditor, DefaultHandle, GFXStaticTextureSRGBProfile)
DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, onDefaultHandleChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(WorldEditor, LockedHandle, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(WorldEditor, DefaultHandle);
DECLARE_IMAGEASSET(WorldEditor, LockedHandle, onLockedHandleChanged, GFXStaticTextureSRGBProfile);
DECLARE_ASSET_SETGET(WorldEditor, LockedHandle);
ColorI mObjectTextColor; ColorI mObjectTextColor;
bool mObjectsUseBoxCenter; bool mObjectsUseBoxCenter;
@ -425,10 +422,6 @@ class WorldEditor : public EditTSCtrl
void setEditorTool(EditorTool*); void setEditorTool(EditorTool*);
EditorTool* getActiveEditorTool() { return mActiveEditorTool; } EditorTool* getActiveEditorTool() { return mActiveEditorTool; }
void onSelectHandleChanged() {}
void onDefaultHandleChanged() {}
void onLockedHandleChanged() {}
}; };
typedef WorldEditor::DropType WorldEditorDropType; typedef WorldEditor::DropType WorldEditorDropType;

View file

@ -28,7 +28,7 @@ $guiContent = new GameTSCtrl(PlayGui) {
noCursor = "1"; noCursor = "1";
new GuiBitmapCtrl(LagIcon) { new GuiBitmapCtrl(LagIcon) {
bitmap = "data/ui/art/lagIcon.png"; bitmapAsset = "UI:lagIcon_image";
color = "255 255 255 255"; color = "255 255 255 255";
wrap = "0"; wrap = "0";
position = "572 3"; position = "572 3";

View file

@ -68,7 +68,7 @@ $guiContent = new GuiControl(AssetPreviewButtonsTemplate) {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {
bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
bitmapMode = "Stretched"; bitmapMode = "Stretched";
autoFitExtents = "0"; autoFitExtents = "0";
useModifiers = "0"; useModifiers = "0";
@ -163,7 +163,7 @@ $guiContent = new GuiControl(AssetPreviewButtonsTemplate) {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {
bitmap = "Data/Blockout_Basics/Walls/WallGrid2x2_Albedo.png"; bitmapAsset = "Data/Blockout_Basics/Walls/WallGrid2x2_Albedo.png";
bitmapMode = "Stretched"; bitmapMode = "Stretched";
autoFitExtents = "0"; autoFitExtents = "0";
useModifiers = "0"; useModifiers = "0";
@ -188,7 +188,7 @@ $guiContent = new GuiControl(AssetPreviewButtonsTemplate) {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {
bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
bitmapMode = "Stretched"; bitmapMode = "Stretched";
autoFitExtents = "0"; autoFitExtents = "0";
useModifiers = "0"; useModifiers = "0";

View file

@ -2565,7 +2565,7 @@ function GuiEditor::onControlDropped(%this, %payload, %position)
{ {
%cmd = "return new guiBitmapCtrl();"; %cmd = "return new guiBitmapCtrl();";
%ctrl = eval( %cmd ); %ctrl = eval( %cmd );
%ctrl.bitmap = %assetId; %ctrl.bitmapAsset = %assetId;
} }
} }
} }

View file

@ -136,7 +136,7 @@ new GuiControl(MaterialSelectorOverlay, EditorGuiGroup) {
Command = "MaterialSelector.createNewMaterial();"; Command = "MaterialSelector.createNewMaterial();";
hovertime = "1000"; hovertime = "1000";
tooltip = "Create New Unmapped Material"; tooltip = "Create New Unmapped Material";
bitmap = "tools/gui/images/new"; bitmapAsset = "ToolsModule:new_n_image";
groupNum = "-1"; groupNum = "-1";
buttonType = "PushButton"; buttonType = "PushButton";
useMouseEvents = "0"; useMouseEvents = "0";
@ -1649,7 +1649,7 @@ function MaterialSelector::createNewMaterial( %this )
position = "7 4"; position = "7 4";
extent = "64 64"; extent = "64 64";
buttonType = "PushButton"; buttonType = "PushButton";
bitmap = "core/images/warnmat"; bitmapAsset = "CoreModule:warnMat_image";
Command = ""; Command = "";
text = "Loading..."; text = "Loading...";
useStates = false; useStates = false;

View file

@ -13,7 +13,7 @@ $guiContent = new GuiChunkedBitmapCtrl(EditorChooseGUI, EditorGuiGroup) {
Visible = "1"; Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile"; tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
bitmap = "data/ui/images/background.png"; bitmapAsset = "UI:background_image";
useVariable = "0"; useVariable = "0";
tile = "0"; tile = "0";

View file

@ -24,7 +24,7 @@
singleton GuiControlProfile (GuiMatEdSliderProfile) singleton GuiControlProfile (GuiMatEdSliderProfile)
{ {
bitmap = "./matEdSlider"; bitmapAsset = "ToolsModule:slider_image";
category = "Editor"; category = "Editor";
}; };
@ -47,9 +47,7 @@ singleton GuiControlProfile(GuiMatEdPopUpMenuProfile)
mouseOverSelected = true; mouseOverSelected = true;
textOffset = "3 3"; textOffset = "3 3";
border = 1; border = 1;
/*borderThickness = 1;*/
fixedExtent = true; fixedExtent = true;
//bitmap = "./images/scrollbar";
bitmapAsset = "ToolsModule:scroll_image"; bitmapAsset = "ToolsModule:scroll_image";
hasBitmapArray = true; hasBitmapArray = true;
profileForChildren = GuiControlListPopupProfile; profileForChildren = GuiControlListPopupProfile;

View file

@ -4821,7 +4821,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) {
tooltipprofile = "ToolsGuiToolTipProfile"; tooltipprofile = "ToolsGuiToolTipProfile";
buttonType = "PushButton"; buttonType = "PushButton";
useMouseEvents = "0"; useMouseEvents = "0";
bitmap = "ToolsModule:new_n_image"; bitmapAsset = "ToolsModule:new_n_image";
}; };
// Save Button // Save Button
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {

View file

@ -4846,7 +4846,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) {
tooltipprofile = "ToolsGuiToolTipProfile"; tooltipprofile = "ToolsGuiToolTipProfile";
buttonType = "PushButton"; buttonType = "PushButton";
useMouseEvents = "0"; useMouseEvents = "0";
bitmap = "ToolsModule:new_n_image"; bitmapAsset = "ToolsModule:new_n_image";
}; };
// Save Button // Save Button
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {

View file

@ -40,7 +40,7 @@ $guiContent = new GuiControl(NavEditorToolbar,EditorGuiGroup) {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiBitmapCtrl() { new GuiBitmapCtrl() {
bitmap = "core/gui/images/separator-h.png"; bitmapAsset = "ToolsModule:separator_h_image";
wrap = "0"; wrap = "0";
position = "90 3"; position = "90 3";
extent = "2 26"; extent = "2 26";

View file

@ -28,7 +28,7 @@ $guiContent = new GuiContainer(EditorChooseLevelGui, EditorGuiGroup) {
Visible = "1"; Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile"; tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
bitmap = "data/ui/images/background.png"; bitmapAsset = "UI:background_image";
useVariable = "0"; useVariable = "0";
tile = "0"; tile = "0";
}; };

View file

@ -115,8 +115,8 @@ $guiContent = new GuiContainer(EditorGui,EditorGuiGroup) {
selectionBoxColor = "255 255 0 255"; selectionBoxColor = "255 255 0 255";
selectionLocked = "0"; selectionLocked = "0";
toggleIgnoreList = "0"; toggleIgnoreList = "0";
selectHandle = "ToolsModule:SelectHandle_image"; selectHandleAsset = "ToolsModule:SelectHandle_image";
defaultHandle = "ToolsModule:DefaultHandle_image"; defaultHandleAsset = "ToolsModule:DefaultHandle_image";
lockedHandleAsset = "ToolsModule:LockedHandle_image"; lockedHandleAsset = "ToolsModule:LockedHandle_image";
}; };
new TerrainEditor(ETerrainEditor) { new TerrainEditor(ETerrainEditor) {