2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2014-05-08 22:48:31 +02:00
|
|
|
/*****************************************************************************
|
2016-05-04 19:24:41 +02:00
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
2014-05-08 22:48:31 +02:00
|
|
|
|
2017-10-07 01:28:00 +02:00
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2017-08-02 00:20:32 +02:00
|
|
|
|
2017-10-07 01:28:00 +02:00
|
|
|
#include <openrct2/config/Config.h>
|
2017-12-07 16:12:37 +01:00
|
|
|
#include <openrct2/core/String.hpp>
|
2017-10-07 01:28:00 +02:00
|
|
|
#include <openrct2/network/network.h>
|
|
|
|
#include <openrct2/OpenRCT2.h>
|
|
|
|
#include <openrct2/ride/RideGroupManager.h>
|
|
|
|
#include <openrct2/ride/TrackDesignRepository.h>
|
|
|
|
#include <openrct2/core/Util.hpp>
|
|
|
|
#include <openrct2/core/Math.hpp>
|
|
|
|
#include <openrct2/Context.h>
|
|
|
|
#include <openrct2/audio/audio.h>
|
2017-11-30 18:17:06 +01:00
|
|
|
#include <openrct2/Game.h>
|
2017-10-07 01:28:00 +02:00
|
|
|
#include <openrct2/interface/widget.h>
|
|
|
|
#include <openrct2/localisation/localisation.h>
|
2017-10-11 21:38:26 +02:00
|
|
|
#include <openrct2/management/NewsItem.h>
|
2017-10-07 01:28:00 +02:00
|
|
|
#include <openrct2/rct1.h>
|
|
|
|
#include <openrct2/ride/ride_data.h>
|
2017-10-16 12:02:23 +02:00
|
|
|
#include <openrct2/ride/TrackData.h>
|
2017-10-07 01:28:00 +02:00
|
|
|
#include <openrct2/sprites.h>
|
|
|
|
#include <openrct2/util/util.h>
|
2017-10-21 16:37:30 +02:00
|
|
|
#include <openrct2/windows/Intent.h>
|
2014-05-08 22:48:31 +02:00
|
|
|
|
2017-11-20 14:25:07 +01:00
|
|
|
#define AVAILABILITY_STRING_SIZE 256
|
|
|
|
#define WH 382
|
2017-11-21 18:28:21 +01:00
|
|
|
#define WW 601
|
2017-11-20 14:25:07 +01:00
|
|
|
|
2016-09-06 00:20:08 +02:00
|
|
|
static uint8 _windowNewRideCurrentTab;
|
|
|
|
static ride_list_item _windowNewRideHighlightedItem[6];
|
|
|
|
static ride_list_item _windowNewRideListItems[384];
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2014-08-20 08:50:01 +02:00
|
|
|
#pragma region Ride type view order
|
2014-08-20 01:05:40 +02:00
|
|
|
|
2014-08-20 08:50:01 +02:00
|
|
|
/**
|
|
|
|
* The order of ride types shown in the new ride window so that the order stays consistent across games and rides of the same
|
|
|
|
* type are kept together.
|
|
|
|
*/
|
|
|
|
const char RideTypeViewOrder[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
// Transport rides
|
|
|
|
RIDE_TYPE_MINIATURE_RAILWAY,
|
|
|
|
RIDE_TYPE_MONORAIL,
|
|
|
|
RIDE_TYPE_SUSPENDED_MONORAIL,
|
|
|
|
RIDE_TYPE_CHAIRLIFT,
|
|
|
|
RIDE_TYPE_LIFT,
|
|
|
|
|
|
|
|
// Roller Coasters
|
|
|
|
RIDE_TYPE_SIDE_FRICTION_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_VIRGINIA_REEL,
|
|
|
|
RIDE_TYPE_REVERSER_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_WOODEN_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_WOODEN_WILD_MOUSE,
|
2017-12-08 07:59:44 +01:00
|
|
|
RIDE_TYPE_STEEL_WILD_MOUSE,
|
2017-06-06 23:24:18 +02:00
|
|
|
RIDE_TYPE_INVERTED_HAIRPIN_COASTER,
|
|
|
|
RIDE_TYPE_JUNIOR_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_MINI_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_SPIRAL_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_MINE_TRAIN_COASTER,
|
|
|
|
RIDE_TYPE_LOOPING_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_STAND_UP_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_CORKSCREW_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_TWISTER_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_GIGA_COASTER,
|
|
|
|
RIDE_TYPE_SUSPENDED_SWINGING_COASTER,
|
|
|
|
RIDE_TYPE_COMPACT_INVERTED_COASTER,
|
|
|
|
RIDE_TYPE_INVERTED_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_INVERTED_IMPULSE_COASTER,
|
|
|
|
RIDE_TYPE_MINI_SUSPENDED_COASTER,
|
|
|
|
RIDE_TYPE_STEEPLECHASE,
|
|
|
|
RIDE_TYPE_BOBSLEIGH_COASTER,
|
|
|
|
RIDE_TYPE_MINE_RIDE,
|
|
|
|
RIDE_TYPE_HEARTLINE_TWISTER_COASTER,
|
|
|
|
RIDE_TYPE_LAY_DOWN_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_FLYING_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_MULTI_DIMENSION_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_REVERSE_FREEFALL_COASTER,
|
|
|
|
RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER,
|
|
|
|
RIDE_TYPE_AIR_POWERED_VERTICAL_COASTER,
|
|
|
|
|
|
|
|
// Gentle rides
|
|
|
|
RIDE_TYPE_MONORAIL_CYCLES,
|
|
|
|
RIDE_TYPE_CROOKED_HOUSE,
|
|
|
|
RIDE_TYPE_HAUNTED_HOUSE,
|
|
|
|
RIDE_TYPE_FERRIS_WHEEL,
|
|
|
|
RIDE_TYPE_MAZE,
|
|
|
|
RIDE_TYPE_MERRY_GO_ROUND,
|
|
|
|
RIDE_TYPE_MINI_GOLF,
|
|
|
|
RIDE_TYPE_OBSERVATION_TOWER,
|
|
|
|
RIDE_TYPE_CAR_RIDE,
|
|
|
|
RIDE_TYPE_MINI_HELICOPTERS,
|
|
|
|
RIDE_TYPE_SPIRAL_SLIDE,
|
|
|
|
RIDE_TYPE_DODGEMS,
|
|
|
|
RIDE_TYPE_SPACE_RINGS,
|
2017-12-08 07:59:44 +01:00
|
|
|
RIDE_TYPE_CIRCUS,
|
2017-06-06 23:24:18 +02:00
|
|
|
RIDE_TYPE_GHOST_TRAIN,
|
|
|
|
RIDE_TYPE_FLYING_SAUCERS,
|
|
|
|
|
|
|
|
// Thrill rides
|
|
|
|
RIDE_TYPE_TWIST,
|
|
|
|
RIDE_TYPE_MAGIC_CARPET,
|
|
|
|
RIDE_TYPE_LAUNCHED_FREEFALL,
|
2017-12-08 07:59:44 +01:00
|
|
|
RIDE_TYPE_SWINGING_SHIP,
|
2017-06-06 23:24:18 +02:00
|
|
|
RIDE_TYPE_GO_KARTS,
|
|
|
|
RIDE_TYPE_SWINGING_INVERTER_SHIP,
|
|
|
|
RIDE_TYPE_MOTION_SIMULATOR,
|
|
|
|
RIDE_TYPE_3D_CINEMA,
|
|
|
|
RIDE_TYPE_TOP_SPIN,
|
|
|
|
RIDE_TYPE_ROTO_DROP,
|
|
|
|
RIDE_TYPE_ENTERPRISE,
|
|
|
|
|
|
|
|
// Water rides
|
|
|
|
RIDE_TYPE_DINGHY_SLIDE,
|
|
|
|
RIDE_TYPE_LOG_FLUME,
|
|
|
|
RIDE_TYPE_RIVER_RAPIDS,
|
|
|
|
RIDE_TYPE_SPLASH_BOATS,
|
|
|
|
RIDE_TYPE_SUBMARINE_RIDE,
|
2017-12-05 10:23:36 +01:00
|
|
|
RIDE_TYPE_BOAT_HIRE,
|
2017-06-06 23:24:18 +02:00
|
|
|
RIDE_TYPE_RIVER_RAFTS,
|
|
|
|
RIDE_TYPE_WATER_COASTER,
|
|
|
|
|
|
|
|
// Shops / stalls
|
|
|
|
RIDE_TYPE_FOOD_STALL,
|
|
|
|
RIDE_TYPE_1D,
|
|
|
|
RIDE_TYPE_DRINK_STALL,
|
|
|
|
RIDE_TYPE_1F,
|
|
|
|
RIDE_TYPE_SHOP,
|
|
|
|
RIDE_TYPE_22,
|
|
|
|
RIDE_TYPE_INFORMATION_KIOSK,
|
|
|
|
RIDE_TYPE_FIRST_AID,
|
|
|
|
RIDE_TYPE_CASH_MACHINE,
|
|
|
|
RIDE_TYPE_TOILETS
|
2014-08-20 01:05:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2014-05-08 22:48:31 +02:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
WINDOW_NEW_RIDE_PAGE_TRANSPORT,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_GENTLE,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_ROLLER_COASTER,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_THRILL,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_WATER,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_SHOP,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_RESEARCH,
|
|
|
|
WINDOW_NEW_RIDE_PAGE_COUNT
|
2014-08-19 22:33:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma region Widgets
|
2014-05-08 22:48:31 +02:00
|
|
|
|
2014-08-18 00:57:41 +02:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
|
|
|
WIDX_PAGE_BACKGROUND,
|
|
|
|
WIDX_TAB_1,
|
|
|
|
WIDX_TAB_2,
|
|
|
|
WIDX_TAB_3,
|
|
|
|
WIDX_TAB_4,
|
|
|
|
WIDX_TAB_5,
|
|
|
|
WIDX_TAB_6,
|
|
|
|
WIDX_TAB_7,
|
|
|
|
WIDX_RIDE_LIST,
|
|
|
|
|
|
|
|
WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP,
|
|
|
|
WIDX_LAST_DEVELOPMENT_GROUP,
|
|
|
|
WIDX_LAST_DEVELOPMENT_BUTTON,
|
|
|
|
WIDX_RESEARCH_FUNDING_BUTTON
|
2014-08-19 22:33:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_new_ride_widgets[] = {
|
2017-11-20 14:25:07 +01:00
|
|
|
{ WWT_FRAME, 0, 0, 600, 0, WH - 1, 0xFFFFFFFF, STR_NONE },
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_CAPTION, 0, 1, 599, 1, 14, 0xFFFFFFFF, STR_WINDOW_TITLE_TIP },
|
|
|
|
{ WWT_CLOSEBOX, 0, 588, 598, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
2017-11-20 14:25:07 +01:00
|
|
|
{ WWT_RESIZE, 1, 0, 600, 43, WH - 1, 0xFFFFFFFF, STR_NONE },
|
2017-07-20 20:56:29 +02:00
|
|
|
{ WWT_TAB, 1, 3, 33, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_TRANSPORT_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 34, 64, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_GENTLE_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 65, 95, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_ROLLER_COASTERS_TIP },
|
|
|
|
{ WWT_TAB, 1, 96, 126, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_THRILL_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 127, 157, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_WATER_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 158, 188, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOPS_STALLS_TIP },
|
|
|
|
{ WWT_TAB, 1, 189, 219, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_RESEARCH_AND_DEVELOPMENT_TIP },
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_SCROLL, 1, 3, 597, 46, 317, SCROLL_VERTICAL, STR_NONE },
|
|
|
|
{ WWT_GROUPBOX, 2, 3, 292, 47, 116, STR_CURRENTLY_IN_DEVELOPMENT, STR_NONE },
|
|
|
|
{ WWT_GROUPBOX, 2, 3, 292, 124, 188, STR_LAST_DEVELOPMENT, STR_NONE },
|
|
|
|
{ WWT_FLATBTN, 2, 265, 288, 161, 184, 0xFFFFFFFF, STR_RESEARCH_SHOW_DETAILS_TIP },
|
|
|
|
{ WWT_FLATBTN, 2, 265, 288, 68, 91, SPR_FINANCE, STR_FINANCES_RESEARCH_TIP },
|
|
|
|
{ WIDGETS_END },
|
2014-08-18 00:57:41 +02:00
|
|
|
};
|
|
|
|
|
2014-08-19 22:33:05 +02:00
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Events
|
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_new_ride_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_new_ride_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget *widget);
|
2014-08-19 22:33:05 +02:00
|
|
|
static void window_new_ride_update(rct_window *w);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height);
|
|
|
|
static void window_new_ride_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
|
|
|
|
static void window_new_ride_scrollmouseover(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_new_ride_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_new_ride_invalidate(rct_window *w);
|
|
|
|
static void window_new_ride_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex);
|
2017-11-20 14:25:07 +01:00
|
|
|
static void window_new_ride_list_vehicles_for(const uint8 rideType, const rct_ride_entry * rideEntry, char * out);
|
2014-08-19 22:33:05 +02:00
|
|
|
|
|
|
|
// 0x0098E354
|
2015-07-10 02:39:16 +02:00
|
|
|
static rct_window_event_list window_new_ride_events = {
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_mouseup,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_mousedown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_update,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_scrollgetsize,
|
|
|
|
window_new_ride_scrollmousedown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_scrollmouseover,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_tooltip,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_invalidate,
|
|
|
|
window_new_ride_paint,
|
|
|
|
window_new_ride_scrollpaint
|
2014-08-19 22:33:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2016-07-14 14:07:49 +02:00
|
|
|
static const rct_string_id window_new_ride_titles[WINDOW_NEW_RIDE_PAGE_COUNT] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
STR_NEW_TRANSPORT_RIDES,
|
|
|
|
STR_NEW_GENTLE_RIDES,
|
|
|
|
STR_NEW_ROLLER_COASTERS,
|
|
|
|
STR_NEW_THRILL_RIDES,
|
|
|
|
STR_NEW_WATER_RIDES,
|
|
|
|
STR_NEW_SHOPS_STALLS,
|
|
|
|
STR_RESEARCH_AND_DEVELOPMENT,
|
2016-07-14 14:07:49 +02:00
|
|
|
};
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
const sint32 window_new_ride_tab_animation_loops[] = { 20, 32, 10, 72, 24, 28, 16 };
|
|
|
|
const sint32 window_new_ride_tab_animation_divisor[] = { 4, 8, 2, 4, 4, 4, 2 };
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_set_page(rct_window *w, sint32 page);
|
2014-08-19 22:33:05 +02:00
|
|
|
static void window_new_ride_refresh_widget_sizing(rct_window *w);
|
2017-01-04 22:17:08 +01:00
|
|
|
static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window *w, sint32 x, sint32 y);
|
|
|
|
static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixelinfo *dpi, ride_list_item item, sint32 x, sint32 y, sint32 width);
|
2014-08-20 23:06:47 +02:00
|
|
|
static void window_new_ride_select(rct_window *w);
|
2017-06-14 13:31:27 +02:00
|
|
|
static ride_list_item * window_new_ride_iterate_over_ride_group(uint8 rideType, uint8 rideGroupIndex, ride_list_item * nextListItem);
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2014-08-21 22:48:23 +02:00
|
|
|
static ride_list_item _lastTrackDesignCountRideType;
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 _lastTrackDesignCount;
|
2014-08-21 22:48:23 +02:00
|
|
|
|
2014-05-08 22:48:31 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006ACA58
|
|
|
|
*/
|
2016-09-06 00:20:08 +02:00
|
|
|
void window_new_ride_init_vars()
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// If we are in the track designer, default to the Roller Coaster tab
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) {
|
|
|
|
_windowNewRideCurrentTab = WINDOW_NEW_RIDE_PAGE_ROLLER_COASTER;
|
|
|
|
} else {
|
|
|
|
_windowNewRideCurrentTab = WINDOW_NEW_RIDE_PAGE_TRANSPORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (sint16 i = 0; i < 6; i++) {
|
|
|
|
/*
|
|
|
|
Reset what is highlighted in each tab.
|
|
|
|
Each 16bit number represents the item in its respective tab.
|
|
|
|
*/
|
2017-08-06 02:26:14 +02:00
|
|
|
_windowNewRideHighlightedItem[i] = { 255, 255 };
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-08-18 00:57:41 +02:00
|
|
|
}
|
|
|
|
|
2014-08-20 01:05:40 +02:00
|
|
|
/**
|
2017-06-06 23:24:18 +02:00
|
|
|
* rct2: 0x006B6F3E
|
2014-08-20 01:05:40 +02:00
|
|
|
*
|
2016-02-25 13:33:19 +01:00
|
|
|
* Note: When the user has selection by track type enabled, the categories are determined by the track type, not those in the rct_ride_entry.
|
2014-08-20 01:05:40 +02:00
|
|
|
*/
|
|
|
|
static void window_new_ride_populate_list()
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
uint8 currentCategory = _windowNewRideCurrentTab;
|
|
|
|
ride_list_item *nextListItem = _windowNewRideListItems;
|
|
|
|
|
|
|
|
// For each ride type in the view order list
|
2017-08-03 21:15:39 +02:00
|
|
|
for (sint32 i = 0; i < (sint32)Util::CountOf(RideTypeViewOrder); i++) {
|
2017-06-06 23:24:18 +02:00
|
|
|
uint8 rideType = RideTypeViewOrder[i];
|
|
|
|
if (rideType == RIDE_TYPE_NULL)
|
|
|
|
continue;
|
|
|
|
|
2017-12-07 16:12:37 +01:00
|
|
|
if(gRideCategories[rideType] != currentCategory)
|
|
|
|
continue;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-07-23 12:09:29 +02:00
|
|
|
if (ride_type_is_invented(rideType) || gCheatsIgnoreResearchStatus) {
|
2017-06-17 13:11:16 +02:00
|
|
|
|
2017-10-06 10:29:24 +02:00
|
|
|
if (!RideGroupManager::RideTypeHasRideGroups(rideType)) {
|
2017-06-14 13:31:27 +02:00
|
|
|
nextListItem = window_new_ride_iterate_over_ride_group(rideType, 0, nextListItem);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (uint8 j = 0; j < MAX_RIDE_GROUPS_PER_RIDE_TYPE; j++) {
|
|
|
|
nextListItem = window_new_ride_iterate_over_ride_group(rideType, j, nextListItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-06-17 13:11:16 +02:00
|
|
|
nextListItem->type = RIDE_TYPE_NULL;
|
2017-06-17 14:01:23 +02:00
|
|
|
nextListItem->entry_index = RIDE_ENTRY_INDEX_NULL;
|
2017-06-14 13:31:27 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
static ride_list_item * window_new_ride_iterate_over_ride_group(uint8 rideType, uint8 rideGroupIndex, ride_list_item * nextListItem)
|
|
|
|
{
|
|
|
|
bool buttonForRideTypeCreated = false;
|
|
|
|
bool allowDrawingOverLastButton = false;
|
|
|
|
uint8 *rideEntryIndexPtr = get_ride_entry_indices_for_ride_type(rideType);
|
|
|
|
|
|
|
|
char preferredVehicleName[9];
|
|
|
|
safe_strcpy(preferredVehicleName, " ", sizeof(preferredVehicleName));
|
|
|
|
|
|
|
|
// For each ride entry for this ride type
|
2017-12-07 16:12:37 +01:00
|
|
|
while (*rideEntryIndexPtr != RIDE_ENTRY_INDEX_NULL)
|
|
|
|
{
|
2017-06-14 13:31:27 +02:00
|
|
|
uint8 rideEntryIndex = *rideEntryIndexPtr++;
|
|
|
|
char rideEntryName[9];
|
|
|
|
memcpy(rideEntryName,object_entry_groups[OBJECT_TYPE_RIDE].entries[rideEntryIndex].name,8);
|
|
|
|
rideEntryName[8]=0;
|
|
|
|
|
|
|
|
// Skip if vehicle type is not invented yet
|
2017-07-23 12:09:29 +02:00
|
|
|
if (!ride_entry_is_invented(rideEntryIndex) && !gCheatsIgnoreResearchStatus)
|
2017-06-14 13:31:27 +02:00
|
|
|
continue;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
// Ride entries
|
|
|
|
rct_ride_entry *rideEntry = get_ride_entry(rideEntryIndex);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-10-06 10:29:24 +02:00
|
|
|
if (RideGroupManager::RideTypeHasRideGroups(rideType))
|
2017-06-14 13:31:27 +02:00
|
|
|
{
|
2017-10-06 10:29:24 +02:00
|
|
|
const RideGroup * rideEntryRideGroup = RideGroupManager::GetRideGroup(rideType, rideEntry);
|
|
|
|
const RideGroup * rideGroup = RideGroupManager::RideGroupFind(rideType, rideGroupIndex);
|
2017-06-17 13:41:40 +02:00
|
|
|
|
2017-10-06 10:29:24 +02:00
|
|
|
if (!RideGroupManager::RideGroupsAreEqual(rideEntryRideGroup, rideGroup))
|
2017-06-14 13:31:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
2017-06-17 13:11:16 +02:00
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
// Skip if the vehicle isn't the preferred vehicle for this generic track type
|
2017-12-07 16:12:37 +01:00
|
|
|
if (!RideGroupManager::RideTypeIsIndependent(rideType))
|
2017-11-20 14:25:07 +01:00
|
|
|
{
|
2017-06-14 13:31:27 +02:00
|
|
|
if (strcmp(preferredVehicleName, " \0") == 0) {
|
|
|
|
safe_strcpy(preferredVehicleName, rideEntryName, sizeof(preferredVehicleName));
|
|
|
|
preferredVehicleName[8] = 0;
|
|
|
|
} else {
|
2017-10-06 10:29:24 +02:00
|
|
|
if (RideGroupManager::VehiclePreferenceCompare(rideType, preferredVehicleName, rideEntryName) == 1) {
|
2017-06-14 13:31:27 +02:00
|
|
|
safe_strcpy(preferredVehicleName, rideEntryName, sizeof(preferredVehicleName));
|
|
|
|
preferredVehicleName[8] = 0;
|
|
|
|
} else {
|
|
|
|
continue;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-14 13:31:27 +02:00
|
|
|
|
|
|
|
// Determines how and where to draw a button for this ride type/vehicle.
|
2017-12-07 16:12:37 +01:00
|
|
|
if (RideGroupManager::RideTypeIsIndependent(rideType))
|
|
|
|
{
|
|
|
|
// Separate, draw apart
|
2017-06-14 13:31:27 +02:00
|
|
|
allowDrawingOverLastButton = false;
|
|
|
|
nextListItem->type = rideType;
|
|
|
|
nextListItem->entry_index = rideEntryIndex;
|
|
|
|
nextListItem++;
|
2017-12-07 16:12:37 +01:00
|
|
|
}
|
|
|
|
else if (!buttonForRideTypeCreated)
|
|
|
|
{
|
|
|
|
// Non-separate, draw-apart
|
2017-06-14 13:31:27 +02:00
|
|
|
buttonForRideTypeCreated = true;
|
|
|
|
allowDrawingOverLastButton = true;
|
|
|
|
nextListItem->type = rideType;
|
|
|
|
nextListItem->entry_index = rideEntryIndex;
|
|
|
|
nextListItem++;
|
2017-12-07 16:12:37 +01:00
|
|
|
}
|
|
|
|
else if (allowDrawingOverLastButton)
|
|
|
|
{
|
|
|
|
// Non-separate, draw over previous
|
|
|
|
if (rideType == rideEntry->ride_type[0])
|
|
|
|
{
|
2017-06-14 13:31:27 +02:00
|
|
|
nextListItem--;
|
|
|
|
nextListItem->type = rideType;
|
|
|
|
nextListItem->entry_index = rideEntryIndex;
|
|
|
|
nextListItem++;
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
return nextListItem;
|
2014-08-20 01:05:40 +02:00
|
|
|
}
|
|
|
|
|
2014-08-20 21:18:17 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B7220
|
|
|
|
*/
|
|
|
|
static void window_new_ride_scroll_to_focused_ride(rct_window *w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 scrollWidth = 0;
|
|
|
|
sint32 scrollHeight = 0;
|
|
|
|
window_get_scroll_size(w, 0, &scrollWidth, &scrollHeight);
|
|
|
|
|
|
|
|
// Find row index of the focused ride type
|
|
|
|
rct_widget *listWidget = &window_new_ride_widgets[WIDX_RIDE_LIST];
|
2017-08-02 00:20:32 +02:00
|
|
|
assert(_windowNewRideCurrentTab < Util::CountOf(_windowNewRideHighlightedItem));
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry;
|
|
|
|
sint32 count = 0, row = 0;
|
|
|
|
ride_list_item *listItem = _windowNewRideListItems;
|
2017-06-14 15:08:56 +02:00
|
|
|
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != 255) {
|
2017-06-06 23:24:18 +02:00
|
|
|
if (listItem->type == focusRideType) {
|
|
|
|
row = count / 5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
count++;
|
|
|
|
listItem++;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Update the Y scroll position
|
|
|
|
sint32 listWidgetHeight = listWidget->bottom - listWidget->top - 1;
|
2017-08-02 00:20:32 +02:00
|
|
|
scrollHeight = Math::Max(0, scrollHeight - listWidgetHeight);
|
|
|
|
w->scrolls[0].v_top = Math::Min(row * 116, scrollHeight);
|
2017-06-06 23:24:18 +02:00
|
|
|
widget_scroll_update_thumbs(w, WIDX_RIDE_LIST);
|
2014-08-20 21:18:17 +02:00
|
|
|
}
|
|
|
|
|
2014-08-18 00:57:41 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B3CFF
|
|
|
|
*/
|
2015-03-31 03:21:30 +02:00
|
|
|
rct_window *window_new_ride_open()
|
2014-08-18 00:57:41 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window *w;
|
|
|
|
|
|
|
|
w = window_bring_to_front_by_class(WC_CONSTRUCT_RIDE);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (w != nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return w;
|
|
|
|
|
|
|
|
// Not sure what these windows are
|
|
|
|
window_close_by_class(WC_TRACK_DESIGN_LIST);
|
|
|
|
window_close_by_class(WC_TRACK_DESIGN_PLACE);
|
|
|
|
|
2017-11-21 18:28:21 +01:00
|
|
|
w = window_create_auto_pos(WW, WH, &window_new_ride_events, WC_CONSTRUCT_RIDE, WF_10);
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets = window_new_ride_widgets;
|
|
|
|
w->enabled_widgets =
|
|
|
|
(1 << WIDX_CLOSE) |
|
|
|
|
(1 << WIDX_TAB_1) |
|
|
|
|
(1 << WIDX_TAB_2) |
|
|
|
|
(1 << WIDX_TAB_3) |
|
|
|
|
(1 << WIDX_TAB_4) |
|
|
|
|
(1 << WIDX_TAB_5) |
|
|
|
|
(1 << WIDX_TAB_6) |
|
|
|
|
(1 << WIDX_TAB_7) |
|
|
|
|
(1 << WIDX_LAST_DEVELOPMENT_BUTTON) |
|
|
|
|
(1 << WIDX_RESEARCH_FUNDING_BUTTON);
|
|
|
|
window_new_ride_populate_list();
|
|
|
|
window_init_scroll_widgets(w);
|
|
|
|
|
|
|
|
w->frame_no = 0;
|
|
|
|
w->new_ride.selected_ride_id = -1;
|
2017-06-17 13:11:16 +02:00
|
|
|
_lastTrackDesignCountRideType.type = RIDE_TYPE_NULL;
|
2017-06-17 14:01:23 +02:00
|
|
|
_lastTrackDesignCountRideType.entry_index = RIDE_ENTRY_INDEX_NULL;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->new_ride.highlighted_ride_id = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry;
|
|
|
|
if (w->new_ride.highlighted_ride_id == -1)
|
|
|
|
w->new_ride.highlighted_ride_id = _windowNewRideListItems[0].ride_type_and_entry;
|
|
|
|
|
|
|
|
w->width = 1;
|
|
|
|
window_new_ride_refresh_widget_sizing(w);
|
|
|
|
|
|
|
|
if (_windowNewRideCurrentTab != WINDOW_NEW_RIDE_PAGE_RESEARCH) {
|
|
|
|
window_new_ride_scroll_to_focused_ride(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
return w;
|
2015-03-31 03:21:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rct_window *window_new_ride_open_research()
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window *w;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w = window_new_ride_open();
|
|
|
|
window_new_ride_set_page(w, WINDOW_NEW_RIDE_PAGE_RESEARCH);
|
|
|
|
return w;
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:11:50 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B3EBA
|
|
|
|
*/
|
|
|
|
void window_new_ride_focus(ride_list_item rideItem)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window *w;
|
2017-06-14 13:31:27 +02:00
|
|
|
rct_ride_entry *rideEntry;
|
|
|
|
bool entryFound = false;
|
|
|
|
// Find the first non-null ride type index.
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
w = window_find_by_class(WC_CONSTRUCT_RIDE);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (w == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
rideEntry = get_ride_entry(rideItem.entry_index);
|
|
|
|
uint8 rideTypeIndex = ride_entry_get_first_non_null_ride_type(rideEntry);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
window_new_ride_set_page(w, gRideCategories[rideTypeIndex]);
|
2017-12-07 16:12:37 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
for (ride_list_item *listItem = _windowNewRideListItems; listItem->type != RIDE_TYPE_NULL; listItem++) {
|
2017-06-06 23:24:18 +02:00
|
|
|
if (listItem->type == rideItem.type && listItem->entry_index == rideItem.entry_index) {
|
|
|
|
_windowNewRideHighlightedItem[0] = rideItem;
|
|
|
|
w->new_ride.highlighted_ride_id = rideItem.ride_type_and_entry;
|
|
|
|
window_new_ride_scroll_to_focused_ride(w);
|
2017-06-14 13:31:27 +02:00
|
|
|
entryFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this entry was not found it was most likely hidden due to it not being the preferential type.
|
|
|
|
// In this case, select the first entry that belongs to the same ride group.
|
2017-12-07 16:12:37 +01:00
|
|
|
if (!entryFound)
|
2017-06-14 13:31:27 +02:00
|
|
|
{
|
2017-10-06 10:29:24 +02:00
|
|
|
const RideGroup * rideGroup = RideGroupManager::GetRideGroup(rideTypeIndex, rideEntry);
|
2017-06-14 13:31:27 +02:00
|
|
|
|
|
|
|
for (ride_list_item *listItem = _windowNewRideListItems; listItem->type != RIDE_TYPE_NULL; listItem++) {
|
|
|
|
if (listItem->type == rideItem.type) {
|
2017-10-06 10:29:24 +02:00
|
|
|
const RideGroup * irg = RideGroupManager::GetRideGroup(rideTypeIndex, rideEntry);
|
2017-06-14 13:31:27 +02:00
|
|
|
|
2017-10-06 10:29:24 +02:00
|
|
|
if (!RideGroupManager::RideTypeHasRideGroups(rideTypeIndex) || RideGroupManager::RideGroupsAreEqual(rideGroup, irg)) {
|
2017-06-14 13:31:27 +02:00
|
|
|
_windowNewRideHighlightedItem[0] = rideItem;
|
|
|
|
w->new_ride.highlighted_ride_id = rideItem.ride_type_and_entry;
|
|
|
|
window_new_ride_scroll_to_focused_ride(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-08 23:11:50 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_set_page(rct_window *w, sint32 page)
|
2014-10-08 23:11:50 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
_windowNewRideCurrentTab = page;
|
|
|
|
w->frame_no = 0;
|
|
|
|
w->new_ride.highlighted_ride_id = -1;
|
|
|
|
w->new_ride.selected_ride_countdown = -1;
|
|
|
|
window_new_ride_populate_list();
|
|
|
|
if (page < WINDOW_NEW_RIDE_PAGE_RESEARCH) {
|
|
|
|
w->new_ride.highlighted_ride_id = _windowNewRideHighlightedItem[page].ride_type_and_entry;
|
|
|
|
if (w->new_ride.highlighted_ride_id == -1)
|
|
|
|
w->new_ride.highlighted_ride_id = _windowNewRideListItems[0].ride_type_and_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
window_new_ride_refresh_widget_sizing(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
|
|
|
|
if (page < WINDOW_NEW_RIDE_PAGE_RESEARCH) {
|
|
|
|
window_new_ride_scroll_to_focused_ride(w);
|
|
|
|
}
|
2014-10-08 23:11:50 +02:00
|
|
|
}
|
|
|
|
|
2014-08-19 22:33:05 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B3DF1
|
|
|
|
*/
|
|
|
|
static void window_new_ride_refresh_widget_sizing(rct_window *w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 width, height;
|
|
|
|
|
|
|
|
// Show or hide unrelated widgets
|
|
|
|
if (_windowNewRideCurrentTab != WINDOW_NEW_RIDE_PAGE_RESEARCH) {
|
|
|
|
window_new_ride_widgets[WIDX_RIDE_LIST].type = WWT_SCROLL;
|
|
|
|
window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].type = WWT_EMPTY;
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].type = WWT_EMPTY;
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_EMPTY;
|
|
|
|
window_new_ride_widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WWT_EMPTY;
|
|
|
|
|
|
|
|
width = 601;
|
2017-11-20 14:25:07 +01:00
|
|
|
height = WH;
|
2017-06-06 23:24:18 +02:00
|
|
|
} else {
|
|
|
|
window_new_ride_widgets[WIDX_RIDE_LIST].type = WWT_EMPTY;
|
|
|
|
window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
|
|
|
|
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
|
|
|
window_new_ride_widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WWT_FLATBTN;
|
|
|
|
|
|
|
|
width = 300;
|
|
|
|
height = 196;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle new window size
|
|
|
|
if (w->width != width || w->height != height) {
|
|
|
|
window_invalidate(w);
|
|
|
|
|
|
|
|
// Resize widgets to new window size
|
|
|
|
window_new_ride_widgets[WIDX_BACKGROUND].right = width - 1;
|
|
|
|
window_new_ride_widgets[WIDX_BACKGROUND].bottom = height - 1;
|
|
|
|
window_new_ride_widgets[WIDX_PAGE_BACKGROUND].right = width - 1;
|
|
|
|
window_new_ride_widgets[WIDX_PAGE_BACKGROUND].bottom = height - 1;
|
|
|
|
window_new_ride_widgets[WIDX_TITLE].right = width - 2;
|
|
|
|
window_new_ride_widgets[WIDX_CLOSE].left = width - 13;
|
|
|
|
window_new_ride_widgets[WIDX_CLOSE].right = width - 3;
|
|
|
|
|
|
|
|
w->width = width;
|
|
|
|
w->height = height;
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
window_init_scroll_widgets(w);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void window_new_ride_set_pressed_tab(rct_window *w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 i;
|
|
|
|
for (i = 0; i < WINDOW_NEW_RIDE_PAGE_COUNT; i++)
|
|
|
|
w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i));
|
|
|
|
w->pressed_widgets |= 1LL << (WIDX_TAB_1 + _windowNewRideCurrentTab);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
const sint32 ThrillRidesTabAnimationSequence[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
5, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0
|
2014-08-19 22:33:05 +02:00
|
|
|
};
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_draw_tab_image(rct_drawpixelinfo *dpi, rct_window *w, sint32 page, sint32 spriteIndex)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_widgetindex widgetIndex = WIDX_TAB_1 + page;
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->widgets[widgetIndex].type != WWT_EMPTY && !(w->disabled_widgets & (1LL << widgetIndex))) {
|
|
|
|
sint32 frame = 0;
|
|
|
|
if (_windowNewRideCurrentTab == page)
|
|
|
|
frame = w->frame_no / window_new_ride_tab_animation_divisor[page];
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
spriteIndex += page == WINDOW_NEW_RIDE_PAGE_THRILL ?
|
|
|
|
ThrillRidesTabAnimationSequence[frame] : frame;
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
spriteIndex |= w->colours[1] << 19;
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_draw_sprite(dpi, spriteIndex, w->x + w->widgets[widgetIndex].left, w->y + w->widgets[widgetIndex].top, 0);
|
|
|
|
}
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void window_new_ride_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w)
|
|
|
|
{
|
2017-07-20 20:56:29 +02:00
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_TRANSPORT, IMAGE_TYPE_REMAP | SPR_TAB_RIDES_TRANSPORT_0);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_GENTLE, SPR_TAB_RIDES_GENTLE_0);
|
2017-07-20 20:56:29 +02:00
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_ROLLER_COASTER, IMAGE_TYPE_REMAP | SPR_TAB_RIDES_ROLLER_COASTERS_0);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_THRILL, SPR_TAB_RIDES_THRILL_0);
|
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_WATER, SPR_TAB_RIDES_WATER_0);
|
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_SHOP, SPR_TAB_RIDES_SHOP_0);
|
|
|
|
window_new_ride_draw_tab_image(dpi, w, WINDOW_NEW_RIDE_PAGE_RESEARCH, SPR_TAB_FINANCES_RESEARCH_0);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6B38
|
|
|
|
*/
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_new_ride_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_LAST_DEVELOPMENT_BUTTON:
|
|
|
|
news_item_open_subject(NEWS_ITEM_RESEARCH, (sint32)gResearchLastItemSubject);
|
|
|
|
break;
|
|
|
|
case WIDX_RESEARCH_FUNDING_BUTTON:
|
2017-09-05 20:55:18 +02:00
|
|
|
context_open_window_view(WV_FINANCES_RESEARCH);
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6B4F
|
|
|
|
*/
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_new_ride_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget *widget)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (widgetIndex >= WIDX_TAB_1 && widgetIndex <= WIDX_TAB_7)
|
|
|
|
window_new_ride_set_page(w, widgetIndex - WIDX_TAB_1);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6CE7
|
|
|
|
*/
|
|
|
|
static void window_new_ride_update(rct_window *w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
|
|
|
if (w->frame_no >= window_new_ride_tab_animation_loops[_windowNewRideCurrentTab])
|
|
|
|
w->frame_no = 0;
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
widget_invalidate(w, WIDX_TAB_1 + _windowNewRideCurrentTab);
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->new_ride.selected_ride_id != -1 && w->new_ride.selected_ride_countdown-- == 0)
|
|
|
|
window_new_ride_select(w);
|
2016-01-23 15:01:17 +01:00
|
|
|
|
2017-12-07 16:12:37 +01:00
|
|
|
window_new_ride_populate_list();
|
|
|
|
//widget_invalidate(w, WIDX_RIDE_LIST);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6BC9
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
ride_list_item *listItem = _windowNewRideListItems;
|
|
|
|
|
|
|
|
sint32 count = 0;
|
2017-06-14 15:08:56 +02:00
|
|
|
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != 255) {
|
2017-06-06 23:24:18 +02:00
|
|
|
count++;
|
|
|
|
listItem++;
|
|
|
|
}
|
|
|
|
*height = ((count + 4) / 5) * 116;
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6C89
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
ride_list_item item;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
item = window_new_ride_scroll_get_ride_list_item_at(w, x, y);
|
2017-06-14 15:08:56 +02:00
|
|
|
if (item.type == RIDE_TYPE_NULL && item.entry_index == 255)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
_windowNewRideHighlightedItem[_windowNewRideCurrentTab] = item;
|
|
|
|
w->new_ride.selected_ride_id = item.ride_type_and_entry;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2));
|
|
|
|
w->new_ride.selected_ride_countdown = 8;
|
|
|
|
window_invalidate(w);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2014-08-20 23:06:47 +02:00
|
|
|
* rct2: 0x006B6C51
|
2014-08-19 22:33:05 +02:00
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_scrollmouseover(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
ride_list_item item;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->new_ride.selected_ride_id != -1)
|
|
|
|
return;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
item = window_new_ride_scroll_get_ride_list_item_at(w, x, y);
|
2014-08-23 14:27:54 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->new_ride.highlighted_ride_id == item.ride_type_and_entry)
|
|
|
|
return;
|
2014-08-19 22:33:05 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->new_ride.highlighted_ride_id = item.ride_type_and_entry;
|
|
|
|
_windowNewRideHighlightedItem[_windowNewRideCurrentTab] = item;
|
|
|
|
window_invalidate(w);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6BBF
|
|
|
|
*/
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_new_ride_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
set_format_arg(0, rct_string_id, STR_LIST);
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6819
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_new_ride_invalidate(rct_window *w)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_new_ride_set_pressed_tab(w);
|
|
|
|
|
|
|
|
window_new_ride_widgets[WIDX_TITLE].text = window_new_ride_titles[_windowNewRideCurrentTab];
|
|
|
|
window_new_ride_widgets[WIDX_TAB_7].type = WWT_TAB;
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
|
|
|
window_new_ride_widgets[WIDX_TAB_7].type = WWT_EMPTY;
|
|
|
|
|
|
|
|
if (_windowNewRideCurrentTab == WINDOW_NEW_RIDE_PAGE_RESEARCH) {
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_EMPTY;
|
|
|
|
uint32 typeId = gResearchLastItemSubject;
|
|
|
|
if (typeId != 0xFFFFFFFF) {
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
|
|
|
|
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].image = typeId >= 0x10000 ? SPR_NEW_RIDE : SPR_NEW_SCENERY;
|
|
|
|
}
|
|
|
|
}
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B689B
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_new_ride_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_draw_widgets(w, dpi);
|
|
|
|
window_new_ride_draw_tab_images(dpi, w);
|
|
|
|
|
|
|
|
if (_windowNewRideCurrentTab != WINDOW_NEW_RIDE_PAGE_RESEARCH) {
|
2017-08-03 21:15:39 +02:00
|
|
|
ride_list_item item;
|
|
|
|
item.ride_type_and_entry = static_cast<uint16>(w->new_ride.highlighted_ride_id);
|
2017-06-14 15:08:56 +02:00
|
|
|
if (item.type != RIDE_TYPE_NULL || item.entry_index != 255)
|
2017-11-20 14:25:07 +01:00
|
|
|
window_new_ride_paint_ride_information(w, dpi, item, w->x + 3, w->y + w->height - 64, w->width - 6);
|
2017-06-06 23:24:18 +02:00
|
|
|
} else {
|
|
|
|
window_research_development_page_paint(w, dpi, WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP);
|
|
|
|
}
|
2014-08-19 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6ABF
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
|
2014-08-19 22:33:05 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (_windowNewRideCurrentTab == WINDOW_NEW_RIDE_PAGE_RESEARCH)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gfx_clear(dpi, ColourMapA[w->colours[1]].mid_light);
|
|
|
|
|
|
|
|
sint32 x = 1;
|
|
|
|
sint32 y = 1;
|
|
|
|
ride_list_item *listItem = _windowNewRideListItems;
|
2017-06-14 15:08:56 +02:00
|
|
|
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != 255) {
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_ride_entry *rideEntry;
|
|
|
|
// Draw flat button rectangle
|
|
|
|
sint32 flags = 0;
|
|
|
|
if (w->new_ride.selected_ride_id == *((sint16*)listItem))
|
|
|
|
flags |= INSET_RECT_FLAG_BORDER_INSET;
|
|
|
|
if (w->new_ride.highlighted_ride_id == *((sint16*)listItem) || flags != 0)
|
|
|
|
gfx_fill_rect_inset(dpi, x, y, x + 115, y + 115, w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT | flags);
|
|
|
|
|
|
|
|
// Draw ride image with feathered border
|
|
|
|
rideEntry = get_ride_entry(listItem->entry_index);
|
2017-12-04 14:04:32 +01:00
|
|
|
sint32 imageId = rideEntry->images_offset;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
|
|
|
{
|
|
|
|
if (rideEntry->ride_type[i] == listItem->type)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
imageId++;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2017-12-04 14:04:32 +01:00
|
|
|
|
|
|
|
gfx_draw_sprite_raw_masked(dpi, x + 2, y + 2, SPR_NEW_RIDE_MASK, imageId);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Next position
|
|
|
|
x += 116;
|
|
|
|
if (x >= 116 * 5 + 1) {
|
|
|
|
x = 1;
|
|
|
|
y += 116;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next item
|
|
|
|
listItem++;
|
|
|
|
}
|
2014-08-20 23:06:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6D3C
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window *w, sint32 x, sint32 y)
|
2014-08-20 23:06:47 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
ride_list_item result;
|
2017-06-17 13:11:16 +02:00
|
|
|
result.type = RIDE_TYPE_NULL;
|
2017-06-17 14:01:23 +02:00
|
|
|
result.entry_index = RIDE_ENTRY_INDEX_NULL;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (--x < 0 || --y < 0)
|
|
|
|
return result;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 column = x / 116;
|
|
|
|
sint32 row = y / 116;
|
|
|
|
if (column >= 5)
|
|
|
|
return result;
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 index = column + (row * 5);
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
ride_list_item *listItem = _windowNewRideListItems;
|
2017-06-14 15:08:56 +02:00
|
|
|
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != 255) {
|
2017-06-06 23:24:18 +02:00
|
|
|
if (index-- == 0)
|
|
|
|
return *listItem;
|
|
|
|
listItem++;
|
|
|
|
}
|
2014-08-20 23:06:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
return result;
|
2014-08-20 23:06:47 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 get_num_track_designs(ride_list_item item)
|
2014-08-21 22:48:23 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
char entry[9];
|
2017-12-07 16:12:37 +01:00
|
|
|
const char * entryPtr = nullptr;
|
2017-08-15 10:07:44 +02:00
|
|
|
rct_ride_entry * rideEntry = nullptr;
|
2017-06-14 13:31:27 +02:00
|
|
|
|
2017-12-07 16:12:37 +01:00
|
|
|
if (item.type < 0x80)
|
|
|
|
{
|
2017-06-14 13:31:27 +02:00
|
|
|
rideEntry = get_ride_entry(item.entry_index);
|
2017-12-07 16:12:37 +01:00
|
|
|
if (RideGroupManager::RideTypeIsIndependent(item.type))
|
2017-11-20 14:25:07 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
get_ride_entry_name(entry, item.entry_index);
|
|
|
|
entryPtr = entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:29:24 +02:00
|
|
|
if (rideEntry != nullptr && RideGroupManager::RideTypeHasRideGroups(item.type))
|
2017-06-14 13:31:27 +02:00
|
|
|
{
|
2017-10-06 10:29:24 +02:00
|
|
|
const RideGroup * rideGroup = RideGroupManager::GetRideGroup(item.type, rideEntry);
|
2017-12-07 16:12:37 +01:00
|
|
|
ITrackDesignRepository * repo = GetTrackDesignRepository();
|
|
|
|
return (sint32)repo->GetCountForRideGroup(item.type, rideGroup);
|
2017-06-14 13:31:27 +02:00
|
|
|
}
|
|
|
|
|
2017-12-07 16:12:37 +01:00
|
|
|
ITrackDesignRepository * repo = GetTrackDesignRepository();
|
|
|
|
return (sint32)repo->GetCountForObjectEntry(item.type, String::ToStd(entryPtr));
|
2014-08-21 22:48:23 +02:00
|
|
|
}
|
|
|
|
|
2014-08-20 23:06:47 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B701C
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixelinfo *dpi, ride_list_item item, sint32 x, sint32 y, sint32 width)
|
2014-08-20 23:06:47 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_ride_entry *rideEntry = get_ride_entry(item.entry_index);
|
2017-06-14 13:31:27 +02:00
|
|
|
rct_ride_name rideNaming;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Ride name and description
|
2017-09-19 12:18:17 +02:00
|
|
|
rideNaming = get_ride_naming(item.type, rideEntry);
|
2017-06-14 13:31:27 +02:00
|
|
|
set_format_arg(0, rct_string_id, rideNaming.name);
|
|
|
|
set_format_arg(2, rct_string_id, rideNaming.description);
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, width, STR_NEW_RIDE_NAME_AND_DESCRIPTION, COLOUR_BLACK);
|
|
|
|
|
|
|
|
// Number of designs available
|
2017-11-20 14:25:07 +01:00
|
|
|
if (ride_type_has_flag(item.type, RIDE_TYPE_FLAG_HAS_TRACK))
|
|
|
|
{
|
|
|
|
char availabilityString[AVAILABILITY_STRING_SIZE];
|
|
|
|
window_new_ride_list_vehicles_for(item.type, rideEntry, availabilityString);
|
|
|
|
|
|
|
|
if (availabilityString[0] != 0)
|
|
|
|
{
|
|
|
|
const char * drawString = _strdup(availabilityString);
|
2017-11-21 18:28:21 +01:00
|
|
|
gfx_draw_string_left_clipped(dpi, STR_AVAILABLE_VEHICLES, (void*)&drawString, COLOUR_BLACK, x, y + 39, WW - 2);
|
2017-11-20 14:25:07 +01:00
|
|
|
}
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Track designs are disabled in multiplayer, so don't say there are any designs available when in multiplayer
|
|
|
|
if (network_get_mode() != NETWORK_MODE_NONE) {
|
|
|
|
_lastTrackDesignCount = 0;
|
|
|
|
}
|
|
|
|
else if (item.type != _lastTrackDesignCountRideType.type || item.entry_index != _lastTrackDesignCountRideType.entry_index) {
|
|
|
|
_lastTrackDesignCountRideType = item;
|
|
|
|
_lastTrackDesignCount = get_num_track_designs(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_string_id stringId;
|
|
|
|
switch (_lastTrackDesignCount) {
|
|
|
|
case 0:
|
|
|
|
stringId = STR_CUSTOM_DESIGNED_LAYOUT;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
stringId = STR_1_DESIGN_AVAILABLE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stringId = STR_X_DESIGNS_AVAILABLE;
|
|
|
|
break;
|
|
|
|
}
|
2017-11-20 14:25:07 +01:00
|
|
|
|
|
|
|
gfx_draw_string_left(dpi, stringId, &_lastTrackDesignCount, COLOUR_BLACK, x, y + 51);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Price
|
|
|
|
if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) {
|
|
|
|
// Get price of ride
|
|
|
|
sint32 unk2 = RideConstructionDefaultTrackType[item.type];
|
|
|
|
money32 price = RideTrackCosts[item.type].track_price;
|
|
|
|
if (ride_type_has_flag(item.type, RIDE_TYPE_FLAG_FLAT_RIDE)) {
|
|
|
|
price *= FlatRideTrackPricing[unk2];
|
|
|
|
} else {
|
|
|
|
price *= TrackPricing[unk2];
|
|
|
|
}
|
|
|
|
price = (price >> 17) * 10 * RideData5[item.type].price;
|
|
|
|
|
|
|
|
//
|
|
|
|
rct_string_id stringId = STR_NEW_RIDE_COST;
|
|
|
|
if (!ride_type_has_flag(item.type, RIDE_TYPE_FLAG_HAS_NO_TRACK))
|
|
|
|
stringId = STR_NEW_RIDE_COST_FROM;
|
|
|
|
|
2017-11-20 14:25:07 +01:00
|
|
|
gfx_draw_string_right(dpi, stringId, &price, COLOUR_BLACK, x + width, y + 51);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-08-20 23:06:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B6B78
|
|
|
|
*/
|
|
|
|
static void window_new_ride_select(rct_window *w)
|
|
|
|
{
|
2017-08-03 21:15:39 +02:00
|
|
|
ride_list_item item;
|
|
|
|
item.ride_type_and_entry = static_cast<uint16>(w->new_ride.selected_ride_id);
|
2017-06-14 15:08:56 +02:00
|
|
|
if (item.type == RIDE_TYPE_NULL)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-08-21 23:50:06 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
window_close(w);
|
|
|
|
window_close_construction_windows();
|
2014-08-21 23:50:06 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
bool allowTrackDesigns = true;
|
2015-12-24 02:35:14 +01:00
|
|
|
#ifndef NETWORK_DISABLE
|
2017-06-06 23:24:18 +02:00
|
|
|
// TODO: FIX NETWORK TRACKS
|
|
|
|
// Until tracks work with the network this will disable them
|
|
|
|
if (network_get_mode() != NETWORK_MODE_NONE) {
|
|
|
|
allowTrackDesigns = false;
|
|
|
|
}
|
2015-12-24 02:35:14 +01:00
|
|
|
#endif
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (allowTrackDesigns && ride_type_has_flag(item.type, RIDE_TYPE_FLAG_HAS_TRACK)) {
|
|
|
|
if (_lastTrackDesignCount > 0) {
|
2017-10-21 16:37:30 +02:00
|
|
|
auto intent = Intent(WC_TRACK_DESIGN_LIST);
|
|
|
|
intent.putExtra(INTENT_EXTRA_RIDE_TYPE, item.type);
|
|
|
|
intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, item.entry_index);
|
|
|
|
context_open_intent(&intent);
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-08-21 23:50:06 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
ride_construct_new(item);
|
2014-09-02 17:52:23 +02:00
|
|
|
}
|
2017-11-20 14:25:07 +01:00
|
|
|
|
|
|
|
static void window_new_ride_list_vehicles_for(const uint8 rideType, const rct_ride_entry * rideEntry, char * out)
|
|
|
|
{
|
|
|
|
rct_ride_entry * currentRideEntry;
|
|
|
|
const RideGroup * rideGroup, * currentRideGroup;
|
|
|
|
sint32 rideEntryIndex;
|
|
|
|
|
2017-12-07 16:12:37 +01:00
|
|
|
if (RideGroupManager::RideTypeIsIndependent(rideType))
|
2017-11-20 14:25:07 +01:00
|
|
|
{
|
|
|
|
out[0] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(out, 0, AVAILABILITY_STRING_SIZE);
|
|
|
|
|
|
|
|
uint8 * rideEntryIndexPtr = get_ride_entry_indices_for_ride_type(rideType);
|
|
|
|
|
|
|
|
for (uint8 *currentRideEntryIndex = rideEntryIndexPtr, numItems = 0; *currentRideEntryIndex != RIDE_ENTRY_INDEX_NULL; currentRideEntryIndex++)
|
|
|
|
{
|
|
|
|
rideEntryIndex = *currentRideEntryIndex;
|
|
|
|
currentRideEntry = get_ride_entry(rideEntryIndex);
|
|
|
|
|
|
|
|
// Skip if vehicle type is not invented yet
|
|
|
|
if (!ride_entry_is_invented(rideEntryIndex) && !gCheatsIgnoreResearchStatus)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Skip if vehicle does not belong to the same ride group
|
|
|
|
if (RideGroupManager::RideTypeHasRideGroups(rideType))
|
|
|
|
{
|
|
|
|
rideGroup = RideGroupManager::GetRideGroup(rideType, (rct_ride_entry *)rideEntry);
|
|
|
|
currentRideGroup = RideGroupManager::GetRideGroup(rideType, (rct_ride_entry *)currentRideEntry);
|
|
|
|
|
|
|
|
if (!RideGroupManager::RideGroupsAreEqual(rideGroup, currentRideGroup))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-11-20 16:40:18 +01:00
|
|
|
const char * vehicleName = language_get_string(currentRideEntry->vehicleName);
|
2017-11-20 14:25:07 +01:00
|
|
|
|
|
|
|
if (numItems > 0)
|
|
|
|
{
|
|
|
|
safe_strcat(out, ", ", AVAILABILITY_STRING_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
safe_strcat(out, vehicleName, AVAILABILITY_STRING_SIZE);
|
|
|
|
|
|
|
|
numItems++;
|
|
|
|
}
|
|
|
|
}
|