From ff04a9349dfa785c02901c552ac51a2808d6aa7b Mon Sep 17 00:00:00 2001 From: pvictress <185700473+pvictress@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:54:02 +0300 Subject: [PATCH] Fix missing unglowing effects and improve some menu code --- src/doom/m_menu.c | 82 ++++++++++++------------------------------- src/heretic/mn_menu.c | 41 +++++++--------------- src/hexen/mn_menu.c | 39 ++++++-------------- 3 files changed, 46 insertions(+), 116 deletions(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index 4c6b091..914d81c 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -1145,6 +1145,7 @@ static byte *M_Cursor_Glow (int tics) enum { saveload_border, + saveload_slider, saveload_text, saveload_cursor, }; @@ -1157,6 +1158,7 @@ static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type) switch (type) { case saveload_border: + case saveload_slider: return itemSetOn ? cr[CR_MENU_BRIGHT2] : NULL; case saveload_text: @@ -4985,31 +4987,13 @@ static void M_DrawSound(void) static void M_SfxVol (int choice) { - if (choice == 0 && sfxVolume > 0) - { - sfxVolume--; - } - else - if (choice == 1 && sfxVolume < 15) - { - sfxVolume++; - } - + sfxVolume = M_INT_Slider(sfxVolume, 0, 15, choice, true); S_SetSfxVolume(sfxVolume * 8); } static void M_MusicVol (int choice) { - if (choice == 0 && musicVolume > 0) - { - musicVolume--; - } - else - if (choice == 1 && musicVolume < 15) - { - musicVolume++; - } - + musicVolume = M_INT_Slider(musicVolume, 0, 15, choice, true); S_SetMusicVolume(musicVolume * 8); } @@ -5186,11 +5170,11 @@ static void M_QuitResponse(int key) else { // [PN] Define quit sounds arrays locally - const int quitsounds[8] = { + static const int quitsounds[8] = { sfx_pldeth, sfx_dmpain, sfx_popain, sfx_slop, sfx_telept, sfx_posit1, sfx_posit3, sfx_sgtatk }; - const int quitsounds2[8] = { + static const int quitsounds2[8] = { sfx_vilact, sfx_getpow, sfx_boscub, sfx_slop, sfx_skeswg, sfx_kntdth, sfx_bspact, sfx_sgtatk }; @@ -5286,10 +5270,7 @@ M_DrawThermo int i; // [JN] Highlight active slider and gem. - if (itemPos == itemOn) - { - dp_translation = cr[CR_MENU_BRIGHT2]; - } + dp_translation = M_SaveLoad_Glow(itemPos == itemOn, 0, saveload_slider); xx = x; V_DrawShadowedPatchOptional(xx, y, 0, W_CacheLumpName(DEH_String("M_THERML"), PU_CACHE)); @@ -5308,7 +5289,6 @@ M_DrawThermo } V_DrawPatch((x + 8) + thermDot * 8, y, W_CacheLumpName(DEH_String("M_THERMO"), PU_CACHE)); - dp_translation = NULL; } @@ -5317,10 +5297,7 @@ static void M_DrawGammaThermo (int x, int y, int width, int dot, int itemPos) int xx = x; // [JN] Highlight active slider and gem. - if (itemPos == itemOn) - { - dp_translation = cr[CR_MENU_BRIGHT2]; - } + dp_translation = M_SaveLoad_Glow(itemPos == itemOn, 0, saveload_slider); V_DrawShadowedPatchOptional(xx, y, 0, W_CacheLumpName("M_THERML", PU_CACHE)); xx += 8; @@ -5562,7 +5539,7 @@ static int G_ReloadLevel (void) static int G_GotoNextLevel (void) { - byte doom_next[6][9] = { + static byte doom_next[6][9] = { {12, 13, 19, 15, 16, 17, 18, 21, 14}, {22, 23, 24, 25, 29, 27, 28, 31, 26}, {32, 33, 34, 35, 36, 39, 38, 41, 37}, @@ -5571,7 +5548,7 @@ static int G_GotoNextLevel (void) {62, 63, 69, 65, 66, 67, 68, 11, 64}, }; - byte doom2_next[33] = { + static byte doom2_next[33] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 31, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, @@ -5637,8 +5614,10 @@ static int G_GotoNextLevel (void) } else { - epsd = doom_next[gameepisode-1][gamemap-1] / 10; - map = doom_next[gameepisode-1][gamemap-1] % 10; + const int level = doom_next[gameepisode - 1][gamemap - 1]; + + epsd = level / 10; + map = level % 10; } G_DeferedInitNew(gameskill, epsd, map); @@ -6573,38 +6552,23 @@ void M_Ticker (void) { if (--skullAnimCounter <= 0) { - whichSkull ^= 1; - skullAnimCounter = 8; + whichSkull ^= 1; + skullAnimCounter = 8; } - // [JN] Menu glowing animation: - - // Brightening - if (!cursor_direction && ++cursor_tics == 8) - { - cursor_direction = true; - } - // Darkening - else - if (cursor_direction && --cursor_tics == -8) + // [JN] Cursor glowing animation: + cursor_tics += cursor_direction ? -1 : 1; + if (cursor_tics == 8 || cursor_tics == -8) { - cursor_direction = false; + cursor_direction = !cursor_direction; } // [JN] Menu item fading effect: - + // Keep menu item bright or decrease tics for fading effect. for (int i = 0 ; i < currentMenu->numitems ; i++) { - if (itemOn == i) - { - // Keep menu item bright - currentMenu->menuitems[i].tics = 5; - } - else - { - // Decrease tics for glowing effect - currentMenu->menuitems[i].tics--; - } + currentMenu->menuitems[i].tics = + (itemOn == i) ? 5 : currentMenu->menuitems[i].tics - 1; } } diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c index 203ee40..0d0a3c5 100644 --- a/src/heretic/mn_menu.c +++ b/src/heretic/mn_menu.c @@ -1013,6 +1013,7 @@ static byte *M_Cursor_Glow (int tics) enum { saveload_border, + saveload_slider, saveload_text, saveload_cursor, }; @@ -1025,6 +1026,7 @@ static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type) switch (type) { case saveload_border: + case saveload_slider: return itemSetOn ? cr[CR_MENU_BRIGHT2] : NULL; case saveload_text: @@ -4723,40 +4725,24 @@ void MN_Ticker(void) MenuTime++; // [JN] Don't go any farther with effects while active info screens. - if (InfoType) { return; } - // [JN] Menu glowing animation: - - if (!cursor_direction && ++cursor_tics == 8) + // [JN] Cursor glowing animation: + cursor_tics += cursor_direction ? -1 : 1; + if (cursor_tics == 8 || cursor_tics == -8) { - // Brightening - cursor_direction = true; - } - else - if (cursor_direction && --cursor_tics == -8) - { - // Darkening - cursor_direction = false; + cursor_direction = !cursor_direction; } // [JN] Menu item fading effect: - + // Keep menu item bright or decrease tics for fading effect. for (int i = 0 ; i < CurrentMenu->itemCount ; i++) { - if (CurrentItPos == i) - { - // Keep menu item bright - CurrentMenu->items[i].tics = 5; - } - else - { - // Decrease tics for glowing effect - CurrentMenu->items[i].tics--; - } + CurrentMenu->items[i].tics = + (CurrentItPos == i) ? 5 : CurrentMenu->items[i].tics - 1; } } @@ -4766,7 +4752,7 @@ void MN_Ticker(void) // //--------------------------------------------------------------------------- -char *QuitEndMsg[] = { +static const char *QuitEndMsg[] = { "ARE YOU SURE YOU WANT TO QUIT?", "ARE YOU SURE YOU WANT TO END THE GAME?", "DO YOU WANT TO QUICKSAVE THE GAME NAMED", @@ -5487,7 +5473,7 @@ static int G_ReloadLevel (void) static int G_GotoNextLevel(void) { - byte heretic_next[6][9] = { + static byte heretic_next[6][9] = { {12, 13, 14, 15, 16, 19, 18, 21, 17}, {22, 23, 24, 29, 26, 27, 28, 31, 25}, {32, 33, 34, 39, 36, 37, 38, 41, 35}, @@ -6519,10 +6505,7 @@ static void DrawSlider(Menu_t * menu, int item, int width, int slot, boolean big y = menu->y + 2 + (item * (bigspacing ? ITEM_HEIGHT : ID_MENU_LINEHEIGHT_SMALL)); // [JN] Highlight active slider and gem. - if (itemPos == CurrentItPos) - { - dp_translation = cr[CR_MENU_BRIGHT2]; - } + dp_translation = M_SaveLoad_Glow(itemPos == CurrentItPos, 0, saveload_slider); V_DrawShadowedPatchOptional(x - 32, y, 1, W_CacheLumpName(DEH_String("M_SLDLT"), PU_CACHE)); for (x2 = x, count = width; count--; x2 += 8) diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index 157163c..cc1bf5c 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -966,6 +966,7 @@ static byte *M_Cursor_Glow (int tics) enum { saveload_border, + saveload_slider, saveload_text, saveload_cursor, }; @@ -978,6 +979,7 @@ static byte *M_SaveLoad_Glow (int itemSetOn, int tics, int type) switch (type) { case saveload_border: + case saveload_slider: return itemSetOn ? cr[CR_MENU_BRIGHT2] : NULL; case saveload_text: @@ -4060,40 +4062,24 @@ void MN_Ticker(void) MenuTime++; // [JN] Don't go any farther with effects while active info screens. - if (InfoType) { return; } - // [JN] Menu glowing animation: - - if (!cursor_direction && ++cursor_tics == 8) + // [JN] Cursor glowing animation: + cursor_tics += cursor_direction ? -1 : 1; + if (cursor_tics == 8 || cursor_tics == -8) { - // Brightening - cursor_direction = true; - } - else - if (cursor_direction && --cursor_tics == -8) - { - // Darkening - cursor_direction = false; + cursor_direction = !cursor_direction; } // [JN] Menu item fading effect: - + // Keep menu item bright or decrease tics for fading effect. for (int i = 0 ; i < CurrentMenu->itemCount ; i++) { - if (CurrentItPos == i) - { - // Keep menu item bright - CurrentMenu->items[i].tics = 5; - } - else - { - // Decrease tics for glowing effect - CurrentMenu->items[i].tics--; - } + CurrentMenu->items[i].tics = + (CurrentItPos == i) ? 5 : CurrentMenu->items[i].tics - 1; } } @@ -4103,7 +4089,7 @@ void MN_Ticker(void) // //--------------------------------------------------------------------------- -const char *QuitEndMsg[] = { +static const char *QuitEndMsg[] = { "ARE YOU SURE YOU WANT TO QUIT?", "ARE YOU SURE YOU WANT TO END THE GAME?", "DO YOU WANT TO QUICKSAVE THE GAME NAMED", @@ -5982,10 +5968,7 @@ static void DrawSlider(Menu_t * menu, int item, int width, int slot, boolean big y = menu->y + 2 + (item * (bigspacing ? ITEM_HEIGHT : ID_MENU_LINEHEIGHT_SMALL)); // [JN] Highlight active slider and gem. - if (itemPos == CurrentItPos) - { - dp_translation = cr[CR_MENU_BRIGHT2]; - } + dp_translation = M_SaveLoad_Glow(itemPos == CurrentItPos, 0, saveload_slider); V_DrawShadowedPatchOptional(x - 32, y, 1, W_CacheLumpName("M_SLDLT", PU_CACHE)); for (x2 = x, count = width; count--; x2 += 8)