mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor ride_list_item to RideSelection (#11505)
This commit is contained in:
parent
3c89d5ec12
commit
2e50cd44ba
|
@ -264,9 +264,9 @@ public:
|
|||
static_cast<track_design_file_ref*>(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)));
|
||||
case WC_TRACK_DESIGN_LIST:
|
||||
{
|
||||
ride_list_item rideItem;
|
||||
rideItem.type = intent->GetUIntExtra(INTENT_EXTRA_RIDE_TYPE);
|
||||
rideItem.entry_index = intent->GetUIntExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX);
|
||||
RideSelection rideItem;
|
||||
rideItem.Type = intent->GetUIntExtra(INTENT_EXTRA_RIDE_TYPE);
|
||||
rideItem.EntryIndex = intent->GetUIntExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX);
|
||||
return window_track_list_open(rideItem);
|
||||
}
|
||||
case WC_SCENARIO_SELECT:
|
||||
|
@ -282,9 +282,9 @@ public:
|
|||
auto w = window_new_ride_open();
|
||||
|
||||
// Switch to right tab and scroll to ride location
|
||||
ride_list_item rideItem;
|
||||
rideItem.type = intent->GetUIntExtra(INTENT_EXTRA_RIDE_TYPE);
|
||||
rideItem.entry_index = intent->GetUIntExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX);
|
||||
RideSelection rideItem;
|
||||
rideItem.Type = intent->GetUIntExtra(INTENT_EXTRA_RIDE_TYPE);
|
||||
rideItem.EntryIndex = intent->GetUIntExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX);
|
||||
window_new_ride_focus(rideItem);
|
||||
|
||||
return w;
|
||||
|
|
|
@ -39,8 +39,8 @@ constexpr int32_t WH = 382;
|
|||
constexpr int32_t WW = 601;
|
||||
|
||||
static uint8_t _windowNewRideCurrentTab;
|
||||
static ride_list_item _windowNewRideHighlightedItem[6];
|
||||
static ride_list_item _windowNewRideListItems[384];
|
||||
static RideSelection _windowNewRideHighlightedItem[6];
|
||||
static RideSelection _windowNewRideListItems[384];
|
||||
|
||||
#pragma region Ride type view order
|
||||
|
||||
|
@ -265,14 +265,14 @@ static constexpr const int32_t window_new_ride_tab_animation_divisor[] = { 4, 8,
|
|||
|
||||
static void window_new_ride_set_page(rct_window* w, int32_t page);
|
||||
static void window_new_ride_refresh_widget_sizing(rct_window* w);
|
||||
static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window* w, const ScreenCoordsXY& screenCoords);
|
||||
static RideSelection window_new_ride_scroll_get_ride_list_item_at(rct_window* w, const ScreenCoordsXY& screenCoords);
|
||||
static void window_new_ride_paint_ride_information(
|
||||
rct_window* w, rct_drawpixelinfo* dpi, ride_list_item item, int32_t x, int32_t y, int32_t width);
|
||||
rct_window* w, rct_drawpixelinfo* dpi, RideSelection item, int32_t x, int32_t y, int32_t width);
|
||||
static void window_new_ride_select(rct_window* w);
|
||||
static ride_list_item* window_new_ride_iterate_over_ride_group(
|
||||
uint8_t rideType, uint8_t rideGroupIndex, ride_list_item* nextListItem);
|
||||
static RideSelection* window_new_ride_iterate_over_ride_group(
|
||||
uint8_t rideType, uint8_t rideGroupIndex, RideSelection* nextListItem);
|
||||
|
||||
static ride_list_item _lastTrackDesignCountRideType;
|
||||
static RideSelection _lastTrackDesignCountRideType;
|
||||
static int32_t _lastTrackDesignCount;
|
||||
|
||||
/**
|
||||
|
@ -310,7 +310,7 @@ void window_new_ride_init_vars()
|
|||
static void window_new_ride_populate_list()
|
||||
{
|
||||
uint8_t currentCategory = _windowNewRideCurrentTab;
|
||||
ride_list_item* nextListItem = _windowNewRideListItems;
|
||||
RideSelection* nextListItem = _windowNewRideListItems;
|
||||
|
||||
// For each ride type in the view order list
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(std::size(RideTypeViewOrder)); i++)
|
||||
|
@ -338,12 +338,12 @@ static void window_new_ride_populate_list()
|
|||
}
|
||||
}
|
||||
|
||||
nextListItem->type = RIDE_TYPE_NULL;
|
||||
nextListItem->entry_index = RIDE_ENTRY_INDEX_NULL;
|
||||
nextListItem->Type = RIDE_TYPE_NULL;
|
||||
nextListItem->EntryIndex = RIDE_ENTRY_INDEX_NULL;
|
||||
}
|
||||
|
||||
static ride_list_item* window_new_ride_iterate_over_ride_group(
|
||||
uint8_t rideType, uint8_t rideGroupIndex, ride_list_item* nextListItem)
|
||||
static RideSelection* window_new_ride_iterate_over_ride_group(
|
||||
uint8_t rideType, uint8_t rideGroupIndex, RideSelection* nextListItem)
|
||||
{
|
||||
bool buttonForRideTypeCreated = false;
|
||||
bool allowDrawingOverLastButton = false;
|
||||
|
@ -403,8 +403,8 @@ static ride_list_item* window_new_ride_iterate_over_ride_group(
|
|||
{
|
||||
// Separate, draw apart
|
||||
allowDrawingOverLastButton = false;
|
||||
nextListItem->type = rideType;
|
||||
nextListItem->entry_index = rideEntryIndex;
|
||||
nextListItem->Type = rideType;
|
||||
nextListItem->EntryIndex = rideEntryIndex;
|
||||
nextListItem++;
|
||||
}
|
||||
else if (!buttonForRideTypeCreated)
|
||||
|
@ -412,8 +412,8 @@ static ride_list_item* window_new_ride_iterate_over_ride_group(
|
|||
// Non-separate, draw-apart
|
||||
buttonForRideTypeCreated = true;
|
||||
allowDrawingOverLastButton = true;
|
||||
nextListItem->type = rideType;
|
||||
nextListItem->entry_index = rideEntryIndex;
|
||||
nextListItem->Type = rideType;
|
||||
nextListItem->EntryIndex = rideEntryIndex;
|
||||
nextListItem++;
|
||||
}
|
||||
else if (allowDrawingOverLastButton)
|
||||
|
@ -422,8 +422,8 @@ static ride_list_item* window_new_ride_iterate_over_ride_group(
|
|||
if (rideType == rideEntry->ride_type[0])
|
||||
{
|
||||
nextListItem--;
|
||||
nextListItem->type = rideType;
|
||||
nextListItem->entry_index = rideEntryIndex;
|
||||
nextListItem->Type = rideType;
|
||||
nextListItem->EntryIndex = rideEntryIndex;
|
||||
nextListItem++;
|
||||
}
|
||||
}
|
||||
|
@ -445,12 +445,12 @@ static void window_new_ride_scroll_to_focused_ride(rct_window* w)
|
|||
// Find row index of the focused ride type
|
||||
rct_widget* listWidget = &window_new_ride_widgets[WIDX_RIDE_LIST];
|
||||
assert(_windowNewRideCurrentTab < std::size(_windowNewRideHighlightedItem));
|
||||
int32_t focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry;
|
||||
auto focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab];
|
||||
int32_t count = 0, row = 0;
|
||||
ride_list_item* listItem = _windowNewRideListItems;
|
||||
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != RIDE_ENTRY_INDEX_NULL)
|
||||
RideSelection* listItem = _windowNewRideListItems;
|
||||
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
|
||||
{
|
||||
if (listItem->type == focusRideType)
|
||||
if (listItem->Type == focusRideType.Type)
|
||||
{
|
||||
row = count / 5;
|
||||
break;
|
||||
|
@ -492,12 +492,12 @@ rct_window* window_new_ride_open()
|
|||
window_init_scroll_widgets(w);
|
||||
|
||||
w->frame_no = 0;
|
||||
w->new_ride.selected_ride_id = -1;
|
||||
_lastTrackDesignCountRideType.type = RIDE_TYPE_NULL;
|
||||
_lastTrackDesignCountRideType.entry_index = RIDE_ENTRY_INDEX_NULL;
|
||||
w->new_ride.highlighted_ride_id = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry;
|
||||
if (w->new_ride.highlighted_ride_id == -1)
|
||||
w->new_ride.highlighted_ride_id = _windowNewRideListItems[0].ride_type_and_entry;
|
||||
w->new_ride.SelectedRide = { RIDE_TYPE_NULL, RIDE_ENTRY_INDEX_NULL };
|
||||
_lastTrackDesignCountRideType.Type = RIDE_TYPE_NULL;
|
||||
_lastTrackDesignCountRideType.EntryIndex = RIDE_ENTRY_INDEX_NULL;
|
||||
w->new_ride.HighlightedRide = _windowNewRideHighlightedItem[_windowNewRideCurrentTab];
|
||||
if (w->new_ride.HighlightedRide.Type == RIDE_TYPE_NULL)
|
||||
w->new_ride.HighlightedRide = _windowNewRideListItems[0];
|
||||
|
||||
w->width = 1;
|
||||
window_new_ride_refresh_widget_sizing(w);
|
||||
|
@ -523,7 +523,7 @@ rct_window* window_new_ride_open_research()
|
|||
*
|
||||
* rct2: 0x006B3EBA
|
||||
*/
|
||||
void window_new_ride_focus(ride_list_item rideItem)
|
||||
void window_new_ride_focus(RideSelection rideItem)
|
||||
{
|
||||
rct_window* w;
|
||||
rct_ride_entry* rideEntry;
|
||||
|
@ -534,17 +534,17 @@ void window_new_ride_focus(ride_list_item rideItem)
|
|||
if (w == nullptr)
|
||||
return;
|
||||
|
||||
rideEntry = get_ride_entry(rideItem.entry_index);
|
||||
rideEntry = get_ride_entry(rideItem.EntryIndex);
|
||||
uint8_t rideTypeIndex = ride_entry_get_first_non_null_ride_type(rideEntry);
|
||||
|
||||
window_new_ride_set_page(w, RideTypeDescriptors[rideTypeIndex].Category);
|
||||
|
||||
for (ride_list_item* listItem = _windowNewRideListItems; listItem->type != RIDE_TYPE_NULL; listItem++)
|
||||
for (RideSelection* listItem = _windowNewRideListItems; listItem->Type != RIDE_TYPE_NULL; listItem++)
|
||||
{
|
||||
if (listItem->type == rideItem.type && listItem->entry_index == rideItem.entry_index)
|
||||
if (listItem->Type == rideItem.Type && listItem->EntryIndex == rideItem.EntryIndex)
|
||||
{
|
||||
_windowNewRideHighlightedItem[0] = rideItem;
|
||||
w->new_ride.highlighted_ride_id = rideItem.ride_type_and_entry;
|
||||
w->new_ride.HighlightedRide = rideItem;
|
||||
window_new_ride_scroll_to_focused_ride(w);
|
||||
entryFound = true;
|
||||
break;
|
||||
|
@ -557,16 +557,16 @@ void window_new_ride_focus(ride_list_item rideItem)
|
|||
{
|
||||
const RideGroup* rideGroup = RideGroupManager::GetRideGroup(rideTypeIndex, rideEntry);
|
||||
|
||||
for (ride_list_item* listItem = _windowNewRideListItems; listItem->type != RIDE_TYPE_NULL; listItem++)
|
||||
for (RideSelection* listItem = _windowNewRideListItems; listItem->Type != RIDE_TYPE_NULL; listItem++)
|
||||
{
|
||||
if (listItem->type == rideItem.type)
|
||||
if (listItem->Type == rideItem.Type)
|
||||
{
|
||||
const RideGroup* irg = RideGroupManager::GetRideGroup(rideTypeIndex, rideEntry);
|
||||
|
||||
if (!RideTypeDescriptors[rideTypeIndex].HasFlag(RIDE_TYPE_FLAG_HAS_RIDE_GROUPS) || rideGroup->Equals(irg))
|
||||
{
|
||||
_windowNewRideHighlightedItem[0] = rideItem;
|
||||
w->new_ride.highlighted_ride_id = rideItem.ride_type_and_entry;
|
||||
w->new_ride.HighlightedRide = rideItem;
|
||||
window_new_ride_scroll_to_focused_ride(w);
|
||||
break;
|
||||
}
|
||||
|
@ -579,14 +579,14 @@ static void window_new_ride_set_page(rct_window* w, int32_t page)
|
|||
{
|
||||
_windowNewRideCurrentTab = page;
|
||||
w->frame_no = 0;
|
||||
w->new_ride.highlighted_ride_id = -1;
|
||||
w->new_ride.HighlightedRide = { RIDE_TYPE_NULL, RIDE_ENTRY_INDEX_NULL };
|
||||
w->new_ride.selected_ride_countdown = std::numeric_limits<uint16_t>::max();
|
||||
window_new_ride_populate_list();
|
||||
if (page < WINDOW_NEW_RIDE_PAGE_RESEARCH)
|
||||
{
|
||||
w->new_ride.highlighted_ride_id = _windowNewRideHighlightedItem[page].ride_type_and_entry;
|
||||
if (w->new_ride.highlighted_ride_id == -1)
|
||||
w->new_ride.highlighted_ride_id = _windowNewRideListItems[0].ride_type_and_entry;
|
||||
w->new_ride.HighlightedRide = _windowNewRideHighlightedItem[page];
|
||||
if (w->new_ride.HighlightedRide.Type == RIDE_TYPE_NULL)
|
||||
w->new_ride.HighlightedRide = _windowNewRideListItems[0];
|
||||
}
|
||||
|
||||
window_new_ride_refresh_widget_sizing(w);
|
||||
|
@ -737,7 +737,7 @@ static void window_new_ride_update(rct_window* w)
|
|||
|
||||
widget_invalidate(w, WIDX_TAB_1 + _windowNewRideCurrentTab);
|
||||
|
||||
if (w->new_ride.selected_ride_id != -1 && w->new_ride.selected_ride_countdown-- == 0)
|
||||
if (w->new_ride.SelectedRide.Type != RIDE_TYPE_NULL && w->new_ride.selected_ride_countdown-- == 0)
|
||||
window_new_ride_select(w);
|
||||
|
||||
window_new_ride_populate_list();
|
||||
|
@ -750,10 +750,10 @@ static void window_new_ride_update(rct_window* w)
|
|||
*/
|
||||
static void window_new_ride_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
||||
{
|
||||
ride_list_item* listItem = _windowNewRideListItems;
|
||||
RideSelection* listItem = _windowNewRideListItems;
|
||||
|
||||
int32_t count = 0;
|
||||
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != RIDE_ENTRY_INDEX_NULL)
|
||||
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
|
||||
{
|
||||
count++;
|
||||
listItem++;
|
||||
|
@ -767,14 +767,14 @@ static void window_new_ride_scrollgetsize(rct_window* w, int32_t scrollIndex, in
|
|||
*/
|
||||
static void window_new_ride_scrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
ride_list_item item;
|
||||
RideSelection item;
|
||||
|
||||
item = window_new_ride_scroll_get_ride_list_item_at(w, screenCoords);
|
||||
if (item.type == RIDE_TYPE_NULL && item.entry_index == RIDE_ENTRY_INDEX_NULL)
|
||||
if (item.Type == RIDE_TYPE_NULL && item.EntryIndex == RIDE_ENTRY_INDEX_NULL)
|
||||
return;
|
||||
|
||||
_windowNewRideHighlightedItem[_windowNewRideCurrentTab] = item;
|
||||
w->new_ride.selected_ride_id = item.ride_type_and_entry;
|
||||
w->new_ride.SelectedRide = item;
|
||||
|
||||
audio_play_sound(SoundId::Click1, 0, w->windowPos.x + (w->width / 2));
|
||||
w->new_ride.selected_ride_countdown = 8;
|
||||
|
@ -787,17 +787,17 @@ static void window_new_ride_scrollmousedown(rct_window* w, int32_t scrollIndex,
|
|||
*/
|
||||
static void window_new_ride_scrollmouseover(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
ride_list_item item;
|
||||
RideSelection item;
|
||||
|
||||
if (w->new_ride.selected_ride_id != -1)
|
||||
if (w->new_ride.SelectedRide.Type != RIDE_TYPE_NULL)
|
||||
return;
|
||||
|
||||
item = window_new_ride_scroll_get_ride_list_item_at(w, screenCoords);
|
||||
|
||||
if (w->new_ride.highlighted_ride_id == item.ride_type_and_entry)
|
||||
if (w->new_ride.HighlightedRide == item)
|
||||
return;
|
||||
|
||||
w->new_ride.highlighted_ride_id = item.ride_type_and_entry;
|
||||
w->new_ride.HighlightedRide = item;
|
||||
_windowNewRideHighlightedItem[_windowNewRideCurrentTab] = item;
|
||||
w->Invalidate();
|
||||
}
|
||||
|
@ -839,9 +839,9 @@ static void window_new_ride_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
|
||||
if (_windowNewRideCurrentTab != WINDOW_NEW_RIDE_PAGE_RESEARCH)
|
||||
{
|
||||
ride_list_item item;
|
||||
item.ride_type_and_entry = static_cast<uint16_t>(w->new_ride.highlighted_ride_id);
|
||||
if (item.type != RIDE_TYPE_NULL || item.entry_index != RIDE_ENTRY_INDEX_NULL)
|
||||
RideSelection item;
|
||||
item = w->new_ride.HighlightedRide;
|
||||
if (item.Type != RIDE_TYPE_NULL || item.EntryIndex != RIDE_ENTRY_INDEX_NULL)
|
||||
window_new_ride_paint_ride_information(
|
||||
w, dpi, item, w->windowPos.x + 3, w->windowPos.y + w->height - 64, w->width - 6);
|
||||
}
|
||||
|
@ -864,24 +864,24 @@ static void window_new_ride_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
|
|||
|
||||
int32_t x = 1;
|
||||
int32_t y = 1;
|
||||
ride_list_item* listItem = _windowNewRideListItems;
|
||||
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != RIDE_ENTRY_INDEX_NULL)
|
||||
RideSelection* listItem = _windowNewRideListItems;
|
||||
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
|
||||
{
|
||||
rct_ride_entry* rideEntry;
|
||||
// Draw flat button rectangle
|
||||
int32_t flags = 0;
|
||||
if (w->new_ride.selected_ride_id == *(reinterpret_cast<int16_t*>(listItem)))
|
||||
if (w->new_ride.SelectedRide == *listItem)
|
||||
flags |= INSET_RECT_FLAG_BORDER_INSET;
|
||||
if (w->new_ride.highlighted_ride_id == *(reinterpret_cast<int16_t*>(listItem)) || flags != 0)
|
||||
if (w->new_ride.HighlightedRide == *listItem || flags != 0)
|
||||
gfx_fill_rect_inset(dpi, x, y, x + 115, y + 115, w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT | flags);
|
||||
|
||||
// Draw ride image with feathered border
|
||||
rideEntry = get_ride_entry(listItem->entry_index);
|
||||
rideEntry = get_ride_entry(listItem->EntryIndex);
|
||||
int32_t imageId = rideEntry->images_offset;
|
||||
|
||||
for (size_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
||||
{
|
||||
if (rideEntry->ride_type[i] == listItem->type)
|
||||
if (rideEntry->ride_type[i] == listItem->Type)
|
||||
break;
|
||||
else
|
||||
imageId++;
|
||||
|
@ -906,11 +906,11 @@ static void window_new_ride_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
|
|||
*
|
||||
* rct2: 0x006B6D3C
|
||||
*/
|
||||
static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window* w, const ScreenCoordsXY& screenCoords)
|
||||
static RideSelection window_new_ride_scroll_get_ride_list_item_at(rct_window* w, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
ride_list_item result;
|
||||
result.type = RIDE_TYPE_NULL;
|
||||
result.entry_index = RIDE_ENTRY_INDEX_NULL;
|
||||
RideSelection result;
|
||||
result.Type = RIDE_TYPE_NULL;
|
||||
result.EntryIndex = RIDE_ENTRY_INDEX_NULL;
|
||||
|
||||
if (screenCoords.x <= 0 || screenCoords.y <= 0)
|
||||
return result;
|
||||
|
@ -922,8 +922,8 @@ static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window* w
|
|||
|
||||
int32_t index = column + (row * 5);
|
||||
|
||||
ride_list_item* listItem = _windowNewRideListItems;
|
||||
while (listItem->type != RIDE_TYPE_NULL || listItem->entry_index != RIDE_ENTRY_INDEX_NULL)
|
||||
RideSelection* listItem = _windowNewRideListItems;
|
||||
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
|
||||
{
|
||||
if (index-- == 0)
|
||||
return *listItem;
|
||||
|
@ -933,30 +933,30 @@ static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window* w
|
|||
return result;
|
||||
}
|
||||
|
||||
static int32_t get_num_track_designs(ride_list_item item)
|
||||
static int32_t get_num_track_designs(RideSelection item)
|
||||
{
|
||||
std::string entryName;
|
||||
rct_ride_entry* rideEntry = nullptr;
|
||||
|
||||
if (item.type < 0x80)
|
||||
if (item.Type < 0x80)
|
||||
{
|
||||
rideEntry = get_ride_entry(item.entry_index);
|
||||
if (RideTypeDescriptors[item.type].HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
||||
rideEntry = get_ride_entry(item.EntryIndex);
|
||||
if (RideTypeDescriptors[item.Type].HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
||||
{
|
||||
entryName = get_ride_entry_name(item.entry_index);
|
||||
entryName = get_ride_entry_name(item.EntryIndex);
|
||||
}
|
||||
}
|
||||
|
||||
auto repo = OpenRCT2::GetContext()->GetTrackDesignRepository();
|
||||
if (rideEntry != nullptr && RideTypeDescriptors[item.type].HasFlag(RIDE_TYPE_FLAG_HAS_RIDE_GROUPS))
|
||||
if (rideEntry != nullptr && RideTypeDescriptors[item.Type].HasFlag(RIDE_TYPE_FLAG_HAS_RIDE_GROUPS))
|
||||
{
|
||||
auto rideGroup = RideGroupManager::GetRideGroup(item.type, rideEntry);
|
||||
auto rideGroup = RideGroupManager::GetRideGroup(item.Type, rideEntry);
|
||||
if (rideGroup != nullptr)
|
||||
{
|
||||
return static_cast<int32_t>(repo->GetCountForRideGroup(item.type, rideGroup));
|
||||
return static_cast<int32_t>(repo->GetCountForRideGroup(item.Type, rideGroup));
|
||||
}
|
||||
}
|
||||
return static_cast<int32_t>(repo->GetCountForObjectEntry(item.type, entryName));
|
||||
return static_cast<int32_t>(repo->GetCountForObjectEntry(item.Type, entryName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -964,19 +964,19 @@ static int32_t get_num_track_designs(ride_list_item item)
|
|||
* rct2: 0x006B701C
|
||||
*/
|
||||
static void window_new_ride_paint_ride_information(
|
||||
rct_window* w, rct_drawpixelinfo* dpi, ride_list_item item, int32_t x, int32_t y, int32_t width)
|
||||
rct_window* w, rct_drawpixelinfo* dpi, RideSelection item, int32_t x, int32_t y, int32_t width)
|
||||
{
|
||||
rct_ride_entry* rideEntry = get_ride_entry(item.entry_index);
|
||||
rct_ride_entry* rideEntry = get_ride_entry(item.EntryIndex);
|
||||
rct_ride_name rideNaming;
|
||||
|
||||
// Ride name and description
|
||||
rideNaming = get_ride_naming(item.type, rideEntry);
|
||||
rideNaming = get_ride_naming(item.Type, rideEntry);
|
||||
set_format_arg(0, rct_string_id, rideNaming.name);
|
||||
set_format_arg(2, rct_string_id, rideNaming.description);
|
||||
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, width, STR_NEW_RIDE_NAME_AND_DESCRIPTION, COLOUR_BLACK);
|
||||
|
||||
char availabilityString[AVAILABILITY_STRING_SIZE];
|
||||
window_new_ride_list_vehicles_for(item.type, rideEntry, availabilityString, sizeof(availabilityString));
|
||||
window_new_ride_list_vehicles_for(item.Type, rideEntry, availabilityString, sizeof(availabilityString));
|
||||
|
||||
if (availabilityString[0] != 0)
|
||||
{
|
||||
|
@ -984,7 +984,7 @@ static void window_new_ride_paint_ride_information(
|
|||
gfx_draw_string_left_clipped(dpi, STR_AVAILABLE_VEHICLES, &drawString, COLOUR_BLACK, x, y + 39, WW - 2);
|
||||
}
|
||||
|
||||
if (item.type != _lastTrackDesignCountRideType.type || item.entry_index != _lastTrackDesignCountRideType.entry_index)
|
||||
if (item.Type != _lastTrackDesignCountRideType.Type || item.EntryIndex != _lastTrackDesignCountRideType.EntryIndex)
|
||||
{
|
||||
_lastTrackDesignCountRideType = item;
|
||||
_lastTrackDesignCount = get_num_track_designs(item);
|
||||
|
@ -1010,9 +1010,9 @@ static void window_new_ride_paint_ride_information(
|
|||
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
// Get price of ride
|
||||
int32_t unk2 = RideTypeDescriptors[item.type].StartTrackPiece;
|
||||
money32 price = RideTrackCosts[item.type].track_price;
|
||||
if (ride_type_has_flag(item.type, RIDE_TYPE_FLAG_FLAT_RIDE))
|
||||
int32_t unk2 = RideTypeDescriptors[item.Type].StartTrackPiece;
|
||||
money32 price = RideTrackCosts[item.Type].track_price;
|
||||
if (ride_type_has_flag(item.Type, RIDE_TYPE_FLAG_FLAT_RIDE))
|
||||
{
|
||||
price *= FlatRideTrackPricing[unk2];
|
||||
}
|
||||
|
@ -1020,11 +1020,11 @@ static void window_new_ride_paint_ride_information(
|
|||
{
|
||||
price *= TrackPricing[unk2];
|
||||
}
|
||||
price = (price >> 17) * 10 * RideData5[item.type].PriceEstimateMultiplier;
|
||||
price = (price >> 17) * 10 * RideData5[item.Type].PriceEstimateMultiplier;
|
||||
|
||||
//
|
||||
rct_string_id stringId = STR_NEW_RIDE_COST;
|
||||
if (!ride_type_has_flag(item.type, RIDE_TYPE_FLAG_HAS_NO_TRACK))
|
||||
if (!ride_type_has_flag(item.Type, RIDE_TYPE_FLAG_HAS_NO_TRACK))
|
||||
stringId = STR_NEW_RIDE_COST_FROM;
|
||||
|
||||
gfx_draw_string_right(dpi, stringId, &price, COLOUR_BLACK, x + width, y + 51);
|
||||
|
@ -1037,9 +1037,8 @@ static void window_new_ride_paint_ride_information(
|
|||
*/
|
||||
static void window_new_ride_select(rct_window* w)
|
||||
{
|
||||
ride_list_item item;
|
||||
item.ride_type_and_entry = static_cast<uint16_t>(w->new_ride.selected_ride_id);
|
||||
if (item.type == RIDE_TYPE_NULL)
|
||||
RideSelection item = w->new_ride.SelectedRide;
|
||||
if (item.Type == RIDE_TYPE_NULL)
|
||||
return;
|
||||
|
||||
window_close(w);
|
||||
|
@ -1048,8 +1047,8 @@ static void window_new_ride_select(rct_window* w)
|
|||
if (_lastTrackDesignCount > 0)
|
||||
{
|
||||
auto intent = Intent(WC_TRACK_DESIGN_LIST);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_TYPE, item.type);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, item.entry_index);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_TYPE, item.Type);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, item.EntryIndex);
|
||||
context_open_intent(&intent);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -225,8 +225,8 @@ static void window_track_place_mouseup(rct_window* w, rct_widgetindex widgetInde
|
|||
window_close(w);
|
||||
|
||||
auto intent = Intent(WC_TRACK_DESIGN_LIST);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_TYPE, _window_track_list_item.type);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, _window_track_list_item.entry_index);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_TYPE, _window_track_list_item.Type);
|
||||
intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, _window_track_list_item.EntryIndex);
|
||||
context_open_intent(&intent);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ static rct_window_event_list window_track_list_events = {
|
|||
|
||||
constexpr uint16_t TRACK_DESIGN_INDEX_UNLOADED = UINT16_MAX;
|
||||
|
||||
ride_list_item _window_track_list_item;
|
||||
RideSelection _window_track_list_item;
|
||||
|
||||
static std::vector<track_design_file_ref> _trackDesigns;
|
||||
static utf8 _filterString[USER_STRING_MAX_LENGTH];
|
||||
|
@ -108,14 +108,14 @@ static uint16_t _loadedTrackDesignIndex;
|
|||
static std::unique_ptr<TrackDesign> _loadedTrackDesign;
|
||||
static std::vector<uint8_t> _trackDesignPreviewPixels;
|
||||
|
||||
static void track_list_load_designs(ride_list_item item);
|
||||
static void track_list_load_designs(RideSelection item);
|
||||
static bool track_list_load_design_for_preview(utf8* path);
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006CF1A2
|
||||
*/
|
||||
rct_window* window_track_list_open(ride_list_item item)
|
||||
rct_window* window_track_list_open(RideSelection item)
|
||||
{
|
||||
window_close_construction_windows();
|
||||
_window_track_list_item = item;
|
||||
|
@ -445,11 +445,11 @@ static void window_track_list_update(rct_window* w)
|
|||
static void window_track_list_invalidate(rct_window* w)
|
||||
{
|
||||
rct_string_id stringId = STR_NONE;
|
||||
rct_ride_entry* entry = get_ride_entry(_window_track_list_item.entry_index);
|
||||
rct_ride_entry* entry = get_ride_entry(_window_track_list_item.EntryIndex);
|
||||
|
||||
if (entry != nullptr)
|
||||
{
|
||||
rct_ride_name rideName = get_ride_naming(_window_track_list_item.type, entry);
|
||||
rct_ride_name rideName = get_ride_naming(_window_track_list_item.Type, entry);
|
||||
stringId = rideName.name;
|
||||
}
|
||||
|
||||
|
@ -768,32 +768,32 @@ static void window_track_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
|||
}
|
||||
}
|
||||
|
||||
static void track_list_load_designs(ride_list_item item)
|
||||
static void track_list_load_designs(RideSelection item)
|
||||
{
|
||||
auto repo = OpenRCT2::GetContext()->GetTrackDesignRepository();
|
||||
if (RideTypeDescriptors[item.type].HasFlag(RIDE_TYPE_FLAG_HAS_RIDE_GROUPS))
|
||||
if (RideTypeDescriptors[item.Type].HasFlag(RIDE_TYPE_FLAG_HAS_RIDE_GROUPS))
|
||||
{
|
||||
auto rideEntry = get_ride_entry(item.entry_index);
|
||||
auto rideEntry = get_ride_entry(item.EntryIndex);
|
||||
if (rideEntry != nullptr)
|
||||
{
|
||||
auto rideGroup = RideGroupManager::GetRideGroup(item.type, rideEntry);
|
||||
auto rideGroup = RideGroupManager::GetRideGroup(item.Type, rideEntry);
|
||||
if (rideGroup != nullptr)
|
||||
{
|
||||
_trackDesigns = repo->GetItemsForRideGroup(item.type, rideGroup);
|
||||
_trackDesigns = repo->GetItemsForRideGroup(item.Type, rideGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string entryName;
|
||||
if (item.type < 0x80)
|
||||
if (item.Type < 0x80)
|
||||
{
|
||||
if (RideTypeDescriptors[item.type].HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
||||
if (RideTypeDescriptors[item.Type].HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
||||
{
|
||||
entryName = get_ride_entry_name(item.entry_index);
|
||||
entryName = get_ride_entry_name(item.EntryIndex);
|
||||
}
|
||||
}
|
||||
_trackDesigns = repo->GetItemsForObjectEntry(item.type, entryName);
|
||||
_trackDesigns = repo->GetItemsForObjectEntry(item.Type, entryName);
|
||||
}
|
||||
|
||||
window_track_list_filter_list();
|
||||
|
|
|
@ -125,7 +125,7 @@ void window_research_funding_page_paint(rct_window* w, rct_drawpixelinfo* dpi, r
|
|||
rct_window* window_new_ride_open();
|
||||
rct_window* window_new_ride_open_research();
|
||||
void window_new_ride_init_vars();
|
||||
void window_new_ride_focus(ride_list_item rideItem);
|
||||
void window_new_ride_focus(RideSelection rideItem);
|
||||
|
||||
rct_window* window_ride_list_open();
|
||||
void window_ride_list_refresh_list(rct_window* w);
|
||||
|
@ -136,8 +136,8 @@ rct_window* window_ride_open_vehicle(Vehicle* vehicle);
|
|||
void window_ride_measurements_design_cancel();
|
||||
|
||||
// rct2: 0x00F635EE
|
||||
extern ride_list_item _window_track_list_item;
|
||||
rct_window* window_track_list_open(ride_list_item item);
|
||||
extern RideSelection _window_track_list_item;
|
||||
rct_window* window_track_list_open(RideSelection item);
|
||||
|
||||
void window_map_tooltip_update_visibility();
|
||||
|
||||
|
|
|
@ -55,13 +55,13 @@ void park_set_entrance_fee(money32 fee)
|
|||
*
|
||||
* rct2: 0x006B4800
|
||||
*/
|
||||
void ride_construct_new(ride_list_item listItem)
|
||||
void ride_construct_new(RideSelection listItem)
|
||||
{
|
||||
int32_t rideEntryIndex = ride_get_entry_index(listItem.type, listItem.entry_index);
|
||||
int32_t colour1 = ride_get_random_colour_preset_index(listItem.type);
|
||||
int32_t rideEntryIndex = ride_get_entry_index(listItem.Type, listItem.EntryIndex);
|
||||
int32_t colour1 = ride_get_random_colour_preset_index(listItem.Type);
|
||||
int32_t colour2 = ride_get_unused_preset_vehicle_colour(rideEntryIndex);
|
||||
|
||||
auto gameAction = RideCreateAction(listItem.type, listItem.entry_index, colour1, colour2);
|
||||
auto gameAction = RideCreateAction(listItem.Type, listItem.EntryIndex, colour1, colour2);
|
||||
|
||||
gameAction.SetCallback([](const GameAction* ga, const RideCreateGameActionResult* result) {
|
||||
if (result->Error != GA_ERROR::OK)
|
||||
|
|
|
@ -223,8 +223,8 @@ struct campaign_variables
|
|||
|
||||
struct new_ride_variables
|
||||
{
|
||||
int16_t selected_ride_id; // 0x480
|
||||
int16_t highlighted_ride_id; // 0x482
|
||||
RideSelection SelectedRide; // 0x480
|
||||
RideSelection HighlightedRide; // 0x482
|
||||
uint16_t pad_484;
|
||||
uint16_t pad_486;
|
||||
uint16_t selected_ride_countdown; // 488
|
||||
|
|
|
@ -53,24 +53,6 @@ constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP;
|
|||
constexpr const ObjectEntryIndex RIDE_ENTRY_INDEX_NULL = OBJECT_ENTRY_INDEX_NULL;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/**
|
||||
* Couples a ride type and subtype together.
|
||||
*/
|
||||
struct ride_list_item
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t entry_index;
|
||||
};
|
||||
uint16_t ride_type_and_entry;
|
||||
};
|
||||
};
|
||||
assert_struct_size(ride_list_item, 2);
|
||||
|
||||
struct TrackColour
|
||||
{
|
||||
uint8_t main;
|
||||
|
@ -1109,7 +1091,7 @@ void ride_update_satisfaction(Ride* ride, uint8_t happiness);
|
|||
void ride_update_popularity(Ride* ride, uint8_t pop_amount);
|
||||
bool ride_try_get_origin_element(const Ride* ride, CoordsXYE* output);
|
||||
int32_t ride_find_track_gap(const Ride* ride, CoordsXYE* input, CoordsXYE* output);
|
||||
void ride_construct_new(ride_list_item listItem);
|
||||
void ride_construct_new(RideSelection listItem);
|
||||
void ride_construct(Ride* ride);
|
||||
bool ride_modify(CoordsXYE* input);
|
||||
void ride_remove_peeps(Ride* ride);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../object/Object.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
|
@ -17,3 +19,22 @@ struct Ride;
|
|||
|
||||
constexpr const ride_id_t RIDE_ID_NULL = 0xFF; // std::numeric_limits<ride_id_t>::max();
|
||||
constexpr const ride_id_t RideIdNewNull = std::numeric_limits<ride_id_t>::max();
|
||||
|
||||
/**
|
||||
* Couples a ride type and subtype together.
|
||||
*/
|
||||
struct RideSelection
|
||||
{
|
||||
uint8_t Type;
|
||||
ObjectEntryIndex EntryIndex;
|
||||
|
||||
bool operator==(const RideSelection& other) const
|
||||
{
|
||||
return Type == other.Type && EntryIndex == other.EntryIndex;
|
||||
}
|
||||
|
||||
bool operator!=(const RideSelection& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue