Skip to content

Commit

Permalink
Merge pull request #547 from andrikpowell/dsda-dark-overlay
Browse files Browse the repository at this point in the history
Implement dark overlay for menus and automap
  • Loading branch information
Pedro-Beirao authored Dec 7, 2024
2 parents b1cb132 + b852a15 commit 7537262
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 40 deletions.
28 changes: 19 additions & 9 deletions prboom2/src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "m_misc.h"
#include "m_bbox.h"
#include "d_main.h"
#include "m_menu.h"

#include "dsda/id_list.h"
#include "dsda/input.h"
Expand Down Expand Up @@ -619,7 +620,7 @@ void AM_SetPosition(void)
f_x = f_y = 0;
f_w = SCREENWIDTH;

if (automap_overlay)
if (automap_overlay > 0)
{
f_h = viewheight;
}
Expand Down Expand Up @@ -1008,6 +1009,18 @@ dboolean AM_Responder
{
static int bigstate=0;

if (dsda_InputActivated(dsda_input_map_overlay) && (automap_input || dsda_ShowMinimap()))
{
dsda_CycleConfig(dsda_config_automap_overlay, true);
dsda_AddMessage(automap_overlay == 0 ? s_AMSTR_OVERLAYOFF :
automap_overlay == 1 ? s_AMSTR_OVERLAYON :
"Overlay Mode Dark");
AM_SetPosition();
AM_activateNewScale();

return true;
}

if (!automap_input)
{
if (dsda_InputActivated(dsda_input_map))
Expand Down Expand Up @@ -1149,14 +1162,6 @@ dboolean AM_Responder

return true;
}
else if (dsda_InputActivated(dsda_input_map_overlay))
{
dsda_ToggleConfig(dsda_config_automap_overlay, true);
AM_SetPosition();
AM_activateNewScale();

return true;
}
else if (dsda_InputActivated(dsda_input_map_textured))
{
dsda_ToggleConfig(dsda_config_map_textured, true);
Expand Down Expand Up @@ -2773,6 +2778,9 @@ void AM_Drawer (dboolean minimap)
if (!automap_active && !minimap)
return;

if (automap_active && automap_overlay == 2 && minimap)
return;

V_BeginAutomapDraw();

if (automap_follow)
Expand All @@ -2796,6 +2804,8 @@ void AM_Drawer (dboolean minimap)

if (!automap_overlay) // cph - If not overlay mode, clear background for the automap
V_FillRect(FB, f_x, f_y, f_w, f_h, (byte)mapcolor_p->back); //jff 1/5/98 background default color
if (automap_overlay == 2 && !M_MenuIsShaded())
V_DrawShaded(FB, f_x, f_y, f_w, f_h, FULLSHADE);

if (map_textured)
{
Expand Down
3 changes: 2 additions & 1 deletion prboom2/src/doomstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ extern int automap_follow;
extern int automap_grid;

#define automap_on (automap_active && !automap_overlay)
#define automap_off (!automap_on)
#define automap_off (!automap_active && automap_overlay > 0)
#define automap_stbar (automap_active && R_StatusBarVisible())
#define automap_input (automap_active)
#define automap_hud (automap_active && !automap_overlay)

Expand Down
4 changes: 2 additions & 2 deletions prboom2/src/dsda/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ dsda_config_t dsda_config[dsda_config_count] = {
},
[dsda_config_menu_background] = {
"menu_background", dsda_config_menu_background,
CONF_BOOL(1)
dsda_config_int, 0, 2, { 1 }
},
[dsda_config_process_priority] = {
"process_priority", dsda_config_process_priority,
Expand Down Expand Up @@ -1046,7 +1046,7 @@ dsda_config_t dsda_config[dsda_config_count] = {
},
[dsda_config_automap_overlay] = {
"automap_overlay", dsda_config_automap_overlay,
CONF_BOOL(0), &automap_overlay
dsda_config_int, 0, 2, { 0 }, &automap_overlay
},
[dsda_config_automap_rotate] = {
"automap_rotate", dsda_config_automap_rotate,
Expand Down
4 changes: 2 additions & 2 deletions prboom2/src/dsda/exhud.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static void dsda_UpdateComponents(exhud_component_t* update_components) {
}

void dsda_UpdateExHud(void) {
if (automap_on) {
if (automap_stbar) {
if (containers[hud_map].loaded)
dsda_UpdateComponents(containers[hud_map].components);

Expand Down Expand Up @@ -689,7 +689,7 @@ int global_patch_top_offset;
void dsda_DrawExHud(void) {
global_patch_top_offset = M_ConsoleOpen() ? dsda_ConsoleHeight() : 0;

if (automap_on) {
if (automap_stbar) {
if (containers[hud_map].loaded)
dsda_DrawComponents(containers[hud_map].components);
}
Expand Down
29 changes: 27 additions & 2 deletions prboom2/src/gl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void gld_MapDrawSubsectors(player_t *plr, int fx, int fy, fixed_t mx, fixed_t my
float coord_scale;
GLTexture *gltexture;

alpha = (float)(automap_overlay ? map_textured_overlay_trans : map_textured_trans) / 100.0f;
alpha = (float)((automap_overlay > 0) ? map_textured_overlay_trans : map_textured_trans) / 100.0f;
if (alpha == 0)
return;

Expand Down Expand Up @@ -714,7 +714,7 @@ void gld_DrawLine_f(float x0, float y0, float x1, float y1, int BaseColor)
unsigned char a;
map_line_t *line;

a = (automap_overlay ? map_lines_overlay_trans * 255 / 100 : 255);
a = ((automap_overlay == 1) ? map_lines_overlay_trans * 255 / 100 : 255);
if (a == 0)
return;

Expand Down Expand Up @@ -848,6 +848,31 @@ void gld_FillBlock(int x, int y, int width, int height, int col)
glsl_PopNullShader();
}

void gld_DrawShaded(int x, int y, int width, int height, int shade)
{
color_rgb_t color = gld_LookupIndexedColor(playpal_black, V_IsAutomapLightmodeIndexed());

glsl_PushNullShader();

gld_EnableTexture2D(GL_TEXTURE0_ARB, false);

glColor4f((float)color.r/255.0f,
(float)color.g/255.0f,
(float)color.b/255.0f,
(float)shade/30);

glBegin(GL_TRIANGLE_STRIP);
glVertex2i( x, y );
glVertex2i( x, y+height );
glVertex2i( x+width, y );
glVertex2i( x+width, y+height );
glEnd();
glColor4f(1.0f,1.0f,1.0f,1.0f);
gld_EnableTexture2D(GL_TEXTURE0_ARB, true);

glsl_PopNullShader();
}

void gld_SetPalette(int palette)
{
static int last_palette = 0;
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/gl_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void gld_DrawLine(int x0, int y0, int x1, int y1, int BaseColor);
void gld_DrawLine_f(float x0, float y0, float x1, float y1, int BaseColor);
void gld_DrawWeapon(int weaponlump, vissprite_t *vis, int lightlevel);
void gld_FillBlock(int x, int y, int width, int height, int col);
void gld_DrawShaded(int x, int y, int width, int height, int shade);
void gld_SetPalette(int palette);
unsigned char *gld_ReadScreen(void);

Expand Down
3 changes: 2 additions & 1 deletion prboom2/src/heretic/sb_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "doomstat.h"
#include "m_cheat.h"
#include "m_menu.h"
#include "m_random.h"
#include "v_video.h"
#include "r_main.h"
Expand Down Expand Up @@ -537,7 +538,7 @@ static int oldpieces = -1;

void SB_Drawer(dboolean statusbaron, dboolean refresh, dboolean fullmenu)
{
if (refresh || fullmenu || V_IsOpenGLMode()) SB_state = -1;
if (refresh || fullmenu || fadeBG() || V_IsOpenGLMode()) SB_state = -1;

if (!statusbaron)
{
Expand Down
3 changes: 2 additions & 1 deletion prboom2/src/hu_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "p_tick.h"
#include "p_map.h"
#include "sc_man.h"
#include "m_menu.h"
#include "m_misc.h"
#include "r_main.h"
#include "lprintf.h"
Expand Down Expand Up @@ -364,7 +365,7 @@ void HU_Start(void)
void HU_Drawer(void)
{
// don't draw anything if there's a fullscreen menu up
if (menuactive == mnact_full)
if (menuactive == mnact_full && !M_MenuIsShaded())
return;

V_BeginUIDraw();
Expand Down
71 changes: 51 additions & 20 deletions prboom2/src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,25 @@

extern dboolean message_dontfuckwithme;

/////////////////////////////
//
// booleans for setup screens
// these tell you what state the setup screens are in, and whether any of
// the overlay screens (automap colors, reset button message) should be
// displayed

dboolean setup_active = false; // in one of the setup screens
dboolean set_keybnd_active = false; // in key binding setup screens
dboolean set_weapon_active = false; // in weapons setup screen
dboolean set_status_active = false; // in status bar/hud setup screen
dboolean set_auto_active = false; // in automap setup screen
dboolean setup_select = false; // changing an item
dboolean setup_gather = false; // gathering keys for value
dboolean colorbox_active = false; // color palette being shown
dboolean set_general_active = false;
dboolean level_table_active = false;


extern const char* g_menu_flat;
extern int g_menu_save_page_size;
extern int g_menu_font_spacing;
Expand Down Expand Up @@ -188,7 +207,7 @@ void (*messageRoutine)(int response);

static void M_DrawBackground(const char *flat, int scrn)
{
if (dsda_IntConfig(dsda_config_menu_background))
if (dsda_IntConfig(dsda_config_menu_background) == 2)
V_DrawBackground(flat, scrn);
}

Expand Down Expand Up @@ -1250,6 +1269,8 @@ static void M_QuitResponse(dboolean affirmative)
void M_QuitDOOM(int choice)
{
static char endstring[160];
setup_active = false;
currentMenu = NULL;

// We pick index 0 which is language sensitive,
// or one at random, between 1 and maximum number.
Expand Down Expand Up @@ -1508,24 +1529,6 @@ void M_SizeDisplay(int choice)
// killough 10/98: added Compatibility and General menus
//

/////////////////////////////
//
// booleans for setup screens
// these tell you what state the setup screens are in, and whether any of
// the overlay screens (automap colors, reset button message) should be
// displayed

dboolean setup_active = false; // in one of the setup screens
dboolean set_keybnd_active = false; // in key binding setup screens
dboolean set_weapon_active = false; // in weapons setup screen
dboolean set_status_active = false; // in status bar/hud setup screen
dboolean set_auto_active = false; // in automap setup screen
dboolean setup_select = false; // changing an item
dboolean setup_gather = false; // gathering keys for value
dboolean colorbox_active = false; // color palette being shown
dboolean set_general_active = false;
dboolean level_table_active = false;

/////////////////////////////
//
// set_menu_itemon is an index that starts at zero, and tells you which
Expand Down Expand Up @@ -3098,6 +3101,8 @@ setup_menu_t misc_settings[] = {
FINAL_ENTRY
};

static const char* menu_background_list[] = { "Off", "Dark", "Texture", NULL };

setup_menu_t display_settings[] = {
{ "Display Options", S_SKIP | S_TITLE, m_null, G_X},
{ "Use Extended Hud", S_YESNO, m_conf, G_X, dsda_config_exhud },
Expand All @@ -3117,7 +3122,7 @@ setup_menu_t display_settings[] = {
{ "Change Palette On Powers", S_YESNO, m_conf, G_X, dsda_config_palette_onpowers },
EMPTY_LINE,
{ "Status Bar and Menu Appearance", S_CHOICE, m_conf, G_X, dsda_config_render_stretch_hud, 0, render_stretch_list },
{ "Fullscreen Menu Background", S_YESNO, m_conf, G_X, dsda_config_menu_background },
{ "Fullscreen Menu Background", S_CHOICE, m_conf, G_X, dsda_config_menu_background, 0, menu_background_list },

PREV_PAGE(misc_settings),
NEXT_PAGE(mapping_settings),
Expand Down Expand Up @@ -5827,6 +5832,29 @@ void M_StartControlPanel (void)
itemOn = currentMenu->lastOn; // JDC
}


/////////////////////////////////////////////////////////////////////////////
//
// Menu Shaded Overlay Stuff
//
// This displays a dark overlay under certain screens of the menus

dboolean fadeBG(void)
{
return dsda_IntConfig(dsda_config_menu_background) == 1;
}

dboolean M_MenuIsShaded(void)
{
int Options = (setup_active || currentMenu == &OptionsDef || currentMenu == &SoundDef);
return fadeBG() && Options;
}

static void M_ShadedScreen(int scrn)
{
V_DrawShaded(scrn, 0, 0, SCREENWIDTH, SCREENHEIGHT, FULLSHADE);
}

//
// M_Drawer
// Called after the view has been rendered,
Expand All @@ -5839,6 +5867,9 @@ void M_Drawer (void)
{
V_BeginUIDraw();

if (M_MenuIsShaded())
M_ShadedScreen(0);

inhelpscreens = false;

// Horiz. & Vertically center string and print it.
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/m_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@

dboolean M_Responder (event_t *ev);

dboolean fadeBG(void);
dboolean M_MenuIsShaded(void);
#define FULLSHADE 20

// Called by main loop,
// only used for menu (skull cursor) animation.

Expand Down
5 changes: 3 additions & 2 deletions prboom2/src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "r_main.h"
#include "am_map.h"
#include "m_cheat.h"
#include "m_menu.h"
#include "s_sound.h"
#include "sounds.h"
#include "dstrings.h"
Expand Down Expand Up @@ -893,7 +894,7 @@ void ST_Refresh(void)
void ST_Drawer(dboolean refresh)
{
dboolean statusbaron = R_StatusBarVisible();
dboolean fullmenu = (menuactive == mnact_full);
dboolean fullmenu = (menuactive == mnact_full) && !M_MenuIsShaded();

V_BeginUIDraw();

Expand All @@ -913,7 +914,7 @@ void ST_Drawer(dboolean refresh)
ST_doPaletteStuff(); // Do red-/gold-shifts from damage/items

if (statusbaron) {
if (st_firsttime || (V_IsOpenGLMode()))
if (st_firsttime || (V_IsOpenGLMode() || fadeBG()))
{
/* If just after ST_Start(), refresh all */
st_firsttime = false;
Expand Down
Loading

0 comments on commit 7537262

Please sign in to comment.