diff --git a/src/k_menu.h b/src/k_menu.h index 539a29c17..a764b6f87 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -945,13 +945,12 @@ struct modedesc_t #define MAXCOLUMNMODES 12 //max modes displayed in one column #define MAXMODEDESCS (MAXCOLUMNMODES*3) +#define M_OPTIONS_OFSTIME 4 // Keep track of some options properties extern struct optionsmenu_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 buttflash; // Button flashing before transitionning to the new submenu. + tic_t ticker; // How long the menu's been open for + menu_anim_t offset; // To make the icons move smoothly when we transition! // For moving the button when we get into a submenu. it's smooth and cool! (normal x/y and target x/y.) // this is only used during menu transitions. @@ -961,6 +960,7 @@ extern struct optionsmenu_s { INT16 opty; INT16 toptx; INT16 topty; + tic_t topt_start; // profile garbage boolean profilemenu; // In profile menu. (Used to know when to get the "PROFILE SETUP" button away.... diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e5195c932..cc7d24ec3 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4131,16 +4131,41 @@ void M_DrawOptionsMovingButton(void) { patch_t *butt = W_CachePatchName("OPT_BUTT", PU_CACHE); UINT8 *c = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PLAGUE, GTC_CACHE); + fixed_t t = M_DueFrac(optionsmenu.topt_start, M_OPTIONS_OFSTIME); + fixed_t tx = Easing_OutQuad(t, optionsmenu.optx * FRACUNIT, optionsmenu.toptx * FRACUNIT); + fixed_t ty = Easing_OutQuad(t, optionsmenu.opty * FRACUNIT, optionsmenu.topty * FRACUNIT); - V_DrawFixedPatch((optionsmenu.optx)*FRACUNIT, (optionsmenu.opty)*FRACUNIT, FRACUNIT, 0, butt, c); - V_DrawCenteredGamemodeString((optionsmenu.optx)-3, (optionsmenu.opty) - 16, 0, c, OPTIONS_MainDef.menuitems[OPTIONS_MainDef.lastOn].text); + V_DrawFixedPatch(tx, ty, FRACUNIT, 0, butt, c); + + const char *s = OPTIONS_MainDef.menuitems[OPTIONS_MainDef.lastOn].text; + fixed_t w = V_StringScaledWidth( + FRACUNIT, + FRACUNIT, + FRACUNIT, + 0, + GM_FONT, + s + ); + V_DrawStringScaled( + tx - 3*FRACUNIT - (w/2), + ty - 16*FRACUNIT, + FRACUNIT, + FRACUNIT, + FRACUNIT, + 0, + c, + GM_FONT, + s + ); } void M_DrawOptions(void) { UINT8 i; - INT32 x = 140 - (48*itemOn) + optionsmenu.offset; - INT32 y = 70 + optionsmenu.offset; + INT32 t = Easing_OutSine(M_DueFrac(optionsmenu.offset.start, M_OPTIONS_OFSTIME), optionsmenu.offset.dist, 0); + INT32 x = 140 - (48*itemOn) + t; + INT32 y = 70 + t; + INT32 tx = M_EaseWithTransition(Easing_Linear, 5 * 64); patch_t *buttback = W_CachePatchName("OPT_BUTT", PU_CACHE); UINT8 *c = NULL; @@ -4148,7 +4173,7 @@ void M_DrawOptions(void) for (i=0; i < currentMenu->numitems; i++) { INT32 py = y - (itemOn*48); - INT32 px = x - menutransition.tics*64; + INT32 px = x - tx; INT32 tflag = 0; if (i == itemOn) @@ -4159,7 +4184,7 @@ void M_DrawOptions(void) if (currentMenu->menuitems[i].status & IT_TRANSTEXT) tflag = V_TRANSLUCENT; - if (!(menutransition.tics && i == itemOn)) + if (!(menutransition.tics != menutransition.dest && i == itemOn)) { V_DrawFixedPatch(px*FRACUNIT, py*FRACUNIT, FRACUNIT, 0, buttback, c); V_DrawCenteredGamemodeString(px-3, py - 16, tflag, (i == itemOn ? c : NULL), currentMenu->menuitems[i].text); @@ -4171,7 +4196,7 @@ void M_DrawOptions(void) M_DrawMenuTooltips(); - if (menutransition.tics) + if (menutransition.tics != menutransition.dest) M_DrawOptionsMovingButton(); } @@ -4357,7 +4382,7 @@ void M_DrawProfileSelect(void) { INT32 i; const INT32 maxp = PR_GetNumProfiles(); - INT32 x = 160 - optionsmenu.profilen*(128 + 128/8) + optionsmenu.offset; + INT32 x = 160 - optionsmenu.profilen*(128 + 128/8) + Easing_OutSine(M_DueFrac(optionsmenu.offset.start, M_OPTIONS_OFSTIME), optionsmenu.offset.dist, 0); INT32 y = 35 + menutransition.tics*32; M_DrawMenuTooltips(); diff --git a/src/menus/options-1.c b/src/menus/options-1.c index d60942d9e..aa4db50ac 100644 --- a/src/menus/options-1.c +++ b/src/menus/options-1.c @@ -1,6 +1,7 @@ /// \file menus/options-1.c /// \brief Options Menu +#include "../i_time.h" #include "../k_menu.h" #include "../k_grandprix.h" // K_CanChangeRules #include "../m_cond.h" // Condition Sets @@ -61,7 +62,7 @@ struct optionsmenu_s optionsmenu; void M_ResetOptions(void) { optionsmenu.ticker = 0; - optionsmenu.offset = 0; + optionsmenu.offset.start = 0; optionsmenu.optx = 0; optionsmenu.opty = 0; @@ -120,8 +121,8 @@ void M_OptionsChangeBGColour(INT16 newcolour) boolean M_OptionsQuit(void) { - optionsmenu.toptx = 140-1; - optionsmenu.topty = 70+1; + optionsmenu.toptx = 140; + optionsmenu.topty = 70; // Reset button behaviour because profile menu is different, since of course it is. if (optionsmenu.resetprofilemenu) @@ -140,20 +141,6 @@ void M_OptionsTick(void) optionsmenu.ticker++; - if (!instanttransmission) - { - optionsmenu.offset /= 2; - - optionsmenu.optx += (optionsmenu.toptx - optionsmenu.optx)/2; - optionsmenu.opty += (optionsmenu.topty - optionsmenu.opty)/2; - - if (abs(optionsmenu.optx - optionsmenu.opty) < 2) - { - optionsmenu.optx = optionsmenu.toptx; - optionsmenu.opty = optionsmenu.topty; // Avoid awkward 1 px errors. - } - } - // Move the button for cool animations if (currentMenu == &OPTIONS_MainDef) { @@ -187,7 +174,7 @@ void M_OptionsTick(void) if (instanttransmission) { optionsmenu.currcolour = currentMenu->extra1; - optionsmenu.offset = optionsmenu.fade = 0; + optionsmenu.offset.start = optionsmenu.fade = 0; optionsmenu.optx = optionsmenu.toptx; optionsmenu.opty = optionsmenu.topty; @@ -199,6 +186,21 @@ void M_OptionsTick(void) if (optionsmenu.currcolour != currentMenu->extra1) M_OptionsChangeBGColour(currentMenu->extra1); + if (optionsmenu.optx != optionsmenu.toptx || optionsmenu.opty != optionsmenu.topty) + { + tic_t t = I_GetTime(); + tic_t n = t - optionsmenu.topt_start; + if (n == M_OPTIONS_OFSTIME) + { + optionsmenu.optx = optionsmenu.toptx; + optionsmenu.opty = optionsmenu.topty; + } + else if (n > M_OPTIONS_OFSTIME) + { + optionsmenu.topt_start = I_GetTime(); + } + } + M_GonerCheckLooking(); } @@ -235,26 +237,28 @@ boolean M_OptionsInputs(INT32 ch) if (menucmd[pid].dpad_ud > 0) { M_SetMenuDelay(pid); - optionsmenu.offset += 48; + optionsmenu.offset.dist = 48; M_NextOpt(); S_StartSound(NULL, sfx_s3k5b); if (itemOn == 0) - optionsmenu.offset -= currentMenu->numitems*48; + optionsmenu.offset.dist -= currentMenu->numitems*48; + optionsmenu.offset.start = I_GetTime(); return true; } else if (menucmd[pid].dpad_ud < 0) { M_SetMenuDelay(pid); - optionsmenu.offset -= 48; + optionsmenu.offset.dist = -48; M_PrevOpt(); S_StartSound(NULL, sfx_s3k5b); if (itemOn == currentMenu->numitems-1) - optionsmenu.offset += currentMenu->numitems*48; + optionsmenu.offset.dist += currentMenu->numitems*48; + optionsmenu.offset.start = I_GetTime(); return true; } diff --git a/src/menus/options-profiles-1.c b/src/menus/options-profiles-1.c index beb801aa6..577841fdf 100644 --- a/src/menus/options-profiles-1.c +++ b/src/menus/options-profiles-1.c @@ -1,6 +1,7 @@ /// \file menus/options-profiles-1.c /// \brief Profiles Menu +#include "../i_time.h" #include "../k_menu.h" #include "../s_sound.h" @@ -141,14 +142,16 @@ void M_HandleProfileSelect(INT32 ch) if (menucmd[pid].dpad_lr > 0) { optionsmenu.profilen++; - optionsmenu.offset += (128 + 128/8); + optionsmenu.offset.dist = (128 + 128/8); if (optionsmenu.profilen > maxp) { optionsmenu.profilen = 0; - optionsmenu.offset -= (128 + 128/8)*(maxp+1); + optionsmenu.offset.dist -= (128 + 128/8)*(maxp+1); } + optionsmenu.offset.start = I_GetTime(); + S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); @@ -156,14 +159,16 @@ void M_HandleProfileSelect(INT32 ch) else if (menucmd[pid].dpad_lr < 0) { optionsmenu.profilen--; - optionsmenu.offset -= (128 + 128/8); + optionsmenu.offset.dist = (128 + 128/8); if (optionsmenu.profilen < 0) { optionsmenu.profilen = maxp; - optionsmenu.offset += (128 + 128/8)*(maxp+1); + optionsmenu.offset.dist += (128 + 128/8)*(maxp+1); } + optionsmenu.offset.start = I_GetTime(); + S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); }