client: Add alttext to main menu

Workaround if game does not have any main menu images.
This commit is contained in:
Denis Pauk 2024-12-01 23:38:19 +02:00
parent 37b0e7a1f3
commit 5518640473
4 changed files with 34 additions and 11 deletions

View file

@ -458,7 +458,7 @@ SCR_DrawNet(void)
return;
}
Draw_PicScaled(scr_vrect.x + 64 * scale, scr_vrect.y, "net", scale);
Draw_PicScaledAltText(scr_vrect.x + 64 * scale, scr_vrect.y, "net", scale, "net");
}
void
@ -478,7 +478,8 @@ SCR_DrawPause(void)
}
Draw_GetPicSize(&w, &h, "pause");
Draw_PicScaled((viddef.width - w * scale) / 2, viddef.height / 2 + 8 * scale, "pause", scale);
Draw_PicScaledAltText((viddef.width - w * scale) / 2, viddef.height / 2 + 8 * scale,
"pause", scale, "pause");
}
void
@ -493,7 +494,8 @@ SCR_DrawLoading(void)
}
Draw_GetPicSize(&w, &h, "loading");
Draw_PicScaled((viddef.width - w * scale) / 2, (viddef.height - h * scale) / 2, "loading", scale);
Draw_PicScaledAltText((viddef.width - w * scale) / 2, (viddef.height - h * scale) / 2,
"loading", scale, "loading");
}
/*
@ -1000,6 +1002,9 @@ SCR_DrawFieldScaled(int x, int y, int color, int width, int value, float factor)
while (*ptr && l)
{
char alttext[] = "?";
alttext[0] = *ptr;
if (*ptr == '-')
{
frame = STAT_MINUS;
@ -1010,8 +1015,8 @@ SCR_DrawFieldScaled(int x, int y, int color, int width, int value, float factor)
frame = *ptr - '0';
}
Draw_PicScaled(x, y, sb_nums[color][frame], factor);
x += CHAR_WIDTH*factor;
Draw_PicScaledAltText(x, y, sb_nums[color][frame], factor, alttext);
x += CHAR_WIDTH * factor;
ptr++;
l--;
}
@ -1153,7 +1158,7 @@ SCR_ExecuteLayoutString(char *s)
if (cl.configstrings[CS_IMAGES + value][0] != '\0')
{
SCR_AddDirtyPoint(x, y);
SCR_AddDirtyPoint(x + 23*scale, y + 23*scale);
SCR_AddDirtyPoint(x + 23 * scale, y + 23 * scale);
Draw_PicScaled(x, y, cl.configstrings[CS_IMAGES + value], scale);
}
@ -1653,7 +1658,8 @@ SCR_UpdateScreen(void)
}
Draw_GetPicSize(&w, &h, "loading");
Draw_PicScaled((viddef.width - w * scale) / 2, (viddef.height - h * scale) / 2, "loading", scale);
Draw_PicScaledAltText((viddef.width - w * scale) / 2, (viddef.height - h * scale) / 2,
"loading", scale, "loading");
}
/* if a cinematic is supposed to be running,

View file

@ -91,6 +91,7 @@ typedef struct
menucommon_s generic;
char * focuspic;
char * errorpic;
char * alttext;
int width;
int height;
} menubitmap_s;

View file

@ -462,7 +462,7 @@ M_DrawCursor(int x, int y, int f)
}
Com_sprintf(cursorname, sizeof(cursorname), "m_cursor%d", f);
Draw_PicScaled(x * scale, y * scale, cursorname, scale);
Draw_PicScaledAltText(x * scale, y * scale, cursorname, scale, "*");
}
static void
@ -665,6 +665,7 @@ InitMainMenu(void)
s_plaque.generic.name = "m_main_plaque";
s_plaque.generic.callback = 0;
s_plaque.focuspic = 0;
s_plaque.alttext = NULL;
s_logo.generic.type = MTYPE_BITMAP;
s_logo.generic.flags = QMF_LEFT_JUSTIFY | QMF_INACTIVE;
@ -673,6 +674,7 @@ InitMainMenu(void)
s_logo.generic.name = "m_main_logo";
s_logo.generic.callback = 0;
s_logo.focuspic = 0;
s_logo.alttext = NULL;
y += 10;
@ -683,6 +685,7 @@ InitMainMenu(void)
s_game.generic.name = "m_main_game";
s_game.generic.callback = GameFunc;
s_game.focuspic = "m_main_game_sel";
s_game.alttext = "Game";
Draw_GetPicSize(&w, &h, ( char * )s_game.generic.name);
y += h + 8;
@ -694,6 +697,7 @@ InitMainMenu(void)
s_multiplayer.generic.name = "m_main_multiplayer";
s_multiplayer.generic.callback = MultiplayerFunc;
s_multiplayer.focuspic = "m_main_multiplayer_sel";
s_multiplayer.alttext = "Multiplayer";
Draw_GetPicSize(&w, &h, ( char * )s_multiplayer.generic.name);
y += h + 8;
@ -705,6 +709,7 @@ InitMainMenu(void)
s_options.generic.name = "m_main_options";
s_options.generic.callback = OptionsFunc;
s_options.focuspic = "m_main_options_sel";
s_options.alttext = "Options";
Draw_GetPicSize(&w, &h, ( char * )s_options.generic.name);
y += h + 8;
@ -716,6 +721,7 @@ InitMainMenu(void)
s_video.generic.name = "m_main_video";
s_video.generic.callback = VideoFunc;
s_video.focuspic = "m_main_video_sel";
s_video.alttext = "Video";
Draw_GetPicSize(&w, &h, ( char * )s_video.generic.name);
y += h + 8;
@ -727,6 +733,7 @@ InitMainMenu(void)
s_quit.generic.name = "m_main_quit";
s_quit.generic.callback = QuitFunc;
s_quit.focuspic = "m_main_quit_sel";
s_quit.alttext = "Quit";
Menu_AddItem(&s_main, (void *)&s_plaque);
Menu_AddItem(&s_main, (void *)&s_logo);
@ -6377,7 +6384,8 @@ M_Quit_Draw(void)
float scale = SCR_GetMenuScale();
Draw_GetPicSize(&w, &h, "quit");
Draw_PicScaled((viddef.width - w * scale) / 2, (viddef.height - h * scale) / 2, "quit", scale);
Draw_PicScaledAltText((viddef.width - w * scale) / 2, (viddef.height - h * scale) / 2,
"quit", scale, "Quit Y/N?");
}
static void
@ -6441,6 +6449,12 @@ M_Init(void)
{
m_cursor_width = w;
}
/* No cursor image? */
if (m_cursor_width == 0)
{
m_cursor_width = 8;
}
}
}

View file

@ -79,11 +79,13 @@ void Bitmap_Draw(menubitmap_s * item)
if (((item->generic.flags & QMF_HIGHLIGHT_IF_FOCUS) &&
(Menu_ItemAtCursor(item->generic.parent) == item)))
{
Draw_PicScaled(x * scale, y * scale, item->focuspic, scale);
Draw_PicScaledAltText(x * scale, y * scale, item->focuspic, scale,
item->alttext);
}
else if (item->generic.name)
{
Draw_PicScaled(x * scale, y * scale, ( char * )item->generic.name, scale);
Draw_PicScaledAltText(x * scale, y * scale, ( char * )item->generic.name, scale,
item->alttext);
}
}