mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
Merge remote-tracking branch 'devhead/Preview4_0' into tsneo
# Conflicts: # Templates/BaseGame/game/data/ui/guis/loadingGui.gui # Templates/BaseGame/game/data/ui/guis/mainMenu.gui # Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui # Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui # Templates/BaseGame/game/tools/forestEditor/brushes.tscript
This commit is contained in:
commit
717c7acca9
2266 changed files with 48780 additions and 26034 deletions
|
|
@ -30,6 +30,9 @@
|
|||
#include "gui/core/guiDefaultControlRender.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "gfx/gfxTextureManager.h"
|
||||
#include "gui/editor/inspector/group.h"
|
||||
#include "gui/editor/inspector/field.h"
|
||||
#include "gui/editor/guiInspector.h"
|
||||
|
||||
|
||||
ImplementEnumType( GuiBitmapMode,
|
||||
|
|
@ -125,6 +128,8 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
|
|||
mUseStates = true;
|
||||
setExtent( 140, 30 );
|
||||
mMasked = false;
|
||||
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -132,13 +137,12 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
|
|||
void GuiBitmapButtonCtrl::initPersistFields()
|
||||
{
|
||||
addGroup( "Bitmap" );
|
||||
|
||||
addProtectedField( "bitmap", TypeStringFilename, Offset( mBitmapName, GuiBitmapButtonCtrl ),
|
||||
&_setBitmap, &defaultProtectedGetFn,
|
||||
"Texture file to display on this button.\n"
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapButtonCtrl, "Texture file to display on this button.\n"
|
||||
"If useStates is false, this will be the file that renders on the control. Otherwise, this will "
|
||||
"specify the default texture name to which the various state and modifier suffixes are appended "
|
||||
"to find the per-state and per-modifier (if enabled) textures." );
|
||||
"to find the per-state and per-modifier (if enabled) textures.");
|
||||
|
||||
addField( "bitmapMode", TYPEID< BitmapMode >(), Offset( mBitmapMode, GuiBitmapButtonCtrl ),
|
||||
"Behavior for fitting the bitmap to the control extents.\n"
|
||||
"If set to 'Stretched', the bitmap will be stretched both verticall and horizontally to fit inside "
|
||||
|
|
@ -173,7 +177,7 @@ bool GuiBitmapButtonCtrl::onWake()
|
|||
return false;
|
||||
|
||||
setActive( true );
|
||||
setBitmap( mBitmapName );
|
||||
setBitmap( getBitmap() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -205,22 +209,22 @@ bool GuiBitmapButtonCtrl::_setAutoFitExtents( void *object, const char *index, c
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool GuiBitmapButtonCtrl::_setBitmap( void *object, const char *index, const char *data )
|
||||
/*bool GuiBitmapButtonCtrl::_setBitmap(void* object, const char* index, const char* data)
|
||||
{
|
||||
GuiBitmapButtonCtrl* ctrl = reinterpret_cast< GuiBitmapButtonCtrl* >( object );
|
||||
ctrl->setBitmap( data );
|
||||
ctrl->setBitmap( StringTable->insert(data) );
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Legacy method. Can just assign to bitmap field.
|
||||
DefineEngineMethod( GuiBitmapButtonCtrl, setBitmap, void, ( const char* path ),,
|
||||
/*DefineEngineMethod(GuiBitmapButtonCtrl, setBitmap, void, (const char* path), ,
|
||||
"Set the bitmap to show on the button.\n"
|
||||
"@param path Path to the texture file in any of the supported formats.\n" )
|
||||
{
|
||||
object->setBitmap( path );
|
||||
}
|
||||
object->setBitmap( StringTable->insert(path) );
|
||||
}*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -253,7 +257,7 @@ void GuiBitmapButtonCtrl::inspectPostApply()
|
|||
}
|
||||
}
|
||||
|
||||
setBitmap( path.getFullPath() );
|
||||
setBitmap( StringTable->insert(path.getFullPath().c_str()) );
|
||||
|
||||
// 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 normal bitmap (if present)
|
||||
|
|
@ -275,17 +279,17 @@ void GuiBitmapButtonCtrl::setAutoFitExtents( bool state )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GuiBitmapButtonCtrl::setBitmap( const String& name )
|
||||
void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||
{
|
||||
PROFILE_SCOPE( GuiBitmapButtonCtrl_setBitmap );
|
||||
|
||||
mBitmapName = name;
|
||||
_setBitmap(name);
|
||||
if( !isAwake() )
|
||||
return;
|
||||
|
||||
if( !mBitmapName.isEmpty() )
|
||||
if( mBitmapAsset.notNull())
|
||||
{
|
||||
if( dStricmp( mBitmapName, "texhandle" ) != 0 )
|
||||
if( dStricmp( getBitmap(), "texhandle" ) != 0 )
|
||||
{
|
||||
const U32 count = mUseModifiers ? NumModifiers : 1;
|
||||
for( U32 i = 0; i < count; ++ i )
|
||||
|
|
@ -298,39 +302,110 @@ void GuiBitmapButtonCtrl::setBitmap( const String& name )
|
|||
"_shift"
|
||||
};
|
||||
|
||||
static String s_n = "_n";
|
||||
static String s_d = "_d";
|
||||
static String s_h = "_h";
|
||||
static String s_i = "_i";
|
||||
static String s_n[2] = { "_n", "_n_image" };
|
||||
static String s_d[2] = { "_d", "_d_image" };
|
||||
static String s_h[2] = { "_h", "_h_image" };
|
||||
static String s_i[2] = { "_i", "_i_image" };
|
||||
|
||||
String baseName = mBitmapAssetId;
|
||||
|
||||
//strip any pre-assigned suffix, just in case
|
||||
baseName = baseName.replace("_n_image", "");
|
||||
baseName = baseName.replace("_n", "");
|
||||
|
||||
String baseName = mBitmapName;
|
||||
if( mUseModifiers )
|
||||
baseName += modifiers[ i ];
|
||||
|
||||
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
|
||||
mTextures[ i ].mTextureNormal = GFXTexHandle( mBitmapAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
|
||||
|
||||
if( mUseStates )
|
||||
{
|
||||
if( !mTextures[ i ].mTextureNormal )
|
||||
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName + s_n, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
|
||||
|
||||
mTextures[ i ].mTextureHilight = GFXTexHandle( baseName + s_h, &GFXDefaultGUIProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
|
||||
//normal lookup
|
||||
StringTableEntry lookupName;
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
if (!mTextures[i].mTextureNormal)
|
||||
{
|
||||
lookupName = StringTable->insert(String(baseName + s_n[s]).c_str());
|
||||
if (AssetDatabase.isDeclaredAsset(lookupName))
|
||||
{
|
||||
mTextures[i].mTextureNormalAssetId = lookupName;
|
||||
mTextures[i].mTextureNormalAsset = mTextures[i].mTextureNormalAssetId;
|
||||
}
|
||||
|
||||
if (mTextures[i].mTextureNormalAsset.notNull() && mTextures[i].mTextureNormalAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureNormal = GFXTexHandle(mTextures[i].mTextureNormalAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Hilight lookup
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
lookupName = StringTable->insert(String(baseName + s_h[s]).c_str());
|
||||
if (AssetDatabase.isDeclaredAsset(lookupName))
|
||||
{
|
||||
mTextures[i].mTextureHilightAssetId = lookupName;
|
||||
mTextures[i].mTextureHilightAsset = mTextures[i].mTextureHilightAssetId;
|
||||
}
|
||||
|
||||
if (mTextures[i].mTextureHilightAsset.notNull() && mTextures[i].mTextureHilightAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureHilight = GFXTexHandle(mTextures[i].mTextureHilightAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureHilight )
|
||||
mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
|
||||
|
||||
mTextures[ i ].mTextureDepressed = GFXTexHandle( baseName + s_d, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
|
||||
|
||||
//Depressed lookup
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
lookupName = StringTable->insert(String(baseName + s_d[s]).c_str());
|
||||
if (AssetDatabase.isDeclaredAsset(lookupName))
|
||||
{
|
||||
mTextures[i].mTextureDepressedAssetId = lookupName;
|
||||
mTextures[i].mTextureDepressedAsset = mTextures[i].mTextureDepressedAssetId;
|
||||
}
|
||||
|
||||
if (mTextures[i].mTextureDepressedAsset.notNull() && mTextures[i].mTextureDepressedAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureDepressed = GFXTexHandle(mTextures[i].mTextureDepressedAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureDepressed )
|
||||
mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
|
||||
|
||||
mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXDefaultGUIProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
|
||||
//Depressed lookup
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
lookupName = StringTable->insert(String(baseName + s_i[s]).c_str());
|
||||
if (AssetDatabase.isDeclaredAsset(lookupName))
|
||||
{
|
||||
mTextures[i].mTextureInactiveAssetId = lookupName;
|
||||
mTextures[i].mTextureInactiveAsset = mTextures[i].mTextureInactiveAssetId;
|
||||
}
|
||||
|
||||
if (mTextures[i].mTextureInactiveAsset.notNull() && mTextures[i].mTextureInactiveAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureInactive = GFXTexHandle(mTextures[i].mTextureInactiveAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureInactive )
|
||||
mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
|
||||
}
|
||||
|
||||
if( i == 0 && mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull() )
|
||||
{
|
||||
Con::warnf( "GuiBitmapButtonCtrl::setBitmap - Unable to load texture: %s", mBitmapName.c_str() );
|
||||
this->setBitmap( GFXTextureManager::getUnavailableTexturePath() );
|
||||
Con::warnf( "GuiBitmapButtonCtrl::setBitmap - Unable to load texture: %s", mBitmapName );
|
||||
this->setBitmap( StringTable->insert(GFXTextureManager::getUnavailableTexturePath().c_str()) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -375,7 +450,7 @@ void GuiBitmapButtonCtrl::setBitmapHandles(GFXTexHandle normal, GFXTexHandle hig
|
|||
if (mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull())
|
||||
{
|
||||
Con::warnf("GuiBitmapButtonCtrl::setBitmapHandles() - Invalid texture handles");
|
||||
setBitmap( GFXTextureManager::getUnavailableTexturePath() );
|
||||
setBitmap( StringTable->insert(GFXTextureManager::getUnavailableTexturePath().c_str()) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -591,4 +666,6 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
|
|||
}
|
||||
else
|
||||
return Parent::pointInControl(parentCoordPoint);
|
||||
}
|
||||
}
|
||||
|
||||
DEF_IMAGEASSET_BINDS(GuiBitmapButtonCtrl, Bitmap);
|
||||
|
|
|
|||
|
|
@ -84,15 +84,23 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
|||
struct Textures
|
||||
{
|
||||
/// Texture for normal state.
|
||||
StringTableEntry mTextureNormalAssetId;
|
||||
AssetPtr<ImageAsset> mTextureNormalAsset;
|
||||
GFXTexHandle mTextureNormal;
|
||||
|
||||
/// Texture for highlight state.
|
||||
StringTableEntry mTextureHilightAssetId;
|
||||
AssetPtr<ImageAsset> mTextureHilightAsset;
|
||||
GFXTexHandle mTextureHilight;
|
||||
|
||||
/// Texture for depressed state.
|
||||
StringTableEntry mTextureDepressedAssetId;
|
||||
AssetPtr<ImageAsset> mTextureDepressedAsset;
|
||||
GFXTexHandle mTextureDepressed;
|
||||
|
||||
/// Texture for inactive state.
|
||||
StringTableEntry mTextureInactiveAssetId;
|
||||
AssetPtr<ImageAsset> mTextureInactiveAsset;
|
||||
GFXTexHandle mTextureInactive;
|
||||
};
|
||||
|
||||
|
|
@ -110,8 +118,8 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
|||
///
|
||||
BitmapMode mBitmapMode;
|
||||
|
||||
/// File name for bitmap.
|
||||
String mBitmapName;
|
||||
DECLARE_IMAGEASSET(GuiBitmapButtonCtrl, Bitmap, onBitmapChange, GFXDefaultGUIProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiBitmapButtonCtrl, Bitmap);
|
||||
|
||||
/// alpha masking
|
||||
bool mMasked;
|
||||
|
|
@ -122,7 +130,7 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
|||
virtual void renderButton( GFXTexHandle &texture, const Point2I& offset, const RectI& updateRect );
|
||||
|
||||
static bool _setAutoFitExtents( void *object, const char *index, const char *data );
|
||||
static bool _setBitmap( void *object, const char *index, const char *data );
|
||||
//static bool _setBitmap( void *object, const char *index, const char *data );
|
||||
|
||||
State getState() const
|
||||
{
|
||||
|
|
@ -149,12 +157,14 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
|||
|
||||
/// @}
|
||||
|
||||
void onBitmapChange() {}
|
||||
|
||||
public:
|
||||
|
||||
GuiBitmapButtonCtrl();
|
||||
|
||||
void setAutoFitExtents( bool state );
|
||||
void setBitmap( const String& name );
|
||||
void setBitmap( StringTableEntry name );
|
||||
void setBitmapHandles( GFXTexHandle normal, GFXTexHandle highlighted, GFXTexHandle depressed, GFXTexHandle inactive );
|
||||
|
||||
//Parent methods
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ void GuiCheckBoxCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
xOffset = mProfile->mBitmapArrayRects[0].extent.x + 2 + mIndent;
|
||||
S32 y = (getHeight() - mProfile->mBitmapArrayRects[0].extent.y) / 2;
|
||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, offset + Point2I(mIndent, y), mProfile->mBitmapArrayRects[index]);
|
||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->getBitmapResource(), offset + Point2I(mIndent, y), mProfile->mBitmapArrayRects[index]);
|
||||
}
|
||||
|
||||
if(mButtonText[0] != '\0')
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ ConsoleDocClass( GuiIconButtonCtrl,
|
|||
|
||||
GuiIconButtonCtrl::GuiIconButtonCtrl()
|
||||
{
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
mTextLocation = TextLocLeft;
|
||||
mIconLocation = IconLocLeft;
|
||||
mTextMargin = 4;
|
||||
|
|
@ -94,9 +94,6 @@ GuiIconButtonCtrl::GuiIconButtonCtrl()
|
|||
mFitBitmapToButton = false;
|
||||
mMakeIconSquare = false;
|
||||
|
||||
mErrorBitmapName = StringTable->EmptyString();
|
||||
mErrorTextureHandle = NULL;
|
||||
|
||||
mAutoSize = false;
|
||||
|
||||
setExtent(140, 30);
|
||||
|
|
@ -125,7 +122,10 @@ EndImplementEnumType;
|
|||
void GuiIconButtonCtrl::initPersistFields()
|
||||
{
|
||||
addField( "buttonMargin", TypePoint2I, Offset( mButtonMargin, GuiIconButtonCtrl ),"Margin area around the button.\n");
|
||||
addField( "iconBitmap", TypeFilename, Offset( mBitmapName, GuiIconButtonCtrl ),"Bitmap file for the icon to display on the button.\n");
|
||||
|
||||
addProtectedField( "iconBitmap", TypeImageFilename, Offset( mBitmapName, GuiIconButtonCtrl ), &_setBitmapData, &defaultProtectedGetFn, "Bitmap file for the icon to display on the button.\n", AbstractClassRep::FIELD_HideInInspectors);
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiIconButtonCtrl, "Bitmap file for the icon to display on the button.\n");
|
||||
|
||||
addField( "iconLocation", TYPEID< IconLocation >(), Offset( mIconLocation, GuiIconButtonCtrl ),"Where to place the icon on the control. Options are 0 (None), 1 (Left), 2 (Right), 3 (Center).\n");
|
||||
addField( "sizeIconToButton", TypeBool, Offset( mFitBitmapToButton, GuiIconButtonCtrl ),"If true, the icon will be scaled to be the same size as the button.\n");
|
||||
addField( "makeIconSquare", TypeBool, Offset( mMakeIconSquare, GuiIconButtonCtrl ),"If true, will make sure the icon is square.\n");
|
||||
|
|
@ -152,7 +152,6 @@ bool GuiIconButtonCtrl::onWake()
|
|||
|
||||
void GuiIconButtonCtrl::onSleep()
|
||||
{
|
||||
mTextureNormal = NULL;
|
||||
Parent::onSleep();
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +175,8 @@ bool GuiIconButtonCtrl::resize(const Point2I &newPosition, const Point2I &newExt
|
|||
|
||||
if ( mIconLocation != IconLocNone )
|
||||
{
|
||||
autoExtent.y = mTextureNormal.getHeight() + mButtonMargin.y * 2;
|
||||
autoExtent.x = mTextureNormal.getWidth() + mButtonMargin.x * 2;
|
||||
autoExtent.y = mBitmap.getHeight() + mButtonMargin.y * 2;
|
||||
autoExtent.x = mBitmap.getWidth() + mButtonMargin.x * 2;
|
||||
}
|
||||
|
||||
if ( mTextLocation != TextLocNone && mButtonText && mButtonText[0] )
|
||||
|
|
@ -201,18 +200,10 @@ bool GuiIconButtonCtrl::resize(const Point2I &newPosition, const Point2I &newExt
|
|||
|
||||
void GuiIconButtonCtrl::setBitmap(const char *name)
|
||||
{
|
||||
mBitmapName = StringTable->insert(name);
|
||||
if(!isAwake())
|
||||
return;
|
||||
|
||||
if (*mBitmapName)
|
||||
{
|
||||
mTextureNormal = GFXTexHandle( name, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextureNormal = NULL;
|
||||
}
|
||||
_setBitmap(getBitmap());
|
||||
|
||||
// So that extent is recalculated if autoSize is set.
|
||||
resize( getPosition(), getExtent() );
|
||||
|
|
@ -279,7 +270,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
RectI iconRect( 0, 0, 0, 0 );
|
||||
|
||||
// Render the icon
|
||||
if ( mTextureNormal && mIconLocation != GuiIconButtonCtrl::IconLocNone )
|
||||
if ( mBitmap && mIconLocation != GuiIconButtonCtrl::IconLocNone )
|
||||
{
|
||||
// Render the normal bitmap
|
||||
drawer->clearBitmapModulation();
|
||||
|
|
@ -287,7 +278,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
// Maintain the bitmap size or fill the button?
|
||||
if ( !mFitBitmapToButton )
|
||||
{
|
||||
Point2I textureSize( mTextureNormal->getWidth(), mTextureNormal->getHeight() );
|
||||
Point2I textureSize(mBitmap->getWidth(), mBitmap->getHeight() );
|
||||
iconRect.set( offset + mButtonMargin, textureSize );
|
||||
|
||||
if ( mIconLocation == IconLocRight )
|
||||
|
|
@ -306,7 +297,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
iconRect.point.y = offset.y + ( getHeight() - textureSize.y ) / 2;
|
||||
}
|
||||
|
||||
drawer->drawBitmapStretch( mTextureNormal, iconRect );
|
||||
drawer->drawBitmapStretch(mBitmap, iconRect );
|
||||
|
||||
}
|
||||
else
|
||||
|
|
@ -322,7 +313,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
iconRect.extent.x = iconRect.extent.y;
|
||||
}
|
||||
|
||||
drawer->drawBitmapStretch( mTextureNormal, iconRect );
|
||||
drawer->drawBitmapStretch( mBitmap, iconRect );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +330,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
if ( mTextLocation == TextLocRight )
|
||||
{
|
||||
Point2I start( mTextMargin, ( getHeight() - mProfile->mFont->getHeight() ) / 2 );
|
||||
if ( mTextureNormal && mIconLocation != IconLocNone )
|
||||
if (mBitmap && mIconLocation != IconLocNone )
|
||||
{
|
||||
start.x = iconRect.extent.x + mButtonMargin.x + mTextMargin;
|
||||
}
|
||||
|
|
@ -357,7 +348,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
if ( mTextLocation == TextLocCenter )
|
||||
{
|
||||
Point2I start;
|
||||
if ( mTextureNormal && mIconLocation == IconLocLeft )
|
||||
if (mBitmap && mIconLocation == IconLocLeft )
|
||||
{
|
||||
start.set( ( getWidth() - textWidth - iconRect.extent.x ) / 2 + iconRect.extent.x,
|
||||
( getHeight() - mProfile->mFont->getHeight() ) / 2 );
|
||||
|
|
@ -421,19 +412,4 @@ void GuiIconButtonCtrl::renderBitmapArray(RectI &bounds, S32 state)
|
|||
}
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiIconButtonCtrl, setBitmap, void, (const char* buttonFilename),,
|
||||
"@brief Set the bitmap to use for the button portion of this control.\n\n"
|
||||
"@param buttonFilename Filename for the image\n"
|
||||
"@tsexample\n"
|
||||
"// Define the button filename\n"
|
||||
"%buttonFilename = \"pearlButton\";\n\n"
|
||||
"// Inform the GuiIconButtonCtrl control to update its main button graphic to the defined bitmap\n"
|
||||
"%thisGuiIconButtonCtrl.setBitmap(%buttonFilename);\n"
|
||||
"@endtsexample\n\n"
|
||||
"@see GuiControl\n"
|
||||
"@see GuiButtonCtrl\n\n")
|
||||
{
|
||||
char* argBuffer = Con::getArgBuffer( 512 );
|
||||
Platform::makeFullPathName( buttonFilename, argBuffer, 512 );
|
||||
object->setBitmap( argBuffer );
|
||||
}
|
||||
DEF_IMAGEASSET_BINDS(GuiIconButtonCtrl, Bitmap);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "gfx/gfxTextureManager.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
/// The GuiIconButtonCtrl draws an icon and text caption within a normal
|
||||
/// button control with several layout options.
|
||||
|
|
@ -41,8 +42,9 @@ private:
|
|||
|
||||
protected:
|
||||
|
||||
StringTableEntry mBitmapName;
|
||||
GFXTexHandle mTextureNormal;
|
||||
DECLARE_IMAGEASSET(GuiIconButtonCtrl, Bitmap, onImageChanged, GFXTexturePersistentSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiIconButtonCtrl, Bitmap);
|
||||
|
||||
S32 mIconLocation;
|
||||
S32 mTextLocation;
|
||||
S32 mTextMargin;
|
||||
|
|
@ -57,10 +59,6 @@ protected:
|
|||
/// Calculate extent based on icon size, text width, and layout options.
|
||||
bool mAutoSize;
|
||||
|
||||
// Optional bitmap to be displayed when the proper bitmap cannot be found
|
||||
StringTableEntry mErrorBitmapName;
|
||||
GFXTexHandle mErrorTextureHandle;
|
||||
|
||||
void renderButton( Point2I &offset, const RectI& updateRect);
|
||||
|
||||
enum
|
||||
|
|
@ -114,6 +112,8 @@ public:
|
|||
void setErrorBitmap(const char *name);
|
||||
|
||||
void onRender(Point2I offset, const RectI &updateRect);
|
||||
|
||||
void onImageChanged() {}
|
||||
};
|
||||
|
||||
typedef GuiIconButtonCtrl::TextLocation GuiIconButtonTextLocation;
|
||||
|
|
|
|||
|
|
@ -43,9 +43,10 @@ ConsoleDocClass( GuiToolboxButtonCtrl,
|
|||
//-------------------------------------
|
||||
GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
|
||||
{
|
||||
mNormalBitmapName = StringTable->EmptyString();
|
||||
mLoweredBitmapName = StringTable->insert("sceneeditor/client/images/buttondown");
|
||||
mHoverBitmapName = StringTable->insert("sceneeditor/client/images/buttonup");
|
||||
INIT_IMAGEASSET(NormalBitmap);
|
||||
INIT_IMAGEASSET(LoweredBitmap);
|
||||
INIT_IMAGEASSET(HoverBitmap);
|
||||
|
||||
setMinExtent(Point2I(16,16));
|
||||
setExtent(48, 48);
|
||||
mButtonType = ButtonTypeRadio;
|
||||
|
|
@ -57,9 +58,10 @@ GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
|
|||
//-------------------------------------
|
||||
void GuiToolboxButtonCtrl::initPersistFields()
|
||||
{
|
||||
addField("normalBitmap", TypeFilename, Offset(mNormalBitmapName, GuiToolboxButtonCtrl));
|
||||
addField("loweredBitmap", TypeFilename, Offset(mLoweredBitmapName, GuiToolboxButtonCtrl));
|
||||
addField("hoverBitmap", TypeFilename, Offset(mHoverBitmapName, GuiToolboxButtonCtrl));
|
||||
INITPERSISTFIELD_IMAGEASSET(NormalBitmap, GuiToolboxButtonCtrl, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(LoweredBitmap, GuiToolboxButtonCtrl, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(HoverBitmap, GuiToolboxButtonCtrl, "");
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
@ -72,9 +74,9 @@ bool GuiToolboxButtonCtrl::onWake()
|
|||
|
||||
setActive( true );
|
||||
|
||||
setNormalBitmap( mNormalBitmapName );
|
||||
setLoweredBitmap( mLoweredBitmapName );
|
||||
setHoverBitmap( mHoverBitmapName );
|
||||
setNormalBitmap( getNormalBitmap() );
|
||||
setLoweredBitmap( getLoweredBitmap() );
|
||||
setHoverBitmap( getHoverBitmap() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -83,30 +85,9 @@ bool GuiToolboxButtonCtrl::onWake()
|
|||
//-------------------------------------
|
||||
void GuiToolboxButtonCtrl::onSleep()
|
||||
{
|
||||
mTextureNormal = NULL;
|
||||
mTextureLowered = NULL;
|
||||
mTextureHover = NULL;
|
||||
Parent::onSleep();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
DefineEngineMethod( GuiToolboxButtonCtrl, setNormalBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is active")
|
||||
{
|
||||
object->setNormalBitmap(name);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiToolboxButtonCtrl, setLoweredBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled")
|
||||
{
|
||||
object->setLoweredBitmap(name);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiToolboxButtonCtrl, setHoverBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled")
|
||||
{
|
||||
object->setHoverBitmap(name);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
void GuiToolboxButtonCtrl::inspectPostApply()
|
||||
{
|
||||
|
|
@ -114,9 +95,9 @@ void GuiToolboxButtonCtrl::inspectPostApply()
|
|||
// set it's extent to be exactly the size of the normal bitmap (if present)
|
||||
Parent::inspectPostApply();
|
||||
|
||||
if ((getWidth() == 0) && (getHeight() == 0) && mTextureNormal)
|
||||
if ((getWidth() == 0) && (getHeight() == 0) && mNormalBitmap)
|
||||
{
|
||||
setExtent( mTextureNormal->getWidth(), mTextureNormal->getHeight());
|
||||
setExtent(mNormalBitmap->getWidth(), mNormalBitmap->getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,46 +105,31 @@ void GuiToolboxButtonCtrl::inspectPostApply()
|
|||
//-------------------------------------
|
||||
void GuiToolboxButtonCtrl::setNormalBitmap( StringTableEntry bitmapName )
|
||||
{
|
||||
mNormalBitmapName = StringTable->insert( bitmapName );
|
||||
_setNormalBitmap(bitmapName);
|
||||
|
||||
if(!isAwake())
|
||||
return;
|
||||
|
||||
if ( *mNormalBitmapName )
|
||||
mTextureNormal = GFXTexHandle( mNormalBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
|
||||
else
|
||||
mTextureNormal = NULL;
|
||||
|
||||
setUpdate();
|
||||
}
|
||||
|
||||
void GuiToolboxButtonCtrl::setLoweredBitmap( StringTableEntry bitmapName )
|
||||
{
|
||||
mLoweredBitmapName = StringTable->insert( bitmapName );
|
||||
_setLoweredBitmap(bitmapName);
|
||||
|
||||
if(!isAwake())
|
||||
return;
|
||||
|
||||
if ( *mLoweredBitmapName )
|
||||
mTextureLowered = GFXTexHandle( mLoweredBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureLowered (line %d)", __FUNCTION__, __LINE__) );
|
||||
else
|
||||
mTextureLowered = NULL;
|
||||
|
||||
setUpdate();
|
||||
}
|
||||
|
||||
void GuiToolboxButtonCtrl::setHoverBitmap( StringTableEntry bitmapName )
|
||||
{
|
||||
mHoverBitmapName = StringTable->insert( bitmapName );
|
||||
_setHoverBitmap(bitmapName);
|
||||
|
||||
if(!isAwake())
|
||||
return;
|
||||
|
||||
if ( *mHoverBitmapName )
|
||||
mTextureHover = GFXTexHandle( mHoverBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureHover (line %d)", __FUNCTION__, __LINE__) );
|
||||
else
|
||||
mTextureHover = NULL;
|
||||
|
||||
setUpdate();
|
||||
}
|
||||
|
||||
|
|
@ -177,15 +143,15 @@ void GuiToolboxButtonCtrl::onRender(Point2I offset, const RectI& updateRect)
|
|||
{
|
||||
RectI r(offset, getExtent());
|
||||
if ( mDepressed || mStateOn )
|
||||
renderStateRect( mTextureLowered , r );
|
||||
renderStateRect( mLoweredBitmap , r );
|
||||
else if ( mMouseOver )
|
||||
renderStateRect( mTextureHover , r );
|
||||
renderStateRect( mHoverBitmap , r );
|
||||
}
|
||||
|
||||
// Now render the image
|
||||
if( mTextureNormal )
|
||||
if( mNormalBitmap )
|
||||
{
|
||||
renderButton( mTextureNormal, offset, updateRect );
|
||||
renderButton(mNormalBitmap, offset, updateRect );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -226,3 +192,7 @@ void GuiToolboxButtonCtrl::renderButton(GFXTexHandle &texture, Point2I &offset,
|
|||
renderChildControls( offset, updateRect);
|
||||
}
|
||||
}
|
||||
|
||||
DEF_IMAGEASSET_BINDS(GuiToolboxButtonCtrl, NormalBitmap);
|
||||
DEF_IMAGEASSET_BINDS(GuiToolboxButtonCtrl, LoweredBitmap);
|
||||
DEF_IMAGEASSET_BINDS(GuiToolboxButtonCtrl, HoverBitmap);
|
||||
|
|
|
|||
|
|
@ -30,23 +30,29 @@
|
|||
#include "gfx/gfxTextureManager.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
class GuiToolboxButtonCtrl : public GuiButtonCtrl
|
||||
{
|
||||
private:
|
||||
typedef GuiButtonCtrl Parent;
|
||||
|
||||
protected:
|
||||
StringTableEntry mNormalBitmapName;
|
||||
StringTableEntry mLoweredBitmapName;
|
||||
StringTableEntry mHoverBitmapName;
|
||||
|
||||
GFXTexHandle mTextureNormal;
|
||||
GFXTexHandle mTextureLowered;
|
||||
GFXTexHandle mTextureHover;
|
||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, NormalBitmap, onNormalImageChanged, GFXTexturePersistentSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiToolboxButtonCtrl, NormalBitmap);
|
||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, LoweredBitmap, onLoweredImageChanged, GFXTexturePersistentSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiToolboxButtonCtrl, LoweredBitmap);
|
||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, HoverBitmap, onHoverImageChanged, GFXTexturePersistentSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiToolboxButtonCtrl, HoverBitmap);
|
||||
|
||||
void renderButton(GFXTexHandle &texture, Point2I &offset, const RectI& updateRect);
|
||||
void renderStateRect( GFXTexHandle &texture, const RectI& rect );
|
||||
|
||||
void onNormalImageChanged() {}
|
||||
void onLoweredImageChanged() {}
|
||||
void onHoverImageChanged() {}
|
||||
|
||||
public:
|
||||
DECLARE_CONOBJECT(GuiToolboxButtonCtrl);
|
||||
GuiToolboxButtonCtrl();
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
Point2I barOffset(barStart, barTop);
|
||||
|
||||
// Draw the start of the bar...
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject ,RectI(barOffset, mProfile->mBitmapArrayRects[2].extent), mProfile->mBitmapArrayRects[2] );
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->getBitmapResource(),RectI(barOffset, mProfile->mBitmapArrayRects[2].extent), mProfile->mBitmapArrayRects[2] );
|
||||
|
||||
// Now draw the middle...
|
||||
barOffset.x += mProfile->mBitmapArrayRects[2].extent.x;
|
||||
|
|
@ -290,7 +290,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
foo.inset(1,0);
|
||||
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||
mProfile->mTextureObject,
|
||||
mProfile->getBitmapResource(),
|
||||
RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
|
||||
foo
|
||||
);
|
||||
|
|
@ -299,7 +299,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
// And the end
|
||||
barOffset.x += barMiddleSize;
|
||||
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mTextureObject, RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->getBitmapResource(), RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
||||
mProfile->mBitmapArrayRects[4]);
|
||||
|
||||
GFX->getDrawUtil()->setBitmapModulation((mMouseOver ? mProfile->mFontColorHL : mProfile->mFontColor));
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
|||
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||
mProfile->mTextureObject,
|
||||
mProfile->getBitmapResource(),
|
||||
RectI(offset, mProfile->mBitmapArrayRects[idx].extent),
|
||||
mProfile->mBitmapArrayRects[idx]
|
||||
);
|
||||
|
|
@ -225,7 +225,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
|||
|
||||
// Draw the start of the bar...
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||
mProfile->mTextureObject,
|
||||
mProfile->getBitmapResource(),
|
||||
RectI(barOffset, mProfile->mBitmapArrayRects[2].extent),
|
||||
mProfile->mBitmapArrayRects[2]
|
||||
);
|
||||
|
|
@ -242,7 +242,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
|||
foo.inset(1,0);
|
||||
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||
mProfile->mTextureObject,
|
||||
mProfile->getBitmapResource(),
|
||||
RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
|
||||
foo
|
||||
);
|
||||
|
|
@ -252,7 +252,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
|||
barOffset.x += barMiddleSize;
|
||||
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||
mProfile->mTextureObject,
|
||||
mProfile->getBitmapResource(),
|
||||
RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
||||
mProfile->mBitmapArrayRects[4]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ bool GuiScrollCtrl::onWake()
|
|||
if (! Parent::onWake())
|
||||
return false;
|
||||
|
||||
mTextureObject = mProfile->mTextureObject;
|
||||
mTextureObject = mProfile->getBitmapResource();
|
||||
if (mTextureObject && (mProfile->constructBitmapArray() >= BmpStates * BmpCount))
|
||||
{
|
||||
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||
|
|
|
|||
|
|
@ -678,7 +678,6 @@ bool GuiWindowCtrl::onWake()
|
|||
return false;
|
||||
|
||||
//get the texture for the close, minimize, and maximize buttons
|
||||
mTextureObject = mProfile->mTextureObject;
|
||||
bool result = mProfile->constructBitmapArray() >= NumBitmaps;
|
||||
if( !result )
|
||||
{
|
||||
|
|
@ -686,6 +685,8 @@ bool GuiWindowCtrl::onWake()
|
|||
return false;
|
||||
}
|
||||
|
||||
mTextureObject = mProfile->getBitmapResource();
|
||||
|
||||
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||
S32 buttonHeight = mBitmapBounds[BmpStates * BmpClose].extent.y;
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ bool guiAnimBitmapCtrl::ptSetFrameRanges(void *object, const char *index, const
|
|||
|
||||
void guiAnimBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||
{
|
||||
if (mTextureObject)
|
||||
if (mBitmap)
|
||||
{
|
||||
if (mFrameTime->getElapsedMs() > 1000 / mFramesPerSec) //fps to msfp conversion
|
||||
{
|
||||
|
|
@ -271,7 +271,7 @@ void guiAnimBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
||||
|
||||
GFXTextureObject* texture = mTextureObject;
|
||||
GFXTextureObject* texture = mBitmap;
|
||||
|
||||
Point2I modifiedSRC = Point2I(texture->mBitmapSize.x / mAnimTexTiling.x, texture->mBitmapSize.y / mAnimTexTiling.y);
|
||||
RectI srcRegion;
|
||||
|
|
@ -285,7 +285,7 @@ void guiAnimBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
GFX->getDrawUtil()->drawBitmapStretchSR(texture, updateRect, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||
}
|
||||
|
||||
if (mProfile->mBorder || !mTextureObject)
|
||||
if (mProfile->mBorder || !mBitmap)
|
||||
{
|
||||
RectI rect(offset, getExtent());
|
||||
GFX->getDrawUtil()->drawRect(rect, mProfile->mBorderColor);
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ void GuiBitmapBarCtrl::initPersistFields()
|
|||
|
||||
void GuiBitmapBarCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||
{
|
||||
if (mTextureObject)
|
||||
if (mBitmap)
|
||||
{
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
||||
F32 pct = (mPercent / 100.0);
|
||||
GFXTextureObject* texture = mTextureObject;
|
||||
GFXTextureObject* texture = mBitmap;
|
||||
Point2I modifiedSRC;
|
||||
modifiedSRC.x = mVertical ? (F32)texture->mBitmapSize.x : (F32)(texture->mBitmapSize.x*pct);
|
||||
modifiedSRC.y = mVertical ? (F32)(texture->mBitmapSize.y*pct) : (F32)texture->mBitmapSize.y;
|
||||
|
|
@ -91,7 +91,7 @@ void GuiBitmapBarCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
GFX->getDrawUtil()->drawBitmapStretchSR(texture, destRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||
}
|
||||
|
||||
if (mProfile->mBorder || !mTextureObject)
|
||||
if (mProfile->mBorder || !mBitmap)
|
||||
{
|
||||
RectI rect(offset, getExtent());
|
||||
GFX->getDrawUtil()->drawRect(rect, mProfile->mBorderColor);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ bool GuiBitmapBorderCtrl::onWake()
|
|||
|
||||
//get the texture for the close, minimize, and maximize buttons
|
||||
mBitmapBounds = NULL;
|
||||
mTextureObject = mProfile->mTextureObject;
|
||||
mTextureObject = mProfile->getBitmapResource();
|
||||
if( mProfile->constructBitmapArray() >= NumBitmaps )
|
||||
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "gui/core/guiControl.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
/// Renders a bitmap.
|
||||
class GuiBitmapCtrl : public GuiControl
|
||||
{
|
||||
|
|
@ -38,11 +39,9 @@ class GuiBitmapCtrl : public GuiControl
|
|||
|
||||
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
|
||||
/// from a file but rather set explicitly on the control.
|
||||
String mBitmapName;
|
||||
|
||||
/// Loaded texture.
|
||||
GFXTexHandle mTextureObject;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiBitmapCtrl, Bitmap);
|
||||
|
||||
Point2I mStartPoint;
|
||||
ColorI mColor;
|
||||
|
||||
|
|
@ -52,6 +51,8 @@ class GuiBitmapCtrl : public GuiControl
|
|||
static bool setBitmapName( void *object, const char *index, const char *data );
|
||||
static const char *getBitmapName( void *obj, const char *data );
|
||||
|
||||
void onImageChanged() {}
|
||||
|
||||
public:
|
||||
|
||||
GuiBitmapCtrl();
|
||||
|
|
@ -72,7 +73,7 @@ class GuiBitmapCtrl : public GuiControl
|
|||
|
||||
DECLARE_CONOBJECT( GuiBitmapCtrl );
|
||||
DECLARE_CATEGORY( "Gui Images" );
|
||||
DECLARE_DESCRIPTION( "A control that displays a single, static image from a file.\n"
|
||||
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." );
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -129,14 +129,14 @@ void GuiGameListMenuCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
|
||||
// render the row bitmap
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));
|
||||
drawUtil->drawBitmapStretchSR(profile->mBitmap, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));
|
||||
|
||||
// render the row icon if it has one
|
||||
if ((iconIndex != NO_ICON) && profileHasIcons && (!profile->getBitmapArrayRect((U32)iconIndex).extent.isZero()))
|
||||
{
|
||||
iconIndex += Profile::TEX_FIRST_ICON;
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
|
||||
drawUtil->drawBitmapStretchSR(profile->mBitmap, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
|
||||
}
|
||||
|
||||
// render the row text
|
||||
|
|
@ -204,7 +204,7 @@ void GuiGameListMenuCtrl::onRenderListOption(Row* row, Point2I currentOffset)
|
|||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||
|
||||
drawer->clearBitmapModulation();
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
|
||||
// render the right arrow
|
||||
bool arrowOnR = (isRowSelected || isRowHighlighted) && (row->mWrapOptions || (row->mSelectedOption < row->mOptions.size() - 1));
|
||||
|
|
@ -213,7 +213,7 @@ void GuiGameListMenuCtrl::onRenderListOption(Row* row, Point2I currentOffset)
|
|||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||
|
||||
drawer->clearBitmapModulation();
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
}
|
||||
|
||||
// get the appropriate font color
|
||||
|
|
@ -1631,8 +1631,7 @@ bool GuiGameListMenuProfile::onAdd()
|
|||
|
||||
// We can't call enforceConstraints() here because incRefCount initializes
|
||||
// some of the things to enforce. Do a basic sanity check here instead.
|
||||
|
||||
if( !mBitmapName || !dStrlen(mBitmapName) )
|
||||
if(mBitmapAsset.isNull())
|
||||
{
|
||||
Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void GuiGameListOptionsCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||
|
||||
drawer->clearBitmapModulation();
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
|
||||
// render the right arrow
|
||||
bool arrowOnR = (isRowSelected || isRowHighlighted) && (myRow->mWrapOptions || (myRow->mSelectedOption < myRow->mOptions.size() - 1));
|
||||
|
|
@ -120,7 +120,7 @@ void GuiGameListOptionsCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||
|
||||
drawer->clearBitmapModulation();
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||
}
|
||||
|
||||
// get the appropriate font color
|
||||
|
|
|
|||
|
|
@ -45,12 +45,14 @@ ConsoleDocClass( GuiMaterialCtrl,
|
|||
GuiMaterialCtrl::GuiMaterialCtrl()
|
||||
: mMaterialInst( NULL )
|
||||
{
|
||||
INIT_MATERIALASSET(Material);
|
||||
}
|
||||
|
||||
void GuiMaterialCtrl::initPersistFields()
|
||||
{
|
||||
addGroup( "Material" );
|
||||
addProtectedField( "materialName", TypeStringFilename, Offset( mMaterialName, GuiMaterialCtrl ), &GuiMaterialCtrl::_setMaterial, &defaultProtectedGetFn, "" );
|
||||
INITPERSISTFIELD_MATERIALASSET(Material, GuiMaterialCtrl, "");
|
||||
addProtectedField( "materialName", TypeStringFilename, Offset( mMaterialName, GuiMaterialCtrl ), &GuiMaterialCtrl::_setMaterialData, &defaultProtectedGetFn, "", AbstractClassRep::FIELD_HideInInspectors );
|
||||
endGroup( "Material" );
|
||||
|
||||
Parent::initPersistFields();
|
||||
|
|
@ -62,7 +64,7 @@ bool GuiMaterialCtrl::onWake()
|
|||
return false;
|
||||
|
||||
setActive( true );
|
||||
setMaterial( mMaterialName );
|
||||
setMaterial( getMaterial() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -85,10 +87,11 @@ bool GuiMaterialCtrl::_setMaterial( void *object, const char *index, const char
|
|||
bool GuiMaterialCtrl::setMaterial( const String &materialName )
|
||||
{
|
||||
SAFE_DELETE( mMaterialInst );
|
||||
mMaterialName = materialName;
|
||||
|
||||
if ( mMaterialName.isNotEmpty() && isAwake() )
|
||||
mMaterialInst = MATMGR->createMatInstance( mMaterialName, getGFXVertexFormat<GFXVertexPCT>() );
|
||||
_setMaterial(StringTable->insert(materialName.c_str()));
|
||||
|
||||
if ( getMaterial() != StringTable->EmptyString() && isAwake() )
|
||||
mMaterialInst = MATMGR->createMatInstance( getMaterial(), getGFXVertexFormat<GFXVertexPCT>() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#include "gui/containers/guiContainer.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/MaterialAsset.h"
|
||||
|
||||
class BaseMatInstance;
|
||||
|
||||
|
||||
|
|
@ -38,7 +40,8 @@ private:
|
|||
|
||||
protected:
|
||||
|
||||
String mMaterialName;
|
||||
DECLARE_MATERIALASSET(GuiMaterialCtrl, Material);
|
||||
DECLARE_MATERIALASSET_SETGET(GuiMaterialCtrl, Material);
|
||||
|
||||
BaseMatInstance *mMaterialInst;
|
||||
|
||||
|
|
|
|||
|
|
@ -277,7 +277,10 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void)
|
|||
mRenderScrollInNA = false; // Added
|
||||
mBackgroundCancel = false; // Added
|
||||
mReverseTextList = false; // Added - Don't reverse text list if displaying up
|
||||
mBitmapName = StringTable->EmptyString(); // Added
|
||||
|
||||
INIT_IMAGEASSET_ARRAY(Bitmap, 0);
|
||||
INIT_IMAGEASSET_ARRAY(Bitmap, 1);
|
||||
|
||||
mBitmapBounds.set(16, 16); // Added
|
||||
mIdMax = -1;
|
||||
mBackground = NULL;
|
||||
|
|
@ -297,12 +300,24 @@ void GuiPopUpMenuCtrl::initPersistFields(void)
|
|||
addField("maxPopupHeight", TypeS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrl));
|
||||
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
|
||||
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));
|
||||
addField("bitmap", TypeFilename, Offset(mBitmapName, GuiPopUpMenuCtrl));
|
||||
|
||||
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiPopUpMenuCtrl), _setBitmaps, defaultProtectedGetFn, "");
|
||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiPopUpMenuCtrl), _setBitmaps, defaultProtectedGetFn, "");
|
||||
|
||||
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrl));
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
bool GuiPopUpMenuCtrl::_setBitmaps(void* obj, const char* index, const char* data)
|
||||
{
|
||||
bool ret = false;
|
||||
GuiPopUpMenuCtrl* object = static_cast<GuiPopUpMenuCtrl*>(obj);
|
||||
|
||||
object->setBitmap(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
DefineEngineMethod( GuiPopUpMenuCtrl, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
|
||||
{
|
||||
|
|
@ -459,7 +474,7 @@ bool GuiPopUpMenuCtrl::onWake()
|
|||
return false;
|
||||
|
||||
// Set the bitmap for the popup.
|
||||
setBitmap( mBitmapName );
|
||||
setBitmap(getBitmap(Normal));
|
||||
|
||||
// Now update the Form Control's bitmap array, and possibly the child's too
|
||||
mProfile->constructBitmapArray();
|
||||
|
|
@ -483,8 +498,6 @@ bool GuiPopUpMenuCtrl::onAdd()
|
|||
//------------------------------------------------------------------------------
|
||||
void GuiPopUpMenuCtrl::onSleep()
|
||||
{
|
||||
mTextureNormal = NULL; // Added
|
||||
mTextureDepressed = NULL; // Added
|
||||
Parent::onSleep();
|
||||
closePopUp(); // Tests in function.
|
||||
}
|
||||
|
|
@ -562,30 +575,30 @@ static S32 QSORT_CALLBACK idCompare(const void *a,const void *b)
|
|||
// Added
|
||||
void GuiPopUpMenuCtrl::setBitmap( const char *name )
|
||||
{
|
||||
mBitmapName = StringTable->insert( name );
|
||||
if ( !isAwake() )
|
||||
return;
|
||||
StringTableEntry bitmapName = StringTable->insert(name);
|
||||
|
||||
if ( *mBitmapName )
|
||||
if ( bitmapName != StringTable->EmptyString() )
|
||||
{
|
||||
char buffer[1024];
|
||||
char *p;
|
||||
dStrcpy(buffer, name, 1024);
|
||||
dStrcpy(buffer, bitmapName, 1024);
|
||||
p = buffer + dStrlen(buffer);
|
||||
S32 pLen = 1024 - dStrlen(buffer);
|
||||
|
||||
dStrcpy(p, "_n", pLen);
|
||||
mTextureNormal = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
|
||||
|
||||
_setBitmap((StringTableEntry)buffer, Normal);
|
||||
|
||||
dStrcpy(p, "_d", pLen);
|
||||
mTextureDepressed = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__) );
|
||||
if ( !mTextureDepressed )
|
||||
mTextureDepressed = mTextureNormal;
|
||||
_setBitmap((StringTableEntry)buffer, Depressed);
|
||||
|
||||
if ( !mBitmap[Depressed] )
|
||||
mBitmap[Depressed] = mBitmap[Normal];
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextureNormal = NULL;
|
||||
mTextureDepressed = NULL;
|
||||
_setBitmap(StringTable->EmptyString(), Normal);
|
||||
_setBitmap(StringTable->EmptyString(), Depressed);
|
||||
}
|
||||
setUpdate();
|
||||
}
|
||||
|
|
@ -879,17 +892,17 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureDepressed )
|
||||
if ( mBitmap[Depressed] )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureDepressed, rect );
|
||||
drawUtil->drawBitmapStretch( mBitmap[Depressed], rect );
|
||||
}
|
||||
else if ( mTextureNormal )
|
||||
else if ( mBitmap[Normal] )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->drawBitmapStretch( mBitmap[Normal], rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
|
|
@ -923,11 +936,11 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureNormal )
|
||||
if ( mBitmap[Normal] )
|
||||
{
|
||||
RectI rect( offset, mBitmapBounds );
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->drawBitmapStretch( mBitmap[Normal], rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
|
|
@ -953,11 +966,11 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureNormal )
|
||||
if ( mBitmap[Normal] )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->drawBitmapStretch( mBitmap[Normal], rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
#ifndef _GUISCROLLCTRL_H_
|
||||
#include "gui/containers/guiScrollCtrl.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
class GuiPopUpMenuCtrl;
|
||||
class GuiPopupTextListCtrl;
|
||||
|
||||
|
|
@ -115,15 +117,26 @@ protected:
|
|||
bool mMouseOver; // Added
|
||||
bool mRenderScrollInNA; // Added
|
||||
bool mReverseTextList; // Added - Should we reverse the text list if we display up?
|
||||
StringTableEntry mBitmapName; // Added
|
||||
|
||||
enum BitmapModes
|
||||
{
|
||||
Normal,
|
||||
Depressed,
|
||||
|
||||
NumBitmapModes = 2
|
||||
};
|
||||
|
||||
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes);
|
||||
DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrl, Bitmap);
|
||||
|
||||
Point2I mBitmapBounds; // Added
|
||||
GFXTexHandle mTextureNormal; // Added
|
||||
GFXTexHandle mTextureDepressed; // Added
|
||||
S32 mIdMax;
|
||||
|
||||
virtual void addChildren();
|
||||
virtual void repositionPopup();
|
||||
|
||||
static bool _setBitmaps(void* obj, const char* index, const char* data);
|
||||
|
||||
public:
|
||||
GuiPopUpMenuCtrl(void);
|
||||
~GuiPopUpMenuCtrl();
|
||||
|
|
|
|||
|
|
@ -328,7 +328,10 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void)
|
|||
mRenderScrollInNA = false; // Added
|
||||
mBackgroundCancel = false; // Added
|
||||
mReverseTextList = false; // Added - Don't reverse text list if displaying up
|
||||
mBitmapName = StringTable->EmptyString(); // Added
|
||||
|
||||
INIT_IMAGEASSET_ARRAY(Bitmap, Normal);
|
||||
INIT_IMAGEASSET_ARRAY(Bitmap, Depressed);
|
||||
|
||||
mBitmapBounds.set(16, 16); // Added
|
||||
mHotTrackItems = false;
|
||||
mIdMax = -1;
|
||||
|
|
@ -349,7 +352,10 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
|
|||
addField("maxPopupHeight", TypeS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrlEx), "Length of menu when it extends");
|
||||
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
|
||||
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
|
||||
addField("bitmap", TypeFilename, Offset(mBitmapName, GuiPopUpMenuCtrlEx), "File name of bitmap to use");
|
||||
|
||||
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "File name of bitmap to use");
|
||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "Name of bitmap asset to use");
|
||||
|
||||
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrlEx), "Boundaries of bitmap displayed");
|
||||
addField("hotTrackCallback", TypeBool, Offset(mHotTrackItems, GuiPopUpMenuCtrlEx),
|
||||
"Whether to provide a 'onHotTrackItem' callback when a list item is hovered over");
|
||||
|
|
@ -357,6 +363,15 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
|
|||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
bool GuiPopUpMenuCtrlEx::_setBitmaps(void* obj, const char* index, const char* data)
|
||||
{
|
||||
bool ret = false;
|
||||
GuiPopUpMenuCtrlEx* object = static_cast<GuiPopUpMenuCtrlEx*>(obj);
|
||||
|
||||
object->setBitmap(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ConsoleDocFragment _GuiPopUpMenuCtrlExAdd(
|
||||
"@brief Adds an entry to the list\n\n"
|
||||
|
|
@ -664,7 +679,7 @@ bool GuiPopUpMenuCtrlEx::onWake()
|
|||
return false;
|
||||
|
||||
// Set the bitmap for the popup.
|
||||
setBitmap( mBitmapName );
|
||||
setBitmap(getBitmap(Normal));
|
||||
|
||||
// Now update the Form Control's bitmap array, and possibly the child's too
|
||||
mProfile->constructBitmapArray();
|
||||
|
|
@ -688,8 +703,6 @@ bool GuiPopUpMenuCtrlEx::onAdd()
|
|||
//------------------------------------------------------------------------------
|
||||
void GuiPopUpMenuCtrlEx::onSleep()
|
||||
{
|
||||
mTextureNormal = NULL; // Added
|
||||
mTextureDepressed = NULL; // Added
|
||||
Parent::onSleep();
|
||||
closePopUp(); // Tests in function.
|
||||
}
|
||||
|
|
@ -767,30 +780,30 @@ static S32 QSORT_CALLBACK idCompare(const void *a,const void *b)
|
|||
// Added
|
||||
void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
|
||||
{
|
||||
mBitmapName = StringTable->insert( name );
|
||||
if ( !isAwake() )
|
||||
return;
|
||||
StringTableEntry bitmapName = StringTable->insert(name);
|
||||
|
||||
if ( *mBitmapName )
|
||||
if (bitmapName != StringTable->EmptyString())
|
||||
{
|
||||
char buffer[1024];
|
||||
char *p;
|
||||
dStrcpy(buffer, name, 1024);
|
||||
char* p;
|
||||
dStrcpy(buffer, bitmapName, 1024);
|
||||
p = buffer + dStrlen(buffer);
|
||||
S32 pLen = 1024 - dStrlen(buffer);
|
||||
|
||||
dStrcpy(p, "_n", pLen);
|
||||
mTextureNormal = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
|
||||
|
||||
_setBitmap((StringTableEntry)buffer, Normal);
|
||||
|
||||
dStrcpy(p, "_d", pLen);
|
||||
mTextureDepressed = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__) );
|
||||
if ( !mTextureDepressed )
|
||||
mTextureDepressed = mTextureNormal;
|
||||
_setBitmap((StringTableEntry)buffer, Depressed);
|
||||
|
||||
if (!mBitmap[Depressed])
|
||||
mBitmap[Depressed] = mBitmap[Normal];
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextureNormal = NULL;
|
||||
mTextureDepressed = NULL;
|
||||
_setBitmap(StringTable->EmptyString(), Normal);
|
||||
_setBitmap(StringTable->EmptyString(), Depressed);
|
||||
}
|
||||
setUpdate();
|
||||
}
|
||||
|
|
@ -1061,17 +1074,17 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureDepressed )
|
||||
if ( mBitmap[Depressed] )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureDepressed, rect );
|
||||
drawUtil->drawBitmapStretch(mBitmap[Depressed], rect );
|
||||
}
|
||||
else if ( mTextureNormal )
|
||||
else if (mBitmap[Normal])
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
|
|
@ -1105,11 +1118,11 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureNormal )
|
||||
if (mBitmap[Normal])
|
||||
{
|
||||
RectI rect( offset, mBitmapBounds );
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
|
|
@ -1135,11 +1148,11 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureNormal )
|
||||
if (mBitmap[Normal])
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
class GuiPopUpMenuCtrlEx;
|
||||
class GuiPopupTextListCtrlEx;
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
class GuiPopUpBackgroundCtrlEx : public GuiControl
|
||||
{
|
||||
protected:
|
||||
|
|
@ -116,15 +118,27 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
|
|||
bool mRenderScrollInNA; // Added
|
||||
bool mReverseTextList; // Added - Should we reverse the text list if we display up?
|
||||
bool mHotTrackItems;
|
||||
StringTableEntry mBitmapName; // Added
|
||||
|
||||
enum BitmapModes
|
||||
{
|
||||
Normal,
|
||||
Depressed,
|
||||
|
||||
NumBitmapModes = 2
|
||||
};
|
||||
|
||||
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, GFXDefaultGUIProfile, NumBitmapModes);
|
||||
DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrlEx, Bitmap);
|
||||
|
||||
Point2I mBitmapBounds; // Added
|
||||
GFXTexHandle mTextureNormal; // Added
|
||||
GFXTexHandle mTextureDepressed; // Added
|
||||
|
||||
S32 mIdMax;
|
||||
|
||||
virtual void addChildren();
|
||||
virtual void repositionPopup();
|
||||
|
||||
static bool _setBitmaps(void* obj, const char* index, const char* data);
|
||||
|
||||
public:
|
||||
GuiPopUpMenuCtrlEx(void);
|
||||
~GuiPopUpMenuCtrlEx();
|
||||
|
|
|
|||
|
|
@ -427,9 +427,9 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
drawUtil->clearBitmapModulation();
|
||||
|
||||
//left border
|
||||
drawUtil->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]);
|
||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(), Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]);
|
||||
//right border
|
||||
drawUtil->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]);
|
||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(), Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]);
|
||||
|
||||
|
||||
//draw our center piece to our slider control's border and stretch it
|
||||
|
|
@ -443,11 +443,11 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
stretchRect = mBitmapBounds[SliderLineCenter];
|
||||
stretchRect.inset(1,0);
|
||||
|
||||
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, destRect, stretchRect);
|
||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), destRect, stretchRect);
|
||||
|
||||
//draw our control slider button
|
||||
thumb.point += pos;
|
||||
drawUtil->drawBitmapSR(mProfile->mTextureObject,Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]);
|
||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(),Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]);
|
||||
|
||||
}
|
||||
else if (getWidth() >= getHeight())
|
||||
|
|
|
|||
|
|
@ -151,6 +151,8 @@ GuiTextEditCtrl::GuiTextEditCtrl()
|
|||
mPasswordMask = StringTable->insert( "*" );
|
||||
#endif
|
||||
Sim::findObject( "InputDeniedSound", mDeniedSound );
|
||||
|
||||
mValidateCommand = "";
|
||||
}
|
||||
|
||||
GuiTextEditCtrl::~GuiTextEditCtrl()
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void GuiTextEditSliderBitmapCtrl::initPersistFields()
|
|||
addField("range", TypePoint2F, Offset(mRange, GuiTextEditSliderBitmapCtrl), "Maximum vertical and horizontal range to allow in the control.\n");
|
||||
addField("increment", TypeF32, Offset(mIncAmount, GuiTextEditSliderBitmapCtrl), "How far to increment the slider on each step.\n");
|
||||
addField("focusOnMouseWheel", TypeBool, Offset(mFocusOnMouseWheel, GuiTextEditSliderBitmapCtrl), "If true, the control will accept giving focus to the user when the mouse wheel is used.\n");
|
||||
addField("bitmap", TypeFilename,Offset(mBitmapName, GuiTextEditSliderBitmapCtrl), "Unused" );
|
||||
addField("bitmap", TypeFilename,Offset(mBitmapName, GuiTextEditSliderBitmapCtrl), "Unused", AbstractClassRep::FIELD_HideInInspectors );
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -425,14 +425,14 @@ void GuiTextEditSliderBitmapCtrl::onRender(Point2I offset, const RectI &updateRe
|
|||
{
|
||||
// This control needs 4 images in order to render correctly
|
||||
if(mTextAreaHit == ArrowUp)
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mTextureObject, RectI(arrowUpStart,arrowUpEnd), mProfile->mBitmapArrayRects[0] );
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mBitmap, RectI(arrowUpStart,arrowUpEnd), mProfile->mBitmapArrayRects[0] );
|
||||
else
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mTextureObject, RectI(arrowUpStart,arrowUpEnd), mProfile->mBitmapArrayRects[1] );
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mBitmap, RectI(arrowUpStart,arrowUpEnd), mProfile->mBitmapArrayRects[1] );
|
||||
|
||||
if(mTextAreaHit == ArrowDown)
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mTextureObject, RectI(arrowDownStart,arrowDownEnd), mProfile->mBitmapArrayRects[2] );
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mBitmap, RectI(arrowDownStart,arrowDownEnd), mProfile->mBitmapArrayRects[2] );
|
||||
else
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mTextureObject, RectI(arrowDownStart,arrowDownEnd), mProfile->mBitmapArrayRects[3] );
|
||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mBitmap, RectI(arrowDownStart,arrowDownEnd), mProfile->mBitmapArrayRects[3] );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -586,8 +586,8 @@ S32 GuiTreeViewCtrl::Item::getDisplayTextWidth(GFont *font)
|
|||
if( bufLen == 0 )
|
||||
return 0;
|
||||
|
||||
// Add space for the string terminator
|
||||
bufLen++;
|
||||
// Add space for the string terminator and marker
|
||||
bufLen += 2;
|
||||
|
||||
char *buf = (char*)txtAlloc.alloc(bufLen);
|
||||
getDisplayText(bufLen, buf);
|
||||
|
|
@ -3696,7 +3696,7 @@ void GuiTreeViewCtrl::onRenderCell(Point2I offset, Point2I cell, bool, bool )
|
|||
{
|
||||
drawRect.point.x -= mTabSize;
|
||||
if ( parent->mNext )
|
||||
drawer->drawBitmapSR( mProfile->mTextureObject, drawRect.point, mProfile->mBitmapArrayRects[BmpLine] );
|
||||
drawer->drawBitmapSR( mProfile->mBitmap, drawRect.point, mProfile->mBitmapArrayRects[BmpLine] );
|
||||
|
||||
parent = parent->mParent;
|
||||
}
|
||||
|
|
@ -3707,7 +3707,7 @@ void GuiTreeViewCtrl::onRenderCell(Point2I offset, Point2I cell, bool, bool )
|
|||
|
||||
// First, draw the rollover glow, if it's an inner node.
|
||||
if ( item->isParent() && item->mState.test( Item::MouseOverBmp ) )
|
||||
drawer->drawBitmapSR( mProfile->mTextureObject, drawRect.point, mProfile->mBitmapArrayRects[BmpGlow] );
|
||||
drawer->drawBitmapSR( mProfile->mBitmap, drawRect.point, mProfile->mBitmapArrayRects[BmpGlow] );
|
||||
|
||||
// Now, do we draw a treeview-selected item or an item dependent one?
|
||||
S32 newOffset = 0; // This is stored so we can render glow, then update render pos.
|
||||
|
|
@ -3752,7 +3752,7 @@ void GuiTreeViewCtrl::onRenderCell(Point2I offset, Point2I cell, bool, bool )
|
|||
if( ( bitmap >= 0 ) && ( bitmap < mProfile->mBitmapArrayRects.size() ) )
|
||||
{
|
||||
if( drawBitmap )
|
||||
drawer->drawBitmapSR( mProfile->mTextureObject, drawRect.point, mProfile->mBitmapArrayRects[bitmap] );
|
||||
drawer->drawBitmapSR( mProfile->getBitmapResource(), drawRect.point, mProfile->mBitmapArrayRects[bitmap] );
|
||||
newOffset = mProfile->mBitmapArrayRects[bitmap].extent.x;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,14 +173,14 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
|||
// Draw all corners first.
|
||||
|
||||
//top left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
|
||||
//top right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
|
||||
|
||||
//bottom left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
|
||||
//bottom right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
||||
bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
|
||||
bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
|
||||
mBitmapBounds[BorderBottomRight]);
|
||||
|
|
@ -198,7 +198,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
|||
stretchRect = mBitmapBounds[BorderTop];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//bottom line stretch
|
||||
destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomLeft].extent.x;
|
||||
destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x;
|
||||
|
|
@ -208,7 +208,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
|||
stretchRect = mBitmapBounds[BorderBottom];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//left line stretch
|
||||
destRect.point.x = bounds.point.x;
|
||||
destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
|
||||
|
|
@ -218,7 +218,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
|||
stretchRect = mBitmapBounds[BorderLeft];
|
||||
stretchRect.inset(0,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//right line stretch
|
||||
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x;
|
||||
destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
|
||||
|
|
@ -228,7 +228,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
|||
stretchRect = mBitmapBounds[BorderRight];
|
||||
stretchRect.inset(0,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
|
||||
// End drawing sides and top stretched borders
|
||||
break;
|
||||
|
|
@ -288,14 +288,14 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
|||
// Draw all corners first.
|
||||
|
||||
//top left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
//top right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
|
||||
//bottom left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
//bottom right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
||||
bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x,
|
||||
bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y),
|
||||
mBitmapBounds[borderBottomRight]);
|
||||
|
|
@ -313,7 +313,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
|||
stretchRect = mBitmapBounds[borderTop];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//bottom line stretch
|
||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x;
|
||||
destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x;
|
||||
|
|
@ -323,7 +323,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
|||
stretchRect = mBitmapBounds[borderBottom];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//left line stretch
|
||||
destRect.point.x = bounds.point.x;
|
||||
destRect.extent.x = mBitmapBounds[borderLeft].extent.x;
|
||||
|
|
@ -333,7 +333,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
|||
stretchRect = mBitmapBounds[borderLeft];
|
||||
stretchRect.inset(0,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//right line stretch
|
||||
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x;
|
||||
destRect.extent.x = mBitmapBounds[borderRight].extent.x;
|
||||
|
|
@ -343,7 +343,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
|||
stretchRect = mBitmapBounds[borderRight];
|
||||
stretchRect.inset(0,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//fill stretch
|
||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x;
|
||||
destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x;
|
||||
|
|
@ -353,7 +353,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
|||
stretchRect = mBitmapBounds[fill];
|
||||
stretchRect.inset(1,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
|
||||
// End drawing sides and top stretched borders
|
||||
}
|
||||
|
|
@ -388,14 +388,14 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
|||
// Draw all corners first.
|
||||
|
||||
//top left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
//top right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
|
||||
//bottom left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
//bottom right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
||||
bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x,
|
||||
bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y),
|
||||
mBitmapBounds[borderBottomRight]);
|
||||
|
|
@ -413,7 +413,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
|||
stretchRect = mBitmapBounds[borderTop];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//bottom line stretch
|
||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x;
|
||||
destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x;
|
||||
|
|
@ -423,7 +423,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
|||
stretchRect = mBitmapBounds[borderBottom];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//left line stretch
|
||||
destRect.point.x = bounds.point.x;
|
||||
destRect.extent.x = mBitmapBounds[borderLeft].extent.x;
|
||||
|
|
@ -433,7 +433,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
|||
stretchRect = mBitmapBounds[borderLeft];
|
||||
stretchRect.inset(0,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//left line stretch
|
||||
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x;
|
||||
destRect.extent.x = mBitmapBounds[borderRight].extent.x;
|
||||
|
|
@ -443,7 +443,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
|||
stretchRect = mBitmapBounds[borderRight];
|
||||
stretchRect.inset(0,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
//fill stretch
|
||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x;
|
||||
destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x;
|
||||
|
|
@ -453,7 +453,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
|||
stretchRect = mBitmapBounds[fill];
|
||||
stretchRect.inset(1,1);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
|
||||
// End drawing sides and top stretched borders
|
||||
}
|
||||
|
|
@ -484,9 +484,9 @@ void renderFixedBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier, Gu
|
|||
// Draw all corners first.
|
||||
|
||||
//left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
//right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||
|
||||
// End drawing corners
|
||||
|
||||
|
|
@ -501,7 +501,7 @@ void renderFixedBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier, Gu
|
|||
stretchRect = mBitmapBounds[fill];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
|
||||
// End drawing fill
|
||||
}
|
||||
|
|
@ -529,9 +529,9 @@ void renderFixedBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex, G
|
|||
// Draw all corners first.
|
||||
|
||||
//left border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
//right border
|
||||
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||
|
||||
// End drawing corners
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ void renderFixedBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex, G
|
|||
stretchRect = mBitmapBounds[fill];
|
||||
stretchRect.inset(1,0);
|
||||
//draw it
|
||||
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
||||
|
||||
// End drawing fill
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ GuiCursor::GuiCursor()
|
|||
mHotSpot.set(0,0);
|
||||
mRenderOffset.set(0.0f,0.0f);
|
||||
mExtent.set(1,1);
|
||||
mTextureObject = NULL;
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
}
|
||||
|
||||
GuiCursor::~GuiCursor()
|
||||
|
|
@ -90,7 +90,9 @@ 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.");
|
||||
addField("bitmapName", TypeFilename, Offset(mBitmapName, GuiCursor), "File name of the bitmap for the cursor.");
|
||||
|
||||
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.");
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
@ -111,24 +113,21 @@ void GuiCursor::onRemove()
|
|||
|
||||
void GuiCursor::render(const Point2I &pos)
|
||||
{
|
||||
if (!mTextureObject && mBitmapName && mBitmapName[0])
|
||||
if (mBitmap)
|
||||
{
|
||||
mTextureObject.set( mBitmapName, &GFXGuiCursorProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
if(!mTextureObject)
|
||||
return;
|
||||
mExtent.set(mTextureObject->getWidth(), mTextureObject->getHeight());
|
||||
mExtent.set(mBitmap->getWidth(), mBitmap->getHeight());
|
||||
}
|
||||
|
||||
// Render the cursor centered according to dimensions of texture
|
||||
S32 texWidth = mTextureObject.getWidth();
|
||||
S32 texHeight = mTextureObject.getHeight();
|
||||
S32 texWidth = mBitmap.getWidth();
|
||||
S32 texHeight = mBitmap.getHeight();
|
||||
|
||||
Point2I renderPos = pos;
|
||||
renderPos.x -= (S32)( texWidth * mRenderOffset.x );
|
||||
renderPos.y -= (S32)( texHeight * mRenderOffset.y );
|
||||
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmap(mTextureObject, renderPos);
|
||||
GFX->getDrawUtil()->drawBitmap(mBitmap, renderPos);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -180,33 +179,40 @@ StringTableEntry GuiControlProfile::sFontCacheDirectory = "";
|
|||
|
||||
void GuiControlProfile::setBitmapHandle(GFXTexHandle handle)
|
||||
{
|
||||
mTextureObject = handle;
|
||||
mBitmap = handle;
|
||||
|
||||
mBitmapName = StringTable->insert("texhandle");
|
||||
_setBitmap(StringTable->insert("texhandle"));
|
||||
}
|
||||
|
||||
bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, const char *data )
|
||||
{
|
||||
GuiControlProfile *profile = static_cast<GuiControlProfile*>( object );
|
||||
|
||||
profile->mBitmapName = StringTable->insert(data);
|
||||
profile->_setBitmap(StringTable->insert(data));
|
||||
|
||||
if ( !profile->isProperlyAdded() )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
if( profile->mLoadCount > 0 )
|
||||
{
|
||||
profile->mBitmapArrayRects.clear();
|
||||
profile->mTextureObject = NULL;
|
||||
profile->mBitmap = nullptr;
|
||||
|
||||
//verify the bitmap
|
||||
if (profile->mBitmapName && profile->mBitmapName[0] && dStricmp(profile->mBitmapName, "texhandle") != 0 &&
|
||||
!profile->mTextureObject.set( profile->mBitmapName, &GFXTexturePersistentProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__) ))
|
||||
Con::errorf("Failed to load profile bitmap (%s)",profile->mBitmapName);
|
||||
if (profile->getBitmap() != StringTable->EmptyString())
|
||||
{
|
||||
if (profile->mBitmapAsset.notNull() && profile->getBitmap() != StringTable->insert("texHandle"))
|
||||
{
|
||||
profile->mBitmap.set(profile->mBitmapAsset->getImagePath(), profile->mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
}
|
||||
|
||||
// If we've got a special border, make sure it's usable.
|
||||
//if( profile->mBorder == -1 || profile->mBorder == -2 )
|
||||
profile->constructBitmapArray();
|
||||
//verify the bitmap
|
||||
if (!profile->mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", profile->getName(), profile->getBitmap());
|
||||
|
||||
// If we've got a special border, make sure it's usable.
|
||||
//if( profile->mBorder == -1 || profile->mBorder == -2 )
|
||||
profile->constructBitmapArray();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -318,9 +324,8 @@ GuiControlProfile::GuiControlProfile(void) :
|
|||
mMouseOverSelected = false;
|
||||
|
||||
// bitmap members
|
||||
mBitmapName = NULL;
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
mUseBitmapArray = false;
|
||||
mTextureObject = NULL; // initialized in incLoadCount()
|
||||
|
||||
mChildrenProfileName = NULL;
|
||||
mChildrenProfile = NULL;
|
||||
|
|
@ -456,10 +461,20 @@ void GuiControlProfile::initPersistFields()
|
|||
endGroup( "Text" );
|
||||
|
||||
addGroup( "Misc" );
|
||||
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
||||
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiControlProfile),
|
||||
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
||||
"Texture to use for rendering control.");
|
||||
#else
|
||||
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiControlProfile),
|
||||
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
||||
"Texture to use for rendering control.", AbstractClassRep::FIELD_HideInInspectors);
|
||||
#endif
|
||||
|
||||
addProtectedField( "bitmap", TypeFilename, Offset(mBitmapName, GuiControlProfile),
|
||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiControlProfile),
|
||||
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
||||
"Texture to use for rendering control." );
|
||||
"Texture to use for rendering control.");
|
||||
|
||||
addField("hasBitmapArray", TypeBool, Offset(mUseBitmapArray, GuiControlProfile),
|
||||
"If true, 'bitmap' is an array of images." );
|
||||
|
||||
|
|
@ -565,20 +580,28 @@ S32 GuiControlProfile::constructBitmapArray()
|
|||
if(mBitmapArrayRects.size())
|
||||
return mBitmapArrayRects.size();
|
||||
|
||||
if( mTextureObject.isNull() )
|
||||
{
|
||||
if ( !mBitmapName || !mBitmapName[0] || !mTextureObject.set( mBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__) ))
|
||||
if( mBitmap.isNull() )
|
||||
{
|
||||
if (!_setBitmap(getBitmap()))
|
||||
return 0;
|
||||
|
||||
if (getBitmap() != StringTable->EmptyString() && mBitmapName != StringTable->insert("texhandle"))
|
||||
{
|
||||
mBitmap.set(getBitmap(), mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
}
|
||||
|
||||
if (getBitmap() == StringTable->EmptyString() || mBitmap.isNull())
|
||||
return 0;
|
||||
}
|
||||
|
||||
GBitmap *bmp = mTextureObject->getBitmap();
|
||||
GBitmap *bmp = mBitmap->getBitmap();
|
||||
|
||||
//get the separator color
|
||||
ColorI sepColor;
|
||||
if ( !bmp || !bmp->getColor( 0, 0, sepColor ) )
|
||||
{
|
||||
Con::errorf("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", mBitmapName, getName());
|
||||
AssertFatal( false, avar("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", mBitmapName, getName()));
|
||||
Con::errorf("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmap(), getName());
|
||||
AssertFatal( false, avar("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmap(), getName()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -654,12 +677,19 @@ void GuiControlProfile::incLoadCount()
|
|||
loadFont();
|
||||
|
||||
//
|
||||
if (getBitmap() != StringTable->EmptyString())
|
||||
{
|
||||
if (mBitmapAsset.notNull() && getBitmap() != StringTable->insert("texHandle"))
|
||||
{
|
||||
mBitmap.set(mBitmapAsset->getImagePath(), mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
}
|
||||
|
||||
if (mBitmapName && mBitmapName[0] && dStricmp(mBitmapName, "texhandle") != 0 &&
|
||||
!mTextureObject.set( mBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__) ))
|
||||
Con::errorf("Failed to load profile bitmap (%s)",mBitmapName);
|
||||
//verify the bitmap
|
||||
if (!mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", getName(), getBitmap());
|
||||
|
||||
constructBitmapArray();
|
||||
constructBitmapArray();
|
||||
}
|
||||
}
|
||||
|
||||
mLoadCount ++;
|
||||
|
|
@ -682,8 +712,9 @@ void GuiControlProfile::decLoadCount()
|
|||
getId(), getClassName(), getName(), getInternalName() );
|
||||
#endif
|
||||
|
||||
if( !mBitmapName || !mBitmapName[0] || dStricmp(mBitmapName, "texhandle") != 0 )
|
||||
mTextureObject = NULL;
|
||||
StringTableEntry bitmapName = getBitmap();
|
||||
if(bitmapName == StringTable->EmptyString() || bitmapName == StringTable->insert("texhandle"))
|
||||
mBitmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -707,6 +738,19 @@ DefineEngineMethod( GuiControlProfile, getStringWidth, S32, (const char* string)
|
|||
return object->mFont->getStrNWidth( string, dStrlen( string ) );
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiControlProfile, getBitmap, const char*, (), , "get name")
|
||||
{
|
||||
return object->getBitmap();
|
||||
}
|
||||
DefineEngineMethod(GuiControlProfile, getBitmapAsset, const char*, (), , "")
|
||||
{
|
||||
return object->mBitmapAssetId;
|
||||
}
|
||||
DefineEngineMethod(GuiControlProfile, setBitmap, bool, (const char* map), , "")
|
||||
{
|
||||
return object->_setBitmap(StringTable->insert(map));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TypeRectSpacingI
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "platform/input/event.h"
|
||||
|
|
@ -335,16 +336,20 @@ struct ControlSizing
|
|||
|
||||
};
|
||||
|
||||
GFX_DeclareTextureProfile(GFXGuiCursorProfile);
|
||||
GFX_DeclareTextureProfile(GFXDefaultGUIProfile);
|
||||
|
||||
class GuiCursor : public SimObject
|
||||
{
|
||||
private:
|
||||
typedef SimObject Parent;
|
||||
StringTableEntry mBitmapName;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiCursor, Bitmap, onImageChanged, GFXGuiCursorProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiCursor, Bitmap);
|
||||
|
||||
Point2I mHotSpot;
|
||||
Point2F mRenderOffset;
|
||||
Point2I mExtent;
|
||||
GFXTexHandle mTextureObject;
|
||||
|
||||
public:
|
||||
Point2I getHotSpot() { return mHotSpot; }
|
||||
|
|
@ -358,6 +363,8 @@ public:
|
|||
bool onAdd(void);
|
||||
void onRemove();
|
||||
void render(const Point2I &pos);
|
||||
|
||||
void onImageChanged() {}
|
||||
};
|
||||
|
||||
/// A GuiControlProfile is used by every GuiObject and is akin to a
|
||||
|
|
@ -441,9 +448,118 @@ public:
|
|||
Point2I mTextOffset; ///< Text offset for the control
|
||||
|
||||
// bitmap members
|
||||
StringTableEntry mBitmapName; ///< Bitmap file name for the bitmap of the control
|
||||
///< Bitmap for the bitmap of the control
|
||||
///
|
||||
public:
|
||||
GFXTexHandle mBitmap = NULL;
|
||||
StringTableEntry mBitmapName;
|
||||
StringTableEntry mBitmapAssetId;
|
||||
AssetPtr<ImageAsset> mBitmapAsset;
|
||||
GFXTextureProfile* mBitmapProfile = &GFXTexturePersistentSRGBProfile;
|
||||
public:
|
||||
const StringTableEntry getBitmapFile() const { return mBitmapName; }
|
||||
void setBitmapFile(const FileName& _in) { mBitmapName = StringTable->insert(_in.c_str()); }
|
||||
const AssetPtr<ImageAsset>& getBitmapAsset() const { return mBitmapAsset; }
|
||||
void setBitmapAsset(const AssetPtr<ImageAsset>& _in) { mBitmapAsset = _in; }
|
||||
|
||||
bool _setBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mBitmapAssetId != _in || mBitmapName != _in)
|
||||
{
|
||||
if (mBitmapAsset.notNull())
|
||||
{
|
||||
mBitmapAsset->getChangedSignal().remove(this, &GuiControlProfile::onBitmapChanged);
|
||||
}
|
||||
if (_in == StringTable->EmptyString())
|
||||
{
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
mBitmapAssetId = StringTable->EmptyString();
|
||||
mBitmapAsset = NULL;
|
||||
mBitmap.free();
|
||||
mBitmap = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (_in[0] == '$' || _in[0] == '#')
|
||||
{
|
||||
mBitmapName = _in;
|
||||
mBitmapAssetId = StringTable->EmptyString();
|
||||
mBitmapAsset = NULL;
|
||||
mBitmap.free();
|
||||
mBitmap = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (AssetDatabase.isDeclaredAsset(_in))
|
||||
{
|
||||
mBitmapAssetId = _in;
|
||||
|
||||
U32 assetState = ImageAsset::getAssetById(mBitmapAssetId, &mBitmapAsset);
|
||||
|
||||
if (ImageAsset::Ok == assetState)
|
||||
{
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTableEntry assetId = ImageAsset::getAssetIdByFilename(_in);
|
||||
if (assetId != StringTable->EmptyString())
|
||||
{
|
||||
mBitmapAssetId = assetId;
|
||||
if (ImageAsset::getAssetById(mBitmapAssetId, &mBitmapAsset) == ImageAsset::Ok)
|
||||
{
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mBitmapName = _in;
|
||||
mBitmapAssetId = StringTable->EmptyString();
|
||||
mBitmapAsset = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getBitmap() != StringTable->EmptyString() && mBitmapName != StringTable->insert("texhandle"))
|
||||
{
|
||||
if (mBitmapAsset.notNull())
|
||||
{
|
||||
mBitmapAsset->getChangedSignal().notify(this, &GuiControlProfile::onBitmapChanged);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mBitmap.free();
|
||||
mBitmap = NULL;
|
||||
}
|
||||
|
||||
if (getBitmap() != StringTable->EmptyString() && mBitmapAsset.notNull() && mBitmapAsset->getStatus() != ImageAsset::Ok)
|
||||
{
|
||||
Con::errorf("%s(%s)::_set%s() - image asset failure \"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, ImageAsset::getAssetErrstrn(mBitmapAsset->getStatus()).c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const StringTableEntry getBitmap() const
|
||||
{
|
||||
if (mBitmapAsset && (mBitmapAsset->getImageFileName() != StringTable->EmptyString()))
|
||||
return Platform::makeRelativePathName(mBitmapAsset->getImagePath(), Platform::getMainDotCsDir());
|
||||
else if (mBitmapAssetId != StringTable->EmptyString())
|
||||
return mBitmapAssetId;
|
||||
else if (mBitmapName != StringTable->EmptyString())
|
||||
return StringTable->insert(Platform::makeRelativePathName(mBitmapName, Platform::getMainDotCsDir()));
|
||||
else
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
GFXTexHandle getBitmapResource()
|
||||
{
|
||||
return mBitmap;
|
||||
}
|
||||
DECLARE_IMAGEASSET_SETGET(GuiControlProfile, Bitmap);
|
||||
|
||||
void onBitmapChanged() {}
|
||||
|
||||
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering
|
||||
GFXTexHandle mTextureObject;
|
||||
Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
|
||||
|
||||
// sound members
|
||||
|
|
@ -518,7 +634,4 @@ DefineEnumType( GuiAlignmentType );
|
|||
typedef FontCharset GuiFontCharset;
|
||||
DefineEnumType( GuiFontCharset );
|
||||
|
||||
GFX_DeclareTextureProfile(GFXGuiCursorProfile);
|
||||
GFX_DeclareTextureProfile(GFXDefaultGUIProfile);
|
||||
|
||||
#endif //_GUITYPES_H
|
||||
|
|
|
|||
|
|
@ -161,7 +161,9 @@ public:
|
|||
|
||||
void setObjectField( const char *fieldName, const char *data );
|
||||
|
||||
static GuiInspector* findByObject( SimObject *obj );
|
||||
static GuiInspector* findByObject( SimObject *obj );
|
||||
|
||||
void refresh();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -181,8 +183,6 @@ protected:
|
|||
SimObjectPtr<GuiInspectorField> mHLField;
|
||||
String mGroupFilters;
|
||||
bool mShowCustomFields;
|
||||
|
||||
void refresh();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -220,8 +220,8 @@ GuiControl* GuiInspectorTypeMaterialName::construct(const char* command)
|
|||
mBrowseButton->setField( "Command", szBuffer );
|
||||
|
||||
//temporary static button name
|
||||
char bitmapName[512] = "tools/materialEditor/gui/change-material-btn";
|
||||
mBrowseButton->setBitmap( bitmapName );
|
||||
char bitmapName[512] = "ToolsModule:change_material_btn_n_image";
|
||||
mBrowseButton->setBitmap( StringTable->insert(bitmapName) );
|
||||
|
||||
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
|
||||
mBrowseButton->registerObject();
|
||||
|
|
@ -326,8 +326,8 @@ GuiControl* GuiInspectorTypeTerrainMaterialName::construct(const char* command)
|
|||
mBrowseButton->setField( "Command", szBuffer );
|
||||
|
||||
//temporary static button name
|
||||
char bitmapName[512] = "tools/gui/images/layers-btn";
|
||||
mBrowseButton->setBitmap( bitmapName );
|
||||
char bitmapName[512] = "ToolsModule:tools/gui/images/layers_btn_n_image";
|
||||
mBrowseButton->setBitmap(StringTable->insert(bitmapName) );
|
||||
|
||||
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
|
||||
mBrowseButton->registerObject();
|
||||
|
|
@ -804,8 +804,8 @@ GuiControl* GuiInspectorTypeShapeFilename::constructEditControl()
|
|||
dSprintf(szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.open(%d.getText());", retCtrl->getId());
|
||||
mShapeEdButton->setField("Command", szBuffer);
|
||||
|
||||
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
||||
mShapeEdButton->setBitmap(bitmapName);
|
||||
char bitmapName[512] = "ToolsModule:shape_editor_n_image";
|
||||
mShapeEdButton->setBitmap(StringTable->insert(bitmapName));
|
||||
|
||||
mShapeEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||
mShapeEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||
|
|
@ -956,8 +956,8 @@ GuiControl* GuiInspectorTypeRectUV::constructEditControl()
|
|||
mBrowseButton->setField( "Command", szBuffer );
|
||||
|
||||
//temporary static button name
|
||||
char bitmapName[512] = "tools/gui/images/uv-editor-btn";
|
||||
mBrowseButton->setBitmap( bitmapName );
|
||||
char bitmapName[512] = "ToolsModule:uv_editor_btn_n_image";
|
||||
mBrowseButton->setBitmap(StringTable->insert(bitmapName) );
|
||||
|
||||
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
|
||||
mBrowseButton->registerObject();
|
||||
|
|
@ -1544,7 +1544,7 @@ GuiControl* GuiInspectorTypeBitMask32Helper::constructEditControl()
|
|||
mButton->setField( "Command", szBuffer );
|
||||
mButton->setField( "buttonType", "ToggleButton" );
|
||||
mButton->setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorButtonProfile" );
|
||||
mButton->setBitmap( "tools/gui/images/arrowBtn" );
|
||||
mButton->setBitmap(StringTable->insert("ToolsModule:arrowBtn_image") );
|
||||
mButton->setStateOn( true );
|
||||
mButton->setExtent( 16, 16 );
|
||||
mButton->registerObject();
|
||||
|
|
|
|||
|
|
@ -1347,7 +1347,7 @@ void GuiMenuBar::onRender(Point2I offset, const RectI &updateRect)
|
|||
bitmapstart.y = mMenuList[i].bounds.point.y + (mMenuList[i].bounds.extent.y - rect.extent.y) / 2;
|
||||
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapSR(mProfile->mTextureObject, offset + bitmapstart, rect);
|
||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(), offset + bitmapstart, rect);
|
||||
|
||||
// Should we also draw the text?
|
||||
if (!mMenuList[i].drawBitmapOnly)
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool s
|
|||
Point2I bitPos = Point2I(offset.x + mCellSize.y / 2, offset.y + mCellSize.y / 2);
|
||||
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, bitPos + off, rect);
|
||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->getBitmapResource(), bitPos + off, rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@
|
|||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "collision/concretePolyList.h"
|
||||
|
||||
#include "T3D/assets/ShapeAsset.h"
|
||||
#include "T3D/assets/ShapeAnimationAsset.h"
|
||||
|
||||
#ifdef TORQUE_COLLADA
|
||||
#include "collision/optimizedPolyList.h"
|
||||
#include "ts/collada/colladaUtils.h"
|
||||
|
|
@ -65,6 +68,7 @@ GuiShapeEdPreview::GuiShapeEdPreview()
|
|||
mZoomSpeed ( 1.0f ),
|
||||
mGridDimension( 30, 30 ),
|
||||
mModel( NULL ),
|
||||
mModelName(StringTable->EmptyString()),
|
||||
mRenderGhost( false ),
|
||||
mRenderNodes( false ),
|
||||
mRenderBounds( false ),
|
||||
|
|
@ -349,6 +353,8 @@ bool GuiShapeEdPreview::setObjectModel(const char* modelName)
|
|||
mThreads.clear();
|
||||
mActiveThread = -1;
|
||||
|
||||
ResourceManager::get().getChangedSignal().remove(this, &GuiShapeEdPreview::_onResourceChanged);
|
||||
|
||||
if (modelName && modelName[0])
|
||||
{
|
||||
Resource<TSShape> model = ResourceManager::get().load( modelName );
|
||||
|
|
@ -382,11 +388,57 @@ bool GuiShapeEdPreview::setObjectModel(const char* modelName)
|
|||
|
||||
// the first time recording
|
||||
mLastRenderTime = Platform::getVirtualMilliseconds();
|
||||
|
||||
mModelName = StringTable->insert(modelName);
|
||||
|
||||
//Now to reflect changes when the model file is changed.
|
||||
ResourceManager::get().getChangedSignal().notify(this, &GuiShapeEdPreview::_onResourceChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
mModelName = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GuiShapeEdPreview::setObjectShapeAsset(const char* assetId)
|
||||
{
|
||||
SAFE_DELETE(mModel);
|
||||
unmountAll();
|
||||
mThreads.clear();
|
||||
mActiveThread = -1;
|
||||
|
||||
StringTableEntry modelName = StringTable->EmptyString();
|
||||
if (AssetDatabase.isDeclaredAsset(assetId))
|
||||
{
|
||||
StringTableEntry id = StringTable->insert(assetId);
|
||||
StringTableEntry assetType = AssetDatabase.getAssetType(id);
|
||||
if (assetType == StringTable->insert("ShapeAsset"))
|
||||
{
|
||||
ShapeAsset* asset = AssetDatabase.acquireAsset<ShapeAsset>(id);
|
||||
modelName = asset->getShapeFilePath();
|
||||
AssetDatabase.releaseAsset(id);
|
||||
}
|
||||
else if (assetType == StringTable->insert("ShapeAnimationAsset"))
|
||||
{
|
||||
ShapeAnimationAsset* asset = AssetDatabase.acquireAsset<ShapeAnimationAsset>(id);
|
||||
modelName = asset->getAnimationPath();
|
||||
AssetDatabase.releaseAsset(id);
|
||||
}
|
||||
}
|
||||
|
||||
return setObjectModel(modelName);
|
||||
}
|
||||
|
||||
void GuiShapeEdPreview::_onResourceChanged(const Torque::Path& path)
|
||||
{
|
||||
if (path != Torque::Path(mModelName))
|
||||
return;
|
||||
|
||||
setObjectModel(path.getFullPath());
|
||||
}
|
||||
|
||||
void GuiShapeEdPreview::addThread()
|
||||
{
|
||||
if ( mModel )
|
||||
|
|
@ -1697,6 +1749,14 @@ DefineEngineMethod( GuiShapeEdPreview, setModel, bool, ( const char* shapePath )
|
|||
return object->setObjectModel( shapePath );
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiShapeEdPreview, setShapeAsset, bool, (const char* shapeAsset), ,
|
||||
"Sets the model to be displayed in this control\n\n"
|
||||
"@param shapeName Name of the model to display.\n"
|
||||
"@return True if the model was loaded successfully, false otherwise.\n")
|
||||
{
|
||||
return object->setObjectShapeAsset(shapeAsset);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiShapeEdPreview, fitToShape, void, (),,
|
||||
"Adjust the camera position and zoom to fit the shape within the view.\n\n" )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ protected:
|
|||
bool mRenderColMeshes;
|
||||
bool mRenderMounts;
|
||||
TSShapeInstance* mModel;
|
||||
StringTableEntry mModelName;
|
||||
|
||||
LightInfo* mFakeSun;
|
||||
EulerF mSunRot;
|
||||
|
|
@ -198,6 +199,9 @@ public:
|
|||
|
||||
void setCurrentDetail(S32 dl);
|
||||
bool setObjectModel(const char * modelName);
|
||||
bool setObjectShapeAsset(const char* assetId);
|
||||
|
||||
void _onResourceChanged(const Torque::Path& path);
|
||||
|
||||
/// @name Threads
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ bool GuiInspectorDynamicField::onAdd()
|
|||
mParent->getId() );
|
||||
|
||||
// FIXME Hardcoded image
|
||||
mDeleteButton->setField( "Bitmap", "tools/gui/images/iconDelete" );
|
||||
mDeleteButton->setField( "Bitmap", "ToolsModule:iconDelete_image" );
|
||||
mDeleteButton->setField( "Text", "X" );
|
||||
mDeleteButton->setField( "Command", szBuffer );
|
||||
mDeleteButton->setSizing( horizResizeLeft, vertResizeCenter );
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ bool GuiInspectorDynamicGroup::createContent()
|
|||
addFieldBtn->setControlProfile( dynamic_cast<GuiControlProfile*>(profilePtr) );
|
||||
|
||||
// FIXME Hardcoded image
|
||||
addFieldBtn->setBitmap("tools/gui/images/iconAdd.png");
|
||||
addFieldBtn->setBitmap(StringTable->insert("ToolsModule:iconAdd_image"));
|
||||
|
||||
char commandBuf[64];
|
||||
dSprintf(commandBuf, 64, "%d.addDynamicField();", this->getId());
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "gui/editor/inspector/variableInspector.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "T3D/assets/ShapeAsset.h"
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
#include "T3D/assets/MaterialAsset.h"
|
||||
|
||||
GuiVariableInspector::GuiVariableInspector() : mAutoUpdate(true)
|
||||
{
|
||||
|
|
@ -180,12 +183,12 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c
|
|||
fieldTypeMask = TypePoint3F;
|
||||
else if (newField.mFieldTypeName == StringTable->insert("vector2"))
|
||||
fieldTypeMask = TypePoint2F;
|
||||
//else if (fieldType == StringTable->insert("material"))
|
||||
// fieldTypeMask = TypeMaterialName;
|
||||
else if (newField.mFieldTypeName == StringTable->insert("material"))
|
||||
fieldTypeMask = TypeMaterialAssetId;
|
||||
else if (newField.mFieldTypeName == StringTable->insert("image"))
|
||||
fieldTypeMask = TypeImageFilename;
|
||||
fieldTypeMask = TypeImageAssetId;
|
||||
else if (newField.mFieldTypeName == StringTable->insert("shape"))
|
||||
fieldTypeMask = TypeShapeFilename;
|
||||
fieldTypeMask = TypeShapeAssetId;
|
||||
else if (newField.mFieldTypeName == StringTable->insert("bool"))
|
||||
fieldTypeMask = TypeBool;
|
||||
else if (newField.mFieldTypeName == StringTable->insert("object"))
|
||||
|
|
|
|||
|
|
@ -65,11 +65,12 @@ ConsoleDocClass( GuiChunkedBitmapCtrl,
|
|||
|
||||
void GuiChunkedBitmapCtrl::initPersistFields()
|
||||
{
|
||||
addGroup("GuiChunkedBitmapCtrl");
|
||||
addField( "bitmap", TypeFilename, Offset( mBitmapName, 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\"");
|
||||
addField( "tile", TypeBool, Offset( mTile, GuiChunkedBitmapCtrl ), "This is no longer in use");
|
||||
addGroup("GuiChunkedBitmapCtrl");
|
||||
INITPERSISTFIELD_IMAGEASSET(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\"");
|
||||
addField( "tile", TypeBool, Offset( mTile, GuiChunkedBitmapCtrl ), "This is no longer in use", AbstractClassRep::FIELD_HideInInspectors);
|
||||
endGroup("GuiChunkedBitmapCtrl");
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -86,7 +87,8 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename
|
|||
|
||||
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
|
||||
{
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
|
||||
mUseVariable = false;
|
||||
mTile = false;
|
||||
}
|
||||
|
|
@ -97,7 +99,8 @@ void GuiChunkedBitmapCtrl::setBitmap(const char *name)
|
|||
if(awake)
|
||||
onSleep();
|
||||
|
||||
mBitmapName = StringTable->insert(name);
|
||||
_setBitmap(StringTable->insert(name));
|
||||
|
||||
if(awake)
|
||||
onWake();
|
||||
setUpdate();
|
||||
|
|
@ -108,14 +111,14 @@ bool GuiChunkedBitmapCtrl::onWake()
|
|||
if(!Parent::onWake())
|
||||
return false;
|
||||
|
||||
if( !mTexHandle
|
||||
if( !mBitmap
|
||||
&& ( ( mBitmapName && mBitmapName[ 0 ] )
|
||||
|| ( mUseVariable && mConsoleVariable && mConsoleVariable[ 0 ] ) ) )
|
||||
{
|
||||
if ( mUseVariable )
|
||||
mTexHandle.set( Con::getVariable( mConsoleVariable ), &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
|
||||
mBitmap.set( Con::getVariable( mConsoleVariable ), &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
|
||||
else
|
||||
mTexHandle.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
|
||||
mBitmap.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -123,7 +126,6 @@ bool GuiChunkedBitmapCtrl::onWake()
|
|||
|
||||
void GuiChunkedBitmapCtrl::onSleep()
|
||||
{
|
||||
mTexHandle = NULL;
|
||||
Parent::onSleep();
|
||||
}
|
||||
|
||||
|
|
@ -164,10 +166,10 @@ void GuiChunkedBitmapCtrl::renderRegion(const Point2I &offset, const Point2I &ex
|
|||
void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||
{
|
||||
|
||||
if( mTexHandle )
|
||||
if( mBitmap )
|
||||
{
|
||||
RectI boundsRect( offset, getExtent());
|
||||
GFX->getDrawUtil()->drawBitmapStretch( mTexHandle, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear );
|
||||
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear );
|
||||
}
|
||||
|
||||
renderChildControls(offset, updateRect);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
class GuiChunkedBitmapCtrl : public GuiControl
|
||||
{
|
||||
private:
|
||||
|
|
@ -14,8 +16,10 @@ private:
|
|||
void renderRegion(const Point2I &offset, const Point2I &extent);
|
||||
|
||||
protected:
|
||||
StringTableEntry mBitmapName;
|
||||
GFXTexHandle mTexHandle;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiChunkedBitmapCtrl, Bitmap);
|
||||
|
||||
bool mUseVariable;
|
||||
bool mTile;
|
||||
|
||||
|
|
@ -34,4 +38,6 @@ public:
|
|||
void setBitmap(const char *name);
|
||||
|
||||
void onRender(Point2I offset, const RectI &updateRect);
|
||||
};
|
||||
|
||||
void onImageChanged() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -114,14 +114,14 @@ public:
|
|||
}
|
||||
|
||||
ColorI color(255,255,255,alpha);
|
||||
if (mTextureObject)
|
||||
if (mBitmap)
|
||||
{
|
||||
GFX->getDrawUtil()->setBitmapModulation(color);
|
||||
|
||||
if(mWrap)
|
||||
{
|
||||
|
||||
GFXTextureObject* texture = mTextureObject;
|
||||
GFXTextureObject* texture = mBitmap;
|
||||
RectI srcRegion;
|
||||
RectI dstRegion;
|
||||
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
|
||||
|
|
@ -144,11 +144,11 @@ public:
|
|||
else
|
||||
{
|
||||
RectI rect(offset, getExtent());
|
||||
GFX->getDrawUtil()->drawBitmapStretch(mTextureObject, rect);
|
||||
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect);
|
||||
}
|
||||
}
|
||||
|
||||
if (mProfile->mBorder || !mTextureObject)
|
||||
if (mProfile->mBorder || !mBitmap)
|
||||
{
|
||||
RectI rect(offset.x, offset.y, getExtent().x, getExtent().y);
|
||||
ColorI borderCol(mProfile->mBorderColor);
|
||||
|
|
|
|||
|
|
@ -119,24 +119,21 @@ ConsoleDocClass( GuiProgressBitmapCtrl,
|
|||
|
||||
GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
|
||||
: mProgress( 0.f ),
|
||||
mBitmapName( StringTable->EmptyString() ),
|
||||
mUseVariable( false ),
|
||||
mTile( false ),
|
||||
mNumberOfBitmaps(0),
|
||||
mDim(0)
|
||||
{
|
||||
INIT_IMAGEASSET(Bitmap);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GuiProgressBitmapCtrl::initPersistFields()
|
||||
{
|
||||
addProtectedField( "bitmap", TypeFilename, Offset( mBitmapName, GuiProgressBitmapCtrl ),
|
||||
_setBitmap, defaultProtectedGetFn,
|
||||
"~Path to the bitmap file to use for rendering the progress bar.\n\n"
|
||||
INITPERSISTFIELD_IMAGEASSET(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."
|
||||
);
|
||||
"set in which case the bitmap from the profile is used.");
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -149,7 +146,8 @@ void GuiProgressBitmapCtrl::setBitmap( const char* name )
|
|||
if( awake )
|
||||
onSleep();
|
||||
|
||||
mBitmapName = StringTable->insert( name );
|
||||
_setBitmap(StringTable->insert(name));
|
||||
|
||||
if( awake )
|
||||
onWake();
|
||||
|
||||
|
|
@ -222,14 +220,14 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
//drawing stretch bitmap
|
||||
RectI progressRect = ctrlRect;
|
||||
progressRect.extent.x = width;
|
||||
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[0]);
|
||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[0]);
|
||||
}
|
||||
}
|
||||
else if(mNumberOfBitmaps >= 3)
|
||||
{
|
||||
//drawing left-end bitmap
|
||||
RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
|
||||
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectLeft, mProfile->mBitmapArrayRects[0]);
|
||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectLeft, mProfile->mBitmapArrayRects[0]);
|
||||
|
||||
//draw the progress with image
|
||||
S32 width = (S32)((F32)(getWidth()) * mProgress);
|
||||
|
|
@ -241,11 +239,11 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
progressRect.extent.x = (width - mDim - mDim);
|
||||
if (progressRect.extent.x < 0)
|
||||
progressRect.extent.x = 0;
|
||||
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[1]);
|
||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[1]);
|
||||
|
||||
//drawing right-end bitmap
|
||||
RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
|
||||
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectRight, mProfile->mBitmapArrayRects[2]);
|
||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectRight, mProfile->mBitmapArrayRects[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "gui/controls/guiTextCtrl.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
//FIXME: WTH is this derived from GuiTextCtrl?? should be a GuiControl
|
||||
|
||||
|
|
@ -45,7 +46,10 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
|
|||
protected:
|
||||
|
||||
F32 mProgress;
|
||||
StringTableEntry mBitmapName;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiProgressBitmapCtrl, Bitmap);
|
||||
|
||||
bool mUseVariable;
|
||||
bool mTile;
|
||||
S32 mNumberOfBitmaps;
|
||||
|
|
@ -57,6 +61,8 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
|
|||
return false;
|
||||
}
|
||||
|
||||
void onImageChanged() {}
|
||||
|
||||
public:
|
||||
|
||||
GuiProgressBitmapCtrl();
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ void GuiTheoraCtrl::setFile( const String& filename )
|
|||
|
||||
void GuiTheoraCtrl::play()
|
||||
{
|
||||
if( mFilename.isEmpty() )
|
||||
if( mFilename == StringTable->EmptyString() )
|
||||
return;
|
||||
|
||||
if( !mTheoraTexture.isPlaying() )
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class GuiTheoraCtrl : public GuiControl
|
|||
protected:
|
||||
|
||||
/// The Theora file we should play.
|
||||
String mFilename;
|
||||
StringTableEntry mFilename;
|
||||
|
||||
/// Theora video player backend.
|
||||
TheoraTexture mTheoraTexture;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ GuiConvexEditorCtrl::GuiConvexEditorCtrl()
|
|||
mCtrlDown( false ),
|
||||
mGridSnap(false)
|
||||
{
|
||||
mMaterialName = StringTable->insert("Grid512_OrangeLines_Mat");
|
||||
mMaterialName = StringTable->insert("Prototyping:WallOrange");
|
||||
}
|
||||
|
||||
GuiConvexEditorCtrl::~GuiConvexEditorCtrl()
|
||||
|
|
@ -115,7 +115,7 @@ void GuiConvexEditorCtrl::onRemove()
|
|||
void GuiConvexEditorCtrl::initPersistFields()
|
||||
{
|
||||
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiConvexEditorCtrl ) );
|
||||
addField( "materialName", TypeString, Offset(mMaterialName, GuiConvexEditorCtrl) );
|
||||
addField( "materialName", TypeMaterialAssetId, Offset(mMaterialName, GuiConvexEditorCtrl) );
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -249,13 +249,13 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
|
||||
//Set the texture to a representatory one so we know what's what
|
||||
if (isTrigger)
|
||||
proxyShape->mMaterialName = "TriggerProxyMaterial";
|
||||
proxyShape->mMaterialName = "ToolsModule:TriggerProxyMaterial";
|
||||
else if (isPortal)
|
||||
proxyShape->mMaterialName = "PortalProxyMaterial";
|
||||
proxyShape->mMaterialName = "ToolsModule:PortalProxyMaterial";
|
||||
else if (isZone)
|
||||
proxyShape->mMaterialName = "ZoneProxyMaterial";
|
||||
proxyShape->mMaterialName = "ToolsModule:ZoneProxyMaterial";
|
||||
else if (isOccluder)
|
||||
proxyShape->mMaterialName = "OccluderProxyMaterial";
|
||||
proxyShape->mMaterialName = "ToolsModule:OccluderProxyMaterial";
|
||||
|
||||
proxyShape->_updateMaterial();
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ void GuiConvexEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event)
|
|||
|
||||
setupShape( newShape );
|
||||
|
||||
newShape->setField("material", mConvexSEL->getMaterialName());
|
||||
newShape->_setMaterial(mConvexSEL->getMaterial());
|
||||
|
||||
submitUndo( CreateShape, newShape );
|
||||
|
||||
|
|
@ -1459,8 +1459,8 @@ bool GuiConvexEditorCtrl::isShapeValid( ConvexShape *shape )
|
|||
|
||||
void GuiConvexEditorCtrl::setupShape( ConvexShape *shape )
|
||||
{
|
||||
shape->setField( "material", mMaterialName );
|
||||
shape->registerObject();
|
||||
shape->_setMaterial(mMaterialName);
|
||||
updateShape( shape );
|
||||
|
||||
Scene* scene = Scene::getRootScene();
|
||||
|
|
@ -1910,11 +1910,11 @@ const char* GuiConvexEditorCtrl::getSelectedFaceMaterial()
|
|||
|
||||
if (mConvexSEL->mSurfaceUVs[mFaceSEL].matID == 0)
|
||||
{
|
||||
return mConvexSEL->mMaterialName;
|
||||
return mConvexSEL->getMaterial();
|
||||
}
|
||||
else
|
||||
{
|
||||
return mConvexSEL->mSurfaceTextures[mConvexSEL->mSurfaceUVs[mFaceSEL].matID - 1].materialName;
|
||||
return mConvexSEL->mSurfaceTextures[mConvexSEL->mSurfaceUVs[mFaceSEL].matID - 1].getMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1978,7 +1978,7 @@ void GuiConvexEditorCtrl::setSelectedFaceMaterial(const char* materialName)
|
|||
{
|
||||
for (U32 i = 0; i < mConvexSEL->mSurfaceTextures.size(); i++)
|
||||
{
|
||||
if (!String::compare(mConvexSEL->mSurfaceTextures[i].materialName, materialName))
|
||||
if (!String::compare(mConvexSEL->mSurfaceTextures[i].getMaterial(), materialName))
|
||||
{
|
||||
//found a match
|
||||
mConvexSEL->mSurfaceUVs[mFaceSEL].matID = i + 1;
|
||||
|
|
@ -1990,7 +1990,7 @@ void GuiConvexEditorCtrl::setSelectedFaceMaterial(const char* materialName)
|
|||
{
|
||||
//add a new one
|
||||
ConvexShape::surfaceMaterial newMat;
|
||||
newMat.materialName = materialName;
|
||||
newMat._setMaterial(materialName);
|
||||
|
||||
mConvexSEL->mSurfaceTextures.push_back(newMat);
|
||||
|
||||
|
|
@ -2284,9 +2284,10 @@ ConvexEditorTool::EventResult ConvexEditorCreateTool::on3DMouseDown( const Gui3D
|
|||
|
||||
mNewConvex->setTransform( objMat );
|
||||
|
||||
mNewConvex->setField( "material", Parent::mEditor->mMaterialName );
|
||||
|
||||
mNewConvex->registerObject();
|
||||
|
||||
mNewConvex->_setMaterial(Parent::mEditor->mMaterialName);
|
||||
|
||||
mPlaneSizes.set( 0.1f, 0.1f, 0.1f );
|
||||
mNewConvex->resizePlanes( mPlaneSizes );
|
||||
mEditor->updateShape( mNewConvex );
|
||||
|
|
@ -2509,7 +2510,7 @@ ConvexShape* ConvexEditorCreateTool::extrudeShapeFromFace( ConvexShape *inShape,
|
|||
}
|
||||
|
||||
//newShape->setField( "material", Parent::mEditor->mMaterialName );
|
||||
newShape->setField("material", inShape->getMaterialName());
|
||||
newShape->_setMaterial(inShape->getMaterial());
|
||||
|
||||
newShape->registerObject();
|
||||
mEditor->updateShape( newShape );
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ ConsoleDocClass( GuiMissionAreaCtrl,
|
|||
|
||||
GuiMissionAreaCtrl::GuiMissionAreaCtrl()
|
||||
{
|
||||
mHandleBitmap = StringTable->EmptyString();
|
||||
mHandleTexture = NULL;
|
||||
INIT_IMAGEASSET(HandleBitmap);
|
||||
|
||||
mHandleTextureSize = Point2I::Zero;
|
||||
mHandleTextureHalfSize = Point2F::Zero;
|
||||
|
||||
|
|
@ -89,8 +89,7 @@ void GuiMissionAreaCtrl::initPersistFields()
|
|||
{
|
||||
addField( "squareBitmap", TypeBool, Offset(mSquareBitmap, GuiMissionAreaCtrl));
|
||||
|
||||
addField( "handleBitmap", TypeFilename, Offset( mHandleBitmap, GuiMissionAreaCtrl ),
|
||||
"Bitmap file for the mission area handles.\n");
|
||||
INITPERSISTFIELD_IMAGEASSET(HandleBitmap, GuiMissionAreaCtrl, "Bitmap for the mission area handles.\n");
|
||||
|
||||
addField( "missionBoundsColor", TypeColorI, Offset(mMissionBoundsColor, GuiMissionAreaCtrl));
|
||||
addField( "cameraColor", TypeColorI, Offset(mCameraColor, GuiMissionAreaCtrl));
|
||||
|
|
@ -114,15 +113,13 @@ bool GuiMissionAreaCtrl::onAdd()
|
|||
desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
|
||||
mBlendStateBlock = GFX->createStateBlock( desc );
|
||||
|
||||
if (*mHandleBitmap)
|
||||
if (!mHandleBitmap.isNull())
|
||||
{
|
||||
mHandleTexture = GFXTexHandle( mHandleBitmap, &GFXTexturePersistentSRGBProfile, avar("%s() - mHandleTexture (line %d)", __FUNCTION__, __LINE__) );
|
||||
mHandleTextureSize = Point2I( mHandleTexture->getWidth(), mHandleTexture->getHeight() );
|
||||
mHandleTextureSize = Point2I(mHandleBitmap->getWidth(), mHandleBitmap->getHeight() );
|
||||
mHandleTextureHalfSize = Point2F(mHandleTextureSize.x, mHandleTextureSize.y) * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
mHandleTexture = NULL;
|
||||
mHandleTextureSize = Point2I::Zero;
|
||||
mHandleTextureHalfSize = Point2F::Zero;
|
||||
}
|
||||
|
|
@ -159,7 +156,7 @@ bool GuiMissionAreaCtrl::onWake()
|
|||
|
||||
void GuiMissionAreaCtrl::onSleep()
|
||||
{
|
||||
mTextureObject = NULL;
|
||||
mBitmap = NULL;
|
||||
mMissionArea = 0;
|
||||
mTerrainBlock = 0;
|
||||
|
||||
|
|
@ -420,7 +417,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(mHandleTexture, pnt);
|
||||
GFX->getDrawUtil()->drawBitmap(mHandleBitmap, pnt);
|
||||
}
|
||||
|
||||
void GuiMissionAreaCtrl::drawHandles(RectI & box)
|
||||
|
|
@ -604,7 +601,7 @@ void GuiMissionAreaCtrl::onRender(Point2I offset, const RectI & updateRect)
|
|||
|
||||
GFXDrawUtil *drawer = GFX->getDrawUtil();
|
||||
drawer->clearBitmapModulation();
|
||||
drawer->drawBitmapStretch(mTextureObject, rect, GFXBitmapFlip_Y, GFXTextureFilterLinear, false);
|
||||
drawer->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_Y, GFXTextureFilterLinear, false);
|
||||
|
||||
GFX->setStateBlock(mSolidStateBlock);
|
||||
drawer->clearBitmapModulation();
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@ protected:
|
|||
GFXStateBlockRef mBlendStateBlock;
|
||||
GFXStateBlockRef mSolidStateBlock;
|
||||
|
||||
StringTableEntry mHandleBitmap;
|
||||
GFXTexHandle mHandleTexture;
|
||||
DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, onHandleBitmapChanged, GFXTexturePersistentSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(GuiMissionAreaCtrl, HandleBitmap);
|
||||
|
||||
Point2I mHandleTextureSize;
|
||||
Point2F mHandleTextureHalfSize;
|
||||
|
||||
|
|
@ -109,6 +110,8 @@ protected:
|
|||
bool testWithinHandle(const Point2I & testPoint, S32 handleX, S32 handleY);
|
||||
S32 getHitHandles(const Point2I & mousePnt, const RectI & box);
|
||||
|
||||
void onHandleBitmapChanged() {}
|
||||
|
||||
public:
|
||||
GuiMissionAreaCtrl();
|
||||
virtual ~GuiMissionAreaCtrl();
|
||||
|
|
|
|||
|
|
@ -1807,9 +1807,11 @@ WorldEditor::WorldEditor()
|
|||
mRenderPopupBackground = true;
|
||||
mPopupBackgroundColor.set(100,100,100);
|
||||
mPopupTextColor.set(255,255,0);
|
||||
mSelectHandle = StringTable->insert("tools/worldEditor/images/SelectHandle");
|
||||
mDefaultHandle = StringTable->insert("tools/worldEditor/images/DefaultHandle");
|
||||
mLockedHandle = StringTable->insert("tools/worldEditor/images/LockedHandle");
|
||||
|
||||
mSelectHandleAssetId = StringTable->insert("ToolsModule:SelectHandle");
|
||||
mDefaultHandleAssetId = StringTable->insert("ToolsModule:DefaultHandle");
|
||||
mLockedHandleAssetId = StringTable->insert("ToolsModule:LockedHandle");
|
||||
|
||||
mObjectTextColor.set(255,255,255);
|
||||
mObjectsUseBoxCenter = true;
|
||||
|
||||
|
|
@ -1894,9 +1896,9 @@ bool WorldEditor::onAdd()
|
|||
// create the default class entry
|
||||
mDefaultClassEntry.mName = 0;
|
||||
mDefaultClassEntry.mIgnoreCollision = false;
|
||||
mDefaultClassEntry.mDefaultHandle = GFXTexHandle(mDefaultHandle, &GFXStaticTextureSRGBProfile, avar("%s() - mDefaultClassEntry.mDefaultHandle (line %d)", __FUNCTION__, __LINE__));
|
||||
mDefaultClassEntry.mSelectHandle = GFXTexHandle(mSelectHandle, &GFXStaticTextureSRGBProfile, avar("%s() - mDefaultClassEntry.mSelectHandle (line %d)", __FUNCTION__, __LINE__));
|
||||
mDefaultClassEntry.mLockedHandle = GFXTexHandle(mLockedHandle, &GFXStaticTextureSRGBProfile, avar("%s() - mDefaultClassEntry.mLockedHandle (line %d)", __FUNCTION__, __LINE__));
|
||||
mDefaultClassEntry.mDefaultHandle = mDefaultHandle;
|
||||
mDefaultClassEntry.mSelectHandle = mSelectHandle;
|
||||
mDefaultClassEntry.mLockedHandle = mLockedHandle;
|
||||
|
||||
if(!(mDefaultClassEntry.mDefaultHandle && mDefaultClassEntry.mSelectHandle && mDefaultClassEntry.mLockedHandle))
|
||||
return false;
|
||||
|
|
@ -2826,9 +2828,10 @@ void WorldEditor::initPersistFields()
|
|||
addField( "renderObjText", TypeBool, Offset(mRenderObjText, WorldEditor) );
|
||||
addField( "renderObjHandle", TypeBool, Offset(mRenderObjHandle, WorldEditor) );
|
||||
addField( "renderSelectionBox", TypeBool, Offset(mRenderSelectionBox, WorldEditor) );
|
||||
addField( "selectHandle", TypeFilename, Offset(mSelectHandle, WorldEditor) );
|
||||
addField( "defaultHandle", TypeFilename, Offset(mDefaultHandle, WorldEditor) );
|
||||
addField( "lockedHandle", TypeFilename, Offset(mLockedHandle, WorldEditor) );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(SelectHandle, WorldEditor, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(DefaultHandle, WorldEditor, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(LockedHandle, WorldEditor, "");
|
||||
|
||||
endGroup( "Rendering" );
|
||||
|
||||
|
|
|
|||
|
|
@ -327,9 +327,14 @@ class WorldEditor : public EditTSCtrl
|
|||
bool mRenderPopupBackground;
|
||||
ColorI mPopupBackgroundColor;
|
||||
ColorI mPopupTextColor;
|
||||
StringTableEntry mSelectHandle;
|
||||
StringTableEntry mDefaultHandle;
|
||||
StringTableEntry mLockedHandle;
|
||||
|
||||
DECLARE_IMAGEASSET(WorldEditor, SelectHandle, onSelectHandleChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(WorldEditor, SelectHandle);
|
||||
DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, onDefaultHandleChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(WorldEditor, DefaultHandle);
|
||||
DECLARE_IMAGEASSET(WorldEditor, LockedHandle, onLockedHandleChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_IMAGEASSET_SETGET(WorldEditor, LockedHandle);
|
||||
|
||||
ColorI mObjectTextColor;
|
||||
bool mObjectsUseBoxCenter;
|
||||
ColorI mObjSelectColor;
|
||||
|
|
@ -420,6 +425,10 @@ class WorldEditor : public EditTSCtrl
|
|||
|
||||
void setEditorTool(EditorTool*);
|
||||
EditorTool* getActiveEditorTool() { return mActiveEditorTool; }
|
||||
|
||||
void onSelectHandleChanged() {}
|
||||
void onDefaultHandleChanged() {}
|
||||
void onLockedHandleChanged() {}
|
||||
};
|
||||
|
||||
typedef WorldEditor::DropType WorldEditorDropType;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue