fill in the validated variables

This commit is contained in:
AzaezelX 2025-03-09 11:53:23 -05:00
parent fa760fa746
commit f633ef3a3d
184 changed files with 1359 additions and 1216 deletions

View file

@ -28,6 +28,7 @@
#include "console/engineAPI.h"
#include "gfx/gfxDevice.h"
#include "gfx/gfxDrawUtil.h"
#include "console/typeValidators.h"
@ -89,7 +90,7 @@ void guiAnimBitmapCtrl::initPersistFields()
addField("reverse", TypeBool, Offset(mReverse, guiAnimBitmapCtrl), "play reversed?");
addField("fps", TypeS32, Offset(mFramesPerSec, guiAnimBitmapCtrl), "Frame Rate");
addProtectedField("curFrame", TypeS32, Offset(mCurFrameIndex, guiAnimBitmapCtrl), &ptSetFrame, &defaultProtectedGetFn, "Index of currently Displaying Frame ");
addProtectedFieldV("curFrame", TypeRangedS32, Offset(mCurFrameIndex, guiAnimBitmapCtrl), &ptSetFrame, &defaultProtectedGetFn, &CommonValidators::S32Range, "Index of currently Displaying Frame ");
Parent::initPersistFields();
removeField("wrap");
@ -126,16 +127,21 @@ bool guiAnimBitmapCtrl::ptSetFrame(void *object, const char *index, const char *
S32 val = dAtoi(data);
if (val < 0)
if ((val < 0) || (val >pData->mNumFrames))
{
pData->mCurFrameIndex = pData->mNumFrames;
if (pData->mLoop)
{
int len = pData->mNumFrames;
val = (val >= 0 ? val % len : -val % len ? len - (-val % len) : 0);
}
else
{
if (val < 0) val = 0;
if (val >pData->mNumFrames) val = pData->mNumFrames;
}
pData->mCurFrameIndex = val;
return false;
}
else if (val > pData->mNumFrames)
{
pData->mCurFrameIndex = 0;
return false;
};
pData->mCurFrameIndex = val;
return true;

View file

@ -44,7 +44,7 @@ GuiBitmapBarCtrl::GuiBitmapBarCtrl(void)
void GuiBitmapBarCtrl::initPersistFields()
{
docsURL;
addField("percent", TypeF32, Offset(mPercent, GuiBitmapBarCtrl),
addFieldV("percent", TypeRangedF32, Offset(mPercent, GuiBitmapBarCtrl), &CommonValidators::NormalizedFloat,
"% shown");
addField("vertical", TypeBool, Offset(mVertical, GuiBitmapBarCtrl),
"If true, the bitmap is clipped vertically.");

View file

@ -88,7 +88,7 @@ void GuiBitmapCtrl::initPersistFields()
addField( "wrap", TypeBool, Offset( mWrap, GuiBitmapCtrl ),
"If true, the bitmap is tiled inside the control rather than stretched to fit." );
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
addFieldV("angle", TypeRangedF32, Offset(mAngle, GuiBitmapCtrl), &CommonValidators::DegreeRange, "rotation");
endGroup( "Bitmap" );

View file

@ -29,6 +29,26 @@
#include "gui/controls/guiColorPicker.h"
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "console/typeValidators.h"
/// @name Common colors we use
/// @{
LinearColorF colorWhite(1.,1.,1.);
LinearColorF colorWhiteBlend(1.,1.,1.,.75);
LinearColorF colorBlack(.0,.0,.0);
LinearColorF colorAlpha(0.0f, 0.0f, 0.0f, 0.0f);
LinearColorF colorAlphaW(1.0f, 1.0f, 1.0f, 0.0f);
ColorI GuiColorPickerCtrl::mColorRange[7] = {
ColorI(255,0,0), // Red
ColorI(255,0,255), // Pink
ColorI(0,0,255), // Blue
ColorI(0,255,255), // Light blue
ColorI(0,255,0), // Green
ColorI(255,255,0), // Yellow
ColorI(255,0,0), // Red
};
/// @}
#include "postFx/postEffectManager.h"
#include "gfx/screenshot.h"
@ -91,7 +111,9 @@ void GuiColorPickerCtrl::initPersistFields()
{
docsURL;
addGroup("ColorPicker");
addField("selectorGap", TypeS32, Offset(mSelectorGap, GuiColorPickerCtrl));
addField("baseColor", TypeColorF, Offset(mBaseColor, GuiColorPickerCtrl));
addField("pickColor", TypeColorF, Offset(mPickColor, GuiColorPickerCtrl));
addFieldV("selectorGap", TypeRangedS32, Offset(mSelectorGap, GuiColorPickerCtrl),&CommonValidators::NaturalNumber);
addField("displayMode", TYPEID< PickMode >(), Offset(mDisplayMode, GuiColorPickerCtrl) );
addField("selectorMode", TYPEID< SelectorMode >(), Offset(mSelectorMode, GuiColorPickerCtrl) );
addField("actionOnMove", TypeBool,Offset(mActionOnMove, GuiColorPickerCtrl));

View file

@ -29,6 +29,7 @@
#include "gui/containers/guiScrollCtrl.h"
#include "sim/actionMap.h"
#include "core/strings/stringUnit.h"
#include "console/typeValidators.h"
//-----------------------------------------------------------------------------
// GuiGameListMenuCtrl
@ -1878,10 +1879,10 @@ void GuiGameListMenuProfile::initPersistFields()
addField( "rowSize", TypePoint2I, Offset(mRowSize, GuiGameListMenuProfile),
"The base size (\"width height\") of a row" );
addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListMenuProfile),
addFieldV("columnSplit", TypeRangedS32, Offset(mColumnSplit, GuiGameListMenuProfile), &CommonValidators::PositiveInt,
"Padding between the leftmost edge of the control, and the row's left arrow.");
addField("rightPad", TypeS32, Offset(mRightPad, GuiGameListMenuProfile),
addFieldV("rightPad", TypeRangedS32, Offset(mRightPad, GuiGameListMenuProfile), &CommonValidators::PositiveInt,
"Padding between the rightmost edge of the control and the row's right arrow.");
Parent::initPersistFields();

View file

@ -544,10 +544,10 @@ ConsoleDocClass( GuiGameListOptionsProfile,
void GuiGameListOptionsProfile::initPersistFields()
{
docsURL;
addField( "columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListOptionsProfile),
addFieldV( "columnSplit", TypeRangedS32, Offset(mColumnSplit, GuiGameListOptionsProfile), &CommonValidators::PositiveInt,
"Padding between the leftmost edge of the control, and the row's left arrow." );
addField( "rightPad", TypeS32, Offset(mRightPad, GuiGameListOptionsProfile),
addFieldV( "rightPad", TypeRangedS32, Offset(mRightPad, GuiGameListOptionsProfile), &CommonValidators::PositiveInt,
"Padding between the rightmost edge of the control and the row's right arrow." );
Parent::initPersistFields();

View file

@ -29,6 +29,7 @@
#include "gui/containers/guiScrollCtrl.h"
#include "core/strings/stringUnit.h"
#include "gui/core/guiDefaultControlRender.h"
#include "console/typeValidators.h"
//-----------------------------------------------------------------------------
// GuiGameSettingsCtrl
@ -844,13 +845,13 @@ void GuiGameSettingsCtrl::initPersistFields()
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.");
addField("arrowSize", TypeS32, Offset(mArrowSize, GuiGameSettingsCtrl),
addFieldV("arrowSize", TypeRangedS32, Offset(mArrowSize, GuiGameSettingsCtrl), &CommonValidators::PositiveInt,
"Size of the arrow buttons' extents");
addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameSettingsCtrl),
addFieldV("columnSplit", TypeRangedS32, Offset(mColumnSplit, GuiGameSettingsCtrl), &CommonValidators::NaturalNumber,
"Position of the split between the leftside label and the rightside setting parts");
addField("rightPad", TypeS32, Offset(mRightPad, GuiGameSettingsCtrl),
addFieldV("rightPad", TypeRangedS32, Offset(mRightPad, GuiGameSettingsCtrl), &CommonValidators::NaturalNumber,
"Padding between the rightmost edge of the control and right arrow.");
addField("callbackOnA", TypeString, Offset(mCallbackOnA, GuiGameSettingsCtrl),

View file

@ -32,6 +32,7 @@
#include "sfx/sfxTrack.h"
#include "sfx/sfxTypes.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
IMPLEMENT_CONOBJECT( GuiMLTextCtrl );
@ -301,18 +302,18 @@ void GuiMLTextCtrl::initPersistFields()
docsURL;
addGroup( "Text" );
addField("lineSpacing", TypeS32, Offset(mLineSpacingPixels, GuiMLTextCtrl), "The number of blank pixels to place between each line.\n");
addFieldV("lineSpacing", TypeRangedS32, Offset(mLineSpacingPixels, GuiMLTextCtrl), &CommonValidators::PositiveInt, "The number of blank pixels to place between each line.\n");
addField("allowColorChars", TypeBool, Offset(mAllowColorChars, GuiMLTextCtrl), "If true, the control will allow characters to have unique colors.");
addField("maxChars", TypeS32, Offset(mMaxBufferSize, GuiMLTextCtrl), "Maximum number of characters that the control will display.");
addFieldV("maxChars", TypeRangedS32, Offset(mMaxBufferSize, GuiMLTextCtrl), &CommonValidators::NegDefaultInt, "Maximum number of characters that the control will display.");
INITPERSISTFIELD_SOUNDASSET(DeniedSound, GuiMLTextCtrl, "If the text will not fit in the control, the deniedSound is played.");
addField("text", TypeCaseString, Offset( mInitialText, GuiMLTextCtrl ), "Text to display in this control.");
addField("useURLMouseCursor", TypeBool, Offset(mUseURLMouseCursor, GuiMLTextCtrl), "If true, the mouse cursor will turn into a hand cursor while over a link in the text.\n"
"This is dependant on the markup language used by the GuiMLTextCtrl\n");
addField("useTypeOverTime", TypeBool, Offset(mUseTypeOverTime, GuiMLTextCtrl), "");
addField("typeOverTimeSpeedMS", TypeF32, Offset(mTypeOverTimeSpeedMS, GuiMLTextCtrl), "");
addFieldV("typeOverTimeSpeedMS", TypeRangedF32, Offset(mTypeOverTimeSpeedMS, GuiMLTextCtrl), &CommonValidators::PositiveFloat, "");
addField("typeoutSound", TypeSFXTrackName, Offset(mTypeoutSound, GuiMLTextCtrl), "Played when the text is being typed out");
addField("typeoutSoundRate", TypeS32, Offset(mTypeoutSoundRate, GuiMLTextCtrl), "Dictates how many characters must be typed out before the sound is played again. -1 for the sound to only play once at the start.");
addFieldV("typeoutSoundRate", TypeRangedS32, Offset(mTypeoutSoundRate, GuiMLTextCtrl), &CommonValidators::NegDefaultInt, "Dictates how many characters must be typed out before the sound is played again. -1 for the sound to only play once at the start.");
endGroup( "Text" );

View file

@ -298,7 +298,7 @@ GuiPopUpMenuCtrl::~GuiPopUpMenuCtrl()
void GuiPopUpMenuCtrl::initPersistFields(void)
{
docsURL;
addField("maxPopupHeight", TypeS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrl));
addFieldV("maxPopupHeight", TypeRangedS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrl), &CommonValidators::PositiveInt);
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));

View file

@ -28,6 +28,7 @@
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
ConsoleDocClass( GuiPopUpMenuCtrlEx,
"@brief A control that allows to select a value from a drop-down list.\n\n"
@ -352,7 +353,7 @@ GuiPopUpMenuCtrlEx::~GuiPopUpMenuCtrlEx()
void GuiPopUpMenuCtrlEx::initPersistFields(void)
{
docsURL;
addField("maxPopupHeight", TypeS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrlEx), "Length of menu when it extends");
addFieldV("maxPopupHeight", TypeRangedS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrlEx), &CommonValidators::PositiveInt, "Length of menu when it extends");
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
@ -1236,7 +1237,7 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
localStart.x = getWidth() - txt_w - 12;
}
}
}
else
{
localStart.x = mProfile->mTextOffset.x; // Use mProfile->mTextOffset as a controlable margin for the control's text.

View file

@ -96,7 +96,7 @@ void GuiTextCtrl::initPersistFields()
addField( "textID", TypeString, Offset( mInitialTextID, GuiTextCtrl ),
"Maps the text of this control to a variable used in localization, rather than raw text.");
addField( "maxLength", TypeS32, Offset( mMaxStrLen, GuiTextCtrl ),
addFieldV( "maxLength", TypeRangedS32, Offset( mMaxStrLen, GuiTextCtrl ), &CommonValidators::PositiveInt,
"Defines the maximum length of the text. The default is 1024." );
Parent::initPersistFields();

View file

@ -36,6 +36,7 @@
#include "sfx/sfxSystem.h"
#include "core/strings/unicode.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
IMPLEMENT_CONOBJECT(GuiTextEditCtrl);
@ -177,7 +178,7 @@ void GuiTextEditCtrl::initPersistFields()
addField("validate", TypeRealString,Offset(mValidateCommand, GuiTextEditCtrl), "Script command to be called when the first validater is lost.\n");
addField("escapeCommand", TypeRealString,Offset(mEscapeCommand, GuiTextEditCtrl), "Script command to be called when the Escape key is pressed.\n");
addField("historySize", TypeS32, Offset(mHistorySize, GuiTextEditCtrl), "How large of a history buffer to maintain.\n");
addFieldV("historySize", TypeRangedS32, Offset(mHistorySize, GuiTextEditCtrl), &CommonValidators::PositiveInt, "How large of a history buffer to maintain.\n");
addField("tabComplete", TypeBool, Offset(mTabComplete, GuiTextEditCtrl), "If true, when the 'tab' key is pressed, it will act as if the Enter key was pressed on the control.\n");
addField("deniedSound", TypeSFXTrackName, Offset(mDeniedSound, GuiTextEditCtrl), "If the attempted text cannot be entered, this sound effect will be played.\n");
addField("sinkAllKeyEvents", TypeBool, Offset(mSinkAllKeyEvents, GuiTextEditCtrl), "If true, every key event will act as if the Enter key was pressed.\n");

View file

@ -341,6 +341,8 @@ void GuiTextEditSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
mIncCounter = (mIncCounter > 0.0f) ? mIncCounter-1 : mIncCounter+1;
checkRange();
setValue();
execConsoleCallback();
execAltConsoleCallback();
mCursorPos = 0;
}
}

View file

@ -29,6 +29,7 @@
#include "gui/core/guiDefaultControlRender.h"
#include "gfx/gfxDrawUtil.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
IMPLEMENT_CONOBJECT(GuiTextListCtrl);
@ -134,7 +135,7 @@ void GuiTextListCtrl::initPersistFields()
addField("columns", TypeS32Vector, Offset(mColumnOffsets, GuiTextListCtrl), "A vector of column offsets. The number of values determines the number of columns in the table.\n" );
addField("fitParentWidth", TypeBool, Offset(mFitParentWidth, GuiTextListCtrl), "If true, the width of this control will match the width of its parent.\n");
addField("clipColumnText", TypeBool, Offset(mClipColumnText, GuiTextListCtrl), "If true, text exceeding a column's given width will get clipped.\n" );
addField("rowHeightPadding", TypeS32, Offset(mRowHeightPadding, GuiTextListCtrl), "Sets how much padding to add to the row heights on top of the font height");
addFieldV("rowHeightPadding", TypeRangedS32, Offset(mRowHeightPadding, GuiTextListCtrl), &CommonValidators::PositiveInt, "Sets how much padding to add to the row heights on top of the font height");
Parent::initPersistFields();
}

View file

@ -883,10 +883,10 @@ void GuiTreeViewCtrl::initPersistFields()
docsURL;
addGroup( "TreeView" );
addField( "tabSize", TypeS32, Offset(mTabSize, GuiTreeViewCtrl));
addFieldV( "tabSize", TypeRangedS32, Offset(mTabSize, GuiTreeViewCtrl), &CommonValidators::PositiveInt);
addField( "textOffset", TypeS32, Offset(mTextOffset, GuiTreeViewCtrl));
addField( "fullRowSelect", TypeBool, Offset(mFullRowSelect, GuiTreeViewCtrl));
addField( "itemHeight", TypeS32, Offset(mItemHeight, GuiTreeViewCtrl));
addFieldV( "itemHeight", TypeRangedS32, Offset(mItemHeight, GuiTreeViewCtrl), &CommonValidators::PositiveInt);
addField( "destroyTreeOnSleep", TypeBool, Offset(mDestroyOnSleep, GuiTreeViewCtrl),
"If true, the entire tree item hierarchy is deleted when the control goes to sleep." );
addField( "mouseDragging", TypeBool, Offset(mSupportMouseDragging, GuiTreeViewCtrl));