2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 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
|
|
|
|
2018-01-21 03:39:52 +01:00
|
|
|
#include <algorithm>
|
2018-01-04 00:36:33 +01:00
|
|
|
#include <cctype>
|
2017-12-05 13:55:33 +01:00
|
|
|
#include <string>
|
2018-01-21 03:39:52 +01:00
|
|
|
#include <vector>
|
2017-11-23 09:03:56 +01:00
|
|
|
#include <openrct2/audio/audio.h>
|
|
|
|
#include <openrct2/config/Config.h>
|
|
|
|
#include <openrct2/Context.h>
|
2018-03-30 17:58:12 +02:00
|
|
|
#include <openrct2/core/String.hpp>
|
2017-11-23 09:03:56 +01:00
|
|
|
#include <openrct2/Editor.h>
|
2017-12-05 13:55:33 +01:00
|
|
|
#include <openrct2/EditorObjectSelectionSession.h>
|
2017-11-23 09:03:56 +01:00
|
|
|
#include <openrct2/Game.h>
|
2018-01-06 18:32:25 +01:00
|
|
|
#include <openrct2/localisation/Localisation.h>
|
2018-01-21 03:39:52 +01:00
|
|
|
#include <openrct2/object/ObjectList.h>
|
2017-11-23 09:03:56 +01:00
|
|
|
#include <openrct2/object/ObjectManager.h>
|
|
|
|
#include <openrct2/object/ObjectRepository.h>
|
2017-12-05 13:55:33 +01:00
|
|
|
#include <openrct2/object/RideObject.h>
|
|
|
|
#include <openrct2/object/StexObject.h>
|
2017-11-23 09:03:56 +01:00
|
|
|
#include <openrct2/OpenRCT2.h>
|
|
|
|
#include <openrct2/platform/platform.h>
|
|
|
|
#include <openrct2/ride/RideGroupManager.h>
|
|
|
|
#include <openrct2/sprites.h>
|
2017-12-13 13:02:24 +01:00
|
|
|
#include <openrct2/util/Util.h>
|
2017-11-23 09:03:56 +01:00
|
|
|
#include <openrct2/windows/Intent.h>
|
2018-01-21 03:39:52 +01:00
|
|
|
#include <openrct2-ui/interface/Dropdown.h>
|
|
|
|
#include <openrct2-ui/interface/Widget.h>
|
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2015-09-10 23:16:41 +02:00
|
|
|
|
2018-01-31 13:07:20 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FILTER_RCT1 = (1 << 0),
|
|
|
|
FILTER_AA = (1 << 1),
|
|
|
|
FILTER_LL = (1 << 2),
|
|
|
|
FILTER_RCT2 = (1 << 3),
|
|
|
|
FILTER_WW = (1 << 4),
|
|
|
|
FILTER_TT = (1 << 5),
|
|
|
|
FILTER_OO = (1 << 6),
|
|
|
|
FILTER_CUSTOM = (1 << 7),
|
|
|
|
|
|
|
|
FILTER_RIDE_TRANSPORT = (1 << 8),
|
|
|
|
FILTER_RIDE_GENTLE = (1 << 9),
|
|
|
|
FILTER_RIDE_COASTER = (1 << 10),
|
|
|
|
FILTER_RIDE_THRILL = (1 << 11),
|
|
|
|
FILTER_RIDE_WATER = (1 << 12),
|
|
|
|
FILTER_RIDE_STALL = (1 << 13),
|
|
|
|
|
|
|
|
FILTER_SELECTED = (1 << 14),
|
|
|
|
FILTER_NONSELECTED = (1 << 15),
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
FILTER_RIDES = FILTER_RIDE_TRANSPORT | FILTER_RIDE_GENTLE | FILTER_RIDE_COASTER | FILTER_RIDE_THRILL | FILTER_RIDE_WATER | FILTER_RIDE_STALL,
|
2018-01-31 13:07:20 +01:00
|
|
|
FILTER_ALL = FILTER_RIDES | FILTER_RCT1 | FILTER_AA | FILTER_LL | FILTER_RCT2 | FILTER_WW | FILTER_TT | FILTER_OO | FILTER_CUSTOM | FILTER_SELECTED | FILTER_NONSELECTED,
|
2017-08-02 00:20:32 +02:00
|
|
|
};
|
2015-06-03 18:37:07 +02:00
|
|
|
|
2018-01-31 13:07:20 +01:00
|
|
|
static constexpr uint8 _numSourceGameItems = 8;
|
|
|
|
|
2017-08-06 14:41:13 +02:00
|
|
|
static uint32 _filter_flags;
|
|
|
|
static uint16 _filter_object_counts[11];
|
2015-06-03 18:37:07 +02:00
|
|
|
|
2017-11-23 12:08:04 +01:00
|
|
|
static char _filter_string[MAX_PATH];
|
2015-06-06 00:54:47 +02:00
|
|
|
|
2015-06-03 18:37:07 +02:00
|
|
|
#define _FILTER_ALL ((_filter_flags & FILTER_ALL) == FILTER_ALL)
|
2018-01-31 13:07:20 +01:00
|
|
|
#define _FILTER_RCT1 (_filter_flags & FILTER_RCT1)
|
|
|
|
#define _FILTER_AA (_filter_flags & FILTER_AA)
|
|
|
|
#define _FILTER_LL (_filter_flags & FILTER_LL)
|
2015-06-03 18:37:07 +02:00
|
|
|
#define _FILTER_RCT2 (_filter_flags & FILTER_RCT2)
|
|
|
|
#define _FILTER_WW (_filter_flags & FILTER_WW)
|
|
|
|
#define _FILTER_TT (_filter_flags & FILTER_TT)
|
2018-01-31 13:07:20 +01:00
|
|
|
#define _FILTER_OO (_filter_flags & FILTER_OO)
|
2015-06-03 18:37:07 +02:00
|
|
|
#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 {
|
2017-06-06 23:24:18 +02:00
|
|
|
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_COUNT
|
2015-02-11 17:02:57 +01:00
|
|
|
};
|
|
|
|
|
2018-01-11 14:50:31 +01:00
|
|
|
static constexpr const rct_string_id ObjectSelectionPageNames[WINDOW_OBJECT_SELECTION_PAGE_COUNT] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
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,
|
2016-07-14 14:07:49 +02:00
|
|
|
};
|
|
|
|
|
2014-11-25 00:05:35 +01:00
|
|
|
#pragma region Widgets
|
|
|
|
|
|
|
|
enum WINDOW_STAFF_LIST_WIDGET_IDX {
|
2017-06-06 23:24:18 +02: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
|
2018-02-08 20:51:35 +01:00
|
|
|
WIDX_ADVANCED, // 14, 4000
|
|
|
|
WIDX_LIST, // 15, 8000
|
|
|
|
WIDX_PREVIEW, // 16, 10000
|
|
|
|
WIDX_INSTALL_TRACK, // 17, 20000
|
|
|
|
WIDX_FILTER_DROPDOWN, // 18, 40000
|
|
|
|
WIDX_FILTER_STRING_BUTTON, // 19, 80000
|
|
|
|
WIDX_FILTER_CLEAR_BUTTON, // 20, 100000
|
|
|
|
WIDX_FILTER_RIDE_TAB_FRAME, // 21, 200000
|
2017-06-06 23:24:18 +02:00
|
|
|
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,
|
|
|
|
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[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_FRAME, 0, 0, 599, 0, 399, 0xFFFFFFFF, STR_NONE },
|
|
|
|
{ WWT_CAPTION, 0, 1, 598, 1, 14, STR_OBJECT_SELECTION, STR_WINDOW_TITLE_TIP },
|
|
|
|
{ WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
|
|
|
{ WWT_RESIZE, 1, 0, 599, 43, 399, 0xFFFFFFFF, STR_NONE },
|
2017-07-20 20:56:29 +02:00
|
|
|
{ WWT_TAB, 1, 3, 33, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 34, 64, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 65, 95, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 96, 126, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 127, 157, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 158, 188, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 189, 219, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 220, 250, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 251, 281, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
|
|
|
{ WWT_TAB, 1, 282, 312, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_STRING_DEFINED_TOOLTIP },
|
2018-01-03 20:30:58 +01:00
|
|
|
{ WWT_BUTTON, 0, 470, 591, 23, 34, STR_OBJECT_SELECTION_ADVANCED, STR_OBJECT_SELECTION_ADVANCED_TIP },
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_SCROLL, 1, 4, 291, 60, 386, SCROLL_VERTICAL, STR_NONE },
|
|
|
|
{ WWT_FLATBTN, 1, 391, 504, 46, 159, 0xFFFFFFFF, STR_NONE },
|
2018-01-03 20:30:58 +01:00
|
|
|
{ WWT_BUTTON, 0, 470, 591, 23, 34, STR_INSTALL_NEW_TRACK_DESIGN, STR_INSTALL_NEW_TRACK_DESIGN_TIP },
|
|
|
|
{ WWT_BUTTON, 0, 350, 463, 23, 34, STR_OBJECT_FILTER, STR_OBJECT_FILTER_TIP },
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_TEXT_BOX, 1, 4, 214, 46, 57, STR_NONE, STR_NONE },
|
2018-01-03 20:30:58 +01:00
|
|
|
{ WWT_BUTTON, 1, 218, 287, 46, 57, STR_OBJECT_SEARCH_CLEAR, STR_NONE },
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_IMGBTN, 1, 3, 287, 73, 76, 0xFFFFFFFF, STR_NONE },
|
2017-07-20 20:56:29 +02:00
|
|
|
{ WWT_TAB, 1, 3, 33, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_OBJECT_FILTER_ALL_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 34, 64, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_TRANSPORT_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 65, 95, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_GENTLE_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 96, 126, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_ROLLER_COASTERS_TIP },
|
|
|
|
{ WWT_TAB, 1, 127, 157, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_THRILL_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 158, 188, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_WATER_RIDES_TIP },
|
|
|
|
{ WWT_TAB, 1, 189, 219, 47, 73, IMAGE_TYPE_REMAP | SPR_TAB, STR_SHOPS_STALLS_TIP },
|
2018-01-03 19:12:44 +01:00
|
|
|
{ WWT_TABLE_HEADER, 1, 4, 204, 80, 93, STR_NONE, STR_NONE },
|
|
|
|
{ WWT_TABLE_HEADER, 1, 205, 291, 80, 93, STR_NONE, STR_NONE },
|
2017-06-06 23:24:18 +02: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-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_object_selection_resize(rct_window *w);
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_editor_object_selection_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_dropdown(rct_window *w, rct_widgetindex 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);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_tooltip(rct_window* w, rct_widgetindex 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);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_textinput(rct_window *w, rct_widgetindex widgetIndex, char *text);
|
2015-07-10 02:39:16 +02:00
|
|
|
|
|
|
|
static rct_window_event_list window_editor_object_selection_events = {
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_object_selection_close,
|
|
|
|
window_editor_object_selection_mouseup,
|
|
|
|
window_editor_object_selection_resize,
|
|
|
|
window_editor_object_selection_mousedown,
|
|
|
|
window_editor_object_selection_dropdown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_object_selection_update,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_object_selection_scrollgetsize,
|
|
|
|
window_editor_object_selection_scroll_mousedown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_object_selection_scroll_mouseover,
|
|
|
|
window_editor_object_selection_textinput,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_object_selection_tooltip,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
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
|
|
|
|
|
2018-01-11 14:50:31 +01:00
|
|
|
static constexpr const sint32 window_editor_object_selection_animation_loops[] = { 20, 32, 10, 72, 24, 28, 16 };
|
|
|
|
static constexpr 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);
|
2017-01-04 22:17:08 +01:00
|
|
|
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
|
|
|
|
2017-12-05 13:55:33 +01:00
|
|
|
static std::string object_get_description(const void * object);
|
|
|
|
|
2015-06-26 02:11:24 +02:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
RIDE_SORT_TYPE,
|
|
|
|
RIDE_SORT_RIDE
|
2015-06-26 02:11:24 +02:00
|
|
|
};
|
2015-06-25 17:48:32 +02:00
|
|
|
|
2016-06-30 22:55:18 +02:00
|
|
|
enum {
|
2018-01-31 13:07:20 +01:00
|
|
|
DDIX_FILTER_RCT1,
|
|
|
|
DDIX_FILTER_AA,
|
|
|
|
DDIX_FILTER_LL,
|
2017-06-06 23:24:18 +02:00
|
|
|
DDIX_FILTER_RCT2,
|
|
|
|
DDIX_FILTER_WW,
|
|
|
|
DDIX_FILTER_TT,
|
2018-01-31 13:07:20 +01:00
|
|
|
DDIX_FILTER_OO,
|
2017-06-06 23:24:18 +02:00
|
|
|
DDIX_FILTER_CUSTOM,
|
2017-11-13 16:25:31 +01:00
|
|
|
DDIX_FILTER_SEPARATOR,
|
2017-06-06 23:24:18 +02:00
|
|
|
DDIX_FILTER_SELECTED,
|
|
|
|
DDIX_FILTER_NONSELECTED,
|
2016-06-30 22:55:18 +02:00
|
|
|
};
|
|
|
|
|
2018-02-14 09:42:26 +01:00
|
|
|
struct list_item {
|
2017-06-06 23:24:18 +02:00
|
|
|
const ObjectRepositoryItem * repositoryItem;
|
|
|
|
rct_object_entry *entry;
|
|
|
|
rct_object_filters *filter;
|
|
|
|
uint8 *flags;
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2015-06-25 17:48:32 +02:00
|
|
|
|
2016-07-02 11:59:50 +02:00
|
|
|
static rct_string_id get_ride_type_string_id(const ObjectRepositoryItem * item);
|
|
|
|
|
2018-02-14 09:42:26 +01:00
|
|
|
using sortFunc_t = bool (*)(const list_item &, const list_item &);
|
2015-06-26 02:11:24 +02:00
|
|
|
|
2018-01-21 03:39:52 +01:00
|
|
|
static std::vector<list_item> _listItems;
|
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;
|
2017-08-15 10:07:44 +02:00
|
|
|
static void * _loadedObject = nullptr;
|
2015-06-25 17:48:32 +02:00
|
|
|
|
|
|
|
static void visible_list_dispose()
|
|
|
|
{
|
2018-01-21 03:39:52 +01:00
|
|
|
_listItems.clear();
|
|
|
|
_listItems.shrink_to_fit();
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
|
|
|
|
2018-01-21 03:39:52 +01:00
|
|
|
static bool visible_list_sort_ride_name(const list_item &a, const list_item &b)
|
2015-06-26 02:11:24 +02:00
|
|
|
{
|
2018-01-21 03:39:52 +01:00
|
|
|
auto nameA = a.repositoryItem->Name;
|
|
|
|
auto nameB = b.repositoryItem->Name;
|
|
|
|
return strcmp(nameA, nameB) < 0;
|
2015-06-26 02:11:24 +02:00
|
|
|
}
|
|
|
|
|
2018-01-21 03:39:52 +01:00
|
|
|
static bool visible_list_sort_ride_type(const list_item &a, const list_item &b)
|
2015-06-25 17:48:32 +02:00
|
|
|
{
|
2018-01-21 03:39:52 +01:00
|
|
|
auto rideTypeA = language_get_string(get_ride_type_string_id(a.repositoryItem));
|
|
|
|
auto rideTypeB = language_get_string(get_ride_type_string_id(b.repositoryItem));
|
2018-03-30 17:58:12 +02:00
|
|
|
sint32 result = String::Compare(rideTypeA, rideTypeB);
|
2018-01-21 03:39:52 +01:00
|
|
|
return result != 0 ?
|
|
|
|
result < 0 :
|
|
|
|
visible_list_sort_ride_name(a, b);
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void visible_list_refresh(rct_window *w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 numObjects = (sint32)object_repository_get_items_count();
|
|
|
|
|
|
|
|
visible_list_dispose();
|
|
|
|
w->selected_list_item = -1;
|
|
|
|
|
|
|
|
const ObjectRepositoryItem *items = object_repository_get_items();
|
|
|
|
for (sint32 i = 0; i < numObjects; i++) {
|
|
|
|
uint8 selectionFlags = _objectSelectionFlags[i];
|
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0x0F;
|
|
|
|
if (objectType == w->selected_tab && !(selectionFlags & OBJECT_SELECTION_FLAG_6) &&
|
|
|
|
filter_source(item) &&
|
|
|
|
filter_string(item) &&
|
|
|
|
filter_chunks(item) &&
|
|
|
|
filter_selected(selectionFlags)
|
|
|
|
) {
|
2017-08-02 00:20:32 +02:00
|
|
|
rct_object_filters * filter = new rct_object_filters;
|
|
|
|
filter->ride.category[0] = 0;
|
|
|
|
filter->ride.category[1] = 0;
|
|
|
|
filter->ride.ride_type = 0;
|
2018-01-21 03:39:52 +01:00
|
|
|
|
|
|
|
list_item currentListItem;
|
|
|
|
currentListItem.repositoryItem = item;
|
|
|
|
currentListItem.entry = (rct_object_entry *)&item->ObjectEntry;
|
|
|
|
currentListItem.filter = filter;
|
|
|
|
currentListItem.flags = &_objectSelectionFlags[i];
|
|
|
|
_listItems.push_back(std::move(currentListItem));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-21 03:39:52 +01:00
|
|
|
if (_listItems.size() == 0)
|
2017-06-06 23:24:18 +02:00
|
|
|
{
|
|
|
|
visible_list_dispose();
|
|
|
|
}
|
2018-01-21 03:39:52 +01:00
|
|
|
else
|
|
|
|
{
|
2017-08-15 10:07:44 +02:00
|
|
|
sortFunc_t sortFunc = nullptr;
|
2018-01-21 03:39:52 +01:00
|
|
|
switch (_listSortType)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
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);
|
2018-01-21 03:39:52 +01:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-01-21 03:39:52 +01:00
|
|
|
if (sortFunc != nullptr)
|
|
|
|
{
|
|
|
|
std::sort(_listItems.begin(), _listItems.end(), sortFunc);
|
|
|
|
if (_listSortDescending)
|
|
|
|
{
|
|
|
|
std::reverse(_listItems.begin(), _listItems.end());
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window_invalidate(w);
|
2015-06-26 02:11:24 +02:00
|
|
|
}
|
2015-06-25 17:48:32 +02:00
|
|
|
|
2014-11-23 17:28:23 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AA64E
|
|
|
|
*/
|
2017-11-23 09:03:56 +01:00
|
|
|
rct_window * window_editor_object_selection_open()
|
2014-11-23 17:28:23 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window* window;
|
|
|
|
|
|
|
|
window = window_bring_to_front_by_class(WC_EDITOR_OBJECT_SELECTION);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (window != nullptr)
|
2017-11-23 09:03:56 +01:00
|
|
|
return window;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-02-11 18:56:12 +01:00
|
|
|
sub_6AB211();
|
2017-06-06 23:24:18 +02:00
|
|
|
reset_selected_object_count_and_size();
|
|
|
|
|
|
|
|
window = window_create_centred(
|
|
|
|
600,
|
|
|
|
400,
|
|
|
|
&window_editor_object_selection_events,
|
|
|
|
WC_EDITOR_OBJECT_SELECTION,
|
|
|
|
WF_10 | WF_RESIZABLE
|
|
|
|
);
|
|
|
|
window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].string = _filter_string;
|
|
|
|
window->widgets = window_editor_object_selection_widgets;
|
|
|
|
|
|
|
|
window->enabled_widgets =
|
|
|
|
(1 << WIDX_ADVANCED) |
|
|
|
|
(1 << WIDX_INSTALL_TRACK) |
|
|
|
|
(1 << WIDX_FILTER_DROPDOWN) |
|
|
|
|
(1 << WIDX_FILTER_STRING_BUTTON) |
|
|
|
|
(1 << WIDX_FILTER_CLEAR_BUTTON) |
|
|
|
|
(1 << WIDX_CLOSE) |
|
|
|
|
(1 << WIDX_LIST_SORT_TYPE) |
|
|
|
|
(((uint32)1) << WIDX_LIST_SORT_RIDE);
|
|
|
|
|
|
|
|
_filter_flags = gConfigInterface.object_selection_filter_flags;
|
|
|
|
memset(_filter_string, 0, sizeof(_filter_string));
|
|
|
|
|
2018-02-08 20:51:35 +01:00
|
|
|
for (sint32 i = WIDX_TAB_1; i <= WIDX_TAB_10; i++)
|
2017-06-06 23:24:18 +02:00
|
|
|
window->enabled_widgets |= (1LL << i);
|
|
|
|
window_init_scroll_widgets(window);
|
|
|
|
|
|
|
|
window->var_4AE = 0;
|
|
|
|
window->selected_tab = 0;
|
|
|
|
window->selected_list_item = -1;
|
2017-10-15 15:53:16 +02:00
|
|
|
window->object_entry = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
window->min_width = 600;
|
|
|
|
window->min_height = 400;
|
|
|
|
window->max_width = 1200;
|
|
|
|
window->max_height = 1000;
|
|
|
|
|
|
|
|
visible_list_refresh(window);
|
2017-11-23 09:03:56 +01:00
|
|
|
|
|
|
|
return window;
|
2014-11-25 00:05:35 +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: 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
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
//if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
|
|
|
|
// return;
|
|
|
|
|
|
|
|
unload_unselected_objects();
|
|
|
|
editor_load_selected_objects();
|
|
|
|
editor_object_flags_free();
|
|
|
|
|
|
|
|
object_delete(_loadedObject);
|
2017-08-15 10:07:44 +02:00
|
|
|
_loadedObject = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_EDITOR) {
|
|
|
|
research_populate_list_random();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Used for in-game object selection cheat
|
|
|
|
// This resets the ride selection list and resets research to 0 on current item
|
|
|
|
gSilentResearch = true;
|
|
|
|
research_reset_current_item();
|
|
|
|
gSilentResearch = false;
|
|
|
|
}
|
2017-10-07 01:28:00 +02:00
|
|
|
|
|
|
|
auto intent = Intent(INTENT_ACTION_REFRESH_NEW_RIDES);
|
|
|
|
context_broadcast_intent(&intent);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
visible_list_dispose();
|
2017-11-11 15:03:59 +01:00
|
|
|
|
2017-11-12 02:32:11 +01:00
|
|
|
intent = Intent(INTENT_ACTION_REFRESH_SCENERY);
|
|
|
|
context_broadcast_intent(&intent);
|
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-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
2014-11-25 00:05:35 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_EDITOR) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
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:
|
|
|
|
window_editor_object_set_page(w, widgetIndex - WIDX_TAB_1);
|
|
|
|
break;
|
|
|
|
case WIDX_FILTER_RIDE_TAB_ALL:
|
|
|
|
_filter_flags |= FILTER_RIDES;
|
|
|
|
gConfigInterface.object_selection_filter_flags = _filter_flags;
|
|
|
|
config_save_default();
|
|
|
|
|
|
|
|
filter_update_counts();
|
|
|
|
visible_list_refresh(w);
|
|
|
|
|
|
|
|
w->selected_list_item = -1;
|
2017-10-15 15:53:16 +02:00
|
|
|
w->object_entry = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls[0].v_top = 0;
|
|
|
|
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:
|
|
|
|
_filter_flags &= ~FILTER_RIDES;
|
2018-01-31 13:07:20 +01:00
|
|
|
_filter_flags |= (1 << (widgetIndex - WIDX_FILTER_RIDE_TAB_TRANSPORT + _numSourceGameItems));
|
2017-06-06 23:24:18 +02:00
|
|
|
gConfigInterface.object_selection_filter_flags = _filter_flags;
|
|
|
|
config_save_default();
|
|
|
|
|
|
|
|
filter_update_counts();
|
|
|
|
visible_list_refresh(w);
|
|
|
|
|
|
|
|
w->selected_list_item = -1;
|
2017-10-15 15:53:16 +02:00
|
|
|
w->object_entry = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls[0].v_top = 0;
|
|
|
|
w->frame_no = 0;
|
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WIDX_ADVANCED:
|
|
|
|
w->list_information_type ^= 1;
|
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WIDX_INSTALL_TRACK:
|
2017-09-12 00:04:03 +02:00
|
|
|
{
|
|
|
|
if (w->selected_list_item != -1)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = -1;
|
|
|
|
}
|
|
|
|
window_invalidate(w);
|
|
|
|
|
2017-09-12 00:04:03 +02:00
|
|
|
auto intent = Intent(WC_LOADSAVE);
|
2017-09-12 21:21:39 +02:00
|
|
|
intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK);
|
2017-09-12 00:04:03 +02:00
|
|
|
context_open_intent(&intent);
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
2017-09-12 00:04:03 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
case WIDX_FILTER_STRING_BUTTON:
|
2017-11-23 12:08:04 +01:00
|
|
|
window_start_textbox(w, widgetIndex, STR_STRING, _filter_string, sizeof(_filter_string));
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
case WIDX_FILTER_CLEAR_BUTTON:
|
|
|
|
memset(_filter_string, 0, sizeof(_filter_string));
|
|
|
|
filter_update_counts();
|
|
|
|
w->scrolls->v_top = 0;
|
|
|
|
visible_list_refresh(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
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
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_set_resize(w, 600, 400, 1200, 1000);
|
2015-06-25 17:48:32 +02:00
|
|
|
}
|
2016-06-30 22:55:18 +02:00
|
|
|
|
2017-07-03 23:09:46 +02:00
|
|
|
void window_editor_object_selection_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget)
|
2015-06-03 18:37:07 +02:00
|
|
|
{
|
2018-01-31 13:07:20 +01:00
|
|
|
sint32 numSelectionItems = 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_FILTER_DROPDOWN:
|
|
|
|
|
2018-01-31 13:07:20 +01:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_RCT1] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_AA] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_LL] = STR_TOGGLE_OPTION;
|
2017-06-06 23:24:18 +02:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_RCT2] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_WW] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_TT] = STR_TOGGLE_OPTION;
|
2018-01-31 13:07:20 +01:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_OO] = STR_TOGGLE_OPTION;
|
2017-06-06 23:24:18 +02:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_CUSTOM] = STR_TOGGLE_OPTION;
|
2018-01-31 13:07:20 +01:00
|
|
|
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_RCT1] = STR_SCENARIO_CATEGORY_RCT1;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_AA] = STR_SCENARIO_CATEGORY_RCT1_AA;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_LL] = STR_SCENARIO_CATEGORY_RCT1_LL;
|
2017-06-06 23:24:18 +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;
|
2018-01-31 13:07:20 +01:00
|
|
|
gDropdownItemsArgs[DDIX_FILTER_OO] = STR_OBJECT_FILTER_OPENRCT2_OFFICIAL;
|
2017-06-06 23:24:18 +02:00
|
|
|
gDropdownItemsArgs[DDIX_FILTER_CUSTOM] = STR_OBJECT_FILTER_CUSTOM;
|
2018-01-31 13:07:20 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Track manager cannot select multiple, so only show selection filters if not in track manager
|
2018-01-31 13:07:20 +01:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER))
|
|
|
|
{
|
|
|
|
numSelectionItems = 3;
|
2017-11-13 16:25:31 +01:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_SEPARATOR] = 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
gDropdownItemsFormat[DDIX_FILTER_SELECTED] = STR_TOGGLE_OPTION;
|
|
|
|
gDropdownItemsFormat[DDIX_FILTER_NONSELECTED] = STR_TOGGLE_OPTION;
|
2017-11-13 16:25:31 +01:00
|
|
|
gDropdownItemsArgs[DDIX_FILTER_SEPARATOR] = STR_NONE;
|
2017-06-06 23:24:18 +02:00
|
|
|
gDropdownItemsArgs[DDIX_FILTER_SELECTED] = STR_SELECTED_ONLY;
|
|
|
|
gDropdownItemsArgs[DDIX_FILTER_NONSELECTED] = STR_NON_SELECTED_ONLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2018-01-31 13:07:20 +01:00
|
|
|
_numSourceGameItems + numSelectionItems
|
2017-06-06 23:24:18 +02:00
|
|
|
);
|
|
|
|
|
2018-01-31 13:07:20 +01:00
|
|
|
for (sint32 i = 0; i < _numSourceGameItems; i++)
|
2017-07-24 11:24:23 +02:00
|
|
|
{
|
|
|
|
if (_filter_flags & (1 << i))
|
|
|
|
{
|
|
|
|
dropdown_set_checked(i, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
2017-08-15 10:03:10 +02:00
|
|
|
dropdown_set_checked(DDIX_FILTER_SELECTED, _FILTER_SELECTED != 0);
|
|
|
|
dropdown_set_checked(DDIX_FILTER_NONSELECTED, _FILTER_NONSELECTED != 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2015-06-03 18:37:07 +02:00
|
|
|
}
|
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_dropdown(rct_window *w, rct_widgetindex widgetIndex, sint32 dropdownIndex)
|
2015-06-03 18:37:07 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (dropdownIndex == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_FILTER_DROPDOWN:
|
|
|
|
if (dropdownIndex == DDIX_FILTER_SELECTED) {
|
|
|
|
_filter_flags ^= FILTER_SELECTED;
|
|
|
|
_filter_flags &= ~FILTER_NONSELECTED;
|
|
|
|
}
|
|
|
|
else if (dropdownIndex == DDIX_FILTER_NONSELECTED) {
|
|
|
|
_filter_flags ^= FILTER_NONSELECTED;
|
|
|
|
_filter_flags &= ~FILTER_SELECTED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_filter_flags ^= (1 << dropdownIndex);
|
|
|
|
}
|
|
|
|
gConfigInterface.object_selection_filter_flags = _filter_flags;
|
|
|
|
config_save_default();
|
|
|
|
|
|
|
|
filter_update_counts();
|
|
|
|
w->scrolls->v_top = 0;
|
|
|
|
|
|
|
|
visible_list_refresh(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
break;
|
|
|
|
}
|
2015-06-03 18:37:07 +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: 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
|
|
|
{
|
2018-01-21 03:39:52 +01:00
|
|
|
*height = (sint32)(_listItems.size() * 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
|
|
|
{
|
2017-06-06 23:24:18 +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);
|
|
|
|
|
|
|
|
sint32 selected_object = get_object_from_object_selection((w->selected_tab & 0xFF), y);
|
|
|
|
if (selected_object == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
list_item * listItem = &_listItems[selected_object];
|
|
|
|
uint8 object_selection_flags = *listItem->flags;
|
|
|
|
if (object_selection_flags & OBJECT_SELECTION_FLAG_6)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window_invalidate(w);
|
|
|
|
|
|
|
|
const CursorState * state = context_get_cursor_state();
|
|
|
|
audio_play_sound(SOUND_CLICK_1, 0, state->x);
|
|
|
|
|
|
|
|
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
|
|
|
if (!window_editor_object_selection_select_object(0, 1, listItem->entry))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Close any other open windows such as options/colour schemes to prevent a crash.
|
|
|
|
window_close_all();
|
|
|
|
//window_close(w);
|
|
|
|
|
|
|
|
// This function calls window_track_list_open
|
|
|
|
window_editor_object_selection_manage_tracks();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sint32 ebx = 6;
|
|
|
|
// If already selected
|
|
|
|
if (!(object_selection_flags & OBJECT_SELECTION_FLAG_SELECTED))
|
|
|
|
ebx = 7;
|
|
|
|
|
|
|
|
_maxObjectsWasHit = false;
|
|
|
|
if (!window_editor_object_selection_select_object(0, ebx, listItem->entry)) {
|
|
|
|
rct_string_id error_title = (ebx & 1) ?
|
|
|
|
STR_UNABLE_TO_SELECT_THIS_OBJECT :
|
|
|
|
STR_UNABLE_TO_DE_SELECT_THIS_OBJECT;
|
|
|
|
|
2017-09-06 16:09:35 +02:00
|
|
|
context_show_error(error_title, gGameCommandErrorText);
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_FILTER_SELECTED || _FILTER_NONSELECTED) {
|
|
|
|
filter_update_counts();
|
|
|
|
visible_list_refresh(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_maxObjectsWasHit) {
|
2017-09-06 16:09:35 +02:00
|
|
|
context_show_error(STR_WARNING_TOO_MANY_OBJECTS_SELECTED, STR_NOT_ALL_OBJECTS_IN_THIS_SCENERY_GROUP_COULD_BE_SELECTED);
|
2017-06-06 23:24:18 +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: 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-06-06 23:24:18 +02:00
|
|
|
sint32 selectedObject = get_object_from_object_selection(w->selected_tab & 0xFF, y);
|
|
|
|
if (selectedObject != -1) {
|
|
|
|
list_item * listItem = &_listItems[selectedObject];
|
|
|
|
uint8 objectSelectionFlags = *listItem->flags;
|
|
|
|
if (objectSelectionFlags & OBJECT_SELECTION_FLAG_6) {
|
|
|
|
selectedObject = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (selectedObject != w->selected_list_item) {
|
|
|
|
w->selected_list_item = selectedObject;
|
|
|
|
|
|
|
|
object_delete(_loadedObject);
|
2017-08-15 10:07:44 +02:00
|
|
|
_loadedObject = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
list_item * listItem = &_listItems[selectedObject];
|
|
|
|
if (selectedObject == -1) {
|
2017-08-15 10:07:44 +02:00
|
|
|
w->object_entry = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
} else {
|
|
|
|
w->object_entry = listItem->entry;
|
|
|
|
_loadedObject = object_repository_load_object(listItem->entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId)
|
2015-02-11 17:02:57 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02: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:
|
|
|
|
set_format_arg(0, rct_string_id, ObjectSelectionPageNames[(widgetIndex - WIDX_TAB_1)]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
set_format_arg(0, rct_string_id, STR_LIST);
|
|
|
|
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: 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
|
|
|
{
|
2017-06-06 23:24:18 +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;
|
|
|
|
w->widgets[WIDX_ADVANCED].left = w->width - 130;
|
|
|
|
w->widgets[WIDX_ADVANCED].right = w->width - 9;
|
|
|
|
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;
|
|
|
|
w->widgets[WIDX_INSTALL_TRACK].left = w->width - 130;
|
|
|
|
w->widgets[WIDX_INSTALL_TRACK].right = w->width - 9;
|
|
|
|
w->widgets[WIDX_FILTER_DROPDOWN].left = w->width - 250;
|
|
|
|
w->widgets[WIDX_FILTER_DROPDOWN].right = w->width - 137;
|
|
|
|
|
|
|
|
// Set pressed widgets
|
|
|
|
w->pressed_widgets |= 1 << WIDX_PREVIEW;
|
|
|
|
window_editor_object_selection_set_pressed_tab(w);
|
|
|
|
if (w->list_information_type & 1)
|
|
|
|
w->pressed_widgets |= (1 << WIDX_ADVANCED);
|
|
|
|
else
|
|
|
|
w->pressed_widgets &= ~(1 << WIDX_ADVANCED);
|
|
|
|
|
|
|
|
// Set window title and buttons
|
|
|
|
set_format_arg(0, rct_string_id, ObjectSelectionPageNames[w->selected_tab]);
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
|
|
|
w->widgets[WIDX_TITLE].text = STR_TRACK_DESIGNS_MANAGER_SELECT_RIDE_TYPE;
|
2018-01-03 20:30:58 +01:00
|
|
|
w->widgets[WIDX_INSTALL_TRACK].type = WWT_BUTTON;
|
2017-06-06 23:24:18 +02:00
|
|
|
} else if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) {
|
|
|
|
w->widgets[WIDX_TITLE].text = STR_ROLLER_COASTER_DESIGNER_SELECT_RIDE_TYPES_VEHICLES;
|
|
|
|
w->widgets[WIDX_INSTALL_TRACK].type = WWT_EMPTY;
|
|
|
|
} else {
|
|
|
|
w->widgets[WIDX_TITLE].text = STR_OBJECT_SELECTION;
|
|
|
|
w->widgets[WIDX_INSTALL_TRACK].type = WWT_EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Align tabs, hide advanced ones
|
|
|
|
sint32 x = 3;
|
|
|
|
for (sint32 i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) {
|
|
|
|
rct_widget *widget = &w->widgets[WIDX_TAB_1 + i];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TRACK_DESIGNER)) {
|
|
|
|
w->widgets[WIDX_ADVANCED].type = WWT_EMPTY;
|
|
|
|
for (sint32 i = 1; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++)
|
|
|
|
w->widgets[WIDX_TAB_1 + i].type = WWT_EMPTY;
|
|
|
|
x = 150;
|
|
|
|
} else {
|
2018-01-03 20:30:58 +01:00
|
|
|
w->widgets[WIDX_ADVANCED].type = WWT_BUTTON;
|
2017-06-06 23:24:18 +02:00
|
|
|
x = 300;
|
|
|
|
}
|
|
|
|
|
2018-01-03 20:30:58 +01:00
|
|
|
w->widgets[WIDX_FILTER_DROPDOWN].type = WWT_BUTTON;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets[WIDX_LIST].right = w->width - (600 - 587) - x;
|
|
|
|
w->widgets[WIDX_PREVIEW].left = w->width - (600 - 537) - (x / 2);
|
|
|
|
w->widgets[WIDX_PREVIEW].right = w->widgets[WIDX_PREVIEW].left + 113;
|
|
|
|
w->widgets[WIDX_FILTER_RIDE_TAB_FRAME].right = w->widgets[WIDX_LIST].right;
|
|
|
|
|
|
|
|
bool ridePage = (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS);
|
|
|
|
w->widgets[WIDX_LIST].top = (ridePage ? 118 : 60);
|
|
|
|
w->widgets[WIDX_FILTER_STRING_BUTTON].right = w->widgets[WIDX_LIST].right - 77;
|
|
|
|
w->widgets[WIDX_FILTER_STRING_BUTTON].top = (ridePage ? 80 : 46);
|
|
|
|
w->widgets[WIDX_FILTER_STRING_BUTTON].bottom = (ridePage ? 91 : 57);
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
for (sint32 i = 0; i < 7; i++)
|
|
|
|
w->pressed_widgets &= ~(1 << (WIDX_FILTER_RIDE_TAB_ALL + i));
|
|
|
|
if ((_filter_flags & FILTER_RIDES) == FILTER_RIDES)
|
|
|
|
w->pressed_widgets |= (1 << WIDX_FILTER_RIDE_TAB_ALL);
|
|
|
|
else {
|
|
|
|
for (sint32 i = 0; i < 6; i++) {
|
2018-02-04 13:34:41 +01:00
|
|
|
if (_filter_flags & (1 << (_numSourceGameItems + i)))
|
2017-08-06 02:26:14 +02:00
|
|
|
w->pressed_widgets |= (uint64)(1ULL << (WIDX_FILTER_RIDE_TAB_TRANSPORT + i));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
w->widgets[WIDX_FILTER_RIDE_TAB_FRAME].type = WWT_IMGBTN;
|
|
|
|
for (sint32 i = WIDX_FILTER_RIDE_TAB_ALL; i <= WIDX_FILTER_RIDE_TAB_STALL; i++)
|
|
|
|
w->widgets[i].type = WWT_TAB;
|
|
|
|
|
2018-01-03 19:12:44 +01:00
|
|
|
w->widgets[WIDX_LIST_SORT_TYPE].type = WWT_TABLE_HEADER;
|
2017-06-06 23:24:18 +02:00
|
|
|
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;
|
2018-01-03 19:12:44 +01:00
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].type = WWT_TABLE_HEADER;
|
2017-06-06 23:24:18 +02:00
|
|
|
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 {
|
|
|
|
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));
|
|
|
|
for (sint32 i = WIDX_FILTER_RIDE_TAB_FRAME; i <= WIDX_FILTER_RIDE_TAB_STALL; i++)
|
|
|
|
w->widgets[i].type = WWT_EMPTY;
|
|
|
|
|
|
|
|
w->widgets[WIDX_LIST_SORT_TYPE].type = WWT_EMPTY;
|
|
|
|
w->widgets[WIDX_LIST_SORT_RIDE].type = WWT_EMPTY;
|
|
|
|
}
|
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
|
|
|
{
|
2018-02-08 20:51:35 +01:00
|
|
|
sint32 i, x, y, width;
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_widget *widget;
|
|
|
|
rct_object_entry *highlightedEntry;
|
|
|
|
rct_string_id stringId;
|
|
|
|
|
|
|
|
/*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
|
|
|
|
);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
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;
|
|
|
|
gfx_draw_sprite(dpi, SPR_TAB_RIDE_16 + i, x, y, 0);
|
|
|
|
}
|
|
|
|
|
2017-07-20 20:56:29 +02:00
|
|
|
const sint32 ride_tabs[] = { SPR_TAB_RIDE_16, IMAGE_TYPE_REMAP | SPR_TAB_RIDES_TRANSPORT_0, SPR_TAB_RIDES_GENTLE_0, IMAGE_TYPE_REMAP | 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 };
|
2017-06-06 23:24:18 +02:00
|
|
|
const sint32 ThrillRidesTabAnimationSequence[] = {
|
|
|
|
5, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
// Draw ride tabs
|
|
|
|
if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
widget = &w->widgets[WIDX_FILTER_RIDE_TAB_ALL + i];
|
|
|
|
if (widget->type == WWT_EMPTY)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sint32 spriteIndex = ride_tabs[i];
|
|
|
|
sint32 frame = 0;
|
|
|
|
if (i != 0 && w->pressed_widgets & (1ULL << (WIDX_FILTER_RIDE_TAB_ALL + i))) {
|
|
|
|
frame = w->frame_no / window_editor_object_selection_animation_divisor[i - 1];
|
|
|
|
}
|
|
|
|
spriteIndex += (i == 4 ? ThrillRidesTabAnimationSequence[frame] : frame);
|
|
|
|
|
|
|
|
x = w->x + widget->left;
|
|
|
|
y = w->y + widget->top;
|
|
|
|
gfx_draw_sprite(dpi, spriteIndex | (w->colours[1] << 19), x, y, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
ColourMapA[w->colours[1]].darkest
|
|
|
|
);
|
|
|
|
|
|
|
|
// Draw number of selected items
|
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
|
|
|
x = w->x + 3;
|
|
|
|
y = w->y + w->height - 13;
|
|
|
|
|
|
|
|
sint32 numSelected = _numSelectedObjectsForType[w->selected_tab];
|
|
|
|
sint32 totalSelectable = object_entry_group_counts[w->selected_tab];
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
|
|
|
totalSelectable = 4;
|
|
|
|
|
|
|
|
set_format_arg(0, uint16, numSelected);
|
|
|
|
set_format_arg(2, uint16, totalSelectable);
|
|
|
|
gfx_draw_string_left(dpi, STR_OBJECT_SELECTION_SELECTION_SIZE, gCommonFormatArgs, COLOUR_BLACK, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
if (w->selected_list_item == -1 || _loadedObject == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
list_item *listItem = &_listItems[w->selected_list_item];
|
|
|
|
|
|
|
|
highlightedEntry = w->object_entry;
|
|
|
|
|
|
|
|
// Draw preview
|
|
|
|
widget = &w->widgets[WIDX_PREVIEW];
|
|
|
|
{
|
|
|
|
rct_drawpixelinfo clipDPI;
|
|
|
|
x = w->x + widget->left + 1;
|
|
|
|
y = w->y + widget->top + 1;
|
|
|
|
width = widget->right - widget->left - 1;
|
|
|
|
sint32 height = widget->bottom - widget->top - 1;
|
|
|
|
if (clip_drawpixelinfo(&clipDPI, dpi, x, y, width, height)) {
|
|
|
|
object_draw_preview(_loadedObject, &clipDPI, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, listItem->repositoryItem->Name);
|
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, x, y, width);
|
|
|
|
|
|
|
|
// Draw description of object
|
2017-12-05 13:55:33 +01:00
|
|
|
auto description = object_get_description(_loadedObject);
|
|
|
|
if (!description.empty()) {
|
2017-06-06 23:24:18 +02:00
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
2017-12-05 13:55:33 +01:00
|
|
|
set_format_arg(2, const char *, description.c_str());
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
x = w->x + w->widgets[WIDX_LIST].right + 4;
|
|
|
|
y += 15;
|
|
|
|
width = w->x + w->width - x - 4;
|
2018-02-08 20:51:35 +01:00
|
|
|
|
|
|
|
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y + 5, width, STR_WINDOW_COLOUR_2_STRINGID, COLOUR_BLACK);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw object source
|
2018-01-31 13:07:20 +01:00
|
|
|
stringId = object_manager_get_source_game_string(highlightedEntry);
|
2017-08-15 10:07:44 +02:00
|
|
|
gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, w->x + w->width - 5, w->y + w->height - 3 - 12 - 14);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
|
|
|
|
y = w->y + w->height - 3 - 12 - 14 - 14;
|
|
|
|
stringId = get_ride_type_string_id(listItem->repositoryItem);
|
2017-08-15 10:07:44 +02:00
|
|
|
gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, w->x + w->width - 5, y);
|
2017-06-06 23:24:18 +02:00
|
|
|
y -= 11;
|
|
|
|
}
|
|
|
|
|
|
|
|
//stringId = highlightedEntry->checksum
|
2017-08-15 10:07:44 +02:00
|
|
|
// gfx_draw_string_right(dpi, stringId, nullptr, 2, w->x + w->width - 5, w->y + w->height - 3 - 12 - 14);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw object dat name
|
|
|
|
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);
|
|
|
|
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
|
|
|
{
|
2018-01-21 03:39:52 +01:00
|
|
|
sint32 x, y, colour, colour2;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
bool ridePage = (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS);
|
|
|
|
|
|
|
|
uint8 paletteIndex = ColourMapA[w->colours[1]].mid_light;
|
|
|
|
gfx_clear(dpi, paletteIndex);
|
|
|
|
|
|
|
|
y = 0;
|
2018-01-21 03:39:52 +01:00
|
|
|
for (const auto &listItem : _listItems)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (y + 12 >= dpi->y && y <= dpi->y + dpi->height) {
|
|
|
|
// Draw checkbox
|
2018-01-21 03:39:52 +01:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && !(*listItem.flags & 0x20))
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_fill_rect_inset(dpi, 2, y, 11, y + 10, w->colours[1], INSET_RECT_F_E0);
|
|
|
|
|
|
|
|
// Highlight background
|
|
|
|
colour = COLOUR_BRIGHT_GREEN | COLOUR_FLAG_TRANSLUCENT;
|
2018-01-21 03:39:52 +01:00
|
|
|
if (listItem.entry == w->object_entry && !(*listItem.flags & OBJECT_SELECTION_FLAG_6)) {
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_filter_rect(dpi, 0, y, w->width, y + 11, PALETTE_DARKEN_1);
|
|
|
|
colour = COLOUR_BRIGHT_GREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw checkmark
|
2018-01-21 03:39:52 +01:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && (*listItem.flags & OBJECT_SELECTION_FLAG_SELECTED)) {
|
2017-06-06 23:24:18 +02:00
|
|
|
x = 2;
|
|
|
|
gCurrentFontSpriteBase = colour == COLOUR_BRIGHT_GREEN ? FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK : FONT_SPRITE_BASE_MEDIUM_DARK;
|
|
|
|
colour2 = NOT_TRANSLUCENT(w->colours[1]);
|
2018-01-21 03:39:52 +01:00
|
|
|
if (*listItem.flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
|
2017-06-06 23:24:18 +02:00
|
|
|
colour2 |= COLOUR_FLAG_INSET;
|
|
|
|
|
|
|
|
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour2, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
x = gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15;
|
|
|
|
|
|
|
|
char *bufferWithColour = gCommonStringFormatBuffer;
|
|
|
|
char *buffer = utf8_write_codepoint(bufferWithColour, colour);
|
2018-01-21 03:39:52 +01:00
|
|
|
if (*listItem.flags & OBJECT_SELECTION_FLAG_6) {
|
2017-06-06 23:24:18 +02:00
|
|
|
colour = w->colours[1] & 0x7F;
|
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
colour = COLOUR_BLACK;
|
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ridePage) {
|
|
|
|
// Draw ride type
|
2018-01-21 03:39:52 +01:00
|
|
|
rct_string_id rideTypeStringId = get_ride_type_string_id(listItem.repositoryItem);
|
2017-06-06 23:24:18 +02:00
|
|
|
safe_strcpy(buffer, language_get_string(rideTypeStringId), 256 - (buffer - bufferWithColour));
|
|
|
|
gfx_draw_string(dpi, bufferWithColour, colour, x, y);
|
|
|
|
x = w->widgets[WIDX_LIST_SORT_RIDE].left - w->widgets[WIDX_LIST].left;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw text
|
2018-01-21 03:39:52 +01:00
|
|
|
safe_strcpy(buffer, listItem.repositoryItem->Name, 256 - (buffer - bufferWithColour));
|
2017-06-06 23:24:18 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
|
|
|
while (*buffer != 0 && *buffer != 9)
|
|
|
|
buffer++;
|
|
|
|
|
|
|
|
*buffer = 0;
|
|
|
|
}
|
|
|
|
gfx_draw_string(dpi, bufferWithColour, colour, x, y);
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->selected_tab == page)
|
|
|
|
return;
|
|
|
|
|
|
|
|
w->selected_tab = page;
|
|
|
|
w->selected_list_item = -1;
|
2017-10-15 15:53:16 +02:00
|
|
|
w->object_entry = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls[0].v_top = 0;
|
|
|
|
w->frame_no = 0;
|
|
|
|
|
|
|
|
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);
|
|
|
|
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-06-06 23:24:18 +02:00
|
|
|
sint32 i;
|
|
|
|
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-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-06-06 23:24:18 +02:00
|
|
|
sint32 listItemIndex = y / 12;
|
2018-01-21 13:41:42 +01:00
|
|
|
if (listItemIndex < 0 || (size_t)listItemIndex >= _listItems.size())
|
2017-06-06 23:24:18 +02:00
|
|
|
return -1;
|
2015-06-25 17:48:32 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
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
|
|
|
{
|
2018-01-10 12:40:50 +01:00
|
|
|
set_every_ride_type_invented();
|
2018-01-02 20:31:48 +01:00
|
|
|
set_every_ride_entry_invented();
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_TRACK_DESIGNS_MANAGER;
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 entry_index = 0;
|
2018-02-11 19:56:09 +01:00
|
|
|
for (; object_entry_get_chunk(OBJECT_TYPE_RIDE, entry_index) == nullptr; entry_index++);
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_ride_entry* ride_entry = get_ride_entry(entry_index);
|
2017-06-17 13:05:48 +02:00
|
|
|
uint8 ride_type = ride_entry_get_first_non_null_ride_type(ride_entry);
|
2015-02-02 19:49:07 +01:00
|
|
|
|
2017-10-21 16:37:30 +02:00
|
|
|
auto intent = Intent(WC_TRACK_DESIGN_LIST);
|
|
|
|
intent.putExtra(INTENT_EXTRA_RIDE_TYPE, ride_type);
|
|
|
|
intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, entry_index);
|
|
|
|
context_open_intent(&intent);
|
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: 0x006ABBBE
|
|
|
|
*/
|
|
|
|
static void editor_load_selected_objects()
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 numItems = (sint32)object_repository_get_items_count();
|
|
|
|
const ObjectRepositoryItem * items = object_repository_get_items();
|
|
|
|
for (sint32 i = 0; i < numItems; i++) {
|
|
|
|
if (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED) {
|
|
|
|
const ObjectRepositoryItem * item = &items[i];
|
|
|
|
const rct_object_entry * entry = &item->ObjectEntry;
|
|
|
|
void * loadedObject = object_manager_get_loaded_object(entry);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (loadedObject == nullptr) {
|
2017-06-06 23:24:18 +02:00
|
|
|
loadedObject = object_manager_load_object(entry);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (loadedObject == nullptr) {
|
2017-06-06 23:24:18 +02:00
|
|
|
log_error("Failed to load entry %.8s", entry->name);
|
|
|
|
}
|
|
|
|
else if (!(gScreenFlags & SCREEN_FLAGS_EDITOR)) {
|
|
|
|
// Defaults selected items to researched (if in-game)
|
2018-02-08 20:34:05 +01:00
|
|
|
uint8 objectType = object_entry_get_type(entry);
|
2017-06-06 23:24:18 +02:00
|
|
|
uint8 entryIndex = object_manager_get_loaded_object_entry_index(loadedObject);
|
|
|
|
if (objectType == OBJECT_TYPE_RIDE) {
|
2017-06-17 13:05:48 +02:00
|
|
|
rct_ride_entry *rideEntry = get_ride_entry(entryIndex);
|
|
|
|
uint8 rideType = ride_entry_get_first_non_null_ride_type(rideEntry);
|
2018-01-28 16:14:00 +01:00
|
|
|
research_insert(1, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | entryIndex, rideEntry->category[0]);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2017-11-20 10:15:52 +01:00
|
|
|
else if (objectType == OBJECT_TYPE_SCENERY_GROUP) {
|
2018-01-28 16:14:00 +01:00
|
|
|
research_insert(1, entryIndex, RESEARCH_CATEGORY_SCENERY_GROUP);
|
2017-06-06 23:24:18 +02: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)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (gCurrentTextBox.window.classification == w->classification &&
|
|
|
|
gCurrentTextBox.window.number == w->number) {
|
|
|
|
window_update_textbox_caret();
|
|
|
|
widget_invalidate(w, WIDX_FILTER_STRING_BUTTON);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (rct_widgetindex i = WIDX_FILTER_RIDE_TAB_TRANSPORT; i <= WIDX_FILTER_RIDE_TAB_STALL; i++) {
|
|
|
|
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-05-01 15:41:45 +02:00
|
|
|
static void window_editor_object_selection_textinput(rct_window *w, rct_widgetindex widgetIndex, char *text)
|
2015-06-06 00:54:47 +02:00
|
|
|
{
|
2017-08-15 10:07:44 +02:00
|
|
|
if (widgetIndex != WIDX_FILTER_STRING_BUTTON || text == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2015-06-06 23:04:53 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (strcmp(_filter_string, text) == 0)
|
|
|
|
return;
|
2015-06-06 23:04:53 +02:00
|
|
|
|
2017-11-23 12:08:04 +01:00
|
|
|
safe_strcpy(_filter_string, text, sizeof(_filter_string));
|
2015-06-06 00:54:47 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
filter_update_counts();
|
2015-06-06 01:02:20 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls->v_top = 0;
|
2015-06-06 01:02:20 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
visible_list_refresh(w);
|
|
|
|
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)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (_FILTER_SELECTED == _FILTER_NONSELECTED) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (_FILTER_SELECTED && objectFlag & OBJECT_SELECTION_FLAG_SELECTED) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (_FILTER_NONSELECTED && !(objectFlag & OBJECT_SELECTION_FLAG_SELECTED)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-17 10:46:30 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
static bool filter_string(const ObjectRepositoryItem * item)
|
2015-06-06 00:54:47 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Nothing to search for
|
|
|
|
if (_filter_string[0] == '\0')
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Object doesn't have a name
|
|
|
|
utf8 *name = item->Name;
|
2017-08-15 10:07:44 +02:00
|
|
|
if (name == nullptr || name[0] == '\0')
|
2017-06-06 23:24:18 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Get ride type
|
|
|
|
const char *rideTypeName = language_get_string(get_ride_type_string_id(item));
|
|
|
|
|
|
|
|
// Get object name (ride/vehicle for rides) and type name (rides only)
|
|
|
|
char name_lower[MAX_PATH];
|
|
|
|
char type_lower[MAX_PATH];
|
2017-11-23 12:08:04 +01:00
|
|
|
char object_path[MAX_PATH];
|
2017-06-06 23:24:18 +02:00
|
|
|
char filter_lower[sizeof(_filter_string)];
|
|
|
|
safe_strcpy(name_lower, name, MAX_PATH);
|
|
|
|
safe_strcpy(type_lower, rideTypeName, MAX_PATH);
|
2017-11-23 12:08:04 +01:00
|
|
|
safe_strcpy(object_path, item->Path, MAX_PATH);
|
2017-06-06 23:24:18 +02:00
|
|
|
safe_strcpy(filter_lower, _filter_string, sizeof(_filter_string));
|
|
|
|
|
|
|
|
// Make use of lowercase characters only
|
|
|
|
for (sint32 i = 0; name_lower[i] != '\0'; i++)
|
|
|
|
name_lower[i] = (char)tolower(name_lower[i]);
|
|
|
|
for (sint32 i = 0; type_lower[i] != '\0'; i++)
|
|
|
|
type_lower[i] = (char)tolower(type_lower[i]);
|
2017-11-23 12:08:04 +01:00
|
|
|
for (sint32 i = 0; object_path[i] != '\0'; i++)
|
|
|
|
object_path[i] = (char)tolower(object_path[i]);
|
2017-06-06 23:24:18 +02:00
|
|
|
for (sint32 i = 0; filter_lower[i] != '\0'; i++)
|
|
|
|
filter_lower[i] = (char)tolower(filter_lower[i]);
|
|
|
|
|
2017-11-23 12:08:04 +01:00
|
|
|
// Check if the searched string exists in the name, ride type, or filename
|
|
|
|
bool inName = strstr(name_lower, filter_lower) != nullptr;
|
|
|
|
bool inRideType = ((item->ObjectEntry.flags & 0x0F) == OBJECT_TYPE_RIDE) && strstr(type_lower, filter_lower) != nullptr;
|
|
|
|
bool inPath = strstr(object_path, filter_lower) != nullptr;
|
|
|
|
|
|
|
|
return inName || inRideType || inPath;
|
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
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (_FILTER_ALL)
|
|
|
|
return true;
|
2015-06-06 00:54:47 +02:00
|
|
|
|
2017-11-13 14:14:24 +01:00
|
|
|
uint8 source = object_entry_get_source_game(&item->ObjectEntry);
|
2018-01-31 13:07:20 +01:00
|
|
|
return (_FILTER_RCT1 && source == OBJECT_SOURCE_RCT1) ||
|
|
|
|
(_FILTER_AA && source == OBJECT_SOURCE_ADDED_ATTRACTIONS) ||
|
|
|
|
(_FILTER_LL && source == OBJECT_SOURCE_LOOPY_LANDSCAPES) ||
|
|
|
|
(_FILTER_RCT2 && source == OBJECT_SOURCE_RCT2) ||
|
2017-11-13 14:14:24 +01:00
|
|
|
(_FILTER_WW && source == OBJECT_SOURCE_WACKY_WORLDS) ||
|
|
|
|
(_FILTER_TT && source == OBJECT_SOURCE_TIME_TWISTER) ||
|
2018-01-31 13:07:20 +01:00
|
|
|
(_FILTER_OO && source == OBJECT_SOURCE_OPENRCT2_OFFICIAL) ||
|
|
|
|
(_FILTER_CUSTOM &&
|
|
|
|
source != OBJECT_SOURCE_RCT1 &&
|
|
|
|
source != OBJECT_SOURCE_ADDED_ATTRACTIONS &&
|
|
|
|
source != OBJECT_SOURCE_LOOPY_LANDSCAPES &&
|
|
|
|
source != OBJECT_SOURCE_RCT2 &&
|
|
|
|
source != OBJECT_SOURCE_WACKY_WORLDS &&
|
|
|
|
source != OBJECT_SOURCE_TIME_TWISTER &&
|
|
|
|
source != OBJECT_SOURCE_OPENRCT2_OFFICIAL);
|
2015-06-06 00:54:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 23:15:38 +02:00
|
|
|
static bool filter_chunks(const ObjectRepositoryItem * item)
|
2015-06-14 18:19:54 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
switch (item->ObjectEntry.flags & 0x0F) {
|
|
|
|
case OBJECT_TYPE_RIDE:
|
2017-12-07 16:12:37 +01:00
|
|
|
|
|
|
|
uint8 rideType = 0;
|
|
|
|
for (sint32 i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
|
|
|
{
|
|
|
|
if (item->RideType[i] != RIDE_TYPE_NULL)
|
|
|
|
{
|
|
|
|
rideType = item->RideType[i];
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2018-01-31 13:07:20 +01:00
|
|
|
if (_filter_flags & (1 << (gRideCategories[rideType] + _numSourceGameItems)))
|
2017-12-07 16:12:37 +01:00
|
|
|
return true;
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2015-06-14 18:19:54 +02:00
|
|
|
}
|
|
|
|
|
2015-06-06 00:54:47 +02:00
|
|
|
static void filter_update_counts()
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (!_FILTER_ALL || strlen(_filter_string) > 0) {
|
2018-02-11 18:56:12 +01:00
|
|
|
const auto &selectionFlags = _objectSelectionFlags;
|
2017-06-06 23:24:18 +02:00
|
|
|
for (sint32 i = 0; i < 11; i++) {
|
|
|
|
_filter_object_counts[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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) &&
|
2018-02-11 18:56:12 +01:00
|
|
|
filter_selected(selectionFlags[i])
|
2017-06-06 23:24:18 +02:00
|
|
|
) {
|
|
|
|
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
|
|
|
_filter_object_counts[objectType]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_string_id result = STR_NONE;
|
2018-01-29 18:06:11 +01:00
|
|
|
for (sint32 i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
uint8 rideType = item->RideType[i];
|
2018-01-29 18:06:11 +01:00
|
|
|
if (rideType != RIDE_TYPE_NULL)
|
|
|
|
{
|
|
|
|
if (RideGroupManager::RideTypeHasRideGroups(rideType))
|
|
|
|
{
|
|
|
|
const RideGroup * rideGroup = RideGroupManager::RideGroupFind(rideType, item->RideGroupIndex);
|
|
|
|
result = rideGroup->Naming.name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = RideNaming[rideType].name;
|
|
|
|
}
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
2016-07-02 11:59:50 +02:00
|
|
|
}
|
2017-12-05 13:55:33 +01:00
|
|
|
|
|
|
|
static std::string object_get_description(const void * object)
|
|
|
|
{
|
|
|
|
const Object * baseObject = static_cast<const Object *>(object);
|
|
|
|
switch (baseObject->GetObjectType()) {
|
|
|
|
case OBJECT_TYPE_RIDE:
|
|
|
|
{
|
|
|
|
const RideObject * rideObject = static_cast<const RideObject *>(baseObject);
|
|
|
|
return rideObject->GetDescription();
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|