2014-11-25 00:05:35 +01:00
|
|
|
/*****************************************************************************
|
2023-01-01 11:58:01 +01:00
|
|
|
* Copyright (c) 2014-2023 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>
|
2021-12-12 00:06:06 +01:00
|
|
|
#include <openrct2/localisation/Formatter.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;
|
2022-07-31 14:22:58 +02:00
|
|
|
static constexpr const StringId 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
|
|
|
};
|
|
|
|
|
2022-12-24 16:50:29 +01:00
|
|
|
static Widget _inventionListWidgets[] = {
|
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),
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2014-12-16 02:24:13 +01:00
|
|
|
};
|
|
|
|
|
2022-12-24 16:50:29 +01:00
|
|
|
static Widget _inventionListDragWidgets[] = {
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({0, 0}, {150, 14}, WindowWidgetType::ImgBtn, WindowColour::Primary),
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2014-12-16 02:24:13 +01:00
|
|
|
};
|
2022-07-02 08:53:46 +02:00
|
|
|
// clang-format on
|
2014-12-16 02:24:13 +01:00
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
static void WindowEditorInventionsListDragOpen(
|
|
|
|
ResearchItem* researchItem, const ScreenCoordsXY& editorPos, int objectSelectionScrollWidth);
|
2022-06-30 11:25:18 +02:00
|
|
|
static const ResearchItem* WindowEditorInventionsListDragGetItem();
|
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
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void ResearchRidesSetup()
|
2018-03-23 11:42:08 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Reset all objects to not required
|
2022-05-30 23:34:29 +02:00
|
|
|
for (auto objectType : TransientObjectTypes)
|
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
|
|
|
{
|
2022-01-19 18:41:24 +01:00
|
|
|
Editor::ClearSelectedObject(objectType, i, ObjectSelectionFlags::AllFlags);
|
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
|
|
|
{
|
2022-01-19 18:41:24 +01:00
|
|
|
Editor::SetSelectedObject(ObjectType::Ride, ride.subtype, ObjectSelectionFlags::Selected | ObjectSelectionFlags::InUse);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-06-04 22:15:00 +02:00
|
|
|
}
|
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
static void DrawResearchItem(
|
|
|
|
rct_drawpixelinfo& dpi, const ResearchItem& researchItem, const int16_t& width, const ScreenCoordsXY& screenCoords,
|
|
|
|
StringId format, TextPaint textPaint)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2022-11-17 11:44:43 +01:00
|
|
|
const StringId itemNameId = researchItem.GetName();
|
|
|
|
int16_t columnSplitOffset = width / 2;
|
2022-07-02 08:53:46 +02:00
|
|
|
|
|
|
|
if (researchItem.type == Research::EntryType::Ride
|
|
|
|
&& !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-11 17:35:01 +01:00
|
|
|
const StringId rideTypeName = get_ride_naming(researchItem.baseRideType, *get_ride_entry(researchItem.entryIndex)).Name;
|
2022-11-17 11:44:43 +01:00
|
|
|
|
|
|
|
// Draw group name
|
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(rideTypeName);
|
2022-11-17 11:44:43 +01:00
|
|
|
DrawTextEllipsised(&dpi, screenCoords, columnSplitOffset - 11, format, ft, textPaint);
|
|
|
|
|
|
|
|
// Draw vehicle name
|
|
|
|
ft = Formatter();
|
|
|
|
ft.Add<StringId>(itemNameId);
|
|
|
|
DrawTextEllipsised(
|
|
|
|
&dpi, { screenCoords + ScreenCoordsXY{ columnSplitOffset, 0 } }, columnSplitOffset - 11, format, ft, textPaint);
|
2019-06-17 20:27:34 +02:00
|
|
|
}
|
2022-07-02 08:53:46 +02:00
|
|
|
else
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-11-17 11:44:43 +01:00
|
|
|
// Scenery group, flat ride or shopdis
|
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<StringId>(itemNameId);
|
|
|
|
DrawTextEllipsised(&dpi, screenCoords, width, format, ft, textPaint);
|
2019-06-17 20:27:34 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
#pragma region Invention List Window
|
2022-07-02 08:53:46 +02:00
|
|
|
struct InventionListItem
|
|
|
|
{
|
|
|
|
ResearchItem* research = nullptr;
|
|
|
|
bool isInvented = true;
|
|
|
|
};
|
2022-07-02 08:23:32 +02:00
|
|
|
|
|
|
|
class InventionListWindow final : public Window
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
ResearchItem* _selectedResearchItem;
|
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
public:
|
|
|
|
void OnOpen() override
|
2018-06-04 22:39:35 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
ResearchRidesSetup();
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
widgets = _inventionListWidgets;
|
2022-07-02 08:23:32 +02:00
|
|
|
InitScrollWidgets();
|
|
|
|
selected_tab = 0;
|
2022-07-02 08:53:46 +02:00
|
|
|
_selectedResearchItem = nullptr;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
min_width = WW;
|
|
|
|
min_height = WH;
|
|
|
|
max_width = WW * 2;
|
|
|
|
max_height = WH * 2;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
void OnClose() override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
research_remove_flags();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
// When used in-game (as a cheat)
|
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
|
|
|
|
{
|
|
|
|
gSilentResearch = true;
|
|
|
|
research_reset_current_item();
|
|
|
|
gSilentResearch = false;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnMouseUp(WidgetIndex widx) override
|
2022-07-01 15:57:19 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
switch (widx)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
Close();
|
|
|
|
break;
|
|
|
|
case WIDX_RANDOM_SHUFFLE:
|
|
|
|
research_items_shuffle();
|
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
case WIDX_MOVE_ITEMS_TO_TOP:
|
|
|
|
research_items_make_all_researched();
|
|
|
|
InitScrollWidgets();
|
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
case WIDX_MOVE_ITEMS_TO_BOTTOM:
|
|
|
|
research_items_make_all_unresearched();
|
|
|
|
InitScrollWidgets();
|
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
}
|
2022-07-01 15:57:19 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
2022-07-01 15:57:19 +02:00
|
|
|
void OnResize() override
|
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
if (width < min_width)
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
width = min_width;
|
|
|
|
}
|
|
|
|
if (height < min_height)
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
height = min_height;
|
|
|
|
}
|
2022-07-01 15:57:19 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
2022-07-01 15:57:19 +02:00
|
|
|
void OnUpdate() override
|
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
frame_no++;
|
|
|
|
OnPrepareDraw();
|
2023-01-16 21:13:42 +01:00
|
|
|
WidgetInvalidate(*this, WIDX_TAB_1);
|
2022-07-02 08:23:32 +02:00
|
|
|
|
|
|
|
if (WindowEditorInventionsListDragGetItem() != nullptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Invalidate();
|
2022-07-01 15:57:19 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
2022-07-01 15:57:19 +02:00
|
|
|
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
ScreenSize size{};
|
|
|
|
if (scrollIndex == 0)
|
|
|
|
{
|
|
|
|
size.height = static_cast<int32_t>(gResearchItemsInvented.size()) * SCROLLABLE_ROW_HEIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size.height = static_cast<int32_t>(gResearchItemsUninvented.size()) * SCROLLABLE_ROW_HEIGHT;
|
|
|
|
}
|
|
|
|
return size;
|
2022-07-01 15:57:19 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
2022-07-01 15:57:19 +02:00
|
|
|
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto* researchItem = GetItemFromScrollY(scrollIndex == 0, screenCoords.y);
|
|
|
|
if (researchItem != _selectedResearchItem)
|
2022-07-02 08:23:32 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
_selectedResearchItem = researchItem;
|
2022-07-02 08:23:32 +02:00
|
|
|
Invalidate();
|
|
|
|
|
|
|
|
// Prevent always-researched items from being highlighted when hovered over
|
|
|
|
if (researchItem != nullptr && researchItem->IsAlwaysResearched())
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
_selectedResearchItem = nullptr;
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-01 15:57:19 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
2022-07-01 15:57:19 +02:00
|
|
|
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto* researchItem = GetItemFromScrollY(scrollIndex == 0, screenCoords.y);
|
2022-07-02 08:23:32 +02:00
|
|
|
if (researchItem == nullptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Disallow picking up always-researched items
|
|
|
|
if (researchItem->IsAlwaysResearched())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Invalidate();
|
2022-11-17 11:44:43 +01:00
|
|
|
|
|
|
|
WindowEditorInventionsListDragOpen(researchItem, windowPos, widgets[WIDX_PRE_RESEARCHED_SCROLL].right);
|
2022-07-01 15:57:19 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
2022-07-01 15:57:19 +02:00
|
|
|
void OnScrollDraw(int32_t scrollIndex, rct_drawpixelinfo& dpi) override
|
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
// Draw background
|
|
|
|
uint8_t paletteIndex = ColourMapA[colours[1]].mid_light;
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxClear(&dpi, paletteIndex);
|
2022-07-01 15:57:19 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
int16_t boxWidth = widgets[WIDX_RESEARCH_ORDER_SCROLL].width();
|
|
|
|
int32_t itemY = -SCROLLABLE_ROW_HEIGHT;
|
|
|
|
auto* dragItem = WindowEditorInventionsListDragGetItem();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
const auto& researchList = scrollIndex == 0 ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
for (const auto& researchItem : researchList)
|
|
|
|
{
|
|
|
|
itemY += SCROLLABLE_ROW_HEIGHT;
|
|
|
|
if (itemY + SCROLLABLE_ROW_HEIGHT < dpi.y || itemY >= dpi.y + dpi.height)
|
|
|
|
continue;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
if (_selectedResearchItem == &researchItem)
|
2022-07-02 08:23:32 +02:00
|
|
|
{
|
|
|
|
int32_t top, bottom;
|
|
|
|
if (dragItem == nullptr)
|
|
|
|
{
|
|
|
|
// Highlight
|
|
|
|
top = itemY;
|
|
|
|
bottom = itemY + SCROLLABLE_ROW_HEIGHT - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Drop horizontal rule
|
|
|
|
top = itemY - 1;
|
|
|
|
bottom = itemY;
|
|
|
|
}
|
|
|
|
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFilterRect(&dpi, { 0, top, boxWidth, bottom }, FilterPaletteID::PaletteDarken1);
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
if (dragItem != nullptr && researchItem == *dragItem)
|
|
|
|
continue;
|
2017-08-12 23:06:12 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
// TODO: this parameter by itself produces very light text.
|
|
|
|
// It needs a {BLACK} token in the string to work properly.
|
|
|
|
colour_t colour = COLOUR_BLACK;
|
2022-10-12 22:40:59 +02:00
|
|
|
FontStyle fontStyle = FontStyle::Medium;
|
2022-10-12 18:27:05 +02:00
|
|
|
auto darkness = TextDarkness::Regular;
|
2018-05-25 19:16:20 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
if (researchItem.IsAlwaysResearched())
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
if (_selectedResearchItem == &researchItem && dragItem == nullptr)
|
2022-10-12 18:27:05 +02:00
|
|
|
darkness = TextDarkness::ExtraDark;
|
2022-07-02 08:23:32 +02:00
|
|
|
else
|
2022-10-12 18:27:05 +02:00
|
|
|
darkness = TextDarkness::Dark;
|
2022-07-02 08:23:32 +02:00
|
|
|
colour = colours[1] | COLOUR_FLAG_INSET;
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
DrawResearchItem(dpi, researchItem, boxWidth, { 1, itemY }, STR_BLACK_STRING, { colour, fontStyle, darkness });
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
CursorID OnCursor(WidgetIndex widx, const ScreenCoordsXY& screenCoords, CursorID fallback) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
bool isInvented = false;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
switch (widx)
|
|
|
|
{
|
|
|
|
case WIDX_PRE_RESEARCHED_SCROLL:
|
2022-07-02 08:53:46 +02:00
|
|
|
isInvented = true;
|
2022-07-02 08:23:32 +02:00
|
|
|
break;
|
|
|
|
case WIDX_RESEARCH_ORDER_SCROLL:
|
2022-07-02 08:53:46 +02:00
|
|
|
isInvented = false;
|
2022-07-02 08:23:32 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use the open hand as cursor for items that can be picked up
|
2022-07-02 08:53:46 +02:00
|
|
|
auto* researchItem = GetItemFromScrollY(isInvented, screenCoords.y);
|
2022-07-02 08:23:32 +02:00
|
|
|
if (researchItem != nullptr && !researchItem->IsAlwaysResearched())
|
|
|
|
{
|
|
|
|
return CursorID::HandOpen;
|
|
|
|
}
|
|
|
|
return fallback;
|
2018-05-25 19:16:20 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
|
|
|
void OnDraw(rct_drawpixelinfo& dpi) override
|
2018-05-25 19:16:20 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
DrawWidgets(dpi);
|
|
|
|
|
|
|
|
// Tab image
|
|
|
|
auto screenPos = windowPos + ScreenCoordsXY{ widgets[WIDX_TAB_1].left, widgets[WIDX_TAB_1].top };
|
2023-01-16 19:52:17 +01:00
|
|
|
GfxDrawSprite(&dpi, ImageId(SPR_TAB_FINANCES_RESEARCH_0 + (frame_no / 2) % 8), screenPos);
|
2022-07-02 08:23:32 +02:00
|
|
|
|
|
|
|
// Pre-researched items label
|
|
|
|
screenPos = windowPos
|
|
|
|
+ ScreenCoordsXY{ widgets[WIDX_PRE_RESEARCHED_SCROLL].left, widgets[WIDX_PRE_RESEARCHED_SCROLL].top - 11 };
|
|
|
|
DrawTextBasic(&dpi, screenPos - ScreenCoordsXY{ 0, 1 }, STR_INVENTION_PREINVENTED_ITEMS);
|
|
|
|
|
|
|
|
// Research order label
|
|
|
|
screenPos = windowPos
|
|
|
|
+ ScreenCoordsXY{ widgets[WIDX_RESEARCH_ORDER_SCROLL].left, widgets[WIDX_RESEARCH_ORDER_SCROLL].top - 11 };
|
|
|
|
DrawTextBasic(&dpi, screenPos - ScreenCoordsXY{ 0, 1 }, STR_INVENTION_TO_BE_INVENTED_ITEMS);
|
|
|
|
|
|
|
|
// Preview background
|
|
|
|
auto& bkWidget = widgets[WIDX_PREVIEW];
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(
|
2022-07-02 08:23:32 +02:00
|
|
|
&dpi,
|
|
|
|
{ windowPos + ScreenCoordsXY{ bkWidget.left + 1, bkWidget.top + 1 },
|
|
|
|
windowPos + ScreenCoordsXY{ bkWidget.right - 1, bkWidget.bottom - 1 } },
|
|
|
|
ColourMapA[colours[1]].darkest);
|
|
|
|
|
|
|
|
auto* researchItem = WindowEditorInventionsListDragGetItem();
|
|
|
|
if (researchItem == nullptr || researchItem->IsNull())
|
2022-07-02 08:53:46 +02:00
|
|
|
researchItem = _selectedResearchItem;
|
2022-07-02 08:23:32 +02:00
|
|
|
// If the research item is null or a list separator.
|
|
|
|
if (researchItem == nullptr || researchItem->IsNull())
|
|
|
|
return;
|
2018-05-25 19:16:20 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
// Preview image
|
|
|
|
ObjectType objectEntryType = ObjectType::SceneryGroup;
|
|
|
|
if (researchItem->type == Research::EntryType::Ride)
|
|
|
|
objectEntryType = ObjectType::Ride;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
auto chunk = object_entry_get_chunk(objectEntryType, researchItem->entryIndex);
|
|
|
|
if (chunk == nullptr)
|
|
|
|
return;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
// Draw preview
|
|
|
|
const auto* object = object_entry_get_object(objectEntryType, researchItem->entryIndex);
|
|
|
|
if (object != nullptr)
|
|
|
|
{
|
|
|
|
rct_drawpixelinfo clipDPI;
|
|
|
|
screenPos = windowPos + ScreenCoordsXY{ bkWidget.left + 1, bkWidget.top + 1 };
|
|
|
|
const auto clipWidth = bkWidget.width() - 1;
|
|
|
|
const auto clipHeight = bkWidget.height() - 1;
|
2023-01-16 14:50:43 +01:00
|
|
|
if (ClipDrawPixelInfo(&clipDPI, &dpi, screenPos, clipWidth, clipHeight))
|
2022-07-02 08:23:32 +02:00
|
|
|
{
|
2022-08-16 01:50:01 +02:00
|
|
|
object->DrawPreview(&clipDPI, clipWidth, clipHeight);
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
// Item name
|
|
|
|
screenPos = windowPos + ScreenCoordsXY{ bkWidget.midX() + 1, bkWidget.bottom + 3 };
|
|
|
|
const auto itemWidth = width - widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6;
|
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
StringId drawString = STR_WINDOW_COLOUR_2_STRINGID;
|
|
|
|
StringId stringId = researchItem->GetName();
|
|
|
|
auto ft = Formatter();
|
|
|
|
|
|
|
|
if (researchItem->type == Research::EntryType::Ride
|
|
|
|
&& !GetRideTypeDescriptor(researchItem->baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
|
|
|
{
|
|
|
|
drawString = STR_WINDOW_COLOUR_2_STRINGID_STRINGID;
|
2023-01-11 17:35:01 +01:00
|
|
|
StringId rideTypeName = get_ride_naming(researchItem->baseRideType, *get_ride_entry(researchItem->entryIndex)).Name;
|
2022-11-17 11:44:43 +01:00
|
|
|
ft.Add<StringId>(rideTypeName);
|
|
|
|
ft.Add<StringId>(stringId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ft.Add<StringId>(stringId);
|
|
|
|
}
|
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
DrawTextEllipsised(&dpi, screenPos, itemWidth, drawString, ft, { TextAlignment::CENTRE });
|
|
|
|
screenPos.y += 15;
|
|
|
|
|
|
|
|
// Item category
|
|
|
|
screenPos.x = windowPos.x + widgets[WIDX_RESEARCH_ORDER_SCROLL].right + 4;
|
|
|
|
ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(researchItem->GetCategoryInventionString());
|
2022-07-02 08:23:32 +02:00
|
|
|
DrawTextBasic(&dpi, screenPos, STR_INVENTION_RESEARCH_GROUP, ft);
|
2019-06-16 23:32:31 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
|
|
|
|
void OnPrepareDraw() override
|
2019-06-16 23:32:31 +02:00
|
|
|
{
|
2022-10-17 19:21:18 +02:00
|
|
|
pressed_widgets |= 1uLL << WIDX_PREVIEW;
|
|
|
|
pressed_widgets |= 1uLL << WIDX_TAB_1;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_CLOSE].type = gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR ? WindowWidgetType::Empty
|
|
|
|
: WindowWidgetType::CloseBox;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-11-06 10:29:40 +01:00
|
|
|
ResizeFrameWithPage();
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
int16_t scrollListHeight = (height - 88) / 2;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom = 60 + scrollListHeight;
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_PRE_RESEARCHED_SCROLL].right = width - 229;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_RESEARCH_ORDER_SCROLL].top = widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom + 15;
|
2022-07-02 08:53:46 +02:00
|
|
|
widgets[WIDX_RESEARCH_ORDER_SCROLL].bottom = widgets[WIDX_RESEARCH_ORDER_SCROLL].top + scrollListHeight;
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_RESEARCH_ORDER_SCROLL].right = width - 229;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_PREVIEW].left = width - 169;
|
|
|
|
widgets[WIDX_PREVIEW].right = width - 56;
|
2018-06-13 11:50:37 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_TOP].top = height - 57;
|
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_TOP].bottom = height - 44;
|
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_TOP].left = width - 225;
|
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_TOP].right = width - 6;
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].top = height - 42;
|
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].bottom = height - 29;
|
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].left = width - 225;
|
|
|
|
widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].right = width - 6;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_RANDOM_SHUFFLE].top = height - 27;
|
|
|
|
widgets[WIDX_RANDOM_SHUFFLE].bottom = height - 14;
|
|
|
|
widgets[WIDX_RANDOM_SHUFFLE].left = width - 225;
|
|
|
|
widgets[WIDX_RANDOM_SHUFFLE].right = width - 6;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
// Get Research Item and Scroll Id (scroll id represents invented(0)/not invented(1)/failure(-1)
|
2022-07-02 08:53:46 +02:00
|
|
|
std::optional<InventionListItem> GetResearchItemAt(const ScreenCoordsXY& screenCoords)
|
2018-06-13 11:50:37 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
if (windowPos.x <= screenCoords.x && windowPos.y < screenCoords.y && windowPos.x + width > screenCoords.x
|
|
|
|
&& windowPos.y + height > screenCoords.y)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
WidgetIndex widgetIndex = WindowFindWidgetFromPoint(*this, screenCoords);
|
2022-07-02 08:23:32 +02:00
|
|
|
auto& widget = widgets[widgetIndex];
|
|
|
|
if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL || widgetIndex == WIDX_RESEARCH_ORDER_SCROLL)
|
|
|
|
{
|
|
|
|
gPressedWidget.widget_index = widgetIndex;
|
|
|
|
int32_t outScrollArea{};
|
|
|
|
ScreenCoordsXY outScrollCoords{};
|
|
|
|
int32_t outScrollId{};
|
2022-07-30 22:40:33 +02:00
|
|
|
WidgetScrollGetPart(*this, &widget, screenCoords, outScrollCoords, &outScrollArea, &outScrollId);
|
2022-07-02 08:23:32 +02:00
|
|
|
if (outScrollArea == SCROLL_PART_VIEW)
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
const auto isInvented = outScrollId == 0;
|
2022-07-02 08:23:32 +02:00
|
|
|
int32_t scrollY = outScrollCoords.y + 6;
|
2022-07-02 08:53:46 +02:00
|
|
|
return InventionListItem{ GetItemFromScrollYIncludeSeps(isInvented, scrollY), isInvented };
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2019-06-17 20:27:34 +02:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsResearchItemSelected(ResearchItem* item) const
|
|
|
|
{
|
|
|
|
return item == _selectedResearchItem;
|
|
|
|
}
|
|
|
|
|
2022-08-16 01:52:20 +02:00
|
|
|
// hack to fix #17544: OnScrollMouseOver never gets called while dragging
|
|
|
|
void SetSelectedResearchItem(ResearchItem* item)
|
|
|
|
{
|
|
|
|
_selectedResearchItem = item;
|
|
|
|
}
|
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
void MoveResearchItem(const ResearchItem& item, ResearchItem* beforeItem, bool isInvented)
|
|
|
|
{
|
|
|
|
_selectedResearchItem = nullptr;
|
|
|
|
Invalidate();
|
|
|
|
|
2022-10-24 22:58:11 +02:00
|
|
|
uint32_t beforeItemRawValue = 0;
|
|
|
|
if (beforeItem != nullptr)
|
|
|
|
beforeItemRawValue = beforeItem->rawValue;
|
|
|
|
|
|
|
|
if (item.rawValue == beforeItemRawValue)
|
|
|
|
return;
|
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
ResearchRemove(item);
|
|
|
|
|
|
|
|
auto& researchList = isInvented ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
if (beforeItem != nullptr)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < researchList.size(); i++)
|
|
|
|
{
|
2022-10-24 22:58:11 +02:00
|
|
|
if (researchList[i].rawValue == beforeItemRawValue)
|
2022-07-02 08:53:46 +02:00
|
|
|
{
|
|
|
|
researchList.insert((researchList.begin() + i), item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Still not found? Append to end of list.
|
|
|
|
researchList.push_back(item);
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
2019-06-17 19:31:54 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
private:
|
2022-07-02 08:53:46 +02:00
|
|
|
ResearchItem* GetItemFromScrollY(bool isInvented, int32_t y) const
|
2017-10-21 00:21:01 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto& researchList = isInvented ? gResearchItemsInvented : gResearchItemsUninvented;
|
2022-07-02 08:23:32 +02:00
|
|
|
for (auto& researchItem : researchList)
|
2018-05-26 23:26:58 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
y -= SCROLLABLE_ROW_HEIGHT;
|
|
|
|
if (y < 0)
|
2018-05-26 23:26:58 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
return &researchItem;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-02-28 00:22:24 +01:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
ResearchItem* GetItemFromScrollYIncludeSeps(bool isInvented, int32_t y) const
|
2022-07-02 08:23:32 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto& researchList = isInvented ? gResearchItemsInvented : gResearchItemsUninvented;
|
2022-07-02 08:23:32 +02:00
|
|
|
for (auto& researchItem : researchList)
|
2018-05-26 23:26:58 +02:00
|
|
|
{
|
2022-07-02 08:23:32 +02:00
|
|
|
y -= SCROLLABLE_ROW_HEIGHT;
|
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
return &researchItem;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-07-02 08:23:32 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
};
|
2018-06-08 22:57:29 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00684E04
|
|
|
|
*/
|
|
|
|
rct_window* WindowEditorInventionsListOpen()
|
|
|
|
{
|
|
|
|
return WindowFocusOrCreate<InventionListWindow>(
|
2022-08-21 18:38:25 +02:00
|
|
|
WindowClass::EditorInventionList, WW, WH, WF_NO_SCROLLING | WF_RESIZABLE | WF_CENTRE_SCREEN);
|
2022-07-02 08:23:32 +02:00
|
|
|
}
|
|
|
|
#pragma endregion
|
2014-12-16 02:24:13 +01:00
|
|
|
|
|
|
|
#pragma region Drag item
|
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
class InventionDragWindow final : public Window
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2022-06-30 11:25:18 +02:00
|
|
|
ResearchItem _draggedItem;
|
2018-03-21 12:52:39 +01:00
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
public:
|
|
|
|
void OnOpen() override
|
2018-03-21 12:52:39 +01:00
|
|
|
{
|
2022-06-30 11:25:18 +02:00
|
|
|
widgets = _inventionListDragWidgets;
|
|
|
|
colours[1] = COLOUR_WHITE;
|
2018-03-21 12:52:39 +01:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
CursorID OnCursor(const WidgetIndex widx, const ScreenCoordsXY& screenCoords, const CursorID defaultCursor) override
|
2022-06-30 11:25:18 +02:00
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
auto* inventionListWindow = static_cast<InventionListWindow*>(WindowFindByClass(WindowClass::EditorInventionList));
|
2022-06-30 11:25:18 +02:00
|
|
|
if (inventionListWindow != nullptr)
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto res = inventionListWindow->GetResearchItemAt(screenCoords);
|
|
|
|
auto* research = res.has_value() ? res->research : nullptr;
|
|
|
|
if (!inventionListWindow->IsResearchItemSelected(research))
|
2022-06-30 11:25:18 +02:00
|
|
|
{
|
2022-08-16 01:52:20 +02:00
|
|
|
inventionListWindow->SetSelectedResearchItem(research);
|
2022-06-30 11:25:18 +02:00
|
|
|
inventionListWindow->Invalidate();
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
return CursorID::HandClosed;
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
void OnMoved(const ScreenCoordsXY& screenCoords) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
auto* inventionListWindow = static_cast<InventionListWindow*>(WindowFindByClass(WindowClass::EditorInventionList));
|
2022-07-02 08:53:46 +02:00
|
|
|
if (inventionListWindow == nullptr)
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
std::optional<InventionListItem> res;
|
2022-06-30 11:25:18 +02:00
|
|
|
// Skip always researched items, so that the dragged item gets placed underneath them
|
|
|
|
auto newScreenCoords = screenCoords;
|
|
|
|
do
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
res = inventionListWindow->GetResearchItemAt(newScreenCoords);
|
2022-06-30 11:25:18 +02:00
|
|
|
newScreenCoords.y += LIST_ROW_HEIGHT;
|
2022-07-17 09:12:29 +02:00
|
|
|
} while (res.has_value() && res->research != nullptr && res->research->IsAlwaysResearched());
|
2022-06-30 11:25:18 +02:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
if (res.has_value())
|
2022-06-30 11:25:18 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
inventionListWindow->MoveResearchItem(_draggedItem, res->research, res->isInvented);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-06-30 11:25:18 +02:00
|
|
|
|
2023-01-16 21:13:42 +01:00
|
|
|
WindowInvalidateByClass(WindowClass::EditorInventionList);
|
2022-06-30 11:25:18 +02:00
|
|
|
Close();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
void OnDraw(rct_drawpixelinfo& dpi) override
|
|
|
|
{
|
|
|
|
auto screenCoords = windowPos + ScreenCoordsXY{ 0, 2 };
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
DrawResearchItem(
|
2023-01-10 23:48:06 +01:00
|
|
|
dpi, _draggedItem, width, screenCoords, STR_WINDOW_COLOUR_2_STRINGID,
|
|
|
|
{ COLOUR_BLACK | static_cast<uint8_t>(COLOUR_FLAG_OUTLINE) });
|
2022-06-30 11:25:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
void Init(ResearchItem& researchItem, const ScreenCoordsXY& editorPos, int objectSelectionScrollWidth)
|
2018-06-13 12:49:45 +02:00
|
|
|
{
|
2022-06-30 11:25:18 +02:00
|
|
|
_draggedItem = researchItem;
|
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
widgets[0].right = objectSelectionScrollWidth;
|
2022-06-30 11:25:18 +02:00
|
|
|
Invalidate();
|
2022-11-17 11:44:43 +01:00
|
|
|
windowPos = ScreenCoordsXY{ editorPos.x, gTooltipCursor.y - 7 };
|
|
|
|
width = objectSelectionScrollWidth;
|
2022-06-30 11:25:18 +02:00
|
|
|
Invalidate();
|
2018-06-13 12:49:45 +02:00
|
|
|
|
2022-07-31 17:12:32 +02:00
|
|
|
InputWindowPositionBegin(*this, 0, gTooltipCursor);
|
2022-06-30 11:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const ResearchItem& GetItem() const
|
2019-06-19 22:58:04 +02:00
|
|
|
{
|
2022-06-30 11:25:18 +02:00
|
|
|
return _draggedItem;
|
2019-06-19 22:58:04 +02:00
|
|
|
}
|
2022-06-30 11:25:18 +02:00
|
|
|
};
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-11-17 11:44:43 +01:00
|
|
|
static void WindowEditorInventionsListDragOpen(
|
|
|
|
ResearchItem* researchItem, const ScreenCoordsXY& editorPos, int objectSelectionScrollWidth)
|
2022-06-30 11:25:18 +02:00
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
WindowCloseByClass(WindowClass::EditorInventionListDrag);
|
2022-06-30 11:25:18 +02:00
|
|
|
auto* wnd = WindowCreate<InventionDragWindow>(
|
2022-08-21 18:38:25 +02:00
|
|
|
WindowClass::EditorInventionListDrag, 10, 14, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_SNAPPING);
|
2022-06-30 11:25:18 +02:00
|
|
|
if (wnd != nullptr)
|
|
|
|
{
|
2022-11-17 11:44:43 +01:00
|
|
|
wnd->Init(*researchItem, editorPos, objectSelectionScrollWidth);
|
2022-06-30 11:25:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
}
|
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
static const ResearchItem* WindowEditorInventionsListDragGetItem()
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
auto* wnd = static_cast<InventionDragWindow*>(WindowFindByClass(WindowClass::EditorInventionListDrag));
|
2022-06-30 11:25:18 +02:00
|
|
|
if (wnd == nullptr)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return &wnd->GetItem();
|
2018-03-21 12:52:39 +01:00
|
|
|
}
|
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
#pragma endregion
|