mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-21 02:43:26 -04:00
improve big font support in menus (#1587)
* Add alt text to all main menu items * Support for upper/lower case fonts
This commit is contained in:
parent
26ff5e1126
commit
1ec38042a3
@ -49,6 +49,7 @@ static fon2_char_t *chars = NULL;
|
||||
static int numchars;
|
||||
static int height;
|
||||
static int firstc;
|
||||
static boolean upper;
|
||||
static int kerning;
|
||||
|
||||
#define FON2_SPACE 12
|
||||
@ -81,6 +82,10 @@ boolean MN_LoadFon2(const byte *gfx_data, int size)
|
||||
}
|
||||
|
||||
firstc = header->firstc;
|
||||
if (header->lastc < 'z')
|
||||
{
|
||||
upper = true;
|
||||
}
|
||||
numchars = header->lastc - header->firstc + 1;
|
||||
chars = malloc(numchars * sizeof(*chars));
|
||||
|
||||
@ -174,7 +179,7 @@ boolean MN_DrawFon2String(int x, int y, byte *cr, const char *str)
|
||||
{
|
||||
c = *str++;
|
||||
|
||||
c = toupper(c) - firstc;
|
||||
c = (upper ? toupper(c) : c) - firstc;
|
||||
if (c < 0 || c >= numchars)
|
||||
{
|
||||
cx += FON2_SPACE;
|
||||
@ -209,7 +214,7 @@ int MN_GetFon2PixelWidth(const char *str)
|
||||
{
|
||||
c = *str++;
|
||||
|
||||
c = toupper(c) - firstc;
|
||||
c = (upper ? toupper(c) : c) - firstc;
|
||||
if (c < 0 || c > numchars)
|
||||
{
|
||||
len += FON2_SPACE; // space
|
||||
|
@ -298,14 +298,14 @@ enum
|
||||
{0, 0, SCREENWIDTH, LINEHEIGHT}
|
||||
|
||||
static menuitem_t MainMenu[] = {
|
||||
{1, "M_NGAME", M_NewGame, 'n', NULL, MAIN_MENU_RECT},
|
||||
{1, "M_LOADG", M_LoadGame, 'l', NULL, MAIN_MENU_RECT},
|
||||
{1, "M_SAVEG", M_SaveGame, 's', NULL, MAIN_MENU_RECT},
|
||||
{1, "M_NGAME", M_NewGame, 'n', "New Game", MAIN_MENU_RECT},
|
||||
{1, "M_LOADG", M_LoadGame, 'l', "Load Game", MAIN_MENU_RECT},
|
||||
{1, "M_SAVEG", M_SaveGame, 's', "Save Game", MAIN_MENU_RECT},
|
||||
// change M_Options to M_Setup
|
||||
{1, "M_OPTION", M_Setup, 'o', NULL, MAIN_MENU_RECT},
|
||||
{1, "M_OPTION", M_Setup, 'o', "Options", MAIN_MENU_RECT},
|
||||
// Another hickup with Special edition.
|
||||
{1, "M_RDTHIS", M_ReadThis, 'r', NULL, MAIN_MENU_RECT},
|
||||
{1, "M_QUITG", M_QuitDOOM, 'q', NULL, MAIN_MENU_RECT}
|
||||
{1, "M_RDTHIS", M_ReadThis, 'r', "Read This!", MAIN_MENU_RECT},
|
||||
{1, "M_QUITG", M_QuitDOOM, 'q', "Quit", MAIN_MENU_RECT}
|
||||
};
|
||||
|
||||
static menu_t MainDef = {
|
||||
@ -488,10 +488,10 @@ enum
|
||||
|
||||
static menuitem_t EpisodeMenu[] = // added a few free entries for UMAPINFO
|
||||
{
|
||||
{1, "M_EPI1", M_Episode, 'k', NULL, EPISODES_RECT(0)},
|
||||
{1, "M_EPI2", M_Episode, 't', NULL, EPISODES_RECT(1)},
|
||||
{1, "M_EPI3", M_Episode, 'i', NULL, EPISODES_RECT(2)},
|
||||
{1, "M_EPI4", M_Episode, 't', NULL, EPISODES_RECT(3)},
|
||||
{1, "M_EPI1", M_Episode, 'k', "Knee-Deep in the Dead", EPISODES_RECT(0)},
|
||||
{1, "M_EPI2", M_Episode, 't', "The Shores of Hell", EPISODES_RECT(1)},
|
||||
{1, "M_EPI3", M_Episode, 'i', "Inferno", EPISODES_RECT(2)},
|
||||
{1, "M_EPI4", M_Episode, 't', "Thy Flesh Consumed", EPISODES_RECT(3)},
|
||||
{1, "", M_Episode, '0', NULL, EPISODES_RECT(4)},
|
||||
{1, "", M_Episode, '0', NULL, EPISODES_RECT(5)},
|
||||
{1, "", M_Episode, '0', NULL, EPISODES_RECT(6)},
|
||||
@ -568,7 +568,7 @@ static void M_DrawEpisode(void)
|
||||
// [crispy] force status bar refresh
|
||||
inhelpscreens = true;
|
||||
|
||||
MN_DrawTitle(54, EpiDef.y - 25, "M_EPISOD", "WHICH EPISODE?");
|
||||
MN_DrawTitle(54, EpiDef.y - 25, "M_EPISOD", "Which Episode?");
|
||||
}
|
||||
|
||||
static void M_Episode(int choice)
|
||||
@ -642,8 +642,8 @@ static void M_DrawNewGame(void)
|
||||
// [crispy] force status bar refresh
|
||||
inhelpscreens = true;
|
||||
|
||||
V_DrawPatchDirect(96, 14, W_CacheLumpName("M_NEWG", PU_CACHE));
|
||||
V_DrawPatchDirect(54, 38, W_CacheLumpName("M_SKILL", PU_CACHE));
|
||||
MN_DrawTitle(96, 14, "M_NEWG", "NEW GAME");
|
||||
MN_DrawTitle(54, 38, "M_SKILL", "Choose Skill Level:");
|
||||
}
|
||||
|
||||
static void M_NewGame(int choice)
|
||||
@ -865,7 +865,7 @@ static void M_DrawLoad(void)
|
||||
int i;
|
||||
|
||||
// jff 3/15/98 use symbolic load position
|
||||
V_DrawPatch(72, LOADGRAPHIC_Y, W_CacheLumpName("M_LOADG", PU_CACHE));
|
||||
MN_DrawTitle(72, LOADGRAPHIC_Y, "M_LOADG", "Load Game");
|
||||
for (i = 0; i < load_page; i++)
|
||||
{
|
||||
menuitem_t *item = ¤tMenu->menuitems[i];
|
||||
@ -1084,7 +1084,7 @@ static void M_DrawSave(void)
|
||||
int i;
|
||||
|
||||
// jff 3/15/98 use symbolic load position
|
||||
V_DrawPatchDirect(72, LOADGRAPHIC_Y, W_CacheLumpName("M_SAVEG", PU_CACHE));
|
||||
MN_DrawTitle(72, LOADGRAPHIC_Y, "M_SAVEG", "Save Game");
|
||||
for (i = 0; i < load_page; i++)
|
||||
{
|
||||
menuitem_t *item = ¤tMenu->menuitems[i];
|
||||
@ -1290,9 +1290,9 @@ enum
|
||||
{80 /*SoundDef.x*/, 64 /*SoundDef.y*/ + LINEHEIGHT *(n), (16 + 2) * 8, 13}
|
||||
|
||||
static menuitem_t SoundMenu[] = {
|
||||
{2, "M_SFXVOL", M_SfxVol, 's', NULL, {}, MF_THRM_STR},
|
||||
{2, "M_SFXVOL", M_SfxVol, 's', "Sfx Volume", {}, MF_THRM_STR},
|
||||
{-1, "", NULL, 0, NULL, THERMO_VOLUME_RECT(sfx_vol_thermo), MF_THRM },
|
||||
{2, "M_MUSVOL", M_MusicVol, 'm', NULL, {}, MF_THRM_STR},
|
||||
{2, "M_MUSVOL", M_MusicVol, 'm', "Music Volume", {}, MF_THRM_STR},
|
||||
{-1, "", NULL, 0, NULL, THERMO_VOLUME_RECT(music_vol_thermo), MF_THRM },
|
||||
};
|
||||
|
||||
@ -1305,7 +1305,7 @@ static menu_t SoundDef = {sound_end, &MainDef, SoundMenu, M_DrawSound,
|
||||
|
||||
static void M_DrawSound(void)
|
||||
{
|
||||
V_DrawPatchDirect(60, 38, W_CacheLumpName("M_SVOL", PU_CACHE));
|
||||
MN_DrawTitle(60, 38, "M_SVOL", "Sound Volume");
|
||||
|
||||
int index = itemOn + 1;
|
||||
menuitem_t *item = ¤tMenu->menuitems[index];
|
||||
@ -1726,13 +1726,13 @@ static void M_DrawHelp(void)
|
||||
|
||||
static menuitem_t SetupMenu[] = {
|
||||
// [FG] alternative text for missing menu graphics lumps
|
||||
{1, "M_GENERL", MN_General, 'g', "GENERAL", SETUP_MENU_RECT(0)},
|
||||
{1, "M_KEYBND", MN_KeyBindings, 'k', "KEY BINDINGS", SETUP_MENU_RECT(1)},
|
||||
{1, "M_COMPAT", MN_Compat, 'c', "COMPATIBILITY", SETUP_MENU_RECT(2)},
|
||||
{1, "M_STAT", MN_StatusBar, 's', "STATUS BAR/HUD", SETUP_MENU_RECT(3)},
|
||||
{1, "M_AUTO", MN_Automap, 'a', "AUTOMAP", SETUP_MENU_RECT(4)},
|
||||
{1, "M_WEAP", MN_Weapons, 'w', "WEAPONS", SETUP_MENU_RECT(5)},
|
||||
{1, "M_ENEM", MN_Enemy, 'e', "ENEMIES", SETUP_MENU_RECT(6)},
|
||||
{1, "M_GENERL", MN_General, 'g', "General", SETUP_MENU_RECT(0)},
|
||||
{1, "M_KEYBND", MN_KeyBindings, 'k', "Key Bindings", SETUP_MENU_RECT(1)},
|
||||
{1, "M_COMPAT", MN_Compat, 'c', "Compatibility", SETUP_MENU_RECT(2)},
|
||||
{1, "M_STAT", MN_StatusBar, 's', "Status Bar/HUD", SETUP_MENU_RECT(3)},
|
||||
{1, "M_AUTO", MN_Automap, 'a', "Automap", SETUP_MENU_RECT(4)},
|
||||
{1, "M_WEAP", MN_Weapons, 'w', "Weapons", SETUP_MENU_RECT(5)},
|
||||
{1, "M_ENEM", MN_Enemy, 'e', "Enemies", SETUP_MENU_RECT(6)},
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
@ -3087,11 +3087,20 @@ void M_Drawer(void)
|
||||
// [FG] check current menu for missing menu graphics lumps - only once
|
||||
if (currentMenu->lumps_missing == 0)
|
||||
{
|
||||
int bigfont_lump = W_CheckNumForName("DBIGFONT");
|
||||
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
const char *name = currentMenu->menuitems[i].name;
|
||||
int patch_lump = -1;
|
||||
|
||||
if ((name[0] == 0 || W_CheckNumForName(name) < 0)
|
||||
if (name[0])
|
||||
{
|
||||
patch_lump = W_CheckNumForName(name);
|
||||
}
|
||||
|
||||
if ((patch_lump < 0
|
||||
|| (W_IsIWADLump(patch_lump) && bigfont_lump >= 0))
|
||||
&& currentMenu->menuitems[i].alttext)
|
||||
{
|
||||
currentMenu->lumps_missing++;
|
||||
@ -3127,6 +3136,10 @@ void M_Drawer(void)
|
||||
cr = NULL;
|
||||
}
|
||||
|
||||
mrect_t *rect = &item->rect;
|
||||
// due to the MainMenu[] hacks, we have to set `y` here
|
||||
rect->y = y;
|
||||
|
||||
// [FG] at least one menu graphics lump is missing, draw alternative
|
||||
// text
|
||||
if (currentMenu->lumps_missing > 0)
|
||||
@ -3142,10 +3155,8 @@ void M_Drawer(void)
|
||||
}
|
||||
else if (name[0])
|
||||
{
|
||||
mrect_t *rect = &item->rect;
|
||||
patch_t *patch = W_CacheLumpName(name, PU_CACHE);
|
||||
// due to the MainMenu[] hacks, we have to set y here
|
||||
rect->y = y - SHORT(patch->topoffset);
|
||||
rect->y -= SHORT(patch->topoffset);
|
||||
V_DrawPatchTranslated(x, y, patch, cr);
|
||||
}
|
||||
|
||||
|
@ -1211,7 +1211,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(84, 2, "M_KEYBND", "Key Bindings");
|
||||
DrawTabs();
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
@ -1312,7 +1312,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(109, 2, "M_WEAP", "Weapons");
|
||||
DrawTabs();
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
@ -1535,7 +1535,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(59, 2, "M_STAT", "Status Bar/HUD");
|
||||
DrawTabs();
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
@ -1626,7 +1626,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(109, 2, "M_AUTO", "Automap");
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
|
||||
@ -1708,7 +1708,7 @@ void MN_DrawEnemy(void)
|
||||
inhelpscreens = true;
|
||||
|
||||
DrawBackground("FLOOR4_6"); // Draw background
|
||||
MN_DrawTitle(114, 2, "M_ENEM", "ENEMIES");
|
||||
MN_DrawTitle(114, 2, "M_ENEM", "Enemies");
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
|
||||
@ -1792,7 +1792,7 @@ void MN_DrawCompat(void)
|
||||
inhelpscreens = true;
|
||||
|
||||
DrawBackground("FLOOR4_6"); // Draw background
|
||||
MN_DrawTitle(52, 2, "M_COMPAT", "COMPATIBILITY");
|
||||
MN_DrawTitle(52, 2, "M_COMPAT", "Compatibility");
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
|
||||
@ -2377,7 +2377,7 @@ void MN_DrawGeneral(void)
|
||||
inhelpscreens = true;
|
||||
|
||||
DrawBackground("FLOOR4_6"); // Draw background
|
||||
MN_DrawTitle(114, 2, "M_GENERL", "GENERAL");
|
||||
MN_DrawTitle(114, 2, "M_GENERL", "General");
|
||||
DrawTabs();
|
||||
DrawInstructions();
|
||||
DrawScreenItems(current_menu);
|
||||
@ -3705,9 +3705,12 @@ int MN_StringHeight(const char *string)
|
||||
|
||||
void MN_DrawTitle(int x, int y, const char *patch, const char *alttext)
|
||||
{
|
||||
if (W_CheckNumForName(patch) >= 0)
|
||||
int patch_lump = W_CheckNumForName(patch);
|
||||
int bigfont_lump = W_CheckNumForName("DBIGFONT");
|
||||
|
||||
if (patch_lump >= 0 && !(W_IsIWADLump(patch_lump) && bigfont_lump >= 0))
|
||||
{
|
||||
V_DrawPatchDirect(x, y, W_CacheLumpName(patch, PU_CACHE));
|
||||
V_DrawPatchDirect(x, y, W_CacheLumpNum(patch_lump, PU_CACHE));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user