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:
Jeff Hutchinson 2021-08-13 20:14:39 -04:00
commit 717c7acca9
2266 changed files with 48780 additions and 26034 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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"

View file

@ -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." );
};

View file

@ -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;

View file

@ -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

View file

@ -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;
}

View file

@ -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;

View file

@ -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?

View file

@ -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();

View file

@ -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?

View file

@ -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();

View file

@ -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())

View file

@ -151,6 +151,8 @@ GuiTextEditCtrl::GuiTextEditCtrl()
mPasswordMask = StringTable->insert( "*" );
#endif
Sim::findObject( "InputDeniedSound", mDeniedSound );
mValidateCommand = "";
}
GuiTextEditCtrl::~GuiTextEditCtrl()

View file

@ -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] );
}
}

View file

@ -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;
}