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>
|
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;
|
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
|
|
|
};
|
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
static rct_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-06-30 11:25:18 +02:00
|
|
|
static rct_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
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowEditorInventionsListDragOpen(ResearchItem* researchItem);
|
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-07-02 08:53:46 +02:00
|
|
|
static std::pair<rct_string_id, Formatter> WindowEditorInventionsListPrepareName(const ResearchItem& researchItem, bool withGap)
|
2014-12-16 02:24:13 +01:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
rct_string_id drawString;
|
|
|
|
rct_string_id stringId = researchItem.GetName();
|
|
|
|
auto ft = Formatter();
|
|
|
|
|
|
|
|
if (researchItem.type == Research::EntryType::Ride
|
|
|
|
&& !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
drawString = withGap ? STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME_DRAG : STR_WINDOW_COLOUR_2_STRINGID_STRINGID;
|
|
|
|
rct_string_id rideTypeName = get_ride_naming(researchItem.baseRideType, get_ride_entry(researchItem.entryIndex)).Name;
|
|
|
|
ft.Add<rct_string_id>(rideTypeName);
|
|
|
|
ft.Add<rct_string_id>(stringId);
|
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-07-02 08:53:46 +02:00
|
|
|
drawString = STR_WINDOW_COLOUR_2_STRINGID;
|
|
|
|
ft.Add<rct_string_id>(stringId);
|
2019-06-17 20:27:34 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:53:46 +02:00
|
|
|
return std::make_pair(drawString, ft);
|
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-07-01 15:57:19 +02:00
|
|
|
void OnMouseUp(rct_widgetindex widx) override
|
|
|
|
{
|
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();
|
2022-07-31 00:25:33 +02:00
|
|
|
widget_invalidate(*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();
|
|
|
|
WindowEditorInventionsListDragOpen(researchItem);
|
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;
|
|
|
|
gfx_clear(&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();
|
|
|
|
int16_t columnSplitOffset = boxWidth / 2;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_filter_rect(&dpi, { 0, top, boxWidth, bottom }, FilterPaletteID::PaletteDarken1);
|
|
|
|
}
|
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;
|
|
|
|
FontSpriteBase fontSpriteBase = FontSpriteBase::MEDIUM;
|
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-07-02 08:23:32 +02:00
|
|
|
fontSpriteBase = FontSpriteBase::MEDIUM_EXTRA_DARK;
|
|
|
|
else
|
|
|
|
fontSpriteBase = FontSpriteBase::MEDIUM_DARK;
|
|
|
|
colour = colours[1] | COLOUR_FLAG_INSET;
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
const rct_string_id itemNameId = researchItem.GetName();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
if (researchItem.type == Research::EntryType::Ride
|
|
|
|
&& !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
|
|
|
{
|
|
|
|
const auto rideEntry = get_ride_entry(researchItem.entryIndex);
|
|
|
|
const rct_string_id rideTypeName = get_ride_naming(researchItem.baseRideType, rideEntry).Name;
|
|
|
|
|
|
|
|
// 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, fontSpriteBase });
|
|
|
|
|
|
|
|
// Draw vehicle name
|
|
|
|
ft = Formatter();
|
|
|
|
ft.Add<rct_string_id>(itemNameId);
|
|
|
|
DrawTextEllipsised(
|
|
|
|
&dpi, { columnSplitOffset + 1, itemY }, columnSplitOffset - 11, STR_BLACK_STRING, ft,
|
|
|
|
{ colour, fontSpriteBase });
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// 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, fontSpriteBase });
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-07-02 08:23:32 +02:00
|
|
|
CursorID OnCursor(rct_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 };
|
|
|
|
gfx_draw_sprite(&dpi, ImageId(SPR_TAB_FINANCES_RESEARCH_0 + (frame_no / 2) % 8), screenPos);
|
|
|
|
|
|
|
|
// 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];
|
|
|
|
gfx_fill_rect(
|
|
|
|
&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;
|
|
|
|
if (clip_drawpixelinfo(&clipDPI, &dpi, screenPos, clipWidth, clipHeight))
|
|
|
|
{
|
|
|
|
object->DrawPreview(&clipDPI, clipWidth, height);
|
|
|
|
}
|
|
|
|
}
|
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-07-02 08:53:46 +02:00
|
|
|
auto [drawString, ft] = WindowEditorInventionsListPrepareName(*researchItem, false);
|
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();
|
|
|
|
ft.Add<rct_string_id>(researchItem->GetCategoryInventionString());
|
|
|
|
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-07-02 08:23:32 +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-07-02 08:23:32 +02:00
|
|
|
widgets[WIDX_BACKGROUND].right = width - 1;
|
|
|
|
widgets[WIDX_BACKGROUND].bottom = height - 1;
|
|
|
|
widgets[WIDX_TITLE].right = width - 2;
|
|
|
|
widgets[WIDX_CLOSE].left = width - 13;
|
|
|
|
widgets[WIDX_CLOSE].right = width - 3;
|
|
|
|
widgets[WIDX_RESIZE].right = width - 1;
|
|
|
|
widgets[WIDX_RESIZE].bottom = height - 1;
|
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
|
|
|
{
|
2022-07-31 00:25:33 +02:00
|
|
|
rct_widgetindex widgetIndex = window_find_widget_from_point(*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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoveResearchItem(const ResearchItem& item, ResearchItem* beforeItem, bool isInvented)
|
|
|
|
{
|
|
|
|
_selectedResearchItem = nullptr;
|
|
|
|
Invalidate();
|
|
|
|
|
|
|
|
ResearchRemove(item);
|
|
|
|
|
|
|
|
auto& researchList = isInvented ? gResearchItemsInvented : gResearchItemsUninvented;
|
|
|
|
if (beforeItem != nullptr)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < researchList.size(); i++)
|
|
|
|
{
|
|
|
|
if (researchList[i] == *beforeItem)
|
|
|
|
{
|
|
|
|
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>(
|
|
|
|
WC_EDITOR_INVENTION_LIST, WW, WH, WF_NO_SCROLLING | WF_RESIZABLE | WF_CENTRE_SCREEN);
|
|
|
|
}
|
|
|
|
#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-06-30 11:25:18 +02:00
|
|
|
CursorID OnCursor(const rct_widgetindex widx, const ScreenCoordsXY& screenCoords, const CursorID defaultCursor) override
|
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto* inventionListWindow = static_cast<InventionListWindow*>(window_find_by_class(WC_EDITOR_INVENTION_LIST));
|
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
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2022-07-02 08:53:46 +02:00
|
|
|
auto* inventionListWindow = static_cast<InventionListWindow*>(window_find_by_class(WC_EDITOR_INVENTION_LIST));
|
|
|
|
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
|
|
|
|
|
|
|
window_invalidate_by_class(WC_EDITOR_INVENTION_LIST);
|
|
|
|
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-07-02 08:53:46 +02:00
|
|
|
auto [drawString, ft] = WindowEditorInventionsListPrepareName(_draggedItem, true);
|
2022-06-30 11:25:18 +02:00
|
|
|
DrawTextBasic(&dpi, screenCoords, drawString, ft, { COLOUR_BLACK | COLOUR_FLAG_OUTLINE });
|
|
|
|
}
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2022-06-30 11:25:18 +02:00
|
|
|
void Init(ResearchItem& researchItem)
|
2018-06-13 12:49:45 +02:00
|
|
|
{
|
2022-06-30 11:25:18 +02:00
|
|
|
_draggedItem = researchItem;
|
|
|
|
rct_string_id stringId = researchItem.GetName();
|
|
|
|
char buffer[256] = {};
|
|
|
|
if (researchItem.type == Research::EntryType::Ride
|
|
|
|
&& !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
|
|
|
{
|
|
|
|
const auto rideEntry = get_ride_entry(researchItem.entryIndex);
|
|
|
|
const rct_string_id rideTypeName = get_ride_naming(researchItem.baseRideType, rideEntry).Name;
|
|
|
|
Formatter ft;
|
|
|
|
ft.Add<rct_string_id>(stringId);
|
|
|
|
ft.Add<rct_string_id>(rideTypeName);
|
|
|
|
format_string(buffer, 256, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, &ft);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
format_string(buffer, 256, stringId, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto stringWidth = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM);
|
|
|
|
widgets[0].right = stringWidth;
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
windowPos = gTooltipCursor - ScreenCoordsXY{ stringWidth / 2, 7 };
|
|
|
|
width = stringWidth;
|
|
|
|
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-06-30 11:25:18 +02:00
|
|
|
static void WindowEditorInventionsListDragOpen(ResearchItem* researchItem)
|
|
|
|
{
|
|
|
|
window_close_by_class(WC_EDITOR_INVENTION_LIST_DRAG);
|
|
|
|
auto* wnd = WindowCreate<InventionDragWindow>(
|
|
|
|
WC_EDITOR_INVENTION_LIST_DRAG, 10, 14, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_SNAPPING);
|
|
|
|
if (wnd != nullptr)
|
|
|
|
{
|
|
|
|
wnd->Init(*researchItem);
|
|
|
|
}
|
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
|
|
|
{
|
2022-06-30 11:25:18 +02:00
|
|
|
auto* wnd = static_cast<InventionDragWindow*>(window_find_by_class(WC_EDITOR_INVENTION_LIST_DRAG));
|
|
|
|
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
|