consvar_t: add step_amount field, used by menus

This commit is contained in:
James R 2023-12-31 18:59:26 -08:00
parent 99baf4e8e1
commit 9df8dd2bc0
3 changed files with 9 additions and 2 deletions

View file

@ -156,6 +156,7 @@ struct consvar_t //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NULL
INT32 flags; // flags see cvflags_t above INT32 flags; // flags see cvflags_t above
CV_PossibleValue_t *PossibleValue; // table of possible values CV_PossibleValue_t *PossibleValue; // table of possible values
void (*func)(void); // called on change, if CV_CALL set void (*func)(void); // called on change, if CV_CALL set
INT32 step_amount;
const char *description; const char *description;
INT32 value; // for INT32 and fixed_t INT32 value; // for INT32 and fixed_t
const char *string; // value in string const char *string; // value in string
@ -217,7 +218,7 @@ struct CVarList;
#define CVAR_INIT consvar_t #define CVAR_INIT consvar_t
#else #else
#define CVAR_INIT( ... ) \ #define CVAR_INIT( ... ) \
{ __VA_ARGS__, NULL, 0, NULL, NULL, {0, {NULL}}, 0U, (char)0, NULL } { __VA_ARGS__, 0, NULL, 0, NULL, NULL, {0, {NULL}}, 0U, (char)0, NULL }
#endif #endif
extern consvar_t *consvar_vars; // list of registered console variables extern consvar_t *consvar_vars; // list of registered console variables

View file

@ -92,6 +92,12 @@ struct consvar_t::Builder
return *this; return *this;
} }
Builder& step_amount(INT32 step_amount)
{
var_.step_amount = step_amount;
return *this;
}
Builder& save() Builder& save()
{ {
var_.flags |= CV_SAVE; var_.flags |= CV_SAVE;

View file

@ -168,7 +168,7 @@ void M_ChangeCvarDirect(INT32 choice, consvar_t *cv)
} }
else if (cv->flags & CV_FLOAT) else if (cv->flags & CV_FLOAT)
{ {
M_AddFloatVar(cv, (FRACUNIT/16) * choice); M_AddFloatVar(cv, (cv->step_amount ? cv->step_amount : FRACUNIT/16) * choice);
} }
else else
{ {