Handle invalid resolutions, make Backspace work in resolution menu.

This commit is contained in:
spherallic 2022-02-19 12:12:04 +01:00
parent 3da52592f2
commit 7d1faf7e2c
2 changed files with 23 additions and 2 deletions

View file

@ -13226,11 +13226,11 @@ static void M_DrawVideoMode(void)
vid.width, vid.height));
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 116, (cv_fullscreen.value ? 0 : V_TRANSLUCENT),
va("Default mode is %c%dx%d",
(SCR_IsAspectCorrect(cv_scr_width.value, cv_scr_height.value)) ? 0x83 : 0x80,
(SCR_IsAspectCorrect(cv_scr_width.value, cv_scr_height.value)) ? 0x83 : (!(VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value)+1) ? 0x85 : 0x80),
cv_scr_width.value, cv_scr_height.value));
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 124, (cv_fullscreen.value ? V_TRANSLUCENT : 0),
va("Windowed mode is %c%dx%d",
(SCR_IsAspectCorrect(cv_scr_width_w.value, cv_scr_height_w.value)) ? 0x83 : 0x80,
(SCR_IsAspectCorrect(cv_scr_width_w.value, cv_scr_height_w.value)) ? 0x83 : (!(VID_GetModeForSize(cv_scr_width_w.value, cv_scr_height_w.value)+1) ? 0x85 : 0x80),
cv_scr_width_w.value, cv_scr_height_w.value));
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 138,
@ -13448,6 +13448,18 @@ static void M_HandleVideoMode(INT32 ch)
M_ClearMenus(true);
break;
case KEY_BACKSPACE:
S_StartSound(NULL, sfx_menu1);
CV_Set(&cv_scr_width, cv_scr_width.defaultvalue);
CV_Set(&cv_scr_height, cv_scr_height.defaultvalue);
CV_Set(&cv_scr_width_w, cv_scr_width_w.defaultvalue);
CV_Set(&cv_scr_height_w, cv_scr_height_w.defaultvalue);
if (cv_fullscreen.value)
setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value)+1;
else
setmodeneeded = VID_GetModeForSize(cv_scr_width_w.value, cv_scr_height_w.value)+1;
break;
case KEY_F11:
S_StartSound(NULL, sfx_menu1);
CV_SetValue(&cv_fullscreen, !cv_fullscreen.value);

View file

@ -375,6 +375,9 @@ void SCR_CheckDefaultMode(void)
setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; // see note above
else
setmodeneeded = VID_GetModeForSize(cv_scr_width_w.value, cv_scr_height_w.value) + 1; // see note above
if (setmodeneeded <= 0)
CONS_Alert(CONS_WARNING, "Invalid resolution given, defaulting to base resolution\n");
}
if (cv_renderer.value != (signed)rendermode)
@ -412,6 +415,12 @@ void SCR_ChangeFullscreen(void)
setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1;
else
setmodeneeded = VID_GetModeForSize(cv_scr_width_w.value, cv_scr_height_w.value) + 1;
if (setmodeneeded <= 0) // hacky safeguard
{
CONS_Alert(CONS_WARNING, "Invalid resolution given, defaulting to base resolution.\n");
setmodeneeded = VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT) + 1;
}
}
return;
#endif