mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Move two footpath globals into the window
This commit is contained in:
@@ -90,6 +90,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
};
|
||||
|
||||
static ProvisionalFootpath _provisionalFootpath;
|
||||
static CoordsXYZ _footpathConstructFromPosition;
|
||||
static uint8_t _footpathConstructSlope;
|
||||
|
||||
#pragma region Measurements
|
||||
|
||||
@@ -463,11 +465,11 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Get construction image
|
||||
uint8_t direction = (_footpathConstructDirection + GetCurrentRotation()) % 4;
|
||||
uint8_t slope = 0;
|
||||
if (gFootpathConstructSlope == 2)
|
||||
if (_footpathConstructSlope == 2)
|
||||
{
|
||||
slope = kTileSlopeNCornerUp;
|
||||
}
|
||||
else if (gFootpathConstructSlope == 6)
|
||||
else if (_footpathConstructSlope == 6)
|
||||
{
|
||||
slope = kTileSlopeECornerUp;
|
||||
}
|
||||
@@ -786,7 +788,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
void WindowFootpathMousedownSlope(int32_t slope)
|
||||
{
|
||||
FootpathUpdateProvisional();
|
||||
gFootpathConstructSlope = slope;
|
||||
_footpathConstructSlope = slope;
|
||||
_windowFootpathCost = kMoney64Undefined;
|
||||
WindowFootpathSetEnabledAndPressedWidgets();
|
||||
}
|
||||
@@ -1151,10 +1153,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
ToolCancel();
|
||||
gFootpathConstructFromPosition = { mapCoords, z };
|
||||
_footpathConstructFromPosition = { mapCoords, z };
|
||||
_footpathConstructDirection = direction;
|
||||
_provisionalFootpath.flags.clearAll();
|
||||
gFootpathConstructSlope = 0;
|
||||
_footpathConstructSlope = 0;
|
||||
_footpathConstructionMode = PathConstructionMode::bridgeOrTunnel;
|
||||
_footpathConstructValidDirections = kInvalidDirection;
|
||||
WindowFootpathSetEnabledAndPressedWidgets();
|
||||
@@ -1195,7 +1197,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
if (gFootpathConstructSlope == 0)
|
||||
if (_footpathConstructSlope == 0)
|
||||
{
|
||||
self->_footpathConstructValidDirections = kInvalidDirection;
|
||||
}
|
||||
@@ -1209,13 +1211,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
ViewportSetVisibility(ViewportVisibility::UndergroundViewOn);
|
||||
}
|
||||
|
||||
gFootpathConstructFromPosition = footpathLoc;
|
||||
_footpathConstructFromPosition = footpathLoc;
|
||||
// If we have just built an upwards slope, the next path to construct is
|
||||
// a bit higher. Note that the z returned by footpath_get_next_path_info
|
||||
// already is lowered if we are building a downwards slope.
|
||||
if (gFootpathConstructSlope == 2)
|
||||
if (_footpathConstructSlope == 2)
|
||||
{
|
||||
gFootpathConstructFromPosition.z += kPathHeightStep;
|
||||
_footpathConstructFromPosition.z += kPathHeightStep;
|
||||
}
|
||||
}
|
||||
self->WindowFootpathSetEnabledAndPressedWidgets();
|
||||
@@ -1259,15 +1261,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
gFootpathConstructFromPosition.z = tileElement->GetBaseZ();
|
||||
auto action = GameActions::FootpathRemoveAction(gFootpathConstructFromPosition);
|
||||
_footpathConstructFromPosition.z = tileElement->GetBaseZ();
|
||||
auto action = GameActions::FootpathRemoveAction(_footpathConstructFromPosition);
|
||||
GameActions::Execute(&action, getGameState());
|
||||
|
||||
// Move selection
|
||||
edge = DirectionReverse(edge);
|
||||
gFootpathConstructFromPosition.x -= CoordsDirectionDelta[edge].x;
|
||||
gFootpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y;
|
||||
gFootpathConstructFromPosition.z = z;
|
||||
_footpathConstructFromPosition.x -= CoordsDirectionDelta[edge].x;
|
||||
_footpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y;
|
||||
_footpathConstructFromPosition.z = z;
|
||||
_footpathConstructDirection = edge;
|
||||
_footpathConstructValidDirections = kInvalidDirection;
|
||||
}
|
||||
@@ -1281,15 +1283,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
TileElement* tileElement;
|
||||
int32_t z, zLow;
|
||||
|
||||
if (!MapIsLocationValid(gFootpathConstructFromPosition))
|
||||
if (!MapIsLocationValid(_footpathConstructFromPosition))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
z = std::min(255 * kCoordsZStep, gFootpathConstructFromPosition.z);
|
||||
z = std::min(255 * kCoordsZStep, _footpathConstructFromPosition.z);
|
||||
zLow = z - kPathHeightStep;
|
||||
|
||||
tileElement = MapGetFirstElementAt(gFootpathConstructFromPosition);
|
||||
tileElement = MapGetFirstElementAt(_footpathConstructFromPosition);
|
||||
do
|
||||
{
|
||||
if (tileElement == nullptr)
|
||||
@@ -1360,8 +1362,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
int32_t direction = _footpathConstructDirection;
|
||||
gMapSelectionTiles.clear();
|
||||
gMapSelectionTiles.push_back(
|
||||
{ gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x,
|
||||
gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y });
|
||||
{ _footpathConstructFromPosition.x + CoordsDirectionDelta[direction].x,
|
||||
_footpathConstructFromPosition.y + CoordsDirectionDelta[direction].y });
|
||||
MapInvalidateMapSelectionTiles();
|
||||
}
|
||||
|
||||
@@ -1377,7 +1379,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
pressedWidgets |= (1LL << (WIDX_DIRECTION_NW + direction));
|
||||
|
||||
// Set pressed slope widget
|
||||
int32_t slope = gFootpathConstructSlope;
|
||||
int32_t slope = _footpathConstructSlope;
|
||||
if (slope == kTileSlopeSESideUp)
|
||||
{
|
||||
pressedWidgets |= (1uLL << WIDX_SLOPEDOWN);
|
||||
@@ -1423,18 +1425,18 @@ namespace OpenRCT2::Ui::Windows
|
||||
void FootpathGetNextPathInfo(ObjectEntryIndex* type, CoordsXYZ& footpathLoc, int32_t* slope)
|
||||
{
|
||||
auto direction = _footpathConstructDirection;
|
||||
footpathLoc.x = gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x;
|
||||
footpathLoc.y = gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y;
|
||||
footpathLoc.z = gFootpathConstructFromPosition.z;
|
||||
footpathLoc.x = _footpathConstructFromPosition.x + CoordsDirectionDelta[direction].x;
|
||||
footpathLoc.y = _footpathConstructFromPosition.y + CoordsDirectionDelta[direction].y;
|
||||
footpathLoc.z = _footpathConstructFromPosition.z;
|
||||
if (type != nullptr)
|
||||
{
|
||||
*type = gFootpathSelection.GetSelectedSurface();
|
||||
}
|
||||
*slope = kTileSlopeFlat;
|
||||
if (gFootpathConstructSlope != 0)
|
||||
if (_footpathConstructSlope != 0)
|
||||
{
|
||||
*slope = _footpathConstructDirection | kTileSlopeSCornerUp;
|
||||
if (gFootpathConstructSlope != 2)
|
||||
if (_footpathConstructSlope != 2)
|
||||
{
|
||||
footpathLoc.z -= kPathHeightStep;
|
||||
*slope ^= kTileSlopeECornerUp;
|
||||
@@ -1491,7 +1493,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
}
|
||||
|
||||
switch (gFootpathConstructSlope)
|
||||
switch (_footpathConstructSlope)
|
||||
{
|
||||
case 0:
|
||||
OnMouseDown(WIDX_SLOPEDOWN);
|
||||
@@ -1513,7 +1515,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
}
|
||||
|
||||
switch (gFootpathConstructSlope)
|
||||
switch (_footpathConstructSlope)
|
||||
{
|
||||
case 6:
|
||||
OnMouseDown(WIDX_LEVEL);
|
||||
@@ -1530,7 +1532,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
void KeyboardShortcutSlopeLevel()
|
||||
{
|
||||
if (IsWidgetDisabled(WIDX_SLOPEDOWN) || IsWidgetDisabled(WIDX_LEVEL) || IsWidgetDisabled(WIDX_SLOPEUP)
|
||||
|| widgets[WIDX_LEVEL].type == WidgetType::empty || gFootpathConstructSlope == 0)
|
||||
|| widgets[WIDX_LEVEL].type == WidgetType::empty || _footpathConstructSlope == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1730,7 +1732,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else if (
|
||||
_provisionalFootpath.slope == kTileSlopeFlat
|
||||
|| _provisionalFootpath.position.z < gFootpathConstructFromPosition.z)
|
||||
|| _provisionalFootpath.position.z < _footpathConstructFromPosition.z)
|
||||
{
|
||||
// Going either straight on, or down.
|
||||
VirtualFloorSetHeight(_provisionalFootpath.position.z);
|
||||
@@ -1772,7 +1774,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_provisionalFootpath.flags.unset(ProvisionalPathFlag::showArrow);
|
||||
|
||||
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
|
||||
MapInvalidateTileFull(gFootpathConstructFromPosition);
|
||||
MapInvalidateTileFull(_footpathConstructFromPosition);
|
||||
}
|
||||
FootpathRemoveProvisional();
|
||||
}
|
||||
|
||||
@@ -52,8 +52,6 @@ using namespace OpenRCT2::TrackMetaData;
|
||||
void FootpathUpdateQueueEntranceBanner(const CoordsXY& footpathPos, TileElement* tileElement);
|
||||
|
||||
FootpathSelection gFootpathSelection;
|
||||
CoordsXYZ gFootpathConstructFromPosition;
|
||||
uint8_t gFootpathConstructSlope;
|
||||
uint8_t gFootpathGroundFlags;
|
||||
|
||||
static RideId* _footpathQueueChainNext;
|
||||
|
||||
@@ -136,8 +136,6 @@ enum
|
||||
};
|
||||
|
||||
extern FootpathSelection gFootpathSelection;
|
||||
extern CoordsXYZ gFootpathConstructFromPosition;
|
||||
extern uint8_t gFootpathConstructSlope;
|
||||
extern uint8_t gFootpathGroundFlags;
|
||||
|
||||
// Given a direction, this will return how to increase/decrease the x and y coordinates.
|
||||
|
||||
Reference in New Issue
Block a user