2016-05-04 19:24:41 +02:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
2014-09-27 01:41:24 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
2016-05-04 19:24:41 +02:00
|
|
|
* 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
|
2014-09-27 01:41:24 +02:00
|
|
|
*
|
|
|
|
* 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.
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
2014-09-27 01:41:24 +02:00
|
|
|
*****************************************************************************/
|
2016-05-04 19:24:41 +02:00
|
|
|
#pragma endregion
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../addresses.h"
|
|
|
|
#include "../audio/audio.h"
|
|
|
|
#include "../editor.h"
|
2016-04-28 22:46:39 +02:00
|
|
|
#include "../interface/themes.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../interface/widget.h"
|
|
|
|
#include "../interface/window.h"
|
2016-04-28 22:46:39 +02:00
|
|
|
#include "../localisation/localisation.h"
|
|
|
|
#include "../rct1.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../ride/ride.h"
|
|
|
|
#include "../ride/track.h"
|
2016-04-28 22:46:39 +02:00
|
|
|
#include "../ride/track_design.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../sprites.h"
|
|
|
|
#include "error.h"
|
2014-09-27 01:41:24 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
|
|
|
WIDX_TRACK_LIST,
|
2014-09-27 21:26:04 +02:00
|
|
|
WIDX_TRACK_PREVIEW,
|
2014-09-27 01:41:24 +02:00
|
|
|
WIDX_ROTATE,
|
2015-06-26 01:21:35 +02:00
|
|
|
WIDX_TOGGLE_SCENERY,
|
|
|
|
WIDX_BACK,
|
2014-09-27 01:41:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_track_list_widgets[] = {
|
|
|
|
{ WWT_FRAME, 0, 0, 599, 0, 399, 0xFFFFFFFF, STR_NONE },
|
|
|
|
{ WWT_CAPTION, 0, 1, 598, 1, 14, STR_SELECT_DESIGN, STR_WINDOW_TITLE_TIP },
|
|
|
|
{ WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
2016-07-14 14:07:49 +02:00
|
|
|
{ WWT_SCROLL, 0, 4, 221, 33, 395, SCROLL_VERTICAL, STR_CLICK_ON_DESIGN_TO_BUILD_IT_TIP },
|
2014-09-27 01:41:24 +02:00
|
|
|
{ WWT_FLATBTN, 0, 224, 595, 18, 236, 0xFFFFFFFF, STR_NONE },
|
2016-05-19 19:22:24 +02:00
|
|
|
{ WWT_FLATBTN, 0, 574, 597, 374, 397, SPR_ROTATE_ARROW, STR_ROTATE_90_TIP },
|
2016-07-14 14:07:49 +02:00
|
|
|
{ WWT_FLATBTN, 0, 574, 597, 350, 373, SPR_SCENERY, STR_TOGGLE_SCENERY_TIP },
|
2015-06-28 21:30:20 +02:00
|
|
|
{ WWT_13, 0, 4, 221, 18, 29, STR_SELECT_OTHER_RIDE, STR_NONE },
|
2014-09-27 01:41:24 +02:00
|
|
|
{ WIDGETS_END },
|
|
|
|
};
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_close(rct_window *w);
|
|
|
|
static void window_track_list_mouseup(rct_window *w, int widgetIndex);
|
2016-05-02 00:34:31 +02:00
|
|
|
static void window_track_list_update(rct_window *w);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height);
|
|
|
|
static void window_track_list_scrollmousedown(rct_window *w, int scrollIndex, int x, int y);
|
|
|
|
static void window_track_list_scrollmouseover(rct_window *w, int scrollIndex, int x, int y);
|
|
|
|
static void window_track_list_tooltip(rct_window* w, int widgetIndex, rct_string_id *stringId);
|
|
|
|
static void window_track_list_invalidate(rct_window *w);
|
|
|
|
static void window_track_list_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
|
|
static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex);
|
|
|
|
|
|
|
|
static rct_window_event_list window_track_list_events = {
|
|
|
|
window_track_list_close,
|
|
|
|
window_track_list_mouseup,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2016-05-04 20:03:27 +02:00
|
|
|
window_track_list_update,
|
2015-07-10 02:39:16 +02:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
window_track_list_scrollgetsize,
|
|
|
|
window_track_list_scrollmousedown,
|
|
|
|
NULL,
|
|
|
|
window_track_list_scrollmouseover,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
window_track_list_tooltip,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
window_track_list_invalidate,
|
|
|
|
window_track_list_paint,
|
|
|
|
window_track_list_scrollpaint
|
2014-09-27 01:41:24 +02:00
|
|
|
};
|
|
|
|
|
2016-05-04 20:03:27 +02:00
|
|
|
#define TRACK_DESIGN_INDEX_UNLOADED UINT16_MAX
|
|
|
|
|
2014-09-30 19:56:30 +02:00
|
|
|
ride_list_item _window_track_list_item;
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2016-04-27 23:57:52 +02:00
|
|
|
static track_design_file_ref *_trackDesigns = NULL;
|
|
|
|
static size_t _trackDesignsCount = 0;
|
2016-04-28 01:19:22 +02:00
|
|
|
static uint16 _loadedTrackDesignIndex;
|
2016-05-01 20:41:48 +02:00
|
|
|
static rct_track_td6 *_loadedTrackDesign;
|
2016-05-02 02:18:46 +02:00
|
|
|
static uint8 *_trackDesignPreviewPixels;
|
2016-04-27 23:57:52 +02:00
|
|
|
|
2016-04-30 14:27:12 +02:00
|
|
|
static void track_list_load_designs(ride_list_item item);
|
|
|
|
static bool track_list_load_design_for_preview(utf8 *path);
|
|
|
|
|
2014-09-27 01:41:24 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CF1A2
|
|
|
|
*/
|
|
|
|
void window_track_list_open(ride_list_item item)
|
|
|
|
{
|
|
|
|
window_close_construction_windows();
|
|
|
|
_window_track_list_item = item;
|
2016-04-30 14:27:12 +02:00
|
|
|
track_list_load_designs(item);
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2016-04-30 14:27:12 +02:00
|
|
|
if (RCT2_GLOBAL(0x00F635ED, uint8) & 1) {
|
2014-09-27 01:41:24 +02:00
|
|
|
window_error_open(STR_WARNING, STR_TOO_MANY_TRACK_DESIGNS_OF_THIS_TYPE);
|
2016-04-30 14:27:12 +02:00
|
|
|
}
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2016-04-30 14:27:12 +02:00
|
|
|
int x, y;
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-04-24 01:36:39 +02:00
|
|
|
x = gScreenWidth / 2 - 300;
|
|
|
|
y = max(28, gScreenHeight / 2 - 200);
|
2014-09-27 01:41:24 +02:00
|
|
|
} else {
|
|
|
|
x = 0;
|
|
|
|
y = 29;
|
|
|
|
}
|
2016-04-30 14:27:12 +02:00
|
|
|
rct_window *w = window_create(
|
2015-06-13 23:16:14 +02:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
600,
|
|
|
|
400,
|
2015-07-10 02:39:16 +02:00
|
|
|
&window_track_list_events,
|
2015-06-13 23:16:14 +02:00
|
|
|
WC_TRACK_DESIGN_LIST,
|
|
|
|
0
|
|
|
|
);
|
2014-09-27 01:41:24 +02:00
|
|
|
w->widgets = window_track_list_widgets;
|
2015-06-26 01:21:35 +02:00
|
|
|
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_ROTATE) | (1 << WIDX_TOGGLE_SCENERY) | (1 << WIDX_BACK);
|
2014-09-27 01:41:24 +02:00
|
|
|
window_init_scroll_widgets(w);
|
|
|
|
w->track_list.var_480 = 0xFFFF;
|
|
|
|
w->track_list.var_484 = 0;
|
2016-05-02 00:34:31 +02:00
|
|
|
w->track_list.reload_track_designs = false;
|
|
|
|
w->selected_list_item = gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 1;
|
2016-05-01 23:46:08 +02:00
|
|
|
gTrackDesignSceneryToggle = false;
|
2014-09-27 01:41:24 +02:00
|
|
|
window_push_others_right(w);
|
2016-04-15 21:56:48 +02:00
|
|
|
_currentTrackPieceDirection = 2;
|
2016-05-02 02:18:46 +02:00
|
|
|
|
|
|
|
_trackDesignPreviewPixels = calloc(4, TRACK_PREVIEW_IMAGE_SIZE);
|
2016-05-17 20:55:07 +02:00
|
|
|
|
|
|
|
_loadedTrackDesign = NULL;
|
|
|
|
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
|
2016-04-30 14:27:12 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFD76
|
|
|
|
*/
|
|
|
|
static void window_track_list_close(rct_window *w)
|
|
|
|
{
|
2016-05-02 02:18:46 +02:00
|
|
|
// Dispose track design and preview
|
|
|
|
track_design_dispose(_loadedTrackDesign);
|
2016-05-01 20:41:48 +02:00
|
|
|
_loadedTrackDesign = NULL;
|
2016-05-02 02:18:46 +02:00
|
|
|
SafeFree(_trackDesignPreviewPixels);
|
2016-04-30 14:27:12 +02:00
|
|
|
|
|
|
|
// Dispose track list
|
|
|
|
for (size_t i = 0; i < _trackDesignsCount; i++) {
|
|
|
|
free(_trackDesigns[i].name);
|
|
|
|
free(_trackDesigns[i].path);
|
|
|
|
}
|
|
|
|
SafeFree(_trackDesigns);
|
|
|
|
_trackDesignsCount = 0;
|
|
|
|
}
|
|
|
|
|
2014-09-28 00:48:42 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFB82
|
|
|
|
*/
|
2014-09-27 21:26:04 +02:00
|
|
|
static void window_track_list_select(rct_window *w, int index)
|
|
|
|
{
|
2014-09-28 00:48:42 +02:00
|
|
|
w->track_list.var_480 = index;
|
|
|
|
|
2015-11-18 00:05:24 +01:00
|
|
|
audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0);
|
2016-04-27 23:57:52 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
|
|
|
if (index == 0) {
|
|
|
|
window_close(w);
|
|
|
|
ride_construct_new(_window_track_list_item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
index--;
|
2014-09-28 00:48:42 +02:00
|
|
|
}
|
|
|
|
|
2016-04-27 23:57:52 +02:00
|
|
|
if (RCT2_GLOBAL(0x00F44153, uint8) != 0) {
|
2016-05-01 23:46:08 +02:00
|
|
|
gTrackDesignSceneryToggle = true;
|
2016-04-27 23:57:52 +02:00
|
|
|
}
|
2014-09-28 00:48:42 +02:00
|
|
|
|
2016-04-27 23:57:52 +02:00
|
|
|
track_design_file_ref *tdRef = &_trackDesigns[index];
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-05-01 22:58:02 +02:00
|
|
|
window_track_manage_open(tdRef);
|
|
|
|
} else {
|
2016-05-04 20:03:27 +02:00
|
|
|
if (_loadedTrackDesignIndex != TRACK_DESIGN_INDEX_UNLOADED && (_loadedTrackDesign->track_flags & 4)) {
|
2016-05-01 22:58:02 +02:00
|
|
|
window_error_open(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, STR_NONE);
|
|
|
|
}
|
2014-09-28 00:48:42 +02:00
|
|
|
|
2016-05-01 23:46:08 +02:00
|
|
|
window_track_place_open(tdRef);
|
2016-04-30 14:27:12 +02:00
|
|
|
}
|
2014-09-27 21:26:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int window_track_list_get_list_item_index_from_position(int x, int y)
|
|
|
|
{
|
2016-04-27 23:57:52 +02:00
|
|
|
int maxItems = _trackDesignsCount;
|
2016-04-23 12:16:46 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
2016-04-27 23:57:52 +02:00
|
|
|
// Extra item: custom design
|
|
|
|
maxItems++;
|
2014-09-27 21:26:04 +02:00
|
|
|
}
|
|
|
|
|
2016-04-27 23:57:52 +02:00
|
|
|
int index = y / 10;
|
|
|
|
if (index < 0 || index >= maxItems) {
|
|
|
|
index = -1;
|
2014-09-27 21:26:04 +02:00
|
|
|
}
|
2016-04-27 23:57:52 +02:00
|
|
|
return index;
|
2014-09-27 21:26:04 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 01:41:24 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFA31
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_mouseup(rct_window *w, int widgetIndex)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2014-12-16 16:33:32 +01:00
|
|
|
window_close_by_number(WC_MANAGE_TRACK_DESIGN, w->number);
|
|
|
|
window_close_by_number(WC_TRACK_DELETE_PROMPT, w->number);
|
2014-09-27 01:41:24 +02:00
|
|
|
trackmanager_load();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WIDX_ROTATE:
|
2016-04-15 21:56:48 +02:00
|
|
|
_currentTrackPieceDirection++;
|
|
|
|
_currentTrackPieceDirection %= 4;
|
2014-09-27 01:41:24 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
case WIDX_TOGGLE_SCENERY:
|
2016-05-01 23:46:08 +02:00
|
|
|
gTrackDesignSceneryToggle = !gTrackDesignSceneryToggle;
|
2016-05-04 20:03:27 +02:00
|
|
|
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
|
2014-09-27 01:41:24 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
2015-06-26 01:21:35 +02:00
|
|
|
case WIDX_BACK:
|
|
|
|
window_close(w);
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2015-08-04 03:12:17 +02:00
|
|
|
window_close_by_number(WC_MANAGE_TRACK_DESIGN, w->number);
|
|
|
|
window_close_by_number(WC_TRACK_DELETE_PROMPT, w->number);
|
|
|
|
trackmanager_load();
|
|
|
|
} else {
|
|
|
|
window_new_ride_open();
|
|
|
|
}
|
2015-06-26 01:21:35 +02:00
|
|
|
break;
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFAB0
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
2016-04-27 23:57:52 +02:00
|
|
|
size_t numItems = _trackDesignsCount;
|
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
|
|
|
// Extra item: custom design
|
|
|
|
numItems++;
|
|
|
|
}
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2016-04-27 23:57:52 +02:00
|
|
|
*height = (int)(numItems * 10);
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFB39
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_scrollmousedown(rct_window *w, int scrollIndex, int x, int y)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
2016-04-27 23:57:52 +02:00
|
|
|
if (!(w->track_list.var_484 & 1)) {
|
|
|
|
int i = window_track_list_get_list_item_index_from_position(x, y);
|
|
|
|
if (i != -1) {
|
|
|
|
window_track_list_select(w, i);
|
|
|
|
}
|
|
|
|
}
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFAD7
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_scrollmouseover(rct_window *w, int scrollIndex, int x, int y)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
2016-04-27 23:57:52 +02:00
|
|
|
if (!(w->track_list.var_484 & 1)) {
|
|
|
|
int i = window_track_list_get_list_item_index_from_position(x, y);
|
2016-05-02 00:34:31 +02:00
|
|
|
if (i != -1 && w->selected_list_item != i) {
|
|
|
|
w->selected_list_item = i;
|
2016-04-27 23:57:52 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
}
|
2014-09-27 02:49:47 +02:00
|
|
|
}
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CFD6C
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_tooltip(rct_window* w, int widgetIndex, rct_string_id *stringId)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(0, uint16, STR_LIST);
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
|
2016-05-02 00:34:31 +02:00
|
|
|
static void window_track_list_update(rct_window *w)
|
|
|
|
{
|
|
|
|
if (w->track_list.reload_track_designs) {
|
|
|
|
track_list_load_designs(_window_track_list_item);
|
|
|
|
w->selected_list_item = 0;
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 01:41:24 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CF2D6
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_invalidate(rct_window *w)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
2016-02-25 13:33:19 +01:00
|
|
|
rct_ride_entry *entry;
|
2014-09-27 01:41:24 +02:00
|
|
|
rct_string_id stringId;
|
|
|
|
|
2015-05-29 18:04:53 +02:00
|
|
|
colour_scheme_update(w);
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2016-01-22 15:38:52 +01:00
|
|
|
entry = get_ride_entry(_window_track_list_item.entry_index);
|
2014-09-27 01:41:24 +02:00
|
|
|
|
|
|
|
stringId = entry->name;
|
2015-06-25 11:46:17 +02:00
|
|
|
if (!(entry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME) || rideTypeShouldLoseSeparateFlag(entry))
|
2014-09-27 01:41:24 +02:00
|
|
|
stringId = _window_track_list_item.type + 2;
|
|
|
|
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(0, uint16, stringId);
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-07-14 14:07:49 +02:00
|
|
|
window_track_list_widgets[WIDX_TITLE].text = STR_TRACK_DESIGNS;
|
2014-09-27 01:41:24 +02:00
|
|
|
window_track_list_widgets[WIDX_TRACK_LIST].tooltip = STR_CLICK_ON_DESIGN_TO_RENAME_OR_DELETE_IT;
|
|
|
|
} else {
|
2016-07-14 14:07:49 +02:00
|
|
|
window_track_list_widgets[WIDX_TITLE].text = STR_SELECT_DESIGN;
|
2014-09-27 01:41:24 +02:00
|
|
|
window_track_list_widgets[WIDX_TRACK_LIST].tooltip = STR_CLICK_ON_DESIGN_TO_BUILD_IT_TIP;
|
|
|
|
}
|
|
|
|
|
2016-05-02 00:34:31 +02:00
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) || w->selected_list_item != 0) {
|
2014-09-27 21:26:04 +02:00
|
|
|
w->pressed_widgets |= 1 << WIDX_TRACK_PREVIEW;
|
|
|
|
w->disabled_widgets &= ~(1 << WIDX_TRACK_PREVIEW);
|
2014-09-27 01:41:24 +02:00
|
|
|
window_track_list_widgets[WIDX_ROTATE].type = WWT_FLATBTN;
|
|
|
|
window_track_list_widgets[WIDX_TOGGLE_SCENERY].type = WWT_FLATBTN;
|
2016-05-01 23:46:08 +02:00
|
|
|
if (gTrackDesignSceneryToggle) {
|
2014-09-27 01:41:24 +02:00
|
|
|
w->pressed_widgets &= ~(1 << WIDX_TOGGLE_SCENERY);
|
2016-05-01 23:46:08 +02:00
|
|
|
} else {
|
|
|
|
w->pressed_widgets |= (1 << WIDX_TOGGLE_SCENERY);
|
|
|
|
}
|
2014-09-27 01:41:24 +02:00
|
|
|
} else {
|
2014-09-27 21:26:04 +02:00
|
|
|
w->pressed_widgets &= ~(1 << WIDX_TRACK_PREVIEW);
|
|
|
|
w->disabled_widgets |= (1 << WIDX_TRACK_PREVIEW);
|
2014-09-27 01:41:24 +02:00
|
|
|
window_track_list_widgets[WIDX_ROTATE].type = WWT_EMPTY;
|
|
|
|
window_track_list_widgets[WIDX_TOGGLE_SCENERY].type = WWT_EMPTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CF387
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
|
|
|
window_draw_widgets(w, dpi);
|
2014-09-27 21:26:04 +02:00
|
|
|
|
2016-05-02 00:34:31 +02:00
|
|
|
int trackIndex = w->selected_list_item;
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-04-27 23:57:52 +02:00
|
|
|
if (_trackDesignsCount == 0 || trackIndex == -1) {
|
2014-09-27 21:26:04 +02:00
|
|
|
return;
|
2016-04-27 23:57:52 +02:00
|
|
|
}
|
2014-09-27 21:26:04 +02:00
|
|
|
} else if (trackIndex-- == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Track preview
|
2016-04-30 14:27:12 +02:00
|
|
|
int x, y, colour;
|
|
|
|
rct_widget *widget = &window_track_list_widgets[WIDX_TRACK_PREVIEW];
|
2014-09-27 21:26:04 +02:00
|
|
|
x = w->x + widget->left + 1;
|
|
|
|
y = w->y + widget->top + 1;
|
2015-11-08 19:55:32 +01:00
|
|
|
colour = ColourMapA[w->colours[0]].darkest;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_fill_rect(dpi, x, y, x + 369, y + 216, colour);
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (_loadedTrackDesignIndex != trackIndex) {
|
2016-05-04 20:03:27 +02:00
|
|
|
utf8 *path = _trackDesigns[trackIndex].path;
|
2016-04-30 14:27:12 +02:00
|
|
|
if (track_list_load_design_for_preview(path)) {
|
|
|
|
_loadedTrackDesignIndex = trackIndex;
|
|
|
|
} else {
|
2016-05-04 20:03:27 +02:00
|
|
|
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
|
2016-04-28 01:19:22 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-04-27 23:57:52 +02:00
|
|
|
}
|
2014-09-27 21:26:04 +02:00
|
|
|
|
2016-05-01 20:41:48 +02:00
|
|
|
rct_track_td6 *td6 = _loadedTrackDesign;
|
|
|
|
if (td6 == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-30 14:27:12 +02:00
|
|
|
rct_g1_element *substituteElement = &g1Elements[0];
|
|
|
|
rct_g1_element tmpElement = *substituteElement;
|
2016-05-02 02:18:46 +02:00
|
|
|
substituteElement->offset = _trackDesignPreviewPixels + (_currentTrackPieceDirection * TRACK_PREVIEW_IMAGE_SIZE);
|
2015-12-22 16:31:51 +01:00
|
|
|
substituteElement->width = 370;
|
|
|
|
substituteElement->height = 217;
|
|
|
|
substituteElement->x_offset = 0;
|
|
|
|
substituteElement->y_offset = 0;
|
|
|
|
substituteElement->flags = G1_FLAG_BMP;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_sprite(dpi, 0, x, y, 0);
|
2015-12-22 16:31:51 +01:00
|
|
|
*substituteElement = tmpElement;
|
2014-09-27 21:26:04 +02:00
|
|
|
|
|
|
|
x = w->x + (widget->left + widget->right) / 2;
|
|
|
|
y = w->y + widget->bottom - 12;
|
2014-12-11 19:26:44 +01:00
|
|
|
|
|
|
|
RCT2_GLOBAL(0x00F44153, uint8) = 0;
|
2014-09-27 21:26:04 +02:00
|
|
|
// Warnings
|
2016-04-28 01:19:22 +02:00
|
|
|
if ((td6->track_flags & 4) && !(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Vehicle design not available
|
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_VEHICLE_DESIGN_UNAVAILABLE, NULL, 0, x, y, 368);
|
|
|
|
y -= 10;
|
|
|
|
}
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (td6->track_flags & 1) {
|
2014-09-27 21:26:04 +02:00
|
|
|
RCT2_GLOBAL(0x00F44153, uint8) = 1;
|
2016-05-01 23:46:08 +02:00
|
|
|
if (!gTrackDesignSceneryToggle) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Scenery not available
|
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, NULL, 0, x, y, 368);
|
|
|
|
y -= 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Track design name
|
2016-04-27 23:57:52 +02:00
|
|
|
utf8 *trackName = _trackDesigns[trackIndex].name;
|
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_TRACK_PREVIEW_NAME_FORMAT, &trackName, 0, x, y, 368);
|
2014-09-27 21:26:04 +02:00
|
|
|
|
|
|
|
// Information
|
|
|
|
x = w->x + widget->left + 1;
|
|
|
|
y = w->y + widget->bottom + 2;
|
|
|
|
|
|
|
|
// Stats
|
2016-04-30 14:27:12 +02:00
|
|
|
fixed32_2dp rating = td6->excitement * 10;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_TRACK_LIST_EXCITEMENT_RATING, &rating, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
rating = td6->intensity * 10;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_TRACK_LIST_INTENSITY_RATING, &rating, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
rating = td6->nausea * 10;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_TRACK_LIST_NAUSEA_RATING, &rating, 0, x, y);
|
|
|
|
y += 14;
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (td6->type != RIDE_TYPE_MAZE) {
|
|
|
|
if (td6->type == RIDE_TYPE_MINI_GOLF) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Holes
|
2016-04-30 14:27:12 +02:00
|
|
|
uint16 holes = td6->holes & 0x1F;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_HOLES, &holes, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
} else {
|
|
|
|
// Maximum speed
|
2016-04-30 14:27:12 +02:00
|
|
|
uint16 speed = ((td6->max_speed << 16) * 9) >> 18;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_MAX_SPEED, &speed, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
// Average speed
|
2016-04-28 01:19:22 +02:00
|
|
|
speed = ((td6->average_speed << 16) * 9) >> 18;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_AVERAGE_SPEED, &speed, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ride length
|
2016-05-19 19:22:24 +02:00
|
|
|
set_format_arg(0, uint16, STR_RIDE_LENGTH_ENTRY);
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(2, uint16, td6->ride_length);
|
|
|
|
gfx_draw_string_left_clipped(dpi, STR_TRACK_LIST_RIDE_LENGTH, gCommonFormatArgs, 0, x, y, 214);
|
2014-09-27 21:26:04 +02:00
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (ride_type_has_flag(td6->type, RIDE_TYPE_FLAG_HAS_G_FORCES)) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Maximum positive vertical Gs
|
2016-04-30 14:27:12 +02:00
|
|
|
int gForces = td6->max_positive_vertical_g * 32;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_MAX_POSITIVE_VERTICAL_G, &gForces, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
// Maximum negative verical Gs
|
2016-04-28 01:19:22 +02:00
|
|
|
gForces = td6->max_negative_vertical_g * 32;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_MAX_NEGATIVE_VERTICAL_G, &gForces, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
// Maximum lateral Gs
|
2016-04-28 01:19:22 +02:00
|
|
|
gForces = td6->max_lateral_g * 32;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_MAX_LATERAL_G, &gForces, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
2015-04-26 13:33:00 +02:00
|
|
|
// If .TD6
|
2016-04-28 01:19:22 +02:00
|
|
|
if (td6->version_and_colour_scheme / 4 >= 2) {
|
|
|
|
if (td6->total_air_time != 0) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Total air time
|
2016-04-30 14:27:12 +02:00
|
|
|
int airTime = td6->total_air_time * 25;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_TOTAL_AIR_TIME, &airTime, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (ride_type_has_flag(td6->type, RIDE_TYPE_FLAG_HAS_DROPS)) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Drops
|
2016-04-30 14:27:12 +02:00
|
|
|
uint16 drops = td6->drops & 0x3F;
|
2014-09-27 21:26:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_DROPS, &drops, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
// Drop height is multiplied by 0.75
|
|
|
|
gfx_draw_string_left(dpi, STR_HIGHEST_DROP_HEIGHT, &drops, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (td6->type != RIDE_TYPE_MINI_GOLF) {
|
2016-04-30 14:27:12 +02:00
|
|
|
uint16 inversions = td6->inversions & 0x1F;
|
2014-09-27 21:26:04 +02:00
|
|
|
if (inversions != 0) {
|
|
|
|
// Inversions
|
|
|
|
gfx_draw_string_left(dpi, STR_INVERSIONS, &inversions, 0, x, y);
|
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y += 4;
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (td6->space_required_x != 0xFF) {
|
2014-09-27 21:26:04 +02:00
|
|
|
// Space required
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(0, uint16, td6->space_required_x);
|
|
|
|
set_format_arg(2, uint16, td6->space_required_y);
|
|
|
|
gfx_draw_string_left(dpi, STR_TRACK_LIST_SPACE_REQUIRED, gCommonFormatArgs, 0, x, y);
|
2014-09-27 21:26:04 +02:00
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
|
2016-04-28 01:19:22 +02:00
|
|
|
if (td6->cost != 0) {
|
|
|
|
gfx_draw_string_left(dpi, STR_TRACK_LIST_COST_AROUND, &td6->cost, 0, x, y);
|
2014-09-27 21:26:04 +02:00
|
|
|
y += 14;
|
|
|
|
}
|
2014-09-27 01:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CF8CD
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex)
|
2014-09-27 01:41:24 +02:00
|
|
|
{
|
2016-05-01 22:58:02 +02:00
|
|
|
int colour = ColourMapA[w->colours[0]].mid_light;
|
2014-09-27 01:41:24 +02:00
|
|
|
colour = (colour << 24) | (colour << 16) | (colour << 8) | colour;
|
|
|
|
gfx_clear(dpi, colour);
|
2014-09-27 02:49:47 +02:00
|
|
|
|
2016-05-01 22:58:02 +02:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
size_t listIndex = 0;
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-04-27 23:57:52 +02:00
|
|
|
if (_trackDesignsCount == 0) {
|
2014-09-27 02:49:47 +02:00
|
|
|
// No track designs
|
|
|
|
gfx_draw_string_left(dpi, STR_NO_TRACK_DESIGNS_OF_THIS_TYPE, NULL, 0, x, y - 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Build custom track item
|
2016-05-01 22:58:02 +02:00
|
|
|
rct_string_id stringId;
|
2016-05-02 00:34:31 +02:00
|
|
|
if (listIndex == w->selected_list_item) {
|
2014-09-27 02:49:47 +02:00
|
|
|
// Highlight
|
|
|
|
gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
|
2016-07-14 14:07:49 +02:00
|
|
|
stringId = STR_WINDOW_COLOUR_2_STRINGID;
|
2014-09-27 02:49:47 +02:00
|
|
|
} else {
|
2016-05-19 19:22:24 +02:00
|
|
|
stringId = STR_BLACK_STRING;
|
2014-09-27 02:49:47 +02:00
|
|
|
}
|
|
|
|
|
2016-05-01 22:58:02 +02:00
|
|
|
rct_string_id stringId2 = STR_BUILD_CUSTOM_DESIGN;
|
2014-09-27 02:49:47 +02:00
|
|
|
gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
|
|
|
|
y += 10;
|
2016-05-01 22:58:02 +02:00
|
|
|
listIndex++;
|
2014-09-27 02:49:47 +02:00
|
|
|
}
|
|
|
|
|
2016-05-01 22:58:02 +02:00
|
|
|
for (size_t i = 0; i < _trackDesignsCount; i++, listIndex++) {
|
2014-09-27 02:49:47 +02:00
|
|
|
if (y + 10 >= dpi->y && y < dpi->y + dpi->height) {
|
2016-05-01 22:58:02 +02:00
|
|
|
rct_string_id stringId;
|
2016-05-02 00:34:31 +02:00
|
|
|
if (listIndex == w->selected_list_item) {
|
2014-09-27 02:49:47 +02:00
|
|
|
// Highlight
|
|
|
|
gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
|
2016-07-14 14:07:49 +02:00
|
|
|
stringId = STR_WINDOW_COLOUR_2_STRINGID;
|
2014-09-27 02:49:47 +02:00
|
|
|
} else {
|
2016-05-19 19:22:24 +02:00
|
|
|
stringId = STR_BLACK_STRING;
|
2014-09-27 02:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw track name
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(0, rct_string_id, STR_TRACK_LIST_NAME_FORMAT);
|
|
|
|
set_format_arg(2, utf8*, _trackDesigns[i].name);
|
|
|
|
gfx_draw_string_left(dpi, stringId, gCommonFormatArgs, 0, x, y - 1);
|
2014-09-27 02:49:47 +02:00
|
|
|
}
|
|
|
|
y += 10;
|
|
|
|
}
|
2015-06-10 18:12:21 +02:00
|
|
|
}
|
2016-04-30 14:27:12 +02:00
|
|
|
|
|
|
|
static void track_list_load_designs(ride_list_item item)
|
|
|
|
{
|
|
|
|
char entry[9];
|
|
|
|
const char *entryPtr = NULL;
|
|
|
|
if (item.type < 0x80) {
|
|
|
|
rct_ride_entry *rideEntry = get_ride_entry(item.entry_index);
|
|
|
|
if ((rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE) && !rideTypeShouldLoseSeparateFlag(rideEntry)) {
|
|
|
|
get_ride_entry_name(entry, item.entry_index);
|
|
|
|
entryPtr = entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_trackDesignsCount = track_design_index_get_for_ride(&_trackDesigns, item.type, entryPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool track_list_load_design_for_preview(utf8 *path)
|
|
|
|
{
|
|
|
|
// Dispose currently loaded track
|
2016-05-01 20:41:48 +02:00
|
|
|
track_design_dispose(_loadedTrackDesign);
|
|
|
|
_loadedTrackDesign = NULL;
|
2016-04-30 14:27:12 +02:00
|
|
|
|
2016-05-01 23:46:08 +02:00
|
|
|
_loadedTrackDesign = track_design_open(path);
|
|
|
|
if (_loadedTrackDesign != NULL) {
|
2016-05-02 03:06:09 +02:00
|
|
|
track_design_draw_preview(_loadedTrackDesign, _trackDesignPreviewPixels);
|
2016-04-30 14:27:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|