From 2446e53ff9f24a68bc8bb534132e6981baad78b4 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 29 Mar 2023 16:14:38 +0100 Subject: [PATCH] Start on Stereo Mode visuals - Buttons have been implemented. - They push down when you press an input. - FUTURE WORK: Back doesn't get the opportunity to do so. Delay the exit of this menu? - Certain ones have special properties. - PLAY locks down when playing and not paused - PAUSE locks down when playing and paused - TRACK is a wheel/slidery thing - BACK should get pressed when you're exiting (see previous FUTURE WORK) - FUTURE WORK: The detection of these currently uses magic numbers. - The Stereo itself is now drawn. - FUTURE WORK: The screen's contents are still the testing visuals. --- src/k_menudraw.c | 114 ++++++++++++++++++++++++++++--- src/menus/transient/sound-test.c | 30 +++++--- src/s_sound.h | 1 + 3 files changed, 128 insertions(+), 17 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 2be547a62..44d06ac5c 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5928,7 +5928,10 @@ void M_DrawStatistics(void) void M_DrawSoundTest(void) { - INT32 x = currentMenu->x - menutransition.tics*48, y, i, w, cursorx = 0; + UINT8 pid = 0; // todo: Add ability for any splitscreen player to bring up the menu. + + INT32 x, y, i, cursorx = 0; + patch_t *btn = W_CachePatchName("STER_BTN", PU_CACHE); if (gamestate == GS_MENU) { @@ -5936,10 +5939,20 @@ void M_DrawSoundTest(void) V_DrawFixedPatch(0, 0, FRACUNIT, 0, bg, NULL); } - y = 50; + V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("STER_BG", PU_CACHE), NULL); + + x = 24; + y = 18; if (soundtest.current != NULL) { + K_DrawMapThumbnail( + x<sequence.map, + NULL); + V_DrawThinString(x, y, (soundtest.playing ? highlightflags : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->title); V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("%d", soundtest.currenttrack)); if (soundtest.current->author) @@ -5956,21 +5969,106 @@ void M_DrawSoundTest(void) V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("%d", cv_soundtest.value)); } - y = currentMenu->y; + x = currentMenu->x; for (i = 0; i < currentMenu->numitems; i++) { - w = V_ThinStringWidth(currentMenu->menuitems[i].text, V_6WIDTHSPACE); + if (currentMenu->menuitems[i].status == IT_SPACE) + { + if (currentMenu->menuitems[i].mvar2 != 0) + { + x = currentMenu->menuitems[i].mvar2; + } + + x += currentMenu->menuitems[i].mvar1; + + continue; + } + + y = currentMenu->y; + if (i == itemOn) { - cursorx = x + w/2; - V_DrawThinString(x, y, V_6WIDTHSPACE|highlightflags, currentMenu->menuitems[i].text); + cursorx = x + 13; + } + + if (currentMenu->menuitems[i].tooltip) + { + V_SetClipRect( + x << FRACBITS, y << FRACBITS, + 27 << FRACBITS, 22 << FRACBITS, + 0 + ); + + // Special cases + if (currentMenu->menuitems[i].mvar2 == 1) // back + { + if (!soundtest.justopened && M_MenuBackHeld(pid)) + { + y = currentMenu->y + 7; + } + } + // The following are springlocks. + else if (currentMenu->menuitems[i].mvar2 == 2) // pause + { + if (soundtest.paused == true) + y = currentMenu->y + 6; + } + else if (currentMenu->menuitems[i].mvar2 == 3) // play + { + if (soundtest.playing == true && soundtest.paused == false) + y = currentMenu->y + 6; + } + + // Button is being pressed + if (i == itemOn && !soundtest.justopened && M_MenuConfirmHeld(pid)) + { + y = currentMenu->y + 7; + } + + // Button itself + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, 0, btn, NULL); + + // Icon + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, + FRACUNIT, 0, + W_CachePatchName(currentMenu->menuitems[i].tooltip, PU_CACHE), + NULL + ); + + // Text + V_DrawCenteredThinString(x + 13, y + 1, V_6WIDTHSPACE, currentMenu->menuitems[i].text); + + V_ClearClipRect(); + + V_DrawFill(x+2, currentMenu->y + 22, 23, 1, 30); + } + else if (currentMenu->menuitems[i].mvar2 == 4) // Track + { + if (i == itemOn) + { + if (menucmd[pid].dpad_ud < 0 || M_MenuConfirmHeld(pid)) + { + y--; + } + else if (menucmd[pid].dpad_ud > 0) + { + y++; + } + } + + V_DrawFixedPatch(x << FRACBITS, (y-1) << FRACBITS, + FRACUNIT, 0, + W_CachePatchName("STER_WH0", PU_CACHE), + NULL + ); } else { - V_DrawThinString(x, y, V_6WIDTHSPACE, currentMenu->menuitems[i].text); + V_DrawCenteredThinString(x + 13, y + 1, V_6WIDTHSPACE, currentMenu->menuitems[i].text); } - x += w + 8; + + x += 27; } V_DrawCharacter(cursorx - 4, currentMenu->y - 8 - (skullAnimCounter/5), diff --git a/src/menus/transient/sound-test.c b/src/menus/transient/sound-test.c index 045cdc246..0ef34f6ed 100644 --- a/src/menus/transient/sound-test.c +++ b/src/menus/transient/sound-test.c @@ -113,15 +113,26 @@ static void M_SoundTestTrack(INT32 choice) } } +static boolean M_SoundTestInputs(INT32 ch) +{ + (void)ch; + soundtest.justopened = false; + return false; +} + menuitem_t MISC_SoundTest[] = { - {IT_STRING | IT_CALL, "Back", NULL, NULL, {.routine = M_GoBack}, 0, 0}, - {IT_STRING | IT_CALL, "Stop", NULL, NULL, {.routine = M_SoundTestMainControl}, 0, 0}, - {IT_STRING | IT_CALL, "Pause", NULL, NULL, {.routine = M_SoundTestMainControl}, 2, 0}, - {IT_STRING | IT_CALL, "Play", NULL, NULL, {.routine = M_SoundTestMainControl}, 1, 0}, - {IT_STRING | IT_ARROWS, "Track", NULL, NULL, {.routine = M_SoundTestTrack}, 0, 0}, - {IT_STRING | IT_CALL, "Prev", NULL, NULL, {.routine = M_SoundTestNextPrev}, -1, 0}, - {IT_STRING | IT_CALL, "Next", NULL, NULL, {.routine = M_SoundTestNextPrev}, 1, 0}, + {IT_STRING | IT_CALL, "Back", "STER_IC0", NULL, {.routine = M_GoBack}, 0, 1}, + {IT_SPACE, NULL, NULL, NULL, {NULL}, 11, 0}, + {IT_STRING | IT_CALL, "Stop", "STER_IC1", NULL, {.routine = M_SoundTestMainControl}, 0, 0}, + {IT_SPACE, NULL, NULL, NULL, {NULL}, 8, 0}, + {IT_STRING | IT_CALL, "Pause", "STER_IC2", NULL, {.routine = M_SoundTestMainControl}, 2, 2}, + {IT_STRING | IT_CALL, "Play", "STER_IC3", NULL, {.routine = M_SoundTestMainControl}, 1, 3}, + {IT_SPACE, NULL, NULL, NULL, {NULL}, 8, 0}, + {IT_STRING | IT_CALL, "Prev", "STER_IC4", NULL, {.routine = M_SoundTestNextPrev}, -1, 0}, + {IT_STRING | IT_CALL, "Next", "STER_IC5", NULL, {.routine = M_SoundTestNextPrev}, 1, 0}, + {IT_SPACE, NULL, NULL, NULL, {NULL}, 0, 276}, + {IT_STRING | IT_ARROWS, "Track", NULL, NULL, {.routine = M_SoundTestTrack}, 0, 4}, }; menu_t MISC_SoundTestDef = { @@ -129,7 +140,7 @@ menu_t MISC_SoundTestDef = { &MainDef, 0, MISC_SoundTest, - 42, BASEVIDHEIGHT/2, + 19, 140, 0, 0, MBF_UD_LR_FLIPPED|MBF_SOUNDLESS, ".", @@ -138,7 +149,7 @@ menu_t MISC_SoundTestDef = { NULL, NULL, NULL, - NULL, + M_SoundTestInputs, }; void M_SoundTest(INT32 choice) @@ -146,6 +157,7 @@ void M_SoundTest(INT32 choice) (void)choice; // I reserve the right to add some sort of setup here -- toast 250323 + soundtest.justopened = true; MISC_SoundTestDef.prevMenu = currentMenu; M_SetupNextMenu(&MISC_SoundTestDef, false); diff --git a/src/s_sound.h b/src/s_sound.h index d39735f97..f17d5dba5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -212,6 +212,7 @@ extern struct soundtest { boolean playing; // Music is playing? boolean paused; // System paused? + boolean justopened; // Menu visual assist boolean privilegedrequest; // Overrides S_PlaysimMusicDisabled w/o changing every function signature musicdef_t *current; // Current selected music definition SINT8 currenttrack; // Current selected music track for definition