From a599174b61e658ebeb0f027dcbf75d57600cd678 Mon Sep 17 00:00:00 2001 From: Alaux <73968015+MrAlaux@users.noreply.github.com> Date: Mon, 28 Nov 2022 04:31:08 -0300 Subject: [PATCH] Implement dark automap overlay (#813) * Implement dark automap overlay * Second implementation * Third implementation * Fourth implementation * Introduce `M_MenuIsShaded()` --- src/am_map.c | 21 +++++++++++++++------ src/d_main.c | 5 +++-- src/doomstat.h | 10 +++++++++- src/m_menu.c | 38 ++++++++++++++------------------------ src/m_menu.h | 3 +++ src/m_misc.c | 5 ++--- src/v_video.c | 30 ++++++++++++++++++++++++++++++ src/v_video.h | 2 ++ 8 files changed, 78 insertions(+), 36 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 6623ae69..1049ca06 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -40,6 +40,7 @@ #include "dstrings.h" #include "d_deh.h" // Ty 03/27/98 - externalizations #include "m_input.h" +#include "m_menu.h" //jff 1/7/98 default automap colors added int mapcolor_back; // map background @@ -247,7 +248,7 @@ int automap_grid = 0; boolean automapactive = false; -boolean automapoverlay = false; +overlay_t automapoverlay = overlay_off; // location of window on screen static int f_x; @@ -943,11 +944,15 @@ boolean AM_Responder else if (M_InputActivated(input_map_overlay)) { - automapoverlay = !automapoverlay; - if (automapoverlay) - plr->message = s_AMSTR_OVERLAYON; - else - plr->message = s_AMSTR_OVERLAYOFF; + if (++automapoverlay > overlay_dark) + automapoverlay = overlay_off; + + switch (automapoverlay) + { + case 2: plr->message = "Dark Overlay On"; break; + case 1: plr->message = s_AMSTR_OVERLAYON; break; + default: plr->message = s_AMSTR_OVERLAYOFF; break; + } } else if (M_InputActivated(input_map_rotate)) { @@ -2309,6 +2314,10 @@ void AM_Drawer (void) AM_clearFB(mapcolor_back); //jff 1/5/98 background default color pspr_interp = false; } + // [Alaux] Dark automap overlay + else if (automapoverlay == overlay_dark && !M_MenuIsShaded()) + V_ShadeScreen(); + if (automap_grid) // killough 2/28/98: change var name AM_drawGrid(mapcolor_grid); //jff 1/7/98 grid default color AM_drawWalls(); diff --git a/src/d_main.c b/src/d_main.c index b2625ac6..fe321d6f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -255,7 +255,7 @@ void D_Display (void) case GS_LEVEL: if (!gametic) break; - if (automapactive) + if (automapactive && !automapoverlay) { // [FG] update automap while playing R_RenderPlayerView (&players[displayplayer]); @@ -279,7 +279,7 @@ void D_Display (void) } // draw the view directly - if (gamestate == GS_LEVEL && !automapactive && gametic) + if (gamestate == GS_LEVEL && (!automapactive || automapoverlay) && gametic) R_RenderPlayerView (&players[displayplayer]); if (gamestate == GS_LEVEL && gametic) @@ -316,6 +316,7 @@ void D_Display (void) if (gamestate == GS_LEVEL && automapactive && automapoverlay) { AM_Drawer(); + ST_Drawer(scaledviewheight == 200, redrawsbar); HU_Drawer(); // [crispy] force redraw of status bar and border diff --git a/src/doomstat.h b/src/doomstat.h index 33732a20..301cd9d1 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -248,7 +248,15 @@ extern int snd_DesiredSfxDevice; extern boolean statusbaractive; extern boolean automapactive; // In AutoMap mode? -extern boolean automapoverlay; + +typedef enum +{ + overlay_off, + overlay_on, + overlay_dark, +} overlay_t; + +extern overlay_t automapoverlay; extern boolean automaprotate; extern boolean menuactive; // Menu overlayed? extern boolean paused; // Game Pause? diff --git a/src/m_menu.c b/src/m_menu.c index 97159e97..f4971239 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3429,6 +3429,10 @@ enum { auto1_flash, }; +static const char *overlay_strings[] = { + "Off", "On", "Dark", NULL +}; + // [FG] show level statistics and level time widgets static const char *show_widgets_strings[] = { "Off", "On Automap", "Always", NULL @@ -3439,9 +3443,9 @@ extern void AM_enableSmoothLines(void); setup_menu_t auto_settings1[] = // 1st AutoMap Settings screen { {"Modes",S_SKIP|S_TITLE,m_null,M_X,M_Y}, - {"Follow Player" ,S_YESNO,m_null,M_X,M_Y+auto1_follow*M_SPC, {"followplayer"}}, - {"Rotate Automap" ,S_YESNO,m_null,M_X,M_Y+auto1_rotate*M_SPC, {"automaprotate"}}, - {"Overlay Automap" ,S_YESNO,m_null,M_X,M_Y+auto1_overlay*M_SPC, {"automapoverlay"}}, + {"Follow Player" ,S_YESNO ,m_null,M_X,M_Y+auto1_follow*M_SPC, {"followplayer"}}, + {"Rotate Automap" ,S_YESNO ,m_null,M_X,M_Y+auto1_rotate*M_SPC, {"automaprotate"}}, + {"Overlay Automap" ,S_CHOICE,m_null,M_X,M_Y+auto1_overlay*M_SPC, {"automapoverlay"}, 0, NULL, overlay_strings}, {"",S_SKIP,m_null,M_X,M_Y+auto1_stub1*M_SPC}, @@ -6527,29 +6531,15 @@ void M_StartControlPanel (void) // killough 9/29/98: Significantly reformatted source // +boolean M_MenuIsShaded(void) +{ + return setup_active && menu_background == 2; +} + void M_Drawer (void) { - static int menushade; - - if (setup_active && menu_background == 2) - { - int y; - byte *dest = screens[0]; - static int firsttic; - - for (y = 0; y < (SCREENWIDTH << hires) * (SCREENHEIGHT << hires); y++) - { - dest[y] = colormaps[0][menushade * 256 + dest[y]]; - } - - if (menushade < 16 && gametic != firsttic) - { - menushade += 2; - firsttic = gametic; - } - } - else if (menushade) - menushade = 0; + if (M_MenuIsShaded()) + V_ShadeScreen(); inhelpscreens = false; diff --git a/src/m_menu.h b/src/m_menu.h index 8da5dd3a..eabd9f06 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -184,6 +184,9 @@ typedef struct setup_menu_s const char **selectstrings; // [FG] selection of choices } setup_menu_t; +extern int menu_background; +extern boolean M_MenuIsShaded(void); + #endif //---------------------------------------------------------------------------- diff --git a/src/m_misc.c b/src/m_misc.c index c2bda0ec..082fbea2 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -108,7 +108,6 @@ extern boolean screen_melt; extern boolean hangsolid; extern boolean blockmapfix; extern int extra_level_brightness; -extern int menu_background; extern char *chat_macros[]; // killough 10/98 @@ -1815,8 +1814,8 @@ default_t defaults[] = { { "automapoverlay", (config_t *) &automapoverlay, NULL, - {0}, {0,1}, number, ss_auto, wad_no, - "1 to enable automap overlay mode" + {0}, {0,2}, number, ss_auto, wad_no, + "automap overlay mode (1 = on, 2 = dark)" }, { diff --git a/src/v_video.c b/src/v_video.c index cda2246c..909ac56b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -858,6 +858,36 @@ void V_DrawHorizLine(int x, int y, int scrn, int width, byte color) } } +void V_ShadeScreen(void) +{ + int y; + byte *dest = screens[0]; + const int targshade = 20; + static int oldtic = -1; + static int screenshade; + + // [FG] longer than one tic ago? start a new sequence + if (gametic - oldtic > 1) + { + screenshade = 0; + } + + for (y = 0; y < (SCREENWIDTH << hires) * (SCREENHEIGHT << hires); y++) + { + dest[y] = colormaps[0][screenshade * 256 + dest[y]]; + } + + if (screenshade < targshade && gametic != oldtic) + { + screenshade += 2; + + if (screenshade > targshade) + screenshade = targshade; + } + + oldtic = gametic; +} + // // V_Init // diff --git a/src/v_video.h b/src/v_video.h index c0f4ada5..4478fd96 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -135,6 +135,8 @@ void V_PutBlock(int x, int y, int scrn, int width, int height, byte *src); void V_DrawHorizLine(int x, int y, int scrn, int width, byte color); +void V_ShadeScreen(void); + // [FG] colored blood and gibs int V_BloodColor(int blood);