tr2/shell: fix support for dual monitors

Addresses #2820.
This commit is contained in:
Marcin Kurczewski 2025-04-22 22:15:51 +02:00
parent 8133f72e20
commit 4fa521d956
3 changed files with 21 additions and 6 deletions

View file

@ -45,6 +45,9 @@
- fixed pushblocks being rotated when Lara grabs them, most noticeable if asymmetric textures have been used (#2776)
- fixed the boat briefly having an underwater hue when Lara first climbs on (#2787)
- fixed destroyed gondolas appearing embedded in the ground after loading a save (#1612)
- fixed a crash in custom levels with large rooms (#2749)
- fixed the viewport not always in sync with the window (#2820)
- fixed inability to move the window to another screen (#2820)
- fixed flares flipped to the right when thrown (regression from 0.10)
- fixed the camera going out of bounds in 60fps near specific invalid floor data (known as no-space) (#2764, regression from 0.10)
- fixed sprites rendering black if no shade value is assigned in the level (#2701, regression from 0.8)
@ -53,9 +56,7 @@
- fixed the `/pos` console command reporting the base room number when Lara is actually in a flipped room (#2487, regression from 0.3)
- fixed a crash if an image was missing
- fixed a crash on level load if an animation has no frames (#2746, regression from 0.8)
- fixed a crash in custom levels with large rooms (#2749)
- fixed flares missing the flicker effect in 60 FPS (#2806)
- fixed the viewport not always in sync with the window (#2820)
- fixed flares missing the flicker effect in 60 FPS (#2806, regression from 0.10)
- improved performance when moving the window around
- improved pause exit dialog - it can now be canceled with escape
- removed the need to specify in the game flow levels that have no secrets (secrets will be automatically counted) (#1582)

View file

@ -156,9 +156,16 @@ SHELL_SIZE Shell_GetCurrentSize(void)
SHELL_SIZE Shell_GetCurrentDisplaySize(void)
{
int32_t display_idx = 0;
SDL_Window *const window = Shell_GetWindow();
if (window != nullptr) {
display_idx = SDL_GetWindowDisplayIndex(window);
}
SDL_DisplayMode dm;
SDL_GetCurrentDisplayMode(0, &dm);
return (SHELL_SIZE) { .w = dm.w, .h = dm.h };
if (SDL_GetCurrentDisplayMode(display_idx, &dm) == 0) {
return (SHELL_SIZE) { .w = dm.w, .h = dm.h };
}
return (SHELL_SIZE) { .w = -1, .h = -1 };
}
void Shell_ScheduleExit(void)

View file

@ -79,6 +79,7 @@ static SHELL_ARGS m_Args = {
static SHELL_SIZE m_ViewportSize = { .w = -1, .h = -1 };
static Uint64 m_UpdateDebounce = 0;
static bool m_IgnoreConfigChanges = false;
static void M_SyncToWindow(void);
static void M_SyncFromWindow(bool update_viewport);
@ -155,7 +156,7 @@ static void M_SyncFromWindow(const bool update_viewport)
// Determine if this call should sync config, i.e., skip immediate
// programmatic events
const Uint32 now = SDL_GetTicks();
const bool skip_config = (now - m_UpdateDebounce) < 100;
const bool skip_config = (now - m_UpdateDebounce) < 500;
// Always pull current window state for logging and viewport reset
const Uint32 window_flags = SDL_GetWindowFlags(g_SDLWindow);
@ -176,7 +177,9 @@ static void M_SyncFromWindow(const bool update_viewport)
g_Config.window.height = height;
}
if (g_Config.loaded) {
m_IgnoreConfigChanges = true;
Config_Write();
m_IgnoreConfigChanges = false;
}
}
@ -351,6 +354,10 @@ static void M_LoadConfig(void)
static void M_HandleConfigChange(const EVENT *const event, void *const data)
{
if (m_IgnoreConfigChanges) {
return;
}
const CONFIG *const old = &g_Config;
const CONFIG *const new = &g_SavedConfig;