Skip to content

Commit

Permalink
Fix forced centerprint not resetting after preview fade out
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Sep 10, 2024
1 parent 55c5c8e commit 91ba833
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 4 additions & 5 deletions Quake/gl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void SCR_DrawCenterString (void) //actually do the drawing
int j;
int x, y;
int remaining;
float alpha, forced;
float alpha, forcedalpha;

GL_SetCanvas (CANVAS_MENU); //johnfitz

Expand All @@ -280,9 +280,8 @@ void SCR_DrawCenterString (void) //actually do the drawing
alpha = fade ? q_min (scr_centertime_off / fade, 1.f) : 1.f;
}

forced = M_ForcedCenterPrint ();
if (forced > 0.f)
alpha *= forced * forced;
if (M_ForcedCenterPrint (&forcedalpha))
alpha *= forcedalpha * forcedalpha;

GL_PushCanvasColor (1.f, 1.f, 1.f, alpha);

Expand Down Expand Up @@ -332,7 +331,7 @@ void SCR_CheckDrawCenterString (void)

if (scr_centertime_off <= 0 && !cl.intermission)
return;
if (key_dest != key_game && !M_ForcedCenterPrint ())
if (key_dest != key_game && !M_ForcedCenterPrint (NULL))
return;
if (cl.paused) //johnfitz -- don't show centerprint during a pause
return;
Expand Down
16 changes: 12 additions & 4 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3529,9 +3529,14 @@ static qboolean M_Options_WantsConsole (void)
return optionsmenu.preview.id == OPT_CONALPHA || optionsmenu.preview.id == OPT_CONBRIGHTNESS;
}

static float M_Options_ForcedCenterPrint (void)
static qboolean M_Options_ForcedCenterPrint (void)
{
return optionsmenu.preview.id == OPT_CENTERPRINTBG && !cl.intermission ? optionsmenu.preview.frac : 0.f;
return optionsmenu.preview.id == OPT_CENTERPRINTBG && !cl.intermission;
}

static float M_Options_PreviewAlpha (void)
{
return optionsmenu.preview.frac;
}

static void M_Options_Preview (int id)
Expand Down Expand Up @@ -7558,9 +7563,12 @@ qboolean M_WantsConsole (void)
return key_dest == key_menu && M_GetBaseState (m_state) == m_options && M_Options_WantsConsole ();
}

float M_ForcedCenterPrint (void)
qboolean M_ForcedCenterPrint (float *alpha)
{
return key_dest == key_menu && M_GetBaseState (m_state) == m_options ? M_Options_ForcedCenterPrint () : 0.f;
qboolean forced = (key_dest == key_menu && M_GetBaseState (m_state) == m_options) ? M_Options_ForcedCenterPrint () : false;
if (alpha)
*alpha = forced ? M_Options_PreviewAlpha () : 0.f;
return forced;
}


Expand Down
2 changes: 1 addition & 1 deletion Quake/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void M_Mousemove (int x, int y);
enum textmode_t M_TextEntry (void);
qboolean M_WaitingForKeyBinding (void);
qboolean M_WantsConsole (void);
float M_ForcedCenterPrint (void);
qboolean M_ForcedCenterPrint (float *alpha);
void M_ToggleMenu_f (void);

void M_RefreshMods (void);
Expand Down

0 comments on commit 91ba833

Please sign in to comment.