From 2c0645cba2f26fed68fe8d68af33637973dd1684 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 30 Mar 2023 18:36:09 +0100 Subject: [PATCH] Improve Stereo text header drawing - Use LSTitleHighString at the top of the menu for the music's title/Sound Test - Only show Track for relevant entries - Show cv_soundtest.value in hex for that Classic Sonic soundtest flavour --- src/k_menudraw.c | 34 ++++++++++++++++++++++++++++---- src/menus/transient/sound-test.c | 8 +++++++- src/s_sound.h | 4 ++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index f938524a9..737f3b1cc 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5931,6 +5931,9 @@ void M_DrawSoundTest(void) UINT8 pid = 0; // todo: Add ability for any splitscreen player to bring up the menu. INT32 x, y, i, cursorx = 0; + INT32 titleoffset = 0, titlewidth; + const char *titletext; + patch_t *btn = W_CachePatchName("STER_BTN", PU_CACHE); if (gamestate == GS_MENU) @@ -5950,6 +5953,8 @@ void M_DrawSoundTest(void) 0 ); + y += 32; + if (soundtest.current != NULL) { if (soundtest.current->sequence.map < nummapheaders) @@ -5962,8 +5967,11 @@ void M_DrawSoundTest(void) 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)); + titletext = soundtest.current->title; + + y -= 10; + if (soundtest.current->numtracks > 1) + V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("Track %c", 'A'+soundtest.currenttrack)); if (soundtest.current->author) V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->author); if (soundtest.current->source) @@ -5974,8 +5982,26 @@ void M_DrawSoundTest(void) else { const char *sfxstr = (cv_soundtest.value) ? S_sfx[cv_soundtest.value].name : "N/A"; - V_DrawThinString(x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, sfxstr); - V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("%d", cv_soundtest.value)); + + titletext = "Sound Test"; + + V_DrawThinString(x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, "Track "); + V_DrawThinString( + x + V_ThinStringWidth("Track ", V_ALLOWLOWERCASE|V_6WIDTHSPACE), + y, + V_6WIDTHSPACE, + va("%04X - %s", cv_soundtest.value, sfxstr) + ); + } + + titletext = va("%s - ", titletext); + titlewidth = V_LSTitleHighStringWidth(titletext, 0); + titleoffset = (-soundtest.menutick) % titlewidth; + + while (titleoffset < 272) + { + V_DrawLSTitleHighString(x + titleoffset, 18+1, 0, titletext); + titleoffset += titlewidth; } V_ClearClipRect(); diff --git a/src/menus/transient/sound-test.c b/src/menus/transient/sound-test.c index 68ca08304..2ce290809 100644 --- a/src/menus/transient/sound-test.c +++ b/src/menus/transient/sound-test.c @@ -144,6 +144,11 @@ static boolean M_SoundTestInputs(INT32 ch) return false; } +static void M_SoundTestTick(void) +{ + soundtest.menutick++; +} + menuitem_t MISC_SoundTest[] = { {IT_STRING | IT_CALL, "Back", "STER_IC0", NULL, {.routine = M_GoBack}, 0, stereospecial_back}, @@ -171,7 +176,7 @@ menu_t MISC_SoundTestDef = { ".", 98, 0, M_DrawSoundTest, - NULL, + M_SoundTestTick, NULL, NULL, M_SoundTestInputs, @@ -182,6 +187,7 @@ void M_SoundTest(INT32 choice) (void)choice; // I reserve the right to add some sort of setup here -- toast 250323 + soundtest.menutick = 0; soundtest.justopened = true; MISC_SoundTestDef.prevMenu = currentMenu; diff --git a/src/s_sound.h b/src/s_sound.h index f17d5dba5..fb711225f 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -214,8 +214,12 @@ extern struct soundtest boolean paused; // System paused? boolean justopened; // Menu visual assist boolean privilegedrequest; // Overrides S_PlaysimMusicDisabled w/o changing every function signature + + INT32 menutick; + musicdef_t *current; // Current selected music definition SINT8 currenttrack; // Current selected music track for definition + soundtestsequence_t sequence; // Sequence head } soundtest;