2014-11-25 00:05:35 +01:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-05-04 19:24:41 +02:00
|
|
|
*****************************************************************************/
|
2014-11-25 00:05:35 +01:00
|
|
|
|
2018-11-21 23:16:04 +01:00
|
|
|
#include <iterator>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2-ui/interface/Widget.h>
|
2017-08-12 23:06:12 +02:00
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2017-09-22 07:56:24 +02:00
|
|
|
#include <openrct2/Editor.h>
|
2017-12-12 14:52:57 +01:00
|
|
|
#include <openrct2/Input.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/OpenRCT2.h>
|
|
|
|
#include <openrct2/interface/Cursors.h>
|
2018-01-06 18:32:25 +01:00
|
|
|
#include <openrct2/localisation/Localisation.h>
|
2017-10-05 16:22:37 +02:00
|
|
|
#include <openrct2/management/Research.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/object/DefaultObjects.h>
|
|
|
|
#include <openrct2/object/ObjectManager.h>
|
|
|
|
#include <openrct2/object/ObjectRepository.h>
|
2020-06-20 02:32:52 +02:00
|
|
|
#include <openrct2/ride/RideData.h>
|
2017-09-18 17:05:28 +02:00
|
|
|
#include <openrct2/sprites.h>
|
2017-12-13 13:02:24 +01:00
|
|
|
#include <openrct2/util/Util.h>
|
2018-01-11 10:59:26 +01:00
|
|
|
#include <openrct2/world/Scenery.h>
|
2014-12-16 02:24:13 +01:00
|
|
|
|
|
|
|
#pragma region Widgets
|
|
|
|
|
2020-05-09 17:05:01 +02:00
|
|
|
static constexpr const int32_t WW = 600;
|
|
|
|
static constexpr const int32_t WH = 400;
|
2020-05-05 22:26:14 +02:00
|
|
|
static constexpr const rct_string_id WINDOW_TITLE = STR_INVENTION_LIST;
|
2018-05-25 19:16:20 +02:00
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format off
|
2014-12-16 02:24:13 +01:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
2018-05-25 19:16:20 +02:00
|
|
|
WIDX_RESIZE,
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_TAB_1,
|
|
|
|
WIDX_PRE_RESEARCHED_SCROLL,
|
|
|
|
WIDX_RESEARCH_ORDER_SCROLL,
|
|
|
|
WIDX_PREVIEW,
|
2018-05-25 19:16:20 +02:00
|
|
|
WIDX_MOVE_ITEMS_TO_TOP,
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_MOVE_ITEMS_TO_BOTTOM,
|
2018-05-25 19:16:20 +02:00
|
|
|
WIDX_RANDOM_SHUFFLE
|
2014-12-16 02:24:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_editor_inventions_list_widgets[] = {
|
2020-05-09 16:44:21 +02:00
|
|
|
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({ 0, 43}, {600, 357}, WindowWidgetType::Resize, WindowColour::Secondary ),
|
2020-08-29 04:31:31 +02:00
|
|
|
MakeTab ({ 3, 17} ),
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({ 4, 56}, {368, 161}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL ),
|
|
|
|
MakeWidget({ 4, 231}, {368, 157}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL ),
|
|
|
|
MakeWidget({431, 106}, {114, 114}, WindowWidgetType::FlatBtn, WindowColour::Secondary ),
|
|
|
|
MakeWidget({375, 343}, {220, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_MOVE_ALL_TOP ),
|
|
|
|
MakeWidget({375, 358}, {220, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_MOVE_ALL_BOTTOM ),
|
|
|
|
MakeWidget({375, 373}, {220, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_RANDOM_SHUFFLE, STR_RANDOM_SHUFFLE_TIP),
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WIDGETS_END }
|
2014-12-16 02:24:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_editor_inventions_list_drag_widgets[] = {
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({0, 0}, {150, 14}, WindowWidgetType::ImgBtn, WindowColour::Primary),
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WIDGETS_END }
|
2014-12-16 02:24:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Events
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_inventions_list_close(rct_window *w);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_editor_inventions_list_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2018-05-25 19:16:20 +02:00
|
|
|
static void window_editor_inventions_list_resize(rct_window *w);
|
2014-12-16 02:24:13 +01:00
|
|
|
static void window_editor_inventions_list_update(rct_window *w);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_editor_inventions_list_scrollgetheight(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_editor_inventions_list_scrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void window_editor_inventions_list_scrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
2020-10-11 18:01:14 +02:00
|
|
|
static void window_editor_inventions_list_cursor(rct_window *w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID *cursorId);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_inventions_list_invalidate(rct_window *w);
|
|
|
|
static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
|
2020-10-11 18:01:14 +02:00
|
|
|
static void window_editor_inventions_list_drag_cursor(rct_window *w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID *cursorId);
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_editor_inventions_list_drag_moved(rct_window* w, const ScreenCoordsXY& screenCoords);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2020-08-28 22:33:36 +02:00
|
|
|
static std::pair<rct_string_id, Formatter> window_editor_inventions_list_prepare_name(const ResearchItem * researchItem, bool withGap);
|
2018-03-21 12:52:39 +01:00
|
|
|
|
2014-12-16 02:24:13 +01:00
|
|
|
// 0x0098177C
|
2020-09-28 20:36:15 +02:00
|
|
|
static rct_window_event_list window_editor_inventions_list_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.close = &window_editor_inventions_list_close;
|
|
|
|
events.mouse_up = &window_editor_inventions_list_mouseup;
|
|
|
|
events.resize = &window_editor_inventions_list_resize;
|
|
|
|
events.update = &window_editor_inventions_list_update;
|
|
|
|
events.get_scroll_size = &window_editor_inventions_list_scrollgetheight;
|
|
|
|
events.scroll_mousedown = &window_editor_inventions_list_scrollmousedown;
|
|
|
|
events.scroll_mouseover = &window_editor_inventions_list_scrollmouseover;
|
|
|
|
events.cursor = &window_editor_inventions_list_cursor;
|
|
|
|
events.invalidate = &window_editor_inventions_list_invalidate;
|
|
|
|
events.paint = &window_editor_inventions_list_paint;
|
|
|
|
events.scroll_paint = &window_editor_inventions_list_scrollpaint;
|
|
|
|
});
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2015-06-03 21:54:28 +02:00
|
|
|
// 0x009817EC
|
2020-09-28 20:36:15 +02:00
|
|
|
static rct_window_event_list window_editor_inventions_list_drag_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.cursor = &window_editor_inventions_list_drag_cursor;
|
|
|
|
events.moved = &window_editor_inventions_list_drag_moved;
|
|
|
|
events.paint = &window_editor_inventions_list_drag_paint;
|
|
|
|
});
|
2014-12-16 02:24:13 +01:00
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2019-06-17 20:27:34 +02:00
|
|
|
static ResearchItem _editorInventionsListDraggedItem;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format on
|
2016-07-14 14:07:49 +02:00
|
|
|
|
2019-06-16 21:21:06 +02:00
|
|
|
static void window_editor_inventions_list_drag_open(ResearchItem* researchItem);
|
2019-06-19 22:58:04 +02:00
|
|
|
static void move_research_item(ResearchItem* beforeItem, int32_t scrollIndex);
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068596F
|
2015-06-06 10:46:01 +02:00
|
|
|
* Sets rides that are in use to be always researched
|
|
|
|
*/
|
2018-03-23 11:42:08 +01:00
|
|
|
static void research_rides_setup()
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Reset all objects to not required
|
2020-11-11 10:51:10 +01:00
|
|
|
for (ObjectType objectType = ObjectType::Ride; objectType < ObjectType::Count; objectType++)
|
2018-02-11 18:56:12 +01:00
|
|
|
{
|
2020-11-11 10:51:10 +01:00
|
|
|
auto maxObjects = object_entry_group_counts[EnumValue(objectType)];
|
2018-06-20 17:28:51 +02:00
|
|
|
for (int32_t i = 0; i < maxObjects; i++)
|
2018-02-11 18:56:12 +01:00
|
|
|
{
|
2020-11-11 10:51:10 +01:00
|
|
|
Editor::ClearSelectedObject(objectType, i, OBJECT_SELECTION_FLAG_ALL);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set research required for rides in use
|
2019-08-04 18:12:34 +02:00
|
|
|
for (const auto& ride : GetRideManager())
|
2018-02-11 18:56:12 +01:00
|
|
|
{
|
2020-11-09 10:36:37 +01:00
|
|
|
Editor::SetSelectedObject(ObjectType::Ride, ride.subtype, OBJECT_SELECTION_FLAG_SELECTED);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-06-04 22:15:00 +02:00
|
|
|
}
|
|
|
|
|
2014-12-16 02:24:13 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006855E7
|
|
|
|
*/
|
2019-06-19 22:58:04 +02:00
|
|
|
static void move_research_item(ResearchItem* beforeItem, int32_t scrollIndex)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-08-21 23:02:12 +02:00
|
|
|
auto w = window_find_by_class(WC_EDITOR_INVENTION_LIST);
|
|
|
|
if (w != nullptr)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-08-21 23:02:12 +02:00
|
|
|
w->research_item = nullptr;
|
|
|
|
w->Invalidate();
|
2019-06-17 20:27:34 +02:00
|
|
|
}
|
2019-08-21 23:02:12 +02:00
|
|
|
|
|
|
|
research_remove(&_editorInventionsListDraggedItem);
|
|
|
|
|
|
|
|
auto& researchList = scrollIndex == 0 ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
if (beforeItem != nullptr)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-08-21 23:02:12 +02:00
|
|
|
for (size_t i = 0; i < researchList.size(); i++)
|
2019-06-19 22:58:04 +02:00
|
|
|
{
|
2019-08-21 23:02:12 +02:00
|
|
|
if (researchList[i].Equals(beforeItem))
|
2019-06-19 22:58:04 +02:00
|
|
|
{
|
2019-08-21 23:02:12 +02:00
|
|
|
researchList.insert((researchList.begin() + i), _editorInventionsListDraggedItem);
|
|
|
|
return;
|
2019-06-19 22:58:04 +02:00
|
|
|
}
|
2019-06-17 20:27:34 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-08-21 23:02:12 +02:00
|
|
|
// Still not found? Append to end of list.
|
|
|
|
researchList.push_back(_editorInventionsListDraggedItem);
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068558E
|
|
|
|
*/
|
2019-06-16 21:21:06 +02:00
|
|
|
static ResearchItem* window_editor_inventions_list_get_item_from_scroll_y(int32_t scrollIndex, int32_t y)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-06-17 19:31:54 +02:00
|
|
|
auto& researchList = scrollIndex == 0 ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
for (auto& researchItem : researchList)
|
2018-06-04 22:39:35 +02:00
|
|
|
{
|
2017-10-21 00:21:01 +02:00
|
|
|
y -= SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (y < 0)
|
2018-06-04 22:39:35 +02:00
|
|
|
{
|
2019-06-17 19:31:54 +02:00
|
|
|
return &researchItem;
|
2018-06-04 22:39:35 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
return nullptr;
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006855BB
|
|
|
|
*/
|
2019-06-16 21:21:06 +02:00
|
|
|
static ResearchItem* window_editor_inventions_list_get_item_from_scroll_y_include_seps(int32_t scrollIndex, int32_t y)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-06-17 19:31:54 +02:00
|
|
|
auto& researchList = scrollIndex == 0 ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
for (auto& researchItem : researchList)
|
2018-06-04 22:39:35 +02:00
|
|
|
{
|
2017-10-21 00:21:01 +02:00
|
|
|
y -= SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (y < 0)
|
2018-06-04 22:39:35 +02:00
|
|
|
{
|
2019-06-17 19:31:54 +02:00
|
|
|
return &researchItem;
|
2018-06-04 22:39:35 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2019-08-21 23:02:12 +02:00
|
|
|
return nullptr;
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
2020-02-29 03:43:29 +01:00
|
|
|
static ResearchItem* get_research_item_at(const ScreenCoordsXY& screenCoords, int32_t* outScrollId)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* w = window_find_by_class(WC_EDITOR_INVENTION_LIST);
|
2020-03-01 20:32:35 +01:00
|
|
|
if (w != nullptr && w->windowPos.x <= screenCoords.x && w->windowPos.y < screenCoords.y
|
|
|
|
&& w->windowPos.x + w->width > screenCoords.x && w->windowPos.y + w->height > screenCoords.y)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-11-18 23:13:32 +01:00
|
|
|
rct_widgetindex widgetIndex = window_find_widget_from_point(w, screenCoords);
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_widget* widget = &w->widgets[widgetIndex];
|
|
|
|
if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL || widgetIndex == WIDX_RESEARCH_ORDER_SCROLL)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
gPressedWidget.widget_index = widgetIndex;
|
2019-10-29 17:41:19 +01:00
|
|
|
int32_t outScrollArea;
|
|
|
|
ScreenCoordsXY outScrollCoords;
|
2020-11-03 22:29:22 +01:00
|
|
|
WidgetScrollGetPart(w, widget, screenCoords, outScrollCoords, &outScrollArea, outScrollId);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (outScrollArea == SCROLL_PART_VIEW)
|
|
|
|
{
|
2019-06-19 22:58:04 +02:00
|
|
|
*outScrollId = *outScrollId == 0 ? 0 : 1;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-10-29 17:41:19 +01:00
|
|
|
int32_t scrollY = outScrollCoords.y + 6;
|
2019-06-19 22:58:04 +02:00
|
|
|
return window_editor_inventions_list_get_item_from_scroll_y_include_seps(*outScrollId, scrollY);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-21 23:02:12 +02:00
|
|
|
*outScrollId = -1;
|
2017-08-15 10:07:44 +02:00
|
|
|
return nullptr;
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
2014-11-25 00:05:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00684E04
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* window_editor_inventions_list_open()
|
2014-11-25 00:05:35 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* w;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
w = window_bring_to_front_by_class(WC_EDITOR_INVENTION_LIST);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (w != nullptr)
|
2017-08-12 23:06:12 +02:00
|
|
|
return w;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-02-19 12:55:43 +01:00
|
|
|
research_rides_setup();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
w = WindowCreateCentred(
|
2018-06-22 23:21:44 +02:00
|
|
|
WW, WH, &window_editor_inventions_list_events, WC_EDITOR_INVENTION_LIST, WF_NO_SCROLLING | WF_RESIZABLE);
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets = window_editor_inventions_list_widgets;
|
2018-06-22 23:21:44 +02:00
|
|
|
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_RESIZE) | (1 << WIDX_TAB_1) | (1 << WIDX_RANDOM_SHUFFLE)
|
|
|
|
| (1 << WIDX_MOVE_ITEMS_TO_BOTTOM) | (1 << WIDX_MOVE_ITEMS_TO_TOP);
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowInitScrollWidgets(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_tab = 0;
|
2017-08-15 10:07:44 +02:00
|
|
|
w->research_item = nullptr;
|
2020-04-27 17:49:03 +02:00
|
|
|
_editorInventionsListDraggedItem.SetNull();
|
2017-08-12 23:06:12 +02:00
|
|
|
|
2018-05-25 19:16:20 +02:00
|
|
|
w->min_width = WW;
|
|
|
|
w->min_height = WH;
|
|
|
|
w->max_width = WW * 2;
|
|
|
|
w->max_height = WH * 2;
|
|
|
|
|
2017-08-12 23:06:12 +02:00
|
|
|
return w;
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006853D2
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_close(rct_window* w)
|
2016-11-13 20:17:49 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
research_remove_flags();
|
|
|
|
|
|
|
|
// When used in-game (as a cheat)
|
2018-06-22 23:21:44 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
gSilentResearch = true;
|
|
|
|
research_reset_current_item();
|
|
|
|
gSilentResearch = false;
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068521B
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_RANDOM_SHUFFLE:
|
|
|
|
research_items_shuffle();
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_MOVE_ITEMS_TO_TOP:
|
|
|
|
research_items_make_all_researched();
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowInitScrollWidgets(w);
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_MOVE_ITEMS_TO_BOTTOM:
|
|
|
|
research_items_make_all_unresearched();
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowInitScrollWidgets(w);
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_resize(rct_window* w)
|
2018-05-25 19:16:20 +02:00
|
|
|
{
|
|
|
|
if (w->width < w->min_width)
|
|
|
|
{
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-05-25 19:16:20 +02:00
|
|
|
w->width = w->min_width;
|
|
|
|
}
|
|
|
|
if (w->height < w->min_height)
|
|
|
|
{
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-05-25 19:16:20 +02:00
|
|
|
w->height = w->min_height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-16 02:24:13 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685392
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_update(rct_window* w)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
|
|
|
window_event_invalidate_call(w);
|
|
|
|
widget_invalidate(w, WIDX_TAB_1);
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2020-01-26 14:12:57 +01:00
|
|
|
if (_editorInventionsListDraggedItem.IsNull())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
if (window_find_by_class(WC_EDITOR_INVENTION_LIST_DRAG) != nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2020-04-27 17:49:03 +02:00
|
|
|
_editorInventionsListDraggedItem.SetNull();
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685239
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_scrollgetheight(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
*height = 0;
|
2019-06-16 23:32:31 +02:00
|
|
|
if (scrollIndex == 0)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-04-18 13:32:48 +02:00
|
|
|
*height += static_cast<int32_t>(gResearchItemsInvented.size()) * SCROLLABLE_ROW_HEIGHT;
|
2019-06-16 23:32:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-18 13:32:48 +02:00
|
|
|
*height += static_cast<int32_t>(gResearchItemsUninvented.size()) * SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006852D4
|
|
|
|
*/
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_editor_inventions_list_scrollmousedown(
|
|
|
|
rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-06-16 21:21:06 +02:00
|
|
|
ResearchItem* researchItem;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, screenCoords.y);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (researchItem == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2018-06-13 11:50:37 +02:00
|
|
|
// Disallow picking up always-researched items
|
2020-01-22 22:51:11 +01:00
|
|
|
if (researchItem->IsAlwaysResearched())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_inventions_list_drag_open(researchItem);
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685275
|
|
|
|
*/
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_editor_inventions_list_scrollmouseover(
|
|
|
|
rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-06-16 21:21:06 +02:00
|
|
|
ResearchItem* researchItem;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, screenCoords.y);
|
2018-06-13 11:50:37 +02:00
|
|
|
if (researchItem != w->research_item)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->research_item = researchItem;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-13 11:50:37 +02:00
|
|
|
|
|
|
|
// Prevent always-researched items from being highlighted when hovered over
|
2020-01-22 22:51:11 +01:00
|
|
|
if (researchItem != nullptr && researchItem->IsAlwaysResearched())
|
2018-06-13 11:50:37 +02:00
|
|
|
{
|
|
|
|
w->research_item = nullptr;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685291
|
|
|
|
*/
|
2018-07-21 11:50:45 +02:00
|
|
|
static void window_editor_inventions_list_cursor(
|
2020-10-11 18:01:14 +02:00
|
|
|
rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID* cursorId)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-06-16 21:21:06 +02:00
|
|
|
ResearchItem* researchItem;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t scrollIndex;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_PRE_RESEARCHED_SCROLL:
|
|
|
|
scrollIndex = 0;
|
|
|
|
break;
|
|
|
|
case WIDX_RESEARCH_ORDER_SCROLL:
|
|
|
|
scrollIndex = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-13 11:50:37 +02:00
|
|
|
// Use the open hand as cursor for items that can be picked up
|
2019-11-18 23:13:32 +01:00
|
|
|
researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, screenCoords.y);
|
2020-01-22 22:51:11 +01:00
|
|
|
if (researchItem != nullptr && !researchItem->IsAlwaysResearched())
|
2018-06-13 11:50:37 +02:00
|
|
|
{
|
2020-10-11 18:01:14 +02:00
|
|
|
*cursorId = CursorID::HandOpen;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685392
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_invalidate(rct_window* w)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->pressed_widgets |= 1 << WIDX_PREVIEW;
|
|
|
|
w->pressed_widgets |= 1 << WIDX_TAB_1;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_CLOSE].type = gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR ? WindowWidgetType::Empty
|
|
|
|
: WindowWidgetType::CloseBox;
|
2018-05-25 19:16:20 +02:00
|
|
|
|
|
|
|
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
|
|
|
w->widgets[WIDX_TITLE].right = w->width - 2;
|
2020-05-05 22:31:04 +02:00
|
|
|
w->widgets[WIDX_CLOSE].left = w->width - 13;
|
|
|
|
w->widgets[WIDX_CLOSE].right = w->width - 3;
|
2018-05-25 19:16:20 +02:00
|
|
|
w->widgets[WIDX_RESIZE].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_RESIZE].bottom = w->height - 1;
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int16_t scroll_list_height = (w->height - 88) / 2;
|
2018-05-25 19:16:20 +02:00
|
|
|
|
|
|
|
w->widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom = 60 + scroll_list_height;
|
|
|
|
w->widgets[WIDX_PRE_RESEARCHED_SCROLL].right = w->width - 229;
|
|
|
|
|
|
|
|
w->widgets[WIDX_RESEARCH_ORDER_SCROLL].top = w->widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom + 15;
|
|
|
|
w->widgets[WIDX_RESEARCH_ORDER_SCROLL].bottom = w->widgets[WIDX_RESEARCH_ORDER_SCROLL].top + scroll_list_height;
|
|
|
|
w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right = w->width - 229;
|
|
|
|
|
|
|
|
w->widgets[WIDX_PREVIEW].left = w->width - 169;
|
|
|
|
w->widgets[WIDX_PREVIEW].right = w->width - 56;
|
|
|
|
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].top = w->height - 57;
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].bottom = w->height - 44;
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].left = w->width - 225;
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].right = w->width - 6;
|
|
|
|
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].top = w->height - 42;
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].bottom = w->height - 29;
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].left = w->width - 225;
|
|
|
|
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].right = w->width - 6;
|
|
|
|
|
|
|
|
w->widgets[WIDX_RANDOM_SHUFFLE].top = w->height - 27;
|
|
|
|
w->widgets[WIDX_RANDOM_SHUFFLE].bottom = w->height - 14;
|
|
|
|
w->widgets[WIDX_RANDOM_SHUFFLE].left = w->width - 225;
|
|
|
|
w->widgets[WIDX_RANDOM_SHUFFLE].right = w->width - 6;
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00684EE0
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_widget* widget;
|
2019-06-16 21:21:06 +02:00
|
|
|
ResearchItem* researchItem;
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_string_id stringId;
|
2020-06-11 23:04:57 +02:00
|
|
|
int32_t width;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Tab image
|
2020-06-11 23:04:57 +02:00
|
|
|
auto screenPos = w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_TAB_1].left, w->widgets[WIDX_TAB_1].top };
|
2020-06-23 23:32:34 +02:00
|
|
|
gfx_draw_sprite(dpi, SPR_TAB_FINANCES_RESEARCH_0 + (w->frame_no / 2) % 8, screenPos, 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Pre-researched items label
|
2020-06-11 23:04:57 +02:00
|
|
|
screenPos = w->windowPos
|
|
|
|
+ ScreenCoordsXY{ w->widgets[WIDX_PRE_RESEARCHED_SCROLL].left, w->widgets[WIDX_PRE_RESEARCHED_SCROLL].top - 11 };
|
2021-02-27 16:49:13 +01:00
|
|
|
DrawTextBasic(dpi, screenPos - ScreenCoordsXY{ 0, 1 }, STR_INVENTION_PREINVENTED_ITEMS);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Research order label
|
2020-06-11 23:04:57 +02:00
|
|
|
screenPos = w->windowPos
|
|
|
|
+ ScreenCoordsXY{ w->widgets[WIDX_RESEARCH_ORDER_SCROLL].left, w->widgets[WIDX_RESEARCH_ORDER_SCROLL].top - 11 };
|
2021-02-27 16:49:13 +01:00
|
|
|
DrawTextBasic(dpi, screenPos - ScreenCoordsXY{ 0, 1 }, STR_INVENTION_TO_BE_INVENTED_ITEMS);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Preview background
|
|
|
|
widget = &w->widgets[WIDX_PREVIEW];
|
|
|
|
gfx_fill_rect(
|
2020-07-10 18:59:08 +02:00
|
|
|
dpi,
|
|
|
|
{ w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 },
|
|
|
|
w->windowPos + ScreenCoordsXY{ widget->right - 1, widget->bottom - 1 } },
|
|
|
|
ColourMapA[w->colours[1]].darkest);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-06-17 20:27:34 +02:00
|
|
|
researchItem = &_editorInventionsListDraggedItem;
|
2020-01-26 14:12:57 +01:00
|
|
|
if (researchItem->IsNull())
|
2017-06-06 23:24:18 +02:00
|
|
|
researchItem = w->research_item;
|
|
|
|
// If the research item is null or a list separator.
|
2020-01-26 14:12:57 +01:00
|
|
|
if (researchItem == nullptr || researchItem->IsNull())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Preview image
|
2020-11-09 11:53:29 +01:00
|
|
|
ObjectType objectEntryType = ObjectType::SceneryGroup;
|
2020-07-22 15:25:05 +02:00
|
|
|
if (researchItem->type == Research::EntryType::Ride)
|
2020-11-09 10:36:37 +01:00
|
|
|
objectEntryType = ObjectType::Ride;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-02-11 19:56:09 +01:00
|
|
|
auto chunk = object_entry_get_chunk(objectEntryType, researchItem->entryIndex);
|
2017-10-15 15:53:16 +02:00
|
|
|
if (chunk == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Draw preview
|
|
|
|
widget = &w->widgets[WIDX_PREVIEW];
|
|
|
|
|
2021-01-03 23:01:52 +01:00
|
|
|
const auto* object = object_entry_get_object(objectEntryType, researchItem->entryIndex);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (object != nullptr)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_drawpixelinfo clipDPI;
|
2020-06-11 23:04:57 +02:00
|
|
|
screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 };
|
2020-06-25 03:44:00 +02:00
|
|
|
width = widget->width() - 1;
|
|
|
|
int32_t height = widget->height() - 1;
|
2020-07-02 19:06:28 +02:00
|
|
|
if (clip_drawpixelinfo(&clipDPI, dpi, screenPos, width, height))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-10-14 21:56:48 +02:00
|
|
|
object->DrawPreview(&clipDPI, width, height);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Item name
|
2020-06-25 10:31:15 +02:00
|
|
|
screenPos = w->windowPos + ScreenCoordsXY{ widget->midX() + 1, widget->bottom + 3 };
|
2017-06-06 23:24:18 +02:00
|
|
|
width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6;
|
2018-03-21 12:52:39 +01:00
|
|
|
|
2020-08-28 22:33:36 +02:00
|
|
|
auto [drawString, ft] = window_editor_inventions_list_prepare_name(researchItem, false);
|
|
|
|
DrawTextEllipsised(dpi, screenPos, width, drawString, ft, COLOUR_BLACK, TextAlignment::CENTRE);
|
2020-06-11 23:04:57 +02:00
|
|
|
screenPos.y += 15;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Item category
|
2020-06-11 23:04:57 +02:00
|
|
|
screenPos.x = w->windowPos.x + w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right + 4;
|
2020-10-24 21:16:45 +02:00
|
|
|
stringId = researchItem->GetCategoryInventionString();
|
2021-02-27 16:49:13 +01:00
|
|
|
DrawTextBasic(dpi, screenPos, STR_INVENTION_RESEARCH_GROUP, &stringId);
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006850BD
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Draw background
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t paletteIndex = ColourMapA[w->colours[1]].mid_light;
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_clear(dpi, paletteIndex);
|
2019-06-17 20:27:34 +02:00
|
|
|
|
2020-06-25 03:44:00 +02:00
|
|
|
int16_t boxWidth = w->widgets[WIDX_RESEARCH_ORDER_SCROLL].width();
|
2018-06-20 17:28:51 +02:00
|
|
|
int16_t columnSplitOffset = boxWidth / 2;
|
|
|
|
int32_t itemY = -SCROLLABLE_ROW_HEIGHT;
|
2019-06-17 19:31:54 +02:00
|
|
|
|
|
|
|
const auto& researchList = scrollIndex == 0 ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
for (const auto& researchItem : researchList)
|
2017-10-21 00:21:01 +02:00
|
|
|
{
|
|
|
|
itemY += SCROLLABLE_ROW_HEIGHT;
|
|
|
|
if (itemY + SCROLLABLE_ROW_HEIGHT < dpi->y || itemY >= dpi->y + dpi->height)
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
|
2019-06-17 19:31:54 +02:00
|
|
|
if (w->research_item == &researchItem)
|
2018-05-26 23:26:58 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t top, bottom;
|
2020-01-26 14:12:57 +01:00
|
|
|
if (_editorInventionsListDraggedItem.IsNull())
|
2018-05-26 23:26:58 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Highlight
|
|
|
|
top = itemY;
|
2017-10-21 00:21:01 +02:00
|
|
|
bottom = itemY + SCROLLABLE_ROW_HEIGHT - 1;
|
2018-05-26 23:26:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Drop horizontal rule
|
|
|
|
top = itemY - 1;
|
|
|
|
bottom = itemY;
|
|
|
|
}
|
|
|
|
|
2020-12-05 19:13:59 +01:00
|
|
|
gfx_filter_rect(dpi, 0, top, boxWidth, bottom, FilterPaletteID::PaletteDarken1);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2019-06-17 20:27:34 +02:00
|
|
|
if (researchItem.Equals(&_editorInventionsListDraggedItem))
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t colour;
|
2020-01-22 22:51:11 +01:00
|
|
|
if (researchItem.IsAlwaysResearched())
|
2018-05-26 23:26:58 +02:00
|
|
|
{
|
2020-01-26 14:12:57 +01:00
|
|
|
if (w->research_item == &researchItem && _editorInventionsListDraggedItem.IsNull())
|
2021-02-27 12:40:20 +01:00
|
|
|
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_EXTRA_DARK;
|
2018-05-26 23:26:58 +02:00
|
|
|
else
|
2021-02-27 12:40:20 +01:00
|
|
|
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK;
|
2018-06-08 22:57:29 +02:00
|
|
|
colour = w->colours[1] | COLOUR_FLAG_INSET;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-05-26 23:26:58 +02:00
|
|
|
else
|
2018-06-08 22:57:29 +02:00
|
|
|
{
|
2021-01-03 14:06:52 +01:00
|
|
|
// TODO: this parameter by itself produces very light text.
|
|
|
|
// It needs a {BLACK} token in the string to work properly.
|
|
|
|
colour = COLOUR_BLACK;
|
2021-02-27 12:40:20 +01:00
|
|
|
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
|
2018-06-08 22:57:29 +02:00
|
|
|
}
|
|
|
|
|
2021-01-03 14:06:52 +01:00
|
|
|
const rct_string_id itemNameId = researchItem.GetName();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-07-22 15:25:05 +02:00
|
|
|
if (researchItem.type == Research::EntryType::Ride
|
2021-02-26 10:01:00 +01:00
|
|
|
&& !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
2018-03-21 12:52:39 +01:00
|
|
|
{
|
2019-06-17 19:31:54 +02:00
|
|
|
const auto rideEntry = get_ride_entry(researchItem.entryIndex);
|
2020-06-20 02:32:52 +02:00
|
|
|
const rct_string_id rideTypeName = get_ride_naming(researchItem.baseRideType, rideEntry).Name;
|
2018-06-08 22:57:29 +02:00
|
|
|
|
2021-01-03 14:06:52 +01:00
|
|
|
// Draw group name
|
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<rct_string_id>(rideTypeName);
|
|
|
|
DrawTextEllipsised(
|
|
|
|
dpi, { 1, itemY }, columnSplitOffset - 11, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, ft, colour);
|
2018-06-08 22:57:29 +02:00
|
|
|
|
2021-01-03 14:06:52 +01:00
|
|
|
// Draw vehicle name
|
|
|
|
ft = Formatter();
|
|
|
|
ft.Add<rct_string_id>(itemNameId);
|
|
|
|
DrawTextEllipsised(dpi, { columnSplitOffset + 1, itemY }, columnSplitOffset - 11, STR_BLACK_STRING, ft, colour);
|
|
|
|
}
|
|
|
|
else
|
2018-06-08 22:57:29 +02:00
|
|
|
{
|
2021-01-03 14:06:52 +01:00
|
|
|
// Scenery group, flat ride or shop
|
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<rct_string_id>(itemNameId);
|
|
|
|
DrawTextEllipsised(dpi, { 1, itemY }, boxWidth, STR_BLACK_STRING, ft, colour);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2019-06-17 19:31:54 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma region Drag item
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006852F4
|
|
|
|
*/
|
2019-06-16 21:21:06 +02:00
|
|
|
static void window_editor_inventions_list_drag_open(ResearchItem* researchItem)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2018-03-21 12:52:39 +01:00
|
|
|
char buffer[256], *ptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
window_close_by_class(WC_EDITOR_INVENTION_LIST_DRAG);
|
2019-06-17 20:27:34 +02:00
|
|
|
_editorInventionsListDraggedItem = *researchItem;
|
2020-01-22 22:51:11 +01:00
|
|
|
rct_string_id stringId = researchItem->GetName();
|
2018-03-21 12:52:39 +01:00
|
|
|
|
|
|
|
ptr = buffer;
|
2020-07-22 15:25:05 +02:00
|
|
|
if (researchItem->type == Research::EntryType::Ride
|
2021-02-26 10:01:00 +01:00
|
|
|
&& !GetRideTypeDescriptor(researchItem->baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
2018-03-21 12:52:39 +01:00
|
|
|
{
|
2018-07-23 14:10:54 +02:00
|
|
|
const auto rideEntry = get_ride_entry(researchItem->entryIndex);
|
2020-06-20 02:32:52 +02:00
|
|
|
const rct_string_id rideTypeName = get_ride_naming(researchItem->baseRideType, rideEntry).Name;
|
2018-07-23 14:10:54 +02:00
|
|
|
rct_string_id args[] = {
|
2020-06-20 02:32:52 +02:00
|
|
|
rideTypeName,
|
2018-07-23 14:10:54 +02:00
|
|
|
stringId,
|
|
|
|
};
|
2018-03-21 12:52:39 +01:00
|
|
|
format_string(ptr, 256, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, &args);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
format_string(ptr, 256, stringId, nullptr);
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2021-02-27 18:15:44 +01:00
|
|
|
auto stringWidth = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_editor_inventions_list_drag_widgets[0].right = stringWidth;
|
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
auto* w = WindowCreate(
|
2020-10-17 10:10:08 +02:00
|
|
|
gTooltipCursor - ScreenCoordsXY{ stringWidth / 2, 7 }, stringWidth, 14, &window_editor_inventions_list_drag_events,
|
|
|
|
WC_EDITOR_INVENTION_LIST_DRAG, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_SNAPPING);
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets = window_editor_inventions_list_drag_widgets;
|
|
|
|
w->colours[1] = COLOUR_WHITE;
|
2020-11-02 14:43:35 +01:00
|
|
|
InputWindowPositionBegin(w, 0, gTooltipCursor);
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068549C
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_drag_cursor(
|
2020-10-11 18:01:14 +02:00
|
|
|
rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID* cursorId)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* inventionListWindow = window_find_by_class(WC_EDITOR_INVENTION_LIST);
|
|
|
|
if (inventionListWindow != nullptr)
|
|
|
|
{
|
2019-06-19 22:58:04 +02:00
|
|
|
int32_t scrollId;
|
2019-11-18 23:13:32 +01:00
|
|
|
ResearchItem* researchItem = get_research_item_at(screenCoords, &scrollId);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (researchItem != inventionListWindow->research_item)
|
|
|
|
{
|
2019-06-15 17:20:16 +02:00
|
|
|
inventionListWindow->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 18:01:14 +02:00
|
|
|
*cursorId = CursorID::HandClosed;
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00685412
|
|
|
|
*/
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_editor_inventions_list_drag_moved(rct_window* w, const ScreenCoordsXY& screenCoords)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2019-06-16 21:21:06 +02:00
|
|
|
ResearchItem* researchItem;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2019-06-19 22:58:04 +02:00
|
|
|
int32_t scrollId;
|
2018-06-13 12:49:45 +02:00
|
|
|
// Skip always researched items, so that the dragged item gets placed underneath them
|
2020-02-29 03:43:29 +01:00
|
|
|
auto newScreenCoords = screenCoords;
|
2018-06-13 12:49:45 +02:00
|
|
|
do
|
|
|
|
{
|
2020-02-29 03:43:29 +01:00
|
|
|
researchItem = get_research_item_at(newScreenCoords, &scrollId);
|
|
|
|
newScreenCoords.y += LIST_ROW_HEIGHT;
|
2020-01-22 22:51:11 +01:00
|
|
|
} while (researchItem != nullptr && researchItem->IsAlwaysResearched());
|
2018-06-13 12:49:45 +02:00
|
|
|
|
2019-08-21 23:02:12 +02:00
|
|
|
if (scrollId != -1)
|
2019-06-19 22:58:04 +02:00
|
|
|
{
|
|
|
|
move_research_item(researchItem, scrollId);
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
window_close(w);
|
2020-04-27 17:49:03 +02:00
|
|
|
_editorInventionsListDraggedItem.SetNull();
|
2017-06-06 23:24:18 +02:00
|
|
|
window_invalidate_by_class(WC_EDITOR_INVENTION_LIST);
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006853D9
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_editor_inventions_list_drag_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2020-06-20 05:22:01 +02:00
|
|
|
auto screenCoords = w->windowPos + ScreenCoordsXY{ 0, 2 };
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2020-08-28 22:33:36 +02:00
|
|
|
auto [drawString, ft] = window_editor_inventions_list_prepare_name(&_editorInventionsListDraggedItem, true);
|
2021-02-27 14:32:13 +01:00
|
|
|
DrawTextBasic(dpi, screenCoords, drawString, ft, { COLOUR_BLACK | COLOUR_FLAG_OUTLINE });
|
2018-03-21 12:52:39 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 22:33:36 +02:00
|
|
|
static std::pair<rct_string_id, Formatter> window_editor_inventions_list_prepare_name(
|
|
|
|
const ResearchItem* researchItem, bool withGap)
|
2018-03-21 12:52:39 +01:00
|
|
|
{
|
|
|
|
rct_string_id drawString;
|
2020-01-22 22:51:11 +01:00
|
|
|
rct_string_id stringId = researchItem->GetName();
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2018-03-21 12:52:39 +01:00
|
|
|
|
2020-07-22 15:25:05 +02:00
|
|
|
if (researchItem->type == Research::EntryType::Ride
|
2021-02-26 10:01:00 +01:00
|
|
|
&& !GetRideTypeDescriptor(researchItem->baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
2018-03-21 12:52:39 +01:00
|
|
|
{
|
|
|
|
drawString = withGap ? STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME_DRAG : STR_WINDOW_COLOUR_2_STRINGID_STRINGID;
|
2020-06-20 02:32:52 +02:00
|
|
|
rct_string_id rideTypeName = get_ride_naming(researchItem->baseRideType, get_ride_entry(researchItem->entryIndex)).Name;
|
|
|
|
ft.Add<rct_string_id>(rideTypeName);
|
2020-05-14 02:29:39 +02:00
|
|
|
ft.Add<rct_string_id>(stringId);
|
2018-03-21 12:52:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drawString = STR_WINDOW_COLOUR_2_STRINGID;
|
2020-05-14 02:29:39 +02:00
|
|
|
ft.Add<rct_string_id>(stringId);
|
2018-03-21 12:52:39 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 22:33:36 +02:00
|
|
|
return std::make_pair(drawString, ft);
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
2015-06-04 17:34:47 +02:00
|
|
|
#pragma endregion
|