mirror of https://github.com/OpenRCT2/OpenRCT2.git
fix #2187
Title sequence now maintains central position from script if window size changes.
This commit is contained in:
parent
d5688cdc4e
commit
025f36ec28
|
@ -31,6 +31,7 @@
|
||||||
#include "../input.h"
|
#include "../input.h"
|
||||||
#include "../localisation/localisation.h"
|
#include "../localisation/localisation.h"
|
||||||
#include "../openrct2.h"
|
#include "../openrct2.h"
|
||||||
|
#include "../title.h"
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
@ -312,12 +313,14 @@ static void platform_resize(int width, int height)
|
||||||
window_relocate_windows(width, height);
|
window_relocate_windows(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
title_fix_location();
|
||||||
gfx_invalidate_screen();
|
gfx_invalidate_screen();
|
||||||
|
|
||||||
// Check if the window has been resized in windowed mode and update the config file accordingly
|
// Check if the window has been resized in windowed mode and update the config file accordingly
|
||||||
// This is called in rct2_update_2 and is only called after resizing a window has finished
|
// This is called in rct2_update_2 and is only called after resizing a window has finished
|
||||||
if ((flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED |
|
const int nonWindowFlags =
|
||||||
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) == 0) {
|
SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
|
if (!(flags & nonWindowFlags)) {
|
||||||
if (width != gConfigGeneral.window_width || height != gConfigGeneral.window_height) {
|
if (width != gConfigGeneral.window_width || height != gConfigGeneral.window_height) {
|
||||||
gConfigGeneral.window_width = width;
|
gConfigGeneral.window_width = width;
|
||||||
gConfigGeneral.window_height = height;
|
gConfigGeneral.window_height = height;
|
||||||
|
|
46
src/title.c
46
src/title.c
|
@ -53,6 +53,7 @@ sint32 gTitleScriptCommand = -1;
|
||||||
uint8 gTitleScriptSave = 0xFF;
|
uint8 gTitleScriptSave = 0xFF;
|
||||||
sint32 gTitleScriptSkipTo = -1;
|
sint32 gTitleScriptSkipTo = -1;
|
||||||
sint32 gTitleScriptSkipLoad = -1;
|
sint32 gTitleScriptSkipLoad = -1;
|
||||||
|
rct_xy16 _titleScriptCurrentCentralPosition = { -1, -1 };
|
||||||
|
|
||||||
#pragma region Showcase script
|
#pragma region Showcase script
|
||||||
|
|
||||||
|
@ -222,6 +223,39 @@ static int title_load_park(const char *path)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the map location to the given tile coordinates. Z is automatic.
|
||||||
|
* @param x X position in map tiles.
|
||||||
|
* @param y Y position in map tiles.
|
||||||
|
*/
|
||||||
|
static void title_set_location(int x, int y)
|
||||||
|
{
|
||||||
|
int z = map_element_height(x, y);
|
||||||
|
|
||||||
|
// Update viewport
|
||||||
|
rct_window* w = window_get_main();
|
||||||
|
if (w != NULL) {
|
||||||
|
window_scroll_to_location(w, x, y, z);
|
||||||
|
w->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||||
|
viewport_update_position(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save known tile position in case of window resize
|
||||||
|
_titleScriptCurrentCentralPosition.x = (sint16)x;
|
||||||
|
_titleScriptCurrentCentralPosition.y = (sint16)y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-centres the map location to the last scripted tile position.
|
||||||
|
*/
|
||||||
|
void title_fix_location()
|
||||||
|
{
|
||||||
|
rct_xy16 position = _titleScriptCurrentCentralPosition;
|
||||||
|
if (position.x != -1) {
|
||||||
|
title_set_location(position.x, position.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void title_skip_opcode()
|
static void title_skip_opcode()
|
||||||
{
|
{
|
||||||
uint8 script_opcode;
|
uint8 script_opcode;
|
||||||
|
@ -255,7 +289,7 @@ static void title_skip_opcode()
|
||||||
static void title_do_next_script_opcode()
|
static void title_do_next_script_opcode()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
short x, y, z;
|
short x, y;
|
||||||
uint8 script_opcode, script_operand;
|
uint8 script_opcode, script_operand;
|
||||||
rct_window* w;
|
rct_window* w;
|
||||||
gTitleScriptCommand++;
|
gTitleScriptCommand++;
|
||||||
|
@ -295,15 +329,7 @@ static void title_do_next_script_opcode()
|
||||||
case TITLE_SCRIPT_LOCATION:
|
case TITLE_SCRIPT_LOCATION:
|
||||||
x = (*_currentScript++) * 32 + 16;
|
x = (*_currentScript++) * 32 + 16;
|
||||||
y = (*_currentScript++) * 32 + 16;
|
y = (*_currentScript++) * 32 + 16;
|
||||||
z = map_element_height(x, y);
|
title_set_location(x, y);
|
||||||
|
|
||||||
// Update viewport
|
|
||||||
w = window_get_main();
|
|
||||||
if (w != NULL) {
|
|
||||||
window_scroll_to_location(w, x, y, z);
|
|
||||||
w->flags &= ~WF_SCROLLING_TO_LOCATION;
|
|
||||||
viewport_update_position(w);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TITLE_SCRIPT_ROTATE:
|
case TITLE_SCRIPT_ROTATE:
|
||||||
script_operand = (*_currentScript++);
|
script_operand = (*_currentScript++);
|
||||||
|
|
|
@ -47,6 +47,7 @@ void title_update();
|
||||||
void title_skip_from_beginning();
|
void title_skip_from_beginning();
|
||||||
void title_script_get_line(SDL_RWops *file, char *parts);
|
void title_script_get_line(SDL_RWops *file, char *parts);
|
||||||
bool title_refresh_sequence();
|
bool title_refresh_sequence();
|
||||||
|
void title_fix_location();
|
||||||
void DrawOpenRCT2(int x, int y);
|
void DrawOpenRCT2(int x, int y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue