From 78cd7407faea0daa23487f0656ac8e63335a18aa Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 31 Aug 2014 15:43:07 +0100 Subject: [PATCH] implement construction button --- src/window_ride.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/window_ride.c b/src/window_ride.c index 1e52e3361c..f31b3613f4 100644 --- a/src/window_ride.c +++ b/src/window_ride.c @@ -21,6 +21,7 @@ #include #include "addresses.h" #include "game.h" +#include "map.h" #include "ride.h" #include "string_ids.h" #include "sprite.h" @@ -426,6 +427,34 @@ static void window_ride_align_tabs(rct_window *w) #pragma region Main +/** + * + * rct2: 0x006B4971 + */ +static void window_ride_construct(rct_window *w) +{ + int rideIndex = w->number; + + window_close_by_id(WC_RIDE_CONSTRUCTION | 0x80, rideIndex); + w = window_find_by_id(WC_RIDE, rideIndex); + if (w == NULL) + return; + + rct_map_element *trackMapElement; + int trackX, trackY; + + trackMapElement = sub_6CAF80(rideIndex, &trackX, &trackY); + if (trackMapElement == (rct_map_element*)-1) { + RCT2_CALLPROC_X(0x006CC3FB, 0, 0, 0, rideIndex, 0, 0, 0); + } else { + trackMapElement = ride_find_track_gap(trackMapElement, &trackX, &trackY); + + w = window_get_main(); + if (w != NULL && ride_try_construct(trackMapElement)) + window_scroll_to_location(w, trackX, trackY, trackMapElement->base_height * 8); + } +} + /** * * rct2: 0x006AF17E @@ -454,6 +483,7 @@ static void window_ride_main_mouseup() window_ride_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_CONSTRUCTION: + window_ride_construct(w); break; case WIDX_RENAME: break;