Skip to content

Commit

Permalink
Center setup menu title patches (#1801)
Browse files Browse the repository at this point in the history
* Center setup menu title patches

* Use M_X_CENTER macro for consistency
  • Loading branch information
xemonix0 authored Jul 25, 2024
1 parent cb53e63 commit 1b3f857
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/mn_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ boolean MN_PointInsideRect(mrect_t *rect, int x, int y);
void MN_ClearMenus(void);
void MN_Back(void);

#define M_X_CENTER (-1)

// [FG] alternative text for missing menu graphics lumps
void MN_DrawTitle(int x, int y, const char *patch, const char *alttext);
void MN_DrawStringCR(int cx, int cy, byte *cr1, byte *cr2, const char *ch);
Expand Down
4 changes: 2 additions & 2 deletions src/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ static menu_t SoundDef = {sound_end, &MainDef, SoundMenu, M_DrawSound,

static void M_DrawSound(void)
{
MN_DrawTitle(60, 38, "M_SVOL", "Sound Volume");
MN_DrawTitle(M_X_CENTER, 38, "M_SVOL", "Sound Volume");

int index = highlight_item + 1;
menuitem_t *item = &currentMenu->menuitems[index];
Expand Down Expand Up @@ -1873,7 +1873,7 @@ void MN_SetNextMenuAlt(ss_types type)

static void M_DrawSetup(void)
{
MN_DrawTitle(108, 15, "M_OPTTTL", "OPTIONS");
MN_DrawTitle(M_X_CENTER, 15, "M_OPTTTL", "OPTIONS");
}

/////////////////////////////
Expand Down
21 changes: 12 additions & 9 deletions src/mn_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static boolean default_reset;
#define M_X 240
#define M_Y (29 + M_SPC)
#define M_Y_WARN (SCREENHEIGHT - 15)
#define M_Y_TITLE 2

#define M_THRM_STEP 8
#define M_THRM_HEIGHT 13
Expand Down Expand Up @@ -1215,7 +1216,7 @@ void MN_DrawKeybnd(void)
// Set up the Key Binding screen

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(84, 2, "M_KEYBND", "Key Bindings");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_KEYBND", "Key Bindings");
DrawTabs();
DrawInstructions();
DrawScreenItems(current_menu);
Expand Down Expand Up @@ -1316,7 +1317,7 @@ void MN_DrawWeapons(void)
inhelpscreens = true; // killough 4/6/98: Force status bar redraw

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(109, 2, "M_WEAP", "Weapons");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_WEAP", "Weapons");
DrawTabs();
DrawInstructions();
DrawScreenItems(current_menu);
Expand Down Expand Up @@ -1545,7 +1546,7 @@ void MN_DrawStatusHUD(void)
inhelpscreens = true; // killough 4/6/98: Force status bar redraw

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(59, 2, "M_STAT", "Status Bar/HUD");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_STAT", "Status Bar/HUD");
DrawTabs();
DrawInstructions();
DrawScreenItems(current_menu);
Expand Down Expand Up @@ -1636,7 +1637,7 @@ void MN_DrawAutoMap(void)
inhelpscreens = true; // killough 4/6/98: Force status bar redraw

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(109, 2, "M_AUTO", "Automap");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_AUTO", "Automap");
DrawInstructions();
DrawScreenItems(current_menu);

Expand Down Expand Up @@ -1718,7 +1719,7 @@ void MN_DrawEnemy(void)
inhelpscreens = true;

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(114, 2, "M_ENEM", "Enemies");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_ENEM", "Enemies");
DrawInstructions();
DrawScreenItems(current_menu);

Expand Down Expand Up @@ -1812,7 +1813,7 @@ void MN_DrawCompat(void)
inhelpscreens = true;

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(52, 2, "M_COMPAT", "Compatibility");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_COMPAT", "Compatibility");
DrawInstructions();
DrawScreenItems(current_menu);

Expand Down Expand Up @@ -2456,7 +2457,7 @@ void MN_DrawGeneral(void)
inhelpscreens = true;

DrawBackground("FLOOR4_6"); // Draw background
MN_DrawTitle(114, 2, "M_GENERL", "General");
MN_DrawTitle(M_X_CENTER, M_Y_TITLE, "M_GENERL", "General");
DrawTabs();
DrawInstructions();
DrawScreenItems(current_menu);
Expand Down Expand Up @@ -2932,7 +2933,7 @@ void MN_DrawCredits(void) // killough 10/98: credit screen
M_snprintf(mbftext_s, sizeof(mbftext_s), PROJECT_STRING);
inhelpscreens = true;
DrawBackground(gamemode == shareware ? "CEIL5_1" : "MFLR8_4");
MN_DrawTitle(42, 9, "MBFTEXT", mbftext_s);
MN_DrawTitle(M_X_CENTER, 9, "MBFTEXT", mbftext_s);
DrawScreenItems(cred_settings);
}

Expand Down Expand Up @@ -3818,7 +3819,9 @@ void MN_DrawTitle(int x, int y, const char *patch, const char *alttext)

if (patch_lump >= 0)
{
V_DrawPatch(x, y, V_CachePatchNum(patch_lump, PU_CACHE));
patch_t *patch = V_CachePatchNum(patch_lump, PU_CACHE);
V_DrawPatch(x == M_X_CENTER ? SCREENWIDTH / 2 - patch->width / 2 : x,
y, patch);
}
else
{
Expand Down

0 comments on commit 1b3f857

Please sign in to comment.