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

@ -34,15 +34,15 @@
IMPLEMENT_CONOBJECT(GuiBitmapCtrl);
ConsoleDocClass( GuiBitmapCtrl,
ConsoleDocClass(GuiBitmapCtrl,
"@brief A gui control that is used to display an image.\n\n"
"The image is stretched to the constraints of the control by default. However, the control can also\n"
"tile the image as well.\n\n"
"The image itself is stored inside the GuiBitmapCtrl::bitmap field. The boolean value that decides\n"
"whether the image is stretched or tiled is stored inside the GuiBitmapCtrl::wrap field.\n"
"@tsexample\n"
"// Create a tiling GuiBitmapCtrl that displays \"myImage.png\"\n"
"%bitmapCtrl = new GuiBitmapCtrl()\n"
@ -51,101 +51,87 @@ ConsoleDocClass( GuiBitmapCtrl,
" wrap = \"true\";\n"
"};\n"
"@endtsexample\n\n"
"@ingroup GuiControls"
);
GuiBitmapCtrl::GuiBitmapCtrl(void)
: mStartPoint( 0, 0 ),
: mStartPoint(0, 0),
mColor(ColorI::WHITE),
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()
{
docsURL;
addGroup( "Bitmap" );
addGroup("Bitmap");
addField("Bitmap", TypeImageFilename, Offset(mBitmapName, GuiBitmapCtrl), assetDoc(Bitmap, docs), AbstractClassRep::FIELD_HideInInspectors);
addField("BitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiBitmapCtrl), assetDoc(Bitmap, asset docs.));
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiBitmapCtrl, "The bitmap to render in this BitmapCtrl.")
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl),"color mul");
addField( "wrap", TypeBool, Offset( mWrap, GuiBitmapCtrl ),
"If true, the bitmap is tiled inside the control rather than stretched to fit." );
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl), "color mul");
addField("wrap", TypeBool, Offset(mWrap, GuiBitmapCtrl),
"If true, the bitmap is tiled inside the control rather than stretched to fit.");
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
endGroup( "Bitmap" );
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
endGroup("Bitmap");
Parent::initPersistFields();
}
bool GuiBitmapCtrl::onWake()
{
if (! Parent::onWake())
if (!Parent::onWake())
return false;
setActive(true);
if (mBitmapName != StringTable->insert("texhandle"))
setBitmap(getBitmap());
return true;
}
void GuiBitmapCtrl::onSleep()
{
if ( mBitmapName != StringTable->insert("texhandle") )
mBitmap = NULL;
Parent::onSleep();
}
//-------------------------------------
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
// set it's extent to be exactly the size of the bitmap (if present)
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());
}
}
void GuiBitmapCtrl::setBitmap( const char *name, bool resize )
void GuiBitmapCtrl::setBitmap(const char* name, bool resize)
{
_setBitmap(StringTable->insert(name));
if (mBitmap && resize)
// coming in here we are probably getting a filename.
if (AssetDatabase.isDeclaredAsset(name))
{
_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());
updateSizing();
}
@ -153,15 +139,6 @@ void GuiBitmapCtrl::setBitmap( const char *name, bool resize )
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)
{
mBitmap = handle;
@ -169,46 +146,58 @@ void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
mBitmapName = StringTable->insert("texhandle");
// Resize the control to fit the bitmap
if (resize)
if (resize)
{
setExtent(mBitmap->getWidth(), mBitmap->getHeight());
updateSizing();
}
}
void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
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)
{
if (mBitmap.isNull() && mBitmapAsset.notNull())
mBitmap = getBitmap();
if (mBitmap)
{
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->setBitmapModulation(mColor);
if(mWrap)
{
if (mWrap)
{
// We manually draw each repeat because non power of two textures will
// not tile correctly when rendered with GFX->drawBitmapTile(). The non POT
// bitmap will be padded by the hardware, and we'll see lots of slack
// in the texture. So... lets do what we must: draw each repeat by itself:
GFXTextureObject* texture = mBitmap;
RectI srcRegion;
RectI dstRegion;
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
F32 ydone = ((F32)getExtent().y/(F32)texture->mBitmapSize.y)+1;
GFXTextureObject* texture = mBitmap;
RectI srcRegion;
RectI dstRegion;
F32 xdone = ((F32)getExtent().x / (F32)texture->mBitmapSize.x) + 1;
F32 ydone = ((F32)getExtent().y / (F32)texture->mBitmapSize.y) + 1;
S32 xshift = mStartPoint.x%texture->mBitmapSize.x;
S32 yshift = mStartPoint.y%texture->mBitmapSize.y;
for(S32 y = 0; y < ydone; ++y)
for(S32 x = 0; x < xdone; ++x)
{
srcRegion.set(0,0,texture->mBitmapSize.x,texture->mBitmapSize.y);
dstRegion.set( ((texture->mBitmapSize.x*x)+offset.x)-xshift,
((texture->mBitmapSize.y*y)+offset.y)-yshift,
texture->mBitmapSize.x,
texture->mBitmapSize.y);
S32 xshift = mStartPoint.x % texture->mBitmapSize.x;
S32 yshift = mStartPoint.y % texture->mBitmapSize.y;
for (S32 y = 0; y < ydone; ++y)
for (S32 x = 0; x < xdone; ++x)
{
srcRegion.set(0, 0, texture->mBitmapSize.x, texture->mBitmapSize.y);
dstRegion.set(((texture->mBitmapSize.x * x) + offset.x) - xshift,
((texture->mBitmapSize.y * y) + offset.y) - yshift,
texture->mBitmapSize.x,
texture->mBitmapSize.y);
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mAngle);
}
}
}
else
}
else
{
RectI rect(offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false, mAngle);
@ -226,21 +215,21 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
void GuiBitmapCtrl::setValue(S32 x, S32 y)
{
if (mBitmap)
if (mBitmapAsset.notNull())
{
x += mBitmap->getWidth() / 2;
y += mBitmap->getHeight() / 2;
}
while (x < 0)
x += 256;
mStartPoint.x = x % 256;
x += mBitmapAsset->getTextureBitmapWidth() / 2;
y += mBitmapAsset->getTextureBitmapHeight() / 2;
}
while (x < 0)
x += 256;
mStartPoint.x = x % 256;
while (y < 0)
y += 256;
mStartPoint.y = y % 256;
while (y < 0)
y += 256;
mStartPoint.y = y % 256;
}
DefineEngineMethod( GuiBitmapCtrl, setValue, void, ( S32 x, S32 y ),,
DefineEngineMethod(GuiBitmapCtrl, setValue, void, (S32 x, S32 y), ,
"Set the offset of the bitmap within the control.\n"
"@param x The x-axis offset of the image.\n"
"@param y The y-axis offset of the image.\n")
@ -257,7 +246,7 @@ static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap1(
"@param filename The filename of the image.\n"
"@param resize Optional parameter. If true, the GUI will resize to fit the image.",
"GuiBitmapCtrl", // The class to place the method in; use NULL for functions.
"void setBitmap( String filename, bool resize );" ); // The definition string.
"void setBitmap( String filename, bool resize );"); // The definition string.
static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
"@brief Assign an image to the control.\n\n"
@ -265,42 +254,42 @@ static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
"@param filename The filename of the image.\n"
"@param resize A boolean value that decides whether the ctrl refreshes or not.",
"GuiBitmapCtrl", // The class to place the method in; use NULL for functions.
"void setBitmap( String filename );" ); // The definition string.
"void setBitmap( String filename );"); // The definition string.
//"Set the bitmap displayed in the control. Note that it is limited in size, to 256x256."
DefineEngineMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, bool resize), ( false),
DefineEngineMethod(GuiBitmapCtrl, setBitmap, void, (const char* fileRoot, bool resize), (false),
"( String filename | String filename, bool resize ) Assign an image to the control.\n\n"
"@hide" )
"@hide")
{
char filename[1024];
Con::expandScriptFilename(filename, sizeof(filename), fileRoot);
object->setBitmap(filename, resize );
object->setBitmap(filename, resize);
}
DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (),,
DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (), ,
"Gets the current bitmap set for this control.\n\n"
"@hide")
{
return object->getBitmap();
return object->_getBitmap();
}
DefineEngineMethod( GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture),,
DefineEngineMethod(GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture), ,
"@brief Set a texture as the image.\n\n"
"@param namedtexture The name of the texture (NamedTexTarget).\n"
"@return true if the texture exists." )
"@return true if the texture exists.")
{
GFXTexHandle theTex;
NamedTexTarget *namedTarget = NULL;
NamedTexTarget* namedTarget = NULL;
namedTarget = NamedTexTarget::find(namedtexture.c_str());
if ( namedTarget )
if (namedTarget)
{
theTex = namedTarget->getTexture( 0 );
theTex = namedTarget->getTexture(0);
}
if ( theTex.isValid() )
if (theTex.isValid())
{
object->setBitmapHandle( theTex , false );
object->setBitmapHandle(theTex, false);
return true; //a new texture was set correctly
}
return false; //we couldn't change the texture

View file

@ -31,51 +31,47 @@
/// Renders a bitmap.
class GuiBitmapCtrl : public GuiControl
{
public:
typedef GuiControl Parent;
public:
protected:
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
/// from a file but rather set explicitly on the control.
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
DECLARE_ASSET_SETGET(GuiBitmapCtrl, Bitmap);
Point2I mStartPoint;
ColorI mColor;
F32 mAngle;
typedef GuiControl Parent;
/// If true, bitmap tiles inside control. Otherwise stretches.
bool mWrap;
protected:
static bool setBitmapName( void *object, const char *index, const char *data );
static const char *getBitmapName( void *obj, const char *data );
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
/// from a file but rather set explicitly on the control.
DECLARE_IMAGEASSET_REFACTOR(GuiBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
void onImageChanged() {}
Point2I mStartPoint;
ColorI mColor;
F32 mAngle;
public:
GuiBitmapCtrl();
static void initPersistFields();
/// If true, bitmap tiles inside control. Otherwise stretches.
bool mWrap;
void setBitmap(const char *name,bool resize = false);
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
public:
GFXTexHandle mBitmap;
StringTableEntry mBitmapName;
// GuiControl.
bool onWake() override;
void onSleep() override;
void inspectPostApply() override;
GuiBitmapCtrl();
static void initPersistFields();
void updateSizing();
// GuiControl.
bool onWake() override;
void onSleep() override;
void inspectPostApply() override;
void onRender(Point2I offset, const RectI &updateRect) override;
void setValue(S32 x, S32 y);
void setBitmap(const char* name, bool resize = true);
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
DECLARE_CONOBJECT( GuiBitmapCtrl );
DECLARE_CATEGORY( "Gui Images" );
DECLARE_DESCRIPTION( "A control that displays a single, static image from a file.n"
"The bitmap can either be tiled or stretched inside the control." );
void updateSizing();
void onRender(Point2I offset, const RectI& updateRect) override;
void setValue(S32 x, S32 y);
DECLARE_CONOBJECT(GuiBitmapCtrl);
DECLARE_CATEGORY("Gui Images");
DECLARE_DESCRIPTION("A control that displays a single, static image from a file.n"
"The bitmap can either be tiled or stretched inside the control.");
};
#endif

View file

@ -59,10 +59,6 @@ GuiGameSettingsCtrl::GuiGameSettingsCtrl() :
mCallbackOnB = mCallbackOnA;
mCallbackOnX = mCallbackOnA;
mCallbackOnY = mCallbackOnA;
INIT_ASSET(KeybindBitmap);
INIT_ASSET(PreviousBitmap);
INIT_ASSET(NextBitmap);
}
GuiGameSettingsCtrl::~GuiGameSettingsCtrl()
@ -193,7 +189,7 @@ void GuiGameSettingsCtrl::onRenderListOption(Point2I currentOffset)
arrowOffset.y = currentOffset.y + arrowOffsetY;
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
{
@ -214,7 +210,7 @@ void GuiGameSettingsCtrl::onRenderListOption(Point2I currentOffset)
arrowOffset.y = currentOffset.y + arrowOffsetY;
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
{
@ -376,7 +372,7 @@ void GuiGameSettingsCtrl::onRenderKeybindOption(Point2I currentOffset)
{
RectI rect(button, buttonSize);
drawer->clearBitmapModulation();
drawer->drawBitmapStretch(mKeybindBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
drawer->drawBitmapStretch(getKeybindBitmap(), rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
}
//drawer->drawRectFill(button, ColorI::BLUE);
@ -454,22 +450,11 @@ bool GuiGameSettingsCtrl::onWake()
if( !Parent::onWake() )
return false;
_setNextBitmap(getNextBitmap());
_setPreviousBitmap(getPreviousBitmap());
_setKeybindBitmap(getKeybindBitmap());
return true;
}
void GuiGameSettingsCtrl::onSleep()
{
if (mNextBitmapAsset.notNull())
mNextBitmap = NULL;
if (mPreviousBitmapAsset.notNull())
mPreviousBitmap = NULL;
if (mKeybindBitmapAsset.notNull())
mKeybindBitmap = NULL;
Parent::onSleep();
}
@ -840,9 +825,9 @@ IMPLEMENT_CALLBACK(GuiGameSettingsCtrl, onAxisEvent, void, (const char* device,
void GuiGameSettingsCtrl::initPersistFields()
{
docsURL;
INITPERSISTFIELD_IMAGEASSET(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(NextBitmap, GuiGameSettingsCtrl, "Bitmap used for the next button when in list mode.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(KeybindBitmap, GuiGameSettingsCtrl, "Bitmap used to display the bound key for this keybind option.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(PreviousBitmap, GuiGameSettingsCtrl, "Bitmap used for the previous 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),
"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
//Keybind option
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, changeBitmap, GFXDefaultGUIProfile);
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, KeybindBitmap);
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, changeBitmap, GFXDefaultGUIProfile);
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, PreviousBitmap);
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, changeBitmap, GFXDefaultGUIProfile);
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, NextBitmap);
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, KeybindBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, PreviousBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, NextBitmap, GFXDefaultGUIProfile)
S32 mArrowSize;
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.
@ -89,8 +84,6 @@ protected:
bool mSelected;
public:
void changeBitmap() {}
/// Sets the control as selected . Only controls that are enabled can be selected.
virtual void setSelected();

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

View file

@ -67,7 +67,7 @@ void GuiChunkedBitmapCtrl::initPersistFields()
{
docsURL;
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 "
"or a bitmap stored in \"variable\"");
@ -88,8 +88,6 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
{
INIT_ASSET(Bitmap);
mUseVariable = false;
mTile = false;
}
@ -112,16 +110,6 @@ bool GuiChunkedBitmapCtrl::onWake()
if(!Parent::onWake())
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;
}
@ -167,10 +155,10 @@ void GuiChunkedBitmapCtrl::renderRegion(const Point2I &offset, const Point2I &ex
void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
{
if( mBitmap )
if( mBitmapAsset.notNull() )
{
RectI boundsRect( offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear );
GFX->getDrawUtil()->drawBitmapStretch(getBitmap(), boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear);
}
renderChildControls(offset, updateRect);

View file

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

View file

@ -124,7 +124,6 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
mNumberOfBitmaps(0),
mDim(0)
{
INIT_ASSET(Bitmap);
}
//-----------------------------------------------------------------------------
@ -132,7 +131,7 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
void GuiProgressBitmapCtrl::initPersistFields()
{
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 "
"set in which case the bitmap from the profile is used.");

View file

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

View file

@ -59,8 +59,6 @@ ConsoleDocClass( GuiMissionAreaCtrl,
GuiMissionAreaCtrl::GuiMissionAreaCtrl()
{
INIT_ASSET(HandleBitmap);
mHandleTextureSize = Point2I::Zero;
mHandleTextureHalfSize = Point2F::Zero;
@ -90,7 +88,7 @@ void GuiMissionAreaCtrl::initPersistFields()
docsURL;
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( "cameraColor", TypeColorI, Offset(mCameraColor, GuiMissionAreaCtrl));
@ -114,9 +112,9 @@ bool GuiMissionAreaCtrl::onAdd()
desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
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;
}
else
@ -418,7 +416,7 @@ void GuiMissionAreaCtrl::setArea(const RectI & area)
void GuiMissionAreaCtrl::drawHandle(const Point2F & pos)
{
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)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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