Skip to content

Commit

Permalink
Fix missing unglowing effects and improve some menu code
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictress committed Nov 16, 2024
1 parent cf45630 commit ff04a93
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 116 deletions.
82 changes: 23 additions & 59 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ static byte *M_Cursor_Glow (int tics)
enum
{
saveload_border,
saveload_slider,
saveload_text,
saveload_cursor,
};
Expand All @@ -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:
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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));
Expand All @@ -5308,7 +5289,6 @@ M_DrawThermo
}

V_DrawPatch((x + 8) + thermDot * 8, y, W_CacheLumpName(DEH_String("M_THERMO"), PU_CACHE));

dp_translation = NULL;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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},
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

Expand Down
41 changes: 12 additions & 29 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ static byte *M_Cursor_Glow (int tics)
enum
{
saveload_border,
saveload_slider,
saveload_text,
saveload_cursor,
};
Expand All @@ -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:
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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",
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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)
Expand Down
39 changes: 11 additions & 28 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ static byte *M_Cursor_Glow (int tics)
enum
{
saveload_border,
saveload_slider,
saveload_text,
saveload_cursor,
};
Expand All @@ -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:
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ff04a93

Please sign in to comment.