Skip to content

Commit

Permalink
Better slider highlighting by mouse hovering
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Jan 6, 2025
1 parent 49ba210 commit 75051b3
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 47 deletions.
43 changes: 28 additions & 15 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ typedef struct menu_s
#define M_SKIP -1,0 // Skippable, cursor can't get here.
#define M_SWTC 1,0 // On/off type or entering function.
#define M_LFRT 2,0 // Multichoice function.
#define M_SLD1 3,0 // Slider 1st line.
#define M_SLD2 4,0 // Slider 2st line.

// [JN] Small cursor timer for glowing effect.
static short cursor_tics = 0;
Expand Down Expand Up @@ -430,9 +432,9 @@ enum
static menuitem_t SoundMenu[]=
{
{ M_LFRT, "M_SFXVOL", M_SfxVol, 's' },
{ M_SKIP, "", 0, '\0' },
{ M_SLD1, "", 0, '\0' },
{ M_LFRT, "M_MUSVOL", M_MusicVol, 'm' },
{ M_SKIP, "", 0, '\0' }
{ M_SLD1, "", 0, '\0' }
};

static menu_t SoundDef =
Expand Down Expand Up @@ -1874,11 +1876,11 @@ static void M_ID_LocalTime (int choice)
static menuitem_t ID_Menu_Sound[]=
{
{ M_LFRT, "SFX VOLUME", M_SfxVol, 's' },
{ M_SKIP, "", 0, '\0' },
{ M_SKIP, "", 0, '\0' },
{ M_SLD1, "", 0, '\0' },
{ M_SLD2, "", 0, '\0' },
{ M_LFRT, "MUSIC VOLUME", M_MusicVol, 'm' },
{ M_SKIP, "", 0, '\0' },
{ M_SKIP, "", 0, '\0' },
{ M_SLD1, "", 0, '\0' },
{ M_SLD2, "", 0, '\0' },
{ M_SKIP, "", 0, '\0' },
{ M_LFRT, "SFX PLAYBACK", M_ID_SFXSystem, 's' },
{ M_LFRT, "MUSIC PLAYBACK", M_ID_MusicSystem, 'm' },
Expand Down Expand Up @@ -2167,14 +2169,14 @@ static menuitem_t ID_Menu_Controls[]=
{ M_SWTC, "MOUSE BINDINGS", M_Choose_ID_MouseBinds, 'm' },
{ M_SKIP, "", 0, '\0' },
{ M_LFRT, "SENSIVITY", M_ID_Controls_Sensivity, 's' },
{ M_SKIP, "", 0, '\0' },
{ M_SKIP, "", 0, '\0' },
{ M_SLD1, "", 0, '\0' },
{ M_SLD2, "", 0, '\0' },
{ M_LFRT, "ACCELERATION", M_ID_Controls_Acceleration, 'a' },
{ M_SKIP, "", 0, '\0' },
{ M_SKIP, "", 0, '\0' },
{ M_SLD1, "", 0, '\0' },
{ M_SLD2, "", 0, '\0' },
{ M_LFRT, "ACCELERATION THRESHOLD", M_ID_Controls_Threshold, 'a' },
{ M_SKIP, "", 0, '\0' },
{ M_SKIP, "", 0, '\0' },
{ M_SLD1, "", 0, '\0' },
{ M_SLD2, "", 0, '\0' },
{ M_LFRT, "MOUSE LOOK", M_ID_Controls_MLook, 'm' },
{ M_LFRT, "VERTICAL MOUSE MOVEMENT", M_ID_Controls_NoVert, 'v' },
{ M_LFRT, "INVERT VERTICAL AXIS", M_ID_Controls_InvertY, 'v' },
Expand Down Expand Up @@ -6461,7 +6463,9 @@ boolean M_Responder (event_t* ev)
do
{
itemOn = (itemOn + 1) % currentMenu->numitems;
} while (currentMenu->menuitems[itemOn].status == -1);
} while (currentMenu->menuitems[itemOn].status == -1 ||
currentMenu->menuitems[itemOn].status == 3 || // [JN] Skip sliders
currentMenu->menuitems[itemOn].status == 4);

S_StartSound(NULL, sfx_pstop);
return true;
Expand All @@ -6472,7 +6476,9 @@ boolean M_Responder (event_t* ev)
do
{
itemOn = (itemOn == 0) ? currentMenu->numitems - 1 : itemOn - 1;
} while (currentMenu->menuitems[itemOn].status == -1);
} while (currentMenu->menuitems[itemOn].status == -1 ||
currentMenu->menuitems[itemOn].status == 3 || // [JN] Skip sliders
currentMenu->menuitems[itemOn].status == 4);

S_StartSound(NULL, sfx_pstop);
return true;
Expand Down Expand Up @@ -6689,7 +6695,14 @@ static void M_ID_MenuMouseControl (void)
&& menu_mouse_y <= (currentMenu->y + (i + 1) * line_height) * vid_resolution
&& currentMenu->menuitems[i].status != -1)
{
itemOn = i; // [PN] Highlight the current menu item
// [PN] Highlight the current menu item
itemOn = i;

// [JN] Move menu cursor higher when hovering slider lines.
if (currentMenu->menuitems[itemOn].status == 3)
itemOn -= 1;
if (currentMenu->menuitems[itemOn].status == 4)
itemOn -= 2;
}
}
}
Expand Down
45 changes: 29 additions & 16 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ typedef enum
ITT_EFUNC,
ITT_LRFUNC,
ITT_SETMENU,
ITT_SLDR1, // Slider 1st line.
ITT_SLDR2, // Slider 2st line.
ITT_INERT
} ItemType_t;

Expand Down Expand Up @@ -369,11 +371,11 @@ static Menu_t OptionsMenu = {

static MenuItem_t Options2Items[] = {
{ ITT_LRFUNC, "SFX VOLUME", SCSfxVolume, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MUSIC VOLUME", SCMusicVolume, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "SCREEN SIZE", SCScreenSize, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
};

static Menu_t Options2Menu = {
Expand Down Expand Up @@ -1699,11 +1701,11 @@ static void M_ID_LocalTime (int choice)

static MenuItem_t ID_Menu_Sound[] = {
{ ITT_LRFUNC, "SFX VOLUME", SCSfxVolume, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MUSIC VOLUME", SCMusicVolume, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MUSIC PLAYBACK", M_ID_MusicSystem, 0, MENU_NONE },
{ ITT_LRFUNC, "SOUND EFFECTS MODE", M_ID_SFXMode, 0, MENU_NONE },
Expand Down Expand Up @@ -1890,14 +1892,14 @@ static MenuItem_t ID_Menu_Controls[] = {
{ ITT_SETMENU, "MOUSE BINDINGS", NULL, 0, MENU_ID_MOUSEBINDS },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "SENSIVITY", SCMouseSensi, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "ACCELERATION", M_ID_Controls_Acceleration, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "ACCELERATION THRESHOLD", M_ID_Controls_Threshold, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MOUSE LOOK", M_ID_Controls_MLook, 0, MENU_NONE },
{ ITT_LRFUNC, "VERTICAL MOUSE MOVEMENT", M_ID_Controls_NoVert, 0, MENU_NONE },
{ ITT_LRFUNC, "INVERT VERTICAL AXIS", M_ID_Controls_InvertY, 0, MENU_NONE },
Expand Down Expand Up @@ -4977,7 +4979,14 @@ static void M_ID_MenuMouseControl (void)
&& menu_mouse_y <= (CurrentMenu->y + (i + 1) * line_height) * vid_resolution
&& CurrentMenu->items[i].type != ITT_EMPTY)
{
CurrentItPos = i; // [PN] Highlight the current menu item
// [PN] Highlight the current menu item
CurrentItPos = i;

// [JN] Move menu cursor higher when hovering slider lines.
if (CurrentMenu->items[i].type == ITT_SLDR1)
CurrentItPos -= 1;
if (CurrentMenu->items[i].type == ITT_SLDR2)
CurrentItPos -= 2;
}
}
}
Expand Down Expand Up @@ -6422,7 +6431,9 @@ boolean MN_Responder(event_t * event)
CurrentItPos++;
}
}
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY ||
CurrentMenu->items[CurrentItPos].type == ITT_SLDR1 || // [JN] Skip sliders
CurrentMenu->items[CurrentItPos].type == ITT_SLDR2);
S_StartSound(NULL, sfx_switch);
return (true);
}
Expand All @@ -6439,7 +6450,9 @@ boolean MN_Responder(event_t * event)
CurrentItPos--;
}
}
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY ||
CurrentMenu->items[CurrentItPos].type == ITT_SLDR1 || // [JN] Skip sliders
CurrentMenu->items[CurrentItPos].type == ITT_SLDR2);
S_StartSound(NULL, sfx_switch);
return (true);
}
Expand Down
45 changes: 29 additions & 16 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ typedef enum
ITT_EFUNC,
ITT_LRFUNC,
ITT_SETMENU,
ITT_SLDR1, // Slider 1st line.
ITT_SLDR2, // Slider 2st line.
ITT_INERT
} ItemType_t;

Expand Down Expand Up @@ -377,11 +379,11 @@ static Menu_t OptionsMenu = {

static MenuItem_t Options2Items[] = {
{ ITT_LRFUNC, "SFX VOLUME", SCSfxVolume, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MUSIC VOLUME", SCMusicVolume, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "SCREEN SIZE", SCScreenSize, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
};

static Menu_t Options2Menu = {
Expand Down Expand Up @@ -1656,11 +1658,11 @@ static void M_ID_LocalTime (int choice)

static MenuItem_t ID_Menu_Sound[] = {
{ ITT_LRFUNC, "SFX VOLUME", SCSfxVolume, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MUSIC VOLUME", SCMusicVolume, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MUSIC PLAYBACK", M_ID_MusicSystem, 0, MENU_NONE },
{ ITT_LRFUNC, "SOUND EFFECTS MODE", M_ID_SFXMode, 0, MENU_NONE },
Expand Down Expand Up @@ -1847,14 +1849,14 @@ static MenuItem_t ID_Menu_Controls[] = {
{ ITT_SETMENU, "MOUSE BINDINGS", NULL, 0, MENU_ID_MOUSEBINDS },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "SENSIVITY", SCMouseSensi, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "ACCELERATION", M_ID_Controls_Acceleration, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "ACCELERATION THRESHOLD", M_ID_Controls_Threshold, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR1, NULL, NULL, 0, MENU_NONE },
{ ITT_SLDR2, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "MOUSE LOOK", M_ID_Controls_MLook, 0, MENU_NONE },
{ ITT_LRFUNC, "VERTICAL MOUSE MOVEMENT", M_ID_Controls_NoVert, 0, MENU_NONE },
{ ITT_LRFUNC, "INVERT VERTICAL AXIS", M_ID_Controls_InvertY, 0, MENU_NONE },
Expand Down Expand Up @@ -4300,7 +4302,14 @@ static void M_ID_MenuMouseControl (void)
&& menu_mouse_y <= (CurrentMenu->y + (i + 1) * line_height) * vid_resolution
&& CurrentMenu->items[i].type != ITT_EMPTY)
{
CurrentItPos = i; // [PN] Highlight the current menu item
// [PN] Highlight the current menu item
CurrentItPos = i;

// [JN] Move menu cursor higher when hovering slider lines.
if (CurrentMenu->items[i].type == ITT_SLDR1)
CurrentItPos -= 1;
if (CurrentMenu->items[i].type == ITT_SLDR2)
CurrentItPos -= 2;
}
}
}
Expand Down Expand Up @@ -5883,7 +5892,9 @@ boolean MN_Responder(event_t * event)
CurrentItPos++;
}
}
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY ||
CurrentMenu->items[CurrentItPos].type == ITT_SLDR1 || // [JN] Skip sliders
CurrentMenu->items[CurrentItPos].type == ITT_SLDR2);
S_StartSound(NULL, SFX_FIGHTER_HAMMER_HITWALL);
return (true);
}
Expand All @@ -5900,7 +5911,9 @@ boolean MN_Responder(event_t * event)
CurrentItPos--;
}
}
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY ||
CurrentMenu->items[CurrentItPos].type == ITT_SLDR1 || // [JN] Skip sliders
CurrentMenu->items[CurrentItPos].type == ITT_SLDR2);
S_StartSound(NULL, SFX_FIGHTER_HAMMER_HITWALL);
return (true);
}
Expand Down

4 comments on commit 75051b3

@Meerschweinmann
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oha, does this commit mean that sliders are mouse friendly?

@JNechaevsky
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not really. Sliders now just highlighted when mouse cursor covers them, Not only when cursor was hovering menu item text from above.

@JNechaevsky
Copy link
Owner Author

@JNechaevsky JNechaevsky commented on 75051b3 Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, some success:

bandicam.2025-01-08.16-32-49-533.mp4

There still work to do, but at least some basic logic of "put slider where cursor is" is working.

@Meerschweinmann
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍😀

Please sign in to comment.