Skip to content

Commit

Permalink
Implement static menu highlighting effect
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Feb 7, 2025
1 parent 5ca321c commit 30e8979
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 57 deletions.
35 changes: 22 additions & 13 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,6 @@ static void M_FillBackground (void)

static byte *M_Small_Line_Glow (int tics)
{
if (!menu_highlight)
return NULL;

return
tics == 5 ? cr[CR_MENU_BRIGHT5] :
tics == 4 ? cr[CR_MENU_BRIGHT4] :
Expand All @@ -970,9 +967,6 @@ static byte *M_Small_Line_Glow (int tics)

static byte *M_Big_Line_Glow (int tics)
{
if (!menu_highlight)
return NULL;

return
tics == 5 ? cr[CR_MENU_BRIGHT3] :
tics >= 3 ? cr[CR_MENU_BRIGHT2] :
Expand Down Expand Up @@ -4000,7 +3994,7 @@ static menuitem_t ID_Menu_Misc[]=
{ M_LFRT, "AUTOLOAD WAD FILES", M_ID_Misc_AutoloadWAD, 'a' },
{ M_LFRT, "AUTOLOAD DEH FILES", M_ID_Misc_AutoloadDEH, 'a' },
{ M_SKIP, "", 0, '\0' },
{ M_LFRT, "ANIMATION AND HIGHLIGHTING", M_ID_Misc_Hightlight, 'a' },
{ M_LFRT, "HIGHLIGHTING EFFECT", M_ID_Misc_Hightlight, 'h' },
{ M_LFRT, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 'e' },
};

Expand Down Expand Up @@ -4083,10 +4077,12 @@ static void M_Draw_ID_Misc (void)

M_WriteTextCentered(90, "MENU SETTINGS", cr[CR_YELLOW]);

// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
// Highlighting effect
sprintf(str, menu_highlight == 1 ? "ANIMATED" :
menu_highlight == 2 ? "STATIC" : "OFF");
M_WriteText (M_ItemRightAlign(str), 99, str,
M_Item_Glow(9, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));
M_Item_Glow(9, menu_highlight == 1 ? GLOW_GREEN :
menu_highlight == 2 ? GLOW_YELLOW : GLOW_DARKRED));

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU" );
Expand Down Expand Up @@ -4186,7 +4182,7 @@ static void M_ID_Misc_AutoloadDEH (int choice)

static void M_ID_Misc_Hightlight (int choice)
{
menu_highlight ^= 1;
menu_highlight = M_INT_Slider(menu_highlight, 0, 2, choice, false);
}

static void M_ID_Misc_MenuEscKey (int choice)
Expand Down Expand Up @@ -6922,8 +6918,21 @@ void M_Ticker (void)
// Keep menu item bright or decrease tics for fading effect.
for (int i = 0 ; i < currentMenu->numitems ; i++)
{
currentMenu->menuitems[i].tics =
(itemOn == i) ? 5 : currentMenu->menuitems[i].tics - 1;
if (menu_highlight == 1)
{
currentMenu->menuitems[i].tics =
(itemOn == i) ? 5 : currentMenu->menuitems[i].tics - 1;
}
else
if (menu_highlight == 2)
{
currentMenu->menuitems[i].tics =
(itemOn == i) ? 5 : 0;
}
else
{
currentMenu->menuitems[i].tics = 0;
}
}
}

Expand Down
55 changes: 32 additions & 23 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,6 @@ static void M_FillBackground (void)

static byte *M_Small_Line_Glow (int tics)
{
if (!menu_highlight)
return cr[CR_MENU_DARK2];

return
tics == 5 ? cr[CR_MENU_BRIGHT2] :
tics == 4 ? cr[CR_MENU_BRIGHT1] :
Expand All @@ -840,9 +837,6 @@ static byte *M_Small_Line_Glow (int tics)

static byte *M_Big_Line_Glow (int tics)
{
if (!menu_highlight)
return NULL;

return
tics == 5 ? cr[CR_MENU_BRIGHT3] :
tics >= 3 ? cr[CR_MENU_BRIGHT2] :
Expand Down Expand Up @@ -3734,17 +3728,17 @@ static void M_DrawGameplayFooter (char *pagenum)
// -----------------------------------------------------------------------------

static MenuItem_t ID_Menu_Misc[] = {
{ ITT_LRFUNC, "INVULNERABILITY EFFECT", M_ID_Misc_A11yInvul, 0, MENU_NONE },
{ ITT_LRFUNC, "PALETTE FLASH EFFECTS", M_ID_Misc_A11yPalFlash, 0, MENU_NONE },
{ ITT_LRFUNC, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 0, MENU_NONE },
{ ITT_LRFUNC, "WEAPON BOBBING", M_ID_Misc_A11yWeaponBob, 0, MENU_NONE },
{ ITT_LRFUNC, "COLORBLIND FILTER", M_ID_Misc_A11yColorblind, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "AUTOLOAD WAD FILES", M_ID_Misc_AutoloadWAD, 0, MENU_NONE },
{ ITT_LRFUNC, "AUTOLOAD HHE FILES", M_ID_Misc_AutoloadHHE, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "ANIMATION AND HIGHLIGHTING", M_ID_Misc_Hightlight, 0, MENU_NONE },
{ ITT_LRFUNC, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 0, MENU_NONE },
{ ITT_LRFUNC, "INVULNERABILITY EFFECT", M_ID_Misc_A11yInvul, 0, MENU_NONE },
{ ITT_LRFUNC, "PALETTE FLASH EFFECTS", M_ID_Misc_A11yPalFlash, 0, MENU_NONE },
{ ITT_LRFUNC, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 0, MENU_NONE },
{ ITT_LRFUNC, "WEAPON BOBBING", M_ID_Misc_A11yWeaponBob, 0, MENU_NONE },
{ ITT_LRFUNC, "COLORBLIND FILTER", M_ID_Misc_A11yColorblind, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "AUTOLOAD WAD FILES", M_ID_Misc_AutoloadWAD, 0, MENU_NONE },
{ ITT_LRFUNC, "AUTOLOAD HHE FILES", M_ID_Misc_AutoloadHHE, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "HIGHLIGHTING EFFECT", M_ID_Misc_Hightlight, 0, MENU_NONE },
{ ITT_LRFUNC, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 0, MENU_NONE },
};

static Menu_t ID_Def_Misc = {
Expand Down Expand Up @@ -3819,10 +3813,12 @@ static void M_Draw_ID_Misc (void)

MN_DrTextACentered("MENU SETTINGS", 100, cr[CR_YELLOW]);

// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
// Highlighting effect
sprintf(str, menu_highlight == 1 ? "ANIMATED" :
menu_highlight == 2 ? "STATIC" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 110,
M_Item_Glow(9, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));
M_Item_Glow(9, menu_highlight == 1 ? GLOW_GREEN :
menu_highlight == 2 ? GLOW_YELLOW : GLOW_DARKRED));

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU");
Expand Down Expand Up @@ -3922,7 +3918,7 @@ static void M_ID_Misc_AutoloadHHE (int choice)

static void M_ID_Misc_Hightlight (int choice)
{
menu_highlight ^= 1;
menu_highlight = M_INT_Slider(menu_highlight, 0, 2, choice, false);
}

static void M_ID_Misc_MenuEscKey (int choice)
Expand Down Expand Up @@ -4972,8 +4968,21 @@ void MN_Ticker(void)
// Keep menu item bright or decrease tics for fading effect.
for (int i = 0 ; i < CurrentMenu->itemCount ; i++)
{
CurrentMenu->items[i].tics =
(CurrentItPos == i) ? 5 : CurrentMenu->items[i].tics - 1;
if (menu_highlight == 1)
{
CurrentMenu->items[i].tics =
(CurrentItPos == i) ? 5 : CurrentMenu->items[i].tics - 1;
}
else
if (menu_highlight == 2)
{
CurrentMenu->items[i].tics =
(CurrentItPos == i) ? 5 : 0;
}
else
{
CurrentMenu->items[i].tics = 0;
}
}
}

Expand Down
51 changes: 30 additions & 21 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,6 @@ static void M_FillBackground (void)

static byte *M_Small_Line_Glow (int tics)
{
if (!menu_highlight)
return cr[CR_MENU_DARK2];

return
tics == 5 ? cr[CR_MENU_BRIGHT2] :
tics == 4 ? cr[CR_MENU_BRIGHT1] :
Expand All @@ -792,9 +789,6 @@ static byte *M_Small_Line_Glow (int tics)

static byte *M_Big_Line_Glow (int tics)
{
if (!menu_highlight)
return NULL;

return
tics == 5 ? cr[CR_MENU_BRIGHT3] :
tics >= 3 ? cr[CR_MENU_BRIGHT2] :
Expand Down Expand Up @@ -3635,15 +3629,15 @@ static void M_DrawGameplayFooter (char *pagenum)
// -----------------------------------------------------------------------------

static MenuItem_t ID_Menu_Misc[] = {
{ ITT_LRFUNC, "PALETTE FLASH EFFECTS", M_ID_Misc_A11yPalFlash, 0, MENU_NONE },
{ ITT_LRFUNC, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 0, MENU_NONE },
{ ITT_LRFUNC, "WEAPON BOBBING", M_ID_Misc_A11yWeaponBob, 0, MENU_NONE },
{ ITT_LRFUNC, "COLORBLIND FILTER", M_ID_Misc_A11yColorblind, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "AUTOLOAD WAD FILES", M_ID_Misc_AutoloadWAD, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "ANIMATION AND HIGHLIGHTING", M_ID_Misc_Hightlight, 0, MENU_NONE },
{ ITT_LRFUNC, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 0, MENU_NONE },
{ ITT_LRFUNC, "PALETTE FLASH EFFECTS", M_ID_Misc_A11yPalFlash, 0, MENU_NONE },
{ ITT_LRFUNC, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 0, MENU_NONE },
{ ITT_LRFUNC, "WEAPON BOBBING", M_ID_Misc_A11yWeaponBob, 0, MENU_NONE },
{ ITT_LRFUNC, "COLORBLIND FILTER", M_ID_Misc_A11yColorblind, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "AUTOLOAD WAD FILES", M_ID_Misc_AutoloadWAD, 0, MENU_NONE },
{ ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
{ ITT_LRFUNC, "HIGHLIGHTING EFFECT", M_ID_Misc_Hightlight, 0, MENU_NONE },
{ ITT_LRFUNC, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 0, MENU_NONE },
};

static Menu_t ID_Def_Misc = {
Expand Down Expand Up @@ -3706,10 +3700,12 @@ static void M_Draw_ID_Misc (void)

MN_DrTextACentered("MENU SETTINGS", 80, cr[CR_YELLOW]);

// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
// Highlighting effect
sprintf(str, menu_highlight == 1 ? "ANIMATED" :
menu_highlight == 2 ? "STATIC" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 90,
M_Item_Glow(7, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));
M_Item_Glow(7, menu_highlight == 1 ? GLOW_GREEN :
menu_highlight == 2 ? GLOW_YELLOW : GLOW_DARKRED));

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU" );
Expand Down Expand Up @@ -3796,7 +3792,7 @@ static void M_ID_Misc_AutoloadWAD (int choice)

static void M_ID_Misc_Hightlight (int choice)
{
menu_highlight ^= 1;
menu_highlight = M_INT_Slider(menu_highlight, 0, 2, choice, false);
}

static void M_ID_Misc_MenuEscKey (int choice)
Expand Down Expand Up @@ -4295,8 +4291,21 @@ void MN_Ticker(void)
// Keep menu item bright or decrease tics for fading effect.
for (int i = 0 ; i < CurrentMenu->itemCount ; i++)
{
CurrentMenu->items[i].tics =
(CurrentItPos == i) ? 5 : CurrentMenu->items[i].tics - 1;
if (menu_highlight == 1)
{
CurrentMenu->items[i].tics =
(CurrentItPos == i) ? 5 : CurrentMenu->items[i].tics - 1;
}
else
if (menu_highlight == 2)
{
CurrentMenu->items[i].tics =
(CurrentItPos == i) ? 5 : 0;
}
else
{
CurrentMenu->items[i].tics = 0;
}
}
}

Expand Down

0 comments on commit 30e8979

Please sign in to comment.