mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-20 19:02:34 +00:00
Merge branch 'fullscreen-toggle' into 'next'
Add fullscreen (and renderer) toggle & make windowed mode use a separate resolution See merge request STJr/SRB2!1734
This commit is contained in:
commit
f46e6883ca
5 changed files with 94 additions and 46 deletions
|
@ -880,6 +880,8 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_scr_depth);
|
||||
CV_RegisterVar(&cv_scr_width);
|
||||
CV_RegisterVar(&cv_scr_height);
|
||||
CV_RegisterVar(&cv_scr_width_w);
|
||||
CV_RegisterVar(&cv_scr_height_w);
|
||||
|
||||
CV_RegisterVar(&cv_soundtest);
|
||||
|
||||
|
|
99
src/m_menu.c
99
src/m_menu.c
|
@ -1314,17 +1314,17 @@ static menuitem_t OP_VideoOptionsMenu[] =
|
|||
{IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 6},
|
||||
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 11},
|
||||
{IT_STRING|IT_CVAR, NULL, "Fullscreen (F11)", &cv_fullscreen, 11},
|
||||
#endif
|
||||
{IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 16},
|
||||
#ifdef HWRENDER
|
||||
{IT_STRING | IT_CVAR, NULL, "Renderer", &cv_renderer, 21},
|
||||
{IT_STRING | IT_CVAR, NULL, "Renderer (F10)", &cv_renderer, 21},
|
||||
#else
|
||||
{IT_TRANSTEXT | IT_PAIR, "Renderer", "Software", &cv_renderer, 21},
|
||||
{IT_TRANSTEXT | IT_PAIR, "Renderer", "Software", &cv_renderer, 21},
|
||||
#endif
|
||||
|
||||
{IT_HEADER, NULL, "Color Profile", NULL, 30},
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness (F11)", &cv_globalgamma,36},
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_globalgamma,36},
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 41},
|
||||
{IT_SUBMENU|IT_STRING, NULL, "Advanced Settings...", &OP_ColorOptionsDef, 46},
|
||||
|
||||
|
@ -2139,7 +2139,7 @@ static void M_VideoOptions(INT32 choice)
|
|||
{
|
||||
OP_VideoOptionsMenu[op_video_renderer].status = (IT_STRING | IT_CVAR);
|
||||
OP_VideoOptionsMenu[op_video_renderer].patch = NULL;
|
||||
OP_VideoOptionsMenu[op_video_renderer].text = "Renderer";
|
||||
OP_VideoOptionsMenu[op_video_renderer].text = "Renderer (F10)";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3379,12 +3379,12 @@ boolean M_Responder(event_t *ev)
|
|||
// Screenshots on F8 now handled elsewhere
|
||||
// Same with Moviemode on F9
|
||||
|
||||
case KEY_F10: // Quit SRB2
|
||||
M_QuitSRB2(0);
|
||||
case KEY_F10: // Renderer toggle, also processed inside menus
|
||||
CV_AddValue(&cv_renderer, 1);
|
||||
return true;
|
||||
|
||||
case KEY_F11: // Gamma Level
|
||||
CV_AddValue(&cv_globalgamma, 1);
|
||||
case KEY_F11: // Fullscreen toggle, also processed inside menus
|
||||
CV_SetValue(&cv_fullscreen, !cv_fullscreen.value);
|
||||
return true;
|
||||
|
||||
// Spymode on F12 handled in game logic
|
||||
|
@ -3565,6 +3565,14 @@ boolean M_Responder(event_t *ev)
|
|||
// M_SetupNextMenu(currentMenu->prevMenu);
|
||||
return false;
|
||||
|
||||
case KEY_F10: // Renderer toggle, also processed outside menus
|
||||
CV_AddValue(&cv_renderer, 1);
|
||||
return true;
|
||||
|
||||
case KEY_F11: // Fullscreen toggle, also processed outside menus
|
||||
CV_SetValue(&cv_fullscreen, !cv_fullscreen.value);
|
||||
return true;
|
||||
|
||||
default:
|
||||
CON_Responder(ev);
|
||||
break;
|
||||
|
@ -4195,15 +4203,6 @@ static void M_DrawSaveLoadBorder(INT32 x,INT32 y)
|
|||
}
|
||||
#endif
|
||||
|
||||
// horizontally centered text
|
||||
static void M_CentreText(INT32 y, const char *string)
|
||||
{
|
||||
INT32 x;
|
||||
//added : 02-02-98 : centre on 320, because V_DrawString centers on vid.width...
|
||||
x = (BASEVIDWIDTH - V_StringWidth(string, V_OLDSPACING))>>1;
|
||||
V_DrawString(x,y,V_OLDSPACING,string);
|
||||
}
|
||||
|
||||
//
|
||||
// M_DrawMapEmblems
|
||||
//
|
||||
|
@ -13106,12 +13105,12 @@ static void M_DrawControl(void)
|
|||
if (tutorialmode && tutorialgcs)
|
||||
{
|
||||
if ((gametic / TICRATE) % 2)
|
||||
M_CentreText(30, "\202EXIT THE TUTORIAL TO CHANGE THE CONTROLS");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, 30, 0, "\202EXIT THE TUTORIAL TO CHANGE THE CONTROLS");
|
||||
else
|
||||
M_CentreText(30, "EXIT THE TUTORIAL TO CHANGE THE CONTROLS");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, 30, 0, "EXIT THE TUTORIAL TO CHANGE THE CONTROLS");
|
||||
}
|
||||
else
|
||||
M_CentreText(30,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, 30, 0,
|
||||
(setupcontrols_secondaryplayer ? "SET CONTROLS FOR SECONDARY PLAYER" :
|
||||
"PRESS ENTER TO CHANGE, BACKSPACE TO CLEAR"));
|
||||
|
||||
|
@ -13476,11 +13475,11 @@ static void M_DrawVideoMode(void)
|
|||
// draw title
|
||||
M_DrawMenuTitle();
|
||||
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y,
|
||||
V_YELLOWMAP, "Choose mode, reselect to change default");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y, V_YELLOWMAP, "Choose mode, reselect to change default");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y+8, V_YELLOWMAP, "Press F11 to toggle fullscreen");
|
||||
|
||||
row = 41;
|
||||
col = OP_VideoModeDef.y + 14;
|
||||
col = OP_VideoModeDef.y + 24;
|
||||
for (i = 0; i < vidm_nummodes; i++)
|
||||
{
|
||||
if (i == vidm_selected)
|
||||
|
@ -13493,7 +13492,7 @@ static void M_DrawVideoMode(void)
|
|||
if ((i % vidm_column_size) == (vidm_column_size-1))
|
||||
{
|
||||
row += 7*13;
|
||||
col = OP_VideoModeDef.y + 14;
|
||||
col = OP_VideoModeDef.y + 24;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13501,28 +13500,34 @@ static void M_DrawVideoMode(void)
|
|||
{
|
||||
INT32 testtime = (vidm_testingmode/TICRATE) + 1;
|
||||
|
||||
M_CentreText(OP_VideoModeDef.y + 116,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 116, 0,
|
||||
va("Previewing mode %c%dx%d",
|
||||
(SCR_IsAspectCorrect(vid.width, vid.height)) ? 0x83 : 0x80,
|
||||
vid.width, vid.height));
|
||||
M_CentreText(OP_VideoModeDef.y + 138,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 138, 0,
|
||||
"Press ENTER again to keep this mode");
|
||||
M_CentreText(OP_VideoModeDef.y + 150,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 150, 0,
|
||||
va("Wait %d second%s", testtime, (testtime > 1) ? "s" : ""));
|
||||
M_CentreText(OP_VideoModeDef.y + 158,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 158, 0,
|
||||
"or press ESC to return");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
M_CentreText(OP_VideoModeDef.y + 116,
|
||||
V_DrawFill(60, OP_VideoModeDef.y + 98, 200, 12, 159);
|
||||
V_DrawFill(60, OP_VideoModeDef.y + 114, 200, 20, 159);
|
||||
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 100, 0,
|
||||
va("Current mode is %c%dx%d",
|
||||
(SCR_IsAspectCorrect(vid.width, vid.height)) ? 0x83 : 0x80,
|
||||
vid.width, vid.height));
|
||||
M_CentreText(OP_VideoModeDef.y + 124,
|
||||
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 : (!(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,
|
||||
V_GREENMAP, "Green modes are recommended.");
|
||||
|
@ -13534,7 +13539,7 @@ static void M_DrawVideoMode(void)
|
|||
|
||||
// Draw the cursor for the VidMode menu
|
||||
i = 41 - 10 + ((vidm_selected / vidm_column_size)*7*13);
|
||||
j = OP_VideoModeDef.y + 14 + ((vidm_selected % vidm_column_size)*8);
|
||||
j = OP_VideoModeDef.y + 24 + ((vidm_selected % vidm_column_size)*8);
|
||||
|
||||
V_DrawScaledPatch(i - 8, j, 0,
|
||||
W_CachePatchName("M_CURSOR", PU_PATCH));
|
||||
|
@ -13717,11 +13722,14 @@ static void M_HandleVideoMode(INT32 ch)
|
|||
break;
|
||||
|
||||
case KEY_ENTER:
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
if (vid.modenum == modedescs[vidm_selected].modenum)
|
||||
{
|
||||
S_StartSound(NULL, sfx_strpst);
|
||||
SCR_SetDefaultMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
vidm_testingmode = 15*TICRATE;
|
||||
vidm_previousmode = vid.modenum;
|
||||
if (!setmodeneeded) // in case the previous setmode was not finished
|
||||
|
@ -13736,6 +13744,27 @@ 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_F10: // Renderer toggle, also processed inside menus
|
||||
CV_AddValue(&cv_renderer, 1);
|
||||
break;
|
||||
|
||||
case KEY_F11:
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
CV_SetValue(&cv_fullscreen, !cv_fullscreen.value);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
32
src/screen.c
32
src/screen.c
|
@ -70,6 +70,8 @@ static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"},
|
|||
//added : 03-02-98: default screen mode, as loaded/saved in config
|
||||
consvar_t cv_scr_width = CVAR_INIT ("scr_width", "1280", CV_SAVE, CV_Unsigned, NULL);
|
||||
consvar_t cv_scr_height = CVAR_INIT ("scr_height", "800", CV_SAVE, CV_Unsigned, NULL);
|
||||
consvar_t cv_scr_width_w = CVAR_INIT ("scr_width_w", "640", CV_SAVE, CV_Unsigned, NULL);
|
||||
consvar_t cv_scr_height_w = CVAR_INIT ("scr_height_w", "400", CV_SAVE, CV_Unsigned, NULL);
|
||||
consvar_t cv_scr_depth = CVAR_INIT ("scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL);
|
||||
|
||||
consvar_t cv_renderview = CVAR_INIT ("renderview", "On", 0, CV_OnOff, NULL);
|
||||
|
@ -377,10 +379,16 @@ void SCR_CheckDefaultMode(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf(M_GetText("Default resolution: %d x %d (%d bits)\n"), cv_scr_width.value,
|
||||
cv_scr_height.value, cv_scr_depth.value);
|
||||
// see note above
|
||||
setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1;
|
||||
CONS_Printf(M_GetText("Default resolution: %d x %d\n"), cv_scr_width.value, cv_scr_height.value);
|
||||
CONS_Printf(M_GetText("Windowed resolution: %d x %d\n"), cv_scr_width_w.value, cv_scr_height_w.value);
|
||||
CONS_Printf(M_GetText("Default bit depth: %d bits\n"), cv_scr_depth.value);
|
||||
if (cv_fullscreen.value)
|
||||
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)
|
||||
|
@ -398,9 +406,8 @@ void SCR_CheckDefaultMode(void)
|
|||
// sets the modenum as the new default video mode to be saved in the config file
|
||||
void SCR_SetDefaultMode(void)
|
||||
{
|
||||
// remember the default screen size
|
||||
CV_SetValue(&cv_scr_width, vid.width);
|
||||
CV_SetValue(&cv_scr_height, vid.height);
|
||||
CV_SetValue(cv_fullscreen.value ? &cv_scr_width : &cv_scr_width_w, vid.width);
|
||||
CV_SetValue(cv_fullscreen.value ? &cv_scr_height : &cv_scr_height_w, vid.height);
|
||||
}
|
||||
|
||||
// Change fullscreen on/off according to cv_fullscreen
|
||||
|
@ -415,7 +422,16 @@ void SCR_ChangeFullscreen(void)
|
|||
if (graphics_started)
|
||||
{
|
||||
VID_PrepareModeList();
|
||||
setmodeneeded = VID_GetModeForSize(vid.width, vid.height) + 1;
|
||||
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;
|
||||
|
||||
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
|
||||
|
|
|
@ -199,7 +199,8 @@ extern CV_PossibleValue_t cv_renderer_t[];
|
|||
extern INT32 scr_bpp;
|
||||
extern UINT8 *scr_borderpatch; // patch used to fill the view borders
|
||||
|
||||
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_fullscreen;
|
||||
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_width_w, cv_scr_height_w, cv_scr_depth, cv_fullscreen;
|
||||
extern consvar_t cv_renderview, cv_renderer;
|
||||
extern consvar_t cv_renderhitbox, cv_renderhitboxinterpolation, cv_renderhitboxgldepth;
|
||||
// wait for page flipping to end or not
|
||||
extern consvar_t cv_vidwait;
|
||||
|
|
|
@ -1859,7 +1859,7 @@ void I_StartupGraphics(void)
|
|||
borderlesswindow = M_CheckParm("-borderless");
|
||||
|
||||
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2);
|
||||
VID_Command_ModeList_f();
|
||||
//VID_Command_ModeList_f();
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
|
@ -1907,7 +1907,7 @@ void I_StartupGraphics(void)
|
|||
realwidth = (Uint16)vid.width;
|
||||
realheight = (Uint16)vid.height;
|
||||
|
||||
VID_Command_Info_f();
|
||||
//VID_Command_Info_f();
|
||||
SDLdoUngrabMouse();
|
||||
|
||||
SDL_RaiseWindow(window);
|
||||
|
|
Loading…
Reference in a new issue