Skip to content

Commit

Permalink
Create buttons for vertical drops in construction window
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast committed Jan 22, 2025
1 parent b9486b9 commit 4eb97f3
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/openrct2-ui/windows/MazeConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ namespace OpenRCT2::Ui::Windows
WIDX_MAZE_BUILD_MODE = 6,
WIDX_MAZE_MOVE_MODE,
WIDX_MAZE_FILL_MODE,
WIDX_MAZE_DIRECTION_GROUPBOX = 25,
WIDX_MAZE_DIRECTION_GROUPBOX = 27,
WIDX_MAZE_DIRECTION_NW,
WIDX_MAZE_DIRECTION_NE,
WIDX_MAZE_DIRECTION_SW,
WIDX_MAZE_DIRECTION_SE,
WIDX_MAZE_ENTRANCE = 30,
WIDX_MAZE_ENTRANCE = 32,
WIDX_MAZE_EXIT,
};

Expand Down
144 changes: 61 additions & 83 deletions src/openrct2-ui/windows/RideConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
constexpr int8_t kDefaultSpeedIncrement = 2;
constexpr int8_t kDefaultMinimumSpeed = 2;

constexpr uint8_t kVerticalDropButtonStart = 6;

using namespace OpenRCT2::Numerics;
using namespace OpenRCT2::TrackMetaData;

Expand Down Expand Up @@ -105,11 +107,13 @@ namespace OpenRCT2::Ui::Windows
WIDX_RIGHT_CURVE_SMALL,
WIDX_RIGHT_CURVE_VERY_SMALL,
WIDX_SPECIAL_TRACK_DROPDOWN,
WIDX_SLOPE_DOWN_VERTICAL,
WIDX_SLOPE_DOWN_STEEP,
WIDX_SLOPE_DOWN,
WIDX_LEVEL,
WIDX_SLOPE_UP,
WIDX_SLOPE_UP_STEEP,
WIDX_SLOPE_UP_VERTICAL,
WIDX_CHAIN_LIFT,
WIDX_BANK_LEFT,
WIDX_BANK_STRAIGHT,
Expand Down Expand Up @@ -156,11 +160,13 @@ namespace OpenRCT2::Ui::Windows
MakeWidget ({160, 29}, { 22, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_G2_ICON_MEDIUM_CURVE_RIGHT), STR_RIDE_CONSTRUCTION_RIGHT_CURVE_SMALL_TIP ),
MakeWidget ({182, 29}, { 22, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_RIGHT_CURVE_SMALL), STR_RIDE_CONSTRUCTION_RIGHT_CURVE_VERY_SMALL_TIP ),
MakeWidget ({ 6, 55}, { GW - 6, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_YELLOW_STRING, STR_RIDE_CONSTRUCTION_OTHER_TRACK_CONFIGURATIONS_TIP),
MakeWidget ({ 45, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_DOWN_STEEP), STR_RIDE_CONSTRUCTION_STEEP_SLOPE_DOWN_TIP ),
MakeWidget ({ 69, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_DOWN), STR_RIDE_CONSTRUCTION_SLOPE_DOWN_TIP ),
MakeWidget ({ 93, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_LEVEL), STR_RIDE_CONSTRUCTION_LEVEL_TIP ),
MakeWidget ({117, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP), STR_RIDE_CONSTRUCTION_SLOPE_UP_TIP ),
MakeWidget ({141, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP_STEEP), STR_RIDE_CONSTRUCTION_STEEP_SLOPE_UP_TIP ),
MakeWidget ({ 6, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_VERTICAL_DROP), STR_RIDE_CONSTRUCTION_VERTICAL_DROP_TIP ),
MakeWidget ({ 30, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_DOWN_STEEP), STR_RIDE_CONSTRUCTION_STEEP_SLOPE_DOWN_TIP ),
MakeWidget ({ 54, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_DOWN), STR_RIDE_CONSTRUCTION_SLOPE_DOWN_TIP ),
MakeWidget ({ 78, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_LEVEL), STR_RIDE_CONSTRUCTION_LEVEL_TIP ),
MakeWidget ({102, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP), STR_RIDE_CONSTRUCTION_SLOPE_UP_TIP ),
MakeWidget ({126, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP_STEEP), STR_RIDE_CONSTRUCTION_STEEP_SLOPE_UP_TIP ),
MakeWidget ({150, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_VERTICAL_RISE), STR_RIDE_CONSTRUCTION_VERTICAL_RISE_TIP ),
MakeWidget ({178, 88}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_CHAIN_LIFT), STR_RIDE_CONSTRUCTION_CHAIN_LIFT_TIP ),
MakeWidget ({ 69, 132}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_LEFT_BANK), STR_RIDE_CONSTRUCTION_ROLL_FOR_LEFT_CURVE_TIP ),
MakeWidget ({ 93, 132}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_RIDE_CONSTRUCTION_NO_BANK), STR_RIDE_CONSTRUCTION_NO_ROLL_TIP ),
Expand Down Expand Up @@ -562,8 +568,12 @@ namespace OpenRCT2::Ui::Windows
}
break;
case TrackPitch::Down90:
disabledWidgets |= (1uLL << WIDX_SLOPE_DOWN) | (1uLL << WIDX_LEVEL) | (1uLL << WIDX_SLOPE_UP)
| (1uLL << WIDX_SLOPE_UP_STEEP);
break;
case TrackPitch::Up90:
disabledWidgets |= (1uLL << WIDX_SLOPE_DOWN) | (1uLL << WIDX_LEVEL) | (1uLL << WIDX_SLOPE_UP);
disabledWidgets |= (1uLL << WIDX_SLOPE_DOWN_STEEP) | (1uLL << WIDX_SLOPE_DOWN) | (1uLL << WIDX_LEVEL)
| (1uLL << WIDX_SLOPE_UP);
break;
}
if (_previousTrackPitchEnd == TrackPitch::None)
Expand All @@ -578,15 +588,15 @@ namespace OpenRCT2::Ui::Windows
{
if (_previousTrackPitchEnd == TrackPitch::Up60 && _currentTrackPieceDirection < 4)
{
disabledWidgets &= ~(1uLL << WIDX_SLOPE_DOWN_STEEP);
disabledWidgets &= ~(1uLL << WIDX_SLOPE_UP_VERTICAL);
}
if (_previousTrackPitchEnd == TrackPitch::Up90)
{
disabledWidgets &= ~(1uLL << WIDX_SLOPE_DOWN_STEEP);
disabledWidgets &= ~(1uLL << WIDX_SLOPE_UP_VERTICAL);
}
if (_previousTrackPitchEnd == TrackPitch::Down60 && _currentTrackPieceDirection < 4)
{
disabledWidgets &= ~(1uLL << WIDX_SLOPE_UP_STEEP);
disabledWidgets &= ~(1uLL << WIDX_SLOPE_DOWN_VERTICAL);
}
}
if (_previousTrackRollEnd == TrackRoll::Left)
Expand Down Expand Up @@ -786,7 +796,8 @@ namespace OpenRCT2::Ui::Windows
{
disabledWidgets |= (1uLL << WIDX_SLOPE_UP_STEEP);
}
disabledWidgets |= (1uLL << WIDX_LEFT_CURVE_LARGE) | (1uLL << WIDX_RIGHT_CURVE_LARGE);
disabledWidgets |= (1uLL << WIDX_LEFT_CURVE_LARGE) | (1uLL << WIDX_RIGHT_CURVE_LARGE)
| (1uLL << WIDX_SLOPE_DOWN_STEEP);
if (currentRide->GetRideTypeDescriptor().SupportsTrackGroup(TrackGroup::reverseFreefall))
{
disabledWidgets |= (1uLL << WIDX_STRAIGHT) | (1uLL << WIDX_RIGHT_CURVE) | (1uLL << WIDX_RIGHT_CURVE_SMALL)
Expand All @@ -799,7 +810,8 @@ namespace OpenRCT2::Ui::Windows
{
disabledWidgets |= (1uLL << WIDX_SLOPE_DOWN_STEEP);
}
disabledWidgets |= (1uLL << WIDX_LEFT_CURVE_LARGE) | (1uLL << WIDX_RIGHT_CURVE_LARGE);
disabledWidgets |= (1uLL << WIDX_LEFT_CURVE_LARGE) | (1uLL << WIDX_RIGHT_CURVE_LARGE)
| (1uLL << WIDX_SLOPE_UP_STEEP);
if (currentRide->GetRideTypeDescriptor().SupportsTrackGroup(TrackGroup::reverseFreefall))
{
disabledWidgets |= (1uLL << WIDX_STRAIGHT) | (1uLL << WIDX_RIGHT_CURVE) | (1uLL << WIDX_RIGHT_CURVE_SMALL)
Expand Down Expand Up @@ -1120,6 +1132,10 @@ namespace OpenRCT2::Ui::Windows
_currentTrackPrice = kMoney64Undefined;
WindowRideConstructionUpdateActiveElements();
break;
case WIDX_SLOPE_DOWN_VERTICAL:
RideConstructionInvalidateCurrentTrack();
UpdateLiftHillSelected(TrackPitch::Down90);
break;
case WIDX_SLOPE_DOWN_STEEP:
RideConstructionInvalidateCurrentTrack();
if (IsTrackEnabled(TrackGroup::helixDownBankedHalf) || IsTrackEnabled(TrackGroup::helixUpBankedHalf))
Expand Down Expand Up @@ -1191,14 +1207,8 @@ namespace OpenRCT2::Ui::Windows
}
}
}
if (widgets[WIDX_SLOPE_DOWN_STEEP].tooltip == STR_RIDE_CONSTRUCTION_STEEP_SLOPE_DOWN_TIP)
{
UpdateLiftHillSelected(TrackPitch::Down60);
}
else
{
UpdateLiftHillSelected(TrackPitch::Up90);
}

UpdateLiftHillSelected(TrackPitch::Down60);
break;
case WIDX_SLOPE_DOWN:
RideConstructionInvalidateCurrentTrack();
Expand Down Expand Up @@ -1326,14 +1336,12 @@ namespace OpenRCT2::Ui::Windows
}
}
}
if (widgets[WIDX_SLOPE_UP_STEEP].tooltip == STR_RIDE_CONSTRUCTION_STEEP_SLOPE_UP_TIP)
{
UpdateLiftHillSelected(TrackPitch::Up60);
}
else
{
UpdateLiftHillSelected(TrackPitch::Down90);
}

UpdateLiftHillSelected(TrackPitch::Up60);
break;
case WIDX_SLOPE_UP_VERTICAL:
RideConstructionInvalidateCurrentTrack();
UpdateLiftHillSelected(TrackPitch::Up90);
break;
case WIDX_CHAIN_LIFT:
RideConstructionInvalidateCurrentTrack();
Expand Down Expand Up @@ -1799,47 +1807,25 @@ namespace OpenRCT2::Ui::Windows
widgets[WIDX_CHAIN_LIFT].type = WindowWidgetType::Empty;
}

int32_t x = 45;
for (int32_t i = WIDX_SLOPE_DOWN_STEEP; i <= WIDX_SLOPE_UP_STEEP; i++)
int32_t x = kVerticalDropButtonStart;
for (int32_t i = WIDX_SLOPE_DOWN_VERTICAL; i <= WIDX_SLOPE_UP_VERTICAL; i++)
{
widgets[i].left = x;
widgets[i].right = x + 23;
widgets[i].moveToX(x);
x += 24;
}

widgets[WIDX_SLOPE_UP_STEEP].image = ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP_STEEP);
widgets[WIDX_SLOPE_UP_STEEP].tooltip = STR_RIDE_CONSTRUCTION_STEEP_SLOPE_UP_TIP;
widgets[WIDX_SLOPE_DOWN_STEEP].image = ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_DOWN_STEEP);
widgets[WIDX_SLOPE_DOWN_STEEP].tooltip = STR_RIDE_CONSTRUCTION_STEEP_SLOPE_DOWN_TIP;
if (IsTrackEnabled(TrackGroup::slopeVertical))
widgets[WIDX_SLOPE_DOWN_VERTICAL].type = WindowWidgetType::Empty;
widgets[WIDX_SLOPE_UP_VERTICAL].type = WindowWidgetType::Empty;

if (IsTrackEnabled(TrackGroup::slopeVertical) && !TrackPieceDirectionIsDiagonal(_currentTrackPieceDirection))
{
if (_previousTrackPitchEnd == TrackPitch::Up60 || _previousTrackPitchEnd == TrackPitch::Up90)
{
int32_t originalSlopeUpSteepLeft = widgets[WIDX_SLOPE_UP_STEEP].left;
int32_t originalSlopeUpSteepRight = widgets[WIDX_SLOPE_UP_STEEP].right;
for (int32_t i = WIDX_SLOPE_UP_STEEP; i > WIDX_SLOPE_DOWN_STEEP; i--)
{
widgets[i].left = widgets[i - 1].left;
widgets[i].right = widgets[i - 1].right;
}
widgets[WIDX_SLOPE_DOWN_STEEP].left = originalSlopeUpSteepLeft;
widgets[WIDX_SLOPE_DOWN_STEEP].right = originalSlopeUpSteepRight;
widgets[WIDX_SLOPE_DOWN_STEEP].image = ImageId(SPR_RIDE_CONSTRUCTION_VERTICAL_RISE);
widgets[WIDX_SLOPE_DOWN_STEEP].tooltip = STR_RIDE_CONSTRUCTION_VERTICAL_RISE_TIP;
widgets[WIDX_SLOPE_UP_VERTICAL].type = WindowWidgetType::FlatBtn;
}
else if (_previousTrackPitchEnd == TrackPitch::Down60 || _previousTrackPitchEnd == TrackPitch::Down90)
{
int32_t originalSlopeDownSteepLeft = widgets[WIDX_SLOPE_DOWN_STEEP].left;
int32_t originalSlopeDownSteepRight = widgets[WIDX_SLOPE_DOWN_STEEP].right;
for (int32_t i = WIDX_SLOPE_DOWN_STEEP; i < WIDX_SLOPE_UP_STEEP; i++)
{
widgets[i].left = widgets[i + 1].left;
widgets[i].right = widgets[i + 1].right;
}
widgets[WIDX_SLOPE_UP_STEEP].left = originalSlopeDownSteepLeft;
widgets[WIDX_SLOPE_UP_STEEP].right = originalSlopeDownSteepRight;
widgets[WIDX_SLOPE_UP_STEEP].image = ImageId(SPR_RIDE_CONSTRUCTION_VERTICAL_DROP);
widgets[WIDX_SLOPE_UP_STEEP].tooltip = STR_RIDE_CONSTRUCTION_VERTICAL_DROP_TIP;
widgets[WIDX_SLOPE_DOWN_VERTICAL].type = WindowWidgetType::FlatBtn;
}
}

Expand Down Expand Up @@ -2106,8 +2092,10 @@ namespace OpenRCT2::Ui::Windows

switch (_currentTrackPitchEnd)
{
case TrackPitch::Down90:
widgetIndex = WIDX_SLOPE_DOWN_VERTICAL;
break;
case TrackPitch::Down60:
case TrackPitch::Up90:
widgetIndex = WIDX_SLOPE_DOWN_STEEP;
break;
case TrackPitch::Down25:
Expand All @@ -2117,9 +2105,11 @@ namespace OpenRCT2::Ui::Windows
widgetIndex = WIDX_SLOPE_UP;
break;
case TrackPitch::Up60:
case TrackPitch::Down90:
widgetIndex = WIDX_SLOPE_UP_STEEP;
break;
case TrackPitch::Up90:
widgetIndex = WIDX_SLOPE_UP_VERTICAL;
break;
default:
widgetIndex = WIDX_LEVEL;
break;
Expand Down Expand Up @@ -4281,11 +4271,10 @@ namespace OpenRCT2::Ui::Windows
switch (_currentTrackPitchEnd)
{
case TrackPitch::Down60:
if (IsTrackEnabled(TrackGroup::slopeVertical) && !WidgetIsDisabled(*w, WIDX_SLOPE_UP_STEEP)
&& w->widgets[WIDX_SLOPE_UP_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_DROP
&& w->widgets[WIDX_SLOPE_UP_STEEP].type != WindowWidgetType::Empty)
if (IsTrackEnabled(TrackGroup::slopeVertical) && !WidgetIsDisabled(*w, WIDX_SLOPE_DOWN_VERTICAL)
&& w->widgets[WIDX_SLOPE_DOWN_VERTICAL].type != WindowWidgetType::Empty)
{
w->OnMouseDown(WIDX_SLOPE_UP_STEEP);
w->OnMouseDown(WIDX_SLOPE_DOWN_VERTICAL);
}
break;
case TrackPitch::Down25:
Expand All @@ -4300,9 +4289,7 @@ namespace OpenRCT2::Ui::Windows
{
w->OnMouseDown(WIDX_SLOPE_DOWN);
}
else if (
IsTrackEnabled(TrackGroup::slopeVertical)
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_RISE)
else if (IsTrackEnabled(TrackGroup::slopeVertical))
{
return;
}
Expand Down Expand Up @@ -4350,9 +4337,7 @@ namespace OpenRCT2::Ui::Windows
{
w->OnMouseDown(WIDX_SLOPE_DOWN);
}
else if (
IsTrackEnabled(TrackGroup::slopeVertical)
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_RISE)
else if (IsTrackEnabled(TrackGroup::slopeVertical))
{
return;
}
Expand All @@ -4369,8 +4354,7 @@ namespace OpenRCT2::Ui::Windows
break;
case TrackPitch::Up90:
if (IsTrackEnabled(TrackGroup::slopeVertical) && !WidgetIsDisabled(*w, WIDX_SLOPE_UP_STEEP)
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_RISE
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].type != WindowWidgetType::Empty)
&& w->widgets[WIDX_SLOPE_UP_VERTICAL].type != WindowWidgetType::Empty)
{
w->OnMouseDown(WIDX_SLOPE_UP_STEEP);
}
Expand All @@ -4392,11 +4376,10 @@ namespace OpenRCT2::Ui::Windows
switch (_currentTrackPitchEnd)
{
case TrackPitch::Up60:
if (IsTrackEnabled(TrackGroup::slopeVertical) && !WidgetIsDisabled(*w, WIDX_SLOPE_DOWN_STEEP)
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_RISE
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].type != WindowWidgetType::Empty)
if (IsTrackEnabled(TrackGroup::slopeVertical) && !WidgetIsDisabled(*w, WIDX_SLOPE_UP_VERTICAL)
&& w->widgets[WIDX_SLOPE_UP_VERTICAL].type != WindowWidgetType::Empty)
{
w->OnMouseDown(WIDX_SLOPE_DOWN_STEEP);
w->OnMouseDown(WIDX_SLOPE_UP_VERTICAL);
}
break;
case TrackPitch::Up25:
Expand All @@ -4411,9 +4394,7 @@ namespace OpenRCT2::Ui::Windows
{
w->OnMouseDown(WIDX_SLOPE_UP);
}
else if (
IsTrackEnabled(TrackGroup::slopeVertical)
&& w->widgets[WIDX_SLOPE_UP_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_DROP)
else if (IsTrackEnabled(TrackGroup::slopeVertical))
{
return;
}
Expand Down Expand Up @@ -4461,9 +4442,7 @@ namespace OpenRCT2::Ui::Windows
{
w->OnMouseDown(WIDX_SLOPE_UP);
}
else if (
IsTrackEnabled(TrackGroup::slopeVertical)
&& w->widgets[WIDX_SLOPE_UP_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_DROP)
else if (IsTrackEnabled(TrackGroup::slopeVertical))
{
return;
}
Expand All @@ -4480,7 +4459,6 @@ namespace OpenRCT2::Ui::Windows
break;
case TrackPitch::Down90:
if (IsTrackEnabled(TrackGroup::slopeVertical) && !WidgetIsDisabled(*w, WIDX_SLOPE_DOWN_STEEP)
&& w->widgets[WIDX_SLOPE_UP_STEEP].image.GetIndex() == SPR_RIDE_CONSTRUCTION_VERTICAL_DROP
&& w->widgets[WIDX_SLOPE_DOWN_STEEP].type != WindowWidgetType::Empty)
{
w->OnMouseDown(WIDX_SLOPE_DOWN_STEEP);
Expand Down
Loading

0 comments on commit 4eb97f3

Please sign in to comment.