mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Merge pull request #1608 from irei1as/patch-1
Set textures as bitmapctrl in script
This commit is contained in:
commit
e79e5eb616
1 changed files with 23 additions and 0 deletions
|
|
@ -29,6 +29,8 @@
|
|||
#include "gfx/gfxDevice.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
|
||||
#include "materials/matTextureTarget.h"
|
||||
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiBitmapCtrl);
|
||||
|
||||
|
|
@ -267,3 +269,24 @@ DefineConsoleMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, bo
|
|||
Con::expandScriptFilename(filename, sizeof(filename), fileRoot);
|
||||
object->setBitmap(filename, resize );
|
||||
}
|
||||
|
||||
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." )
|
||||
{
|
||||
GFXTexHandle theTex;
|
||||
NamedTexTarget *namedTarget = NULL;
|
||||
namedTarget = NamedTexTarget::find(namedtexture.c_str());
|
||||
if ( namedTarget )
|
||||
{
|
||||
theTex = namedTarget->getTexture( 0 );
|
||||
}
|
||||
|
||||
if ( theTex.isValid() )
|
||||
{
|
||||
object->setBitmapHandle( theTex , false );
|
||||
return true; //a new texture was set correctly
|
||||
}
|
||||
return false; //we couldn't change the texture
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue