mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Updates ImageAsset usage to utilize AssetRef, and standardizes the setter/getter functions and naming conventions, as well as the ability to use and bind named targets.
This commit is contained in:
parent
a858d8624e
commit
34e3f78a22
82 changed files with 1451 additions and 951 deletions
|
|
@ -120,6 +120,22 @@ IMPLEMENT_CALLBACK( GuiBitmapButtonCtrl, onShiftClick, void, (), (),
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GuiBitmapButtonCtrl::_setBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mBitmapAssetRef.assetId = _in;
|
||||
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
}
|
||||
else
|
||||
{
|
||||
mBitmapAssetRef = _in;
|
||||
}
|
||||
}
|
||||
|
||||
GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
|
||||
{
|
||||
mBitmapMode = BitmapStretched;
|
||||
|
|
@ -129,10 +145,7 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
|
|||
setExtent( 140, 30 );
|
||||
mMasked = false;
|
||||
mColor = ColorI::WHITE;
|
||||
mBitmapName = StringTable->EmptyString();
|
||||
mBitmap = NULL;
|
||||
mBitmapAsset.registerRefreshNotify(this);
|
||||
mBitmapFile = String::EmptyString;
|
||||
mBitmapAssetRef.assetPtr.registerRefreshNotify(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -142,10 +155,11 @@ void GuiBitmapButtonCtrl::initPersistFields()
|
|||
docsURL;
|
||||
addGroup( "Bitmap" );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapButtonCtrl,"Texture file to display on this button.\n"
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiBitmapButtonCtrl))
|
||||
.doc("Texture asset 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("color", TypeColorI, Offset(mColor, GuiBitmapButtonCtrl), "color mul");
|
||||
|
||||
|
|
@ -183,7 +197,7 @@ bool GuiBitmapButtonCtrl::onWake()
|
|||
return false;
|
||||
|
||||
setActive( true );
|
||||
setBitmap( mBitmapName );
|
||||
setBitmap(mBitmapAssetRef.assetId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -192,17 +206,13 @@ bool GuiBitmapButtonCtrl::onWake()
|
|||
|
||||
void GuiBitmapButtonCtrl::onSleep()
|
||||
{
|
||||
if( dStricmp(mBitmapName, "texhandle") != 0 )
|
||||
for( U32 i = 0; i < NumModifiers; ++ i )
|
||||
{
|
||||
mTextures[ i ].mTextureNormal = NULL;
|
||||
mTextures[ i ].mTextureHilight = NULL;
|
||||
mTextures[ i ].mTextureDepressed = NULL;
|
||||
mTextures[ i ].mTextureInactive = NULL;
|
||||
}
|
||||
|
||||
if (mBitmapAsset.notNull())
|
||||
mBitmap = NULL;
|
||||
for( U32 i = 0; i < NumModifiers; ++ i )
|
||||
{
|
||||
mTextures[ i ].mTextureNormal = NULL;
|
||||
mTextures[ i ].mTextureHilight = NULL;
|
||||
mTextures[ i ].mTextureDepressed = NULL;
|
||||
mTextures[ i ].mTextureInactive = NULL;
|
||||
}
|
||||
|
||||
Parent::onSleep();
|
||||
}
|
||||
|
|
@ -241,7 +251,7 @@ void GuiBitmapButtonCtrl::inspectPostApply()
|
|||
{
|
||||
Parent::inspectPostApply();
|
||||
|
||||
setBitmap(mBitmapName);
|
||||
setBitmap(mBitmapAssetRef.assetId);
|
||||
|
||||
// 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)
|
||||
|
|
@ -258,7 +268,7 @@ void GuiBitmapButtonCtrl::setAutoFitExtents( bool state )
|
|||
{
|
||||
mAutoFitExtents = state;
|
||||
if( mAutoFitExtents )
|
||||
setBitmap( mBitmapName );
|
||||
setBitmap(mBitmapAssetRef.assetId);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -271,143 +281,140 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
|||
if( !isAwake() )
|
||||
return;
|
||||
|
||||
if( mBitmapAsset.notNull())
|
||||
if( mBitmapAssetRef.notNull())
|
||||
{
|
||||
if( dStricmp( mBitmapName, "texhandle" ) != 0 )
|
||||
const U32 count = mUseModifiers ? NumModifiers : 1;
|
||||
for( U32 i = 0; i < count; ++ i )
|
||||
{
|
||||
const U32 count = mUseModifiers ? NumModifiers : 1;
|
||||
for( U32 i = 0; i < count; ++ i )
|
||||
static String modifiers[] =
|
||||
{
|
||||
static String modifiers[] =
|
||||
"",
|
||||
"_ctrl",
|
||||
"_alt",
|
||||
"_shift"
|
||||
};
|
||||
|
||||
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 = mBitmapAssetRef.getAssetId();
|
||||
|
||||
//strip any pre-assigned suffix, just in case
|
||||
baseName = baseName.replace("_n_image", "");
|
||||
baseName = baseName.replace("_n", "");
|
||||
|
||||
if( mUseModifiers )
|
||||
baseName += modifiers[ i ];
|
||||
|
||||
mTextures[i].mTextureNormal = getBitmap();
|
||||
|
||||
if( mUseStates )
|
||||
{
|
||||
//normal lookup
|
||||
StringTableEntry lookupName;
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
"",
|
||||
"_ctrl",
|
||||
"_alt",
|
||||
"_shift"
|
||||
};
|
||||
|
||||
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 = mBitmapAsset.getAssetId();
|
||||
|
||||
//strip any pre-assigned suffix, just in case
|
||||
baseName = baseName.replace("_n_image", "");
|
||||
baseName = baseName.replace("_n", "");
|
||||
|
||||
if( mUseModifiers )
|
||||
baseName += modifiers[ i ];
|
||||
|
||||
mTextures[i].mTextureNormal = getBitmap();
|
||||
|
||||
if( mUseStates )
|
||||
{
|
||||
//normal lookup
|
||||
StringTableEntry lookupName;
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
if (!mTextures[i].mTextureNormal)
|
||||
{
|
||||
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->load();
|
||||
if (mTextures[i].mTextureNormalAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureNormal = mTextures[i].mTextureNormalAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Hilight lookup
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
lookupName = StringTable->insert(String(baseName + s_h[s]).c_str());
|
||||
lookupName = StringTable->insert(String(baseName + s_n[s]).c_str());
|
||||
if (AssetDatabase.isDeclaredAsset(lookupName))
|
||||
{
|
||||
mTextures[i].mTextureHilightAssetId = lookupName;
|
||||
mTextures[i].mTextureHilightAsset = mTextures[i].mTextureHilightAssetId;
|
||||
mTextures[i].mTextureNormalAssetId = lookupName;
|
||||
mTextures[i].mTextureNormalAsset = mTextures[i].mTextureNormalAssetId;
|
||||
}
|
||||
|
||||
if (mTextures[i].mTextureHilightAsset.notNull())
|
||||
if (mTextures[i].mTextureNormalAsset.notNull())
|
||||
{
|
||||
mTextures[i].mTextureHilightAsset->load();
|
||||
if (mTextures[i].mTextureHilightAsset->getStatus() == AssetBase::Ok)
|
||||
mTextures[i].mTextureNormalAsset->load();
|
||||
if (mTextures[i].mTextureNormalAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureHilight = mTextures[i].mTextureHilightAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
mTextures[i].mTextureNormal = mTextures[i].mTextureNormalAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureHilight )
|
||||
mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
|
||||
|
||||
//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->load();
|
||||
if (mTextures[i].mTextureDepressedAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureDepressed = mTextures[i].mTextureDepressedAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureDepressed )
|
||||
mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
|
||||
|
||||
//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->load();
|
||||
if (mTextures[i].mTextureInactiveAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureInactive = mTextures[i].mTextureInactiveAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
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() )
|
||||
//Hilight lookup
|
||||
for (U32 s = 0; s < 2; s++)
|
||||
{
|
||||
Con::warnf( "GuiBitmapButtonCtrl::setBitmap - Unable to load texture: %s", mBitmapName );
|
||||
this->setBitmap( StringTable->insert(GFXTextureManager::getUnavailableTexturePath().c_str()) );
|
||||
return;
|
||||
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->load();
|
||||
if (mTextures[i].mTextureHilightAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureHilight = mTextures[i].mTextureHilightAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureHilight )
|
||||
mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
|
||||
|
||||
//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->load();
|
||||
if (mTextures[i].mTextureDepressedAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureDepressed = mTextures[i].mTextureDepressedAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !mTextures[ i ].mTextureDepressed )
|
||||
mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
|
||||
|
||||
//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->load();
|
||||
if (mTextures[i].mTextureInactiveAsset->getStatus() == AssetBase::Ok)
|
||||
{
|
||||
mTextures[i].mTextureInactive = mTextures[i].mTextureInactiveAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
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", mBitmapAssetRef.assetId);
|
||||
this->setBitmap( StringTable->insert(GFXTextureManager::getUnavailableTexturePath().c_str()) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -428,37 +435,6 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
|||
setUpdate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GuiBitmapButtonCtrl::setBitmapHandles(GFXTexHandle normal, GFXTexHandle highlighted, GFXTexHandle depressed, GFXTexHandle inactive)
|
||||
{
|
||||
const U32 count = mUseModifiers ? NumModifiers : 1;
|
||||
for( U32 i = 0; i < count; ++ i )
|
||||
{
|
||||
mTextures[ i ].mTextureNormal = normal;
|
||||
mTextures[ i ].mTextureHilight = highlighted;
|
||||
mTextures[ i ].mTextureDepressed = depressed;
|
||||
mTextures[ i ].mTextureInactive = inactive;
|
||||
|
||||
if (!mTextures[ i ].mTextureHilight)
|
||||
mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
|
||||
if (!mTextures[ i ].mTextureDepressed)
|
||||
mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
|
||||
if (!mTextures[ i ].mTextureInactive)
|
||||
mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
|
||||
|
||||
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( StringTable->insert(GFXTextureManager::getUnavailableTexturePath().c_str()) );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mBitmapName = "texhandle";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
GuiBitmapButtonCtrl::Modifier GuiBitmapButtonCtrl::getCurrentModifier()
|
||||
|
|
@ -644,7 +620,7 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
|
|||
bmp = getTextureForCurrentState().getBitmap();
|
||||
if (!bmp)
|
||||
{
|
||||
setBitmap(mBitmapName);
|
||||
setBitmap(mBitmapAssetRef.assetId);
|
||||
bmp = getTextureForCurrentState().getBitmap();
|
||||
}
|
||||
|
||||
|
|
@ -669,10 +645,12 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
|
|||
return Parent::pointInControl(parentCoordPoint);
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiBitmapButtonCtrl, getBitmap, StringTableEntry, (), , "get name") {
|
||||
return object->getBitmapFile();
|
||||
}DefineEngineMethod(GuiBitmapButtonCtrl, getBitmapAsset, StringTableEntry, (), , assetText(Bitmap, asset reference)) {
|
||||
return object->_getBitmap();
|
||||
}DefineEngineMethod(GuiBitmapButtonCtrl, setBitmap, void, (const char* assetName), , assetText(Bitmap, assignment.first tries asset then flat file.)) {
|
||||
DefineEngineMethod(GuiBitmapButtonCtrl, getBitmapAsset, StringTableEntry, (), , "Get the Bitmap asset reference.")
|
||||
{
|
||||
return object->getBitmapAssetId();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiBitmapButtonCtrl, setBitmap, void, (const char* assetName), , "Bitmap assignment. First tries asset then flat file.")
|
||||
{
|
||||
object->setBitmap(StringTable->insert(assetName));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,46 +119,19 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl, protected AssetPtrCallback
|
|||
BitmapMode mBitmapMode;
|
||||
|
||||
private:
|
||||
AssetPtr<ImageAsset> mBitmapAsset;
|
||||
String mBitmapFile;
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
public:
|
||||
void _setBitmap(StringTableEntry _in) {
|
||||
if (_in == NULL || _in == StringTable->EmptyString() || _in[0] == '\0')
|
||||
{
|
||||
mBitmapAsset = NULL;
|
||||
mBitmapFile = "";
|
||||
return;
|
||||
}
|
||||
if (mBitmapAsset.getAssetId() == _in) return; if (!AssetDatabase.isDeclaredAsset(_in)) {
|
||||
StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback; AssetQuery query; S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); if (foundAssetcount != 0) {
|
||||
imageAssetId = query.mAssetList[0];
|
||||
} mBitmapAsset = imageAssetId;
|
||||
}
|
||||
else {
|
||||
mBitmapAsset = _in;
|
||||
mBitmapName = _in;
|
||||
mBitmap = getBitmap();
|
||||
}
|
||||
}; inline StringTableEntry _getBitmap(void) const {
|
||||
return mBitmapAsset.getAssetId();
|
||||
} GFXTexHandle getBitmap() {
|
||||
return mBitmapAsset.notNull() ? mBitmapAsset->getTexture(&GFXDefaultGUIProfile) : 0;
|
||||
} AssetPtr<ImageAsset> getBitmapAsset(void) {
|
||||
return mBitmapAsset;
|
||||
} static bool _setBitmapData(void* obj, const char* index, const char* data) {
|
||||
static_cast<GuiBitmapButtonCtrl*>(obj)->_setBitmap(_getStringTable()->insert(data)); return false;
|
||||
}
|
||||
StringTableEntry getBitmapFile() { return mBitmapAsset.notNull() ? mBitmapAsset->getImageFile() : ""; }
|
||||
void _setBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
protected:
|
||||
|
||||
void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
|
||||
{
|
||||
setBitmap(mBitmapName);
|
||||
setBitmap(mBitmapAssetRef.assetId);
|
||||
}
|
||||
|
||||
GFXTexHandle mBitmap;
|
||||
StringTableEntry mBitmapName;
|
||||
/// alpha masking
|
||||
bool mMasked;
|
||||
|
||||
|
|
@ -202,7 +175,6 @@ protected:
|
|||
|
||||
void setAutoFitExtents( bool state );
|
||||
void setBitmap( StringTableEntry name );
|
||||
void setBitmapHandles( GFXTexHandle normal, GFXTexHandle highlighted, GFXTexHandle depressed, GFXTexHandle inactive );
|
||||
|
||||
//Parent methods
|
||||
bool onWake() override;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,8 @@ void GuiIconButtonCtrl::initPersistFields()
|
|||
docsURL;
|
||||
addField( "buttonMargin", TypePoint2I, Offset( mButtonMargin, GuiIconButtonCtrl ),"Margin area around the button.\n");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiIconButtonCtrl, "Bitmap file for the icon to display on the button.\n");
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiIconButtonCtrl))
|
||||
.doc("Bitmap asset for the icon to display on the button.");
|
||||
|
||||
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");
|
||||
|
|
@ -200,6 +201,21 @@ bool GuiIconButtonCtrl::resize(const Point2I &newPosition, const Point2I &newExt
|
|||
return Parent::resize( newPosition, autoExtent );
|
||||
}
|
||||
|
||||
void GuiIconButtonCtrl::_setBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mBitmapAssetRef.assetId = _in;
|
||||
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiIconButtonCtrl::setBitmap(const char *name)
|
||||
{
|
||||
_setBitmap(name);
|
||||
|
|
@ -463,10 +479,12 @@ void GuiIconButtonCtrl::renderBitmapArray(RectI &bounds, S32 state)
|
|||
}
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiIconButtonCtrl, getBitmap, StringTableEntry, (), , "get name") {
|
||||
return object->getBitmapFile();
|
||||
}DefineEngineMethod(GuiIconButtonCtrl, getBitmapAsset, StringTableEntry, (), , assetText(Bitmap, asset reference)) {
|
||||
return object->_getBitmap();
|
||||
}DefineEngineMethod(GuiIconButtonCtrl, setBitmap, void, (const char* assetName), , assetText(Bitmap, assignment.first tries asset then flat file.)) {
|
||||
DefineEngineMethod(GuiIconButtonCtrl, getBitmapAsset, StringTableEntry, (), , "Get the Bitmap asset reference.")
|
||||
{
|
||||
return object->getBitmapAssetId();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiIconButtonCtrl, setBitmap, void, (const char* assetName), , "Bitmap assignment. First tries asset then flat file.")
|
||||
{
|
||||
object->setBitmap(StringTable->insert(assetName));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ private:
|
|||
|
||||
protected:
|
||||
|
||||
DECLARE_IMAGEASSET(GuiIconButtonCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
|
||||
S32 mIconLocation;
|
||||
S32 mTextLocation;
|
||||
|
|
@ -113,9 +113,27 @@ public:
|
|||
// Used to set the optional error bitmap
|
||||
void setErrorBitmap(const char *name);
|
||||
|
||||
void _setBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
||||
|
||||
void onImageChanged() {}
|
||||
|
||||
void setFitBitmapToButton(const bool& state) {
|
||||
mFitBitmapToButton = state;
|
||||
}
|
||||
bool getFitBitmapToButton() const {
|
||||
return mFitBitmapToButton;
|
||||
}
|
||||
|
||||
void setMakeIconSquare(const bool& state) {
|
||||
mMakeIconSquare = state;
|
||||
}
|
||||
bool getMakeIconSquare() const {
|
||||
return mMakeIconSquare;
|
||||
}
|
||||
};
|
||||
|
||||
typedef GuiIconButtonCtrl::TextLocation GuiIconButtonTextLocation;
|
||||
|
|
|
|||
|
|
@ -55,9 +55,12 @@ GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
|
|||
void GuiToolboxButtonCtrl::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
INITPERSISTFIELD_IMAGEASSET(NormalBitmap, GuiToolboxButtonCtrl, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(LoweredBitmap, GuiToolboxButtonCtrl, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(HoverBitmap, GuiToolboxButtonCtrl, "");
|
||||
ADD_FIELD("normalBitmapAsset", TypeImageAssetRef, Offset(mNormalBitmapAssetRef, GuiToolboxButtonCtrl))
|
||||
.doc("Bitmap asset to display when the button is in its normal state.");
|
||||
ADD_FIELD("loweredBitmapAsset", TypeImageAssetRef, Offset(mLoweredBitmapAssetRef, GuiToolboxButtonCtrl))
|
||||
.doc("Bitmap asset to display when the button is pressed.");
|
||||
ADD_FIELD("hoverBitmapAsset", TypeImageAssetRef, Offset(mHoverBitmapAssetRef, GuiToolboxButtonCtrl))
|
||||
.doc("Bitmap asset to display when the button is hovered.");
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -95,6 +98,52 @@ void GuiToolboxButtonCtrl::inspectPostApply()
|
|||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
void GuiToolboxButtonCtrl::_setNormalBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mNormalBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mNormalBitmapAssetRef.assetId = _in;
|
||||
mNormalBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mNormalBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiToolboxButtonCtrl::_setLoweredBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mLoweredBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mLoweredBitmapAssetRef.assetId = _in;
|
||||
mLoweredBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mLoweredBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiToolboxButtonCtrl::_setHoverBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mHoverBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mHoverBitmapAssetRef.assetId = _in;
|
||||
mHoverBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mHoverBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
void GuiToolboxButtonCtrl::setNormalBitmap( StringTableEntry bitmapName )
|
||||
{
|
||||
|
|
@ -186,6 +235,32 @@ void GuiToolboxButtonCtrl::renderButton(GFXTexHandle texture, Point2I &offset, c
|
|||
}
|
||||
}
|
||||
|
||||
DEF_ASSET_BINDS_REFACTOR(GuiToolboxButtonCtrl, NormalBitmap)
|
||||
DEF_ASSET_BINDS_REFACTOR(GuiToolboxButtonCtrl, LoweredBitmap)
|
||||
DEF_ASSET_BINDS_REFACTOR(GuiToolboxButtonCtrl, HoverBitmap)
|
||||
DefineEngineMethod(GuiToolboxButtonCtrl, getNormalBitmapAsset, StringTableEntry, (), , "Get the Normal Bitmap asset reference.")
|
||||
{
|
||||
return object->getNormalBitmapAssetId();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiToolboxButtonCtrl, setNormalBitmap, void, (const char* assetName), , "Normal Bitmap assignment. First tries asset then flat file.")
|
||||
{
|
||||
object->setNormalBitmap(StringTable->insert(assetName));
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiToolboxButtonCtrl, getLoweredBitmapAsset, StringTableEntry, (), , "Get the Lowered Bitmap asset reference.")
|
||||
{
|
||||
return object->getLoweredBitmapAssetId();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiToolboxButtonCtrl, setLoweredBitmap, void, (const char* assetName), , "Lowered Bitmap assignment. First tries asset then flat file.")
|
||||
{
|
||||
object->setLoweredBitmap(StringTable->insert(assetName));
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiToolboxButtonCtrl, getHoverBitmapAsset, StringTableEntry, (), , "Get the Hover Bitmap asset reference.")
|
||||
{
|
||||
return object->getHoverBitmapAssetId();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiToolboxButtonCtrl, setHoverBitmap, void, (const char* assetName), , "Hover Bitmap assignment. First tries asset then flat file.")
|
||||
{
|
||||
object->setHoverBitmap(StringTable->insert(assetName));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ private:
|
|||
|
||||
protected:
|
||||
|
||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, NormalBitmap, GFXDefaultGUIProfile)
|
||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, LoweredBitmap, GFXDefaultGUIProfile)
|
||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, HoverBitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mNormalBitmapAssetRef;
|
||||
AssetRef<ImageAsset> mLoweredBitmapAssetRef;
|
||||
AssetRef<ImageAsset> mHoverBitmapAssetRef;
|
||||
|
||||
void renderButton(GFXTexHandle texture, Point2I &offset, const RectI& updateRect);
|
||||
void renderStateRect( GFXTexHandle texture, const RectI& rect );
|
||||
|
|
@ -60,7 +60,19 @@ public:
|
|||
void setNormalBitmap( StringTableEntry bitmapName );
|
||||
void setLoweredBitmap( StringTableEntry bitmapName );
|
||||
void setHoverBitmap( StringTableEntry bitmapName );
|
||||
|
||||
|
||||
void _setNormalBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getNormalBitmapAssetId() const { return mNormalBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getNormalBitmap() { return mNormalBitmapAssetRef.notNull() ? mNormalBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
void _setLoweredBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getLoweredBitmapAssetId() const { return mLoweredBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getLoweredBitmap() { return mLoweredBitmapAssetRef.notNull() ? mLoweredBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
void _setHoverBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getHoverBitmapAssetId() const { return mHoverBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getHoverBitmap() { return mHoverBitmapAssetRef.notNull() ? mHoverBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
|
||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ void GuiBitmapCtrl::initPersistFields()
|
|||
docsURL;
|
||||
addGroup("Bitmap");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapCtrl, "The bitmap to render in this BitmapCtrl.")
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiBitmapCtrl))
|
||||
.doc("The bitmap asset to render in this BitmapCtrl.");
|
||||
|
||||
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.");
|
||||
|
|
@ -127,6 +128,21 @@ void GuiBitmapCtrl::inspectPostApply()
|
|||
}
|
||||
}
|
||||
|
||||
void GuiBitmapCtrl::_setBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mBitmapAssetRef.assetId = _in;
|
||||
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiBitmapCtrl::setBitmap(const char* name, bool resize)
|
||||
{
|
||||
// coming in here we are probably getting a filename.
|
||||
|
|
@ -144,9 +160,9 @@ void GuiBitmapCtrl::setBitmap(const char* name, bool resize)
|
|||
_setBitmap(StringTable->EmptyString());
|
||||
}
|
||||
|
||||
if (mBitmapAsset.notNull())
|
||||
if (mBitmapAssetRef.notNull())
|
||||
{
|
||||
mBitmap = mBitmapAsset->getTexture(&GFXDefaultGUIProfile);
|
||||
mBitmap = mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile);
|
||||
|
||||
if (getBitmap() && resize)
|
||||
{
|
||||
|
|
@ -184,7 +200,7 @@ void GuiBitmapCtrl::updateSizing()
|
|||
|
||||
void GuiBitmapCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||
{
|
||||
if (mBitmap.isNull() && mBitmapAsset.notNull())
|
||||
if (mBitmap.isNull() && mBitmapAssetRef.notNull())
|
||||
mBitmap = getBitmap();
|
||||
|
||||
if (mBitmap)
|
||||
|
|
@ -309,8 +325,8 @@ void GuiBitmapCtrl::setValue(S32 x, S32 y)
|
|||
{
|
||||
if (getBitmap())
|
||||
{
|
||||
x += mBitmapAsset->getTextureBitmapWidth() / 2;
|
||||
y += mBitmapAsset->getTextureBitmapHeight() / 2;
|
||||
x += mBitmapAssetRef.assetPtr->getTextureBitmapWidth() / 2;
|
||||
y += mBitmapAssetRef.assetPtr->getTextureBitmapHeight() / 2;
|
||||
}
|
||||
while (x < 0)
|
||||
x += 256;
|
||||
|
|
@ -359,11 +375,11 @@ DefineEngineMethod(GuiBitmapCtrl, setBitmap, void, (const char* fileRoot, bool r
|
|||
object->setBitmap(filename, resize);
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (), ,
|
||||
"Gets the current bitmap set for this control.\n\n"
|
||||
DefineEngineMethod(GuiBitmapCtrl, getBitmapAsset, const char*, (), ,
|
||||
"Gets the current asset Id of the bitmap set for this control.\n\n"
|
||||
"@hide")
|
||||
{
|
||||
return object->_getBitmap();
|
||||
return object->getBitmapAssetId();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture), ,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ protected:
|
|||
|
||||
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
|
||||
/// from a file but rather set explicitly on the control.
|
||||
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
|
||||
Point2I mStartPoint;
|
||||
ColorI mColor;
|
||||
|
|
@ -74,6 +74,11 @@ public:
|
|||
void setBitmap(const char* name, bool resize = true);
|
||||
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
|
||||
|
||||
void _setBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
AssetPtr<ImageAsset> getBitmapAsset() { return mBitmapAssetRef.assetPtr; }
|
||||
|
||||
void updateSizing();
|
||||
|
||||
void onRender(Point2I offset, const RectI& updateRect) override;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,51 @@ GuiGameSettingsCtrl::GuiGameSettingsCtrl() :
|
|||
mCallbackOnY = mCallbackOnA;
|
||||
}
|
||||
|
||||
void GuiGameSettingsCtrl::setKeybindBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mKeybindBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mKeybindBitmapAssetRef.assetId = _in;
|
||||
mKeybindBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mKeybindBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiGameSettingsCtrl::setPreviousBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mPreviousBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mPreviousBitmapAssetRef.assetId = _in;
|
||||
mPreviousBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mPreviousBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiGameSettingsCtrl::setNextBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mNextBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mNextBitmapAssetRef.assetId = _in;
|
||||
mNextBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mNextBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
GuiGameSettingsCtrl::~GuiGameSettingsCtrl()
|
||||
{
|
||||
mOptions.clear();
|
||||
|
|
@ -430,7 +475,7 @@ void GuiGameSettingsCtrl::setKeybindSetting(const char* label, const char* bitma
|
|||
{
|
||||
static StringTableEntry DELIM = StringTable->insert("\t", true);
|
||||
|
||||
_setKeybindBitmap(StringTable->insert(bitmapName));
|
||||
setKeybindBitmap(StringTable->insert(bitmapName));
|
||||
|
||||
//if(mBitmap != StringTable->EmptyString())
|
||||
// mBitmapTex.set(mBitmap, &GFXDefaultGUIProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
|
|
@ -828,9 +873,12 @@ IMPLEMENT_CALLBACK(GuiGameSettingsCtrl, onAxisEvent, void, (const char* device,
|
|||
void GuiGameSettingsCtrl::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
INITPERSISTFIELD_IMAGEASSET(KeybindBitmap, GuiGameSettingsCtrl, "Bitmap used to display the bound key for this keybind option.");
|
||||
INITPERSISTFIELD_IMAGEASSET(PreviousBitmap, GuiGameSettingsCtrl, "Bitmap used for the previous button when in list mode.");
|
||||
INITPERSISTFIELD_IMAGEASSET(NextBitmap, GuiGameSettingsCtrl, "Bitmap used for the next button when in list mode.");
|
||||
ADD_FIELD("keybindBitmapAsset", TypeImageAssetRef, Offset(mKeybindBitmapAssetRef, GuiGameSettingsCtrl))
|
||||
.doc("Bitmap asset used to display the bound key for this keybind option.");
|
||||
ADD_FIELD("previousBitmapAsset", TypeImageAssetRef, Offset(mPreviousBitmapAssetRef, GuiGameSettingsCtrl))
|
||||
.doc("Bitmap asset used for the previous button when in list mode.");
|
||||
ADD_FIELD("nextBitmapAsset", TypeImageAssetRef, Offset(mNextBitmapAssetRef, GuiGameSettingsCtrl))
|
||||
.doc("Bitmap asset used for the next button when in list mode.");
|
||||
|
||||
addFieldV("arrowSize", TypeRangedS32, Offset(mArrowSize, GuiGameSettingsCtrl), &CommonValidators::PositiveInt,
|
||||
"Size of the arrow buttons' extents");
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ protected:
|
|||
Point2F mRange; ///< When working as a slider, this sets our min/max range
|
||||
|
||||
//Keybind option
|
||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, GFXDefaultGUIProfile)
|
||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, GFXDefaultGUIProfile)
|
||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mKeybindBitmapAssetRef;
|
||||
AssetRef<ImageAsset> mPreviousBitmapAssetRef;
|
||||
AssetRef<ImageAsset> mNextBitmapAssetRef;
|
||||
|
||||
S32 mArrowSize;
|
||||
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.
|
||||
|
|
@ -84,7 +84,19 @@ protected:
|
|||
bool mSelected;
|
||||
|
||||
public:
|
||||
/// Sets the control as selected . Only controls that are enabled can be selected.
|
||||
void setKeybindBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getKeybindBitmapAssetId() const { return mKeybindBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getKeybindBitmap() { return mKeybindBitmapAssetRef.notNull() ? mKeybindBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
void setPreviousBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getPreviousBitmapAssetId() const { return mPreviousBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getPreviousBitmap() { return mPreviousBitmapAssetRef.notNull() ? mPreviousBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
void setNextBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getNextBitmapAssetId() const { return mNextBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getNextBitmap() { return mNextBitmapAssetRef.notNull() ? mNextBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
/// Sets the control as selected . Only controls that are enabled can be selected.
|
||||
virtual void setSelected();
|
||||
|
||||
/// Determines if the specified control is enabled or disabled.
|
||||
|
|
|
|||
|
|
@ -299,7 +299,10 @@ void GuiPopUpMenuCtrl::initPersistFields(void)
|
|||
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
|
||||
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));
|
||||
|
||||
addProtectedField("BitmapAsset", TypeImageAssetPtr, Offset(mBitmapAsset, GuiPopUpMenuCtrl), _setBitmaps, &defaultProtectedGetFn, "@brief ""Bitmap"" ""asset \"\".");
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiPopUpMenuCtrl))
|
||||
.elements(NumBitmapModes)
|
||||
.onSet(_setBitmaps)
|
||||
.doc("@brief ""Bitmap"" ""asset \"\".");
|
||||
|
||||
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrl));
|
||||
|
||||
|
|
@ -580,18 +583,18 @@ void GuiPopUpMenuCtrl::setBitmap( const char *name )
|
|||
|
||||
dStrcpy(p, "_n", pLen);
|
||||
|
||||
_setBitmap((StringTableEntry)buffer, Normal);
|
||||
setBitmap((StringTableEntry)buffer, Normal);
|
||||
|
||||
dStrcpy(p, "_d", pLen);
|
||||
_setBitmap((StringTableEntry)buffer, Depressed);
|
||||
setBitmap((StringTableEntry)buffer, Depressed);
|
||||
|
||||
if ( mBitmapAsset[Depressed].isNull() )
|
||||
mBitmapAsset[Depressed] = mBitmapAsset[Normal];
|
||||
if ( mBitmapAssetRef[Depressed].isNull() )
|
||||
mBitmapAssetRef[Depressed] = mBitmapAssetRef[Normal];
|
||||
}
|
||||
else
|
||||
{
|
||||
_setBitmap(StringTable->EmptyString(), Normal);
|
||||
_setBitmap(StringTable->EmptyString(), Depressed);
|
||||
setBitmap(StringTable->EmptyString(), Normal);
|
||||
setBitmap(StringTable->EmptyString(), Depressed);
|
||||
}
|
||||
setUpdate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,9 @@ protected:
|
|||
NumBitmapModes = 2
|
||||
};
|
||||
|
||||
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef[NumBitmapModes];
|
||||
GFXTexHandle getBitmap(const U32& index) { return mBitmapAssetRef[index].notNull() ? mBitmapAssetRef[index].assetPtr->getTexture(&GFXDefaultGUIProfile) : GFXTexHandle(); }
|
||||
void setBitmap(StringTableEntry assetId, const U32& index) { mBitmapAssetRef[index] = assetId; }
|
||||
|
||||
Point2I mBitmapBounds; // Added
|
||||
S32 mIdMax;
|
||||
|
|
|
|||
|
|
@ -354,7 +354,10 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
|
|||
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
|
||||
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
|
||||
|
||||
addProtectedField("BitmapAsset", TypeImageAssetPtr, Offset(mBitmapAsset, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "@brief ""Bitmap"" ""asset \"Name of bitmap asset to use\".");
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiPopUpMenuCtrlEx))
|
||||
.elements(NumBitmapModes)
|
||||
.onSet(_setBitmaps)
|
||||
.doc("@brief ""Bitmap"" ""asset \"Name of bitmap asset to use\".");
|
||||
|
||||
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrlEx), "Boundaries of bitmap displayed");
|
||||
addField("hotTrackCallback", TypeBool, Offset(mHotTrackItems, GuiPopUpMenuCtrlEx),
|
||||
|
|
@ -807,18 +810,18 @@ void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
|
|||
|
||||
dStrcpy(p, "_n", pLen);
|
||||
|
||||
_setBitmap((StringTableEntry)buffer, Normal);
|
||||
setBitmap((StringTableEntry)buffer, Normal);
|
||||
|
||||
dStrcpy(p, "_d", pLen);
|
||||
_setBitmap((StringTableEntry)buffer, Depressed);
|
||||
setBitmap((StringTableEntry)buffer, Depressed);
|
||||
|
||||
if (mBitmapAsset[Depressed].isNull())
|
||||
mBitmapAsset[Depressed] = mBitmapAsset[Normal];
|
||||
if (mBitmapAssetRef[Depressed].isNull())
|
||||
mBitmapAssetRef[Depressed] = mBitmapAssetRef[Normal];
|
||||
}
|
||||
else
|
||||
{
|
||||
_setBitmap(StringTable->EmptyString(), Normal);
|
||||
_setBitmap(StringTable->EmptyString(), Depressed);
|
||||
setBitmap(StringTable->EmptyString(), Normal);
|
||||
setBitmap(StringTable->EmptyString(), Depressed);
|
||||
}
|
||||
setUpdate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
|
|||
NumBitmapModes = 2
|
||||
};
|
||||
|
||||
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef[NumBitmapModes];
|
||||
GFXTexHandle getBitmap(const U32& index) { return mBitmapAssetRef[index].notNull() ? mBitmapAssetRef[index].assetPtr->getTexture(&GFXDefaultGUIProfile) : GFXTexHandle(); }
|
||||
void setBitmap(StringTableEntry assetId, const U32& index) { mBitmapAssetRef[index] = assetId; }
|
||||
|
||||
Point2I mBitmapBounds; // Added
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ 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.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiCursor))
|
||||
.doc("Bitmap asset for the cursor.");
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
@ -187,39 +188,44 @@ void GuiControlProfile::setBitmapHandle(GFXTexHandle handle)
|
|||
mBitmapName = "texhandle";
|
||||
}
|
||||
|
||||
bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, const char *data )
|
||||
bool GuiControlProfile::_setBitmap( void *object, const char *index, const char *data )
|
||||
{
|
||||
GuiControlProfile *profile = static_cast<GuiControlProfile*>( object );
|
||||
|
||||
profile->_setBitmap(StringTable->insert(data));
|
||||
profile->setBitmap(StringTable->insert(data));
|
||||
|
||||
if ( !profile->isProperlyAdded() )
|
||||
return true;
|
||||
|
||||
if( profile->mLoadCount > 0 )
|
||||
{
|
||||
profile->mBitmapArrayRects.clear();
|
||||
profile->mBitmap = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (profile->mBitmapName != StringTable->EmptyString())
|
||||
void GuiControlProfile::setBitmap(StringTableEntry _in)
|
||||
{
|
||||
mBitmapAssetRef = _in;
|
||||
|
||||
if( mLoadCount > 0 )
|
||||
{
|
||||
mBitmapArrayRects.clear();
|
||||
mBitmap = NULL;
|
||||
|
||||
if (mBitmapName != StringTable->EmptyString())
|
||||
{
|
||||
if (profile->mBitmapAsset.notNull() && profile->mBitmapName != StringTable->insert("texHandle"))
|
||||
if (mBitmapAssetRef.notNull() && mBitmapName != StringTable->insert("texHandle"))
|
||||
{
|
||||
profile->mBitmap = profile->getBitmap();
|
||||
profile->mBitmapName = profile->mBitmapAsset->getImageFile();
|
||||
mBitmap = getBitmap();
|
||||
mBitmapName = mBitmapAssetRef.assetPtr->getImageFile();
|
||||
}
|
||||
|
||||
//verify the bitmap
|
||||
if (!profile->mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", profile->getName(), profile->getBitmapAsset().getAssetId());
|
||||
if (!mBitmap)
|
||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", getName(), getBitmapAsset().getAssetId());
|
||||
|
||||
// If we've got a special border, make sure it's usable.
|
||||
//if( profile->mBorder == -1 || profile->mBorder == -2 )
|
||||
profile->constructBitmapArray();
|
||||
//if( mBorder == -1 || mBorder == -2 )
|
||||
constructBitmapArray();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GuiControlProfile::GuiControlProfile(void) :
|
||||
|
|
@ -436,19 +442,10 @@ 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("bitmapAsset", TypeImageAssetPtr, Offset(mBitmapAsset, GuiControlProfile),
|
||||
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
||||
"Texture to use for rendering control.");
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiControlProfile))
|
||||
.onSet(_setBitmap)
|
||||
.doc("Texture to use for rendering control.");
|
||||
|
||||
addField("hasBitmapArray", TypeBool, Offset(mUseBitmapArray, GuiControlProfile),
|
||||
"If true, 'bitmap' is an array of images." );
|
||||
|
|
@ -554,12 +551,12 @@ S32 GuiControlProfile::constructBitmapArray()
|
|||
|
||||
if( mBitmap.isNull() )
|
||||
{
|
||||
if (mBitmapAsset.notNull() && mBitmapName != StringTable->insert("texhandle"))
|
||||
if (mBitmapAssetRef.notNull() && mBitmapName != StringTable->insert("texhandle"))
|
||||
{
|
||||
mBitmap = getBitmap();
|
||||
}
|
||||
|
||||
if (mBitmapAsset.isNull() || mBitmap.isNull())
|
||||
if (mBitmapAssetRef.isNull() || mBitmap.isNull())
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -645,7 +642,7 @@ void GuiControlProfile::incLoadCount()
|
|||
if( mFont == NULL )
|
||||
loadFont();
|
||||
|
||||
if (mBitmapAsset.notNull() && mBitmapName != StringTable->insert("texHandle"))
|
||||
if (mBitmapAssetRef.notNull() && mBitmapName != StringTable->insert("texHandle"))
|
||||
{
|
||||
mBitmap = getBitmap();
|
||||
|
||||
|
|
@ -713,7 +710,7 @@ DefineEngineMethod(GuiControlProfile, getBitmapAsset, const char*, (), , "")
|
|||
}
|
||||
DefineEngineMethod(GuiControlProfile, setBitmap, void, (const char* map), , "")
|
||||
{
|
||||
object->_setBitmap(StringTable->insert(map));
|
||||
object->setBitmap(StringTable->insert(map));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ class GuiCursor : public SimObject
|
|||
private:
|
||||
typedef SimObject Parent;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiCursor, Bitmap, GFXGuiCursorProfile)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
|
||||
Point2I mHotSpot;
|
||||
Point2F mRenderOffset;
|
||||
|
|
@ -358,6 +358,10 @@ public:
|
|||
Point2I getHotSpot() { return mHotSpot; }
|
||||
Point2I getExtent() { return mExtent; }
|
||||
|
||||
void setBitmap(StringTableEntry _in) { mBitmapAssetRef = _in; }
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXGuiCursorProfile) : NULL; }
|
||||
|
||||
DECLARE_CONOBJECT(GuiCursor);
|
||||
GuiCursor(void);
|
||||
~GuiCursor(void);
|
||||
|
|
@ -458,7 +462,13 @@ public:
|
|||
///
|
||||
public:
|
||||
|
||||
DECLARE_IMAGEASSET(GuiControlProfile, Bitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
|
||||
void setBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
AssetPtr<ImageAsset> getBitmapAsset() { return mBitmapAssetRef.assetPtr; }
|
||||
StringTableEntry getBitmapFile() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getImageFile() : ""; }
|
||||
|
||||
GFXTexHandle mBitmap;
|
||||
StringTableEntry mBitmapName;
|
||||
|
|
@ -488,7 +498,7 @@ public:
|
|||
protected:
|
||||
GuiControlProfile* mChildrenProfile; ///< Profile used with children controls (such as the scroll bar on a popup menu) when defined.
|
||||
|
||||
static bool protectedSetBitmap( void *object, const char *index, const char *data );
|
||||
static bool _setBitmap( void *object, const char *index, const char *data );
|
||||
|
||||
public:
|
||||
DECLARE_CONOBJECT(GuiControlProfile);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ void GuiChunkedBitmapCtrl::initPersistFields()
|
|||
{
|
||||
docsURL;
|
||||
addGroup("GuiChunkedBitmapCtrl");
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap to render to the control.");
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiChunkedBitmapCtrl))
|
||||
.doc("This is the bitmap asset 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\"");
|
||||
|
|
@ -92,6 +93,21 @@ GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
|
|||
mTile = false;
|
||||
}
|
||||
|
||||
void GuiChunkedBitmapCtrl::_setBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mBitmapAssetRef.assetId = _in;
|
||||
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiChunkedBitmapCtrl::setBitmap(const char *name)
|
||||
{
|
||||
bool awake = mAwake;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ private:
|
|||
|
||||
protected:
|
||||
|
||||
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
|
||||
bool mUseVariable;
|
||||
bool mTile;
|
||||
|
|
@ -36,5 +36,9 @@ public:
|
|||
|
||||
void setBitmap(const char *name);
|
||||
|
||||
void _setBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -131,15 +131,31 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
|
|||
void GuiProgressBitmapCtrl::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiProgressBitmapCtrl, "Bitmap file to use for rendering the progress bar.\n\n"
|
||||
ADD_FIELD("bitmapAsset", TypeImageAssetRef, Offset(mBitmapAssetRef, GuiProgressBitmapCtrl))
|
||||
.doc("Bitmap asset 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.");
|
||||
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GuiProgressBitmapCtrl::_setBitmap(StringTableEntry _in)
|
||||
{
|
||||
if (mBitmapAssetRef.assetId == _in)
|
||||
return;
|
||||
|
||||
if (ImageAsset::isNamedTarget(_in))
|
||||
{
|
||||
mBitmapAssetRef.assetId = _in;
|
||||
mBitmapAssetRef.assetPtr = ImageAsset::getNamedTargetAssetPtr(_in);
|
||||
return;
|
||||
}
|
||||
|
||||
mBitmapAssetRef = _in;
|
||||
}
|
||||
|
||||
void GuiProgressBitmapCtrl::setBitmap( const char* name )
|
||||
{
|
||||
bool awake = mAwake;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
|
|||
|
||||
F32 mProgress;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mBitmapAssetRef;
|
||||
|
||||
bool mUseVariable;
|
||||
bool mTile;
|
||||
|
|
@ -59,6 +59,10 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
|
|||
GuiProgressBitmapCtrl();
|
||||
|
||||
void setBitmap( const char* name );
|
||||
|
||||
void _setBitmap(StringTableEntry _in);
|
||||
inline StringTableEntry getBitmapAssetId() const { return mBitmapAssetRef.getAssetId(); }
|
||||
GFXTexHandle getBitmap() { return mBitmapAssetRef.notNull() ? mBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
|
||||
//console related methods
|
||||
const char *getScriptValue() override;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ void GuiMissionAreaCtrl::initPersistFields()
|
|||
docsURL;
|
||||
addField( "squareBitmap", TypeBool, Offset(mSquareBitmap, GuiMissionAreaCtrl));
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(HandleBitmap, GuiMissionAreaCtrl, "Bitmap for the mission area handles.\n");
|
||||
ADD_FIELD("handleBitmapAsset", TypeImageAssetRef, Offset(mHandleBitmapAssetRef, GuiMissionAreaCtrl))
|
||||
.doc("Bitmap asset for the mission area handles.\n");
|
||||
|
||||
addField( "missionBoundsColor", TypeColorI, Offset(mMissionBoundsColor, GuiMissionAreaCtrl));
|
||||
addField( "cameraColor", TypeColorI, Offset(mCameraColor, GuiMissionAreaCtrl));
|
||||
|
|
@ -122,7 +123,7 @@ bool GuiMissionAreaCtrl::onAdd()
|
|||
desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
|
||||
mBlendStateBlock = GFX->createStateBlock( desc );
|
||||
|
||||
if (!mHandleBitmapAsset.isNull())
|
||||
if (mHandleBitmapAssetRef.notNull())
|
||||
{
|
||||
mHandleTextureSize = Point2I(getHandleBitmap()->getWidth(), getHandleBitmap()->getHeight());
|
||||
mHandleTextureHalfSize = Point2F(mHandleTextureSize.x, mHandleTextureSize.y) * 0.5f;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ protected:
|
|||
GFXTextureTargetRef mLevelTexture;
|
||||
Box3F mLevelBounds;
|
||||
|
||||
DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, GFXDefaultGUIProfile)
|
||||
AssetRef<ImageAsset> mHandleBitmapAssetRef;
|
||||
|
||||
Point2I mHandleTextureSize;
|
||||
Point2F mHandleTextureHalfSize;
|
||||
|
|
@ -112,6 +112,9 @@ public:
|
|||
|
||||
DECLARE_CONOBJECT(GuiMissionAreaCtrl);
|
||||
|
||||
GFXTexHandle getHandleBitmap() { return mHandleBitmapAssetRef.notNull() ? mHandleBitmapAssetRef.assetPtr->getTexture(&GFXDefaultGUIProfile) : NULL; }
|
||||
StringTableEntry getHandleBitmapFile() { return mHandleBitmapAssetRef.notNull() ? mHandleBitmapAssetRef.assetPtr->getImageFile() : ""; }
|
||||
|
||||
// SimObject
|
||||
bool onAdd() override;
|
||||
static void initPersistFields();
|
||||
|
|
|
|||
|
|
@ -1817,9 +1817,9 @@ WorldEditor::WorldEditor()
|
|||
mPopupBackgroundColor.set(100,100,100);
|
||||
mPopupTextColor.set(255,255,0);
|
||||
|
||||
mSelectHandleAsset = StringTable->insert("ToolsModule:SelectHandle_image");
|
||||
mDefaultHandleAsset = StringTable->insert("ToolsModule:DefaultHandle_image");
|
||||
mLockedHandleAsset = StringTable->insert("ToolsModule:LockedHandle_image");
|
||||
mSelectHandleAssetRef = StringTable->insert("ToolsModule:SelectHandle_image");
|
||||
mDefaultHandleAssetRef = StringTable->insert("ToolsModule:DefaultHandle_image");
|
||||
mLockedHandleAssetRef = StringTable->insert("ToolsModule:LockedHandle_image");
|
||||
|
||||
mObjectTextColor.set(255,255,255);
|
||||
mObjectsUseBoxCenter = true;
|
||||
|
|
@ -2839,9 +2839,12 @@ void WorldEditor::initPersistFields()
|
|||
addField( "renderObjHandle", TypeBool, Offset(mRenderObjHandle, WorldEditor) );
|
||||
addField( "renderSelectionBox", TypeBool, Offset(mRenderSelectionBox, WorldEditor) );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(SelectHandle, WorldEditor, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(DefaultHandle, WorldEditor, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(LockedHandle, WorldEditor, "");
|
||||
ADD_FIELD("selectHandleAsset", TypeImageAssetRef, Offset(mSelectHandleAssetRef, WorldEditor))
|
||||
.doc("Bitmap asset used for the selection handle.");
|
||||
ADD_FIELD("defaultHandleAsset", TypeImageAssetRef, Offset(mDefaultHandleAssetRef, WorldEditor))
|
||||
.doc("Bitmap asset used for the default handle.");
|
||||
ADD_FIELD("lockedHandleAsset", TypeImageAssetRef, Offset(mLockedHandleAssetRef, WorldEditor))
|
||||
.doc("Bitmap asset used for the locked handle.");
|
||||
|
||||
endGroup( "Rendering" );
|
||||
|
||||
|
|
|
|||
|
|
@ -328,9 +328,14 @@ class WorldEditor : public EditTSCtrl
|
|||
ColorI mPopupBackgroundColor;
|
||||
ColorI mPopupTextColor;
|
||||
|
||||
DECLARE_IMAGEASSET(WorldEditor, SelectHandle, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(WorldEditor, LockedHandle, GFXStaticTextureSRGBProfile)
|
||||
AssetRef<ImageAsset> mSelectHandleAssetRef;
|
||||
GFXTexHandle getSelectHandle() { return mSelectHandleAssetRef.notNull() ? mSelectHandleAssetRef.assetPtr->getTexture(&GFXStaticTextureSRGBProfile) : NULL; }
|
||||
|
||||
AssetRef<ImageAsset> mDefaultHandleAssetRef;
|
||||
GFXTexHandle getDefaultHandle() { return mDefaultHandleAssetRef.notNull() ? mDefaultHandleAssetRef.assetPtr->getTexture(&GFXStaticTextureSRGBProfile) : NULL; }
|
||||
|
||||
AssetRef<ImageAsset> mLockedHandleAssetRef;
|
||||
GFXTexHandle getLockedHandle() { return mLockedHandleAssetRef.notNull() ? mLockedHandleAssetRef.assetPtr->getTexture(&GFXStaticTextureSRGBProfile) : NULL; }
|
||||
|
||||
ColorI mObjectTextColor;
|
||||
bool mObjectsUseBoxCenter;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue