Replace cursor position globals with gCursorState

This commit is contained in:
Ted John 2016-09-05 22:37:57 +01:00
parent 1c9164d3d3
commit 1e65c7e940
6 changed files with 13 additions and 19 deletions

View File

@ -326,9 +326,6 @@ void platform_process_messages()
}
break;
case SDL_MOUSEMOTION:
RCT2_GLOBAL(0x0142406C, int) = (int)(e.motion.x / gConfigGeneral.window_scale);
RCT2_GLOBAL(0x01424070, int) = (int)(e.motion.y / gConfigGeneral.window_scale);
gCursorState.x = (int)(e.motion.x / gConfigGeneral.window_scale);
gCursorState.y = (int)(e.motion.y / gConfigGeneral.window_scale);
break;
@ -384,9 +381,6 @@ void platform_process_messages()
// Apple sends touchscreen events for trackpads, so ignore these events on macOS
#ifndef __MACOSX__
case SDL_FINGERMOTION:
RCT2_GLOBAL(0x0142406C, int) = (int)(e.tfinger.x * gScreenWidth);
RCT2_GLOBAL(0x01424070, int) = (int)(e.tfinger.y * gScreenHeight);
gCursorState.x = (int)(e.tfinger.x * gScreenWidth);
gCursorState.y = (int)(e.tfinger.y * gScreenHeight);
break;

View File

@ -989,7 +989,7 @@ static void window_editor_object_selection_scroll_mousedown(rct_window *w, int s
window_invalidate(w);
audio_play_sound_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0);
audio_play_sound_panned(SOUND_CLICK_1, gCursorState.x, 0, 0, 0);
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {

View File

@ -119,10 +119,10 @@ 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;
x = RCT2_GLOBAL(0x0142406C, sint32) - (width / 2);
x = gCursorState.x - (width / 2);
x = clamp(0, x, gScreenWidth);
y = RCT2_GLOBAL(0x01424070, sint32) + 26;
y = gCursorState.y + 26;
y = max(22, y);
maxY = gScreenHeight - height;
if (y > maxY) {

View File

@ -75,8 +75,8 @@ void window_map_tooltip_update_visibility()
{
int cursorX, cursorY, inputFlags;
cursorX = RCT2_GLOBAL(0x0142406C, sint32);
cursorY = RCT2_GLOBAL(0x01424070, sint32);
cursorX = gCursorState.x;
cursorY = gCursorState.y;
inputFlags = gInputFlags;
// Check for cursor movement
@ -113,8 +113,8 @@ static void window_map_tooltip_open()
width = 200;
height = 44;
x = RCT2_GLOBAL(0x0142406C, sint32) - (width / 2);
y = RCT2_GLOBAL(0x01424070, sint32) + 15;
x = gCursorState.x - (width / 2);
y = gCursorState.y + 15;
w = window_find_by_class(WC_MAP_TOOLTIP);
if (w == NULL) {

View File

@ -3859,7 +3859,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY)
zAttempts == 0 ||
z < 0
) {
audio_play_sound_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z);
audio_play_sound_panned(SOUND_ERROR, gCursorState.x, x, y, z);
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
if (w != NULL){
tool_set(w, 23, 12);
@ -3931,7 +3931,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY)
_currentTrackCovered = saveCurrentTrackCovered;
_currentTrackLiftHill = saveCurrentTrackLiftHill;
audio_play_sound_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z);
audio_play_sound_panned(SOUND_ERROR, gCursorState.x, x, y, z);
break;
} else if (zAttempts >= 0) {
z += 16;

View File

@ -729,13 +729,13 @@ static void window_scenery_event_07(rct_window *w)
*/
static void window_scenery_update(rct_window *w)
{
rct_window *other = window_find_from_point(RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int));
rct_window *other = window_find_from_point(gCursorState.x, gCursorState.y);
if (other == w) {
int window_x = RCT2_GLOBAL(0x0142406C, int) - w->x + 26;
int window_y = RCT2_GLOBAL(0x01424070, int) - w->y;
int window_x = gCursorState.x - w->x + 26;
int window_y = gCursorState.y - w->y;
if (window_y < 44 || window_x <= w->width) {
int widgetIndex = window_find_widget_from_point(w, RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int));
int widgetIndex = window_find_widget_from_point(w, gCursorState.x, gCursorState.y);
if (widgetIndex >= WIDX_SCENERY_TAB_CONTENT_PANEL) {
w->scenery.hover_counter++;
if (w->scenery.hover_counter < 8) {