mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 16:24:35 +01:00
Merge pull request #17809 from Gymnasiast/bla3
Move some code from _legacy.cpp to RideConstruction.cpp (ui)
This commit is contained in:
@@ -154,6 +154,7 @@ static int32_t _trackPlaceZ;
|
||||
static money32 _trackPlaceCost;
|
||||
static StringId _trackPlaceErrorMessage;
|
||||
static bool _autoRotatingShop;
|
||||
static bool _gotoStartPlacementMode = false;
|
||||
|
||||
static constexpr const StringId RideConstructionSeatAngleRotationStrings[] = {
|
||||
STR_RIDE_CONSTRUCTION_SEAT_ROTATION_ANGLE_NEG_180, STR_RIDE_CONSTRUCTION_SEAT_ROTATION_ANGLE_NEG_135,
|
||||
@@ -166,6 +167,8 @@ static constexpr const StringId RideConstructionSeatAngleRotationStrings[] = {
|
||||
STR_RIDE_CONSTRUCTION_SEAT_ROTATION_ANGLE_450, STR_RIDE_CONSTRUCTION_SEAT_ROTATION_ANGLE_495,
|
||||
};
|
||||
|
||||
static void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type);
|
||||
|
||||
static int32_t RideGetAlternativeType(Ride* ride)
|
||||
{
|
||||
return (_currentTrackAlternative & RIDE_TYPE_ALTERNATIVE_TRACK_TYPE) ? ride->GetRideTypeDescriptor().AlternateType
|
||||
@@ -2328,7 +2331,7 @@ private:
|
||||
*newCoords = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z };
|
||||
direction = trackBeginEnd.begin_direction;
|
||||
type = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
|
||||
gGotoStartPlacementMode = false;
|
||||
_gotoStartPlacementMode = false;
|
||||
}
|
||||
else if (track_block_get_next(&inputElement, &outputElement, &newCoords->z, &direction))
|
||||
{
|
||||
@@ -2336,7 +2339,7 @@ private:
|
||||
newCoords->y = outputElement.y;
|
||||
direction = outputElement.element->GetDirection();
|
||||
type = outputElement.element->AsTrack()->GetTrackType();
|
||||
gGotoStartPlacementMode = false;
|
||||
_gotoStartPlacementMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2354,7 +2357,7 @@ private:
|
||||
const auto& ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
|
||||
const rct_preview_track* trackBlock = ted.Block;
|
||||
newCoords->z = (tileElement->GetBaseZ()) - trackBlock->z;
|
||||
gGotoStartPlacementMode = true;
|
||||
_gotoStartPlacementMode = true;
|
||||
|
||||
// When flat rides are deleted, the window should be reset so the currentRide can be placed again.
|
||||
auto currentRide = get_ride(_currentRideIndex);
|
||||
@@ -2753,6 +2756,28 @@ static void CloseConstructWindowOnCompletion(Ride* ride)
|
||||
}
|
||||
}
|
||||
|
||||
static void window_ride_construction_do_entrance_exit_check()
|
||||
{
|
||||
auto w = window_find_by_class(WC_RIDE_CONSTRUCTION);
|
||||
auto ride = get_ride(_currentRideIndex);
|
||||
if (w == nullptr || ride == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_rideConstructionState == RideConstructionState::State0)
|
||||
{
|
||||
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
|
||||
if (w != nullptr)
|
||||
{
|
||||
if (!ride_are_all_possible_entrances_and_exits_built(ride).Successful)
|
||||
{
|
||||
window_event_mouse_up_call(w, WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const GameActions::Result* result)
|
||||
{
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
@@ -4465,3 +4490,76 @@ void window_ride_construction_keyboard_shortcut_demolish_current()
|
||||
|
||||
window_event_mouse_up_call(w, WIDX_DEMOLISH);
|
||||
}
|
||||
|
||||
static void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type)
|
||||
{
|
||||
if (_gotoStartPlacementMode)
|
||||
{
|
||||
_currentTrackBegin.z = floor2(piecePos.z, COORDS_Z_STEP);
|
||||
_rideConstructionState = RideConstructionState::Front;
|
||||
_currentTrackSelectionFlags = 0;
|
||||
_currentTrackPieceDirection = piecePos.direction & 3;
|
||||
auto savedCurrentTrackCurve = _currentTrackCurve;
|
||||
int32_t savedPreviousTrackSlopeEnd = _previousTrackSlopeEnd;
|
||||
int32_t savedCurrentTrackSlopeEnd = _currentTrackSlopeEnd;
|
||||
int32_t savedPreviousTrackBankEnd = _previousTrackBankEnd;
|
||||
int32_t savedCurrentTrackBankEnd = _currentTrackBankEnd;
|
||||
int32_t savedCurrentTrackAlternative = _currentTrackAlternative;
|
||||
int32_t savedCurrentTrackLiftHill = _currentTrackLiftHill;
|
||||
ride_construction_set_default_next_piece();
|
||||
window_ride_construction_update_active_elements();
|
||||
auto ride = get_ride(_currentRideIndex);
|
||||
if (!ride_try_get_origin_element(ride, nullptr))
|
||||
{
|
||||
ride_initialise_construction_window(ride);
|
||||
_currentTrackPieceDirection = piecePos.direction & 3;
|
||||
if (!(savedCurrentTrackCurve & RideConstructionSpecialPieceSelected))
|
||||
{
|
||||
_currentTrackCurve = savedCurrentTrackCurve;
|
||||
_previousTrackSlopeEnd = savedPreviousTrackSlopeEnd;
|
||||
_currentTrackSlopeEnd = savedCurrentTrackSlopeEnd;
|
||||
_previousTrackBankEnd = savedPreviousTrackBankEnd;
|
||||
_currentTrackBankEnd = savedCurrentTrackBankEnd;
|
||||
_currentTrackAlternative = savedCurrentTrackAlternative;
|
||||
_currentTrackLiftHill = savedCurrentTrackLiftHill;
|
||||
window_ride_construction_update_active_elements();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_rideConstructionState2 == RideConstructionState::Selected
|
||||
|| _rideConstructionState2 == RideConstructionState::Front)
|
||||
{
|
||||
if (type == TrackElemType::MiddleStation || type == TrackElemType::BeginStation)
|
||||
{
|
||||
type = TrackElemType::EndStation;
|
||||
}
|
||||
}
|
||||
if (_rideConstructionState2 == RideConstructionState::Back)
|
||||
{
|
||||
if (type == TrackElemType::MiddleStation)
|
||||
{
|
||||
type = TrackElemType::BeginStation;
|
||||
}
|
||||
}
|
||||
if (network_get_mode() == NETWORK_MODE_CLIENT)
|
||||
{
|
||||
// rideConstructionState needs to be set again to the proper value, this only affects the client
|
||||
_rideConstructionState = RideConstructionState::Selected;
|
||||
}
|
||||
_currentTrackBegin = piecePos;
|
||||
_currentTrackPieceDirection = piecePos.direction;
|
||||
_currentTrackPieceType = type;
|
||||
_currentTrackSelectionFlags = 0;
|
||||
if (_rideConstructionState2 == RideConstructionState::Front)
|
||||
{
|
||||
ride_select_next_section();
|
||||
}
|
||||
else if (_rideConstructionState2 == RideConstructionState::Back)
|
||||
{
|
||||
ride_select_previous_section();
|
||||
}
|
||||
window_ride_construction_update_active_elements();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,15 +1075,11 @@ void UpdateGhostTrackAndArrow();
|
||||
|
||||
void ride_reset_all_names();
|
||||
|
||||
void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type);
|
||||
|
||||
uint32_t ride_customers_per_hour(const Ride* ride);
|
||||
uint32_t ride_customers_in_last_5_minutes(const Ride* ride);
|
||||
|
||||
Vehicle* ride_get_broken_vehicle(const Ride* ride);
|
||||
|
||||
void window_ride_construction_do_entrance_exit_check();
|
||||
|
||||
money16 ride_get_price(const Ride* ride);
|
||||
|
||||
TileElement* get_station_platform(const CoordsXYRangedZ& coords);
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "Vehicle.h"
|
||||
|
||||
using namespace OpenRCT2::TrackMetaData;
|
||||
bool gGotoStartPlacementMode = false;
|
||||
|
||||
money16 gTotalRideValueForMoney;
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ enum class RideConstructionState : uint8_t
|
||||
MazeFill
|
||||
};
|
||||
|
||||
extern bool gGotoStartPlacementMode;
|
||||
|
||||
extern money32 _currentTrackPrice;
|
||||
|
||||
extern uint32_t _currentTrackCurve;
|
||||
|
||||
@@ -390,101 +390,6 @@ bool window_ride_construction_update_state(
|
||||
return false;
|
||||
}
|
||||
|
||||
void window_ride_construction_do_entrance_exit_check()
|
||||
{
|
||||
auto w = window_find_by_class(WC_RIDE_CONSTRUCTION);
|
||||
auto ride = get_ride(_currentRideIndex);
|
||||
if (w == nullptr || ride == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_rideConstructionState == RideConstructionState::State0)
|
||||
{
|
||||
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
|
||||
if (w != nullptr)
|
||||
{
|
||||
if (!ride_are_all_possible_entrances_and_exits_built(ride).Successful)
|
||||
{
|
||||
window_event_mouse_up_call(w, WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type)
|
||||
{
|
||||
if (gGotoStartPlacementMode)
|
||||
{
|
||||
_currentTrackBegin.z = floor2(piecePos.z, COORDS_Z_STEP);
|
||||
_rideConstructionState = RideConstructionState::Front;
|
||||
_currentTrackSelectionFlags = 0;
|
||||
_currentTrackPieceDirection = piecePos.direction & 3;
|
||||
auto savedCurrentTrackCurve = _currentTrackCurve;
|
||||
int32_t savedPreviousTrackSlopeEnd = _previousTrackSlopeEnd;
|
||||
int32_t savedCurrentTrackSlopeEnd = _currentTrackSlopeEnd;
|
||||
int32_t savedPreviousTrackBankEnd = _previousTrackBankEnd;
|
||||
int32_t savedCurrentTrackBankEnd = _currentTrackBankEnd;
|
||||
int32_t savedCurrentTrackAlternative = _currentTrackAlternative;
|
||||
int32_t savedCurrentTrackLiftHill = _currentTrackLiftHill;
|
||||
ride_construction_set_default_next_piece();
|
||||
window_ride_construction_update_active_elements();
|
||||
auto ride = get_ride(_currentRideIndex);
|
||||
if (!ride_try_get_origin_element(ride, nullptr))
|
||||
{
|
||||
ride_initialise_construction_window(ride);
|
||||
_currentTrackPieceDirection = piecePos.direction & 3;
|
||||
if (!(savedCurrentTrackCurve & RideConstructionSpecialPieceSelected))
|
||||
{
|
||||
_currentTrackCurve = savedCurrentTrackCurve;
|
||||
_previousTrackSlopeEnd = savedPreviousTrackSlopeEnd;
|
||||
_currentTrackSlopeEnd = savedCurrentTrackSlopeEnd;
|
||||
_previousTrackBankEnd = savedPreviousTrackBankEnd;
|
||||
_currentTrackBankEnd = savedCurrentTrackBankEnd;
|
||||
_currentTrackAlternative = savedCurrentTrackAlternative;
|
||||
_currentTrackLiftHill = savedCurrentTrackLiftHill;
|
||||
window_ride_construction_update_active_elements();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_rideConstructionState2 == RideConstructionState::Selected
|
||||
|| _rideConstructionState2 == RideConstructionState::Front)
|
||||
{
|
||||
if (type == TrackElemType::MiddleStation || type == TrackElemType::BeginStation)
|
||||
{
|
||||
type = TrackElemType::EndStation;
|
||||
}
|
||||
}
|
||||
if (_rideConstructionState2 == RideConstructionState::Back)
|
||||
{
|
||||
if (type == TrackElemType::MiddleStation)
|
||||
{
|
||||
type = TrackElemType::BeginStation;
|
||||
}
|
||||
}
|
||||
if (network_get_mode() == NETWORK_MODE_CLIENT)
|
||||
{
|
||||
// rideConstructionState needs to be set again to the proper value, this only affects the client
|
||||
_rideConstructionState = RideConstructionState::Selected;
|
||||
}
|
||||
_currentTrackBegin = piecePos;
|
||||
_currentTrackPieceDirection = piecePos.direction;
|
||||
_currentTrackPieceType = type;
|
||||
_currentTrackSelectionFlags = 0;
|
||||
if (_rideConstructionState2 == RideConstructionState::Front)
|
||||
{
|
||||
ride_select_next_section();
|
||||
}
|
||||
else if (_rideConstructionState2 == RideConstructionState::Back)
|
||||
{
|
||||
ride_select_previous_section();
|
||||
}
|
||||
window_ride_construction_update_active_elements();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006C84CE
|
||||
|
||||
Reference in New Issue
Block a user