Get the game working

Mostly just needed to resolve screen size which is now retrieved via ui context.
This commit is contained in:
Ted John authored and Gymnasiast committed 2017-05-29 22:38:43 +02:00
1 parent 7163973bd2
commit bd9839ff50
47 files changed
+208 -153

No files matched your search

+11 -11
View File
@@ -22,7 +22,17 @@
using namespace OpenRCT2::Ui;
CursorRepository::CursorRepository()
CursorRepository::~CursorRepository()
{
for (size_t i = 0; i < CURSOR_COUNT; i++)
{
SDL_FreeCursor(_loadedCursors[i]);
_loadedCursors[i] = nullptr;
}
_currentCursor = CURSOR_UNDEFINED;
}
void CursorRepository::LoadCursors()
{
// Using system cursors
_loadedCursors[CURSOR_ARROW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
@@ -42,16 +52,6 @@ CursorRepository::CursorRepository()
SetCurrentCursor(CURSOR_ARROW);
}
CursorRepository::~CursorRepository()
{
for (size_t i = 0; i < CURSOR_COUNT; i++)
{
SDL_FreeCursor(_loadedCursors[i]);
_loadedCursors[i] = nullptr;
}
_currentCursor = CURSOR_UNDEFINED;
}
CURSOR_ID CursorRepository::GetCurrentCursor()
{
return _currentCursor;
+2 -2
View File
@@ -28,12 +28,12 @@ namespace OpenRCT2
constexpr static sint32 CURSOR_WIDTH = 32;
constexpr static sint32 CURSOR_HEIGHT = 32;
SDL_Cursor * _loadedCursors[CURSOR_COUNT];
SDL_Cursor * _loadedCursors[CURSOR_COUNT] = { nullptr };
CURSOR_ID _currentCursor = CURSOR_UNDEFINED;
public:
CursorRepository();
~CursorRepository();
void LoadCursors();
CURSOR_ID GetCurrentCursor();
void SetCurrentCursor(CURSOR_ID cursorId);
+8 -7
View File
@@ -83,6 +83,7 @@ public:
{
SDLException::Throw("SDL_Init(SDL_INIT_VIDEO)");
}
_cursorRepository.LoadCursors();
}
~UiContext() override
@@ -331,13 +332,13 @@ public:
// Apple sends touchscreen events for trackpads, so ignore these events on macOS
#ifndef __MACOSX__
case SDL_FINGERMOTION:
_cursorState.x = (sint32)(e.tfinger.x * gScreenWidth);
_cursorState.y = (sint32)(e.tfinger.y * gScreenHeight);
_cursorState.x = (sint32)(e.tfinger.x * _width);
_cursorState.y = (sint32)(e.tfinger.y * _height);
break;
case SDL_FINGERDOWN:
{
sint32 x = (sint32)(e.tfinger.x * gScreenWidth);
sint32 y = (sint32)(e.tfinger.y * gScreenHeight);
sint32 x = (sint32)(e.tfinger.x * _width);
sint32 y = (sint32)(e.tfinger.y * _height);
_cursorState.touchIsDouble = (!_cursorState.touchIsDouble &&
e.tfinger.timestamp - _cursorState.touchDownTimestamp < TOUCH_DOUBLE_TIMEOUT);
@@ -360,8 +361,8 @@ public:
}
case SDL_FINGERUP:
{
sint32 x = (sint32)(e.tfinger.x * gScreenWidth);
sint32 y = (sint32)(e.tfinger.y * gScreenHeight);
sint32 x = (sint32)(e.tfinger.x * _width);
sint32 y = (sint32)(e.tfinger.y * _height);
if (_cursorState.touchIsDouble)
{
@@ -393,7 +394,7 @@ public:
// Zoom gesture
constexpr sint32 tolerance = 128;
sint32 gesturePixels = (sint32)(_gestureRadius * gScreenWidth);
sint32 gesturePixels = (sint32)(_gestureRadius * _width);
if (abs(gesturePixels) > tolerance)
{
_gestureRadius = 0;
@@ -655,8 +655,8 @@ private:
// Determine region in pixels
uint32 left = Math::Max<uint32>(0, x * _dirtyGrid.BlockWidth);
uint32 top = Math::Max<uint32>(0, y * _dirtyGrid.BlockHeight);
uint32 right = Math::Min((uint32)gScreenWidth, left + (columns * _dirtyGrid.BlockWidth));
uint32 bottom = Math::Min((uint32)gScreenHeight, top + (rows * _dirtyGrid.BlockHeight));
uint32 right = Math::Min(_width, left + (columns * _dirtyGrid.BlockWidth));
uint32 bottom = Math::Min(_height, top + (rows * _dirtyGrid.BlockHeight));
if (right <= left || bottom <= top)
{
return;
+10
View File
@@ -664,4 +664,14 @@ extern "C"
Memory::CopyArray(*outResolutions, resolutions.data(), count);
return count;
}
sint32 context_get_width()
{
return GetContext()->GetUiContext()->GetWidth();
}
sint32 context_get_height()
{
return GetContext()->GetUiContext()->GetHeight();
}
}
+2
View File
@@ -100,6 +100,8 @@ extern "C"
void context_trigger_resize();
void context_set_fullscreen_mode(sint32 mode);
sint32 context_get_resolutions(struct Resolution * * outResolutions);
sint32 context_get_width();
sint32 context_get_height();
#ifdef __cplusplus
}
+4 -2
View File
@@ -14,17 +14,19 @@
*****************************************************************************/
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../core/File.h"
#include "../core/FileStream.hpp"
#include "../core/Memory.hpp"
#include "../core/Util.hpp"
#include "../localisation/string_ids.h"
#include "../OpenRCT2.h"
#include "../ui/UiContext.h"
#include "AudioMixer.h"
extern "C"
{
#include "../config/Config.h"
#include "../interface/viewport.h"
#include "../intro.h"
#include "../localisation/language.h"
@@ -255,7 +257,7 @@ sint32 audio_play_sound(sint32 soundId, sint32 volume, sint32 pan)
sint32 mixerPan = 0;
if (pan != AUDIO_PLAY_AT_CENTRE) {
sint32 x2 = pan << 16;
uint16 screenWidth = Math::Max(64, gScreenWidth);
uint16 screenWidth = Math::Max<sint32>(64, OpenRCT2::GetContext()->GetUiContext()->GetWidth());
mixerPan = ((x2 / screenWidth) - 0x8000) >> 4;
}
+3 -1
View File
@@ -139,7 +139,9 @@ extern "C"
{
drawing_engine_init();
}
_drawingEngine->Resize(gScreenWidth, gScreenHeight);
IUiContext * uiContext = GetContext()->GetUiContext();
_drawingEngine->Resize(uiContext->GetWidth(), uiContext->GetHeight());
}
void drawing_engine_set_palette(SDL_Color * colours)
+2 -1
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../common.h"
#include "../Context.h"
#include "../core/Guard.hpp"
#include "../interface/window.h"
#include "../localisation/localisation.h"
@@ -546,7 +547,7 @@ void load_palette(){
*/
void gfx_invalidate_screen()
{
gfx_set_dirty_blocks(0, 0, gScreenWidth, gScreenHeight);
gfx_set_dirty_blocks(0, 0, context_get_width(), context_get_height());
}
/**
+2 -1
View File
@@ -17,6 +17,7 @@
#include "audio/audio.h"
#include "cheats.h"
#include "config/Config.h"
#include "Context.h"
#include "editor.h"
#include "game.h"
#include "input.h"
@@ -138,7 +139,7 @@ void game_create_windows()
window_main_open();
window_top_toolbar_open();
window_game_bottom_toolbar_open();
window_resize_gui(gScreenWidth, gScreenHeight);
window_resize_gui(context_get_width(), context_get_height());
}
enum {
+7 -5
View File
@@ -138,8 +138,10 @@ void game_handle_input()
if (_inputFlags & INPUT_FLAG_5) {
game_handle_input_mouse(x, y, state);
} else if (x != 0x80000000) {
x = clamp(0, x, gScreenWidth - 1);
y = clamp(0, y, gScreenHeight - 1);
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = clamp(0, x, screenWidth - 1);
y = clamp(0, y, screenHeight - 1);
game_handle_input_mouse(x, y, state);
process_mouse_over(x, y);
@@ -470,7 +472,7 @@ static void input_window_resize_begin(rct_window *w, rct_widgetindex widgetIndex
static void input_window_resize_continue(rct_window *w, sint32 x, sint32 y)
{
if (y < (sint32)gScreenHeight - 2) {
if (y < (sint32)context_get_height() - 2) {
sint32 dx, dy, targetWidth, targetHeight;
dx = x - gInputDragLastX;
dy = y - gInputDragLastY;
@@ -1623,13 +1625,13 @@ void game_handle_edge_scroll()
const CursorState * cursorState = context_get_cursor_state();
if (cursorState->x == 0)
scrollX = -1;
else if (cursorState->x >= gScreenWidth - 1)
else if (cursorState->x >= context_get_width() - 1)
scrollX = 1;
// Scroll up / down
if (cursorState->y == 0)
scrollY = -1;
else if (cursorState->y >= gScreenHeight - 1)
else if (cursorState->y >= context_get_height() - 1)
scrollY = 1;
// Scroll viewport
+2 -2
View File
@@ -84,9 +84,9 @@ void chat_draw(rct_drawpixelinfo * dpi)
}
_chatLeft = 10;
_chatRight = min((gScreenWidth - 10), CHAT_MAX_WINDOW_WIDTH);
_chatRight = min((context_get_width() - 10), CHAT_MAX_WINDOW_WIDTH);
_chatWidth = _chatRight - _chatLeft;
_chatBottom = gScreenHeight - 45;
_chatBottom = context_get_height() - 45;
_chatTop = _chatBottom - 10;
char lineBuffer[CHAT_INPUT_SIZE + 10];
+1 -1
View File
@@ -127,7 +127,7 @@ void console_update()
_consoleLeft = 0;
_consoleTop = 0;
_consoleRight = gScreenWidth;
_consoleRight = context_get_width();
_consoleBottom = 322;
if (gConsoleOpen) {
+2 -1
View File
@@ -16,6 +16,7 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../game.h"
#include "../Imaging.h"
@@ -46,7 +47,7 @@ void screenshot_check()
screenshotIndex = screenshot_dump();
if (screenshotIndex != -1) {
audio_play_sound(SOUND_WINDOW_OPEN, 100, gScreenWidth / 2);
audio_play_sound(SOUND_WINDOW_OPEN, 100, context_get_width() / 2);
} else {
window_error_open(STR_SCREENSHOT_FAILED, STR_NONE);
}
+5 -4
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../game.h"
#include "../input.h"
@@ -424,8 +425,8 @@ static void viewport_move(sint16 x, sint16 y, rct_window* w, rct_viewport* viewp
if (w->flags & WF_7){
sint32 left = max(viewport->x, 0);
sint32 top = max(viewport->y, 0);
sint32 right = min(viewport->x + viewport->width, gScreenWidth);
sint32 bottom = min(viewport->y + viewport->height, gScreenHeight);
sint32 right = min(viewport->x + viewport->width, context_get_width());
sint32 bottom = min(viewport->y + viewport->height, context_get_height());
if (left >= right) return;
if (top >= bottom) return;
@@ -447,7 +448,7 @@ static void viewport_move(sint16 x, sint16 y, rct_window* w, rct_viewport* viewp
viewport->x = 0;
}
sint32 eax = viewport->x + viewport->width - gScreenWidth;
sint32 eax = viewport->x + viewport->width - context_get_width();
if (eax > 0){
viewport->width -= eax;
viewport->view_width -= eax * zoom;
@@ -465,7 +466,7 @@ static void viewport_move(sint16 x, sint16 y, rct_window* w, rct_viewport* viewp
viewport->y = 0;
}
eax = viewport->y + viewport->height - gScreenHeight;
eax = viewport->y + viewport->height - context_get_height();
if (eax > 0){
viewport->height -= eax;
viewport->view_height -= eax * zoom;
+20 -19
View File
@@ -500,8 +500,8 @@ rct_window *window_create(sint32 x, sint32 y, sint32 width, sint32 height, rct_w
*/
static bool sub_6EA8EC(sint32 x, sint32 y, sint32 width, sint32 height)
{
uint16 screenWidth = gScreenWidth;
uint16 screenHeight = gScreenHeight;
uint16 screenWidth = context_get_width();
uint16 screenHeight = context_get_height();
sint32 unk;
unk = -(width / 4);
@@ -527,8 +527,8 @@ static bool sub_6EA934(sint32 x, sint32 y, sint32 width, sint32 height)
{
if (x < 0) return false;
if (y < 28) return false;
if (x + width > gScreenWidth) return false;
if (y + height > gScreenHeight) return false;
if (x + width > context_get_width()) return false;
if (y + height > context_get_height()) return false;
return sub_6EA95D(x, y, width, height);
}
@@ -569,8 +569,8 @@ static bool sub_6EA95D(sint32 x, sint32 y, sint32 width, sint32 height)
*/
rct_window *window_create_auto_pos(sint32 width, sint32 height, rct_window_event_list *event_handlers, rct_windowclass cls, uint16 flags)
{
uint16 screenWidth = gScreenWidth;
uint16 screenHeight = gScreenHeight;
uint16 screenWidth = context_get_width();
uint16 screenHeight = context_get_height();
// TODO dead code, looks like it is cascading the new window offset from an existing window
// we will have to re-implement this in our own way.
@@ -579,11 +579,11 @@ rct_window *window_create_auto_pos(sint32 width, sint32 height, rct_window_event
// cls &= ~0x80;
// rct_window *w = window_find_by_number(0, 0);
// if (w != NULL) {
// if (w->x > -60 && w->x < gScreenWidth - 20) {
// if (w->y < gScreenHeight - 20) {
// if (w->x > -60 && w->x < screenWidth - 20) {
// if (w->y < screenHeight - 20) {
// sint32 x = w->x;
// if (w->x + width > gScreenWidth)
// x = gScreenWidth - 20 - width;
// if (w->x + width > screenWidth)
// x = screenWidth - 20 - width;
// sint32 y = w->y;
// return window_create(x + 10, y + 10, width, height, event_handlers, cls, flags);
// }
@@ -689,12 +689,13 @@ foundSpace:
return window_create(x, y, width, height, event_handlers, cls, flags);
}
rct_window *window_create_centred(sint32 width, sint32 height, rct_window_event_list *event_handlers, rct_windowclass cls, uint16 flags)
rct_window * window_create_centred(sint32 width, sint32 height, rct_window_event_list *event_handlers, rct_windowclass cls, uint16 flags)
{
sint32 x, y;
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = (gScreenWidth - width) / 2;
y = max(28, (gScreenHeight - height) / 2);
sint32 x = (screenWidth - width) / 2;
sint32 y = max(28, (screenHeight - height) / 2);
return window_create(x, y, width, height, event_handlers, cls, flags);
}
@@ -1233,7 +1234,7 @@ void window_push_others_right(rct_window* window)
continue;
window_invalidate(w);
if (window->x + window->width + 13 >= gScreenWidth)
if (window->x + window->width + 13 >= context_get_width())
continue;
uint16 push_amount = window->x + window->width - w->x + 3;
w->x += push_amount;
@@ -1268,7 +1269,7 @@ void window_push_others_below(rct_window *w1)
continue;
// Check if there is room to push it down
if (w1->y + w1->height + 80 >= gScreenHeight)
if (w1->y + w1->height + 80 >= context_get_height())
continue;
// Invalidate the window's current area
@@ -2402,7 +2403,7 @@ static void window_snap_right(rct_window *w, sint32 proximity)
leftMost = min(leftMost, w2->x);
}
screenWidth = gScreenWidth;
screenWidth = context_get_width();
if (screenWidth >= wLeftProximity && screenWidth <= wRightProximity)
leftMost = min(leftMost, screenWidth);
@@ -2435,7 +2436,7 @@ static void window_snap_bottom(rct_window *w, sint32 proximity)
topMost = min(topMost, w2->y);
}
screenHeight = gScreenHeight;
screenHeight = context_get_height();
if (screenHeight >= wTopProximity && screenHeight <= wBottomProximity)
topMost = min(topMost, screenHeight);
@@ -2448,7 +2449,7 @@ void window_move_and_snap(rct_window *w, sint32 newWindowX, sint32 newWindowY, s
sint32 originalX = w->x;
sint32 originalY = w->y;
newWindowY = clamp(29, newWindowY, gScreenHeight - 34);
newWindowY = clamp(29, newWindowY, context_get_height() - 34);
if (snapProximity > 0) {
w->x = newWindowX;
+5 -5
View File
@@ -69,7 +69,7 @@ void intro_update()
_introStateCounter += 5;
// Check if logo is off the screen...ish
if (_introStateCounter > gScreenHeight - 120) {
if (_introStateCounter > context_get_height() - 120) {
_introStateCounter = -116;
gIntroState++;
}
@@ -85,7 +85,7 @@ void intro_update()
_introStateCounter += 5;
// Check if logo is almost scrolled to the bottom
if (!_chainLiftFinished && _introStateCounter >= gScreenHeight + 40 - 421) {
if (!_chainLiftFinished && _introStateCounter >= context_get_height() + 40 - 421) {
_chainLiftFinished = true;
// Stop the chain lift sound
@@ -99,7 +99,7 @@ void intro_update()
}
// Check if logo is off the screen...ish
if (_introStateCounter >= gScreenHeight + 40) {
if (_introStateCounter >= context_get_height() + 40) {
// Stop the track friction sound
if (_soundChannel != NULL) {
Mixer_Stop_Channel(_soundChannel);
@@ -160,7 +160,7 @@ void intro_update()
void intro_draw(rct_drawpixelinfo *dpi)
{
sint32 screenWidth = gScreenWidth;
sint32 screenWidth = context_get_width();
switch (gIntroState) {
case INTRO_STATE_DISCLAIMER_1:
@@ -258,7 +258,7 @@ static void screen_intro_skip_part()
static void screen_intro_draw_logo(rct_drawpixelinfo *dpi)
{
sint32 screenWidth = gScreenWidth;
sint32 screenWidth = context_get_width();
sint32 imageWidth = 640;
sint32 imageX = (screenWidth - imageWidth) / 2;
+2 -1
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../audio/audio.h"
#include "../Context.h"
#include "../input.h"
#include "../interface/window.h"
#include "../localisation/date.h"
@@ -97,7 +98,7 @@ static void news_item_tick_current()
// Only play news item sound when in normal playing mode
if (ticks == 1 && (gScreenFlags == SCREEN_FLAGS_PLAYING)) {
// Play sound
audio_play_sound_panned(SOUND_NEWS_ITEM, gScreenWidth / 2, 0, 0, 0);
audio_play_sound_panned(SOUND_NEWS_ITEM, context_get_width() / 2, 0, 0, 0);
}
}
+2 -1
View File
@@ -18,6 +18,7 @@
#include "../audio/AudioMixer.h"
#include "../cheats.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../input.h"
#include "../interface/window.h"
@@ -6997,7 +6998,7 @@ void peep_applause()
}
// Play applause noise
audio_play_sound_panned(SOUND_APPLAUSE, gScreenWidth / 2, 0, 0, 0);
audio_play_sound_panned(SOUND_APPLAUSE, context_get_width() / 2, 0, 0, 0);
}
/**
+3 -4
View File
@@ -20,6 +20,7 @@
#include "audio/audio.h"
#include "audio/AudioMixer.h"
#include "config/Config.h"
#include "Context.h"
#include "drawing/drawing.h"
#include "drawing/lightfx.h"
#include "editor.h"
@@ -114,8 +115,6 @@ uint32 gCurrentDrawCount = 0;
uint8 gScreenFlags;
uint32 gScreenAge;
uint8 gSavePromptMode;
sint32 gScreenWidth;
sint32 gScreenHeight;
char gRCT2AddressAppPath[MAX_PATH];
char gRCT2AddressSavedGamesPath[MAX_PATH];
@@ -273,7 +272,7 @@ void rct2_draw(rct_drawpixelinfo *dpi)
console_draw(dpi);
if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gTitleHideVersionInfo) {
DrawOpenRCT2(dpi, 0, gScreenHeight - 20);
DrawOpenRCT2(dpi, 0, context_get_height() - 20);
}
if (gConfigGeneral.show_fps) {
@@ -303,7 +302,7 @@ static void rct2_measure_fps()
static void rct2_draw_fps(rct_drawpixelinfo *dpi)
{
sint32 x = gScreenWidth / 2;
sint32 x = context_get_width() / 2;
sint32 y = 2;
// Measure FPS
-2
View File
@@ -161,8 +161,6 @@ extern uint32 gCurrentDrawCount;
extern uint8 gScreenFlags;
extern uint32 gScreenAge;
extern uint8 gSavePromptMode;
extern sint32 gScreenWidth;
extern sint32 gScreenHeight;
extern char gRCT2AddressAppPath[];
extern char gRCT2AddressSavedGamesPath[];
+3 -2
View File
@@ -19,6 +19,7 @@
#include "../cheats.h"
#include "../common.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../editor.h"
#include "../game.h"
#include "../input.h"
@@ -3448,7 +3449,7 @@ sint32 ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, u
}
sint32 x2 = viewport->x + ((rotatedCoords.x - viewport->view_x) >> viewport->zoom);
x2 *= 0x10000;
uint16 screenwidth = gScreenWidth;
uint16 screenwidth = context_get_width();
if (screenwidth < 64) {
screenwidth = 64;
}
@@ -3456,7 +3457,7 @@ sint32 ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, u
sint32 y2 = viewport->y + ((rotatedCoords.y - viewport->view_y) >> viewport->zoom);
y2 *= 0x10000;
uint16 screenheight = gScreenHeight;
uint16 screenheight = context_get_height();
if (screenheight < 64) {
screenheight = 64;
}
+3 -2
View File
@@ -17,6 +17,7 @@
#include "../audio/audio.h"
#include "../audio/AudioMixer.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../editor.h"
#include "../game.h"
#include "../interface/viewport.h"
@@ -701,7 +702,7 @@ static void vehicle_update_sound_params(rct_vehicle* vehicle)
pan_x >>= g_music_tracking_viewport->zoom;
pan_x += g_music_tracking_viewport->x;
uint16 screenwidth = gScreenWidth;
uint16 screenwidth = context_get_width();
if (screenwidth < 64) {
screenwidth = 64;
}
@@ -711,7 +712,7 @@ static void vehicle_update_sound_params(rct_vehicle* vehicle)
pan_y >>= g_music_tracking_viewport->zoom;
pan_y += g_music_tracking_viewport->y;
uint16 screenheight = gScreenHeight;
uint16 screenheight = context_get_height();
if (screenheight < 64) {
screenheight = 64;
}
+2 -1
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../core/Console.hpp"
#include "../Context.h"
#include "../network/network.h"
#include "../OpenRCT2.h"
#include "../scenario/ScenarioRepository.h"
@@ -161,7 +162,7 @@ extern "C"
window_title_exit_open();
window_title_options_open();
window_title_logo_open();
window_resize_gui(gScreenWidth, gScreenHeight);
window_resize_gui(context_get_width(), context_get_height());
gTitleHideVersionInfo = false;
}
+13 -9
View File
@@ -447,13 +447,13 @@ private:
sint32 z = map_element_height(x, y);
window_set_location(w, x, y, z);
viewport_update_position(w);
}
// Save known tile position in case of window resize
_lastScreenWidth = gScreenWidth;
_lastScreenHeight = gScreenHeight;
_viewCentreLocation.x = x;
_viewCentreLocation.y = y;
// Save known tile position in case of window resize
_lastScreenWidth = w->width;
_lastScreenHeight = w->height;
_viewCentreLocation.x = x;
_viewCentreLocation.y = y;
}
}
/**
@@ -461,10 +461,14 @@ private:
*/
void FixViewLocation()
{
if (gScreenWidth != _lastScreenWidth ||
gScreenHeight != _lastScreenHeight)
rct_window * w = window_get_main();
if (w != nullptr)
{
SetViewLocation(_viewCentreLocation.x, _viewCentreLocation.y);
if (w->width != _lastScreenWidth ||
w->height != _lastScreenHeight)
{
SetViewLocation(_viewCentreLocation.x, _viewCentreLocation.y);
}
}
}
};
+6 -4
View File
@@ -14,6 +14,8 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -107,8 +109,8 @@ rct_window *window_changelog_open()
if (!window_changelog_read_file())
return NULL;
sint32 screenWidth = gScreenWidth;
sint32 screenHeight = gScreenHeight;
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
window = window_create_centred(
screenWidth * 4 / 5,
@@ -144,8 +146,8 @@ static void window_changelog_mouseup(rct_window *w, rct_widgetindex widgetIndex)
static void window_changelog_resize(rct_window *w)
{
sint32 screenWidth = gScreenWidth;
sint32 screenHeight = gScreenHeight;
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
w->max_width = (screenWidth * 4) / 5;
w->max_height = (screenHeight * 4) / 5;
+2 -1
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -104,7 +105,7 @@ void window_clear_scenery_open()
if (window_find_by_class(WC_CLEAR_SCENERY) != NULL)
return;
window = window_create(gScreenWidth - 98, 29, 98, 94, &window_clear_scenery_events, WC_CLEAR_SCENERY, 0);
window = window_create(context_get_width() - 98, 29, 98, 94, &window_clear_scenery_events, WC_CLEAR_SCENERY, 0);
window->widgets = window_clear_scenery_widgets;
window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_INCREMENT) | (1 << WIDX_DECREMENT) | (1 << WIDX_PREVIEW) |
(1 << WIDX_SMALL_SCENERY) | (1 << WIDX_LARGE_SCENERY) | (1 << WIDX_FOOTPATH);
+3 -4
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -81,15 +82,13 @@ static rct_window_event_list window_debug_paint_events = {
void window_debug_paint_open()
{
rct_window * window;
// Check if window is already open
if (window_find_by_class(WC_DEBUG_PAINT) != NULL)
return;
window = window_create(
rct_window * window = window_create(
16,
gScreenHeight - 16 - 33 - WINDOW_HEIGHT,
context_get_height() - 16 - 33 - WINDOW_HEIGHT,
WINDOW_WIDTH,
WINDOW_HEIGHT,
&window_debug_paint_events,
+14 -8
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -176,10 +177,12 @@ void window_dropdown_show_text_custom_width(sint32 x, sint32 y, sint32 extray, u
width = _dropdown_item_width * _dropdown_num_columns + 3;
sint32 height = _dropdown_item_height * _dropdown_num_rows + 3;
if (x + width > gScreenWidth)
x = max(0, gScreenWidth - width);
if (y + height > gScreenHeight)
y = max(0, gScreenHeight - height);
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
if (x + width > screenWidth)
x = max(0, screenWidth - width);
if (y + height > screenHeight)
y = max(0, screenHeight - height);
window_dropdown_widgets[WIDX_BACKGROUND].bottom = (sint16)(_dropdown_item_height * num_items + 3);
window_dropdown_widgets[WIDX_BACKGROUND].right = (sint16)(_dropdown_item_width + 3);
@@ -245,10 +248,13 @@ void window_dropdown_show_image(sint32 x, sint32 y, sint32 extray, uint8 colour,
// Calculate position and size
width = _dropdown_item_width * _dropdown_num_columns + 3;
height = _dropdown_item_height * _dropdown_num_rows + 3;
if (x + width > gScreenWidth)
x = max(0, gScreenWidth - width);
if (y + height > gScreenHeight)
y = max(0, gScreenHeight - height);
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
if (x + width > screenWidth)
x = max(0, screenWidth - width);
if (y + height > screenHeight)
y = max(0, screenHeight - height);
window_dropdown_widgets[WIDX_BACKGROUND].right = width;
window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;
+4 -5
View File
@@ -16,6 +16,7 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../editor.h"
#include "../input.h"
@@ -135,10 +136,8 @@ static void sub_6DFED0();
*/
void window_editor_bottom_toolbar_open()
{
rct_window* window;
window = window_create(0, gScreenHeight - 32,
gScreenWidth, 32,
rct_window * window = window_create(0, context_get_height() - 32,
context_get_width(), 32,
&window_editor_bottom_toolbar_events,
WC_BOTTOM_TOOLBAR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND);
window->widgets = window_editor_bottom_toolbar_widgets;
@@ -371,7 +370,7 @@ void window_editor_bottom_toolbar_invalidate(rct_window *w)
{
colour_scheme_update_by_class(w, (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) ? WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR : WC_EDITOR_TRACK_BOTTOM_TOOLBAR);
uint16 screenWidth = gScreenWidth;
uint16 screenWidth = context_get_width();
window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left = screenWidth - 200;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].right = screenWidth - 1;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_STEP_BUTTON].left = screenWidth - 198;
+3 -2
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -65,8 +66,8 @@ static rct_widget window_editor_main_widgets[] = {
*/
rct_window * window_editor_main_open()
{
window_editor_main_widgets[0].right = gScreenWidth;
window_editor_main_widgets[0].bottom = gScreenHeight;
window_editor_main_widgets[0].right = context_get_width();
window_editor_main_widgets[0].bottom = context_get_height();
rct_window *window = window_create(0, 0, window_editor_main_widgets[0].right, window_editor_main_widgets[0].bottom,
&window_editor_main_events, WC_MAIN_WINDOW, WF_STICK_TO_BACK);
window->widgets = window_editor_main_widgets;
+4 -2
View File
@@ -121,13 +121,15 @@ void window_error_open(rct_string_id title, rct_string_id message)
window_error_widgets[WIDX_BACKGROUND].right = width;
window_error_widgets[WIDX_BACKGROUND].bottom = height;
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
const CursorState * state = context_get_cursor_state();
x = state->x - (width / 2);
x = clamp(0, x, gScreenWidth);
x = clamp(0, x, screenWidth);
y = state->y + 26;
y = max(22, y);
maxY = gScreenHeight - height;
maxY = screenHeight - height;
if (y > maxY) {
y = y - height - 40;
y = min(y, maxY);
+7 -6
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../input.h"
#include "../interface/widget.h"
@@ -127,11 +128,11 @@ static void window_game_bottom_toolbar_invalidate_dirty_widgets(rct_window *w);
*/
void window_game_bottom_toolbar_open()
{
rct_window* window;
window = window_create(
0, gScreenHeight - 32,
gScreenWidth, 32,
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
rct_window * window = window_create(
0, screenHeight - 32,
screenWidth, 32,
&window_game_bottom_toolbar_events,
WC_BOTTOM_TOOLBAR,
WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND
@@ -242,7 +243,7 @@ static void window_game_bottom_toolbar_invalidate(rct_window *w)
NewsItem *newsItem;
// Anchor the middle and right panel to the right
x = gScreenWidth;
x = context_get_width();
w->width = x;
x--;
window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].right = x;
+5 -2
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../audio/audio.h"
#include "../Context.h"
#include "../editor.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -125,8 +126,10 @@ void window_install_track_open(const utf8 *path)
gTrackDesignSceneryToggle = false;
_currentTrackPieceDirection = 2;
sint32 x = gScreenWidth / 2 - 201;
sint32 y = max(28, gScreenHeight / 2 - 200);
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
sint32 x = screenWidth / 2 - 201;
sint32 y = max(28, screenHeight / 2 - 200);
rct_window *w = window_create(x, y, 402, 400, &window_install_track_events, WC_INSTALL_TRACK, 0);
w->widgets = window_install_track_widgets;
+2 -1
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -126,7 +127,7 @@ void window_land_open()
if (window_find_by_class(WC_LAND) != NULL)
return;
window = window_create(gScreenWidth - 98, 29, 98, 160, &window_land_events, WC_LAND, 0);
window = window_create(context_get_width() - 98, 29, 98, 160, &window_land_events, WC_LAND, 0);
window->widgets = window_land_widgets;
window->enabled_widgets =
(1 << WIDX_CLOSE) |
+2 -1
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
@@ -99,7 +100,7 @@ void window_land_rights_open()
if (window_find_by_class(WC_LAND_RIGHTS) != NULL)
return;
window = window_create(gScreenWidth - 98, 29, 98, 94, &window_land_rights_events, WC_LAND_RIGHTS, 0);
window = window_create(context_get_width() - 98, 29, 98, 94, &window_land_rights_events, WC_LAND_RIGHTS, 0);
window->widgets = window_land_rights_widgets;
window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_DECREMENT) | (1 << WIDX_INCREMENT) | (1 << WIDX_PREVIEW) |
(1 << WIDX_BUY_LAND_RIGHTS) | (1 << WIDX_BUY_CONSTRUCTION_RIGHTS);
+4 -5
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -64,11 +65,9 @@ static rct_window_event_list window_main_events = {
*/
void window_main_open()
{
rct_window* window;
window_main_widgets[0].right = gScreenWidth;
window_main_widgets[0].bottom = gScreenHeight;
window = window_create(
window_main_widgets[0].right = context_get_width();
window_main_widgets[0].bottom = context_get_height();
rct_window * window = window_create(
0, 0,
window_main_widgets[0].right, window_main_widgets[0].bottom,
&window_main_events,
+3 -2
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
@@ -1667,8 +1668,8 @@ void window_park_objective_open()
window->hold_down_widgets = window_park_page_hold_down_widgets[WINDOW_PARK_PAGE_OBJECTIVE];
window->event_handlers = &window_park_objective_events;
window_init_scroll_widgets(window);
window->x = gScreenWidth / 2 - 115;
window->y = gScreenHeight / 2 - 87;
window->x = context_get_width() / 2 - 115;
window->y = context_get_height() / 2 - 87;
window_invalidate(window);
}
+2 -2
View File
@@ -424,7 +424,7 @@ void window_scenery_open()
init_scenery();
window = window_create(
gScreenWidth - WINDOW_SCENERY_WIDTH,
context_get_width() - WINDOW_SCENERY_WIDTH,
0x1D,
WINDOW_SCENERY_WIDTH,
WINDOW_SCENERY_HEIGHT,
@@ -748,7 +748,7 @@ static void window_scenery_update(rct_window *w)
}
} else {
sint32 windowHeight = min(463, w->scrolls[0].v_bottom + 62);
if (gScreenHeight < 600)
if (context_get_height() < 600)
windowHeight = min(374, windowHeight);
windowHeight = max(WINDOW_SCENERY_HEIGHT, windowHeight);
+2 -1
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../sprites.h"
#include "../localisation/localisation.h"
@@ -75,7 +76,7 @@ void window_title_exit_open()
rct_window* window;
window = window_create(
gScreenWidth - 40, gScreenHeight - 64,
context_get_width() - 40, context_get_height() - 64,
40, 64,
&window_title_exit_events,
WC_TITLE_EXIT,
+3 -2
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../editor.h"
#include "../game.h"
#include "../input.h"
@@ -88,7 +89,7 @@ void window_title_menu_open()
rct_window* window;
window = window_create(
0, gScreenHeight - 142,
0, context_get_height() - 142,
0, 100,
&window_title_menu_events,
WC_TITLE_MENU,
@@ -120,7 +121,7 @@ void window_title_menu_open()
i++;
}
window->width = x;
window->x = (gScreenWidth - window->width) / 2;
window->x = (context_get_width() - window->width) / 2;
window_init_scroll_widgets(window);
}
+3 -4
View File
@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../intro.h"
#include "../localisation/localisation.h"
@@ -70,10 +71,8 @@ static rct_window_event_list window_title_options_events = {
*/
void window_title_options_open()
{
rct_window* window;
window = window_create(
gScreenWidth - 80, 0,
rct_window * window = window_create(
context_get_width() - 80, 0,
80, 12,
&window_title_options_events,
WC_TITLE_OPTIONS,
+5 -2
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../localisation/localisation.h"
#include "../input.h"
@@ -110,12 +111,14 @@ void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
memcpy(_tooltipText, buffer, sizeof(_tooltipText));
x = clamp(0, x - (width / 2), gScreenWidth - width);
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = clamp(0, x - (width / 2), screenWidth - width);
// TODO The cursor size will be relative to the window DPI.
// The amount to offset the y should be adjusted.
sint32 max_y = gScreenHeight - height;
sint32 max_y = screenHeight - height;
y += 26; // Normally, we'd display the tooltip 26 lower
if (y > max_y)
// If y is too large, the tooltip could be forced below the cursor if we'd just clamped y,
+5 -5
View File
@@ -17,6 +17,7 @@
#include "../audio/audio.h"
#include "../cheats.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../editor.h"
#include "../game.h"
#include "../input.h"
@@ -290,11 +291,9 @@ static uint16 _unkF64F15;
*/
void window_top_toolbar_open()
{
rct_window* window;
window = window_create(
rct_window * window = window_create(
0, 0,
gScreenWidth, 28,
context_get_width(), 28,
&window_top_toolbar_events,
WC_TOP_TOOLBAR,
WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND
@@ -763,8 +762,9 @@ static void window_top_toolbar_invalidate(rct_window *w)
}
// Align right hand side toolbar buttons
sint32 screenWidth = context_get_width();
firstAlignment = 1;
x = max(640, gScreenWidth);
x = max(640, screenWidth);
for (sint32 i = 0; i < countof(right_aligned_widgets_order); ++i) {
widgetIndex = right_aligned_widgets_order[i];
widget = &window_top_toolbar_widgets[widgetIndex];
+5 -2
View File
@@ -16,6 +16,7 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../drawing/IDrawingEngine.h"
#include "../editor.h"
#include "../interface/widget.h"
@@ -121,8 +122,10 @@ void window_track_list_open(ride_list_item item)
sint32 x, y;
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
x = gScreenWidth / 2 - 300;
y = max(28, gScreenHeight / 2 - 200);
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = screenWidth / 2 - 300;
y = max(28, screenHeight / 2 - 200);
} else {
x = 0;
y = 29;
+6 -5
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -252,13 +253,13 @@ static void window_track_manage_paint(rct_window *w, rct_drawpixelinfo *dpi)
*/
static void window_track_delete_prompt_open()
{
rct_window *w;
window_close_by_class(WC_TRACK_DELETE_PROMPT);
w = window_create(
max(28, (gScreenWidth - 250) / 2),
(gScreenHeight - 44) / 2,
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
rct_window *w = window_create(
max(28, (screenWidth - 250) / 2),
(screenHeight - 44) / 2,
250,
74,
&window_track_delete_prompt_events,
+2 -1
View File
@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
@@ -98,7 +99,7 @@ void window_water_open()
return;
window = window_create(
gScreenWidth - 76,
context_get_width() - 76,
29,
76,
77,