2016-05-04 19:24:41 +02:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
2014-11-23 17:28:23 +01: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-11-23 17:28:23 +01:00
|
|
|
|
2017-01-12 19:20:22 +01:00
|
|
|
#pragma warning(disable : 4295) // 'identifier': array is too small to include a terminating null character
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
#include "../audio/audio.h"
|
2017-02-18 16:45:10 +01:00
|
|
|
#include "../config/Config.h"
|
2014-11-25 00:05:35 +01:00
|
|
|
#include "../game.h"
|
2016-05-21 00:26:19 +02:00
|
|
|
#include "../editor.h"
|
2015-09-10 23:16:41 +02:00
|
|
|
#include "../interface/themes.h"
|
2014-11-25 00:05:35 +01:00
|
|
|
#include "../interface/widget.h"
|
|
|
|
#include "../interface/window.h"
|
2015-02-11 17:02:57 +01:00
|
|
|
#include "../localisation/localisation.h"
|
2015-03-31 16:17:43 +02:00
|
|
|
#include "../management/research.h"
|
2014-11-25 00:05:35 +01:00
|
|
|
#include "../object.h"
|
2016-06-15 14:59:01 +02:00
|
|
|
#include "../object_list.h"
|
2016-07-06 23:31:14 +02:00
|
|
|
#include "../object/ObjectManager.h"
|
2016-06-29 23:15:38 +02:00
|
|
|
#include "../object/ObjectRepository.h"
|
2017-03-23 19:34:32 +01:00
|
|
|
#include "../platform/platform.h"
|
2015-09-10 23:16:41 +02:00
|
|
|
#include "../rct1.h"
|
|
|
|
#include "../ride/ride.h"
|
|
|
|
#include "../ride/ride_data.h"
|
2015-02-02 19:49:07 +01:00
|
|
|
#include "../ride/track.h"
|
2016-05-10 01:00:59 +02:00
|
|
|
#include "../ride/track_data.h"
|
2016-04-28 22:46:39 +02:00
|
|
|
#include "../ride/track_design.h"
|
2016-12-14 13:13:52 +01:00
|
|
|
#include "../scenario/scenario.h"
|
2015-10-30 15:18:29 +01:00
|
|
|
#include "../util/util.h"
|
2015-12-05 00:08:34 +01:00
|
|
|
#include "../world/footpath.h"
|
2016-01-29 20:39:31 +01:00
|
|
|
#include "dropdown.h"
|
|
|
|
#include "error.h"
|
2016-07-14 14:07:49 +02:00
|
|
|
#include "../sprites.h"
|
2015-09-10 23:16:41 +02:00
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
enum {
|
|
|
|
FILTER_RCT2 = (1 << 0),
|
|
|
|
FILTER_WW = (1 << 1),
|
|
|
|
FILTER_TT = (1 << 2),
|
|
|
|
FILTER_CUSTOM = (1 << 3),
|
2015-06-14 18:19:54 +02:00
|
|
|
|
|
|
|
FILTER_RIDE_TRANSPORT = (1 << 5),
|
|
|
|
FILTER_RIDE_GENTLE = (1 << 6),
|
|
|
|
FILTER_RIDE_COASTER = (1 << 7),
|
|
|
|
FILTER_RIDE_THRILL = (1 << 8),
|
|
|
|
FILTER_RIDE_WATER = (1 << 9),
|
|
|
|
FILTER_RIDE_STALL = (1 << 10),
|
|
|
|
|
2016-06-21 20:41:07 +02:00
|
|
|
FILTER_SELECTED = (1 << 12),
|
|
|
|
FILTER_NONSELECTED = (1 << 13),
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2017-02-16 19:35:59 +01:00
|
|
|
FILTER_RIDES = FILTER_RIDE_TRANSPORT | FILTER_RIDE_GENTLE | FILTER_RIDE_COASTER | FILTER_RIDE_THRILL | FILTER_RIDE_WATER | FILTER_RIDE_STALL,
|
|
|
|
FILTER_ALL = FILTER_RIDES | FILTER_RCT2 | FILTER_WW | FILTER_TT | FILTER_CUSTOM | FILTER_SELECTED | FILTER_NONSELECTED,
|
2015-06-03 18:37:07 +02:00
|
|
|
} FILTER_FLAGS;
|
|
|
|
|
|
|
|
uint32 _filter_flags;
|
|
|
|
uint16 _filter_object_counts[11];
|
2015-06-14 18:19:54 +02:00
|
|
|
uint8 _filter_ride_tab;
|
2015-06-03 18:37:07 +02:00
|
|
|
|
2015-06-06 00:54:47 +02:00
|
|
|
char _filter_string[41];
|
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
#define _FILTER_ALL ((_filter_flags & FILTER_ALL) == FILTER_ALL)
|
|
|
|
#define _FILTER_RCT2 (_filter_flags & FILTER_RCT2)
|
|
|
|
#define _FILTER_WW (_filter_flags & FILTER_WW)
|
|
|
|
#define _FILTER_TT (_filter_flags & FILTER_TT)
|
|
|
|
#define _FILTER_CUSTOM (_filter_flags & FILTER_CUSTOM)
|
2016-06-21 20:41:07 +02:00
|
|
|
#define _FILTER_SELECTED (_filter_flags & FILTER_SELECTED)
|
|
|
|
#define _FILTER_NONSELECTED (_filter_flags & FILTER_NONSELECTED)
|
2014-11-25 00:05:35 +01:00
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
enum {
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_SMALL_SCENERY,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_LARGE_SCENERY,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_WALLS_FENCES,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_PATH_SIGNS,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_FOOTPATHS,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_PATH_EXTRAS,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_SCENERY_GROUPS,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_PARK_ENTRANCE,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_WATER,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_SCENARIO_DESCRIPTION,
|
|
|
|
WINDOW_OBJECT_SELECTION_PAGE_COUNT
|
|
|
|
};
|
|
|
|
|
2016-07-14 14:07:49 +02:00
|
|
|
static const rct_string_id ObjectSelectionPageNames[WINDOW_OBJECT_SELECTION_PAGE_COUNT] = {
|
|
|
|
STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS,
|
|
|
|
STR_OBJECT_SELECTION_SMALL_SCENERY,
|
|
|
|
STR_OBJECT_SELECTION_LARGE_SCENERY,
|
|
|
|
STR_OBJECT_SELECTION_WALLS_FENCES,
|
|
|
|
STR_OBJECT_SELECTION_PATH_SIGNS,
|
|
|
|
STR_OBJECT_SELECTION_FOOTPATHS,
|
|
|
|
STR_OBJECT_SELECTION_PATH_EXTRAS,
|
|
|
|
STR_OBJECT_SELECTION_SCENERY_GROUPS,
|
|
|
|
STR_OBJECT_SELECTION_PARK_ENTRANCE,
|
|
|
|
STR_OBJECT_SELECTION_WATER,
|
|
|
|
STR_OBJECT_SELECTION_SCENARIO_DESCRIPTION,
|
|
|
|
};
|
|
|
|
|
2014-11-25 00:05:35 +01:00
|
|
|
#pragma region Widgets
|
|
|
|
|
|
|
|
enum WINDOW_STAFF_LIST_WIDGET_IDX {
|
2015-02-11 17:02:57 +01:00
|
|
|
WIDX_BACKGROUND, // 0, 1
|
|
|
|
WIDX_TITLE, // 1, 2
|
|
|
|
WIDX_CLOSE, // 2, 4
|
|
|
|
WIDX_TAB_CONTENT_PANEL, // 3, 8
|
|
|
|
WIDX_TAB_1, // 4, 10
|
|
|
|
WIDX_TAB_2, // 5, 20
|
|
|
|
WIDX_TAB_3, // 6, 40
|
|
|
|
WIDX_TAB_4, // 7, 80
|
|
|
|
WIDX_TAB_5, // 8, 100
|
|
|
|
WIDX_TAB_6, // 9, 200
|
|
|
|
WIDX_TAB_7, // 10, 400
|
|
|
|
WIDX_TAB_8, // 11, 800
|
|
|
|
WIDX_TAB_9, // 12, 1000
|
|
|
|
WIDX_TAB_10, // 13, 2000
|
|
|
|
WIDX_TAB_11, // 14, 4000
|
2015-06-26 02:11:24 +02:00
|
|
|
WIDX_ADVANCED, // 15, 8000
|
2015-02-11 17:02:57 +01:00
|
|
|
WIDX_LIST, // 16, 10000
|
|
|
|
WIDX_PREVIEW, // 17, 20000
|
2015-06-26 02:11:24 +02:00
|
|
|
WIDX_INSTALL_TRACK, // 18, 40000
|
2015-06-03 18:37:07 +02:00
|
|
|
WIDX_FILTER_DROPDOWN, // 19, 80000
|
2015-06-06 00:54:47 +02:00
|
|
|
WIDX_FILTER_STRING_BUTTON, // 20, 100000
|
2015-06-14 18:19:54 +02:00
|
|
|
WIDX_FILTER_CLEAR_BUTTON, // 21, 200000
|
|
|
|
WIDX_FILTER_RIDE_TAB_FRAME,
|
|
|
|
WIDX_FILTER_RIDE_TAB_ALL,
|
|
|
|
WIDX_FILTER_RIDE_TAB_TRANSPORT,
|
|
|
|
WIDX_FILTER_RIDE_TAB_GENTLE,
|
|
|
|
WIDX_FILTER_RIDE_TAB_COASTER,
|
|
|
|
WIDX_FILTER_RIDE_TAB_THRILL,
|
|
|
|
WIDX_FILTER_RIDE_TAB_WATER,
|
2015-06-26 02:11:24 +02:00
|
|
|
WIDX_FILTER_RIDE_TAB_STALL,
|
|
|
|
WIDX_LIST_SORT_TYPE,
|
|
|
|
WIDX_LIST_SORT_RIDE,
|
2015-02-11 17:02:57 +01:00
|
|
|
};
|
|
|
|
|
2017-05-02 02:01:29 +02:00
|
|
|
validate_global_widx(WC_EDITOR_OBJECT_SELECTION, WIDX_TAB_1);
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
static rct_widget window_editor_object_selection_widgets[] = {
|
|
|
|
{ WWT_FRAME, 0, 0, 599, 0, 399, 0xFFFFFFFF, STR_NONE },
|
2015-09-11 16:21:27 +02:00
|
|
|
{ WWT_CAPTION, 0, 1, 598, 1, 14, STR_OBJECT_SELECTION, STR_WINDOW_TITLE_TIP },
|
2015-02-11 17:02:57 +01:00
|
|
|
{ WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
|
|
|
{ WWT_RESIZE, 1, 0, 599, 43, 399, 0xFFFFFFFF, STR_NONE },
|
2016-07-14 14:07:49 +02:00
|
|
|
{ WWT_TAB, 1, 3, 33, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 34, 64, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 65, 95, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 96, 126, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 127, 157, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 158, 188, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 189, 219, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 220, 250, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 251, 281, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 282, 312, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 313, 343, 17, 43, 0x20000000 | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
2015-02-11 17:02:57 +01:00
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 470, 591, 23, 34, STR_OBJECT_SELECTION_ADVANCED, STR_OBJECT_SELECTION_ADVANCED_TIP },
|
2016-07-14 14:07:49 +02:00
|
|
|
{ WWT_SCROLL, 1, 4, 291, 60, 386, SCROLL_VERTICAL, STR_NONE },
|
2015-02-11 17:02:57 +01:00
|
|
|
{ WWT_FLATBTN, 1, 391, 504, 46, 159, 0xFFFFFFFF, STR_NONE },
|
2015-09-11 16:21:27 +02:00
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 470, 591, 23, 34, STR_INSTALL_NEW_TRACK_DESIGN, STR_INSTALL_NEW_TRACK_DESIGN_TIP },
|
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 350, 463, 23, 34, STR_OBJECT_FILTER, STR_OBJECT_FILTER_TIP },
|
2016-04-21 22:20:24 +02:00
|
|
|
{ WWT_TEXT_BOX, 1, 4, 214, 46, 57, STR_NONE, STR_NONE },
|
2015-09-11 16:21:27 +02:00
|
|
|
{ WWT_DROPDOWN_BUTTON, 1, 218, 287, 46, 57, STR_OBJECT_SEARCH_CLEAR, STR_NONE },
|
2015-06-25 17:48:32 +02:00
|
|
|
{ WWT_IMGBTN, 1, 3, 287, 73, 76, 0xFFFFFFFF, STR_NONE },
|
2016-07-14 14:07:49 +02:00
|
|
|
{ WWT_TAB, 1, 3, 33, 47, 73, 0x20000000 | SPR_TAB, STR_OBJECT_FILTER_ALL_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 34, 64, 47, 73, 0x20000000 | SPR_TAB, STR_TRANSPORT_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 65, 95, 47, 73, 0x20000000 | SPR_TAB, STR_GENTLE_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 96, 126, 47, 73, 0x20000000 | SPR_TAB, STR_ROLLER_COASTERS_TIP },
|
|
|
|
{ WWT_TAB, 1, 127, 157, 47, 73, 0x20000000 | SPR_TAB, STR_THRILL_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 158, 188, 47, 73, 0x20000000 | SPR_TAB, STR_WATER_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 189, 219, 47, 73, 0x20000000 | SPR_TAB, STR_SHOPS_STALLS_TIP },
|
2015-06-26 02:11:24 +02:00
|
|
|
{ WWT_13, 1, 4, 204, 80, 93, STR_NONE, STR_NONE },
|
|
|
|
{ WWT_13, 1, 205, 291, 80, 93, STR_NONE, STR_NONE },
|
2015-02-11 17:02:57 +01:00
|
|
|
{ WIDGETS_END }
|
2014-11-25 00:05:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Events
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_close(rct_window *w);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_mouseup(rct_window *w, sint32 widgetIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_resize(rct_window *w);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_mousedown(sint32 widgetIndex, rct_window*w, rct_widget* widget);
|
|
|
|
static void window_editor_object_selection_dropdown(rct_window *w, sint32 widgetIndex, sint32 dropdownIndex);
|
2015-06-06 23:04:53 +02:00
|
|
|
static void window_editor_object_selection_update(rct_window *w);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height);
|
|
|
|
static void window_editor_object_selection_scroll_mousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
|
|
|
|
static void window_editor_object_selection_scroll_mouseover(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
|
|
|
|
static void window_editor_object_selection_tooltip(rct_window* w, sint32 widgetIndex, rct_string_id *stringId);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_invalidate(rct_window *w);
|
|
|
|
static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex);
|
|
|
|
static void window_editor_object_selection_textinput(rct_window *w, sint32 widgetIndex, char *text);
|
2015-07-10 02:39:16 +02:00
|
|
|
|
|
|
|
static rct_window_event_list window_editor_object_selection_events = {
|
2015-02-02 19:49:07 +01:00
|
|
|
window_editor_object_selection_close,
|
2015-07-10 02:39:16 +02:00
|
|
|
window_editor_object_selection_mouseup,
|
|
|
|
window_editor_object_selection_resize,
|
|
|
|
window_editor_object_selection_mousedown,
|
|
|
|
window_editor_object_selection_dropdown,
|
|
|
|
NULL,
|
|
|
|
window_editor_object_selection_update,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
window_editor_object_selection_scrollgetsize,
|
|
|
|
window_editor_object_selection_scroll_mousedown,
|
|
|
|
NULL,
|
|
|
|
window_editor_object_selection_scroll_mouseover,
|
|
|
|
window_editor_object_selection_textinput,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
window_editor_object_selection_tooltip,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
window_editor_object_selection_invalidate,
|
|
|
|
window_editor_object_selection_paint,
|
|
|
|
window_editor_object_selection_scrollpaint
|
2014-11-25 00:05:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
const sint32 window_editor_object_selection_animation_loops[] = { 20, 32, 10, 72, 24, 28, 16 };
|
|
|
|
const sint32 window_editor_object_selection_animation_divisor[] = { 4, 8, 2, 4, 4, 4, 2 };
|
2015-06-26 02:11:24 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_set_page(rct_window *w, sint32 page);
|
2015-02-11 17:02:57 +01:00
|
|
|
static void window_editor_object_selection_set_pressed_tab(rct_window *w);
|
2015-02-13 19:43:22 +01:00
|
|
|
static void window_editor_object_selection_select_default_objects();
|
2015-06-17 20:51:41 +02:00
|
|
|
static void window_editor_object_selection_select_required_objects();
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 window_editor_object_selection_select_object(uint8 bh, sint32 flags, const rct_object_entry *entry);
|
|
|
|
static sint32 get_object_from_object_selection(uint8 object_type, sint32 y);
|
2015-02-13 19:43:22 +01:00
|
|
|
static void window_editor_object_selection_manage_tracks();
|
2015-02-11 17:02:57 +01:00
|
|
|
static void editor_load_selected_objects();
|
2016-07-02 15:59:13 +02:00
|
|
|
static bool filter_selected(uint8 objectFlags);
|
2016-06-29 23:15:38 +02:00
|
|
|
static bool filter_string(const ObjectRepositoryItem * item);
|
|
|
|
static bool filter_source(const ObjectRepositoryItem * item);
|
|
|
|
static bool filter_chunks(const ObjectRepositoryItem * item);
|
2015-06-06 00:54:47 +02:00
|
|
|
static void filter_update_counts();
|
2014-11-23 17:28:23 +01:00
|
|
|
|
2015-06-17 20:51:41 +02:00
|
|
|
void reset_selected_object_count_and_size();
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 sub_6AB211();
|
2015-06-17 20:51:41 +02:00
|
|
|
|
2016-08-11 20:52:56 +02:00
|
|
|
/** rct2: 0x0098DA74 */
|
|
|
|
rct_object_entry RequiredSelectedObjects[] = {
|
2015-02-13 19:43:22 +01:00
|
|
|
// Objects that are always required
|
2015-06-26 02:11:24 +02:00
|
|
|
{ 0x00000087, { "SCGTREES" }, 0 }, // Scenery: Trees
|
|
|
|
{ 0x00000087, { "SCGSHRUB" }, 0 }, // Scenery: Shrubs and Ornaments
|
|
|
|
{ 0x00000087, { "SCGGARDN" }, 0 }, // Scenery: Gardens
|
|
|
|
{ 0x00000087, { "SCGFENCE" }, 0 }, // Scenery: Fences and Walls
|
|
|
|
{ 0x00000087, { "SCGWALLS" }, 0 }, // Scenery: Walls and Roofs
|
|
|
|
{ 0x00000087, { "SCGPATHX" }, 0 }, // Scenery: Signs and Items for Footpaths
|
|
|
|
{ 0x00000085, { "TARMAC " }, 0 }, // Footpath: Tarmac
|
2015-06-17 20:51:41 +02:00
|
|
|
};
|
2015-02-13 19:43:22 +01:00
|
|
|
|
2015-06-17 20:51:41 +02:00
|
|
|
static rct_object_entry DefaultSelectedObjects[] = {
|
2015-02-13 19:43:22 +01:00
|
|
|
// An initial default selection
|
2015-06-17 20:51:41 +02:00
|
|
|
{ 0x00000080, { "TWIST1 " }, 0 }, // Ride: Twist
|
|
|
|
{ 0x00000080, { "PTCT1 " }, 0 }, // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
|
|
|
|
{ 0x00000080, { "ZLDB " }, 0 }, // Ride: Junior Roller Coaster (Ladybird Trains)
|
|
|
|
{ 0x00000080, { "LFB1 " }, 0 }, // Ride: Log Flume
|
|
|
|
{ 0x00000080, { "VCR " }, 0 }, // Ride: Vintage Cars
|
|
|
|
{ 0x00000080, { "MGR1 " }, 0 }, // Ride: Merry-Go-Round
|
|
|
|
{ 0x00000080, { "TLT1 " }, 0 }, // Ride: Restroom
|
|
|
|
{ 0x00000080, { "ATM1 " }, 0 }, // Ride: Cash Machine
|
|
|
|
{ 0x00000080, { "FAID1 " }, 0 }, // Ride: First Aid Room
|
|
|
|
{ 0x00000080, { "INFOK " }, 0 }, // Ride: Information Kiosk
|
|
|
|
{ 0x00000080, { "DRNKS " }, 0 }, // Ride: Drinks Stall
|
2017-04-30 06:39:24 +02:00
|
|
|
{ 0x00000080, { "CNDYF " }, 0 }, // Ride: Cotton Candy Stall
|
2015-06-17 20:51:41 +02:00
|
|
|
{ 0x00000080, { "BURGB " }, 0 }, // Ride: Burger Bar
|
|
|
|
{ 0x00000080, { "BALLN " }, 0 }, // Ride: Balloon Stall
|
|
|
|
{ 0x00000080, { "ARRT1 " }, 0 }, // Ride: Corkscrew Roller Coaster
|
|
|
|
{ 0x00000080, { "RBOAT " }, 0 }, // Ride: Rowing Boats
|
2017-04-30 06:39:24 +02:00
|
|
|
{ 0x00000088, { "PKENT1 " }, 0 }, // Park Entrance: Traditional Park Entrance
|
2015-06-17 20:51:41 +02:00
|
|
|
{ 0x00000089, { "WTRCYAN " }, 0 }, // Water: Natural Water
|
|
|
|
{ 0x00000085, { "TARMACB " }, 0 }, // Footpath: Brown Tarmac Footpath
|
|
|
|
{ 0x00000085, { "PATHSPCE" }, 0 }, // Footpath: Space Style Footpath
|
|
|
|
{ 0x00000085, { "PATHDIRT" }, 0 }, // Footpath: Dirt Footpath
|
|
|
|
{ 0x00000085, { "PATHCRZY" }, 0 }, // Footpath: Crazy Paving Footpath
|
|
|
|
{ 0x00000085, { "PATHASH " }, 0 }, // Footpath: Ash Footpath
|
2015-02-13 19:43:22 +01:00
|
|
|
|
|
|
|
// The following are for all random map generation features to work out the box
|
|
|
|
{ 0x00000087, { "SCGJUNGL" }, 0 }, // Jungle Themeing
|
|
|
|
{ 0x00000087, { "SCGSNOW " }, 0 }, // Snow and Ice Themeing
|
|
|
|
{ 0x00000087, { "SCGWATER" }, 0 } // Water Feature Themeing
|
|
|
|
};
|
2015-02-13 04:29:40 +01:00
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
enum {
|
|
|
|
RIDE_SORT_TYPE,
|
|
|
|
RIDE_SORT_RIDE
|
|
|
|
};
|
2015-06-25 17:48:32 +02:00
|
|
|
|
2016-06-30 22:55:18 +02:00
|
|
|
enum {
|
|
|
|
DDIX_FILTER_RCT2,
|
|
|
|
DDIX_FILTER_WW,
|
|
|
|
DDIX_FILTER_TT,
|
|
|
|
DDIX_FILTER_CUSTOM,
|
|
|
|
DDIX_FILTER_SEPERATOR,
|
|
|
|
DDIX_FILTER_SELECTED,
|
|
|
|
DDIX_FILTER_NONSELECTED,
|
|
|
|
};
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct list_item {
|
2016-06-29 23:15:38 +02:00
|
|
|
const ObjectRepositoryItem * repositoryItem;
|
2015-06-25 17:48:32 +02:00
|
|
|
rct_object_entry *entry;
|
|
|
|
rct_object_filters *filter;
|
|
|
|
uint8 *flags;
|
|
|
|
} list_item;
|
|
|
|
|
2016-07-02 11:59:50 +02:00
|
|
|
static rct_string_id get_ride_type_string_id(const ObjectRepositoryItem * item);
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
typedef sint32(*sortFunc_t)(const void *, const void *);
|
2015-06-26 02:11:24 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 _numListItems = 0;
|
2015-06-25 17:48:32 +02:00
|
|
|
static list_item *_listItems = NULL;
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 _listSortType = RIDE_SORT_TYPE;
|
2015-06-26 02:11:24 +02:00
|
|
|
static bool _listSortDescending = false;
|
2016-06-30 22:55:18 +02:00
|
|
|
static void * _loadedObject = NULL;
|
2016-07-02 15:59:13 +02:00
|
|
|
static uint8 * _objectSelectionFlags = NULL;
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 _numSelectedObjectsForType[11];
|
|
|
|
static sint32 _numAvailableObjectsForType[11];
|
2016-07-02 15:59:13 +02:00
|
|
|
static bool _maxObjectsWasHit;
|
2015-06-25 17:48:32 +02:00
|
|
|
|
|
|
|
static void visible_list_dispose()
|
|
|
|
{
|
|
|
|
SafeFree(_listItems);
|
|
|
|
_numListItems = 0;
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 visible_list_sort_ride_name(const void *rawA, const void *rawB)
|
2015-06-26 02:11:24 +02:00
|
|
|
{
|
|
|
|
list_item *a = (list_item*)rawA;
|
|
|
|
list_item *b = (list_item*)rawB;
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
const char *nameA = a->repositoryItem->Name;
|
|
|
|
const char *nameB = b->repositoryItem->Name;
|
2015-06-26 02:11:24 +02:00
|
|
|
return strcmp(nameA, nameB);
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 visible_list_sort_ride_type(const void *rawA, const void *rawB)
|
2015-06-25 17:48:32 +02:00
|
|
|
{
|
|
|
|
list_item *a = (list_item*)rawA;
|
|
|
|
list_item *b = (list_item*)rawB;
|
|
|
|
|
2016-07-02 11:59:50 +02:00
|
|
|
const char *rideTypeA = language_get_string(get_ride_type_string_id(a->repositoryItem));
|
|
|
|
const char *rideTypeB = language_get_string(get_ride_type_string_id(b->repositoryItem));
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 result = strcmp(rideTypeA, rideTypeB);
|
2015-06-25 17:48:32 +02:00
|
|
|
if (result != 0)
|
|
|
|
return result;
|
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
return visible_list_sort_ride_name(rawA, rawB);
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void visible_list_refresh(rct_window *w)
|
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2015-06-25 17:48:32 +02:00
|
|
|
|
|
|
|
visible_list_dispose();
|
2016-07-03 22:05:18 +02:00
|
|
|
w->selected_list_item = -1;
|
2015-06-25 17:48:32 +02:00
|
|
|
_listItems = malloc(numObjects * sizeof(list_item));
|
|
|
|
_numListItems = 0;
|
|
|
|
|
|
|
|
list_item *currentListItem = &_listItems[0];
|
2016-06-29 23:15:38 +02:00
|
|
|
const ObjectRepositoryItem *items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 selectionFlags = _objectSelectionFlags[i];
|
2016-06-29 23:15:38 +02:00
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0x0F;
|
2016-07-02 15:59:13 +02:00
|
|
|
if (objectType == w->selected_tab && !(selectionFlags & OBJECT_SELECTION_FLAG_6) &&
|
2016-06-29 23:15:38 +02:00
|
|
|
filter_source(item) &&
|
|
|
|
filter_string(item) &&
|
|
|
|
filter_chunks(item) &&
|
2016-07-02 15:59:13 +02:00
|
|
|
filter_selected(selectionFlags)
|
2016-06-29 23:15:38 +02:00
|
|
|
) {
|
|
|
|
rct_object_filters * filter = calloc(1, sizeof(rct_object_filters));
|
|
|
|
currentListItem->repositoryItem = item;
|
|
|
|
currentListItem->entry = (rct_object_entry *)&item->ObjectEntry;
|
|
|
|
currentListItem->filter = filter;
|
2016-07-02 15:59:13 +02:00
|
|
|
currentListItem->flags = &_objectSelectionFlags[i];
|
2016-06-29 23:15:38 +02:00
|
|
|
currentListItem++;
|
|
|
|
_numListItems++;
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-12 23:11:31 +01:00
|
|
|
if (_numListItems == 0)
|
|
|
|
{
|
|
|
|
visible_list_dispose();
|
|
|
|
window_invalidate(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-12 23:20:27 +01:00
|
|
|
_listItems = realloc(_listItems, _numListItems * sizeof(list_item));
|
|
|
|
if (_listItems == NULL) {
|
|
|
|
_numListItems = 0;
|
2016-11-30 23:32:47 +01:00
|
|
|
log_error("Unable to reallocate list items");
|
2017-01-12 23:20:27 +01:00
|
|
|
} else {
|
2017-01-13 10:47:39 +01:00
|
|
|
sortFunc_t sortFunc = NULL;
|
2017-01-12 23:20:27 +01:00
|
|
|
switch (_listSortType) {
|
|
|
|
case RIDE_SORT_TYPE:
|
|
|
|
sortFunc = visible_list_sort_ride_type;
|
|
|
|
break;
|
|
|
|
case RIDE_SORT_RIDE:
|
|
|
|
sortFunc = visible_list_sort_ride_name;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log_warning("Wrong sort type %d, leaving list as-is.", _listSortType);
|
|
|
|
window_invalidate(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
qsort(_listItems, _numListItems, sizeof(list_item), sortFunc);
|
|
|
|
|
|
|
|
if (_listSortDescending) {
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < _numListItems / 2; i++) {
|
|
|
|
sint32 ri = _numListItems - i - 1;
|
2017-01-12 23:20:27 +01:00
|
|
|
list_item temp = _listItems[i];
|
|
|
|
_listItems[i] = _listItems[ri];
|
|
|
|
_listItems[ri] = temp;
|
|
|
|
}
|
2015-06-26 02:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
2015-06-25 17:48:32 +02:00
|
|
|
|
2014-11-23 17:28:23 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AA64E
|
|
|
|
*/
|
|
|
|
void window_editor_object_selection_open()
|
|
|
|
{
|
2014-11-25 00:05:35 +01:00
|
|
|
rct_window* window;
|
|
|
|
|
|
|
|
window = window_bring_to_front_by_class(WC_EDITOR_OBJECT_SELECTION);
|
|
|
|
if (window != NULL)
|
|
|
|
return;
|
|
|
|
|
2015-06-17 20:51:41 +02:00
|
|
|
if (!sub_6AB211())
|
|
|
|
return;
|
2015-06-15 21:17:40 +02:00
|
|
|
reset_selected_object_count_and_size();
|
2014-11-25 00:05:35 +01:00
|
|
|
|
2015-02-14 19:26:59 +01:00
|
|
|
window = window_create_centred(
|
2014-11-25 00:05:35 +01:00
|
|
|
600,
|
|
|
|
400,
|
2015-07-10 02:39:16 +02:00
|
|
|
&window_editor_object_selection_events,
|
2014-11-25 00:05:35 +01:00
|
|
|
WC_EDITOR_OBJECT_SELECTION,
|
2015-06-25 17:48:32 +02:00
|
|
|
WF_10 | WF_RESIZABLE
|
2014-11-25 00:05:35 +01:00
|
|
|
);
|
2016-07-14 14:07:49 +02:00
|
|
|
window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].string = _filter_string;
|
2015-02-11 17:02:57 +01:00
|
|
|
window->widgets = window_editor_object_selection_widgets;
|
2014-11-25 00:05:35 +01:00
|
|
|
|
|
|
|
window->enabled_widgets =
|
2015-06-26 02:11:24 +02:00
|
|
|
(1 << WIDX_ADVANCED) |
|
|
|
|
(1 << WIDX_INSTALL_TRACK) |
|
2015-06-03 18:37:07 +02:00
|
|
|
(1 << WIDX_FILTER_DROPDOWN) |
|
2015-06-06 00:54:47 +02:00
|
|
|
(1 << WIDX_FILTER_STRING_BUTTON) |
|
|
|
|
(1 << WIDX_FILTER_CLEAR_BUTTON) |
|
2015-06-26 02:11:24 +02:00
|
|
|
(1 << WIDX_CLOSE) |
|
|
|
|
(1 << WIDX_LIST_SORT_TYPE) |
|
2016-07-15 19:48:22 +02:00
|
|
|
(((uint32)1) << WIDX_LIST_SORT_RIDE);
|
2014-11-25 00:05:35 +01:00
|
|
|
|
2015-07-24 21:15:13 +02:00
|
|
|
_filter_flags = gConfigInterface.object_selection_filter_flags;
|
2015-06-06 00:54:47 +02:00
|
|
|
memset(_filter_string, 0, sizeof(_filter_string));
|
2015-06-03 18:37:07 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = WIDX_TAB_1; i <= WIDX_TAB_11; i++)
|
2014-11-25 00:05:35 +01:00
|
|
|
window->enabled_widgets |= (1LL << i);
|
|
|
|
window_init_scroll_widgets(window);
|
|
|
|
|
|
|
|
window->var_4AE = 0;
|
|
|
|
window->selected_tab = 0;
|
|
|
|
window->selected_list_item = -1;
|
2016-08-28 00:32:15 +02:00
|
|
|
window->object_entry = (rct_object_entry *)-1;
|
2015-06-25 17:48:32 +02:00
|
|
|
window->min_width = 600;
|
|
|
|
window->min_height = 400;
|
|
|
|
window->max_width = 1200;
|
|
|
|
window->max_height = 1000;
|
|
|
|
|
|
|
|
visible_list_refresh(window);
|
2014-11-25 00:05:35 +01:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006ABCD1
|
|
|
|
*/
|
2016-06-29 23:58:38 +02:00
|
|
|
static void setup_track_manager_objects()
|
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 * selectionFlags = &_objectSelectionFlags[i];
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
|
|
|
uint8 object_type = item->ObjectEntry.flags & 0xF;
|
2016-07-07 18:50:02 +02:00
|
|
|
if (object_type == OBJECT_TYPE_RIDE) {
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags |= OBJECT_SELECTION_FLAG_6;
|
2015-06-17 20:51:41 +02:00
|
|
|
|
2016-06-29 23:58:38 +02:00
|
|
|
for (uint8 j = 0; j < 3; j++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 rideType = item->RideType[j];
|
2016-07-07 18:50:02 +02:00
|
|
|
if (rideType != 0xFF && ride_type_has_flag(rideType, RIDE_TYPE_FLAG_HAS_TRACK)) {
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags &= ~OBJECT_SELECTION_FLAG_6;
|
2016-07-07 18:50:02 +02:00
|
|
|
break;
|
2015-06-17 20:51:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006ABC1E
|
|
|
|
*/
|
2016-06-29 23:58:38 +02:00
|
|
|
static void setup_track_designer_objects()
|
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 * selectionFlags = &_objectSelectionFlags[i];
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
|
|
|
if (objectType == OBJECT_TYPE_RIDE){
|
|
|
|
*selectionFlags |= OBJECT_SELECTION_FLAG_6;
|
2015-06-17 20:51:41 +02:00
|
|
|
|
2016-06-29 23:58:38 +02:00
|
|
|
for (uint8 j = 0; j < 3; j++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 rideType = item->RideType[j];
|
|
|
|
if (rideType != 0xFF) {
|
|
|
|
if (RideData4[rideType].flags & RIDE_TYPE_FLAG4_11) {
|
|
|
|
*selectionFlags &= ~OBJECT_SELECTION_FLAG_6;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-06-17 20:51:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AA82B
|
|
|
|
*/
|
2016-07-02 15:59:13 +02:00
|
|
|
static void setup_in_use_selection_flags()
|
|
|
|
{
|
2015-06-18 19:15:31 +02:00
|
|
|
for (uint8 object_type = 0; object_type < 11; object_type++){
|
|
|
|
for (uint16 i = 0; i < object_entry_group_counts[object_type]; i++){
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[object_type][i] = 0;
|
2015-06-18 19:15:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint8 object_type = 0; object_type < 11; object_type++){
|
|
|
|
for (uint16 i = 0; i < object_entry_group_counts[object_type]; i++){
|
2016-08-28 00:32:15 +02:00
|
|
|
if (object_entry_groups[object_type].chunks[i] != (uint8*)-1) {
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[object_type][i] |= (1 << 1);
|
2015-06-18 19:15:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
map_element_iterator iter;
|
|
|
|
map_element_iterator_begin(&iter);
|
|
|
|
do {
|
|
|
|
uint16 type;
|
|
|
|
rct_banner* banner;
|
|
|
|
|
|
|
|
switch (map_element_get_type(iter.element)) {
|
|
|
|
default:
|
|
|
|
case MAP_ELEMENT_TYPE_SURFACE:
|
|
|
|
case MAP_ELEMENT_TYPE_TRACK:
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_PATH:
|
|
|
|
type = iter.element->properties.path.type;
|
Fix variable not being shifted
When decompiled, at 0x6AA8ED, there's `shr edi,0x4`, which is not
reflected in sources.
The `type` without that shift could easily become a value large enough
to point to memory beyond object entries and modify those values. In my
case, it was modifying `RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS` from 2122 to
2123 (by setting lowest bit), which luckily, is used later in
`setup_in_use_selection_flags`. For this reason, I believe it could be a
major source of other problems, possibly also recent `MAP_ANIMATION`
ones, although I haven't checked.
I also put an assert in place to validate type against max available
count.
2015-11-01 18:44:16 +01:00
|
|
|
type >>= 4;
|
|
|
|
assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_PATHS][type] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
|
2015-12-05 00:08:34 +01:00
|
|
|
if (footpath_element_has_path_scenery(iter.element)) {
|
|
|
|
uint8 path_additions = footpath_element_get_path_scenery_index(iter.element);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_PATH_BITS][path_additions] |= 1;
|
2015-06-18 19:15:31 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY:
|
|
|
|
type = iter.element->properties.scenery.type;
|
Fix variable not being shifted
When decompiled, at 0x6AA8ED, there's `shr edi,0x4`, which is not
reflected in sources.
The `type` without that shift could easily become a value large enough
to point to memory beyond object entries and modify those values. In my
case, it was modifying `RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS` from 2122 to
2123 (by setting lowest bit), which luckily, is used later in
`setup_in_use_selection_flags`. For this reason, I believe it could be a
major source of other problems, possibly also recent `MAP_ANIMATION`
ones, although I haven't checked.
I also put an assert in place to validate type against max available
count.
2015-11-01 18:44:16 +01:00
|
|
|
assert(type < object_entry_group_counts[OBJECT_TYPE_SMALL_SCENERY]);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_SMALL_SCENERY][type] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_ENTRANCE:
|
|
|
|
if (iter.element->properties.entrance.type != ENTRANCE_TYPE_PARK_ENTRANCE)
|
|
|
|
break;
|
|
|
|
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_PARK_ENTRANCE][0] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
|
|
|
|
type = iter.element->properties.entrance.path_type;
|
Fix variable not being shifted
When decompiled, at 0x6AA8ED, there's `shr edi,0x4`, which is not
reflected in sources.
The `type` without that shift could easily become a value large enough
to point to memory beyond object entries and modify those values. In my
case, it was modifying `RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS` from 2122 to
2123 (by setting lowest bit), which luckily, is used later in
`setup_in_use_selection_flags`. For this reason, I believe it could be a
major source of other problems, possibly also recent `MAP_ANIMATION`
ones, although I haven't checked.
I also put an assert in place to validate type against max available
count.
2015-11-01 18:44:16 +01:00
|
|
|
assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_PATHS][type] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
break;
|
2017-02-20 22:02:19 +01:00
|
|
|
case MAP_ELEMENT_TYPE_WALL:
|
2017-02-20 22:10:49 +01:00
|
|
|
type = iter.element->properties.wall.type;
|
Fix variable not being shifted
When decompiled, at 0x6AA8ED, there's `shr edi,0x4`, which is not
reflected in sources.
The `type` without that shift could easily become a value large enough
to point to memory beyond object entries and modify those values. In my
case, it was modifying `RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS` from 2122 to
2123 (by setting lowest bit), which luckily, is used later in
`setup_in_use_selection_flags`. For this reason, I believe it could be a
major source of other problems, possibly also recent `MAP_ANIMATION`
ones, although I haven't checked.
I also put an assert in place to validate type against max available
count.
2015-11-01 18:44:16 +01:00
|
|
|
assert(type < object_entry_group_counts[OBJECT_TYPE_WALLS]);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_WALLS][type] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
|
|
|
|
type = iter.element->properties.scenerymultiple.type & 0x3FF;
|
Fix variable not being shifted
When decompiled, at 0x6AA8ED, there's `shr edi,0x4`, which is not
reflected in sources.
The `type` without that shift could easily become a value large enough
to point to memory beyond object entries and modify those values. In my
case, it was modifying `RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS` from 2122 to
2123 (by setting lowest bit), which luckily, is used later in
`setup_in_use_selection_flags`. For this reason, I believe it could be a
major source of other problems, possibly also recent `MAP_ANIMATION`
ones, although I haven't checked.
I also put an assert in place to validate type against max available
count.
2015-11-01 18:44:16 +01:00
|
|
|
assert(type < object_entry_group_counts[OBJECT_TYPE_LARGE_SCENERY]);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_LARGE_SCENERY][type] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_BANNER:
|
|
|
|
banner = &gBanners[iter.element->properties.banner.index];
|
|
|
|
type = banner->type;
|
Fix variable not being shifted
When decompiled, at 0x6AA8ED, there's `shr edi,0x4`, which is not
reflected in sources.
The `type` without that shift could easily become a value large enough
to point to memory beyond object entries and modify those values. In my
case, it was modifying `RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS` from 2122 to
2123 (by setting lowest bit), which luckily, is used later in
`setup_in_use_selection_flags`. For this reason, I believe it could be a
major source of other problems, possibly also recent `MAP_ANIMATION`
ones, although I haven't checked.
I also put an assert in place to validate type against max available
count.
2015-11-01 18:44:16 +01:00
|
|
|
assert(type < object_entry_group_counts[OBJECT_TYPE_BANNERS]);
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_BANNERS][type] |= (1 << 0);
|
2015-06-18 19:15:31 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (map_element_iterator_next(&iter));
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
for (uint8 ride_index = 0; ride_index < 0xFF; ride_index++) {
|
2016-01-22 15:38:52 +01:00
|
|
|
rct_ride* ride = get_ride(ride_index);
|
2016-07-02 15:59:13 +02:00
|
|
|
if (ride->type != RIDE_TYPE_NULL) {
|
|
|
|
uint8 type = ride->subtype;
|
2016-09-05 23:26:02 +02:00
|
|
|
gEditorSelectedObjects[OBJECT_TYPE_RIDE][type] |= (1 << 0);
|
2016-07-02 15:59:13 +02:00
|
|
|
}
|
2015-06-18 19:15:31 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 *selectionFlags = &_objectSelectionFlags[i];
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags &= ~OBJECT_SELECTION_FLAG_IN_USE;
|
2015-06-18 19:15:31 +02:00
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 entryType, entryIndex;
|
|
|
|
if (find_object_in_entry_group(&item->ObjectEntry, &entryType, &entryIndex)) {
|
2016-09-05 23:26:02 +02:00
|
|
|
if (gEditorSelectedObjects[entryType][entryIndex] & (1 << 0)) {
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags |=
|
2015-10-20 20:16:30 +02:00
|
|
|
OBJECT_SELECTION_FLAG_IN_USE |
|
2015-06-18 19:15:31 +02:00
|
|
|
OBJECT_SELECTION_FLAG_SELECTED;
|
|
|
|
}
|
2016-09-05 23:26:02 +02:00
|
|
|
if (gEditorSelectedObjects[entryType][entryIndex] & (1 << 1)) {
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags |= OBJECT_SELECTION_FLAG_SELECTED;
|
2015-06-18 19:15:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AB211
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 sub_6AB211()
|
2016-06-29 23:58:38 +02:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-07-02 15:59:13 +02:00
|
|
|
_objectSelectionFlags = (uint8*)calloc(numObjects, sizeof(uint8));
|
|
|
|
if (_objectSelectionFlags == NULL){
|
2015-06-16 19:00:47 +02:00
|
|
|
log_error("Failed to allocate memory for object flag list.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
for (uint8 objectType = 0; objectType < 11; objectType++) {
|
|
|
|
_numSelectedObjectsForType[objectType] = 0;
|
|
|
|
_numAvailableObjectsForType[objectType] = 0;
|
2015-06-16 19:00:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 objectType = items[i].ObjectEntry.flags & 0xF;
|
|
|
|
_numAvailableObjectsForType[objectType]++;
|
2015-06-16 19:00:47 +02:00
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) {
|
2015-06-17 20:51:41 +02:00
|
|
|
setup_track_designer_objects();
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2015-06-17 20:51:41 +02:00
|
|
|
setup_track_manager_objects();
|
|
|
|
}
|
|
|
|
|
2015-06-18 19:15:31 +02:00
|
|
|
setup_in_use_selection_flags();
|
2015-06-17 20:51:41 +02:00
|
|
|
reset_selected_object_count_and_size();
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
|
2015-06-17 20:51:41 +02:00
|
|
|
window_editor_object_selection_select_required_objects();
|
|
|
|
|
|
|
|
// To prevent it breaking in scenario mode.
|
2016-07-02 15:59:13 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) {
|
2015-06-17 20:51:41 +02:00
|
|
|
window_editor_object_selection_select_default_objects();
|
2016-07-02 15:59:13 +02:00
|
|
|
}
|
2015-06-17 20:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
reset_selected_object_count_and_size();
|
|
|
|
return 1;
|
2015-06-16 19:00:47 +02:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AB316
|
|
|
|
*/
|
2016-01-14 21:18:55 +01:00
|
|
|
static void editor_object_flags_free()
|
|
|
|
{
|
2016-07-02 15:59:13 +02:00
|
|
|
SafeFree(_objectSelectionFlags);
|
2015-06-17 21:06:42 +02:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685791
|
|
|
|
*/
|
2016-07-13 00:46:51 +02:00
|
|
|
static void remove_selected_objects_from_research(const rct_object_entry* installedObject){
|
2015-06-19 20:11:23 +02:00
|
|
|
uint8 entry_type, entry_index;
|
2015-06-19 22:33:37 +02:00
|
|
|
if (!find_object_in_entry_group(installedObject, &entry_type, &entry_index))
|
2015-06-19 20:11:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (entry_type == OBJECT_TYPE_RIDE){
|
2016-02-25 13:33:19 +01:00
|
|
|
rct_ride_entry* rideEntry = (rct_ride_entry*)object_entry_groups[entry_type].chunks[entry_index];
|
2015-06-19 22:33:37 +02:00
|
|
|
research_remove(entry_index | rideEntry->ride_type[0] << 8 | 0x10000);
|
|
|
|
research_remove(entry_index | rideEntry->ride_type[1] << 8 | 0x10000);
|
|
|
|
research_remove(entry_index | rideEntry->ride_type[2] << 8 | 0x10000);
|
2015-06-19 20:11:23 +02:00
|
|
|
}
|
|
|
|
else if (entry_type == OBJECT_TYPE_SCENERY_SETS){
|
2015-06-19 22:33:37 +02:00
|
|
|
research_remove(entry_index);
|
2015-06-19 20:11:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006ABB66
|
|
|
|
*/
|
2016-07-13 00:46:51 +02:00
|
|
|
static void unload_unselected_objects()
|
2016-06-29 23:58:38 +02:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numItems = (sint32)object_repository_get_items_count();
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2016-07-06 23:31:14 +02:00
|
|
|
|
|
|
|
size_t numObjectsToUnload = 0;
|
|
|
|
rct_object_entry * objectsToUnload = (rct_object_entry *)malloc(numItems * sizeof(rct_object_entry));
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numItems; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
if (!(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED)) {
|
2016-07-06 23:31:14 +02:00
|
|
|
const rct_object_entry * entry = &items[i].ObjectEntry;
|
|
|
|
|
|
|
|
remove_selected_objects_from_research(entry);
|
|
|
|
objectsToUnload[numObjectsToUnload++] = *entry;
|
2015-06-19 20:11:23 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-06 23:31:14 +02:00
|
|
|
|
|
|
|
object_manager_unload_objects(objectsToUnload, numObjectsToUnload);
|
|
|
|
free(objectsToUnload);
|
2015-06-19 20:11:23 +02:00
|
|
|
}
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AB199
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_close(rct_window *w)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2016-04-23 12:16:46 +02:00
|
|
|
//if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
|
2015-05-23 20:56:54 +02:00
|
|
|
// return;
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2015-06-21 12:38:58 +02:00
|
|
|
unload_unselected_objects();
|
2015-02-11 17:02:57 +01:00
|
|
|
editor_load_selected_objects();
|
2015-06-17 21:06:42 +02:00
|
|
|
editor_object_flags_free();
|
|
|
|
|
2016-07-02 19:01:51 +02:00
|
|
|
object_delete(_loadedObject);
|
|
|
|
_loadedObject = NULL;
|
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_EDITOR) {
|
2015-05-23 20:56:54 +02:00
|
|
|
research_populate_list_random();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Used for in-game object selection cheat
|
2016-05-28 10:30:31 +02:00
|
|
|
// This resets the ride selection list and resets research to 0 on current item
|
2015-05-23 20:56:54 +02:00
|
|
|
gSilentResearch = true;
|
|
|
|
sub_684AC3();
|
|
|
|
gSilentResearch = false;
|
|
|
|
}
|
2016-03-30 21:37:42 +02:00
|
|
|
research_remove_non_separate_vehicle_types();
|
2015-02-11 17:02:57 +01:00
|
|
|
window_new_ride_init_vars();
|
2015-06-25 17:48:32 +02:00
|
|
|
|
|
|
|
visible_list_dispose();
|
2015-02-11 17:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AAFAB
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_mouseup(rct_window *w, sint32 widgetIndex)
|
2014-11-25 00:05:35 +01:00
|
|
|
{
|
|
|
|
switch (widgetIndex) {
|
2015-02-11 17:02:57 +01:00
|
|
|
case WIDX_CLOSE:
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_EDITOR) {
|
2015-05-23 20:56:54 +02:00
|
|
|
game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 1, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Used for in-game object selection cheat
|
|
|
|
window_close(w);
|
|
|
|
}
|
2014-11-25 00:05:35 +01:00
|
|
|
break;
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
case WIDX_TAB_1:
|
|
|
|
case WIDX_TAB_2:
|
|
|
|
case WIDX_TAB_3:
|
|
|
|
case WIDX_TAB_4:
|
|
|
|
case WIDX_TAB_5:
|
|
|
|
case WIDX_TAB_6:
|
|
|
|
case WIDX_TAB_7:
|
|
|
|
case WIDX_TAB_8:
|
|
|
|
case WIDX_TAB_9:
|
|
|
|
case WIDX_TAB_10:
|
|
|
|
case WIDX_TAB_11:
|
|
|
|
window_editor_object_set_page(w, widgetIndex - WIDX_TAB_1);
|
2014-11-25 00:05:35 +01:00
|
|
|
break;
|
2015-06-14 18:19:54 +02:00
|
|
|
case WIDX_FILTER_RIDE_TAB_ALL:
|
2017-02-16 19:35:59 +01:00
|
|
|
_filter_flags |= FILTER_RIDES;
|
2015-07-24 21:15:13 +02:00
|
|
|
gConfigInterface.object_selection_filter_flags = _filter_flags;
|
|
|
|
config_save_default();
|
|
|
|
|
2015-06-14 18:19:54 +02:00
|
|
|
filter_update_counts();
|
2015-06-26 02:11:24 +02:00
|
|
|
visible_list_refresh(w);
|
2015-06-14 18:19:54 +02:00
|
|
|
|
2015-06-14 20:43:01 +02:00
|
|
|
w->selected_list_item = -1;
|
2016-08-28 00:32:15 +02:00
|
|
|
w->object_entry = (rct_object_entry *)-1;
|
2015-06-14 20:43:01 +02:00
|
|
|
w->scrolls[0].v_top = 0;
|
2015-06-14 18:19:54 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
case WIDX_FILTER_RIDE_TAB_TRANSPORT:
|
|
|
|
case WIDX_FILTER_RIDE_TAB_GENTLE:
|
|
|
|
case WIDX_FILTER_RIDE_TAB_COASTER:
|
|
|
|
case WIDX_FILTER_RIDE_TAB_THRILL:
|
|
|
|
case WIDX_FILTER_RIDE_TAB_WATER:
|
|
|
|
case WIDX_FILTER_RIDE_TAB_STALL:
|
2017-02-16 19:35:59 +01:00
|
|
|
_filter_flags &= ~FILTER_RIDES;
|
2015-06-14 18:19:54 +02:00
|
|
|
_filter_flags |= (1 << (widgetIndex - WIDX_FILTER_RIDE_TAB_TRANSPORT + 5));
|
2015-07-24 21:15:13 +02:00
|
|
|
gConfigInterface.object_selection_filter_flags = _filter_flags;
|
|
|
|
config_save_default();
|
2015-06-14 18:19:54 +02:00
|
|
|
|
|
|
|
filter_update_counts();
|
2015-06-25 17:48:32 +02:00
|
|
|
visible_list_refresh(w);
|
2015-06-14 18:19:54 +02:00
|
|
|
|
2015-06-14 20:47:08 +02:00
|
|
|
w->selected_list_item = -1;
|
2016-08-28 00:32:15 +02:00
|
|
|
w->object_entry = (rct_object_entry *)-1;
|
2015-06-14 20:47:08 +02:00
|
|
|
w->scrolls[0].v_top = 0;
|
2017-02-04 12:30:15 +01:00
|
|
|
w->frame_no = 0;
|
2015-06-14 18:19:54 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
2014-11-25 00:05:35 +01:00
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
case WIDX_ADVANCED:
|
2014-11-25 00:05:35 +01:00
|
|
|
w->list_information_type ^= 1;
|
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
case WIDX_INSTALL_TRACK:
|
2014-11-25 00:05:35 +01:00
|
|
|
if (w->selected_list_item != -1) {
|
|
|
|
w->selected_list_item = -1;
|
|
|
|
}
|
|
|
|
window_invalidate(w);
|
|
|
|
|
2015-06-08 00:12:17 +02:00
|
|
|
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK, NULL);
|
2014-11-25 00:05:35 +01:00
|
|
|
break;
|
2015-06-06 00:54:47 +02:00
|
|
|
case WIDX_FILTER_STRING_BUTTON:
|
2016-07-14 14:07:49 +02:00
|
|
|
//window_text_input_open(w, widgetIndex, STR_OBJECT_SEARCH, STR_OBJECT_SEARCH_DESC, STR_STRING, (uint32)_filter_string, 40);
|
2016-07-30 20:49:07 +02:00
|
|
|
window_start_textbox(w, widgetIndex, STR_STRING, _filter_string, 40);
|
2015-06-06 00:54:47 +02:00
|
|
|
break;
|
|
|
|
case WIDX_FILTER_CLEAR_BUTTON:
|
|
|
|
memset(_filter_string, 0, sizeof(_filter_string));
|
2015-11-19 00:19:25 +01:00
|
|
|
filter_update_counts();
|
2015-06-06 01:02:20 +02:00
|
|
|
w->scrolls->v_top = 0;
|
2015-11-19 00:19:25 +01:00
|
|
|
visible_list_refresh(w);
|
2015-06-06 00:54:47 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
2015-06-26 02:11:24 +02:00
|
|
|
case WIDX_LIST_SORT_TYPE:
|
|
|
|
if (_listSortType == RIDE_SORT_TYPE) {
|
|
|
|
_listSortDescending = !_listSortDescending;
|
|
|
|
} else {
|
|
|
|
_listSortType = RIDE_SORT_TYPE;
|
|
|
|
_listSortDescending = false;
|
|
|
|
}
|
|
|
|
visible_list_refresh(w);
|
|
|
|
break;
|
|
|
|
case WIDX_LIST_SORT_RIDE:
|
|
|
|
if (_listSortType == RIDE_SORT_RIDE) {
|
|
|
|
_listSortDescending = !_listSortDescending;
|
|
|
|
} else {
|
|
|
|
_listSortType = RIDE_SORT_RIDE;
|
|
|
|
_listSortDescending = false;
|
|
|
|
}
|
|
|
|
visible_list_refresh(w);
|
|
|
|
break;
|
2014-11-25 00:05:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_resize(rct_window *w)
|
2015-06-25 17:48:32 +02:00
|
|
|
{
|
|
|
|
window_set_resize(w, 600, 400, 1200, 1000);
|
|
|
|
}
|
2016-06-30 22:55:18 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
void window_editor_object_selection_mousedown(sint32 widgetIndex, rct_window*w, rct_widget* widget)
|
2015-06-03 18:37:07 +02:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 num_items;
|
2015-06-03 18:37:07 +02:00
|
|
|
|
|
|
|
//widget = &w->widgets[widgetIndex - 1];
|
|
|
|
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_FILTER_DROPDOWN:
|
|
|
|
|
2016-06-21 16:16:51 +02:00
|
|
|
num_items = 4;
|
2016-07-14 14:07:49 +02:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_RCT2] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_WW] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_TT] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_CUSTOM] = STR_TOGGLE_OPTION;
|
2016-06-27 19:32:43 +02:00
|
|
|
gDropdownItemsArgs[DDIX_FILTER_RCT2] = STR_ROLLERCOASTER_TYCOON_2_DROPDOWN;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_WW] = STR_OBJECT_FILTER_WW;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_TT] = STR_OBJECT_FILTER_TT;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_CUSTOM] = STR_OBJECT_FILTER_CUSTOM;
|
2016-06-21 20:30:07 +02:00
|
|
|
//Track manager cannot select multiple, so only show selection filters if not in track manager
|
2016-06-21 16:16:51 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
|
|
|
num_items = 7;
|
2016-06-27 19:32:43 +02:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_SEPERATOR] = 0;
|
2016-07-14 14:07:49 +02:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_SELECTED] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_NONSELECTED] = STR_TOGGLE_OPTION;
|
2016-06-27 19:32:43 +02:00
|
|
|
gDropdownItemsArgs[DDIX_FILTER_SEPERATOR] = STR_NONE;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_SELECTED] = STR_SELECTED_ONLY;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_NONSELECTED] = STR_NON_SELECTED_ONLY;
|
2016-06-21 16:16:51 +02:00
|
|
|
}
|
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
window_dropdown_show_text(
|
|
|
|
w->x + widget->left,
|
|
|
|
w->y + widget->top,
|
|
|
|
widget->bottom - widget->top + 1,
|
|
|
|
w->colours[widget->colour],
|
|
|
|
DROPDOWN_FLAG_STAY_OPEN,
|
|
|
|
num_items
|
|
|
|
);
|
|
|
|
|
2015-06-14 18:19:54 +02:00
|
|
|
gDropdownItemsChecked = _filter_flags & 0xF;
|
2016-06-21 16:16:51 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
2016-06-27 19:32:43 +02:00
|
|
|
dropdown_set_checked(DDIX_FILTER_SELECTED, _FILTER_SELECTED);
|
|
|
|
dropdown_set_checked(DDIX_FILTER_NONSELECTED, _FILTER_NONSELECTED);
|
2016-06-21 16:16:51 +02:00
|
|
|
}
|
2015-06-03 18:37:07 +02:00
|
|
|
break;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_dropdown(rct_window *w, sint32 widgetIndex, sint32 dropdownIndex)
|
2015-06-03 18:37:07 +02:00
|
|
|
{
|
|
|
|
if (dropdownIndex == -1)
|
|
|
|
return;
|
2015-07-10 02:39:16 +02:00
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_FILTER_DROPDOWN:
|
2016-06-27 19:32:43 +02:00
|
|
|
if (dropdownIndex == DDIX_FILTER_SELECTED) {
|
2016-06-21 20:41:07 +02:00
|
|
|
_filter_flags ^= FILTER_SELECTED;
|
|
|
|
_filter_flags &= ~FILTER_NONSELECTED;
|
2016-06-17 10:46:30 +02:00
|
|
|
}
|
2016-06-27 19:32:43 +02:00
|
|
|
else if (dropdownIndex == DDIX_FILTER_NONSELECTED) {
|
2016-06-21 20:41:07 +02:00
|
|
|
_filter_flags ^= FILTER_NONSELECTED;
|
|
|
|
_filter_flags &= ~FILTER_SELECTED;
|
2016-06-17 10:46:30 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
_filter_flags ^= (1 << dropdownIndex);
|
|
|
|
}
|
2016-06-21 20:30:07 +02:00
|
|
|
gConfigInterface.object_selection_filter_flags = _filter_flags;
|
2015-07-24 21:15:13 +02:00
|
|
|
config_save_default();
|
2015-06-03 18:37:07 +02:00
|
|
|
|
2015-06-06 00:54:47 +02:00
|
|
|
filter_update_counts();
|
2015-06-03 18:37:07 +02:00
|
|
|
w->scrolls->v_top = 0;
|
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
visible_list_refresh(w);
|
2015-06-03 18:37:07 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AB031
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2015-07-10 02:39:16 +02:00
|
|
|
*height = _numListItems * 12;
|
2015-02-11 17:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AB0B6
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_scroll_mousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2015-05-23 20:56:54 +02:00
|
|
|
// Used for in-game object selection cheat to prevent crashing the game
|
|
|
|
// when windows attempt to draw objects that don't exist any more
|
|
|
|
window_close_all_except_class(WC_EDITOR_OBJECT_SELECTION);
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 selected_object = get_object_from_object_selection((w->selected_tab & 0xFF), y);
|
2016-06-30 22:55:18 +02:00
|
|
|
if (selected_object == -1)
|
|
|
|
return;
|
2016-06-30 22:07:32 +02:00
|
|
|
|
|
|
|
list_item * listItem = &_listItems[selected_object];
|
|
|
|
uint8 object_selection_flags = *listItem->flags;
|
2016-06-30 22:55:18 +02:00
|
|
|
if (object_selection_flags & OBJECT_SELECTION_FLAG_6)
|
2015-02-11 17:02:57 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
window_invalidate(w);
|
|
|
|
|
2016-09-05 23:37:57 +02:00
|
|
|
audio_play_sound_panned(SOUND_CLICK_1, gCursorState.x, 0, 0, 0);
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2015-05-23 20:56:54 +02:00
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-06-30 22:07:32 +02:00
|
|
|
if (!window_editor_object_selection_select_object(0, 1, listItem->entry))
|
2015-02-11 22:03:23 +01:00
|
|
|
return;
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2015-05-29 18:04:53 +02:00
|
|
|
// Close any other open windows such as options/colour schemes to prevent a crash.
|
|
|
|
window_close_all();
|
|
|
|
//window_close(w);
|
2015-02-11 17:02:57 +01:00
|
|
|
|
|
|
|
//This function calls window_track_list_open
|
2015-02-13 19:43:22 +01:00
|
|
|
window_editor_object_selection_manage_tracks();
|
2015-02-11 17:02:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 ebx = 6;
|
2015-02-11 17:02:57 +01:00
|
|
|
// If already selected
|
2015-06-15 21:52:04 +02:00
|
|
|
if (!(object_selection_flags & OBJECT_SELECTION_FLAG_SELECTED))
|
2015-02-11 17:02:57 +01:00
|
|
|
ebx = 7;
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
_maxObjectsWasHit = false;
|
2016-06-30 22:07:32 +02:00
|
|
|
if (!window_editor_object_selection_select_object(0, ebx, listItem->entry)) {
|
2016-11-30 23:32:47 +01:00
|
|
|
rct_string_id error_title = (ebx & 1) ?
|
2015-02-13 19:43:22 +01:00
|
|
|
STR_UNABLE_TO_SELECT_THIS_OBJECT :
|
|
|
|
STR_UNABLE_TO_DE_SELECT_THIS_OBJECT;
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2016-04-15 18:54:46 +02:00
|
|
|
window_error_open(error_title, gGameCommandErrorText);
|
2015-02-11 17:02:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-21 20:41:07 +02:00
|
|
|
if (_FILTER_SELECTED || _FILTER_NONSELECTED) {
|
2016-06-17 10:46:30 +02:00
|
|
|
filter_update_counts();
|
|
|
|
visible_list_refresh(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
if (_maxObjectsWasHit) {
|
|
|
|
window_error_open(STR_WARNING_TOO_MANY_OBJECTS_SELECTED, STR_NOT_ALL_OBJECTS_IN_THIS_SCENERY_GROUP_COULD_BE_SELECTED);
|
|
|
|
}
|
2015-02-11 17:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AB079
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_scroll_mouseover(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 selectedObject = get_object_from_object_selection(w->selected_tab & 0xFF, y);
|
2016-06-30 22:55:18 +02:00
|
|
|
if (selectedObject != -1) {
|
|
|
|
list_item * listItem = &_listItems[selectedObject];
|
|
|
|
uint8 objectSelectionFlags = *listItem->flags;
|
|
|
|
if (objectSelectionFlags & OBJECT_SELECTION_FLAG_6) {
|
|
|
|
selectedObject = -1;
|
|
|
|
}
|
2016-06-30 22:07:32 +02:00
|
|
|
}
|
|
|
|
if (selectedObject != w->selected_list_item) {
|
|
|
|
w->selected_list_item = selectedObject;
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2016-07-02 19:01:51 +02:00
|
|
|
object_delete(_loadedObject);
|
|
|
|
_loadedObject = NULL;
|
2016-06-30 22:55:18 +02:00
|
|
|
|
|
|
|
list_item * listItem = &_listItems[selectedObject];
|
|
|
|
if (selectedObject == -1) {
|
|
|
|
w->object_entry = NULL;
|
|
|
|
} else {
|
|
|
|
w->object_entry = listItem->entry;
|
|
|
|
_loadedObject = object_repository_load_object(listItem->entry);
|
2016-06-30 22:07:32 +02:00
|
|
|
}
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2016-06-30 22:07:32 +02:00
|
|
|
window_invalidate(w);
|
|
|
|
}
|
2015-02-11 17:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AB058
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_tooltip(rct_window* w, sint32 widgetIndex, rct_string_id *stringId)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_TAB_1:
|
|
|
|
case WIDX_TAB_2:
|
|
|
|
case WIDX_TAB_3:
|
|
|
|
case WIDX_TAB_4:
|
|
|
|
case WIDX_TAB_5:
|
|
|
|
case WIDX_TAB_6:
|
|
|
|
case WIDX_TAB_7:
|
|
|
|
case WIDX_TAB_8:
|
|
|
|
case WIDX_TAB_9:
|
|
|
|
case WIDX_TAB_10:
|
|
|
|
case WIDX_TAB_11:
|
2016-07-14 14:07:49 +02:00
|
|
|
set_format_arg(0, rct_string_id, ObjectSelectionPageNames[(widgetIndex - WIDX_TAB_1)]);
|
2015-02-11 17:02:57 +01:00
|
|
|
break;
|
|
|
|
default:
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(0, rct_string_id, STR_LIST);
|
2015-02-11 17:02:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006AA9FD
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_invalidate(rct_window *w)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2015-05-29 18:04:53 +02:00
|
|
|
colour_scheme_update(w);
|
2015-02-11 17:02:57 +01:00
|
|
|
|
2015-06-25 17:48:32 +02:00
|
|
|
// Resize widgets
|
|
|
|
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
|
|
|
w->widgets[WIDX_TITLE].right = w->width - 2;
|
|
|
|
w->widgets[WIDX_CLOSE].left = w->width - 13;
|
|
|
|
w->widgets[WIDX_CLOSE].right = w->width - 3;
|
|
|
|
w->widgets[WIDX_TAB_CONTENT_PANEL].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_TAB_CONTENT_PANEL].bottom = w->height - 1;
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_ADVANCED].left = w->width - 130;
|
|
|
|
w->widgets[WIDX_ADVANCED].right = w->width - 9;
|
2015-06-25 17:48:32 +02:00
|
|
|
w->widgets[WIDX_LIST].right = w->width - 309;
|
|
|
|
w->widgets[WIDX_LIST].bottom = w->height - 14;
|
|
|
|
w->widgets[WIDX_PREVIEW].left = w->width - 209;
|
|
|
|
w->widgets[WIDX_PREVIEW].right = w->width - 96;
|
2015-09-11 16:21:27 +02:00
|
|
|
w->widgets[WIDX_INSTALL_TRACK].left = w->width - 130;
|
|
|
|
w->widgets[WIDX_INSTALL_TRACK].right = w->width - 9;
|
2015-06-25 17:48:32 +02:00
|
|
|
w->widgets[WIDX_FILTER_DROPDOWN].left = w->width - 250;
|
|
|
|
w->widgets[WIDX_FILTER_DROPDOWN].right = w->width - 137;
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
// Set pressed widgets
|
|
|
|
w->pressed_widgets |= 1 << WIDX_PREVIEW;
|
|
|
|
window_editor_object_selection_set_pressed_tab(w);
|
|
|
|
if (w->list_information_type & 1)
|
2015-06-26 02:11:24 +02:00
|
|
|
w->pressed_widgets |= (1 << WIDX_ADVANCED);
|
2015-02-11 17:02:57 +01:00
|
|
|
else
|
2015-06-26 02:11:24 +02:00
|
|
|
w->pressed_widgets &= ~(1 << WIDX_ADVANCED);
|
2015-02-11 17:02:57 +01:00
|
|
|
|
|
|
|
// Set window title and buttons
|
2016-07-14 14:07:49 +02:00
|
|
|
set_format_arg(0, rct_string_id, ObjectSelectionPageNames[w->selected_tab]);
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-07-14 14:07:49 +02:00
|
|
|
w->widgets[WIDX_TITLE].text = STR_TRACK_DESIGNS_MANAGER_SELECT_RIDE_TYPE;
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_INSTALL_TRACK].type = WWT_DROPDOWN_BUTTON;
|
2016-04-23 12:16:46 +02:00
|
|
|
} else if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) {
|
2016-07-14 14:07:49 +02:00
|
|
|
w->widgets[WIDX_TITLE].text = STR_ROLLER_COASTER_DESIGNER_SELECT_RIDE_TYPES_VEHICLES;
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_INSTALL_TRACK].type = WWT_EMPTY;
|
2015-02-11 17:02:57 +01:00
|
|
|
} else {
|
2016-07-14 14:07:49 +02:00
|
|
|
w->widgets[WIDX_TITLE].text = STR_OBJECT_SELECTION;
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_INSTALL_TRACK].type = WWT_EMPTY;
|
2015-02-11 17:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Align tabs, hide advanced ones
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 x = 3;
|
|
|
|
for (sint32 i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) {
|
2016-11-30 23:32:47 +01:00
|
|
|
rct_widget *widget = &w->widgets[WIDX_TAB_1 + i];
|
2015-02-11 17:02:57 +01:00
|
|
|
|
|
|
|
if (!(w->list_information_type & 1) && ((1 << i) & 0x5E)) {
|
|
|
|
widget->type = WWT_EMPTY;
|
|
|
|
} else {
|
|
|
|
widget->type = WWT_TAB;
|
|
|
|
widget->left = x;
|
|
|
|
widget->right = x + 30;
|
|
|
|
x += 31;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TRACK_DESIGNER)) {
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_ADVANCED].type = WWT_EMPTY;
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 1; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++)
|
2015-02-11 17:02:57 +01:00
|
|
|
w->widgets[WIDX_TAB_1 + i].type = WWT_EMPTY;
|
|
|
|
x = 150;
|
|
|
|
} else {
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_ADVANCED].type = WWT_DROPDOWN_BUTTON;
|
2015-02-11 17:02:57 +01:00
|
|
|
x = 300;
|
|
|
|
}
|
|
|
|
|
2015-09-11 16:21:27 +02:00
|
|
|
w->widgets[WIDX_FILTER_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
|
2015-06-25 17:48:32 +02:00
|
|
|
w->widgets[WIDX_LIST].right = w->width - (600 - 587) - x;
|
|
|
|
w->widgets[WIDX_PREVIEW].left = w->width - (600 - 537) - (x / 2);
|
2015-02-11 17:02:57 +01:00
|
|
|
w->widgets[WIDX_PREVIEW].right = w->widgets[WIDX_PREVIEW].left + 113;
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_FILTER_RIDE_TAB_FRAME].right = w->widgets[WIDX_LIST].right;
|
2015-06-14 18:19:54 +02:00
|
|
|
|
|
|
|
bool ridePage = (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS);
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_LIST].top = (ridePage ? 118 : 60);
|
|
|
|
w->widgets[WIDX_FILTER_STRING_BUTTON].right = w->widgets[WIDX_LIST].right - 77;
|
2015-06-14 18:19:54 +02:00
|
|
|
w->widgets[WIDX_FILTER_STRING_BUTTON].top = (ridePage ? 80 : 46);
|
|
|
|
w->widgets[WIDX_FILTER_STRING_BUTTON].bottom = (ridePage ? 91 : 57);
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_FILTER_CLEAR_BUTTON].left = w->widgets[WIDX_LIST].right - 73;
|
|
|
|
w->widgets[WIDX_FILTER_CLEAR_BUTTON].right = w->widgets[WIDX_LIST].right;
|
2015-06-14 18:19:54 +02:00
|
|
|
w->widgets[WIDX_FILTER_CLEAR_BUTTON].top = (ridePage ? 80 : 46);
|
|
|
|
w->widgets[WIDX_FILTER_CLEAR_BUTTON].bottom = (ridePage ? 91 : 57);
|
|
|
|
|
|
|
|
if (ridePage) {
|
|
|
|
w->enabled_widgets |= (1 << WIDX_FILTER_RIDE_TAB_ALL) | (1 << WIDX_FILTER_RIDE_TAB_TRANSPORT) |
|
|
|
|
(1 << WIDX_FILTER_RIDE_TAB_GENTLE) | (1 << WIDX_FILTER_RIDE_TAB_COASTER) | (1 << WIDX_FILTER_RIDE_TAB_THRILL) |
|
|
|
|
(1 << WIDX_FILTER_RIDE_TAB_WATER) | (1 << WIDX_FILTER_RIDE_TAB_STALL);
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 7; i++)
|
2015-06-14 18:19:54 +02:00
|
|
|
w->pressed_widgets &= ~(1 << (WIDX_FILTER_RIDE_TAB_ALL + i));
|
2017-02-16 19:35:59 +01:00
|
|
|
if ((_filter_flags & FILTER_RIDES) == FILTER_RIDES)
|
2015-06-14 18:19:54 +02:00
|
|
|
w->pressed_widgets |= (1 << WIDX_FILTER_RIDE_TAB_ALL);
|
|
|
|
else {
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 6; i++) {
|
2015-06-14 18:19:54 +02:00
|
|
|
if (_filter_flags & (1 << (5 + i)))
|
|
|
|
w->pressed_widgets |= (uint64)(1 << (WIDX_FILTER_RIDE_TAB_TRANSPORT + i));
|
|
|
|
}
|
|
|
|
}
|
2015-06-25 17:48:32 +02:00
|
|
|
w->widgets[WIDX_FILTER_RIDE_TAB_FRAME].type = WWT_IMGBTN;
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = WIDX_FILTER_RIDE_TAB_ALL; i <= WIDX_FILTER_RIDE_TAB_STALL; i++)
|
2015-06-14 18:19:54 +02:00
|
|
|
w->widgets[i].type = WWT_TAB;
|
2015-06-26 02:11:24 +02:00
|
|
|
|
|
|
|
w->widgets[WIDX_LIST_SORT_TYPE].type = WWT_13;
|
|
|
|
w->widgets[WIDX_LIST_SORT_TYPE].top = w->widgets[WIDX_FILTER_STRING_BUTTON].bottom + 3;
|
|
|
|
w->widgets[WIDX_LIST_SORT_TYPE].bottom = w->widgets[WIDX_LIST_SORT_TYPE].top + 13;
|
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].type = WWT_13;
|
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].top = w->widgets[WIDX_LIST_SORT_TYPE].top;
|
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].bottom = w->widgets[WIDX_LIST_SORT_TYPE].bottom;
|
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].right = w->widgets[WIDX_LIST].right;
|
|
|
|
w->widgets[WIDX_LIST].top = w->widgets[WIDX_LIST_SORT_TYPE].bottom + 2;
|
|
|
|
} else {
|
2015-06-14 18:19:54 +02:00
|
|
|
w->enabled_widgets &= ~((1 << WIDX_FILTER_RIDE_TAB_ALL) | (1 << WIDX_FILTER_RIDE_TAB_TRANSPORT) |
|
|
|
|
(1 << WIDX_FILTER_RIDE_TAB_GENTLE) | (1 << WIDX_FILTER_RIDE_TAB_COASTER) | (1 << WIDX_FILTER_RIDE_TAB_THRILL) |
|
|
|
|
(1 << WIDX_FILTER_RIDE_TAB_WATER) | (1 << WIDX_FILTER_RIDE_TAB_STALL));
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = WIDX_FILTER_RIDE_TAB_FRAME; i <= WIDX_FILTER_RIDE_TAB_STALL; i++)
|
2015-06-14 18:19:54 +02:00
|
|
|
w->widgets[i].type = WWT_EMPTY;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
w->widgets[WIDX_LIST_SORT_TYPE].type = WWT_EMPTY;
|
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].type = WWT_EMPTY;
|
2015-06-14 18:19:54 +02:00
|
|
|
}
|
2015-02-11 17:02:57 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 18:50:52 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 18:50:52 +01:00
|
|
|
* rct2: 0x006AAB56
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
2015-02-11 18:50:52 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 i, x, y, width, type;
|
2015-02-11 18:50:52 +01:00
|
|
|
rct_widget *widget;
|
|
|
|
rct_object_entry *highlightedEntry;
|
|
|
|
rct_string_id stringId;
|
2016-06-30 22:55:18 +02:00
|
|
|
uint8 source;
|
2015-02-11 18:50:52 +01:00
|
|
|
|
2015-06-14 18:19:54 +02:00
|
|
|
/*if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
|
|
|
|
gfx_fill_rect_inset(dpi,
|
|
|
|
w->x + w->widgets[WIDX_FILTER_RIDE_TAB_ALL].left - 1,
|
|
|
|
w->y + w->widgets[WIDX_FILTER_RIDE_TAB_ALL].bottom,
|
|
|
|
w->x + w->widgets[WIDX_FILTER_RIDE_TAB_STALL].right + 1,
|
|
|
|
w->y + w->widgets[WIDX_FILTER_RIDE_TAB_ALL].bottom + 2,
|
|
|
|
w->colours[1],
|
|
|
|
0x10
|
|
|
|
);
|
|
|
|
}*/
|
|
|
|
|
2015-02-11 18:50:52 +01:00
|
|
|
window_draw_widgets(w, dpi);
|
|
|
|
|
|
|
|
// Draw tabs
|
|
|
|
for (i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) {
|
|
|
|
widget = &w->widgets[WIDX_TAB_1 + i];
|
|
|
|
if (widget->type == WWT_EMPTY)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
x = w->x + widget->left;
|
|
|
|
y = w->y + widget->top;
|
2016-07-14 14:07:49 +02:00
|
|
|
gfx_draw_sprite(dpi, SPR_TAB_RIDE_16 + i, x, y, 0);
|
2015-02-11 18:50:52 +01:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
const sint32 ride_tabs[] = { SPR_TAB_RIDE_16, 0x20000000 | SPR_TAB_RIDES_TRANSPORT_0, SPR_TAB_RIDES_GENTLE_0, 0x20000000 | SPR_TAB_RIDES_ROLLER_COASTERS_0, SPR_TAB_RIDES_THRILL_0, SPR_TAB_RIDES_WATER_0, SPR_TAB_RIDES_SHOP_0, SPR_TAB_FINANCES_RESEARCH_0 };
|
|
|
|
const sint32 ThrillRidesTabAnimationSequence[] = {
|
2015-06-26 02:11:24 +02:00
|
|
|
5, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0
|
|
|
|
};
|
2015-06-14 18:19:54 +02:00
|
|
|
|
|
|
|
// Draw ride tabs
|
|
|
|
if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
|
|
|
|
for (i = 0; i < 7; i++) {
|
2015-06-26 02:11:24 +02:00
|
|
|
widget = &w->widgets[WIDX_FILTER_RIDE_TAB_ALL + i];
|
2015-06-14 18:19:54 +02:00
|
|
|
if (widget->type == WWT_EMPTY)
|
|
|
|
continue;
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 spriteIndex = ride_tabs[i];
|
|
|
|
sint32 frame = 0;
|
2015-07-02 18:41:17 +02:00
|
|
|
if (i != 0 && w->pressed_widgets & (1ULL << (WIDX_FILTER_RIDE_TAB_ALL + i))) {
|
2015-06-26 02:11:24 +02:00
|
|
|
frame = w->frame_no / window_editor_object_selection_animation_divisor[i - 1];
|
|
|
|
}
|
|
|
|
spriteIndex += (i == 4 ? ThrillRidesTabAnimationSequence[frame] : frame);
|
|
|
|
|
2015-06-14 18:19:54 +02:00
|
|
|
x = w->x + widget->left;
|
|
|
|
y = w->y + widget->top;
|
2015-06-26 02:11:24 +02:00
|
|
|
gfx_draw_sprite(dpi, spriteIndex | (w->colours[1] << 19), x, y, 0);
|
2015-06-14 18:19:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-11 18:50:52 +01:00
|
|
|
// Preview background
|
|
|
|
widget = &w->widgets[WIDX_PREVIEW];
|
|
|
|
gfx_fill_rect(
|
|
|
|
dpi,
|
|
|
|
w->x + widget->left + 1,
|
|
|
|
w->y + widget->top + 1,
|
|
|
|
w->x + widget->right - 1,
|
|
|
|
w->y + widget->bottom - 1,
|
2015-11-08 19:55:32 +01:00
|
|
|
ColourMapA[w->colours[1]].darkest
|
2015-02-11 18:50:52 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// Draw number of selected items
|
2016-04-23 12:16:46 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
2015-02-11 18:50:52 +01:00
|
|
|
x = w->x + 3;
|
2015-06-04 17:33:29 +02:00
|
|
|
y = w->y + w->height - 13;
|
2015-02-11 18:50:52 +01:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numSelected = _numSelectedObjectsForType[w->selected_tab];
|
|
|
|
sint32 totalSelectable = object_entry_group_counts[w->selected_tab];
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
2015-02-11 18:50:52 +01:00
|
|
|
totalSelectable = 4;
|
|
|
|
|
2016-05-15 23:03:53 +02:00
|
|
|
set_format_arg(0, uint16, numSelected);
|
|
|
|
set_format_arg(2, uint16, totalSelectable);
|
2016-11-13 23:29:03 +01:00
|
|
|
gfx_draw_string_left(dpi, STR_OBJECT_SELECTION_SELECTION_SIZE, gCommonFormatArgs, COLOUR_BLACK, x, y);
|
2015-02-11 18:50:52 +01:00
|
|
|
}
|
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
// Draw sort button text
|
|
|
|
widget = &w->widgets[WIDX_LIST_SORT_TYPE];
|
|
|
|
if (widget->type != WWT_EMPTY) {
|
|
|
|
stringId = _listSortType == RIDE_SORT_TYPE ? (_listSortDescending ? STR_DOWN : STR_UP) : STR_NONE;
|
|
|
|
gfx_draw_string_left_clipped(dpi, STR_OBJECTS_SORT_TYPE, &stringId, w->colours[1], w->x + widget->left + 1, w->y + widget->top + 1, widget->right - widget->left);
|
|
|
|
}
|
|
|
|
widget = &w->widgets[WIDX_LIST_SORT_RIDE];
|
|
|
|
if (widget->type != WWT_EMPTY) {
|
|
|
|
stringId = _listSortType == RIDE_SORT_RIDE ? (_listSortDescending ? STR_DOWN : STR_UP) : STR_NONE;
|
|
|
|
gfx_draw_string_left_clipped(dpi, STR_OBJECTS_SORT_RIDE, &stringId, w->colours[1], w->x + widget->left + 1, w->y + widget->top + 1, widget->right - widget->left);
|
|
|
|
}
|
|
|
|
|
2016-06-30 22:55:18 +02:00
|
|
|
if (w->selected_list_item == -1 || _loadedObject == NULL)
|
2015-02-11 18:50:52 +01:00
|
|
|
return;
|
|
|
|
|
2016-06-30 22:55:18 +02:00
|
|
|
list_item *listItem = &_listItems[w->selected_list_item];
|
|
|
|
|
2015-12-31 09:16:44 +01:00
|
|
|
highlightedEntry = w->object_entry;
|
2015-02-11 18:50:52 +01:00
|
|
|
type = highlightedEntry->flags & 0x0F;
|
|
|
|
|
|
|
|
// Draw preview
|
|
|
|
widget = &w->widgets[WIDX_PREVIEW];
|
2016-07-02 11:59:50 +02:00
|
|
|
{
|
|
|
|
rct_drawpixelinfo clipDPI;
|
2016-07-02 13:06:29 +02:00
|
|
|
x = w->x + widget->left + 1;
|
|
|
|
y = w->y + widget->top + 1;
|
2017-01-12 19:20:22 +01:00
|
|
|
width = widget->right - widget->left - 1;
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 height = widget->bottom - widget->top - 1;
|
2016-07-02 11:59:50 +02:00
|
|
|
if (clip_drawpixelinfo(&clipDPI, dpi, x, y, width, height)) {
|
2016-07-11 23:09:15 +02:00
|
|
|
object_draw_preview(_loadedObject, &clipDPI, width, height);
|
2016-07-02 11:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
2015-02-11 18:50:52 +01:00
|
|
|
|
|
|
|
// Draw name of object
|
|
|
|
x = w->x + (widget->left + widget->right) / 2 + 1;
|
|
|
|
y = w->y + widget->bottom + 3;
|
|
|
|
width = w->width - w->widgets[WIDX_LIST].right - 6;
|
2016-09-06 00:00:17 +02:00
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, listItem->repositoryItem->Name);
|
2016-11-13 18:20:30 +01:00
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, x, y, width);
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-02-11 18:50:52 +01:00
|
|
|
// Draw description of object
|
2016-09-06 00:00:17 +02:00
|
|
|
const char *description = object_get_description(_loadedObject);
|
|
|
|
if (description != NULL) {
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, description);
|
|
|
|
|
2016-01-07 20:12:59 +01:00
|
|
|
x = w->x + w->widgets[WIDX_LIST].right + 4;
|
|
|
|
y += 15;
|
2017-01-12 19:20:22 +01:00
|
|
|
width = w->x + w->width - x - 4;
|
2016-01-07 20:12:59 +01:00
|
|
|
if (type == OBJECT_TYPE_SCENARIO_TEXT) {
|
2016-11-13 18:20:30 +01:00
|
|
|
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, width, STR_OBJECT_SELECTION_DESCRIPTION_SCENARIO_TEXT, COLOUR_BLACK);
|
2016-01-07 20:12:59 +01:00
|
|
|
} else {
|
2016-11-13 18:20:30 +01:00
|
|
|
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y + 5, width, STR_WINDOW_COLOUR_2_STRINGID, COLOUR_BLACK);
|
2016-01-07 20:12:59 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-11 19:54:31 +01:00
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
// Draw object source
|
|
|
|
source = (highlightedEntry->flags & 0xF0) >> 4;
|
|
|
|
switch (source) {
|
2015-09-11 16:21:27 +02:00
|
|
|
case 8: stringId = STR_ROLLERCOASTER_TYCOON_2_DROPDOWN; break;
|
|
|
|
case 1: stringId = STR_OBJECT_FILTER_WW; break;
|
|
|
|
case 2: stringId = STR_OBJECT_FILTER_TT; break;
|
|
|
|
default: stringId = STR_OBJECT_FILTER_CUSTOM; break;
|
2015-06-03 18:37:07 +02:00
|
|
|
}
|
2016-11-13 18:44:34 +01:00
|
|
|
gfx_draw_string_right(dpi, stringId, NULL, COLOUR_WHITE, w->x + w->width - 5, w->y + w->height - 3 - 12 - 14);
|
2015-06-03 18:37:07 +02:00
|
|
|
|
2015-10-20 20:16:30 +02:00
|
|
|
//
|
2015-06-03 20:14:45 +02:00
|
|
|
if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
|
|
|
|
y = w->y + w->height - 3 - 12 - 14 - 14;
|
2016-07-02 11:59:50 +02:00
|
|
|
stringId = get_ride_type_string_id(listItem->repositoryItem);
|
2016-11-13 18:44:34 +01:00
|
|
|
gfx_draw_string_right(dpi, stringId, NULL, COLOUR_WHITE, w->x + w->width - 5, y);
|
2016-07-02 11:59:50 +02:00
|
|
|
y -= 11;
|
2015-06-03 20:14:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//stringId = highlightedEntry->checksum
|
|
|
|
// gfx_draw_string_right(dpi, stringId, NULL, 2, w->x + w->width - 5, w->y + w->height - 3 - 12 - 14);
|
|
|
|
|
2015-02-11 19:54:31 +01:00
|
|
|
// Draw object dat name
|
2016-09-06 00:00:17 +02:00
|
|
|
const char *path = path_get_filename(listItem->repositoryItem->Path);
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, path);
|
2016-11-13 18:20:30 +01:00
|
|
|
gfx_draw_string_right(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, w->x + w->width - 5, w->y + w->height - 3 - 12);
|
2015-02-11 18:50:52 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 20:42:10 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 20:42:10 +01:00
|
|
|
* rct2: 0x006AADA3
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
|
2015-02-11 20:42:10 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 x, y, i, colour, colour2;
|
2015-02-11 20:42:10 +01:00
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
bool ridePage = (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS);
|
|
|
|
|
2016-11-16 14:27:02 +01:00
|
|
|
uint8 paletteIndex = ColourMapA[w->colours[1]].mid_light;
|
|
|
|
gfx_clear(dpi, paletteIndex);
|
2015-02-11 20:42:10 +01:00
|
|
|
|
|
|
|
y = 0;
|
2015-06-25 17:48:32 +02:00
|
|
|
for (i = 0; i < _numListItems; i++) {
|
|
|
|
list_item *listItem = &_listItems[i];
|
|
|
|
|
|
|
|
if (y + 12 >= dpi->y && y <= dpi->y + dpi->height) {
|
|
|
|
// Draw checkbox
|
2016-04-23 12:16:46 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && !(*listItem->flags & 0x20))
|
2016-11-10 18:54:33 +01:00
|
|
|
gfx_fill_rect_inset(dpi, 2, y, 11, y + 10, w->colours[1], INSET_RECT_F_E0);
|
2015-06-25 17:48:32 +02:00
|
|
|
|
|
|
|
// Highlight background
|
2016-11-13 23:29:03 +01:00
|
|
|
colour = COLOUR_BRIGHT_GREEN | COLOUR_FLAG_TRANSLUCENT;
|
2015-12-31 09:16:44 +01:00
|
|
|
if (listItem->entry == w->object_entry && !(*listItem->flags & OBJECT_SELECTION_FLAG_6)) {
|
2016-11-10 00:03:12 +01:00
|
|
|
gfx_filter_rect(dpi, 0, y, w->width, y + 11, PALETTE_DARKEN_1);
|
2016-11-13 23:29:03 +01:00
|
|
|
colour = COLOUR_BRIGHT_GREEN;
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
2015-02-11 20:42:10 +01:00
|
|
|
|
2015-06-25 17:48:32 +02:00
|
|
|
// Draw checkmark
|
2016-04-23 12:16:46 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && (*listItem->flags & OBJECT_SELECTION_FLAG_SELECTED)) {
|
2015-06-25 17:48:32 +02:00
|
|
|
x = 2;
|
2016-11-16 14:24:39 +01:00
|
|
|
gCurrentFontSpriteBase = colour == COLOUR_BRIGHT_GREEN ? FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK : FONT_SPRITE_BASE_MEDIUM_DARK;
|
2016-11-13 23:29:03 +01:00
|
|
|
colour2 = NOT_TRANSLUCENT(w->colours[1]);
|
2016-07-02 17:52:44 +02:00
|
|
|
if (*listItem->flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
|
2016-11-13 18:44:34 +01:00
|
|
|
colour2 |= COLOUR_FLAG_INSET;
|
2015-02-11 20:42:10 +01:00
|
|
|
|
2015-07-27 02:09:24 +02:00
|
|
|
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour2, x, y);
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
2015-02-11 20:42:10 +01:00
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
x = gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15;
|
2015-02-11 22:03:23 +01:00
|
|
|
|
2016-09-04 16:55:37 +02:00
|
|
|
char *bufferWithColour = gCommonStringFormatBuffer;
|
2015-07-27 02:09:24 +02:00
|
|
|
char *buffer = utf8_write_codepoint(bufferWithColour, colour);
|
2015-06-25 17:48:32 +02:00
|
|
|
if (*listItem->flags & OBJECT_SELECTION_FLAG_6) {
|
|
|
|
colour = w->colours[1] & 0x7F;
|
2016-11-16 14:24:39 +01:00
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-11-13 23:29:03 +01:00
|
|
|
colour = COLOUR_BLACK;
|
2016-04-26 00:00:58 +02:00
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
2015-02-11 20:42:10 +01:00
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
if (ridePage) {
|
|
|
|
// Draw ride type
|
2016-07-02 11:59:50 +02:00
|
|
|
rct_string_id rideTypeStringId = get_ride_type_string_id(listItem->repositoryItem);
|
2016-09-26 04:24:29 +02:00
|
|
|
safe_strcpy(buffer, language_get_string(rideTypeStringId), 256 - (buffer - bufferWithColour));
|
2015-06-26 02:11:24 +02:00
|
|
|
gfx_draw_string(dpi, bufferWithColour, colour, x, y);
|
|
|
|
x = w->widgets[WIDX_LIST_SORT_RIDE].left - w->widgets[WIDX_LIST].left;
|
2015-02-11 20:42:10 +01:00
|
|
|
}
|
|
|
|
|
2015-06-25 17:48:32 +02:00
|
|
|
// Draw text
|
2016-09-26 04:24:29 +02:00
|
|
|
safe_strcpy(buffer, listItem->repositoryItem->Name, 256 - (buffer - bufferWithColour));
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2015-06-25 17:48:32 +02:00
|
|
|
while (*buffer != 0 && *buffer != 9)
|
|
|
|
buffer++;
|
|
|
|
|
|
|
|
*buffer = 0;
|
2015-02-11 20:42:10 +01:00
|
|
|
}
|
2015-06-25 17:48:32 +02:00
|
|
|
gfx_draw_string(dpi, bufferWithColour, colour, x, y);
|
2015-02-11 20:42:10 +01:00
|
|
|
}
|
2015-06-25 17:48:32 +02:00
|
|
|
y += 12;
|
2015-02-11 20:42:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_set_page(rct_window *w, sint32 page)
|
2014-11-25 00:05:35 +01:00
|
|
|
{
|
|
|
|
if (w->selected_tab == page)
|
|
|
|
return;
|
|
|
|
|
|
|
|
w->selected_tab = page;
|
|
|
|
w->selected_list_item = -1;
|
2016-08-28 00:32:15 +02:00
|
|
|
w->object_entry = (rct_object_entry *)-1;
|
2014-11-25 00:05:35 +01:00
|
|
|
w->scrolls[0].v_top = 0;
|
2016-11-02 20:08:12 +01:00
|
|
|
w->frame_no = 0;
|
2015-06-26 02:11:24 +02:00
|
|
|
|
|
|
|
if (page == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
|
|
|
|
_listSortType = RIDE_SORT_TYPE;
|
|
|
|
_listSortDescending = false;
|
|
|
|
} else {
|
|
|
|
_listSortType = RIDE_SORT_RIDE;
|
|
|
|
_listSortDescending = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
visible_list_refresh(w);
|
2014-11-25 00:05:35 +01:00
|
|
|
window_invalidate(w);
|
2015-02-02 19:49:07 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
static void window_editor_object_selection_set_pressed_tab(rct_window *w)
|
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 i;
|
2015-02-11 17:02:57 +01:00
|
|
|
for (i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++)
|
|
|
|
w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i));
|
|
|
|
w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->selected_tab);
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:43:22 +01:00
|
|
|
/**
|
2015-06-17 20:51:41 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006AA805
|
|
|
|
*/
|
2015-02-13 19:43:22 +01:00
|
|
|
static void window_editor_object_selection_select_default_objects()
|
|
|
|
{
|
2016-07-02 15:59:13 +02:00
|
|
|
if (_numSelectedObjectsForType[0] == 0) {
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < countof(DefaultSelectedObjects); i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
window_editor_object_selection_select_object(0, 7, &DefaultSelectedObjects[i]);
|
|
|
|
}
|
|
|
|
}
|
2015-02-13 19:43:22 +01:00
|
|
|
}
|
|
|
|
|
2015-06-17 20:51:41 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AA7E9
|
|
|
|
*/
|
|
|
|
static void window_editor_object_selection_select_required_objects()
|
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 i;
|
2015-06-17 20:51:41 +02:00
|
|
|
|
|
|
|
for (i = 0; i < countof(RequiredSelectedObjects); i++)
|
|
|
|
window_editor_object_selection_select_object(0, 0xF, &RequiredSelectedObjects[i]);
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AA770
|
|
|
|
*/
|
2016-06-29 23:58:38 +02:00
|
|
|
void reset_selected_object_count_and_size()
|
|
|
|
{
|
2016-07-02 15:59:13 +02:00
|
|
|
for (uint8 objectType = 0; objectType < 11; objectType++) {
|
|
|
|
_numSelectedObjectsForType[objectType] = 0;
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-07-02 15:59:13 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 objectType = items[i].ObjectEntry.flags & 0xF;
|
|
|
|
if (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED) {
|
|
|
|
_numSelectedObjectsForType[objectType]++;
|
|
|
|
}
|
2015-06-15 21:17:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
2015-06-16 19:00:47 +02:00
|
|
|
* Master objects are objects that are not
|
2015-10-20 20:16:30 +02:00
|
|
|
* optional / required dependants of an
|
2015-06-16 19:00:47 +02:00
|
|
|
* object.
|
|
|
|
*/
|
2016-07-13 00:46:51 +02:00
|
|
|
static void set_object_selection_error(uint8 is_master_object, rct_string_id error_msg){
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = error_msg;
|
2015-06-16 19:00:47 +02:00
|
|
|
if (!is_master_object){
|
|
|
|
reset_selected_object_count_and_size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:43:22 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AB54F
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 window_editor_object_selection_select_object(uint8 bh, sint32 flags, const rct_object_entry *entry)
|
2015-02-13 19:43:22 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-06-30 22:07:32 +02:00
|
|
|
const ObjectRepositoryItem * item = object_repository_find_object_by_entry(entry);
|
|
|
|
if (item == NULL) {
|
2016-07-14 14:07:49 +02:00
|
|
|
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_OBJECT_DATA_NOT_FOUND);
|
2016-06-30 22:07:32 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-06-14 13:24:01 +02:00
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
// Get repository item index
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 index = -1;
|
2016-07-02 15:59:13 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
if (&items[i] == item) {
|
|
|
|
index = i;
|
|
|
|
}
|
2015-06-14 13:24:01 +02:00
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 * selectionFlags = &_objectSelectionFlags[index];
|
|
|
|
if (!(flags & 1)) {
|
2016-07-02 17:52:44 +02:00
|
|
|
if (!(*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED)) {
|
2015-06-14 13:24:01 +02:00
|
|
|
return 1;
|
2015-06-15 21:52:04 +02:00
|
|
|
}
|
2016-07-02 17:52:44 +02:00
|
|
|
else if (*selectionFlags & OBJECT_SELECTION_FLAG_IN_USE) {
|
2016-07-14 14:07:49 +02:00
|
|
|
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_CURRENTLY_IN_USE);
|
2015-06-14 13:24:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2016-07-02 17:52:44 +02:00
|
|
|
else if (*selectionFlags & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED) {
|
2016-07-14 14:07:49 +02:00
|
|
|
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_ALWAYS_REQUIRED);
|
2015-06-14 13:24:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-16 18:57:58 +02:00
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
|
|
|
if (objectType == OBJECT_TYPE_SCENERY_SETS && (flags & (1 << 2))) {
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 j = 0; j < item->NumThemeObjects; j++) {
|
2016-07-02 17:52:44 +02:00
|
|
|
window_editor_object_selection_select_object(++bh, flags, &item->ThemeObjects[j]);
|
2015-06-14 13:24:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
_numSelectedObjectsForType[objectType]--;
|
|
|
|
*selectionFlags &= ~OBJECT_SELECTION_FLAG_SELECTED;
|
2015-06-14 13:24:01 +02:00
|
|
|
return 1;
|
2016-06-30 22:07:32 +02:00
|
|
|
} else {
|
|
|
|
if (bh == 0) {
|
|
|
|
if (flags & (1 << 3)) {
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags |= OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED;
|
2015-06-14 13:24:01 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-02 15:59:13 +02:00
|
|
|
if (*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED) {
|
2015-06-14 13:24:01 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
|
|
|
uint16 maxObjects = object_entry_group_counts[objectType];
|
2016-06-30 22:07:32 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) {
|
2016-07-02 15:59:13 +02:00
|
|
|
maxObjects = 4;
|
2015-06-14 13:24:01 +02:00
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
if (maxObjects <= _numSelectedObjectsForType[objectType]) {
|
2016-07-14 14:07:49 +02:00
|
|
|
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
2015-06-14 13:24:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:52:44 +02:00
|
|
|
if (objectType == OBJECT_TYPE_SCENERY_SETS && (flags & (1 << 2))) {
|
2016-07-02 15:59:13 +02:00
|
|
|
for (uint16 j = 0; j < item->NumThemeObjects; j++) {
|
2016-07-02 17:52:44 +02:00
|
|
|
if (!window_editor_object_selection_select_object(++bh, flags, &item->ThemeObjects[j])) {
|
|
|
|
_maxObjectsWasHit = true;
|
2015-06-14 13:24:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2016-06-30 22:07:32 +02:00
|
|
|
if (bh != 0 && !(flags & (1 << 1))) {
|
2016-09-05 23:34:07 +02:00
|
|
|
char objectName[64];
|
2016-09-26 04:24:29 +02:00
|
|
|
object_create_identifier_name(objectName, 64, &item->ObjectEntry);
|
2016-09-05 23:34:07 +02:00
|
|
|
set_format_arg(0, const char *, objectName);
|
2016-07-14 14:07:49 +02:00
|
|
|
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_SHOULD_SELECT_X_FIRST);
|
2015-06-14 13:24:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
if (maxObjects <= _numSelectedObjectsForType[objectType]) {
|
2016-07-14 14:07:49 +02:00
|
|
|
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
2015-06-14 13:24:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
_numSelectedObjectsForType[objectType]++;
|
2015-06-14 13:24:01 +02:00
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
*selectionFlags |= OBJECT_SELECTION_FLAG_SELECTED;
|
2015-06-14 13:24:01 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2015-02-13 19:43:22 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
/**
|
2015-02-02 19:49:07 +01:00
|
|
|
* Takes the y coordinate of the clicked on scroll list
|
|
|
|
* and converts this into an object selection.
|
|
|
|
* Returns the position in the list.
|
|
|
|
* Object_selection_flags, installed_entry also populated
|
2015-02-11 17:02:57 +01:00
|
|
|
*
|
2015-12-11 16:38:37 +01:00
|
|
|
* rct2: 0x006AA703
|
2015-02-02 19:49:07 +01:00
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static sint32 get_object_from_object_selection(uint8 object_type, sint32 y)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 listItemIndex = y / 12;
|
2015-06-25 17:48:32 +02:00
|
|
|
if (listItemIndex < 0 || listItemIndex >= _numListItems)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return listItemIndex;
|
2015-02-02 19:49:07 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006D33E2
|
|
|
|
*/
|
2015-02-13 19:43:22 +01:00
|
|
|
static void window_editor_object_selection_manage_tracks()
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 4; i++) {
|
2016-05-10 01:00:59 +02:00
|
|
|
gResearchedRideTypes[i] = 0xFFFFFFFF;
|
2015-02-02 19:49:07 +01:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < countof(RideTypePossibleTrackConfigurations); i++) {
|
2016-05-10 01:00:59 +02:00
|
|
|
gResearchedTrackTypesA[i] = (RideTypePossibleTrackConfigurations[i] ) & 0xFFFFFFFFULL;
|
|
|
|
gResearchedTrackTypesB[i] = (RideTypePossibleTrackConfigurations[i] >> 32ULL) & 0xFFFFFFFFULL;
|
|
|
|
}
|
|
|
|
|
2016-05-13 11:36:24 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = countof(RideTypePossibleTrackConfigurations); i < 128; i++) {
|
2016-05-13 11:36:24 +02:00
|
|
|
gResearchedTrackTypesA[i] = (uint32)-1;
|
|
|
|
gResearchedTrackTypesB[i] = (uint32)-1;
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 8; i++) {
|
2016-05-10 01:00:59 +02:00
|
|
|
gResearchedRideEntries[i] = 0xFFFFFFFF;
|
2015-02-02 19:49:07 +01:00
|
|
|
}
|
|
|
|
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_TRACK_DESIGNS_MANAGER;
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 entry_index = 0;
|
2016-07-31 22:00:02 +02:00
|
|
|
for (; ((intptr_t)object_entry_groups[0].chunks[entry_index]) == -1; ++entry_index);
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2016-02-25 13:33:19 +01:00
|
|
|
rct_ride_entry* ride_entry = get_ride_entry(entry_index);
|
2015-03-31 18:09:16 +02:00
|
|
|
uint8* ride_type_array = &ride_entry->ride_type[0];
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 ride_type;
|
|
|
|
for (sint32 i = 0; (ride_type = ride_type_array[i]) == 0xFF; i++) { }
|
2015-02-02 19:49:07 +01:00
|
|
|
|
|
|
|
ride_list_item item = { ride_type, entry_index };
|
2016-04-28 23:57:04 +02:00
|
|
|
// track_load_list(item);
|
2015-02-02 19:49:07 +01:00
|
|
|
window_track_list_open(item);
|
|
|
|
}
|
|
|
|
|
2015-02-11 17:02:57 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-11 17:02:57 +01:00
|
|
|
* rct2: 0x006ABBBE
|
|
|
|
*/
|
|
|
|
static void editor_load_selected_objects()
|
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numItems = (sint32)object_repository_get_items_count();
|
2016-06-29 23:58:38 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numItems; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
if (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED) {
|
2016-07-06 23:31:14 +02:00
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
|
|
|
const rct_object_entry * entry = &item->ObjectEntry;
|
|
|
|
void * loadedObject = object_manager_get_loaded_object(entry);
|
|
|
|
if (loadedObject == NULL) {
|
|
|
|
loadedObject = object_manager_load_object(entry);
|
|
|
|
if (loadedObject == NULL) {
|
|
|
|
log_error("Failed to load entry %.8s", entry->name);
|
2015-02-02 19:49:07 +01:00
|
|
|
}
|
2016-07-06 23:31:14 +02:00
|
|
|
else if (!(gScreenFlags & SCREEN_FLAGS_EDITOR)) {
|
|
|
|
// Defaults selected items to researched (if in-game)
|
|
|
|
uint8 objectType = entry->flags & 0x0F;
|
|
|
|
uint8 entryIndex = object_manager_get_loaded_object_entry_index(loadedObject);
|
|
|
|
if (objectType == OBJECT_TYPE_RIDE) {
|
|
|
|
rct_ride_entry *rideType = get_ride_entry(entryIndex);
|
|
|
|
research_insert(1, 0x10000 | (rideType->ride_type[0] << 8) | entryIndex, rideType->category[0]);
|
|
|
|
}
|
|
|
|
else if (objectType == OBJECT_TYPE_SCENERY_SETS) {
|
|
|
|
research_insert(1, entryIndex, RESEARCH_CATEGORY_SCENERYSET);
|
2016-05-28 10:30:31 +02:00
|
|
|
}
|
|
|
|
}
|
2015-02-02 19:49:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-04 17:33:29 +02:00
|
|
|
}
|
2015-06-06 00:54:47 +02:00
|
|
|
|
2015-06-06 23:04:53 +02:00
|
|
|
static void window_editor_object_selection_update(rct_window *w)
|
|
|
|
{
|
|
|
|
if (gCurrentTextBox.window.classification == w->classification &&
|
|
|
|
gCurrentTextBox.window.number == w->number) {
|
|
|
|
window_update_textbox_caret();
|
|
|
|
widget_invalidate(w, WIDX_FILTER_STRING_BUTTON);
|
|
|
|
}
|
2015-06-26 02:11:24 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = WIDX_FILTER_RIDE_TAB_TRANSPORT; i <= WIDX_FILTER_RIDE_TAB_STALL; i++) {
|
2015-06-26 02:11:24 +02:00
|
|
|
if (!(w->pressed_widgets & (1ULL << i)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
w->frame_no++;
|
|
|
|
if (w->frame_no >= window_editor_object_selection_animation_loops[i - WIDX_FILTER_RIDE_TAB_TRANSPORT])
|
|
|
|
w->frame_no = 0;
|
|
|
|
|
|
|
|
widget_invalidate(w, i);
|
|
|
|
break;
|
|
|
|
}
|
2015-06-06 23:04:53 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_editor_object_selection_textinput(rct_window *w, sint32 widgetIndex, char *text)
|
2015-06-06 00:54:47 +02:00
|
|
|
{
|
2015-07-10 02:39:16 +02:00
|
|
|
if (widgetIndex != WIDX_FILTER_STRING_BUTTON || text == NULL)
|
2015-06-06 00:54:47 +02:00
|
|
|
return;
|
2015-06-06 23:04:53 +02:00
|
|
|
|
|
|
|
if (strcmp(_filter_string, text) == 0)
|
|
|
|
return;
|
|
|
|
|
2015-06-06 00:54:47 +02:00
|
|
|
if (strlen(text) == 0) {
|
|
|
|
memset(_filter_string, 0, sizeof(_filter_string));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(_filter_string, 0, sizeof(_filter_string));
|
2016-01-18 20:49:52 +01:00
|
|
|
safe_strcpy(_filter_string, text, sizeof(_filter_string));
|
2015-06-06 00:54:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
filter_update_counts();
|
2015-06-06 01:02:20 +02:00
|
|
|
|
|
|
|
w->scrolls->v_top = 0;
|
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
visible_list_refresh(w);
|
2015-06-06 01:02:20 +02:00
|
|
|
window_invalidate(w);
|
2015-06-06 00:54:47 +02:00
|
|
|
}
|
|
|
|
|
2016-07-02 15:59:13 +02:00
|
|
|
static bool filter_selected(uint8 objectFlag)
|
|
|
|
{
|
2016-06-21 20:41:07 +02:00
|
|
|
if (_FILTER_SELECTED == _FILTER_NONSELECTED) {
|
2016-06-17 10:46:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-02 15:59:13 +02:00
|
|
|
if (_FILTER_SELECTED && objectFlag & OBJECT_SELECTION_FLAG_SELECTED) {
|
2016-06-17 10:46:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-02 15:59:13 +02:00
|
|
|
else if (_FILTER_NONSELECTED && !(objectFlag & OBJECT_SELECTION_FLAG_SELECTED)) {
|
2016-06-17 10:46:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
static bool filter_string(const ObjectRepositoryItem * item)
|
2015-06-06 00:54:47 +02:00
|
|
|
{
|
2015-11-17 00:16:54 +01:00
|
|
|
// Nothing to search for
|
|
|
|
if (_filter_string[0] == '\0')
|
2015-06-06 00:54:47 +02:00
|
|
|
return true;
|
|
|
|
|
2015-11-17 00:16:54 +01:00
|
|
|
// Object doesn't have a name
|
2016-06-29 23:15:38 +02:00
|
|
|
utf8 *name = item->Name;
|
|
|
|
if (name == NULL || name[0] == '\0')
|
2015-06-06 00:54:47 +02:00
|
|
|
return false;
|
|
|
|
|
2015-11-17 00:16:54 +01:00
|
|
|
// Get ride type
|
2016-07-02 11:59:50 +02:00
|
|
|
const char *rideTypeName = language_get_string(get_ride_type_string_id(item));
|
2015-11-17 00:16:54 +01:00
|
|
|
|
|
|
|
// Get object name (ride/vehicle for rides) and type name (rides only)
|
2015-06-06 00:54:47 +02:00
|
|
|
char name_lower[MAX_PATH];
|
2015-11-17 00:16:54 +01:00
|
|
|
char type_lower[MAX_PATH];
|
2015-06-06 00:54:47 +02:00
|
|
|
char filter_lower[sizeof(_filter_string)];
|
2016-01-18 20:49:52 +01:00
|
|
|
safe_strcpy(name_lower, name, MAX_PATH);
|
2016-06-29 23:15:38 +02:00
|
|
|
safe_strcpy(type_lower, rideTypeName, MAX_PATH);
|
2016-01-18 20:49:52 +01:00
|
|
|
safe_strcpy(filter_lower, _filter_string, sizeof(_filter_string));
|
2015-06-06 00:54:47 +02:00
|
|
|
|
2015-11-17 00:16:54 +01:00
|
|
|
// Make use of lowercase characters only
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; name_lower[i] != '\0'; i++)
|
2015-06-06 00:54:47 +02:00
|
|
|
name_lower[i] = (char)tolower(name_lower[i]);
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; type_lower[i] != '\0'; i++)
|
2015-11-17 00:16:54 +01:00
|
|
|
type_lower[i] = (char)tolower(type_lower[i]);
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; filter_lower[i] != '\0'; i++)
|
2015-06-06 00:54:47 +02:00
|
|
|
filter_lower[i] = (char)tolower(filter_lower[i]);
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
return strstr(name_lower, filter_lower) != NULL || (((item->ObjectEntry.flags & 0x0F) == OBJECT_TYPE_RIDE) && strstr(type_lower, filter_lower) != NULL);
|
2015-06-06 00:54:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
static bool filter_source(const ObjectRepositoryItem * item)
|
2015-06-06 00:54:47 +02:00
|
|
|
{
|
|
|
|
if (_FILTER_ALL)
|
|
|
|
return true;
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
uint8 source = (item->ObjectEntry.flags & 0xF0) >> 4;
|
2015-06-06 00:54:47 +02:00
|
|
|
return (_FILTER_RCT2 && source == 8) || (_FILTER_WW && source == 1) || (_FILTER_TT && source == 2) || (_FILTER_CUSTOM && source != 8 && source != 1 && source != 2);
|
|
|
|
}
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
static bool filter_chunks(const ObjectRepositoryItem * item)
|
2015-06-14 18:19:54 +02:00
|
|
|
{
|
2016-06-29 23:15:38 +02:00
|
|
|
switch (item->ObjectEntry.flags & 0x0F) {
|
2015-06-14 18:19:54 +02:00
|
|
|
case OBJECT_TYPE_RIDE:
|
2015-06-27 13:08:29 +02:00
|
|
|
if(!gConfigInterface.select_by_track_type) {
|
2016-06-29 23:15:38 +02:00
|
|
|
if (_filter_flags & (1 << (item->RideCategory[0] + 5)))
|
2015-06-27 13:08:29 +02:00
|
|
|
return true;
|
2016-06-29 23:15:38 +02:00
|
|
|
if (_filter_flags & (1 << (item->RideCategory[1] + 5)))
|
2015-06-27 13:08:29 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2016-07-02 11:59:50 +02:00
|
|
|
uint8 rideType = 0;
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 3; i++) {
|
2016-07-02 11:59:50 +02:00
|
|
|
if (item->RideType[i] != 255) {
|
|
|
|
rideType = item->RideType[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 13:06:29 +02:00
|
|
|
if (_filter_flags & (1 << (gRideCategories[rideType] + 5)))
|
2015-06-27 13:08:29 +02:00
|
|
|
return true;
|
|
|
|
}
|
2015-06-14 18:19:54 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-06 00:54:47 +02:00
|
|
|
static void filter_update_counts()
|
|
|
|
{
|
|
|
|
if (!_FILTER_ALL || strlen(_filter_string) > 0) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 *selectionFlags = _objectSelectionFlags;
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 11; i++) {
|
2015-06-06 00:54:47 +02:00
|
|
|
_filter_object_counts[i] = 0;
|
|
|
|
}
|
2016-06-29 23:15:38 +02:00
|
|
|
|
|
|
|
size_t numObjects = object_repository_get_items_count();
|
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
|
|
|
for (size_t i = 0; i < numObjects; i++) {
|
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
|
|
|
if (filter_source(item) &&
|
|
|
|
filter_string(item) &&
|
|
|
|
filter_chunks(item) &&
|
2016-07-02 15:59:13 +02:00
|
|
|
filter_selected(*selectionFlags)
|
2016-06-29 23:15:38 +02:00
|
|
|
) {
|
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
|
|
|
_filter_object_counts[objectType]++;
|
2015-06-06 00:54:47 +02:00
|
|
|
}
|
2016-07-02 15:59:13 +02:00
|
|
|
selectionFlags++;
|
2015-06-06 00:54:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 11:59:50 +02:00
|
|
|
|
|
|
|
static rct_string_id get_ride_type_string_id(const ObjectRepositoryItem * item)
|
|
|
|
{
|
|
|
|
rct_string_id result = STR_NONE;
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < 3; i++) {
|
2016-07-02 11:59:50 +02:00
|
|
|
uint8 rideType = item->RideType[i];
|
|
|
|
if (rideType != 255) {
|
2016-07-27 00:02:10 +02:00
|
|
|
result = RideNaming[rideType].name;
|
2016-07-02 11:59:50 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2016-07-02 15:59:13 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
bool editor_check_object_group_at_least_one_selected(sint32 checkObjectType)
|
2016-07-02 15:59:13 +02:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
2016-07-02 15:59:13 +02:00
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
2016-07-02 15:59:13 +02:00
|
|
|
uint8 objectType = items[i].ObjectEntry.flags & 0x0F;
|
2016-07-04 18:55:04 +02:00
|
|
|
if (checkObjectType == objectType && (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED)) {
|
2016-07-02 15:59:13 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|