remove one pixel trimming for each font character in setup menu (#926)

* set menu font spacing based on font width
This commit is contained in:
Roman Fomin 2023-03-06 15:23:54 +07:00 committed by GitHub
parent f49693b204
commit 60573fa667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -2430,6 +2430,7 @@ void D_DoomMain(void)
puts("HU_Init: Setting up heads up display.");
HU_Init();
M_SetMenuFontSpacing();
puts("ST_Init: Init status bar.");
ST_Init();

View File

@ -5019,6 +5019,8 @@ setup_menu_t helpstrings[] = // HELP screen strings
#define SPACEWIDTH 4
static int menu_font_spacing = 0;
// M_DrawMenuString() draws the string in menu_buffer[]
void M_DrawStringCR(int cx, int cy, char *color, const char *ch)
@ -5046,7 +5048,7 @@ void M_DrawStringCR(int cx, int cy, char *color, const char *ch)
// The screen is cramped, so trim one unit from each
// character so they butt up against each other.
cx += w - 1;
cx += w + menu_font_spacing;
}
}
@ -5088,9 +5090,9 @@ int M_GetPixelWidth(const char *ch)
continue;
}
len += SHORT (hu_font[c]->width);
len--; // adjust so everything fits
len += menu_font_spacing; // adjust so everything fits
}
len++; // replace what you took away on the last char only
len -= menu_font_spacing; // replace what you took away on the last char only
return len;
}
@ -7030,6 +7032,12 @@ void M_Init(void)
}
}
void M_SetMenuFontSpacing(void)
{
if (M_StringWidth("abcdefghijklmnopqrstuvwxyz01234") > 230)
menu_font_spacing = -1;
}
// killough 10/98: allow runtime changing of menu order
void M_ResetMenu(void)

View File

@ -79,6 +79,8 @@ void M_ResetTimeScale(void);
void M_DrawCredits(void); // killough 11/98
void M_SetMenuFontSpacing(void);
// killough 8/15/98: warn about changes not being committed until next game
#define warn_about_changes(x) (warning_about_changes=(x), \
print_warning_about_changes = 2)