Skip to content

Commit

Permalink
A11Y - implement variable movement bobbing
Browse files Browse the repository at this point in the history
Co-Authored-By: pvictress <[email protected]>
  • Loading branch information
JNechaevsky and pvictress committed Nov 24, 2024
1 parent 28b7d61 commit 71f758e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 33 deletions.
42 changes: 32 additions & 10 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ static void M_DrawGameplayFooter (char *pagenum);
static void M_Choose_ID_Misc (int choice);
static void M_Draw_ID_Misc (void);
static void M_ID_Misc_A11yInvul (int choice);
static void M_ID_Misc_A11yMoveBob (int choice);
static void M_ID_Misc_AutoloadWAD (int choice);
static void M_ID_Misc_AutoloadDEH (int choice);
static void M_ID_Misc_Hightlight (int choice);
Expand Down Expand Up @@ -3852,6 +3853,7 @@ static void M_DrawGameplayFooter (char *pagenum)
static menuitem_t ID_Menu_Misc[]=
{
{ M_LFRT, "INVULNERABILITY EFFECT", M_ID_Misc_A11yInvul, 'i' },
{ M_LFRT, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 'm' },
{ M_SKIP, "", 0, '\0' },
{ M_LFRT, "AUTOLOAD WAD FILES", M_ID_Misc_AutoloadWAD, 'a' },
{ M_LFRT, "AUTOLOAD DEH FILES", M_ID_Misc_AutoloadDEH, 'a' },
Expand All @@ -3862,7 +3864,7 @@ static menuitem_t ID_Menu_Misc[]=

static menu_t ID_Def_Misc =
{
7,
8,
&ID_Def_Main,
ID_Menu_Misc,
M_Draw_ID_Misc,
Expand All @@ -3885,44 +3887,59 @@ static void M_Draw_ID_Misc (void)
// Invulnerability effect
sprintf(str, a11y_invul ? "GRAYSCALE" : "DEFAULT");
M_WriteText (M_ItemRightAlign(str), 18, str,
M_Item_Glow(1, a11y_invul ? GLOW_GREEN : GLOW_DARKRED));
M_Item_Glow(0, a11y_invul ? GLOW_GREEN : GLOW_DARKRED));

// Movement bobbing
sprintf(str, a11y_move_bob == 10 ? "DEFAULT" :
a11y_move_bob == 9 ? "90%%" :
a11y_move_bob == 8 ? "80%%" :
a11y_move_bob == 7 ? "70%%" :
a11y_move_bob == 6 ? "60%%" :
a11y_move_bob == 5 ? "50%%" :
a11y_move_bob == 4 ? "40%%" :
a11y_move_bob == 3 ? "30%%" :
a11y_move_bob == 2 ? "20%%" :
a11y_move_bob == 1 ? "10%%" : "OFF");
M_WriteText (M_ItemRightAlign(str), 27, str,
M_Item_Glow(1, a11y_move_bob == 10 ? GLOW_DARKRED :
a11y_move_bob == 0 ? GLOW_RED : GLOW_YELLOW));

M_WriteTextCentered(27, "AUTOLOAD", cr[CR_YELLOW]);
M_WriteTextCentered(36, "AUTOLOAD", cr[CR_YELLOW]);

// Autoload WAD files
sprintf(str, autoload_wad == 1 ? "IWAD ONLY" :
autoload_wad == 2 ? "IWAD AND PWAD" : "OFF");
M_WriteText (M_ItemRightAlign(str), 36, str,
M_WriteText (M_ItemRightAlign(str), 45, str,
M_Item_Glow(3, autoload_wad == 1 ? GLOW_YELLOW :
autoload_wad == 2 ? GLOW_GREEN : GLOW_DARKRED));

// Autoload DEH patches
sprintf(str, autoload_deh == 1 ? "IWAD ONLY" :
autoload_deh == 2 ? "IWAD AND PWAD" : "OFF");
M_WriteText (M_ItemRightAlign(str), 45, str,
M_WriteText (M_ItemRightAlign(str), 54, str,
M_Item_Glow(4, autoload_deh == 1 ? GLOW_YELLOW :
autoload_deh == 2 ? GLOW_GREEN : GLOW_DARKRED));

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

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

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU" );
M_WriteText (M_ItemRightAlign(str), 72, str,
M_WriteText (M_ItemRightAlign(str), 81, str,
M_Item_Glow(7, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));

// [PN] Added explanations for autoload variables
if (itemOn == 2 || itemOn == 3)
if (itemOn == 3 || itemOn == 4)
{
const char *off = "AUTOLOAD IS DISABLED";
const char *first_line = "AUTOLOAD AND FOLDER CREATION";
const char *second_line1 = "ONLY ALLOWED FOR IWAD FILES";
const char *second_line2 = "ALLOWED FOR BOTH IWAD AND PWAD FILES";
const int autoload_option = (itemOn == 2) ? autoload_wad : autoload_deh;
const int autoload_option = (itemOn == 3) ? autoload_wad : autoload_deh;

switch (autoload_option)
{
Expand Down Expand Up @@ -3950,6 +3967,11 @@ static void M_ID_Misc_A11yInvul (int choice)
R_InitColormaps();
}

static void M_ID_Misc_A11yMoveBob (int choice)
{
a11y_move_bob = M_INT_Slider(a11y_move_bob, 0, 10, choice, true);
}

static void M_ID_Misc_AutoloadWAD (int choice)
{
autoload_wad = M_INT_Slider(autoload_wad, 0, 2, choice, false);
Expand Down
10 changes: 10 additions & 0 deletions src/doom/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ void P_CalcHeight (player_t* player)
angle = (FINEANGLES/20*realleveltime)&FINEMASK;
bob = FixedMul ( player->bob/2, finesine[angle]);

// [PN] A11Y - Movement bobbing.
// Compute reduction factor dynamically based on the pattern.
if (a11y_move_bob > 0 && a11y_move_bob < 10)
{
bob -= bob * (1.0 - a11y_move_bob * 0.1);
}
else if (a11y_move_bob == 0)
{
bob = 0;
}

// move viewheight
if (player->playerstate == PST_LIVE)
Expand Down
48 changes: 35 additions & 13 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ static void M_DrawGameplayFooter (char *pagenum);

static void M_Draw_ID_Misc (void);
static void M_ID_Misc_A11yInvul (int choice);
static void M_ID_Misc_A11yMoveBob (int choice);
static void M_ID_Misc_AutoloadWAD (int choice);
static void M_ID_Misc_AutoloadHHE (int choice);
static void M_ID_Misc_Hightlight (int choice);
Expand Down Expand Up @@ -3613,6 +3614,7 @@ 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, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 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 },
Expand All @@ -3624,7 +3626,7 @@ static MenuItem_t ID_Menu_Misc[] = {
static Menu_t ID_Def_Misc = {
ID_MENU_CTRLSOFFSET, ID_MENU_TOPOFFSET,
M_Draw_ID_Misc,
7, ID_Menu_Misc,
8, ID_Menu_Misc,
0,
SmallFont, false, true,
MENU_ID_MAIN
Expand All @@ -3641,42 +3643,57 @@ static void M_Draw_ID_Misc (void)
MN_DrTextA(str, M_ItemRightAlign(str), 20,
M_Item_Glow(0, a11y_invul ? GLOW_GREEN : GLOW_DARKRED));

MN_DrTextACentered("AUTOLOAD", 30, cr[CR_YELLOW]);
// Movement bobbing
sprintf(str, a11y_move_bob == 10 ? "DEFAULT" :
a11y_move_bob == 9 ? "90%%" :
a11y_move_bob == 8 ? "80%%" :
a11y_move_bob == 7 ? "70%%" :
a11y_move_bob == 6 ? "60%%" :
a11y_move_bob == 5 ? "50%%" :
a11y_move_bob == 4 ? "40%%" :
a11y_move_bob == 3 ? "30%%" :
a11y_move_bob == 2 ? "20%%" :
a11y_move_bob == 1 ? "10%%" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 30,
M_Item_Glow(1, a11y_move_bob == 10 ? GLOW_DARKRED :
a11y_move_bob == 0 ? GLOW_RED : GLOW_YELLOW));

MN_DrTextACentered("AUTOLOAD", 40, cr[CR_YELLOW]);

// Autoload WAD files
sprintf(str, autoload_wad == 1 ? "IWAD ONLY" :
autoload_wad == 2 ? "IWAD AND PWAD" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 40,
M_Item_Glow(2, autoload_wad == 1 ? GLOW_YELLOW :
MN_DrTextA(str, M_ItemRightAlign(str), 50,
M_Item_Glow(3, autoload_wad == 1 ? GLOW_YELLOW :
autoload_wad == 2 ? GLOW_GREEN : GLOW_DARKRED));

// Autoload DEH patches
sprintf(str, autoload_hhe == 1 ? "IWAD ONLY" :
autoload_hhe == 2 ? "IWAD AND PWAD" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 50,
M_Item_Glow(3, autoload_hhe == 1 ? GLOW_YELLOW :
MN_DrTextA(str, M_ItemRightAlign(str), 60,
M_Item_Glow(4, autoload_hhe == 1 ? GLOW_YELLOW :
autoload_hhe == 2 ? GLOW_GREEN : GLOW_DARKRED));

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

// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 70,
M_Item_Glow(5, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));
MN_DrTextA(str, M_ItemRightAlign(str), 80,
M_Item_Glow(6, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));

// ESC key behaviour
sprintf(str, menu_esc_key ? "GO BACK" : "CLOSE MENU");
MN_DrTextA(str, M_ItemRightAlign(str), 80,
M_Item_Glow(6, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));
MN_DrTextA(str, M_ItemRightAlign(str), 90,
M_Item_Glow(7, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));

// [PN] Added explanations for autoload variables
if (CurrentItPos == 2 || CurrentItPos == 3)
if (CurrentItPos == 3 || CurrentItPos == 4)
{
const char *off = "AUTOLOAD IS DISABLED";
const char *first_line = "AUTOLOAD AND FOLDER CREATION";
const char *second_line1 = "ONLY ALLOWED FOR IWAD FILES";
const char *second_line2 = "ALLOWED FOR BOTH IWAD AND PWAD FILES";
const int autoload_option = (CurrentItPos == 2) ? autoload_wad : autoload_hhe;
const int autoload_option = (CurrentItPos == 3) ? autoload_wad : autoload_hhe;

switch (autoload_option)
{
Expand Down Expand Up @@ -3704,6 +3721,11 @@ static void M_ID_Misc_A11yInvul (int choice)
R_InitColormaps();
}

static void M_ID_Misc_A11yMoveBob (int choice)
{
a11y_move_bob = M_INT_Slider(a11y_move_bob, 0, 10, choice, true);
}

static void M_ID_Misc_AutoloadWAD (int choice)
{
autoload_wad = M_INT_Slider(autoload_wad, 0, 2, choice, false);
Expand Down
11 changes: 11 additions & 0 deletions src/heretic/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ void P_CalcHeight(player_t * player)
angle = (FINEANGLES / 20 * realleveltime) & FINEMASK;
bob = FixedMul(player->bob / 2, finesine[angle]);

// [PN] A11Y - Movement bobbing.
// Compute reduction factor dynamically based on the pattern.
if (a11y_move_bob > 0 && a11y_move_bob < 10)
{
bob -= bob * (1.0 - a11y_move_bob * 0.1);
}
else if (a11y_move_bob == 0)
{
bob = 0;
}

//
// move viewheight
//
Expand Down
45 changes: 35 additions & 10 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ static void M_ScrollGameplay (int choice);
static void M_DrawGameplayFooter (char *pagenum);

static void M_Draw_ID_Misc (void);
static void M_ID_Misc_A11yMoveBob (int choice);
static void M_ID_Misc_AutoloadWAD (int choice);
static void M_ID_Misc_Hightlight (int choice);
static void M_ID_Misc_MenuEscKey (int choice);
Expand Down Expand Up @@ -3513,6 +3514,8 @@ static void M_DrawGameplayFooter (char *pagenum)
// -----------------------------------------------------------------------------

static MenuItem_t ID_Menu_Misc[] = {
{ ITT_LRFUNC, "MOVEMENT BOBBING", M_ID_Misc_A11yMoveBob, 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 },
Expand All @@ -3522,7 +3525,7 @@ static MenuItem_t ID_Menu_Misc[] = {
static Menu_t ID_Def_Misc = {
ID_MENU_CTRLSOFFSET, ID_MENU_TOPOFFSET,
M_Draw_ID_Misc,
4, ID_Menu_Misc,
6, ID_Menu_Misc,
0,
SmallFont, false, true,
MENU_ID_MAIN
Expand All @@ -3532,29 +3535,46 @@ static void M_Draw_ID_Misc (void)
{
char str[32];

MN_DrTextACentered("AUTOLOAD", 10, cr[CR_YELLOW]);
MN_DrTextACentered("ACCESSIBILITY", 10, cr[CR_YELLOW]);

// Movement bobbing
sprintf(str, a11y_move_bob == 10 ? "DEFAULT" :
a11y_move_bob == 9 ? "90%%" :
a11y_move_bob == 8 ? "80%%" :
a11y_move_bob == 7 ? "70%%" :
a11y_move_bob == 6 ? "60%%" :
a11y_move_bob == 5 ? "50%%" :
a11y_move_bob == 4 ? "40%%" :
a11y_move_bob == 3 ? "30%%" :
a11y_move_bob == 2 ? "20%%" :
a11y_move_bob == 1 ? "10%%" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 20,
M_Item_Glow(0, a11y_move_bob == 10 ? GLOW_DARKRED :
a11y_move_bob == 0 ? GLOW_RED : GLOW_YELLOW));

MN_DrTextACentered("AUTOLOAD", 30, cr[CR_YELLOW]);

// Autoload WAD files
sprintf(str, autoload_wad == 1 ? "IWAD ONLY" :
autoload_wad == 2 ? "IWAD AND PWAD" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 20,
M_Item_Glow(0, autoload_wad == 1 ? GLOW_YELLOW :
MN_DrTextA(str, M_ItemRightAlign(str), 40,
M_Item_Glow(1, autoload_wad == 1 ? GLOW_YELLOW :
autoload_wad == 2 ? GLOW_GREEN : GLOW_DARKRED));

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

// Animation and highlighting
sprintf(str, menu_highlight ? "ON" : "OFF");
MN_DrTextA(str, M_ItemRightAlign(str), 40,
M_Item_Glow(2, menu_highlight ? GLOW_GREEN : GLOW_DARKRED));
MN_DrTextA(str, M_ItemRightAlign(str), 60,
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), 50,
M_Item_Glow(3, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));
MN_DrTextA(str, M_ItemRightAlign(str), 70,
M_Item_Glow(4, menu_esc_key ? GLOW_GREEN : GLOW_DARKRED));

// [PN] Added explanations for autoload variables
if (CurrentItPos == 0)
if (CurrentItPos == 2)
{
const char *off = "AUTOLOAD IS DISABLED";
const char *first_line = "AUTOLOAD AND FOLDER CREATION";
Expand All @@ -3580,6 +3600,11 @@ static void M_Draw_ID_Misc (void)
}
}

static void M_ID_Misc_A11yMoveBob (int choice)
{
a11y_move_bob = M_INT_Slider(a11y_move_bob, 0, 10, choice, true);
}

static void M_ID_Misc_AutoloadWAD (int choice)
{
autoload_wad = M_INT_Slider(autoload_wad, 0, 2, choice, false);
Expand Down
11 changes: 11 additions & 0 deletions src/hexen/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ void P_CalcHeight(player_t * player)
angle = (FINEANGLES / 20 * realleveltime) & FINEMASK;
bob = FixedMul(player->bob / 2, finesine[angle]);

// [PN] A11Y - Movement bobbing.
// Compute reduction factor dynamically based on the pattern.
if (a11y_move_bob > 0 && a11y_move_bob < 10)
{
bob -= bob * (1.0 - a11y_move_bob * 0.1);
}
else if (a11y_move_bob == 0)
{
bob = 0;
}

//
// move viewheight
//
Expand Down
2 changes: 2 additions & 0 deletions src/id_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ int compat_vertical_aiming = 0;
//

int a11y_invul = 0;
int a11y_move_bob = 10;
int autoload_wad = 1;
int autoload_deh = 1;
int autoload_hhe = 1;
Expand Down Expand Up @@ -420,6 +421,7 @@ void ID_BindVariables (GameMission_t mission)
{
M_BindIntVariable("a11y_invul", &a11y_invul);
}
M_BindIntVariable("a11y_move_bob", &a11y_move_bob);
M_BindIntVariable("menu_highlight", &menu_highlight);
M_BindIntVariable("menu_esc_key", &menu_esc_key);
}
1 change: 1 addition & 0 deletions src/id_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extern int compat_vertical_aiming;

// Miscellaneous
extern int a11y_invul;
extern int a11y_move_bob;
extern int autoload_wad;
extern int autoload_deh;
extern int autoload_hhe;
Expand Down
1 change: 1 addition & 0 deletions src/m_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ static default_t doom_defaults_list[] =
CONFIG_VARIABLE_INT(compat_vertical_aiming),

CONFIG_VARIABLE_INT(a11y_invul),
CONFIG_VARIABLE_INT(a11y_move_bob),
CONFIG_VARIABLE_INT(menu_highlight),
CONFIG_VARIABLE_INT(menu_esc_key),
};
Expand Down

0 comments on commit 71f758e

Please sign in to comment.