Skip to content

Commit

Permalink
Improve maze construction window UX in entrance/exit mode
Browse files Browse the repository at this point in the history
- Arrows are disabled when entrance and exit are being placed
- Clicking a construction mode will disable the entrance and exit mode
- Previous state restored when leaving entrance/exit construction mode
- Fix entrance/exit buttons not changing when the mode switches after placing the first entrance/exit
  • Loading branch information
Simon Jarrett authored and mwnciau committed Oct 6, 2020
1 parent 88e59ee commit f137035
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Expand Up @@ -15,6 +15,7 @@
- Fix: [#13044] Rides in RCT1 saves all have "0 customers per hour".
- Fix: [#13074] Entrance and exit ghosts for mazes not being removed.
- Improved: [#13023] Made add_news_item console command last argument, assoc, optional.
- Improved: [#13098] Improvements to the maze construction window user interface

0.3.1 (2020-09-27)
------------------------------------------------------------------------
Expand Down
64 changes: 47 additions & 17 deletions src/openrct2-ui/windows/MazeConstruction.cpp
Expand Up @@ -186,11 +186,12 @@ static void window_maze_construction_entrance_mouseup(rct_window* w, rct_widgeti

ride_construction_invalidate_current_track();

// ???
uint8_t old_state = _rideConstructionState;
if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT)
{
gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState;
}
_rideConstructionState = RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT;
if (old_state != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT)
_rideConstructionState = old_state;

window_maze_construction_update_pressed_widgets();
}

Expand Down Expand Up @@ -232,6 +233,11 @@ static void window_maze_construction_resize(rct_window* w)
| (1ULL << WIDX_MAZE_DIRECTION_NW) | (1ULL << WIDX_MAZE_DIRECTION_NE) | (1ULL << WIDX_MAZE_DIRECTION_SW)
| (1ULL << WIDX_MAZE_DIRECTION_SE));
}
else if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT)
{
disabledWidgets = (1ULL << WIDX_MAZE_DIRECTION_NW) | (1ULL << WIDX_MAZE_DIRECTION_NE) | (1ULL << WIDX_MAZE_DIRECTION_SW)
| (1ULL << WIDX_MAZE_DIRECTION_SE);
}

// Set and invalidate the changed widgets
uint64_t currentDisabledWidgets = w->disabled_widgets;
Expand All @@ -248,6 +254,16 @@ static void window_maze_construction_resize(rct_window* w)
w->disabled_widgets = disabledWidgets;
}

static void window_maze_construction_build_mode_mousedown(uint8_t rideConstructionState)
{
if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT)
{
tool_cancel();
}
_rideConstructionState = rideConstructionState;
window_maze_construction_update_pressed_widgets();
}

/**
*
* rct2: 0x006CD48C
Expand All @@ -257,16 +273,13 @@ static void window_maze_construction_mousedown(rct_window* w, rct_widgetindex wi
switch (widgetIndex)
{
case WIDX_MAZE_BUILD_MODE:
_rideConstructionState = RIDE_CONSTRUCTION_STATE_MAZE_BUILD;
window_maze_construction_update_pressed_widgets();
window_maze_construction_build_mode_mousedown(RIDE_CONSTRUCTION_STATE_MAZE_BUILD);
break;
case WIDX_MAZE_MOVE_MODE:
_rideConstructionState = RIDE_CONSTRUCTION_STATE_MAZE_MOVE;
window_maze_construction_update_pressed_widgets();
window_maze_construction_build_mode_mousedown(RIDE_CONSTRUCTION_STATE_MAZE_MOVE);
break;
case WIDX_MAZE_FILL_MODE:
_rideConstructionState = RIDE_CONSTRUCTION_STATE_MAZE_FILL;
window_maze_construction_update_pressed_widgets();
window_maze_construction_build_mode_mousedown(RIDE_CONSTRUCTION_STATE_MAZE_FILL);
break;
}
}
Expand Down Expand Up @@ -377,7 +390,10 @@ static void window_maze_construction_entrance_tooldown(const ScreenCoordsXY& scr
{
gRideEntranceExitPlaceType = gRideEntranceExitPlaceType ^ 1;
window_invalidate_by_class(WC_RIDE_CONSTRUCTION);
gCurrentToolWidget.widget_index = gRideEntranceExitPlaceType ? WIDX_MAZE_ENTRANCE : WIDX_MAZE_EXIT;
gCurrentToolWidget.widget_index = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) ? WIDX_MAZE_ENTRANCE
: WIDX_MAZE_EXIT;

window_maze_construction_update_pressed_widgets();
}
});
auto res = GameActions::Execute(&rideEntranceExitPlaceAction);
Expand Down Expand Up @@ -443,20 +459,34 @@ void window_maze_construction_update_pressed_widgets()
return;

uint64_t pressedWidgets = w->pressed_widgets;
pressedWidgets &= ~(1ULL << WIDX_MAZE_BUILD_MODE);
pressedWidgets &= ~(1ULL << WIDX_MAZE_MOVE_MODE);
pressedWidgets &= ~(1ULL << WIDX_MAZE_FILL_MODE);

// Unpress all the mode buttons
pressedWidgets &= ~EnumToFlag(WIDX_MAZE_BUILD_MODE);
pressedWidgets &= ~EnumToFlag(WIDX_MAZE_MOVE_MODE);
pressedWidgets &= ~EnumToFlag(WIDX_MAZE_FILL_MODE);
pressedWidgets &= ~EnumToFlag(WIDX_MAZE_ENTRANCE);
pressedWidgets &= ~EnumToFlag(WIDX_MAZE_EXIT);

switch (_rideConstructionState)
{
case RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT:
if (gCurrentToolWidget.widget_index == WIDX_MAZE_ENTRANCE)
{
pressedWidgets |= EnumToFlag(WIDX_MAZE_ENTRANCE);
}
else
{
pressedWidgets |= EnumToFlag(WIDX_MAZE_EXIT);
}
break;
case RIDE_CONSTRUCTION_STATE_MAZE_BUILD:
pressedWidgets |= (1ULL << WIDX_MAZE_BUILD_MODE);
pressedWidgets |= EnumToFlag(WIDX_MAZE_BUILD_MODE);
break;
case RIDE_CONSTRUCTION_STATE_MAZE_MOVE:
pressedWidgets |= (1ULL << WIDX_MAZE_MOVE_MODE);
pressedWidgets |= EnumToFlag(WIDX_MAZE_MOVE_MODE);
break;
case RIDE_CONSTRUCTION_STATE_MAZE_FILL:
pressedWidgets |= (1ULL << WIDX_MAZE_FILL_MODE);
pressedWidgets |= EnumToFlag(WIDX_MAZE_FILL_MODE);
break;
}

Expand Down

0 comments on commit f137035

Please sign in to comment.