1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

implement dropdown behaviour for window ride

This commit is contained in:
IntelOrca
2014-09-01 14:06:21 +01:00
parent 17c4e4937a
commit 1647100b1a
4 changed files with 66 additions and 8 deletions

View File

@@ -258,6 +258,12 @@ enum {
STR_OVERALL_VIEW = 996,
STR_VIEW_SELECTION = 997,
STR_CANT_OPEN = 1002,
STR_CANT_TEST = 1003,
STR_CANT_CLOSE = 1004,
STR_CANT_START_CONSTRUCTION_ON = 1005,
STR_MUST_BE_CLOSED_FIRST = 1006,
STR_UNABLE_TO_CREATE_ENOUGH_VEHICLES = 1007,
STR_OPEN_CLOSE_OR_TEST_RIDE = 1008,
STR_OPEN_OR_CLOSE_ALL_RIDES = 1009,
STR_OPEN_OR_CLOSE_PARK_TIP = 1010,

View File

@@ -44,13 +44,13 @@ static rct_widget window_dropdown_widgets[] = {
{ WIDGETS_END },
};
int _dropdown_num_items;
int _dropdown_num_columns;
int _dropdown_num_rows;
int _dropdown_item_width;
int _dropdown_item_height;
int _dropdown_highlighted_index;
int gDropdownNumItems;
uint16 gDropdownItemsFormat[64];
sint64 gDropdownItemsArgs[64];
// Replaces 0x009DED38
@@ -149,7 +149,7 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo
_dropdown_item_height = flags & 0x3F;
// Set the widgets
_dropdown_num_items = num_items;
gDropdownNumItems = num_items;
_dropdown_num_rows = num_items;
window_dropdown_widgets[WIDX_BACKGROUND].bottom = _dropdown_item_height * num_items + 3;
window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;
@@ -175,7 +175,7 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = INPUT_STATE_DROPDOWN_ACTIVE;
// Copy the following properties until all use of it is decompiled
RCT2_GLOBAL(0x009DEBA0, sint16) = _dropdown_num_items;
RCT2_GLOBAL(0x009DEBA0, sint16) = gDropdownNumItems;
RCT2_GLOBAL(0x009DED44, sint32) = _dropdown_num_columns;
RCT2_GLOBAL(0x009DED48, sint32) = _dropdown_num_rows;
RCT2_GLOBAL(0x009DED40, sint32) = _dropdown_item_width;
@@ -216,10 +216,10 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl
// Set and calculate num items, rows and columns
_dropdown_item_width = itemWidth;
_dropdown_item_height = itemHeight;
_dropdown_num_items = numItems;
gDropdownNumItems = numItems;
_dropdown_num_columns = numColumns;
_dropdown_num_rows = _dropdown_num_items / _dropdown_num_columns;
if (_dropdown_num_items % _dropdown_num_columns != 0)
_dropdown_num_rows = gDropdownNumItems / _dropdown_num_columns;
if (gDropdownNumItems % _dropdown_num_columns != 0)
_dropdown_num_rows++;
// Calculate position and size
@@ -253,7 +253,7 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = INPUT_STATE_DROPDOWN_ACTIVE;
// Copy the following properties until all use of it is decompiled
RCT2_GLOBAL(0x009DEBA0, sint16) = _dropdown_num_items;
RCT2_GLOBAL(0x009DEBA0, sint16) = gDropdownNumItems;
RCT2_GLOBAL(0x009DED44, sint32) = _dropdown_num_columns;
RCT2_GLOBAL(0x009DED48, sint32) = _dropdown_num_rows;
RCT2_GLOBAL(0x009DED40, sint32) = _dropdown_item_width;
@@ -278,7 +278,7 @@ static void window_dropdown_paint()
_dropdown_highlighted_index = RCT2_GLOBAL(0x009DEBA2, sint16);
{
int i, cell_x, cell_y, l, t, r, b, item, image, colour;
for (i = 0; i < _dropdown_num_items; i++) {
for (i = 0; i < gDropdownNumItems; i++) {
cell_x = i % _dropdown_num_columns;
cell_y = i / _dropdown_num_columns;

View File

@@ -27,6 +27,7 @@
extern int gAppropriateImageDropdownItemsPerRow[];
extern int gDropdownNumItems;
extern uint16 gDropdownItemsFormat[64];
extern sint64 gDropdownItemsArgs[64];
extern uint32 gDropdownItemsChecked;

View File

@@ -718,7 +718,58 @@ static void window_ride_main_mousedown(int widgetIndex, rct_window *w, rct_widge
*/
static void window_ride_main_dropdown()
{
rct_ride *ride;
rct_window *w;
int status;
short widgetIndex, dropdownIndex;
window_dropdown_get_registers(w, widgetIndex, dropdownIndex);
switch (widgetIndex) {
case WIDX_VIEW_DROPDOWN:
if (dropdownIndex == -1) {
dropdownIndex = w->ride.var_480;
ride = GET_RIDE(w->number);
dropdownIndex++;
if (dropdownIndex != 0 && dropdownIndex <= ride->var_0C8 && !(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
dropdownIndex = ride->var_0C8 + 1;
if (dropdownIndex >= gDropdownNumItems)
dropdownIndex = 0;
}
w->ride.var_480 = dropdownIndex;
RCT2_CALLPROC_X(0x006AF994, 0, 0, 0, 0, (int)w, 0, 0);
window_invalidate(w);
break;
case WIDX_OPEN:
if (dropdownIndex == -1)
dropdownIndex = RCT2_GLOBAL(0x009DEBA2, sint16);
ride = GET_RIDE(w->number);
if ((RCT2_GLOBAL(0x0097CF40 + (ride->type * 8), uint32) & 0x800) && dropdownIndex != 0)
dropdownIndex++;
switch (dropdownIndex) {
case 0:
status = RIDE_STATUS_CLOSED;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = 1004;
break;
case 1:
status = RIDE_STATUS_TESTING;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = 1003;
break;
case 2:
status = RIDE_STATUS_OPEN;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = 1002;
break;
}
RCT2_GLOBAL(0x013CE952 + 6, uint16) = ride->overall_view;
RCT2_GLOBAL(0x013CE952 + 8, uint32) = ride->var_04C;
game_do_command(0, 1, 0, w->number | (status << 8), GAME_COMMAND_SET_RIDE_OPEN, 0, 0);
break;
}
}
/**