mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
gui types using image_asset
This commit is contained in:
parent
fa8110ce8f
commit
f519cff6ff
25 changed files with 184 additions and 266 deletions
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(GuiBitmapCtrl);
|
IMPLEMENT_CONOBJECT(GuiBitmapCtrl);
|
||||||
|
|
||||||
ConsoleDocClass( GuiBitmapCtrl,
|
ConsoleDocClass(GuiBitmapCtrl,
|
||||||
"@brief A gui control that is used to display an image.\n\n"
|
"@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"
|
"The image is stretched to the constraints of the control by default. However, the control can also\n"
|
||||||
|
|
@ -56,96 +56,82 @@ ConsoleDocClass( GuiBitmapCtrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
GuiBitmapCtrl::GuiBitmapCtrl(void)
|
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()
|
||||||
{
|
{
|
||||||
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),
|
||||||
"If true, the bitmap is tiled inside the control rather than stretched to fit." );
|
"If true, the bitmap is tiled inside the control rather than stretched to fit.");
|
||||||
|
|
||||||
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
|
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
|
||||||
|
|
||||||
endGroup( "Bitmap" );
|
endGroup("Bitmap");
|
||||||
|
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiBitmapCtrl::onWake()
|
bool GuiBitmapCtrl::onWake()
|
||||||
{
|
{
|
||||||
if (! Parent::onWake())
|
if (!Parent::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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,39 +153,51 @@ void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (mBitmap)
|
||||||
{
|
{
|
||||||
GFX->getDrawUtil()->clearBitmapModulation();
|
GFX->getDrawUtil()->clearBitmapModulation();
|
||||||
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
||||||
if(mWrap)
|
if (mWrap)
|
||||||
{
|
{
|
||||||
// We manually draw each repeat because non power of two textures will
|
// We manually draw each repeat because non power of two textures will
|
||||||
// not tile correctly when rendered with GFX->drawBitmapTile(). The non POT
|
// 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
|
// 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:
|
// in the texture. So... lets do what we must: draw each repeat by itself:
|
||||||
GFXTextureObject* texture = mBitmap;
|
GFXTextureObject* texture = mBitmap;
|
||||||
RectI srcRegion;
|
RectI srcRegion;
|
||||||
RectI dstRegion;
|
RectI dstRegion;
|
||||||
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
|
F32 xdone = ((F32)getExtent().x / (F32)texture->mBitmapSize.x) + 1;
|
||||||
F32 ydone = ((F32)getExtent().y/(F32)texture->mBitmapSize.y)+1;
|
F32 ydone = ((F32)getExtent().y / (F32)texture->mBitmapSize.y) + 1;
|
||||||
|
|
||||||
S32 xshift = mStartPoint.x%texture->mBitmapSize.x;
|
S32 xshift = mStartPoint.x % texture->mBitmapSize.x;
|
||||||
S32 yshift = mStartPoint.y%texture->mBitmapSize.y;
|
S32 yshift = mStartPoint.y % texture->mBitmapSize.y;
|
||||||
for(S32 y = 0; y < ydone; ++y)
|
for (S32 y = 0; y < ydone; ++y)
|
||||||
for(S32 x = 0; x < xdone; ++x)
|
for (S32 x = 0; x < xdone; ++x)
|
||||||
{
|
{
|
||||||
srcRegion.set(0,0,texture->mBitmapSize.x,texture->mBitmapSize.y);
|
srcRegion.set(0, 0, texture->mBitmapSize.x, texture->mBitmapSize.y);
|
||||||
dstRegion.set( ((texture->mBitmapSize.x*x)+offset.x)-xshift,
|
dstRegion.set(((texture->mBitmapSize.x * x) + offset.x) - xshift,
|
||||||
((texture->mBitmapSize.y*y)+offset.y)-yshift,
|
((texture->mBitmapSize.y * y) + offset.y) - yshift,
|
||||||
texture->mBitmapSize.x,
|
texture->mBitmapSize.x,
|
||||||
texture->mBitmapSize.y);
|
texture->mBitmapSize.y);
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mAngle);
|
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RectI rect(offset, getExtent());
|
RectI rect(offset, getExtent());
|
||||||
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false, mAngle);
|
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)
|
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;
|
||||||
mStartPoint.x = x % 256;
|
mStartPoint.x = x % 256;
|
||||||
|
|
||||||
while (y < 0)
|
while (y < 0)
|
||||||
y += 256;
|
y += 256;
|
||||||
mStartPoint.y = 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"
|
"Set the offset of the bitmap within the control.\n"
|
||||||
"@param x The x-axis offset of the image.\n"
|
"@param x The x-axis offset of the image.\n"
|
||||||
"@param y The y-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 filename The filename of the image.\n"
|
||||||
"@param resize Optional parameter. If true, the GUI will resize to fit the image.",
|
"@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.
|
"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(
|
static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
|
||||||
"@brief Assign an image to the control.\n\n"
|
"@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 filename The filename of the image.\n"
|
||||||
"@param resize A boolean value that decides whether the ctrl refreshes or not.",
|
"@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.
|
"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."
|
//"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"
|
"( String filename | String filename, bool resize ) Assign an image to the control.\n\n"
|
||||||
"@hide" )
|
"@hide")
|
||||||
{
|
{
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
Con::expandScriptFilename(filename, sizeof(filename), fileRoot);
|
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"
|
"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), ,
|
||||||
"@brief Set a texture as the image.\n\n"
|
"@brief Set a texture as the image.\n\n"
|
||||||
"@param namedtexture The name of the texture (NamedTexTarget).\n"
|
"@param namedtexture The name of the texture (NamedTexTarget).\n"
|
||||||
"@return true if the texture exists." )
|
"@return true if the texture exists.")
|
||||||
{
|
{
|
||||||
GFXTexHandle theTex;
|
GFXTexHandle theTex;
|
||||||
NamedTexTarget *namedTarget = NULL;
|
NamedTexTarget* namedTarget = NULL;
|
||||||
namedTarget = NamedTexTarget::find(namedtexture.c_str());
|
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 true; //a new texture was set correctly
|
||||||
}
|
}
|
||||||
return false; //we couldn't change the texture
|
return false; //we couldn't change the texture
|
||||||
|
|
|
||||||
|
|
@ -31,51 +31,47 @@
|
||||||
/// Renders a bitmap.
|
/// Renders a bitmap.
|
||||||
class GuiBitmapCtrl : public GuiControl
|
class GuiBitmapCtrl : public GuiControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef GuiControl Parent;
|
typedef GuiControl Parent;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// 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;
|
||||||
F32 mAngle;
|
F32 mAngle;
|
||||||
|
|
||||||
/// 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 );
|
public:
|
||||||
static const char *getBitmapName( void *obj, const char *data );
|
GFXTexHandle mBitmap;
|
||||||
|
StringTableEntry mBitmapName;
|
||||||
|
|
||||||
void onImageChanged() {}
|
GuiBitmapCtrl();
|
||||||
|
static void initPersistFields();
|
||||||
|
|
||||||
public:
|
// GuiControl.
|
||||||
|
bool onWake() override;
|
||||||
|
void onSleep() override;
|
||||||
|
void inspectPostApply() override;
|
||||||
|
|
||||||
GuiBitmapCtrl();
|
void setBitmap(const char* name, bool resize = true);
|
||||||
static void initPersistFields();
|
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
|
||||||
|
|
||||||
void setBitmap(const char *name,bool resize = false);
|
void updateSizing();
|
||||||
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
|
|
||||||
|
|
||||||
// GuiControl.
|
void onRender(Point2I offset, const RectI& updateRect) override;
|
||||||
bool onWake() override;
|
void setValue(S32 x, S32 y);
|
||||||
void onSleep() override;
|
|
||||||
void inspectPostApply() override;
|
|
||||||
|
|
||||||
void updateSizing();
|
DECLARE_CONOBJECT(GuiBitmapCtrl);
|
||||||
|
DECLARE_CATEGORY("Gui Images");
|
||||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
DECLARE_DESCRIPTION("A control that displays a single, static image from a file.n"
|
||||||
void setValue(S32 x, S32 y);
|
"The bitmap can either be tiled or stretched inside the control.");
|
||||||
|
|
||||||
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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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");
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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() {}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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.");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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" );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue