Skip to content

Commit

Permalink
Make menu animation/highlighting optional
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Nov 12, 2024
1 parent 04c5610 commit 244e238
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 46 deletions.
98 changes: 81 additions & 17 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ static void M_Choose_ID_Misc (int choice);
static void M_Draw_ID_Misc (void);
static void M_ID_Misc_AutoloadWAD (int choice);
static void M_ID_Misc_AutoloadDEH (int choice);
static void M_ID_Misc_Hightlight (int choice);
static void M_ID_Misc_MenuEscKey (int choice);

static void M_Choose_ID_Level (int choice);
Expand Down Expand Up @@ -940,8 +941,11 @@ static void M_FillBackground (void)
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);
}

static byte *M_Small_Line_Glow (const int tics)
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 @@ -950,8 +954,11 @@ static byte *M_Small_Line_Glow (const int tics)
tics == 1 ? cr[CR_MENU_BRIGHT1] : NULL;
}

static byte *M_Big_Line_Glow (const 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 @@ -981,8 +988,24 @@ static void M_Reset_Line_Glow (void)
#define ITEMONTICS currentMenu->menuitems[itemOn].tics
#define ITEMSETONTICS currentMenu->menuitems[itemSetOn].tics

static byte *M_Item_Glow (const int itemSetOn, const int color)
static byte *M_Item_Glow (int itemSetOn, int color)
{
if (!menu_highlight)
{
return
color == GLOW_RED ? cr[CR_RED] :
color == GLOW_DARKRED ? cr[CR_DARKRED] :
color == GLOW_GREEN ? cr[CR_GREEN] :
color == GLOW_YELLOW ? cr[CR_YELLOW] :
color == GLOW_ORANGE ? cr[CR_ORANGE] :
color == GLOW_LIGHTGRAY ? cr[CR_LIGHTGRAY] :
color == GLOW_BLUE ? cr[CR_BLUE2] :
color == GLOW_OLIVE ? cr[CR_OLIVE] :
color == GLOW_DARKGREEN ? cr[CR_DARKGREEN] :
color == GLOW_GRAY ? cr[CR_GRAY] :
NULL; // color == GLOW_UNCOLORED
}

if (itemOn == itemSetOn)
{
return
Expand Down Expand Up @@ -1103,8 +1126,11 @@ static byte *M_Item_Glow (const int itemSetOn, const int color)
return NULL;
}

static byte *M_Cursor_Glow (const int tics)
static byte *M_Cursor_Glow (int tics)
{
if (!menu_highlight)
return whichSkull ? NULL : cr[CR_MENU_DARK4];

return
tics == 8 || tics == 7 ? cr[CR_MENU_BRIGHT4] :
tics == 6 || tics == 5 ? cr[CR_MENU_BRIGHT3] :
Expand All @@ -1116,6 +1142,33 @@ static byte *M_Cursor_Glow (const int tics)
tics == -7 || tics == -8 ? cr[CR_MENU_DARK4] : NULL;
}

enum
{
saveload_border,
saveload_text,
saveload_cursor,
};

static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type)
{
if (!menu_highlight)
return NULL;

switch (type)
{
case saveload_border:
return itemSetOn ? cr[CR_MENU_BRIGHT2] : NULL;

case saveload_text:
return itemSetOn ? cr[CR_MENU_BRIGHT5] : M_Small_Line_Glow(tics);

case saveload_cursor:
return cr[CR_MENU_BRIGHT5];
}

return NULL;
}

static const 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
Expand Down Expand Up @@ -3794,15 +3847,16 @@ static void M_DrawGameplayFooter (char *pagenum)

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_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, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 'e' },
{ M_LFRT, "ANIMATION AND HIGHLIGHTING", M_ID_Misc_Hightlight, 'a' },
{ M_LFRT, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 'e' },
};

static menu_t ID_Def_Misc =
{
4,
5,
&ID_Def_Main,
ID_Menu_Misc,
M_Draw_ID_Misc,
Expand Down Expand Up @@ -3838,10 +3892,15 @@ static void M_Draw_ID_Misc (void)

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

// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
M_WriteText (M_ItemRightAlign(str), 45, str,
M_Item_Glow(3, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU" );
M_WriteText (M_ItemRightAlign(str), 45, str,
M_Item_Glow(3, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));
M_WriteText (M_ItemRightAlign(str), 54, str,
M_Item_Glow(4, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));

// [PN] Added explanations for autoload variables
if (itemOn == 0 || itemOn == 1)
Expand Down Expand Up @@ -3881,6 +3940,11 @@ static void M_ID_Misc_AutoloadDEH (int choice)
autoload_deh = M_INT_Slider(autoload_deh, 0, 2, choice, false);
}

static void M_ID_Misc_Hightlight (int choice)
{
menu_highlight ^= 1;
}

static void M_ID_Misc_MenuEscKey (int choice)
{
menu_esc_key ^= 1;
Expand Down Expand Up @@ -4605,10 +4669,10 @@ static void M_DrawLoad(void)
for (i = 0;i < load_end; i++)
{
// [JN] Highlight selected item (itemOn == i) or apply fading effect.
dp_translation = i == itemOn ? cr[CR_MENU_BRIGHT2] : NULL;
dp_translation = M_SaveLoad_Glow(itemOn == i, 0, saveload_border);
M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i+7);
M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i], itemOn == i ?
cr[CR_MENU_BRIGHT5] : M_Small_Line_Glow(currentMenu->menuitems[i].tics));
M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i],
M_SaveLoad_Glow(itemOn == i, currentMenu->menuitems[i].tics, saveload_text));
}

M_DrawSaveLoadBottomLine();
Expand Down Expand Up @@ -4681,17 +4745,17 @@ static void M_DrawSave(void)
for (i = 0;i < load_end; i++)
{
// [JN] Highlight selected item (itemOn == i) or apply fading effect.
dp_translation = i == itemOn ? cr[CR_MENU_BRIGHT2] : NULL;
dp_translation = M_SaveLoad_Glow(itemOn == i, 0, saveload_border);
M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i+7);
M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i], itemOn == i ?
cr[CR_MENU_BRIGHT5] : M_Small_Line_Glow(currentMenu->menuitems[i].tics));
M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i],
M_SaveLoad_Glow(itemOn == i, currentMenu->menuitems[i].tics, saveload_text));
}

if (saveStringEnter)
{
i = M_StringWidth(savegamestrings[saveSlot]);
// [JN] Highlight "_" cursor, line is always active while typing.
M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_", cr[CR_MENU_BRIGHT5]);
M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_", M_SaveLoad_Glow(0, 0, saveload_cursor));
}

M_DrawSaveLoadBottomLine();
Expand Down
94 changes: 79 additions & 15 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ static void M_DrawGameplayFooter (char *pagenum);
static void M_Draw_ID_Misc (void);
static void M_ID_Misc_AutoloadWAD (int choice);
static void M_ID_Misc_AutoloadHHE (int choice);
static void M_ID_Misc_Hightlight (int choice);
static void M_ID_Misc_MenuEscKey (int choice);

static void M_Draw_ID_Level_1 (void);
Expand Down Expand Up @@ -808,8 +809,11 @@ static void M_FillBackground (void)
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);
}

static byte *M_Small_Line_Glow (const int tics)
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 @@ -818,8 +822,11 @@ static byte *M_Small_Line_Glow (const int tics)
cr[CR_MENU_DARK2] ;
}

static byte *M_Big_Line_Glow (const 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 @@ -849,8 +856,24 @@ static void M_Reset_Line_Glow (void)
#define ITEMONTICS CurrentMenu->items[CurrentItPos].tics
#define ITEMSETONTICS CurrentMenu->items[CurrentItPosOn].tics

static byte *M_Item_Glow (const int CurrentItPosOn, const int color)
static byte *M_Item_Glow (int CurrentItPosOn, int color)
{
if (!menu_highlight)
{
return
color == GLOW_RED ? cr[CR_RED] :
color == GLOW_DARKRED ? cr[CR_DARKRED] :
color == GLOW_GREEN ? cr[CR_GREEN] :
color == GLOW_YELLOW ? cr[CR_YELLOW] :
color == GLOW_ORANGE ? cr[CR_ORANGE_HR] :
color == GLOW_LIGHTGRAY ? cr[CR_LIGHTGRAY] :
color == GLOW_DARKGRAY ? cr[CR_MENU_DARK4] :
color == GLOW_BLUE ? cr[CR_BLUE2] :
color == GLOW_OLIVE ? cr[CR_OLIVE] :
color == GLOW_DARKGREEN ? cr[CR_DARKGREEN] :
NULL; // color == GLOW_UNCOLORED
}

if (CurrentItPos == CurrentItPosOn)
{
return
Expand Down Expand Up @@ -971,8 +994,11 @@ static byte *M_Item_Glow (const int CurrentItPosOn, const int color)
return NULL;
}

static byte *M_Cursor_Glow (const int tics)
static byte *M_Cursor_Glow (int tics)
{
if (!menu_highlight)
return MenuTime & 16 ? cr[CR_MENU_DARK1] : cr[CR_MENU_DARK4];

return
tics == 8 || tics == 7 ? cr[CR_MENU_BRIGHT4] :
tics == 6 || tics == 5 ? cr[CR_MENU_BRIGHT3] :
Expand All @@ -984,6 +1010,33 @@ static byte *M_Cursor_Glow (const int tics)
tics == -7 || tics == -8 ? cr[CR_MENU_DARK4] : NULL;
}

enum
{
saveload_border,
saveload_text,
saveload_cursor,
};

static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type)
{
if (!menu_highlight)
return NULL;

switch (type)
{
case saveload_border:
return itemSetOn ? cr[CR_MENU_BRIGHT2] : NULL;

case saveload_text:
return itemSetOn ? cr[CR_MENU_BRIGHT2] : M_Small_Line_Glow(tics);

case saveload_cursor:
return cr[CR_MENU_BRIGHT2];
}

return NULL;
}

static const 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
Expand Down Expand Up @@ -3556,16 +3609,17 @@ static void M_DrawGameplayFooter (char *pagenum)
// -----------------------------------------------------------------------------

static MenuItem_t ID_Menu_Misc[] = {
{ 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, "ESC KEY BEHAVIOUR", M_ID_Misc_MenuEscKey, 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 },
};

static Menu_t ID_Def_Misc = {
ID_MENU_CTRLSOFFSET, ID_MENU_TOPOFFSET,
M_Draw_ID_Misc,
4, ID_Menu_Misc,
5, ID_Menu_Misc,
0,
SmallFont, false, true,
MENU_ID_MAIN
Expand Down Expand Up @@ -3593,10 +3647,15 @@ static void M_Draw_ID_Misc (void)

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

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU" );
// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 50,
M_Item_Glow(3, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));
M_Item_Glow(3, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU");
MN_DrTextA(str, M_ItemRightAlign(str), 60,
M_Item_Glow(4, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));

// [PN] Added explanations for autoload variables
if (CurrentItPos == 0 || CurrentItPos == 1)
Expand Down Expand Up @@ -3636,6 +3695,11 @@ static void M_ID_Misc_AutoloadHHE (int choice)
autoload_hhe = M_INT_Slider(autoload_hhe, 0, 2, choice, false);
}

static void M_ID_Misc_Hightlight (int choice)
{
menu_highlight ^= 1;
}

static void M_ID_Misc_MenuEscKey (int choice)
{
menu_esc_key ^= 1;
Expand Down Expand Up @@ -5013,12 +5077,12 @@ static void DrawFileSlots(Menu_t * menu)
for (i = 0; i < SAVES_PER_PAGE; i++)
{
// [JN] Highlight selected item (CurrentItPos == i) or apply fading effect.
dp_translation = CurrentItPos == i ? cr[CR_MENU_BRIGHT2] : NULL;
dp_translation = M_SaveLoad_Glow(CurrentItPos == i, 0, saveload_border);
V_DrawShadowedPatchOptional(x, y, 1, W_CacheLumpName(DEH_String("M_FSLOT"), PU_CACHE));
if (SlotStatus[i])
{
MN_DrTextA(SlotText[i], x + 5, y + 5, CurrentItPos == i ?
cr[CR_MENU_BRIGHT2] : M_Small_Line_Glow(CurrentMenu->items[i].tics));
MN_DrTextA(SlotText[i], x + 5, y + 5,
M_SaveLoad_Glow(CurrentItPos == i, CurrentMenu->items[i].tics, saveload_text));
}
y += ITEM_HEIGHT;
}
Expand Down
Loading

5 comments on commit 244e238

@Meerschweinmann
Copy link
Contributor

Choose a reason for hiding this comment

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

Heyhey, the new misc menu motivated you to find new options to put in :)

@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.

Yep! This is exactly the purpose of "Misc" menu, for collecting some uncategorized stuff.

@Meerschweinmann
Copy link
Contributor

Choose a reason for hiding this comment

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

Good that it is here now 👍

@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.

So, if you have any ideas regarding what can be placed there - please, feel free to suggest! I think it's necessary to keep 4-6 lines for Accessibility features, though I haven' investigated them yet.

@Meerschweinmann
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, the Inter ports have every option i find useful for the moment. But who knows what ideas the future will bring and the misc menu has four lines of options in it for now. So it is good that it is there.

Please sign in to comment.