mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'save-display' into 'master'
Remember the last used window display See merge request KartKrew/Kart!2393
This commit is contained in:
commit
7c46cc029d
3 changed files with 33 additions and 4 deletions
|
|
@ -445,6 +445,8 @@ consvar_t cv_scr_scale = Player("scr_scale", "1.0").floating_point();
|
||||||
consvar_t cv_scr_x = Player("scr_x", "0.0").floating_point();
|
consvar_t cv_scr_x = Player("scr_x", "0.0").floating_point();
|
||||||
consvar_t cv_scr_y = Player("scr_y", "0.0").floating_point();
|
consvar_t cv_scr_y = Player("scr_y", "0.0").floating_point();
|
||||||
|
|
||||||
|
consvar_t cv_display = Player("display", "0").values(CV_Unsigned).save();
|
||||||
|
|
||||||
consvar_t cv_seenames = Player("seenames", "On").on_off();
|
consvar_t cv_seenames = Player("seenames", "On").on_off();
|
||||||
consvar_t cv_shadow = Player("shadow", "On").on_off();
|
consvar_t cv_shadow = Player("shadow", "On").on_off();
|
||||||
consvar_t cv_showfocuslost = Player("showfocuslost", "Yes").yes_no();
|
consvar_t cv_showfocuslost = Player("showfocuslost", "Yes").yes_no();
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ 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_renderhitbox, cv_fullscreen;
|
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_renderhitbox, cv_fullscreen;
|
||||||
extern consvar_t cv_scr_effect;
|
extern consvar_t cv_scr_effect;
|
||||||
extern consvar_t cv_parallelsoftware;
|
extern consvar_t cv_parallelsoftware;
|
||||||
|
extern consvar_t cv_display;
|
||||||
|
|
||||||
// wait for page flipping to end or not
|
// wait for page flipping to end or not
|
||||||
extern consvar_t cv_vidwait;
|
extern consvar_t cv_vidwait;
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,23 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||||
//static void Impl_SetWindowName(const char *title);
|
//static void Impl_SetWindowName(const char *title);
|
||||||
static void Impl_SetWindowIcon(void);
|
static void Impl_SetWindowIcon(void);
|
||||||
|
|
||||||
|
static void ValidateDisplay(void)
|
||||||
|
{
|
||||||
|
// Validate display index, otherwise use main display
|
||||||
|
if (cv_display.value >= SDL_GetNumVideoDisplays())
|
||||||
|
{
|
||||||
|
CV_SetValue(&cv_display, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CenterWindow(void)
|
||||||
|
{
|
||||||
|
SDL_SetWindowPosition(window,
|
||||||
|
SDL_WINDOWPOS_CENTERED_DISPLAY(cv_display.value),
|
||||||
|
SDL_WINDOWPOS_CENTERED_DISPLAY(cv_display.value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static void SDLSetMode(int width, int height, SDL_bool fullscreen, SDL_bool reposition)
|
static void SDLSetMode(int width, int height, SDL_bool fullscreen, SDL_bool reposition)
|
||||||
{
|
{
|
||||||
static SDL_bool wasfullscreen = SDL_FALSE;
|
static SDL_bool wasfullscreen = SDL_FALSE;
|
||||||
|
|
@ -183,6 +200,14 @@ static void SDLSetMode(int width, int height, SDL_bool fullscreen, SDL_bool repo
|
||||||
{
|
{
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
|
if (reposition)
|
||||||
|
{
|
||||||
|
ValidateDisplay();
|
||||||
|
if (SDL_GetWindowDisplayIndex(window) != cv_display.value)
|
||||||
|
{
|
||||||
|
CenterWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
wasfullscreen = SDL_TRUE;
|
wasfullscreen = SDL_TRUE;
|
||||||
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
}
|
}
|
||||||
|
|
@ -197,10 +222,8 @@ static void SDLSetMode(int width, int height, SDL_bool fullscreen, SDL_bool repo
|
||||||
SDL_SetWindowSize(window, width, height);
|
SDL_SetWindowSize(window, width, height);
|
||||||
if (reposition)
|
if (reposition)
|
||||||
{
|
{
|
||||||
SDL_SetWindowPosition(window,
|
ValidateDisplay();
|
||||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
|
CenterWindow();
|
||||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -505,6 +528,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
vid.realwidth = evt.data1;
|
vid.realwidth = evt.data1;
|
||||||
vid.realheight = evt.data2;
|
vid.realheight = evt.data2;
|
||||||
break;
|
break;
|
||||||
|
case SDL_WINDOWEVENT_DISPLAY_CHANGED:
|
||||||
|
CV_SetValue(&cv_display, evt.data1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FOCUSUNION == oldfocus) // No state change
|
if (FOCUSUNION == oldfocus) // No state change
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue