From ec2ecd2e6274dd9a15f9d635cb8e227a41686621 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 11:32:59 -0800 Subject: [PATCH 01/22] Menus: interpolate Gamemode menu transitions --- src/k_menudraw.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 4fc8f24fc..6a38b8b92 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1212,6 +1212,7 @@ void M_DrawKartGamemodeMenu(void) { UINT8 n = 0; INT32 i, x, y; + INT32 tx = M_EaseWithTransition(Easing_Linear, 5 * 48); for (i = 0; i < currentMenu->numitems; i++) { @@ -1224,16 +1225,11 @@ void M_DrawKartGamemodeMenu(void) } n--; - x = GM_STARTX - ((GM_XOFFSET / 2) * (n-1)); + x = GM_STARTX - ((GM_XOFFSET / 2) * (n-1)) + tx; y = GM_STARTY - ((GM_YOFFSET / 2) * (n-1)); M_DrawMenuTooltips(); - if (menutransition.tics) - { - x += 48 * menutransition.tics; - } - for (i = 0; i < currentMenu->numitems; i++) { INT32 type; @@ -1245,13 +1241,9 @@ void M_DrawKartGamemodeMenu(void) if (i >= currentMenu->numitems-1) { - x = GM_STARTX + (GM_XOFFSET * 5 / 2); + x = GM_STARTX + (GM_XOFFSET * 5 / 2) + tx; y = GM_STARTY + (GM_YOFFSET * 5 / 2); - if (menutransition.tics) - { - x += 48 * menutransition.tics; - } } INT32 cx = x; From 5d35c9795574ba8743a856b13b259ce0cf267ac6 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 11:47:43 -0800 Subject: [PATCH 02/22] Menus/Cup Grid: interpolate scrolling level previews --- src/k_menudraw.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 6a38b8b92..d0f09c703 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2656,7 +2656,7 @@ static void M_DrawCupPreview(INT16 y, levelsearch_t *levelsearch) { UINT8 i = 0; INT16 maxlevels = M_CountLevelsToShowInList(levelsearch); - INT16 x = -(cupgrid.previewanim % 82); + fixed_t x = -((cupgrid.previewanim % 82 * FRACUNIT + rendertimefrac) % (82 * FRACUNIT)); INT16 add; INT16 map, start = M_GetFirstLevelInList(&i, levelsearch); UINT8 starti = i; @@ -2676,7 +2676,7 @@ static void M_DrawCupPreview(INT16 y, levelsearch_t *levelsearch) add--; } - while (x < BASEVIDWIDTH) + while (x < BASEVIDWIDTH * FRACUNIT) { if (map >= nummapheaders) { @@ -2685,13 +2685,13 @@ static void M_DrawCupPreview(INT16 y, levelsearch_t *levelsearch) } K_DrawMapThumbnail( - (x+1)< Date: Wed, 27 Dec 2023 11:49:00 -0800 Subject: [PATCH 03/22] Menus/Cup Grid: interpolate slide away --- src/k_menudraw.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index d0f09c703..007ca955e 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3005,6 +3005,7 @@ void M_DrawCupSelect(void) { UINT8 i, j, temp = 0; INT16 x, y; + INT16 cy = M_EaseWithTransition(Easing_Linear, 5 * 30); cupwindata_t *windata = NULL; levelsearch_t templevelsearch = levellist.levelsearch; // full copy @@ -3021,7 +3022,7 @@ void M_DrawCupSelect(void) templevelsearch.cup = cupgrid.builtgrid[id]; - y = 20 + (j*44) - (30*menutransition.tics); + y = 20 + (j*44) - cy; if (cupgrid.cache_secondrowlocked == true) y += 28; @@ -3088,15 +3089,16 @@ void M_DrawCupSelect(void) V_DrawScaledPatch(x + 32, y + 32, 0, W_CachePatchName("CUPBKUP2", PU_CACHE)); } - V_DrawFill(0, 146 + (24*menutransition.tics), BASEVIDWIDTH, 54, 31); - M_DrawCupPreview(146 + (24*menutransition.tics), &templevelsearch); + INT16 ty = M_EaseWithTransition(Easing_Linear, 5 * 24); + V_DrawFill(0, 146 + ty, BASEVIDWIDTH, 54, 31); + M_DrawCupPreview(146 + ty, &templevelsearch); - M_DrawCupTitle(120 - (24*menutransition.tics), &templevelsearch); + M_DrawCupTitle(120 - ty, &templevelsearch); if (cupgrid.numpages > 1) { x = 3 - (skullAnimCounter/5); - y = 20 + (44 - 1) - (30*menutransition.tics); + y = 20 + (44 - 1) - cy; patch_t *cuparrow = W_CachePatchName("CUPARROW", PU_CACHE); From 1c2ed2b306b8d6963cf55616c870b0626ec951e3 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 11:51:39 -0800 Subject: [PATCH 04/22] Menus/Cup Grid: stagger cursor movement --- src/k_menu.h | 2 ++ src/k_menudraw.c | 10 ++++++++-- src/menus/transient/cup-select.c | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index bb952fa88..8f6cb8d33 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -785,9 +785,11 @@ void M_SetupGametypeMenu(INT32 choice); void M_SetupRaceMenu(INT32 choice); #define CUPMENU_CURSORID (cupgrid.x + (cupgrid.y * CUPMENU_COLUMNS) + (cupgrid.pageno * (CUPMENU_COLUMNS * CUPMENU_ROWS))) +#define CUPMENU_SLIDETIME 3 extern struct cupgrid_s { SINT8 x, y; + menu_anim_t xslide, yslide; size_t pageno; cupheader_t **builtgrid; size_t numpages; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 007ca955e..a4c8bf27c 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3073,8 +3073,14 @@ void M_DrawCupSelect(void) } } - x = 14 + (cupgrid.x*42); - y = 20 + (cupgrid.y*44) - (30*menutransition.tics); + { + fixed_t tx = Easing_Linear(M_DueFrac(cupgrid.xslide.start, CUPMENU_SLIDETIME), cupgrid.xslide.dist * FRACUNIT, 0); + fixed_t ty = Easing_Linear(M_DueFrac(cupgrid.yslide.start, CUPMENU_SLIDETIME), cupgrid.yslide.dist * FRACUNIT, 0); + + x = 14 + (cupgrid.x*42*FRACUNIT - tx) / FRACUNIT; + y = 20 + (cupgrid.y*44*FRACUNIT - ty) / FRACUNIT - cy; + } + if (cupgrid.cache_secondrowlocked == true) y += 28; diff --git a/src/menus/transient/cup-select.c b/src/menus/transient/cup-select.c index 6cd4052f8..51db53499 100644 --- a/src/menus/transient/cup-select.c +++ b/src/menus/transient/cup-select.c @@ -1,6 +1,7 @@ /// \file menus/transient/cup-select.c /// \brief Cup Select +#include "../../i_time.h" #include "../../k_menu.h" #include "../../s_sound.h" #include "../../f_finale.h" // F_WipeStartScreen @@ -197,6 +198,8 @@ void M_CupSelectHandler(INT32 choice) if (cupgrid.pageno >= cupgrid.numpages) cupgrid.pageno = 0; } + cupgrid.xslide.start = I_GetTime(); + cupgrid.xslide.dist = 42; S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); } @@ -211,6 +214,8 @@ void M_CupSelectHandler(INT32 choice) else cupgrid.pageno--; } + cupgrid.xslide.start = I_GetTime(); + cupgrid.xslide.dist = -42; S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); } @@ -221,7 +226,13 @@ void M_CupSelectHandler(INT32 choice) { cupgrid.y++; if (cupgrid.y >= CUPMENU_ROWS) + { cupgrid.y = 0; + cupgrid.yslide.dist = 8; + } + else + cupgrid.yslide.dist = 44; + cupgrid.yslide.start = I_GetTime(); S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); } @@ -229,7 +240,13 @@ void M_CupSelectHandler(INT32 choice) { cupgrid.y--; if (cupgrid.y < 0) + { cupgrid.y = CUPMENU_ROWS-1; + cupgrid.yslide.dist = -8; + } + else + cupgrid.yslide.dist = -44; + cupgrid.yslide.start = I_GetTime(); S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); } From d9f0f70987bf095b75f631a0e7bb8c19bf35767d Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 11:56:55 -0800 Subject: [PATCH 05/22] Menus/Level Select: interpolate - Uses slightly different easing --- src/k_menu.h | 4 +++- src/k_menudraw.c | 9 +++++++-- src/menus/transient/cup-select.c | 2 +- src/menus/transient/level-select.c | 31 ++++++++++++++++-------------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 8f6cb8d33..2d78dd7af 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -808,10 +808,12 @@ typedef struct levelsearch_s { boolean checklocked; } levelsearch_t; +#define M_LEVELLIST_SLIDETIME 4 + extern struct levellist_s { SINT8 cursor; + menu_anim_t slide; UINT16 y; - UINT16 dest; UINT16 choosemap; UINT16 mapcount; UINT8 newgametype; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index a4c8bf27c..f4fb42766 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3271,8 +3271,13 @@ void M_DrawLevelSelect(void) INT16 i = 0; UINT8 j = 0; INT16 map = M_GetFirstLevelInList(&j, &levellist.levelsearch); - INT16 t = (64*menutransition.tics), tay = 0; - INT16 y = 80 - (12 * levellist.y); + INT16 t = M_EaseWithTransition(Easing_Linear, 5 * 64), tay = 0; + INT16 y = 80 - levellist.y + + Easing_OutSine( + M_DueFrac(levellist.slide.start, 4), + levellist.slide.dist, + 0 + ); boolean tatransition = ((menutransition.startmenu == &PLAY_TimeAttackDef || menutransition.endmenu == &PLAY_TimeAttackDef) && menutransition.tics); if (tatransition) diff --git a/src/menus/transient/cup-select.c b/src/menus/transient/cup-select.c index 51db53499..8df28af4c 100644 --- a/src/menus/transient/cup-select.c +++ b/src/menus/transient/cup-select.c @@ -308,7 +308,7 @@ void M_CupSelectHandler(INT32 choice) levellist.mapcount = count; M_LevelSelectScrollDest(); - levellist.y = levellist.dest; + levellist.slide.start = 0; M_SetupNextMenu(&PLAY_LevelSelectDef, false); S_StartSound(NULL, sfx_s3k63); diff --git a/src/menus/transient/level-select.c b/src/menus/transient/level-select.c index 54ea2c078..73189a3bb 100644 --- a/src/menus/transient/level-select.c +++ b/src/menus/transient/level-select.c @@ -1,6 +1,7 @@ /// \file menus/transient/level-select.c /// \brief Level Select +#include "../../i_time.h" #include "../../k_menu.h" #include "../../m_cond.h" // Condition Sets #include "../../z_zone.h" @@ -223,14 +224,23 @@ UINT16 M_GetNextLevelInList(UINT16 mapnum, UINT8 *i, levelsearch_t *levelsearch) void M_LevelSelectScrollDest(void) { UINT16 m = levellist.mapcount-1; + UINT16 dest = (6*levellist.cursor); - levellist.dest = (6*levellist.cursor); + if (dest < 3) + dest = 3; - if (levellist.dest < 3) - levellist.dest = 3; + if (m && dest > (6*m)-3) + dest = (6*m)-3; - if (m && levellist.dest > (6*m)-3) - levellist.dest = (6*m)-3; + dest *= 12; + + if (levellist.y != dest) + { + levellist.slide.start = I_GetTime(); + levellist.slide.dist = dest - levellist.y; + } + + levellist.y = dest; } // Builds the level list we'll be using from the gametype we're choosing and send us to the apropriate menu. @@ -599,7 +609,7 @@ boolean M_LevelListFromGametype(INT16 gt) } M_LevelSelectScrollDest(); - levellist.y = levellist.dest; + levellist.slide.start = 0; if (gt != -1) { @@ -778,7 +788,7 @@ void M_LevelSelectHandler(INT32 choice) (void)choice; - if (levellist.y != levellist.dest) + if (I_GetTime() - levellist.slide.start < M_LEVELLIST_SLIDETIME) { return; } @@ -820,11 +830,4 @@ void M_LevelSelectHandler(INT32 choice) void M_LevelSelectTick(void) { - - INT16 dist = levellist.dest - levellist.y; - - if (abs(dist) == 1) // cheating to avoid off by 1 errors with divisions. - levellist.y = levellist.dest; - else - levellist.y += dist/2; } From 8a2e0469e9c00eb8cc28120a816072965eaefd55 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 12:08:03 -0800 Subject: [PATCH 06/22] Menus/Extras: interpolate - Uses a different easing --- src/k_menu.h | 6 ++++-- src/k_menudraw.c | 5 +++-- src/menus/extras-1.c | 16 ++++++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 2d78dd7af..539a29c17 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1065,10 +1065,12 @@ void M_DrawEggaChannel(void); // Extras menu: #define DF_ENCORE 0x40 +#define M_EXTRAS_OFSTIME 4 + extern struct extrasmenu_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! // 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. (and will probably remain unused until we get the statistics menu diff --git a/src/k_menudraw.c b/src/k_menudraw.c index f4fb42766..e5195c932 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4942,8 +4942,9 @@ void M_DrawExtrasMovingButton(void) void M_DrawExtras(void) { UINT8 i; - INT32 x = 140 - (48*itemOn) + extrasmenu.offset; - INT32 y = 70 + extrasmenu.offset; + INT32 t = Easing_OutSine(M_DueFrac(extrasmenu.offset.start, M_EXTRAS_OFSTIME), extrasmenu.offset.dist, 0); + INT32 x = 140 - (48*itemOn) + t; + INT32 y = 70 + t; patch_t *buttback = W_CachePatchName("OPT_BUTT", PU_CACHE); UINT8 *c = NULL; diff --git a/src/menus/extras-1.c b/src/menus/extras-1.c index 2ae596544..9d1ab4b55 100644 --- a/src/menus/extras-1.c +++ b/src/menus/extras-1.c @@ -1,6 +1,7 @@ /// \file menus/extras-1.c /// \brief Extras Menu +#include "../i_time.h" #include "../k_menu.h" #include "../m_cond.h" #include "../m_cheat.h" @@ -127,7 +128,7 @@ void M_InitExtras(INT32 choice) return; extrasmenu.ticker = 0; - extrasmenu.offset = 0; + extrasmenu.offset.start = 0; extrasmenu.extx = 0; extrasmenu.exty = 0; @@ -148,7 +149,6 @@ boolean M_ExtrasQuit(void) void M_ExtrasTick(void) { - extrasmenu.offset /= 2; extrasmenu.ticker++; extrasmenu.extx += (extrasmenu.textx - extrasmenu.extx)/2; @@ -197,12 +197,14 @@ boolean M_ExtrasInputs(INT32 ch) if (menucmd[pid].dpad_ud > 0) { - extrasmenu.offset += 48; + extrasmenu.offset.dist = 48; M_NextOpt(); S_StartSound(NULL, sfx_s3k5b); if (itemOn == 0) - extrasmenu.offset -= currentMenu->numitems*48; + extrasmenu.offset.dist -= currentMenu->numitems*48; + + extrasmenu.offset.start = I_GetTime(); M_SetMenuDelay(pid); return true; @@ -210,12 +212,14 @@ boolean M_ExtrasInputs(INT32 ch) else if (menucmd[pid].dpad_ud < 0) { - extrasmenu.offset -= 48; + extrasmenu.offset.dist = -48; M_PrevOpt(); S_StartSound(NULL, sfx_s3k5b); if (itemOn == currentMenu->numitems-1) - extrasmenu.offset += currentMenu->numitems*48; + extrasmenu.offset.dist += currentMenu->numitems*48; + + extrasmenu.offset.start = I_GetTime(); M_SetMenuDelay(pid); return true; From ecc7b466afe2ece464e9c81483281ba03f5137a7 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 12:02:44 -0800 Subject: [PATCH 07/22] Menus/Options: interpolate main Options menu Profiles menu is touched too out of necessity (since these share state). However, no mind has been paid to Profiles. I have not tested Profiles after this change. --- src/k_menu.h | 8 +++--- src/k_menudraw.c | 41 +++++++++++++++++++++++------ src/menus/options-1.c | 48 ++++++++++++++++++---------------- src/menus/options-profiles-1.c | 13 ++++++--- 4 files changed, 72 insertions(+), 38 deletions(-) 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); } From 90670d3e246f9659b58aea2f3c068d999ef85826 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 12:04:42 -0800 Subject: [PATCH 08/22] M_DrawGenericOptions: interpolate with menu transition --- src/k_menudraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index cc7d24ec3..e88d4c6f9 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4203,7 +4203,7 @@ void M_DrawOptions(void) void M_DrawGenericOptions(void) { - INT32 x = currentMenu->x - menutransition.tics*48, y = currentMenu->y, w, i, cursory = 0; + INT32 x = currentMenu->x - M_EaseWithTransition(Easing_Linear, 5 * 48), y = currentMenu->y, w, i, cursory = 0; M_DrawMenuTooltips(); M_DrawOptionsMovingButton(); From 4733cef0d7a21d48af6890ba8ba6f9f486cfb9b2 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 12:07:09 -0800 Subject: [PATCH 09/22] Menus/Set Resolution: interpolate with menu transition --- src/k_menudraw.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e88d4c6f9..80c1a42c9 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4742,14 +4742,15 @@ void M_DrawProfileControls(void) void M_DrawVideoModes(void) { INT32 i, j, row, col; + INT32 t = M_EaseWithTransition(Easing_Linear, 5 * 64); M_DrawMenuTooltips(); M_DrawOptionsMovingButton(); - V_DrawCenteredString(BASEVIDWIDTH/2 + menutransition.tics*64, currentMenu->y, + V_DrawCenteredString(BASEVIDWIDTH/2 + t, currentMenu->y, highlightflags, "Choose mode, reselect to change default"); - row = 41 + menutransition.tics*64; + row = 41 + t; col = currentMenu->y + 14; for (i = 0; i < optionsmenu.vidm_nummodes; i++) { @@ -4771,41 +4772,41 @@ void M_DrawVideoModes(void) { INT32 testtime = (optionsmenu.vidm_testingmode/TICRATE) + 1; - M_CentreText(menutransition.tics*64, currentMenu->y + 75, + M_CentreText(t, currentMenu->y + 75, va("Previewing mode %c%dx%d", (SCR_IsAspectCorrect(vid.width, vid.height)) ? 0x83 : 0x80, vid.width, vid.height)); - M_CentreText(menutransition.tics*64, currentMenu->y + 75+8, + M_CentreText(t, currentMenu->y + 75+8, "Press ENTER again to keep this mode"); - M_CentreText(menutransition.tics*64, currentMenu->y + 75+16, + M_CentreText(t, currentMenu->y + 75+16, va("Wait %d second%s", testtime, (testtime > 1) ? "s" : "")); - M_CentreText(menutransition.tics*64, currentMenu->y + 75+24, + M_CentreText(t, currentMenu->y + 75+24, "or press ESC to return"); } else { - M_CentreText(menutransition.tics*64, currentMenu->y + 75, + M_CentreText(t, currentMenu->y + 75, va("Current mode is %c%dx%d", (SCR_IsAspectCorrect(vid.width, vid.height)) ? 0x83 : 0x80, vid.width, vid.height)); - M_CentreText(menutransition.tics*64, currentMenu->y + 75+8, + M_CentreText(t, currentMenu->y + 75+8, va("Default mode is %c%dx%d", (SCR_IsAspectCorrect(cv_scr_width.value, cv_scr_height.value)) ? 0x83 : 0x80, cv_scr_width.value, cv_scr_height.value)); - V_DrawCenteredString(BASEVIDWIDTH/2 + menutransition.tics*64, currentMenu->y + 75+24, + V_DrawCenteredString(BASEVIDWIDTH/2 + t, currentMenu->y + 75+24, recommendedflags, "Modes marked in GREEN are recommended."); /* - V_DrawCenteredString(BASEVIDWIDTH/2 + menutransition.tics*64, currentMenu->y + 75+16, + V_DrawCenteredString(BASEVIDWIDTH/2 + t, currentMenu->y + 75+16, highlightflags, "High resolutions stress your PC more, but will"); - V_DrawCenteredString(BASEVIDWIDTH/2 + menutransition.tics*64, currentMenu->y + 75+24, + V_DrawCenteredString(BASEVIDWIDTH/2 + t, currentMenu->y + 75+24, highlightflags, "look sharper. Balance visual quality and FPS!"); */ } // Draw the cursor for the VidMode menu - i = 41 - 10 + ((optionsmenu.vidm_selected / optionsmenu.vidm_column_size)*7*13) + menutransition.tics*64; + i = 41 - 10 + ((optionsmenu.vidm_selected / optionsmenu.vidm_column_size)*7*13) + t; j = currentMenu->y + 14 + ((optionsmenu.vidm_selected % optionsmenu.vidm_column_size)*8); V_DrawScaledPatch(i - 8, j, 0, From c805cdc24a78495ae10fda0e877dcf9cfcd268dc Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Dec 2023 12:06:39 -0800 Subject: [PATCH 10/22] Menus/Erase Profile: interpolate with menu transition --- src/k_menudraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 80c1a42c9..d5a3074af 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4351,7 +4351,7 @@ void M_DrawGenericOptions(void) // *Heavily* simplified version of the generic options menu, cattered only towards erasing profiles. void M_DrawProfileErase(void) { - INT32 x = currentMenu->x - menutransition.tics*48, y = currentMenu->y-SMALLLINEHEIGHT, i, cursory = 0; + INT32 x = currentMenu->x - M_EaseWithTransition(Easing_Linear, 5 * 48), y = currentMenu->y-SMALLLINEHEIGHT, i, cursory = 0; UINT8 np = PR_GetNumProfiles(); M_DrawMenuTooltips(); From 67e76ae720bc763601db7659006937966e0dfe68 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 05:47:27 -0800 Subject: [PATCH 11/22] Menus/Level Select: fix interp for Time Attack transition --- src/k_menudraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index d5a3074af..0004a4554 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3278,7 +3278,7 @@ void M_DrawLevelSelect(void) levellist.slide.dist, 0 ); - boolean tatransition = ((menutransition.startmenu == &PLAY_TimeAttackDef || menutransition.endmenu == &PLAY_TimeAttackDef) && menutransition.tics); + boolean tatransition = ((menutransition.startmenu == &PLAY_TimeAttackDef || menutransition.endmenu == &PLAY_TimeAttackDef) && menutransition.tics != menutransition.dest); if (tatransition) { From a1c76b044ed631bef70f7449ae6cc2c222586096 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 05:56:08 -0800 Subject: [PATCH 12/22] Menus/Time Attack: interpolate menu transition --- src/k_menudraw.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 0004a4554..d18712dd1 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3323,9 +3323,6 @@ static boolean M_LevelSelectHasBG(menu_t *check) static boolean M_LevelSelectToTimeAttackTransitionHelper(void) { - if (menutransition.tics == 0) - return false; - return (M_LevelSelectHasBG(menutransition.startmenu)) != M_LevelSelectHasBG(menutransition.endmenu); } @@ -3358,7 +3355,7 @@ void M_DrawSealedBack(void) void M_DrawTimeAttack(void) { UINT16 map = levellist.choosemap; - INT16 t = (48*menutransition.tics); + INT16 t = M_EaseWithTransition(Easing_Linear, 5 * 48); INT16 leftedge = 149+t+16; INT16 rightedge = 149+t+155; INT16 opty = 140; From efc2e800f85563d2644342b06b79fa84af250deb Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 07:10:22 -0800 Subject: [PATCH 13/22] Menus/Profiles: slide button a little further off-screen --- src/menus/options-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menus/options-1.c b/src/menus/options-1.c index aa4db50ac..cb51bec00 100644 --- a/src/menus/options-1.c +++ b/src/menus/options-1.c @@ -151,7 +151,7 @@ void M_OptionsTick(void) // I don't like this, it looks like shit but it needs to be done.......... if (optionsmenu.profilemenu) { - optionsmenu.toptx = 420; + optionsmenu.toptx = 440; optionsmenu.topty = 70+1; } else if (currentMenu == &OPTIONS_GameplayItemsDef) From 91452fcfed606c991800675043f43dbca88d94d7 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 07:14:45 -0800 Subject: [PATCH 14/22] Menus/Options: use fixed-point positioning This avoids a precision error when compared with the moving button. --- src/k_menudraw.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index d18712dd1..c9169d763 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4159,18 +4159,18 @@ void M_DrawOptionsMovingButton(void) void M_DrawOptions(void) { UINT8 i; - 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); + fixed_t t = Easing_OutSine(M_DueFrac(optionsmenu.offset.start, M_OPTIONS_OFSTIME), optionsmenu.offset.dist * FRACUNIT, 0); + fixed_t x = (140 - (48*itemOn))*FRACUNIT + t; + fixed_t y = 70*FRACUNIT + t; + fixed_t tx = M_EaseWithTransition(Easing_Linear, 5 * 64 * FRACUNIT); patch_t *buttback = W_CachePatchName("OPT_BUTT", PU_CACHE); UINT8 *c = NULL; for (i=0; i < currentMenu->numitems; i++) { - INT32 py = y - (itemOn*48); - INT32 px = x - tx; + fixed_t py = y - (itemOn*48)*FRACUNIT; + fixed_t px = x - tx; INT32 tflag = 0; if (i == itemOn) @@ -4183,12 +4183,32 @@ void M_DrawOptions(void) 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); + V_DrawFixedPatch(px, py, FRACUNIT, 0, buttback, c); + + const char *s = currentMenu->menuitems[i].text; + fixed_t w = V_StringScaledWidth( + FRACUNIT, + FRACUNIT, + FRACUNIT, + 0, + GM_FONT, + s + ); + V_DrawStringScaled( + px - 3*FRACUNIT - (w/2), + py - 16*FRACUNIT, + FRACUNIT, + FRACUNIT, + FRACUNIT, + tflag, + (i == itemOn ? c : NULL), + GM_FONT, + s + ); } - y += 48; - x += 48; + y += 48*FRACUNIT; + x += 48*FRACUNIT; } M_DrawMenuTooltips(); From f1b44443950074dde03f0d2af274fcd6f29e5e27 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 07:22:14 -0800 Subject: [PATCH 15/22] Menus/Options: align moving button with menu scroll --- src/k_menudraw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index c9169d763..892f27322 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4129,8 +4129,9 @@ 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); + fixed_t z = Easing_OutSine(M_DueFrac(optionsmenu.offset.start, M_OPTIONS_OFSTIME), optionsmenu.offset.dist * FRACUNIT, 0); + fixed_t tx = Easing_OutQuad(t, optionsmenu.optx * FRACUNIT, optionsmenu.toptx * FRACUNIT) + z; + fixed_t ty = Easing_OutQuad(t, optionsmenu.opty * FRACUNIT, optionsmenu.topty * FRACUNIT) + z; V_DrawFixedPatch(tx, ty, FRACUNIT, 0, butt, c); From d6439b8462a996fc0c37ca122a9fb8eccd04b5d2 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 07:23:06 -0800 Subject: [PATCH 16/22] Menus/Options: tweak easing algorithm --- src/k_menudraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 892f27322..71476b20d 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4163,7 +4163,7 @@ void M_DrawOptions(void) fixed_t t = Easing_OutSine(M_DueFrac(optionsmenu.offset.start, M_OPTIONS_OFSTIME), optionsmenu.offset.dist * FRACUNIT, 0); fixed_t x = (140 - (48*itemOn))*FRACUNIT + t; fixed_t y = 70*FRACUNIT + t; - fixed_t tx = M_EaseWithTransition(Easing_Linear, 5 * 64 * FRACUNIT); + fixed_t tx = M_EaseWithTransition(Easing_InQuart, 5 * 64 * FRACUNIT); patch_t *buttback = W_CachePatchName("OPT_BUTT", PU_CACHE); UINT8 *c = NULL; From 9a4d18bd7db18d561b01ab8619c4303f3632d0e5 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 07:27:01 -0800 Subject: [PATCH 17/22] Menus/Profiles: fix card select animation --- src/menus/options-profiles-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menus/options-profiles-1.c b/src/menus/options-profiles-1.c index 577841fdf..2e106f75c 100644 --- a/src/menus/options-profiles-1.c +++ b/src/menus/options-profiles-1.c @@ -159,7 +159,7 @@ void M_HandleProfileSelect(INT32 ch) else if (menucmd[pid].dpad_lr < 0) { optionsmenu.profilen--; - optionsmenu.offset.dist = (128 + 128/8); + optionsmenu.offset.dist = -(128 + 128/8); if (optionsmenu.profilen < 0) { From a461a6cfb2a4f1da69e9ed4464be46e23aba88c4 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 07:27:12 -0800 Subject: [PATCH 18/22] Menus/Profiles: interpolate with menu transition Replaced some linear transitions according to taste. --- src/k_menudraw.c | 30 +++++++++++++++++++++--------- src/menus/options-profiles-1.c | 1 + 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 71476b20d..1073975d2 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2378,7 +2378,7 @@ void M_DrawCharacterSelect(void) UINT8 priority = 0; INT16 quadx, quady; INT16 skin; - INT32 basex = optionsmenu.profile ? (64 + (menutransition.tics*32)) : 0; + INT32 basex = optionsmenu.profile ? (64 + M_EaseWithTransition(Easing_Linear, 5 * 32)) : 0; boolean forceskin = M_CharacterSelectForceInAction(); if (setup_numplayers > 0) @@ -4401,7 +4401,7 @@ void M_DrawProfileSelect(void) INT32 i; const INT32 maxp = PR_GetNumProfiles(); 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; + INT32 y = 35 + M_EaseWithTransition(Easing_Linear, 5 * 32); M_DrawMenuTooltips(); @@ -4414,7 +4414,7 @@ void M_DrawProfileSelect(void) profile_t *p = PR_GetProfile(i); // don't draw the card in this specific scenario - if (!(menutransition.tics && optionsmenu.profile != NULL && optionsmenu.profilen == i)) + if (!(optionsmenu.profile != NULL && optionsmenu.profilen == i)) M_DrawProfileCard(x, y, i > maxp, p); x += 128 + 128/8; @@ -4422,9 +4422,15 @@ void M_DrawProfileSelect(void) // needs to be drawn since it happens on the transition if (optionsmenu.profile != NULL) - M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, false, optionsmenu.profile); - - + { + fixed_t t = M_DueFrac(optionsmenu.topt_start, M_OPTIONS_OFSTIME); + M_DrawProfileCard( + Easing_OutQuad(t, optionsmenu.optx, optionsmenu.toptx), + Easing_OutQuad(t, optionsmenu.opty, optionsmenu.topty), + false, + optionsmenu.profile + ); + } } // Profile edition menu @@ -4432,7 +4438,7 @@ void M_DrawEditProfile(void) { INT32 y = 34; - INT32 x = (145 + (menutransition.tics*32)); + INT32 x = (145 + M_EaseWithTransition(Easing_InSine, 5 * 48)); INT32 i; // Tooltip @@ -4453,7 +4459,7 @@ void M_DrawEditProfile(void) y = currentMenu->menuitems[i].mvar2; // Background -- 169 is the plague colourization - V_DrawFill(0, y, 400 - (menutransition.tics*64), 10, itemOn == i ? 169 : 30); + V_DrawFill(0, y, 400 - M_EaseWithTransition(Easing_InQuad, 5 * 128), 10, itemOn == i ? 169 : 30); if (i == itemOn) { @@ -4483,7 +4489,13 @@ void M_DrawEditProfile(void) // Finally, draw the card ontop if (optionsmenu.profile != NULL) { - M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, false, optionsmenu.profile); + fixed_t t = M_DueFrac(optionsmenu.topt_start, M_OPTIONS_OFSTIME); + M_DrawProfileCard( + Easing_OutQuad(t, optionsmenu.optx, optionsmenu.toptx), + Easing_OutQuad(t, optionsmenu.opty, optionsmenu.topty), + false, + optionsmenu.profile + ); } } diff --git a/src/menus/options-profiles-1.c b/src/menus/options-profiles-1.c index 2e106f75c..7c82d12e5 100644 --- a/src/menus/options-profiles-1.c +++ b/src/menus/options-profiles-1.c @@ -82,6 +82,7 @@ void M_StartEditProfile(INT32 c) optionsmenu.opty = 35; optionsmenu.toptx = 130/2; optionsmenu.topty = 0; + optionsmenu.topt_start = I_GetTime(); // setup cvars if (optionsmenu.profile->version) From 3faf0d02ba75dd20c63e2f8c13742670362384a3 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 08:12:20 -0800 Subject: [PATCH 19/22] Menus/Options, Profiles: slow down easing animations by 1 tic --- src/k_menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_menu.h b/src/k_menu.h index a764b6f87..0047748a8 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -945,7 +945,7 @@ struct modedesc_t #define MAXCOLUMNMODES 12 //max modes displayed in one column #define MAXMODEDESCS (MAXCOLUMNMODES*3) -#define M_OPTIONS_OFSTIME 4 +#define M_OPTIONS_OFSTIME 5 // Keep track of some options properties extern struct optionsmenu_s { From 95378ade8f9f9947233f45e746fa62a0bcfde4bf Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 08:22:43 -0800 Subject: [PATCH 20/22] k_menu: move easing helper functions to k_menu.h --- src/k_menu.h | 10 ++++++++++ src/k_menudraw.c | 12 +++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 0047748a8..a4da4fb52 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -184,6 +184,16 @@ struct menu_anim_t INT16 dist; }; +fixed_t M_TimeFrac(tic_t tics, tic_t duration); +fixed_t M_ReverseTimeFrac(tic_t tics, tic_t duration); +fixed_t M_DueFrac(tic_t start, tic_t duration); + +// FIXME: C++ template +#define M_EaseWithTransition(EasingFunc, N) \ + (menutransition.tics != menutransition.dest ? EasingFunc(menutransition.in ?\ + M_ReverseTimeFrac(menutransition.tics, menutransition.endmenu->transitionTics) :\ + M_TimeFrac(menutransition.tics, menutransition.startmenu->transitionTics), 0, N) : 0) + typedef enum { MM_NOTHING = 0, // is just displayed until the user do someting diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 1073975d2..6da7b0180 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -80,29 +80,23 @@ int snprintf(char *str, size_t n, const char *fmt, ...); #include "discord.h" #endif -static ATTRUNUSED fixed_t M_TimeFrac(tic_t tics, tic_t duration) +fixed_t M_TimeFrac(tic_t tics, tic_t duration) { return tics < duration ? (tics * FRACUNIT + rendertimefrac) / duration : FRACUNIT; } -static ATTRUNUSED fixed_t M_ReverseTimeFrac(tic_t tics, tic_t duration) +fixed_t M_ReverseTimeFrac(tic_t tics, tic_t duration) { return FRACUNIT - M_TimeFrac(duration - tics, duration); } -static ATTRUNUSED fixed_t M_DueFrac(tic_t start, tic_t duration) +fixed_t M_DueFrac(tic_t start, tic_t duration) { tic_t t = I_GetTime(); tic_t n = t - start; return M_TimeFrac(min(n, duration), duration); } -// FIXME: C++ template -#define M_EaseWithTransition(EasingFunc, N) \ - (menutransition.tics != menutransition.dest ? EasingFunc(menutransition.in ?\ - M_ReverseTimeFrac(menutransition.tics, menutransition.endmenu->transitionTics) :\ - M_TimeFrac(menutransition.tics, menutransition.startmenu->transitionTics), 0, N) : 0) - #define SKULLXOFF -32 #define LINEHEIGHT 16 #define STRINGHEIGHT 8 From 6574d0065a83d249feaeb10e08ab219a1069d8a7 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 08:23:12 -0800 Subject: [PATCH 21/22] Menus/Sound Options: interpolate custom sliders with transition --- src/menus/options-sound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/menus/options-sound.cpp b/src/menus/options-sound.cpp index 2887be4b9..bf3840483 100644 --- a/src/menus/options-sound.cpp +++ b/src/menus/options-sound.cpp @@ -10,6 +10,7 @@ #include "../console.h" #include "../k_menu.h" #include "../m_cond.h" +#include "../m_easing.h" #include "../s_sound.h" // sounds consvars #include "../g_game.h" // cv_chatnotifications @@ -171,7 +172,7 @@ void restartaudio_routine(INT32) void draw_routine() { - int x = currentMenu->x - (menutransition.tics * 48); + int x = currentMenu->x - M_EaseWithTransition(Easing_Linear, 5 * 48); int y = currentMenu->y; M_DrawGenericOptions(); From a5410244d3bb41854a9e31924b6893072303ce9d Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Dec 2023 08:29:50 -0800 Subject: [PATCH 22/22] Menus/GP, Match Race: interpolate with menu transition --- src/k_menudraw.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 6da7b0180..a6cc32819 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2514,18 +2514,14 @@ void M_DrawRaceDifficulty(void) patch_t *box = W_CachePatchName("M_DBOX", PU_CACHE); INT32 i; - INT32 x = 120; + INT32 tx = M_EaseWithTransition(Easing_Linear, 5 * 48); + INT32 x = 120 + tx; INT32 y = 48; M_DrawMenuTooltips(); // Draw the box for difficulty... - V_DrawFixedPatch((111 + 48*menutransition.tics)*FRACUNIT, 33*FRACUNIT, FRACUNIT, 0, box, NULL); - - if (menutransition.tics) - { - x += 48 * menutransition.tics; - } + V_DrawFixedPatch((111 + tx)*FRACUNIT, 33*FRACUNIT, FRACUNIT, 0, box, NULL); for (i = 0; i < currentMenu->numitems; i++) { @@ -2540,11 +2536,7 @@ void M_DrawRaceDifficulty(void) y -= GM_YOFFSET; } - - if (menutransition.tics) - { - x += 48 * menutransition.tics; - } + x += tx; } switch (currentMenu->menuitems[i].status & IT_DISPLAY) @@ -2556,12 +2548,12 @@ void M_DrawRaceDifficulty(void) INT32 f = (i == itemOn) ? highlightflags : 0; - V_DrawString(140 + 48*menutransition.tics + (i == itemOn ? 1 : 0), y, f, currentMenu->menuitems[i].text); + V_DrawString(140 + tx + (i == itemOn ? 1 : 0), y, f, currentMenu->menuitems[i].text); if (currentMenu->menuitems[i].status & IT_CVAR) { // implicitely we'll only take care of normal cvars - INT32 cx = 260 + 48*menutransition.tics; + INT32 cx = 260 + tx; consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar; V_DrawCenteredString(cx, y, f, cv->string); @@ -2578,7 +2570,7 @@ void M_DrawRaceDifficulty(void) if (i == itemOn) { - V_DrawScaledPatch(140 + 48*menutransition.tics - 24, y, 0, + V_DrawScaledPatch(140 + tx - 24, y, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); } @@ -2611,8 +2603,8 @@ void M_DrawRaceDifficulty(void) if (currentMenu->menuitems[i].status & IT_CVAR) { - INT32 fx = (cx - 48*menutransition.tics); - INT32 centx = fx + (320-fx)/2 + (menutransition.tics*48); // undo the menutransition movement to redo it here otherwise the text won't move at the same speed lole. + INT32 fx = (cx - tx); + INT32 centx = fx + (320-fx)/2 + (tx); // undo the menutransition movement to redo it here otherwise the text won't move at the same speed lole. // implicitely we'll only take care of normal consvars consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar;