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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue