Merge branch 'polish-pause-menu' into 'master'

Interpolate pause menu

See merge request KartKrew/Kart!1760
This commit is contained in:
Oni 2024-01-01 16:16:31 +00:00
commit d26a535610
3 changed files with 24 additions and 18 deletions

View file

@ -1135,11 +1135,11 @@ void M_EggTV_RefreshButtonLabels(void);
// Keep track of some pause menu data for visual goodness.
extern struct pausemenu_s {
tic_t ticker; // How long the menu's been open for
INT16 offset; // To make the icons move smoothly when we transition!
tic_t ticker; // How long the menu's been open for
menu_anim_t offset; // To make the icons move smoothly when we transition!
INT16 openoffset; // Used when you open / close the menu to slide everything in.
boolean closing; // When this is set, the open offset goes backwards to close the menu smoothly.
menu_anim_t openoffset; // Used when you open / close the menu to slide everything in.
boolean closing; // When this is set, the open offset goes backwards to close the menu smoothly.
} pausemenu;
void M_OpenPauseMenu(void);

View file

@ -82,7 +82,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
fixed_t M_TimeFrac(tic_t tics, tic_t duration)
{
return tics < duration ? (tics * FRACUNIT + rendertimefrac) / duration : FRACUNIT;
return tics < duration ? (tics * FRACUNIT + rendertimefrac_unpaused) / duration : FRACUNIT;
}
fixed_t M_ReverseTimeFrac(tic_t tics, tic_t duration)
@ -5266,7 +5266,9 @@ void M_DrawPause(void)
INT16 ypos = -50; // Draw 3 items from selected item (y=100 - 3 items spaced by 50 px each... you get the idea.)
INT16 dypos;
INT16 offset = menutransition.tics ? floor(pow(2, (double)menutransition.tics)) : pausemenu.openoffset;
fixed_t t = M_DueFrac(pausemenu.openoffset.start, 6);
INT16 offset = menutransition.tics ? floor(pow(2, (double)menutransition.tics)) :
(pausemenu.openoffset.dist ? Easing_InQuad(t, 0, 256) : Easing_OutQuad(t, 256, 0));
INT16 arrxpos = 150 + 2*offset; // To draw the background arrow.
INT16 j = 0;
@ -5275,6 +5277,8 @@ void M_DrawPause(void)
patch_t *arrstart = W_CachePatchName("M_PTIP", PU_CACHE);
patch_t *arrfill = W_CachePatchName("M_PFILL", PU_CACHE);
t = M_DueFrac(pausemenu.offset.start, 3);
//V_DrawFadeScreen(0xFF00, 16);
// "PAUSED"
@ -5346,8 +5350,9 @@ void M_DrawPause(void)
// Multiply by -1 or 1 depending on whether we're below or above 100 px.
// This double ternary is awful, yes.
dypos = ypos + pausemenu.offset;
V_DrawFixedPatch( ((i == itemOn ? (294 - pausemenu.offset*2/3 * (dypos > 100 ? 1 : -1)) : 261) + offset) << FRACBITS, (dypos)*FRACUNIT, FRACUNIT, 0, pp, colormap);
INT32 yofs = Easing_InQuad(t, pausemenu.offset.dist, 0);
dypos = ypos + yofs;
V_DrawFixedPatch( ((i == itemOn ? (294 - yofs*2/3 * (dypos > 100 ? 1 : -1)) : 261) + offset) << FRACBITS, (dypos)*FRACUNIT, FRACUNIT, 0, pp, colormap);
ypos += 50;
itemsdrawn++; // We drew that!

View file

@ -2,6 +2,7 @@
/// \brief In-game/pause menus
#include "../../d_netcmd.h"
#include "../../i_time.h"
#include "../../k_menu.h"
#include "../../k_grandprix.h" // K_CanChangeRules
#include "../../m_cond.h"
@ -117,8 +118,9 @@ void M_OpenPauseMenu(void)
// Ready the variables
pausemenu.ticker = 0;
pausemenu.offset = 0;
pausemenu.openoffset = 256;
pausemenu.offset.dist = 0;
pausemenu.openoffset.start = I_GetTime();
pausemenu.openoffset.dist = 0;
pausemenu.closing = false;
currentMenu->lastOn = mpause_continue; // Make sure we select "RESUME GAME" by default
@ -260,23 +262,20 @@ void M_QuitPauseMenu(INT32 choice)
(void)choice;
// M_PauseTick actually handles the quitting when it's been long enough.
pausemenu.closing = true;
pausemenu.openoffset = 4;
pausemenu.openoffset.start = I_GetTime();
pausemenu.openoffset.dist = 1;
}
void M_PauseTick(void)
{
pausemenu.offset /= 2;
pausemenu.ticker++;
if (pausemenu.closing)
{
pausemenu.openoffset *= 2;
if (pausemenu.openoffset > 255)
if (I_GetTime() - pausemenu.openoffset.start > 6)
M_ClearMenus(true);
}
else
pausemenu.openoffset /= 2;
#ifdef HAVE_DISCORDRPC
// Show discord requests menu option if any requests are pending
@ -299,7 +298,8 @@ boolean M_PauseInputs(INT32 ch)
if (menucmd[pid].dpad_ud < 0)
{
M_SetMenuDelay(pid);
pausemenu.offset -= 50; // Each item is spaced by 50 px
pausemenu.offset.start = I_GetTime();
pausemenu.offset.dist = -50; // Each item is spaced by 50 px
S_StartSound(NULL, sfx_s3k5b);
M_PrevOpt();
return true;
@ -307,7 +307,8 @@ boolean M_PauseInputs(INT32 ch)
else if (menucmd[pid].dpad_ud > 0)
{
pausemenu.offset += 50; // Each item is spaced by 50 px
pausemenu.offset.start = I_GetTime();
pausemenu.offset.dist = 50; // Each item is spaced by 50 px
S_StartSound(NULL, sfx_s3k5b);
M_NextOpt();
M_SetMenuDelay(pid);