mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
guiControlProfile
This commit is contained in:
parent
b75d5b70c6
commit
32c6330b72
16 changed files with 91 additions and 189 deletions
|
|
@ -173,14 +173,14 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
|||
// Draw all corners first.
|
||||
|
||||
//top left border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
|
||||
//top right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
|
||||
|
||||
//bottom left border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
|
||||
//bottom right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
||||
drawer->drawBitmapSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
//top right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
|
||||
//bottom left border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
//bottom right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
||||
drawer->drawBitmapSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||
//top right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||
|
||||
//bottom left border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||
//bottom right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
||||
drawer->drawBitmapSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
//right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),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->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||
//right border
|
||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||
drawer->drawBitmapSR(profile->getBitmap(),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->getBitmapResource(),destRect,stretchRect);
|
||||
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||
|
||||
// End drawing fill
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ void GuiControlProfile::setBitmapHandle(GFXTexHandle handle)
|
|||
{
|
||||
mBitmap = handle;
|
||||
|
||||
_setBitmap(StringTable->insert("texhandle"));
|
||||
mBitmapName = "texhandle";
|
||||
}
|
||||
|
||||
bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, const char *data )
|
||||
|
|
@ -196,16 +196,17 @@ bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, con
|
|||
profile->mBitmapArrayRects.clear();
|
||||
profile->mBitmap = nullptr;
|
||||
|
||||
if (profile->getBitmap() != StringTable->EmptyString())
|
||||
if (profile->mBitmapName != StringTable->EmptyString())
|
||||
{
|
||||
if (profile->mBitmapAsset.notNull() && profile->getBitmap() != StringTable->insert("texHandle"))
|
||||
if (profile->mBitmapAsset.notNull() && profile->mBitmapName != StringTable->insert("texHandle"))
|
||||
{
|
||||
profile->mBitmap.set(profile->mBitmapAsset->getImageFile(), profile->mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
profile->mBitmap = profile->getBitmap();
|
||||
profile->mBitmapName = profile->mBitmapAsset->getImageFile();
|
||||
}
|
||||
|
||||
//verify the bitmap
|
||||
if (!profile->mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", profile->getName(), profile->getBitmap());
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", profile->getName(), profile->getBitmapAsset().getAssetId());
|
||||
|
||||
// If we've got a special border, make sure it's usable.
|
||||
//if( profile->mBorder == -1 || profile->mBorder == -2 )
|
||||
|
|
@ -271,7 +272,9 @@ GuiControlProfile::GuiControlProfile(void) :
|
|||
mMouseOverSelected = false;
|
||||
|
||||
// bitmap members
|
||||
INIT_ASSET(Bitmap);
|
||||
mBitmap = NULL;
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
|
||||
mUseBitmapArray = false;
|
||||
|
||||
mChildrenProfileName = NULL;
|
||||
|
|
@ -438,7 +441,7 @@ void GuiControlProfile::initPersistFields()
|
|||
"Texture to use for rendering control.", AbstractClassRep::FIELD_HideInInspectors);
|
||||
#endif
|
||||
|
||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiControlProfile),
|
||||
addProtectedField("bitmapAsset", TypeImageAssetPtrRefactor, Offset(mBitmapAsset, GuiControlProfile),
|
||||
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
||||
"Texture to use for rendering control.");
|
||||
|
||||
|
|
@ -546,15 +549,12 @@ S32 GuiControlProfile::constructBitmapArray()
|
|||
|
||||
if( mBitmap.isNull() )
|
||||
{
|
||||
if (!_setBitmap(getBitmap()))
|
||||
return 0;
|
||||
|
||||
if (getBitmap() != StringTable->EmptyString() && mBitmapName != StringTable->insert("texhandle"))
|
||||
if (mBitmapAsset.notNull() && mBitmapName != StringTable->insert("texhandle"))
|
||||
{
|
||||
mBitmap.set(getBitmap(), mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
mBitmap = getBitmap();
|
||||
}
|
||||
|
||||
if (getBitmap() == StringTable->EmptyString() || mBitmap.isNull())
|
||||
if (mBitmapAsset.isNull() || mBitmap.isNull())
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -564,8 +564,8 @@ S32 GuiControlProfile::constructBitmapArray()
|
|||
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!", getBitmap(), getName());
|
||||
AssertFatal( false, avar("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmap(), getName()));
|
||||
Con::errorf("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmapAsset().getAssetId(), getName());
|
||||
AssertFatal( false, avar("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmapAsset().getAssetId(), getName()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -640,20 +640,16 @@ void GuiControlProfile::incLoadCount()
|
|||
if( mFont == NULL )
|
||||
loadFont();
|
||||
|
||||
//
|
||||
if (getBitmap() != StringTable->EmptyString())
|
||||
if (mBitmapAsset.notNull() && mBitmapName != StringTable->insert("texHandle"))
|
||||
{
|
||||
if (mBitmapAsset.notNull() && getBitmap() != StringTable->insert("texHandle"))
|
||||
{
|
||||
mBitmap.set(mBitmapAsset->getImageFile(), mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
}
|
||||
|
||||
//verify the bitmap
|
||||
if (!mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", getName(), getBitmap());
|
||||
|
||||
constructBitmapArray();
|
||||
mBitmap = getBitmap();
|
||||
}
|
||||
|
||||
//verify the bitmap
|
||||
if (!mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", getName(), getBitmapAsset().getAssetId());
|
||||
|
||||
constructBitmapArray();
|
||||
}
|
||||
|
||||
mLoadCount ++;
|
||||
|
|
@ -676,7 +672,7 @@ void GuiControlProfile::decLoadCount()
|
|||
getId(), getClassName(), getName(), getInternalName() );
|
||||
#endif
|
||||
|
||||
StringTableEntry bitmapName = getBitmap();
|
||||
StringTableEntry bitmapName = getBitmapAsset().getAssetId();
|
||||
if(bitmapName == StringTable->EmptyString() || bitmapName == StringTable->insert("texhandle"))
|
||||
mBitmap = NULL;
|
||||
}
|
||||
|
|
@ -704,15 +700,15 @@ DefineEngineMethod( GuiControlProfile, getStringWidth, S32, (const char* string)
|
|||
|
||||
DefineEngineMethod(GuiControlProfile, getBitmap, const char*, (), , "get name")
|
||||
{
|
||||
return object->getBitmap();
|
||||
return object->getBitmapAsset()->getImageFile();
|
||||
}
|
||||
DefineEngineMethod(GuiControlProfile, getBitmapAsset, const char*, (), , "")
|
||||
{
|
||||
return object->mBitmapAssetId;
|
||||
return object->getBitmapAsset().getAssetId();
|
||||
}
|
||||
DefineEngineMethod(GuiControlProfile, setBitmap, bool, (const char* map), , "")
|
||||
DefineEngineMethod(GuiControlProfile, setBitmap, void, (const char* map), , "")
|
||||
{
|
||||
return object->_setBitmap(StringTable->insert(map));
|
||||
object->_setBitmap(StringTable->insert(map));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -457,105 +457,11 @@ public:
|
|||
///< Bitmap for the bitmap of the control
|
||||
///
|
||||
public:
|
||||
GFXTexHandle mBitmap = NULL;
|
||||
StringTableEntry mBitmapName;
|
||||
StringTableEntry mBitmapAssetId;
|
||||
AssetPtr<ImageAsset> mBitmapAsset;
|
||||
GFXTextureProfile* mBitmapProfile = &GFXDefaultGUIProfile;
|
||||
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 (_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"))
|
||||
{
|
||||
}
|
||||
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->getImageFile() != StringTable->EmptyString()))
|
||||
return Platform::makeRelativePathName(mBitmapAsset->getImageFile(), 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_ASSET_SETGET(GuiControlProfile, Bitmap);
|
||||
|
||||
void onBitmapChanged() {}
|
||||
DECLARE_IMAGEASSET_REFACTOR(GuiControlProfile, Bitmap, GFXDefaultGUIProfile)
|
||||
|
||||
GFXTexHandle mBitmap;
|
||||
StringTableEntry mBitmapName;
|
||||
|
||||
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering
|
||||
Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue