Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrance/exit construction state fixes in ride and maze construction #13098

Merged
merged 2 commits into from Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions distribution/changelog.txt
Expand Up @@ -5,6 +5,7 @@
- Feature: [#13000] objective_options command for console.
- Feature: [#13096] Add Esperanto translation.
- Change: [#9568] Change lift sounds of Reverser Roller Coaster and Compact Inverted Coaster to better fitting ones.
- Fix: [#1324] Last track piece map selection still visible when placing ride entrance or exit (original bug).
- Fix: [#3200] Close Construction window upon selecting vehicle page.
- Fix: [#4041] Garbled park option on scenario editor with custom theme.
- Fix: [#5904] Empty errors on tile inspector base height change.
Expand All @@ -19,10 +20,13 @@
- Fix: [#13044] Rides in RCT1 saves all have "0 customers per hour".
- Fix: [#13074] Entrance and exit ghosts for mazes not being removed.
- Fix: [#13083] Dialog for renaming conflicting track design crops text out.
- Fix: [#13098] UI buttons for entrance and exit don't toggle according to them being built.
- Fix: [#13098] Maze can still be constructed while placing entrance and exit (original bug).
- Fix: [#13118] Closing construction window resets ride viewport.
- Fix: [#13129] Missing error message when waiting for train to leave station on the ride measurements graph.
- Fix: [#13138] Fix logical sorting of list windows.
- Improved: [#13023] Made add_news_item console command last argument, assoc, optional.
- Improved: [#13098] Improvements to the maze construction window user interface
- Improved: [#13125] Selecting the RCT2 files now uses localised dialogs.

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)
mwnciau marked this conversation as resolved.
Show resolved Hide resolved
{
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
3 changes: 3 additions & 0 deletions src/openrct2-ui/windows/RideConstruction.cpp
Expand Up @@ -2659,6 +2659,9 @@ static void window_ride_construction_update_map_selection()
trackType = _currentTrackPieceType;
trackPos = _currentTrackBegin;
break;
case RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT:
gMapSelectionTiles.clear();
return;
default:
if (window_ride_construction_update_state(&trackType, &trackDirection, nullptr, nullptr, &trackPos, nullptr))
{
Expand Down