Skip to content

Commit 7537262

Browse files
authored
Merge pull request #547 from andrikpowell/dsda-dark-overlay
Implement dark overlay for menus and automap
2 parents b1cb132 + b852a15 commit 7537262

File tree

13 files changed

+154
-40
lines changed

13 files changed

+154
-40
lines changed

prboom2/src/am_map.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "m_misc.h"
5858
#include "m_bbox.h"
5959
#include "d_main.h"
60+
#include "m_menu.h"
6061

6162
#include "dsda/id_list.h"
6263
#include "dsda/input.h"
@@ -619,7 +620,7 @@ void AM_SetPosition(void)
619620
f_x = f_y = 0;
620621
f_w = SCREENWIDTH;
621622

622-
if (automap_overlay)
623+
if (automap_overlay > 0)
623624
{
624625
f_h = viewheight;
625626
}
@@ -1008,6 +1009,18 @@ dboolean AM_Responder
10081009
{
10091010
static int bigstate=0;
10101011

1012+
if (dsda_InputActivated(dsda_input_map_overlay) && (automap_input || dsda_ShowMinimap()))
1013+
{
1014+
dsda_CycleConfig(dsda_config_automap_overlay, true);
1015+
dsda_AddMessage(automap_overlay == 0 ? s_AMSTR_OVERLAYOFF :
1016+
automap_overlay == 1 ? s_AMSTR_OVERLAYON :
1017+
"Overlay Mode Dark");
1018+
AM_SetPosition();
1019+
AM_activateNewScale();
1020+
1021+
return true;
1022+
}
1023+
10111024
if (!automap_input)
10121025
{
10131026
if (dsda_InputActivated(dsda_input_map))
@@ -1149,14 +1162,6 @@ dboolean AM_Responder
11491162

11501163
return true;
11511164
}
1152-
else if (dsda_InputActivated(dsda_input_map_overlay))
1153-
{
1154-
dsda_ToggleConfig(dsda_config_automap_overlay, true);
1155-
AM_SetPosition();
1156-
AM_activateNewScale();
1157-
1158-
return true;
1159-
}
11601165
else if (dsda_InputActivated(dsda_input_map_textured))
11611166
{
11621167
dsda_ToggleConfig(dsda_config_map_textured, true);
@@ -2773,6 +2778,9 @@ void AM_Drawer (dboolean minimap)
27732778
if (!automap_active && !minimap)
27742779
return;
27752780

2781+
if (automap_active && automap_overlay == 2 && minimap)
2782+
return;
2783+
27762784
V_BeginAutomapDraw();
27772785

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

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

28002810
if (map_textured)
28012811
{

prboom2/src/doomstat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ extern int automap_follow;
197197
extern int automap_grid;
198198

199199
#define automap_on (automap_active && !automap_overlay)
200-
#define automap_off (!automap_on)
200+
#define automap_off (!automap_active && automap_overlay > 0)
201+
#define automap_stbar (automap_active && R_StatusBarVisible())
201202
#define automap_input (automap_active)
202203
#define automap_hud (automap_active && !automap_overlay)
203204

prboom2/src/dsda/configuration.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ dsda_config_t dsda_config[dsda_config_count] = {
231231
},
232232
[dsda_config_menu_background] = {
233233
"menu_background", dsda_config_menu_background,
234-
CONF_BOOL(1)
234+
dsda_config_int, 0, 2, { 1 }
235235
},
236236
[dsda_config_process_priority] = {
237237
"process_priority", dsda_config_process_priority,
@@ -1046,7 +1046,7 @@ dsda_config_t dsda_config[dsda_config_count] = {
10461046
},
10471047
[dsda_config_automap_overlay] = {
10481048
"automap_overlay", dsda_config_automap_overlay,
1049-
CONF_BOOL(0), &automap_overlay
1049+
dsda_config_int, 0, 2, { 0 }, &automap_overlay
10501050
},
10511051
[dsda_config_automap_rotate] = {
10521052
"automap_rotate", dsda_config_automap_rotate,

prboom2/src/dsda/exhud.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static void dsda_UpdateComponents(exhud_component_t* update_components) {
659659
}
660660

661661
void dsda_UpdateExHud(void) {
662-
if (automap_on) {
662+
if (automap_stbar) {
663663
if (containers[hud_map].loaded)
664664
dsda_UpdateComponents(containers[hud_map].components);
665665

@@ -689,7 +689,7 @@ int global_patch_top_offset;
689689
void dsda_DrawExHud(void) {
690690
global_patch_top_offset = M_ConsoleOpen() ? dsda_ConsoleHeight() : 0;
691691

692-
if (automap_on) {
692+
if (automap_stbar) {
693693
if (containers[hud_map].loaded)
694694
dsda_DrawComponents(containers[hud_map].components);
695695
}

prboom2/src/gl_main.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void gld_MapDrawSubsectors(player_t *plr, int fx, int fy, fixed_t mx, fixed_t my
282282
float coord_scale;
283283
GLTexture *gltexture;
284284

285-
alpha = (float)(automap_overlay ? map_textured_overlay_trans : map_textured_trans) / 100.0f;
285+
alpha = (float)((automap_overlay > 0) ? map_textured_overlay_trans : map_textured_trans) / 100.0f;
286286
if (alpha == 0)
287287
return;
288288

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

717-
a = (automap_overlay ? map_lines_overlay_trans * 255 / 100 : 255);
717+
a = ((automap_overlay == 1) ? map_lines_overlay_trans * 255 / 100 : 255);
718718
if (a == 0)
719719
return;
720720

@@ -848,6 +848,31 @@ void gld_FillBlock(int x, int y, int width, int height, int col)
848848
glsl_PopNullShader();
849849
}
850850

851+
void gld_DrawShaded(int x, int y, int width, int height, int shade)
852+
{
853+
color_rgb_t color = gld_LookupIndexedColor(playpal_black, V_IsAutomapLightmodeIndexed());
854+
855+
glsl_PushNullShader();
856+
857+
gld_EnableTexture2D(GL_TEXTURE0_ARB, false);
858+
859+
glColor4f((float)color.r/255.0f,
860+
(float)color.g/255.0f,
861+
(float)color.b/255.0f,
862+
(float)shade/30);
863+
864+
glBegin(GL_TRIANGLE_STRIP);
865+
glVertex2i( x, y );
866+
glVertex2i( x, y+height );
867+
glVertex2i( x+width, y );
868+
glVertex2i( x+width, y+height );
869+
glEnd();
870+
glColor4f(1.0f,1.0f,1.0f,1.0f);
871+
gld_EnableTexture2D(GL_TEXTURE0_ARB, true);
872+
873+
glsl_PopNullShader();
874+
}
875+
851876
void gld_SetPalette(int palette)
852877
{
853878
static int last_palette = 0;

prboom2/src/gl_struct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ void gld_DrawLine(int x0, int y0, int x1, int y1, int BaseColor);
9292
void gld_DrawLine_f(float x0, float y0, float x1, float y1, int BaseColor);
9393
void gld_DrawWeapon(int weaponlump, vissprite_t *vis, int lightlevel);
9494
void gld_FillBlock(int x, int y, int width, int height, int col);
95+
void gld_DrawShaded(int x, int y, int width, int height, int shade);
9596
void gld_SetPalette(int palette);
9697
unsigned char *gld_ReadScreen(void);
9798

prboom2/src/heretic/sb_bar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "doomstat.h"
2020
#include "m_cheat.h"
21+
#include "m_menu.h"
2122
#include "m_random.h"
2223
#include "v_video.h"
2324
#include "r_main.h"
@@ -537,7 +538,7 @@ static int oldpieces = -1;
537538

538539
void SB_Drawer(dboolean statusbaron, dboolean refresh, dboolean fullmenu)
539540
{
540-
if (refresh || fullmenu || V_IsOpenGLMode()) SB_state = -1;
541+
if (refresh || fullmenu || fadeBG() || V_IsOpenGLMode()) SB_state = -1;
541542

542543
if (!statusbaron)
543544
{

prboom2/src/hu_stuff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "p_tick.h"
4848
#include "p_map.h"
4949
#include "sc_man.h"
50+
#include "m_menu.h"
5051
#include "m_misc.h"
5152
#include "r_main.h"
5253
#include "lprintf.h"
@@ -364,7 +365,7 @@ void HU_Start(void)
364365
void HU_Drawer(void)
365366
{
366367
// don't draw anything if there's a fullscreen menu up
367-
if (menuactive == mnact_full)
368+
if (menuactive == mnact_full && !M_MenuIsShaded())
368369
return;
369370

370371
V_BeginUIDraw();

prboom2/src/m_menu.c

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@
160160

161161
extern dboolean message_dontfuckwithme;
162162

163+
/////////////////////////////
164+
//
165+
// booleans for setup screens
166+
// these tell you what state the setup screens are in, and whether any of
167+
// the overlay screens (automap colors, reset button message) should be
168+
// displayed
169+
170+
dboolean setup_active = false; // in one of the setup screens
171+
dboolean set_keybnd_active = false; // in key binding setup screens
172+
dboolean set_weapon_active = false; // in weapons setup screen
173+
dboolean set_status_active = false; // in status bar/hud setup screen
174+
dboolean set_auto_active = false; // in automap setup screen
175+
dboolean setup_select = false; // changing an item
176+
dboolean setup_gather = false; // gathering keys for value
177+
dboolean colorbox_active = false; // color palette being shown
178+
dboolean set_general_active = false;
179+
dboolean level_table_active = false;
180+
181+
163182
extern const char* g_menu_flat;
164183
extern int g_menu_save_page_size;
165184
extern int g_menu_font_spacing;
@@ -188,7 +207,7 @@ void (*messageRoutine)(int response);
188207

189208
static void M_DrawBackground(const char *flat, int scrn)
190209
{
191-
if (dsda_IntConfig(dsda_config_menu_background))
210+
if (dsda_IntConfig(dsda_config_menu_background) == 2)
192211
V_DrawBackground(flat, scrn);
193212
}
194213

@@ -1250,6 +1269,8 @@ static void M_QuitResponse(dboolean affirmative)
12501269
void M_QuitDOOM(int choice)
12511270
{
12521271
static char endstring[160];
1272+
setup_active = false;
1273+
currentMenu = NULL;
12531274

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

1511-
/////////////////////////////
1512-
//
1513-
// booleans for setup screens
1514-
// these tell you what state the setup screens are in, and whether any of
1515-
// the overlay screens (automap colors, reset button message) should be
1516-
// displayed
1517-
1518-
dboolean setup_active = false; // in one of the setup screens
1519-
dboolean set_keybnd_active = false; // in key binding setup screens
1520-
dboolean set_weapon_active = false; // in weapons setup screen
1521-
dboolean set_status_active = false; // in status bar/hud setup screen
1522-
dboolean set_auto_active = false; // in automap setup screen
1523-
dboolean setup_select = false; // changing an item
1524-
dboolean setup_gather = false; // gathering keys for value
1525-
dboolean colorbox_active = false; // color palette being shown
1526-
dboolean set_general_active = false;
1527-
dboolean level_table_active = false;
1528-
15291532
/////////////////////////////
15301533
//
15311534
// set_menu_itemon is an index that starts at zero, and tells you which
@@ -3098,6 +3101,8 @@ setup_menu_t misc_settings[] = {
30983101
FINAL_ENTRY
30993102
};
31003103

3104+
static const char* menu_background_list[] = { "Off", "Dark", "Texture", NULL };
3105+
31013106
setup_menu_t display_settings[] = {
31023107
{ "Display Options", S_SKIP | S_TITLE, m_null, G_X},
31033108
{ "Use Extended Hud", S_YESNO, m_conf, G_X, dsda_config_exhud },
@@ -3117,7 +3122,7 @@ setup_menu_t display_settings[] = {
31173122
{ "Change Palette On Powers", S_YESNO, m_conf, G_X, dsda_config_palette_onpowers },
31183123
EMPTY_LINE,
31193124
{ "Status Bar and Menu Appearance", S_CHOICE, m_conf, G_X, dsda_config_render_stretch_hud, 0, render_stretch_list },
3120-
{ "Fullscreen Menu Background", S_YESNO, m_conf, G_X, dsda_config_menu_background },
3125+
{ "Fullscreen Menu Background", S_CHOICE, m_conf, G_X, dsda_config_menu_background, 0, menu_background_list },
31213126

31223127
PREV_PAGE(misc_settings),
31233128
NEXT_PAGE(mapping_settings),
@@ -5827,6 +5832,29 @@ void M_StartControlPanel (void)
58275832
itemOn = currentMenu->lastOn; // JDC
58285833
}
58295834

5835+
5836+
/////////////////////////////////////////////////////////////////////////////
5837+
//
5838+
// Menu Shaded Overlay Stuff
5839+
//
5840+
// This displays a dark overlay under certain screens of the menus
5841+
5842+
dboolean fadeBG(void)
5843+
{
5844+
return dsda_IntConfig(dsda_config_menu_background) == 1;
5845+
}
5846+
5847+
dboolean M_MenuIsShaded(void)
5848+
{
5849+
int Options = (setup_active || currentMenu == &OptionsDef || currentMenu == &SoundDef);
5850+
return fadeBG() && Options;
5851+
}
5852+
5853+
static void M_ShadedScreen(int scrn)
5854+
{
5855+
V_DrawShaded(scrn, 0, 0, SCREENWIDTH, SCREENHEIGHT, FULLSHADE);
5856+
}
5857+
58305858
//
58315859
// M_Drawer
58325860
// Called after the view has been rendered,
@@ -5839,6 +5867,9 @@ void M_Drawer (void)
58395867
{
58405868
V_BeginUIDraw();
58415869

5870+
if (M_MenuIsShaded())
5871+
M_ShadedScreen(0);
5872+
58425873
inhelpscreens = false;
58435874

58445875
// Horiz. & Vertically center string and print it.

prboom2/src/m_menu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949

5050
dboolean M_Responder (event_t *ev);
5151

52+
dboolean fadeBG(void);
53+
dboolean M_MenuIsShaded(void);
54+
#define FULLSHADE 20
55+
5256
// Called by main loop,
5357
// only used for menu (skull cursor) animation.
5458

0 commit comments

Comments
 (0)