mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 19:02:04 -05:00
Make gDropdownItemsChecked and gDropdownItemsDisabled static
This commit is contained in:
parent
b183d82062
commit
8473a40bc4
7 changed files with 54 additions and 36 deletions
|
@ -1207,7 +1207,7 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde
|
|||
goto dropdown_cleanup;
|
||||
}
|
||||
|
||||
if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && gDropdownItemsDisabled & (1ULL << dropdown_index)) {
|
||||
if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index)) {
|
||||
goto dropdown_cleanup;
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1344,7 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde
|
|||
window_tooltip_show(colourTooltips[dropdown_index], x, y);
|
||||
}
|
||||
|
||||
if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && gDropdownItemsDisabled & (1ULL << dropdown_index)) {
|
||||
if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ bool _dropdown_list_vertically;
|
|||
sint32 gDropdownNumItems;
|
||||
rct_string_id gDropdownItemsFormat[DROPDOWN_ITEMS_MAX_SIZE];
|
||||
sint64 gDropdownItemsArgs[DROPDOWN_ITEMS_MAX_SIZE];
|
||||
uint64 gDropdownItemsChecked;
|
||||
uint64 gDropdownItemsDisabled;
|
||||
static uint64 _dropdownItemsChecked;
|
||||
static uint64 _dropdownItemsDisabled;
|
||||
bool gDropdownIsColour;
|
||||
sint32 gDropdownLastColourHover;
|
||||
sint32 gDropdownHighlightedIndex;
|
||||
|
@ -61,29 +61,29 @@ sint32 gDropdownDefaultIndex;
|
|||
|
||||
bool dropdown_is_checked(sint32 index)
|
||||
{
|
||||
return gDropdownItemsChecked & (1ULL << index);
|
||||
return _dropdownItemsChecked & (1ULL << index);
|
||||
}
|
||||
|
||||
bool dropdown_is_disabled(sint32 index)
|
||||
{
|
||||
return gDropdownItemsDisabled & (1ULL << index);
|
||||
return _dropdownItemsDisabled & (1ULL << index);
|
||||
}
|
||||
|
||||
void dropdown_set_checked(sint32 index, bool value)
|
||||
{
|
||||
if (value) {
|
||||
gDropdownItemsChecked |= 1ULL << index;
|
||||
_dropdownItemsChecked |= 1ULL << index;
|
||||
} else {
|
||||
gDropdownItemsChecked &= ~(1ULL << index);
|
||||
_dropdownItemsChecked &= ~(1ULL << index);
|
||||
}
|
||||
}
|
||||
|
||||
void dropdown_set_disabled(sint32 index, bool value)
|
||||
{
|
||||
if (value) {
|
||||
gDropdownItemsDisabled |= 1ULL << index;
|
||||
_dropdownItemsDisabled |= 1ULL << index;
|
||||
} else {
|
||||
gDropdownItemsDisabled &= ~(1ULL << index);
|
||||
_dropdownItemsDisabled &= ~(1ULL << index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,8 +208,8 @@ void window_dropdown_show_text_custom_width(sint32 x, sint32 y, sint32 extray, u
|
|||
|
||||
// Input state
|
||||
gDropdownHighlightedIndex = -1;
|
||||
gDropdownItemsDisabled = 0;
|
||||
gDropdownItemsChecked = 0;
|
||||
_dropdownItemsDisabled = 0;
|
||||
_dropdownItemsChecked = 0;
|
||||
gDropdownIsColour = false;
|
||||
gDropdownDefaultIndex = -1;
|
||||
input_set_state(INPUT_STATE_DROPDOWN_ACTIVE);
|
||||
|
@ -282,8 +282,8 @@ void window_dropdown_show_image(sint32 x, sint32 y, sint32 extray, uint8 colour,
|
|||
|
||||
// Input state
|
||||
gDropdownHighlightedIndex = -1;
|
||||
gDropdownItemsDisabled = 0;
|
||||
gDropdownItemsChecked = 0;
|
||||
_dropdownItemsDisabled = 0;
|
||||
_dropdownItemsChecked = 0;
|
||||
gDropdownIsColour = false;
|
||||
gDropdownDefaultIndex = -1;
|
||||
input_set_state(INPUT_STATE_DROPDOWN_ACTIVE);
|
||||
|
|
|
@ -36,8 +36,6 @@ extern sint32 gAppropriateImageDropdownItemsPerRow[];
|
|||
extern sint32 gDropdownNumItems;
|
||||
extern rct_string_id gDropdownItemsFormat[DROPDOWN_ITEMS_MAX_SIZE];
|
||||
extern sint64 gDropdownItemsArgs[DROPDOWN_ITEMS_MAX_SIZE];
|
||||
extern uint64 gDropdownItemsChecked;
|
||||
extern uint64 gDropdownItemsDisabled;
|
||||
extern bool gDropdownIsColour;
|
||||
extern sint32 gDropdownLastColourHover;
|
||||
extern sint32 gDropdownHighlightedIndex;
|
||||
|
|
|
@ -901,8 +901,6 @@ void window_editor_object_selection_mousedown(rct_window *w, rct_widgetindex wid
|
|||
{
|
||||
sint32 num_items;
|
||||
|
||||
//widget = &w->widgets[widgetIndex - 1];
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_FILTER_DROPDOWN:
|
||||
|
||||
|
@ -935,7 +933,14 @@ void window_editor_object_selection_mousedown(rct_window *w, rct_widgetindex wid
|
|||
num_items
|
||||
);
|
||||
|
||||
gDropdownItemsChecked = _filter_flags & 0xF;
|
||||
for (sint32 i = 0; i < 4; i++)
|
||||
{
|
||||
if (_filter_flags & (1 << i))
|
||||
{
|
||||
dropdown_set_checked(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
|
||||
dropdown_set_checked(DDIX_FILTER_SELECTED, _FILTER_SELECTED);
|
||||
dropdown_set_checked(DDIX_FILTER_NONSELECTED, _FILTER_NONSELECTED);
|
||||
|
|
|
@ -2043,11 +2043,12 @@ static void window_ride_show_view_dropdown(rct_window *w, rct_widget *widget)
|
|||
}
|
||||
|
||||
// Set highlighted item
|
||||
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) {
|
||||
sint32 j = 2;
|
||||
for (sint32 i = 0; i < ride->num_vehicles; i++) {
|
||||
gDropdownItemsDisabled |= j;
|
||||
j <<= 1;
|
||||
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
{
|
||||
for (sint32 i = 0; i < ride->num_vehicles; i++)
|
||||
{
|
||||
// The +1 is to skip 'Overall view'
|
||||
dropdown_set_disabled(i + 1, true);;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3757,7 +3758,7 @@ static void window_ride_maintenance_mousedown(rct_window *w, rct_widgetindex wid
|
|||
}
|
||||
|
||||
if ((ride->lifecycle_flags & RIDE_LIFECYCLE_BREAKDOWN_PENDING) == 0) {
|
||||
gDropdownItemsDisabled = (1 << 0);
|
||||
dropdown_set_disabled(0, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -4140,7 +4141,7 @@ static void window_ride_colour_mousedown(rct_window *w, rct_widgetindex widgetIn
|
|||
vehicle_colour vehicleColour;
|
||||
rct_widget *dropdownWidget;
|
||||
rct_ride_entry *rideEntry;
|
||||
sint32 i, numItems;
|
||||
sint32 i, numItems, checkedIndex;
|
||||
rct_string_id stringId;
|
||||
|
||||
ride = get_ride(w->number);
|
||||
|
@ -4197,16 +4198,15 @@ static void window_ride_colour_mousedown(rct_window *w, rct_widgetindex widgetIn
|
|||
dropdown_set_checked(ride->track_colour_supports[colourSchemeIndex], true);
|
||||
break;
|
||||
case WIDX_ENTRANCE_STYLE_DROPDOWN:
|
||||
gDropdownItemsChecked = 0;
|
||||
checkedIndex = -1;
|
||||
for (i = 0; i < countof(window_ride_entrance_style_list); i++) {
|
||||
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;
|
||||
gDropdownItemsArgs[i] = RideEntranceDefinitions[window_ride_entrance_style_list[i]].string_id;
|
||||
|
||||
if (ride->entrance_style == window_ride_entrance_style_list[i]) {
|
||||
dropdown_set_checked(i, true);
|
||||
checkedIndex = i;
|
||||
}
|
||||
}
|
||||
uint64 checked = gDropdownItemsChecked;
|
||||
|
||||
window_dropdown_show_text_custom_width(
|
||||
w->x + dropdownWidget->left,
|
||||
|
@ -4219,7 +4219,11 @@ static void window_ride_colour_mousedown(rct_window *w, rct_widgetindex widgetIn
|
|||
widget->right - dropdownWidget->left
|
||||
);
|
||||
|
||||
gDropdownItemsChecked = checked;
|
||||
|
||||
if (checkedIndex != -1)
|
||||
{
|
||||
dropdown_set_checked(checkedIndex, true);
|
||||
}
|
||||
break;
|
||||
case WIDX_VEHICLE_COLOUR_SCHEME_DROPDOWN:
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
@ -5066,7 +5070,9 @@ static void window_ride_measurements_mousedown(rct_window *w, rct_widgetindex wi
|
|||
);
|
||||
gDropdownDefaultIndex = 0;
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
||||
gDropdownItemsDisabled |= 2;
|
||||
{
|
||||
dropdown_set_disabled(1, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3578,7 +3578,13 @@ static void window_ride_construction_show_special_track_dropdown(rct_window *w,
|
|||
widget->right - widget->left
|
||||
);
|
||||
|
||||
gDropdownItemsDisabled = _currentDisabledSpecialTrackPieces;
|
||||
for (sint32 i = 0; i < 32; i++)
|
||||
{
|
||||
if (_currentDisabledSpecialTrackPieces & (1 << i))
|
||||
{
|
||||
dropdown_set_disabled(i, true);
|
||||
}
|
||||
}
|
||||
gDropdownDefaultIndex = defaultIndex;
|
||||
}
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ void window_staff_overview_mousedown(rct_window *w, rct_widgetindex widgetIndex,
|
|||
|
||||
// Disable clear patrol area if no area is set.
|
||||
if (!(gStaffModes[peep->staff_id] & 2)) {
|
||||
gDropdownItemsDisabled |= (1ULL << 1);
|
||||
dropdown_set_disabled(1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1285,7 +1285,7 @@ void window_staff_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
|
|||
}
|
||||
|
||||
rct_peep* peep = GET_PEEP(w->number);
|
||||
sint32 itemsChecked = 0;
|
||||
sint32 checkedIndex = -1;
|
||||
//This will be moved below where Items Checked is when all
|
||||
//of dropdown related functions are finished. This prevents
|
||||
//the dropdown from not working on first click.
|
||||
|
@ -1293,7 +1293,7 @@ void window_staff_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
|
|||
for (sint32 i = 0; i < numCostumes; i++) {
|
||||
uint8 costume = _availableCostumes[i];
|
||||
if (costume == peep->sprite_type) {
|
||||
itemsChecked = 1 << i;
|
||||
checkedIndex = i;
|
||||
}
|
||||
gDropdownItemsArgs[i] = StaffCostumeNames[costume];
|
||||
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;
|
||||
|
@ -1309,7 +1309,10 @@ void window_staff_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
|
|||
window_dropdown_show_text_custom_width(x, y, extray, w->colours[1], 0, DROPDOWN_FLAG_STAY_OPEN, numCostumes, width);
|
||||
|
||||
// See above note.
|
||||
gDropdownItemsChecked = itemsChecked;
|
||||
if (checkedIndex != -1)
|
||||
{
|
||||
dropdown_set_checked(checkedIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue