mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Open the game window on the last remembered display
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
0.0.8 (in development)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: OpenRCT2 now starts up on the display it was last shown on.
|
||||
- Improved: Mouse can now be dragged to select scenery when saving track designs
|
||||
- Fix: [#3178, #5456] Paths with non-ASCII characters not handled properly on macOS.
|
||||
- Fix: [#3681] Steel Twister rollercoaster always shows all track designs
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <openrct2/audio/AudioMixer.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/core/Math.hpp>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/drawing/IDrawingEngine.h>
|
||||
#include <openrct2/platform/Platform2.h>
|
||||
@@ -295,6 +296,24 @@ public:
|
||||
{
|
||||
OnResize(e.window.data1, e.window.data2);
|
||||
}
|
||||
|
||||
switch (e.window.event) {
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
{
|
||||
// Update default display index
|
||||
sint32 displayIndex = SDL_GetWindowDisplayIndex(_window);
|
||||
if (displayIndex != gConfigGeneral.default_display)
|
||||
{
|
||||
gConfigGeneral.default_display = displayIndex;
|
||||
config_save_default();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gConfigSound.audio_focus && gConfigSound.sound_enabled)
|
||||
{
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||
@@ -481,6 +500,11 @@ public:
|
||||
// g1.dat is loaded.
|
||||
// sub_68371D();
|
||||
|
||||
// Set window position to default display
|
||||
sint32 defaultDisplay = Math::Clamp(0, gConfigGeneral.default_display, 0xFFFF);
|
||||
sint32 x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
sint32 y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
|
||||
// Get saved window size
|
||||
sint32 width = gConfigGeneral.window_width;
|
||||
sint32 height = gConfigGeneral.window_height;
|
||||
@@ -494,7 +518,7 @@ public:
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
_window = SDL_CreateWindow(OPENRCT2_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
|
||||
_window = SDL_CreateWindow(OPENRCT2_NAME, x, y, width, height, flags);
|
||||
if (_window == nullptr)
|
||||
{
|
||||
SDLException::Throw("SDL_CreateWindow(...)");
|
||||
@@ -503,7 +527,7 @@ public:
|
||||
SDL_SetWindowMinimumSize(_window, 720, 480);
|
||||
SetCursorTrap(gConfigGeneral.trap_cursor);
|
||||
_platformUiContext->SetWindowIcon(_window);
|
||||
|
||||
|
||||
// Initialise the surface, palette and draw buffer
|
||||
OnResize(width, height);
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@ namespace Config
|
||||
model->window_height = reader->GetSint32("window_height", -1);
|
||||
model->window_snap_proximity = reader->GetSint32("window_snap_proximity", 5);
|
||||
model->window_width = reader->GetSint32("window_width", -1);
|
||||
model->default_display = reader->GetSint32("default_display", 0);
|
||||
model->drawing_engine = reader->GetEnum<sint32>("drawing_engine", DRAWING_ENGINE_SOFTWARE, Enum_DrawingEngine);
|
||||
model->uncap_fps = reader->GetBoolean("uncap_fps", false);
|
||||
|
||||
@@ -233,6 +234,7 @@ namespace Config
|
||||
writer->WriteSint32("window_height", model->window_height);
|
||||
writer->WriteSint32("window_snap_proximity", model->window_snap_proximity);
|
||||
writer->WriteSint32("window_width", model->window_width);
|
||||
writer->WriteSint32("default_display", model->default_display);
|
||||
writer->WriteEnum<sint32>("drawing_engine", model->drawing_engine, Enum_DrawingEngine);
|
||||
writer->WriteBoolean("uncap_fps", model->uncap_fps);
|
||||
writer->WriteBoolean("test_unfinished_tracks", model->test_unfinished_tracks);
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef struct GeneralConfiguration
|
||||
utf8 * rct2_path;
|
||||
|
||||
// Display
|
||||
sint32 default_display;
|
||||
sint32 window_width;
|
||||
sint32 window_height;
|
||||
sint32 fullscreen_mode;
|
||||
|
||||
Reference in New Issue
Block a user