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:
JeffR 2026-06-16 17:39:30 -05:00
parent a858d8624e
commit 34e3f78a22
82 changed files with 1451 additions and 951 deletions

View file

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

View file

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

View file

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

View file

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