mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
Converts all game, gui editor, and system classes to utilize assets
Processed core, tools and default modules to utilize assets Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption Removed unneeded MainEditor mockup module Removed some unused/duplicate image assets from the tools
This commit is contained in:
parent
83b0432283
commit
5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions
|
|
@ -56,11 +56,11 @@ ConsoleDocClass( GuiBitmapCtrl,
|
|||
);
|
||||
|
||||
GuiBitmapCtrl::GuiBitmapCtrl(void)
|
||||
: mBitmapName(),
|
||||
mStartPoint( 0, 0 ),
|
||||
: mStartPoint( 0, 0 ),
|
||||
mColor(ColorI::WHITE),
|
||||
mWrap( false )
|
||||
{
|
||||
{
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
}
|
||||
|
||||
bool GuiBitmapCtrl::setBitmapName( void *object, const char *index, const char *data )
|
||||
|
|
@ -78,10 +78,8 @@ bool GuiBitmapCtrl::setBitmapName( void *object, const char *index, const char *
|
|||
void GuiBitmapCtrl::initPersistFields()
|
||||
{
|
||||
addGroup( "Bitmap" );
|
||||
|
||||
addProtectedField( "bitmap", TypeImageFilename, Offset( mBitmapName, GuiBitmapCtrl ),
|
||||
&setBitmapName, &defaultProtectedGetFn,
|
||||
"The bitmap file to display in the control.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapCtrl, The bitmap file to display in the control);
|
||||
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." );
|
||||
|
|
@ -96,14 +94,15 @@ bool GuiBitmapCtrl::onWake()
|
|||
if (! Parent::onWake())
|
||||
return false;
|
||||
setActive(true);
|
||||
setBitmap(mBitmapName);
|
||||
|
||||
setBitmap(getBitmap());
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiBitmapCtrl::onSleep()
|
||||
{
|
||||
if ( !mBitmapName.equal("texhandle", String::NoCase) )
|
||||
mTextureObject = NULL;
|
||||
if ( mBitmapName != StringTable->insert("texhandle") )
|
||||
mBitmap = NULL;
|
||||
|
||||
Parent::onSleep();
|
||||
}
|
||||
|
|
@ -115,32 +114,24 @@ void GuiBitmapCtrl::inspectPostApply()
|
|||
// set it's extent to be exactly the size of the bitmap (if present)
|
||||
Parent::inspectPostApply();
|
||||
|
||||
if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mTextureObject)
|
||||
if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mBitmap)
|
||||
{
|
||||
setExtent( mTextureObject->getWidth(), mTextureObject->getHeight());
|
||||
setExtent( mBitmap->getWidth(), mBitmap->getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
void GuiBitmapCtrl::setBitmap( const char *name, bool resize )
|
||||
{
|
||||
mBitmapName = name;
|
||||
if ( !isAwake() )
|
||||
return;
|
||||
|
||||
if ( mBitmapName.isNotEmpty() )
|
||||
{
|
||||
if ( !mBitmapName.equal("texhandle", String::NoCase) )
|
||||
mTextureObject.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__) );
|
||||
_setBitmap(StringTable->insert(name));
|
||||
|
||||
// Resize the control to fit the bitmap
|
||||
if ( mTextureObject && resize )
|
||||
{
|
||||
setExtent( mTextureObject->getWidth(), mTextureObject->getHeight() );
|
||||
updateSizing();
|
||||
}
|
||||
if (mBitmap && resize)
|
||||
{
|
||||
setExtent(mBitmap->getWidth(), mBitmap->getHeight());
|
||||
updateSizing();
|
||||
}
|
||||
else
|
||||
mTextureObject = NULL;
|
||||
|
||||
setUpdate();
|
||||
}
|
||||
|
|
@ -156,21 +147,21 @@ void GuiBitmapCtrl::updateSizing()
|
|||
|
||||
void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
|
||||
{
|
||||
mTextureObject = handle;
|
||||
mBitmap = handle;
|
||||
|
||||
mBitmapName = String("texhandle");
|
||||
|
||||
// Resize the control to fit the bitmap
|
||||
if (resize)
|
||||
{
|
||||
setExtent(mTextureObject->getWidth(), mTextureObject->getHeight());
|
||||
setExtent(mBitmap->getWidth(), mBitmap->getHeight());
|
||||
updateSizing();
|
||||
}
|
||||
}
|
||||
|
||||
void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||
{
|
||||
if (mTextureObject)
|
||||
if (mBitmap)
|
||||
{
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
||||
|
|
@ -180,7 +171,7 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
// 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 = mTextureObject;
|
||||
GFXTextureObject* texture = mBitmap;
|
||||
RectI srcRegion;
|
||||
RectI dstRegion;
|
||||
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
|
||||
|
|
@ -203,11 +194,11 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
else
|
||||
{
|
||||
RectI rect(offset, getExtent());
|
||||
GFX->getDrawUtil()->drawBitmapStretch(mTextureObject, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mProfile->mBorder || !mTextureObject)
|
||||
if (mProfile->mBorder || !mBitmap)
|
||||
{
|
||||
RectI rect(offset.x, offset.y, getExtent().x, getExtent().y);
|
||||
GFX->getDrawUtil()->drawRect(rect, mProfile->mBorderColor);
|
||||
|
|
@ -218,10 +209,10 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
|
||||
void GuiBitmapCtrl::setValue(S32 x, S32 y)
|
||||
{
|
||||
if (mTextureObject)
|
||||
if (mBitmap)
|
||||
{
|
||||
x += mTextureObject->getWidth() / 2;
|
||||
y += mTextureObject->getHeight() / 2;
|
||||
x += mBitmap->getWidth() / 2;
|
||||
y += mBitmap->getHeight() / 2;
|
||||
}
|
||||
while (x < 0)
|
||||
x += 256;
|
||||
|
|
@ -270,6 +261,13 @@ DefineEngineMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, boo
|
|||
object->setBitmap(filename, resize );
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (),,
|
||||
"Gets the current bitmap set for this control.\n\n"
|
||||
"@hide")
|
||||
{
|
||||
return object->getBitmap();
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture),,
|
||||
"@brief Set a texture as the image.\n\n"
|
||||
"@param namedtexture The name of the texture (NamedTexTarget).\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue