Skip to content

Commit

Permalink
Update int/float slider functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Jan 12, 2025
1 parent 404cc03 commit 1be4f63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type)
return NULL;
}

static const int M_INT_Slider (int val, int min, int max, int direction, boolean capped)
static int M_INT_Slider (int val, int min, int max, int direction, boolean capped)
{
// [PN] Adjust the slider value based on direction and handle min/max limits
val += (direction == -1) ? 0 : // [JN] Routine "-1" just reintializes value.
Expand All @@ -1200,11 +1200,12 @@ static const int M_INT_Slider (int val, int min, int max, int direction, boolean
return val;
}

static const float M_FLOAT_Slider (float val, float min, float max, float step,
int direction, boolean capped)
static float M_FLOAT_Slider (float val, float min, float max, float step,
int direction, boolean capped)
{
// [PN] Adjust value based on direction
val += (direction == 0) ? -step : step;
val += (direction == -1) ? 0 : // [JN] Routine "-1" just reintializes value.
(direction == 0) ? -step : step; // Otherwise, move either left "0" or right "1".

// [PN] Handle min/max limits
if (val < min)
Expand Down
9 changes: 5 additions & 4 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type)
return NULL;
}

static const int M_INT_Slider (int val, int min, int max, int direction, boolean capped)
static int M_INT_Slider (int val, int min, int max, int direction, boolean capped)
{
// [PN] Adjust the slider value based on direction and handle min/max limits
val += (direction == -1) ? 0 : // [JN] Routine "-1" just reintializes value.
Expand All @@ -1070,11 +1070,12 @@ static const int M_INT_Slider (int val, int min, int max, int direction, boolean
return val;
}

static const float M_FLOAT_Slider (float val, float min, float max, float step,
int direction, boolean capped)
static float M_FLOAT_Slider (float val, float min, float max, float step,
int direction, boolean capped)
{
// [PN] Adjust value based on direction
val += (direction == 0) ? -step : step;
val += (direction == -1) ? 0 : // [JN] Routine "-1" just reintializes value.
(direction == 0) ? -step : step; // Otherwise, move either left "0" or right "1".

// [PN] Handle min/max limits
if (val < min)
Expand Down
9 changes: 5 additions & 4 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type)
}


static const int M_INT_Slider (int val, int min, int max, int direction, boolean capped)
static int M_INT_Slider (int val, int min, int max, int direction, boolean capped)
{
// [PN] Adjust the slider value based on direction and handle min/max limits
val += (direction == -1) ? 0 : // [JN] Routine "-1" just reintializes value.
Expand All @@ -1023,11 +1023,12 @@ static const int M_INT_Slider (int val, int min, int max, int direction, boolean
return val;
}

static const float M_FLOAT_Slider (float val, float min, float max, float step,
int direction, boolean capped)
static float M_FLOAT_Slider (float val, float min, float max, float step,
int direction, boolean capped)
{
// [PN] Adjust value based on direction
val += (direction == 0) ? -step : step;
val += (direction == -1) ? 0 : // [JN] Routine "-1" just reintializes value.
(direction == 0) ? -step : step; // Otherwise, move either left "0" or right "1".

// [PN] Handle min/max limits
if (val < min)
Expand Down

0 comments on commit 1be4f63

Please sign in to comment.