mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #10818 from tupaschoal/coords-xy-2
Use ScreenCoordsXY for some window interactions
This commit is contained in:
commit
6d7a2bea69
|
@ -557,10 +557,10 @@ public:
|
|||
|
||||
// Set window position to default display
|
||||
int32_t defaultDisplay = std::clamp(gConfigGeneral.default_display, 0, 0xFFFF);
|
||||
int32_t x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
int32_t y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
auto windowPos = ScreenCoordsXY{ static_cast<int32_t>(SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay)),
|
||||
static_cast<int32_t>(SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay)) };
|
||||
|
||||
CreateWindow(x, y);
|
||||
CreateWindow(windowPos);
|
||||
|
||||
// Check if steam overlay renderer is loaded into the process
|
||||
_steamOverlayActive = _platformUiContext->IsSteamOverlayAttached();
|
||||
|
@ -579,12 +579,12 @@ public:
|
|||
void RecreateWindow() override
|
||||
{
|
||||
// Use the position of the current window for the new window
|
||||
int32_t x, y;
|
||||
ScreenCoordsXY windowPos;
|
||||
SDL_SetWindowFullscreen(_window, 0);
|
||||
SDL_GetWindowPosition(_window, &x, &y);
|
||||
SDL_GetWindowPosition(_window, &windowPos.x, &windowPos.y);
|
||||
|
||||
CloseWindow();
|
||||
CreateWindow(x, y);
|
||||
CreateWindow(windowPos);
|
||||
}
|
||||
|
||||
void ShowMessageBox(const std::string& message) override
|
||||
|
@ -629,7 +629,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void CreateWindow(int32_t x, int32_t y)
|
||||
void CreateWindow(const ScreenCoordsXY& windowPos)
|
||||
{
|
||||
// Get saved window size
|
||||
int32_t width = gConfigGeneral.window_width;
|
||||
|
@ -646,7 +646,7 @@ private:
|
|||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
_window = SDL_CreateWindow(OPENRCT2_NAME, x, y, width, height, flags);
|
||||
_window = SDL_CreateWindow(OPENRCT2_NAME, windowPos.x, windowPos.y, width, height, flags);
|
||||
if (_window == nullptr)
|
||||
{
|
||||
SDLException::Throw("SDL_CreateWindow(...)");
|
||||
|
|
|
@ -488,7 +488,7 @@ public:
|
|||
return std::string(buffer);
|
||||
}
|
||||
|
||||
void SetMainView(int32_t x, int32_t y, int32_t zoom, int32_t rotation) override
|
||||
void SetMainView(const ScreenCoordsXY& viewPos, int32_t zoom, int32_t rotation) override
|
||||
{
|
||||
auto mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
|
@ -497,8 +497,8 @@ public:
|
|||
auto zoomDifference = zoom - viewport->zoom;
|
||||
|
||||
mainWindow->viewport_target_sprite = SPRITE_INDEX_NULL;
|
||||
mainWindow->saved_view_x = x;
|
||||
mainWindow->saved_view_y = y;
|
||||
mainWindow->saved_view_x = viewPos.x;
|
||||
mainWindow->saved_view_y = viewPos.y;
|
||||
viewport->zoom = zoom;
|
||||
gCurrentRotation = rotation;
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ private:
|
|||
void PrepareParkForPlayback()
|
||||
{
|
||||
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
|
||||
windowManager->SetMainView(gSavedViewX, gSavedViewY, gSavedViewZoom, gSavedViewRotation);
|
||||
windowManager->SetMainView(gSavedView, gSavedViewZoom, gSavedViewRotation);
|
||||
reset_sprite_spatial_index();
|
||||
reset_all_sprite_quadrant_placements();
|
||||
auto intent = Intent(INTENT_ACTION_REFRESH_NEW_RIDES);
|
||||
|
|
|
@ -425,7 +425,7 @@ namespace Editor
|
|||
static void FinaliseMainView()
|
||||
{
|
||||
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
|
||||
windowManager->SetMainView(gSavedViewX, gSavedViewY, gSavedViewZoom, gSavedViewRotation);
|
||||
windowManager->SetMainView(gSavedView, gSavedViewZoom, gSavedViewRotation);
|
||||
|
||||
reset_all_sprite_quadrant_placements();
|
||||
scenery_set_default_placement_configuration();
|
||||
|
|
|
@ -553,7 +553,7 @@ void game_load_init()
|
|||
}
|
||||
|
||||
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
|
||||
windowManager->SetMainView(gSavedViewX, gSavedViewY, gSavedViewZoom, gSavedViewRotation);
|
||||
windowManager->SetMainView(gSavedView, gSavedViewZoom, gSavedViewRotation);
|
||||
|
||||
if (network_get_mode() != NETWORK_MODE_CLIENT)
|
||||
{
|
||||
|
|
|
@ -733,8 +733,8 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption
|
|||
}
|
||||
else
|
||||
{
|
||||
viewport.view_x = gSavedViewX - (viewport.view_width / 2);
|
||||
viewport.view_y = gSavedViewY - (viewport.view_height / 2);
|
||||
viewport.view_x = gSavedView.x - (viewport.view_width / 2);
|
||||
viewport.view_y = gSavedView.y - (viewport.view_height / 2);
|
||||
viewport.zoom = gSavedViewZoom;
|
||||
gCurrentRotation = gSavedViewRotation;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ rct_viewport* g_music_tracking_viewport;
|
|||
|
||||
static std::unique_ptr<JobPool> _paintJobs;
|
||||
|
||||
int16_t gSavedViewX;
|
||||
int16_t gSavedViewY;
|
||||
ScreenCoordsXY gSavedView;
|
||||
uint8_t gSavedViewZoom;
|
||||
uint8_t gSavedViewRotation;
|
||||
|
||||
|
@ -1922,8 +1921,8 @@ void viewport_set_saved_view()
|
|||
{
|
||||
rct_viewport* viewport = w->viewport;
|
||||
|
||||
gSavedViewX = viewport->view_width / 2 + viewport->view_x;
|
||||
gSavedViewY = viewport->view_height / 2 + viewport->view_y;
|
||||
gSavedView = ScreenCoordsXY{ viewport->view_width / 2 + viewport->view_x,
|
||||
viewport->view_height / 2 + viewport->view_y };
|
||||
|
||||
gSavedViewZoom = viewport->zoom;
|
||||
gSavedViewRotation = get_current_rotation();
|
||||
|
|
|
@ -121,8 +121,7 @@ extern uint8_t gShowConstuctionRightsRefCount;
|
|||
// rct2: 0x014234BC
|
||||
extern rct_viewport g_viewport_list[MAX_VIEWPORT_COUNT];
|
||||
extern rct_viewport* g_music_tracking_viewport;
|
||||
extern int16_t gSavedViewX;
|
||||
extern int16_t gSavedViewY;
|
||||
extern ScreenCoordsXY gSavedView;
|
||||
extern uint8_t gSavedViewZoom;
|
||||
extern uint8_t gSavedViewRotation;
|
||||
|
||||
|
|
|
@ -2680,8 +2680,7 @@ private:
|
|||
|
||||
void ImportSavedView()
|
||||
{
|
||||
gSavedViewX = _s4.view_x;
|
||||
gSavedViewY = _s4.view_y;
|
||||
gSavedView = ScreenCoordsXY{ _s4.view_x, _s4.view_y };
|
||||
gSavedViewZoom = _s4.view_zoom;
|
||||
gSavedViewRotation = _s4.view_rotation;
|
||||
}
|
||||
|
|
|
@ -360,8 +360,8 @@ void S6Exporter::Export()
|
|||
this->ExportRides();
|
||||
|
||||
_s6.saved_age = gSavedAge;
|
||||
_s6.saved_view_x = gSavedViewX;
|
||||
_s6.saved_view_y = gSavedViewY;
|
||||
_s6.saved_view_x = gSavedView.x;
|
||||
_s6.saved_view_y = gSavedView.y;
|
||||
_s6.saved_view_zoom = gSavedViewZoom;
|
||||
_s6.saved_view_rotation = gSavedViewRotation;
|
||||
|
||||
|
|
|
@ -383,8 +383,7 @@ public:
|
|||
ImportRides();
|
||||
|
||||
gSavedAge = _s6.saved_age;
|
||||
gSavedViewX = _s6.saved_view_x;
|
||||
gSavedViewY = _s6.saved_view_y;
|
||||
gSavedView = ScreenCoordsXY{ _s6.saved_view_x, _s6.saved_view_y };
|
||||
gSavedViewZoom = _s6.saved_view_zoom;
|
||||
gSavedViewRotation = _s6.saved_view_rotation;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace OpenRCT2::Ui
|
|||
{
|
||||
return std::string();
|
||||
}
|
||||
void SetMainView(int32_t x, int32_t y, int32_t zoom, int32_t rotation) override
|
||||
void SetMainView(const ScreenCoordsXY& viewPos, int32_t zoom, int32_t rotation) override
|
||||
{
|
||||
}
|
||||
void UpdateMouseWheel() override
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace OpenRCT2::Ui
|
|||
virtual void HandleInput() abstract;
|
||||
virtual void HandleKeyboard(bool isTitle) abstract;
|
||||
virtual std::string GetKeyboardShortcutString(int32_t shortcut) abstract;
|
||||
virtual void SetMainView(int32_t x, int32_t y, int32_t zoom, int32_t rotation) abstract;
|
||||
virtual void SetMainView(const ScreenCoordsXY& viewPos, int32_t zoom, int32_t rotation) abstract;
|
||||
virtual void UpdateMouseWheel() abstract;
|
||||
virtual rct_window* GetOwner(const rct_viewport* viewport) abstract;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue