review notes from Az

Should render fallback for namedTarget if namedTarget fails
Add safety around namedtarget getTexture to stop assert
Missing assets should revert to fallback image and print a warning to console
Remove REFACTOR tag from all macros.
This commit is contained in:
marauder2k7 2025-03-30 11:22:42 +01:00
parent b707b2e2b7
commit 73ad92b757
60 changed files with 189 additions and 164 deletions

View file

@ -141,7 +141,7 @@ void GuiBitmapButtonCtrl::initPersistFields()
docsURL;
addGroup( "Bitmap" );
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiBitmapButtonCtrl,"Texture file to display on this button.\n"
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapButtonCtrl,"Texture file 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.")

View file

@ -127,7 +127,7 @@ void GuiIconButtonCtrl::initPersistFields()
addField( "buttonMargin", TypePoint2I, Offset( mButtonMargin, GuiIconButtonCtrl ),"Margin area around the button.\n");
addProtectedField( "iconBitmap", TypeImageFilename, Offset( mBitmapAsset, GuiIconButtonCtrl ), &_setBitmapData, &defaultProtectedGetFn, "Bitmap file for the icon to display on the button.\n", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiIconButtonCtrl, "Bitmap file for the icon to display on the button.\n");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiIconButtonCtrl, "Bitmap file for the icon to display on the button.\n");
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");

View file

@ -42,7 +42,7 @@ private:
protected:
DECLARE_IMAGEASSET_REFACTOR(GuiIconButtonCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiIconButtonCtrl, Bitmap, GFXDefaultGUIProfile)
S32 mIconLocation;
S32 mTextLocation;

View file

@ -55,9 +55,9 @@ GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
void GuiToolboxButtonCtrl::initPersistFields()
{
docsURL;
INITPERSISTFIELD_IMAGEASSET_REFACTOR(NormalBitmap, GuiToolboxButtonCtrl, "");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(LoweredBitmap, GuiToolboxButtonCtrl, "");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(HoverBitmap, GuiToolboxButtonCtrl, "");
INITPERSISTFIELD_IMAGEASSET(NormalBitmap, GuiToolboxButtonCtrl, "");
INITPERSISTFIELD_IMAGEASSET(LoweredBitmap, GuiToolboxButtonCtrl, "");
INITPERSISTFIELD_IMAGEASSET(HoverBitmap, GuiToolboxButtonCtrl, "");
Parent::initPersistFields();
}

View file

@ -39,9 +39,9 @@ private:
protected:
DECLARE_IMAGEASSET_REFACTOR(GuiToolboxButtonCtrl, NormalBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiToolboxButtonCtrl, LoweredBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiToolboxButtonCtrl, HoverBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, NormalBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, LoweredBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, HoverBitmap, GFXDefaultGUIProfile)
void renderButton(GFXTexHandle texture, Point2I &offset, const RectI& updateRect);
void renderStateRect( GFXTexHandle texture, const RectI& rect );

View file

@ -70,7 +70,7 @@ void GuiBitmapCtrl::initPersistFields()
docsURL;
addGroup("Bitmap");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiBitmapCtrl, "The bitmap to render in this BitmapCtrl.")
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapCtrl, "The bitmap 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.");

View file

@ -39,7 +39,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_REFACTOR(GuiBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
Point2I mStartPoint;
ColorI mColor;

View file

@ -826,9 +826,9 @@ IMPLEMENT_CALLBACK(GuiGameSettingsCtrl, onAxisEvent, void, (const char* device,
void GuiGameSettingsCtrl::initPersistFields()
{
docsURL;
INITPERSISTFIELD_IMAGEASSET_REFACTOR(KeybindBitmap, GuiGameSettingsCtrl, "Bitmap used to display the bound key for this keybind option.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(PreviousBitmap, GuiGameSettingsCtrl, "Bitmap used for the previous button when in list mode.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(NextBitmap, GuiGameSettingsCtrl, "Bitmap used for the next button when in list mode.");
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.");
addFieldV("arrowSize", TypeRangedS32, Offset(mArrowSize, GuiGameSettingsCtrl), &CommonValidators::PositiveInt,
"Size of the arrow buttons' extents");

View file

@ -72,9 +72,9 @@ protected:
Point2F mRange; ///< When working as a slider, this sets our min/max range
//Keybind option
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, KeybindBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, PreviousBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET_REFACTOR(GuiGameSettingsCtrl, NextBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, GFXDefaultGUIProfile)
S32 mArrowSize;
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.

View file

@ -126,7 +126,7 @@ protected:
NumBitmapModes = 2
};
DECLARE_IMAGEASSET_ARRAY_REFACTOR(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
Point2I mBitmapBounds; // Added
S32 mIdMax;

View file

@ -131,7 +131,7 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
NumBitmapModes = 2
};
DECLARE_IMAGEASSET_ARRAY_REFACTOR(GuiPopUpMenuCtrlEx, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
Point2I mBitmapBounds; // Added

View file

@ -91,7 +91,7 @@ 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_REFACTOR(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
Parent::initPersistFields();
}

View file

@ -348,7 +348,7 @@ class GuiCursor : public SimObject
private:
typedef SimObject Parent;
DECLARE_IMAGEASSET_REFACTOR(GuiCursor, Bitmap, GFXGuiCursorProfile)
DECLARE_IMAGEASSET(GuiCursor, Bitmap, GFXGuiCursorProfile)
Point2I mHotSpot;
Point2F mRenderOffset;
@ -458,7 +458,7 @@ public:
///
public:
DECLARE_IMAGEASSET_REFACTOR(GuiControlProfile, Bitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiControlProfile, Bitmap, GFXDefaultGUIProfile)
GFXTexHandle mBitmap;
StringTableEntry mBitmapName;

View file

@ -67,7 +67,7 @@ void GuiChunkedBitmapCtrl::initPersistFields()
{
docsURL;
addGroup("GuiChunkedBitmapCtrl");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap to render to the control.");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap 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\"");

View file

@ -17,7 +17,7 @@ private:
protected:
DECLARE_IMAGEASSET_REFACTOR(GuiChunkedBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
bool mUseVariable;
bool mTile;

View file

@ -131,7 +131,7 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
void GuiProgressBitmapCtrl::initPersistFields()
{
docsURL;
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiProgressBitmapCtrl, "Bitmap file to use for rendering the progress bar.\n\n"
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiProgressBitmapCtrl, "Bitmap file 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.");

View file

@ -47,7 +47,7 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
F32 mProgress;
DECLARE_IMAGEASSET_REFACTOR(GuiProgressBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
bool mUseVariable;
bool mTile;

View file

@ -88,7 +88,7 @@ void GuiMissionAreaCtrl::initPersistFields()
docsURL;
addField( "squareBitmap", TypeBool, Offset(mSquareBitmap, GuiMissionAreaCtrl));
INITPERSISTFIELD_IMAGEASSET_REFACTOR(HandleBitmap, GuiMissionAreaCtrl, "Bitmap for the mission area handles.\n");
INITPERSISTFIELD_IMAGEASSET(HandleBitmap, GuiMissionAreaCtrl, "Bitmap for the mission area handles.\n");
addField( "missionBoundsColor", TypeColorI, Offset(mMissionBoundsColor, GuiMissionAreaCtrl));
addField( "cameraColor", TypeColorI, Offset(mCameraColor, GuiMissionAreaCtrl));

View file

@ -63,7 +63,7 @@ protected:
GFXStateBlockRef mBlendStateBlock;
GFXStateBlockRef mSolidStateBlock;
DECLARE_IMAGEASSET_REFACTOR(GuiMissionAreaCtrl, HandleBitmap, GFXDefaultGUIProfile)
DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, GFXDefaultGUIProfile)
Point2I mHandleTextureSize;
Point2F mHandleTextureHalfSize;

View file

@ -2839,9 +2839,9 @@ void WorldEditor::initPersistFields()
addField( "renderObjHandle", TypeBool, Offset(mRenderObjHandle, WorldEditor) );
addField( "renderSelectionBox", TypeBool, Offset(mRenderSelectionBox, WorldEditor) );
INITPERSISTFIELD_IMAGEASSET_REFACTOR(SelectHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(DefaultHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(LockedHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET(SelectHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET(DefaultHandle, WorldEditor, "");
INITPERSISTFIELD_IMAGEASSET(LockedHandle, WorldEditor, "");
endGroup( "Rendering" );

View file

@ -328,9 +328,9 @@ class WorldEditor : public EditTSCtrl
ColorI mPopupBackgroundColor;
ColorI mPopupTextColor;
DECLARE_IMAGEASSET_REFACTOR(WorldEditor, SelectHandle, GFXStaticTextureSRGBProfile)
DECLARE_IMAGEASSET_REFACTOR(WorldEditor, DefaultHandle, GFXStaticTextureSRGBProfile)
DECLARE_IMAGEASSET_REFACTOR(WorldEditor, LockedHandle, GFXStaticTextureSRGBProfile)
DECLARE_IMAGEASSET(WorldEditor, SelectHandle, GFXStaticTextureSRGBProfile)
DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, GFXStaticTextureSRGBProfile)
DECLARE_IMAGEASSET(WorldEditor, LockedHandle, GFXStaticTextureSRGBProfile)
ColorI mObjectTextColor;
bool mObjectsUseBoxCenter;