Merge pull request #25143 from Gymnasiast/refactor/footpath-cpp

Refactor a few selection enums
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2025-09-11 22:19:12 +02:00
commit 7ceaa4fed1
33 files changed
+332 -304

No files matched your search

@@ -29,7 +29,7 @@ namespace OpenRCT2::Scripting
DukValue range_get() const
{
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
DukObject range(_ctx);
@@ -61,13 +61,13 @@ namespace OpenRCT2::Scripting
gMapSelectPositionA.y = range->GetTop();
gMapSelectPositionB.x = range->GetRight();
gMapSelectPositionB.y = range->GetBottom();
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MapSelectType::full;
gMapSelectFlags.set(MapSelectFlag::enable);
}
}
else
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
}
MapInvalidateSelectionRect();
}
@@ -75,7 +75,7 @@ namespace OpenRCT2::Scripting
DukValue tiles_get() const
{
duk_push_array(_ctx);
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
duk_uarridx_t index = 0;
for (const auto& tile : gMapSelectionTiles)
@@ -117,12 +117,12 @@ namespace OpenRCT2::Scripting
if (gMapSelectionTiles.empty())
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::green);
}
else
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags.set(MapSelectFlag::enableConstruct);
}
MapInvalidateMapSelectionTiles();
}
+8 -8
View File
@@ -219,7 +219,7 @@ namespace OpenRCT2::Ui::Windows
uint8_t state_changed = 0;
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
auto mapTile = ScreenGetMapXY(screenPos, nullptr);
@@ -228,15 +228,15 @@ namespace OpenRCT2::Ui::Windows
return state_changed;
}
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
state_changed++;
}
if (gMapSelectType != MAP_SELECT_TYPE_FULL)
if (gMapSelectType != MapSelectType::full)
{
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
state_changed++;
}
@@ -314,7 +314,7 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_BACKGROUND:
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
auto action = GetClearAction();
GameActions::Execute(&action, getGameState());
@@ -331,7 +331,7 @@ namespace OpenRCT2::Ui::Windows
case WIDX_BACKGROUND:
{
auto* windowMgr = GetWindowManager();
if (windowMgr->FindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (windowMgr->FindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags.has(MapSelectFlag::enable)))
{
auto action = GetClearAction();
GameActions::Execute(&action, getGameState());
@@ -348,7 +348,7 @@ namespace OpenRCT2::Ui::Windows
{
case WIDX_BACKGROUND:
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
gCurrentToolId = Tool::bulldozer;
break;
}
@@ -165,9 +165,7 @@ namespace OpenRCT2::Ui::Windows
{
MapInvalidateSelectionRect();
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags.unset(MapSelectFlag::enable, MapSelectFlag::enableArrow, MapSelectFlag::enableConstruct);
CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords);
if (parkEntrancePosition.IsNull())
{
@@ -188,7 +186,7 @@ namespace OpenRCT2::Ui::Windows
gMapSelectArrowPosition = parkEntrancePosition;
gMapSelectArrowDirection = parkEntrancePosition.direction;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT | MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.set(MapSelectFlag::enableConstruct, MapSelectFlag::enableArrow);
MapInvalidateMapSelectionTiles();
if (gParkEntranceGhostExists && parkEntrancePosition == gParkEntranceGhostPosition)
{
+42 -37
View File
@@ -54,11 +54,17 @@ namespace OpenRCT2::Ui::Windows
ObjectEntryIndex type, ObjectEntryIndex railingsType, const CoordsXYZ& footpathLoc, int32_t slope,
PathConstructFlags constructFlags);
enum
enum class PathConstructionMode : uint8_t
{
PATH_CONSTRUCTION_MODE_LAND,
PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL,
PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL
land,
/**
* When picking a location to start the bridge or tunnel
*/
bridgeOrTunnelPick,
/**
* When actually building a bridge or tunnel (enables the appropriate buttons)
*/
bridgeOrTunnel,
};
enum class ProvisionalPathFlag : uint8_t
@@ -191,7 +197,7 @@ namespace OpenRCT2::Ui::Windows
uint8_t _footpathConstructDirection;
uint8_t _footpathConstructValidDirections;
uint8_t _footpathConstructionMode;
PathConstructionMode _footpathConstructionMode;
std::vector<std::pair<ObjectType, ObjectEntryIndex>> _dropdownEntries;
@@ -221,7 +227,7 @@ namespace OpenRCT2::Ui::Windows
ShowGridlines();
ToolCancel();
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
_footpathConstructionMode = PathConstructionMode::land;
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
gInputFlags.set(InputFlag::unk6);
_footpathErrorOccured = false;
@@ -238,7 +244,7 @@ namespace OpenRCT2::Ui::Windows
FootpathUpdateProvisional();
ViewportSetVisibility(ViewportVisibility::Default);
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
auto* windowMgr = Ui::GetWindowManager();
windowMgr->InvalidateByClass(WindowClass::TopToolbar);
@@ -258,12 +264,12 @@ namespace OpenRCT2::Ui::Windows
}
// Check tool
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND)
if (_footpathConstructionMode == PathConstructionMode::land)
{
if (!isToolActive(WindowClass::Footpath, WIDX_CONSTRUCT_ON_LAND))
Close();
}
else if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL)
else if (_footpathConstructionMode == PathConstructionMode::bridgeOrTunnelPick)
{
if (!isToolActive(WindowClass::Footpath, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL))
Close();
@@ -321,7 +327,7 @@ namespace OpenRCT2::Ui::Windows
Close();
break;
case WIDX_CONSTRUCT_ON_LAND:
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND)
if (_footpathConstructionMode == PathConstructionMode::land)
{
break;
}
@@ -330,15 +336,15 @@ namespace OpenRCT2::Ui::Windows
ToolCancel();
FootpathUpdateProvisional();
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
_footpathConstructionMode = PathConstructionMode::land;
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
gInputFlags.set(InputFlag::unk6);
_footpathErrorOccured = false;
WindowFootpathSetEnabledAndPressedWidgets();
break;
case WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL:
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL)
if (_footpathConstructionMode == PathConstructionMode::bridgeOrTunnelPick)
{
break;
}
@@ -347,8 +353,8 @@ namespace OpenRCT2::Ui::Windows
ToolCancel();
FootpathUpdateProvisional();
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
_footpathConstructionMode = PathConstructionMode::bridgeOrTunnelPick;
ToolSet(*this, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::crosshair);
gInputFlags.set(InputFlag::unk6);
_footpathErrorOccured = false;
@@ -452,7 +458,7 @@ namespace OpenRCT2::Ui::Windows
: (1uLL << WIDX_FOOTPATH_TYPE);
// Enable / disable construct button
widgets[WIDX_CONSTRUCT].type = _footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL
widgets[WIDX_CONSTRUCT].type = _footpathConstructionMode == PathConstructionMode::bridgeOrTunnel
? WidgetType::imgBtn
: WidgetType::empty;
@@ -549,7 +555,7 @@ namespace OpenRCT2::Ui::Windows
*/
void WindowFootpathUpdateProvisionalPathForBridgeMode()
{
if (_footpathConstructionMode != PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
if (_footpathConstructionMode != PathConstructionMode::bridgeOrTunnel)
{
return;
}
@@ -591,11 +597,11 @@ namespace OpenRCT2::Ui::Windows
gMapSelectArrowDirection = _footpathConstructDirection;
if (_provisionalFootpath.flags.has(ProvisionalPathFlag::showArrow))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.set(MapSelectFlag::enableArrow);
}
else
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
}
MapInvalidateTileFull(footpathLoc);
}
@@ -923,7 +929,7 @@ namespace OpenRCT2::Ui::Windows
{
if (info.interactionType == ViewportInteractionItem::None || info.Element == nullptr)
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
FootpathUpdateProvisional();
return kTileSlopeFlat;
}
@@ -1001,7 +1007,7 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathSetProvisionalPathAtPoint(const ScreenCoordsXY& screenCoords)
{
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
// Get current map pos and handle key modifier state
auto mapPos = FootpathGetPlacePositionFromScreenPosition(screenCoords);
@@ -1017,8 +1023,8 @@ namespace OpenRCT2::Ui::Windows
}
// Set map selection
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = *mapPos;
gMapSelectPositionB = *mapPos;
@@ -1042,7 +1048,7 @@ namespace OpenRCT2::Ui::Windows
if (baseZ == 0)
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
FootpathUpdateProvisional();
return;
}
@@ -1071,8 +1077,7 @@ namespace OpenRCT2::Ui::Windows
TileElement* tileElement;
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable, MapSelectFlag::enableArrow);
auto mapCoords = FootpathBridgeGetInfoFromPos(screenCoords, &direction, &tileElement);
if (mapCoords.IsNull())
@@ -1080,9 +1085,8 @@ namespace OpenRCT2::Ui::Windows
return;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable, MapSelectFlag::enableArrow);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords;
@@ -1213,7 +1217,7 @@ namespace OpenRCT2::Ui::Windows
_footpathConstructDirection = direction;
_provisionalFootpath.flags.clearAll();
gFootpathConstructSlope = 0;
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
_footpathConstructionMode = PathConstructionMode::bridgeOrTunnel;
_footpathConstructValidDirections = kInvalidDirection;
WindowFootpathSetEnabledAndPressedWidgets();
}
@@ -1410,11 +1414,10 @@ namespace OpenRCT2::Ui::Windows
*/
void WindowFootpathSetEnabledAndPressedWidgets()
{
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
if (_footpathConstructionMode == PathConstructionMode::bridgeOrTunnel)
{
MapInvalidateMapSelectionTiles();
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags |= MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.set(MapSelectFlag::enableConstruct, MapSelectFlag::green);
int32_t direction = _footpathConstructDirection;
gMapSelectionTiles.clear();
@@ -1429,7 +1432,7 @@ namespace OpenRCT2::Ui::Windows
| (1LL << WIDX_DIRECTION_SE) | (1LL << WIDX_SLOPEDOWN) | (1LL << WIDX_LEVEL) | (1LL << WIDX_SLOPEUP));
uint64_t disabledWidgets = 0;
int32_t currentRotation = GetCurrentRotation();
if (_footpathConstructionMode >= PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
if (_footpathConstructionMode == PathConstructionMode::bridgeOrTunnel)
{
// Set pressed directional widget
int32_t direction = (_footpathConstructDirection + currentRotation) & 3;
@@ -1519,7 +1522,8 @@ namespace OpenRCT2::Ui::Windows
void KeyboardShortcutTurnLeft()
{
if (IsWidgetDisabled(WIDX_DIRECTION_NW) || IsWidgetDisabled(WIDX_DIRECTION_NE)
|| IsWidgetDisabled(WIDX_DIRECTION_SW) || IsWidgetDisabled(WIDX_DIRECTION_SE) || _footpathConstructionMode != 2)
|| IsWidgetDisabled(WIDX_DIRECTION_SW) || IsWidgetDisabled(WIDX_DIRECTION_SE)
|| _footpathConstructionMode != PathConstructionMode::bridgeOrTunnel)
{
return;
}
@@ -1531,7 +1535,8 @@ namespace OpenRCT2::Ui::Windows
void KeyboardShortcutTurnRight()
{
if (IsWidgetDisabled(WIDX_DIRECTION_NW) || IsWidgetDisabled(WIDX_DIRECTION_NE)
|| IsWidgetDisabled(WIDX_DIRECTION_SW) || IsWidgetDisabled(WIDX_DIRECTION_SE) || _footpathConstructionMode != 2)
|| IsWidgetDisabled(WIDX_DIRECTION_SW) || IsWidgetDisabled(WIDX_DIRECTION_SE)
|| _footpathConstructionMode != PathConstructionMode::bridgeOrTunnel)
{
return;
}
@@ -1828,7 +1833,7 @@ namespace OpenRCT2::Ui::Windows
{
_provisionalFootpath.flags.unset(ProvisionalPathFlag::showArrow);
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
MapInvalidateTileFull(gFootpathConstructFromPosition);
}
FootpathRemoveProvisional();
+3 -3
View File
@@ -976,13 +976,13 @@ namespace OpenRCT2::Ui::Windows
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
auto mapCoords = FootpathGetCoordinatesFromPos({ screenCoords.x, screenCoords.y + 16 }, nullptr, nullptr);
if (!mapCoords.IsNull())
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords;
MapInvalidateSelectionRect();
+35 -32
View File
@@ -445,7 +445,7 @@ namespace OpenRCT2::Ui::Windows
uint8_t state_changed = 0;
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
auto mapTile = ScreenGetMapXY(screenPos, nullptr);
@@ -454,15 +454,15 @@ namespace OpenRCT2::Ui::Windows
return state_changed;
}
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
state_changed++;
}
if (gMapSelectType != MAP_SELECT_TYPE_FULL)
if (gMapSelectType != MapSelectType::full)
{
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
state_changed++;
}
@@ -524,7 +524,7 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_BACKGROUND:
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
@@ -551,7 +551,7 @@ namespace OpenRCT2::Ui::Windows
// Custom setting to only change land style instead of raising or lowering land
if (_landToolPaintMode)
{
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
@@ -583,7 +583,7 @@ namespace OpenRCT2::Ui::Windows
{
case WIDX_BACKGROUND:
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
gCurrentToolId = Tool::digDown;
break;
}
@@ -613,7 +613,7 @@ namespace OpenRCT2::Ui::Windows
if (gCurrentToolId == Tool::upDownArrow)
{
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
return;
money64 lower_cost = SelectionLowerLand(0);
@@ -632,12 +632,13 @@ namespace OpenRCT2::Ui::Windows
std::optional<CoordsXY> mapTile;
uint8_t side{};
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
if (tool_size == 1)
{
int32_t selectionType;
int32_t direction;
// Get selection type and map coordinates from mouse x,y position
ScreenPosToMapPos(screenPos, &selectionType);
ScreenPosToMapPos(screenPos, &direction);
MapSelectType selectionType = static_cast<MapSelectType>(direction);
mapTile = ScreenGetMapXYSide(screenPos, &side);
if (!mapTile.has_value())
@@ -656,9 +657,9 @@ namespace OpenRCT2::Ui::Windows
uint8_t state_changed = 0;
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
state_changed++;
}
@@ -668,9 +669,10 @@ namespace OpenRCT2::Ui::Windows
state_changed++;
}
if ((gMapSelectType != MAP_SELECT_TYPE_EDGE_0 + (side & 0xFF)) && mapCtrlPressed)
MapSelectType selectedSide = getMapSelectEdge(side & 0xFF);
if (gMapSelectType != selectedSide && mapCtrlPressed)
{
gMapSelectType = MAP_SELECT_TYPE_EDGE_0 + (side & 0xFF);
gMapSelectType = selectedSide;
state_changed++;
}
@@ -733,21 +735,22 @@ namespace OpenRCT2::Ui::Windows
uint8_t state_changed = 0;
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
state_changed++;
}
if (gMapSelectType != MAP_SELECT_TYPE_FULL)
if (gMapSelectType != MapSelectType::full)
{
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
state_changed++;
}
if ((gMapSelectType != MAP_SELECT_TYPE_EDGE_0 + (side & 0xFF)) && mapCtrlPressed)
MapSelectType selectedSide = getMapSelectEdge(side & 0xFF);
if (gMapSelectType != selectedSide && mapCtrlPressed)
{
gMapSelectType = MAP_SELECT_TYPE_EDGE_0 + (side & 0xFF);
gMapSelectType = selectedSide;
state_changed++;
}
@@ -759,14 +762,14 @@ namespace OpenRCT2::Ui::Windows
// Decide on shape of the brush for bigger selection size
switch (gMapSelectType)
{
case MAP_SELECT_TYPE_EDGE_0:
case MAP_SELECT_TYPE_EDGE_2:
case MapSelectType::edge0:
case MapSelectType::edge2:
// Line
mapTile->y -= (tool_size - 1) * 16;
mapTile->y = mapTile->ToTileStart().y;
break;
case MAP_SELECT_TYPE_EDGE_1:
case MAP_SELECT_TYPE_EDGE_3:
case MapSelectType::edge1:
case MapSelectType::edge3:
// Line
mapTile->x -= (tool_size - 1) * 16;
mapTile->x = mapTile->ToTileStart().x;
@@ -794,17 +797,17 @@ namespace OpenRCT2::Ui::Windows
// Go to other side
switch (gMapSelectType)
{
case MAP_SELECT_TYPE_EDGE_0:
case MAP_SELECT_TYPE_EDGE_2:
case MapSelectType::edge0:
case MapSelectType::edge2:
// Line
mapTile->y += tool_length;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
break;
case MAP_SELECT_TYPE_EDGE_1:
case MAP_SELECT_TYPE_EDGE_3:
case MapSelectType::edge1:
case MapSelectType::edge3:
// Line
mapTile->x += tool_length;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
break;
default:
mapTile->x += tool_length;
+5 -5
View File
@@ -460,7 +460,7 @@ namespace OpenRCT2::Ui::Windows
void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
auto info = GetMapCoordinatesFromPos(
screenCoords, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water));
@@ -479,15 +479,15 @@ namespace OpenRCT2::Ui::Windows
uint8_t state_changed = 0;
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
state_changed++;
}
if (gMapSelectType != MAP_SELECT_TYPE_FULL_LAND_RIGHTS)
if (gMapSelectType != MapSelectType::fullLandRights)
{
gMapSelectType = MAP_SELECT_TYPE_FULL_LAND_RIGHTS;
gMapSelectType = MapSelectType::fullLandRights;
state_changed++;
}
+3 -5
View File
@@ -447,8 +447,7 @@ namespace OpenRCT2::Ui::Windows
int32_t direction;
TileElement* tileElement;
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable, MapSelectFlag::enableArrow);
auto mapCoords = FootpathBridgeGetInfoFromPos(screenCoords, &direction, &tileElement);
if (mapCoords.IsNull())
return;
@@ -462,9 +461,8 @@ namespace OpenRCT2::Ui::Windows
mapZ += 16;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable, MapSelectFlag::enableArrow);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords;
gMapSelectArrowPosition = CoordsXYZ{ mapCoords, mapZ };
+5 -5
View File
@@ -119,8 +119,8 @@ namespace OpenRCT2::Ui::Windows
ViewportSetVisibility(ViewportVisibility::Default);
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
// In order to cancel the yellow arrow correctly the
// selection tool should be cancelled.
@@ -346,8 +346,8 @@ namespace OpenRCT2::Ui::Windows
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
CoordsXYZD entranceOrExitCoords = RideGetEntranceOrExitPositionFromScreenPosition(screenCoords);
if (entranceOrExitCoords.IsNull())
@@ -403,7 +403,7 @@ namespace OpenRCT2::Ui::Windows
_currentTrackSelectionFlags.clearAll();
_rideConstructionNextArrowPulse = 0;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
RideConstructionInvalidateCurrentTrack();
x = _currentTrackBegin.x + (CoordsDirectionDelta[direction].x / 2);
+4 -4
View File
@@ -159,10 +159,10 @@ namespace OpenRCT2::Ui::Windows
return;
auto stateChanged = false;
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
stateChanged = true;
if (gMapSelectType != MAP_SELECT_TYPE_FULL)
if (gMapSelectType != MapSelectType::full)
stateChanged = true;
auto toolSize = std::max<uint16_t>(1, gLandToolSize);
@@ -185,8 +185,8 @@ namespace OpenRCT2::Ui::Windows
MapInvalidateSelectionRect();
// Update and invalidate new area
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = posA;
gMapSelectPositionB = posB;
MapInvalidateSelectionRect();
+33 -33
View File
@@ -287,8 +287,8 @@ namespace OpenRCT2::Ui::Windows
ViewportSetVisibility(ViewportVisibility::Default);
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
// In order to cancel the yellow arrow correctly the
// selection tool should be cancelled. Don't do a tool cancel if
@@ -1136,12 +1136,12 @@ namespace OpenRCT2::Ui::Windows
break;
case WIDX_NEXT_SECTION:
RideSelectNextSection();
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
VirtualFloorSetHeight(_currentTrackBegin.z);
break;
case WIDX_PREVIOUS_SECTION:
RideSelectPreviousSection();
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
VirtualFloorSetHeight(_currentTrackBegin.z);
break;
case WIDX_LEFT_CURVE:
@@ -2242,8 +2242,8 @@ namespace OpenRCT2::Ui::Windows
CoordsXYZ trackPos{};
MapInvalidateMapSelectionTiles();
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags |= MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.set(MapSelectFlag::enableConstruct);
gMapSelectFlags.set(MapSelectFlag::green);
switch (_rideConstructionState)
{
@@ -2653,8 +2653,8 @@ namespace OpenRCT2::Ui::Windows
{
RideConstructionInvalidateCurrentTrack();
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
CoordsXYZD entranceOrExitCoords = RideGetEntranceOrExitPositionFromScreenPosition(screenCoords);
if (gRideEntranceExitPlaceDirection == kInvalidDirection)
@@ -2978,7 +2978,7 @@ namespace OpenRCT2::Ui::Windows
_currentTrackSelectionFlags.clearAll();
_rideConstructionState = RideConstructionState::Selected;
_rideConstructionNextArrowPulse = 0;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
RideSelectNextSection();
}
else
@@ -3025,7 +3025,7 @@ namespace OpenRCT2::Ui::Windows
_currentTrackSelectionFlags.clearAll();
_rideConstructionState = RideConstructionState::Selected;
_rideConstructionNextArrowPulse = 0;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
RideSelectPreviousSection();
}
else
@@ -3260,7 +3260,7 @@ namespace OpenRCT2::Ui::Windows
rideIndex, type, direction, liftHillAndAlternativeState, trackPos);
WindowRideConstructionUpdateActiveElements();
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
// Set height to where the next track piece would begin
VirtualFloorSetHeight(_currentTrackBegin.z);
@@ -3284,9 +3284,9 @@ namespace OpenRCT2::Ui::Windows
direction = DirectionReverse(direction);
gMapSelectArrowPosition = trackPos;
gMapSelectArrowDirection = direction;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
if (_currentTrackSelectionFlags.has(TrackSelectionFlag::arrow))
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.set(MapSelectFlag::enableArrow);
MapInvalidateTileFull(trackPos);
break;
}
@@ -3334,9 +3334,9 @@ namespace OpenRCT2::Ui::Windows
gMapSelectArrowDirection = 7;
}
}
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
if (_currentTrackSelectionFlags.has(TrackSelectionFlag::arrow))
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.set(MapSelectFlag::enableArrow);
MapInvalidateTileFull(trackPos);
break;
}
@@ -3354,9 +3354,9 @@ namespace OpenRCT2::Ui::Windows
int32_t z;
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
auto mapCoords = RideGetPlacePositionFromScreenPosition(screenCoords);
if (!mapCoords)
{
@@ -3369,9 +3369,9 @@ namespace OpenRCT2::Ui::Windows
if (z == 0)
z = MapGetHighestZ(*mapCoords);
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.set(MapSelectFlag::enableConstruct);
gMapSelectFlags.set(MapSelectFlag::enableArrow);
gMapSelectFlags.unset(MapSelectFlag::green);
gMapSelectArrowPosition = CoordsXYZ{ *mapCoords, z };
gMapSelectArrowDirection = _currentTrackPieceDirection;
gMapSelectionTiles.clear();
@@ -3414,7 +3414,7 @@ namespace OpenRCT2::Ui::Windows
if (_trackPlaceZ == 0)
{
// Raise z above all slopes and water
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
int32_t highestZ = 0;
for (const auto& selectedTile : gMapSelectionTiles)
@@ -3574,18 +3574,18 @@ namespace OpenRCT2::Ui::Windows
{
MapInvalidateSelectionRect();
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
CoordsXYZD entranceOrExitCoords = RideGetEntranceOrExitPositionFromScreenPosition(screenCoords);
if (gRideEntranceExitPlaceDirection == kInvalidDirection)
{
RideConstructionInvalidateCurrentTrack();
return;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectFlags.set(MapSelectFlag::enableArrow);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = entranceOrExitCoords;
gMapSelectPositionB = entranceOrExitCoords;
gMapSelectArrowPosition = entranceOrExitCoords;
@@ -3633,7 +3633,7 @@ namespace OpenRCT2::Ui::Windows
// Raise z above all slopes and water
highestZ = 0;
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
for (const auto& selectedTile : gMapSelectionTiles)
{
@@ -3646,9 +3646,9 @@ namespace OpenRCT2::Ui::Windows
}
}
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
auto ridePlacePosition = RideGetPlacePositionFromScreenPosition(screenCoords);
if (!ridePlacePosition)
return;
@@ -4819,7 +4819,7 @@ namespace OpenRCT2::Ui::Windows
if (_currentTrackPitchEnd != TrackPitch::None)
ViewportSetVisibility(ViewportVisibility::TrackHeights);
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
// Set height to where the next track piece would begin
VirtualFloorSetHeight(trackPos.z - zBegin + zEnd);
+12 -12
View File
@@ -1782,8 +1782,8 @@ namespace OpenRCT2::Ui::Windows
MapInvalidateSelectionRect();
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
if (_sceneryPaintEnabled)
return;
@@ -1815,7 +1815,7 @@ namespace OpenRCT2::Ui::Windows
return;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
if (gWindowSceneryScatterEnabled)
{
uint16_t cluster_size = (gWindowSceneryScatterSize - 1) * kCoordsXYStep;
@@ -1839,10 +1839,10 @@ namespace OpenRCT2::Ui::Windows
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(selection.EntryIndex);
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE) && !gWindowSceneryScatterEnabled)
{
gMapSelectType = MAP_SELECT_TYPE_QUARTER_0 + (quadrant ^ 2);
gMapSelectType = getMapSelectQuarter((quadrant ^ 2));
}
MapInvalidateSelectionRect();
@@ -1893,12 +1893,12 @@ namespace OpenRCT2::Ui::Windows
return;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.y = mapTile.y;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
MapInvalidateSelectionRect();
@@ -1929,12 +1929,12 @@ namespace OpenRCT2::Ui::Windows
return;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.y = mapTile.y;
gMapSelectType = MAP_SELECT_TYPE_EDGE_0 + edge;
gMapSelectType = getMapSelectEdge(edge);
MapInvalidateSelectionRect();
@@ -1998,7 +1998,7 @@ namespace OpenRCT2::Ui::Windows
gMapSelectionTiles.push_back(rotatedTileCoords);
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags.set(MapSelectFlag::enableConstruct);
MapInvalidateMapSelectionTiles();
// If no change in ghost placement
@@ -2050,12 +2050,12 @@ namespace OpenRCT2::Ui::Windows
return;
}
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.y = mapTile.y;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
MapInvalidateSelectionRect();
+3 -3
View File
@@ -664,13 +664,13 @@ namespace OpenRCT2::Ui::Windows
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
auto mapCoords = FootpathGetCoordinatesFromPos({ screenCoords.x, screenCoords.y + 16 }, nullptr, nullptr);
if (!mapCoords.IsNull())
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectType = MapSelectType::full;
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords;
MapInvalidateSelectionRect();
+3 -3
View File
@@ -967,7 +967,7 @@ static uint64_t PageDisabledWidgets[] = {
void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
MapInvalidateSelectionRect();
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
CoordsXY mapCoords;
TileElement* clickedElement = nullptr;
@@ -993,9 +993,9 @@ static uint64_t PageDisabledWidgets[] = {
else if (_tileSelected)
gMapSelectPositionA = gMapSelectPositionB = _toolMap;
else
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
MapInvalidateSelectionRect();
}
+8 -8
View File
@@ -119,8 +119,8 @@ namespace OpenRCT2::Ui::Windows
ClearProvisional();
ViewportSetVisibility(ViewportVisibility::Default);
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
HideGridlines();
_miniPreview.clear();
_miniPreview.shrink_to_fit();
@@ -170,9 +170,9 @@ namespace OpenRCT2::Ui::Windows
TrackDesignState tds{};
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
// Take shift modifier into account
ScreenCoordsXY targetScreenCoords = screenCoords;
@@ -246,9 +246,9 @@ namespace OpenRCT2::Ui::Windows
{
ClearProvisional();
MapInvalidateMapSelectionTiles();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enable);
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
// Take shift modifier into account
ScreenCoordsXY targetScreenCoords = screenCoords;
+4 -4
View File
@@ -218,11 +218,11 @@ namespace OpenRCT2::Ui::Windows
auto mapCoords = ScreenPosToMapPos(screenCoords, &direction);
if (mapCoords.has_value())
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
MapInvalidateTileFull(gMapSelectPositionA);
gMapSelectPositionA = gMapSelectPositionB = mapCoords.value();
MapInvalidateTileFull(mapCoords.value());
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
}
}
@@ -249,12 +249,12 @@ namespace OpenRCT2::Ui::Windows
if (mapCoords)
{
MapInvalidateSelectionRect();
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
gMapSelectPositionA.x = std::min(_selectionStart.x, mapCoords->x);
gMapSelectPositionB.x = std::max(_selectionStart.x, mapCoords->x);
gMapSelectPositionA.y = std::min(_selectionStart.y, mapCoords->y);
gMapSelectPositionB.y = std::max(_selectionStart.y, mapCoords->y);
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MapSelectType::full;
MapInvalidateSelectionRect();
}
}
+8 -8
View File
@@ -201,7 +201,7 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_BACKGROUND:
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
gCurrentToolId = Tool::upDownArrow;
}
@@ -225,7 +225,7 @@ namespace OpenRCT2::Ui::Windows
{
case WIDX_BACKGROUND:
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
gCurrentToolId = Tool::waterDown;
break;
}
@@ -302,7 +302,7 @@ namespace OpenRCT2::Ui::Windows
if (gCurrentToolId == Tool::upDownArrow)
{
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
return;
auto waterLowerAction = GameActions::WaterLowerAction(
@@ -325,7 +325,7 @@ namespace OpenRCT2::Ui::Windows
return;
}
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.unset(MapSelectFlag::enable);
auto info = GetMapCoordinatesFromPos(
screenPos, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water));
@@ -345,15 +345,15 @@ namespace OpenRCT2::Ui::Windows
uint8_t state_changed = 0;
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags.set(MapSelectFlag::enable);
state_changed++;
}
if (gMapSelectType != MAP_SELECT_TYPE_FULL_WATER)
if (gMapSelectType != MapSelectType::fullWater)
{
gMapSelectType = MAP_SELECT_TYPE_FULL_WATER;
gMapSelectType = MapSelectType::fullWater;
state_changed++;
}
+5 -5
View File
@@ -29,7 +29,7 @@
namespace OpenRCT2::GameActions
{
LandLowerAction::LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType)
LandLowerAction::LandLowerAction(const CoordsXY& coords, MapRange range, MapSelectType selectionType)
: _coords(coords)
, _range(range)
, _selectionType(selectionType)
@@ -68,11 +68,11 @@ namespace OpenRCT2::GameActions
Result LandLowerAction::QueryExecute(GameState_t& gameState, bool isExecuting) const
{
auto res = Result();
size_t tableRow = _selectionType;
size_t tableRow = EnumValue(_selectionType);
// The selections between MAP_SELECT_TYPE_FULL and MAP_SELECT_TYPE_EDGE_0 are not included in the tables
if (_selectionType >= MAP_SELECT_TYPE_EDGE_0 && _selectionType <= MAP_SELECT_TYPE_EDGE_3)
tableRow -= MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1;
// The selections between MapSelectType::full and MapSelectType::edge0 are not included in the tables
if (_selectionType >= MapSelectType::edge0 && _selectionType <= MapSelectType::edge3)
tableRow -= EnumValue(MapSelectType::edge0) - EnumValue(MapSelectType::full) - 1;
auto validRange = ClampRangeWithinMap(_range);
+4 -2
View File
@@ -11,6 +11,8 @@
#include "GameAction.h"
enum class MapSelectType : uint8_t;
namespace OpenRCT2::GameActions
{
class LandLowerAction final : public GameActionBase<GameCommand::LowerLand>
@@ -18,11 +20,11 @@ namespace OpenRCT2::GameActions
private:
CoordsXY _coords;
MapRange _range;
uint8_t _selectionType{};
MapSelectType _selectionType{};
public:
LandLowerAction() = default;
LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType);
LandLowerAction(const CoordsXY& coords, MapRange range, MapSelectType selectionType);
void AcceptParameters(GameActionParameterVisitor&) final;
+5 -5
View File
@@ -30,7 +30,7 @@
namespace OpenRCT2::GameActions
{
LandRaiseAction::LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType)
LandRaiseAction::LandRaiseAction(const CoordsXY& coords, MapRange range, MapSelectType selectionType)
: _coords(coords)
, _range(range)
, _selectionType(selectionType)
@@ -69,11 +69,11 @@ namespace OpenRCT2::GameActions
Result LandRaiseAction::QueryExecute(GameState_t& gameState, bool isExecuting) const
{
auto res = Result();
size_t tableRow = _selectionType;
size_t tableRow = EnumValue(_selectionType);
// The selections between MAP_SELECT_TYPE_FULL and MAP_SELECT_TYPE_EDGE_0 are not included in the tables
if (_selectionType >= MAP_SELECT_TYPE_EDGE_0 && _selectionType <= MAP_SELECT_TYPE_EDGE_3)
tableRow -= MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1;
// The selections between MapSelectType::full and MapSelectType::edge0 are not included in the tables
if (_selectionType >= MapSelectType::edge0 && _selectionType <= MapSelectType::edge3)
tableRow -= EnumValue(MapSelectType::edge0) - EnumValue(MapSelectType::full) - 1;
auto validRange = ClampRangeWithinMap(_range);
+4 -2
View File
@@ -11,6 +11,8 @@
#include "GameAction.h"
enum class MapSelectType : uint8_t;
namespace OpenRCT2::GameActions
{
class LandRaiseAction final : public GameActionBase<GameCommand::RaiseLand>
@@ -18,11 +20,11 @@ namespace OpenRCT2::GameActions
private:
CoordsXY _coords;
MapRange _range;
uint8_t _selectionType{};
MapSelectType _selectionType{};
public:
LandRaiseAction() = default;
LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType);
LandRaiseAction(const CoordsXY& coords, MapRange range, MapSelectType selectionType);
void AcceptParameters(GameActionParameterVisitor&) final;
+27 -23
View File
@@ -32,7 +32,7 @@
namespace OpenRCT2::GameActions
{
LandSmoothAction::LandSmoothAction(const CoordsXY& coords, MapRange range, uint8_t selectionType, bool isLowering)
LandSmoothAction::LandSmoothAction(const CoordsXY& coords, MapRange range, MapSelectType selectionType, bool isLowering)
: _coords(coords)
, _range(range)
, _selectionType(selectionType)
@@ -337,7 +337,7 @@ namespace OpenRCT2::GameActions
Result LandSmoothAction::SmoothLand(GameState_t& gameState, bool isExecuting) const
{
const bool raiseLand = !_isLowering;
const int32_t selectionType = _selectionType;
const auto selectionType = _selectionType;
const int32_t heightOffset = raiseLand ? 2 : -2;
auto normRange = _range.Normalise();
@@ -358,7 +358,7 @@ namespace OpenRCT2::GameActions
// Do the smoothing
switch (selectionType)
{
case MAP_SELECT_TYPE_FULL:
case MapSelectType::full:
{
uint8_t minHeight = heightOffset + MapGetLowestLandHeight(validRange);
uint8_t maxHeight = heightOffset + MapGetHighestLandHeight(validRange);
@@ -458,24 +458,25 @@ namespace OpenRCT2::GameActions
}
break;
}
case MAP_SELECT_TYPE_CORNER_0:
case MAP_SELECT_TYPE_CORNER_1:
case MAP_SELECT_TYPE_CORNER_2:
case MAP_SELECT_TYPE_CORNER_3:
case MapSelectType::corner0:
case MapSelectType::corner1:
case MapSelectType::corner2:
case MapSelectType::corner3:
{
auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ validRange.GetLeft(), validRange.GetTop() });
if (surfaceElement == nullptr)
break;
uint8_t newBaseZ = surfaceElement->BaseHeight;
uint8_t newSlope = surfaceElement->GetSlope();
auto direction = static_cast<Direction>(selectionType);
if (raiseLand)
{
newSlope = RaiseSurfaceCornerFlags(selectionType, newSlope);
newSlope = RaiseSurfaceCornerFlags(direction, newSlope);
}
else
{
newSlope = LowerSurfaceCornerFlags(selectionType, newSlope);
newSlope = LowerSurfaceCornerFlags(direction, newSlope);
}
if (newSlope & kTileSlopeRaiseOrLowerBaseHeight)
@@ -501,7 +502,7 @@ namespace OpenRCT2::GameActions
// Smooth the edges
switch (selectionType)
{
case MAP_SELECT_TYPE_CORNER_0:
case MapSelectType::corner0:
z = MapGetCornerHeight(newBaseZ, newSlope, 0);
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 3, 0);
@@ -514,7 +515,7 @@ namespace OpenRCT2::GameActions
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 0, 1);
break;
case MAP_SELECT_TYPE_CORNER_1:
case MapSelectType::corner1:
z = MapGetCornerHeight(newBaseZ, newSlope, 1);
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 2, 1);
@@ -527,7 +528,7 @@ namespace OpenRCT2::GameActions
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 1, 0);
break;
case MAP_SELECT_TYPE_CORNER_2:
case MapSelectType::corner2:
z = MapGetCornerHeight(newBaseZ, newSlope, 2);
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 1, 2);
@@ -540,7 +541,7 @@ namespace OpenRCT2::GameActions
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 2, 3);
break;
case MAP_SELECT_TYPE_CORNER_3:
case MapSelectType::corner3:
z = MapGetCornerHeight(newBaseZ, newSlope, 3);
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 0, 3);
@@ -553,13 +554,15 @@ namespace OpenRCT2::GameActions
res.Cost += SmoothLandRowByCorner(
gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 3, 2);
break;
default:
break;
}
break;
}
case MAP_SELECT_TYPE_EDGE_0:
case MAP_SELECT_TYPE_EDGE_1:
case MAP_SELECT_TYPE_EDGE_2:
case MAP_SELECT_TYPE_EDGE_3:
case MapSelectType::edge0:
case MapSelectType::edge1:
case MapSelectType::edge2:
case MapSelectType::edge3:
{
// TODO: Handle smoothing by edge
// Get the two corners to raise
@@ -568,7 +571,8 @@ namespace OpenRCT2::GameActions
break;
uint8_t newBaseZ = surfaceElement->BaseHeight;
uint8_t oldSlope = surfaceElement->GetSlope();
int32_t rowIndex = selectionType - (MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1);
int32_t rowIndex = EnumValue(selectionType)
- (EnumValue(MapSelectType::edge0) - EnumValue(MapSelectType::full) - 1);
uint8_t newSlope = raiseLand ? RaiseSurfaceCornerFlags(rowIndex, oldSlope)
: LowerSurfaceCornerFlags(rowIndex, oldSlope);
@@ -579,15 +583,15 @@ namespace OpenRCT2::GameActions
newSlope &= ~kTileSlopeRaiseOrLowerBaseHeight;
}
const uint8_t edge = selectionType - MAP_SELECT_TYPE_EDGE_0;
const uint8_t edge = EnumValue(selectionType) - EnumValue(MapSelectType::edge0);
// Table with corners for each edge selection. The first two are the selected corners, the latter
// two are the opposites
static constexpr uint8_t cornerIndices[][4] = {
{ 2, 3, 1, 0 }, // MAP_SELECT_TYPE_EDGE_0
{ 3, 0, 2, 1 }, // MAP_SELECT_TYPE_EDGE_1
{ 0, 1, 3, 2 }, // MAP_SELECT_TYPE_EDGE_2
{ 1, 2, 0, 3 }, // MAP_SELECT_TYPE_EDGE_3
{ 2, 3, 1, 0 }, // MapSelectType::edge0
{ 3, 0, 2, 1 }, // MapSelectType::edge1
{ 0, 1, 3, 2 }, // MapSelectType::edge2
{ 1, 2, 0, 3 }, // MapSelectType::edge3
};
// Big coordinate offsets for the neighbouring tile for the given edge selection
static constexpr CoordsXY stepOffsets[] = {
+4 -2
View File
@@ -11,6 +11,8 @@
#include "GameAction.h"
enum class MapSelectType : uint8_t;
namespace OpenRCT2::GameActions
{
class LandSmoothAction final : public GameActionBase<GameCommand::EditLandSmooth>
@@ -18,7 +20,7 @@ namespace OpenRCT2::GameActions
private:
CoordsXY _coords;
MapRange _range;
uint8_t _selectionType{};
MapSelectType _selectionType{};
bool _isLowering{};
constexpr static StringId kErrorTitles[] = {
@@ -28,7 +30,7 @@ namespace OpenRCT2::GameActions
public:
LandSmoothAction() = default;
LandSmoothAction(const CoordsXY& coords, MapRange range, uint8_t selectionType, bool isLowering);
LandSmoothAction(const CoordsXY& coords, MapRange range, MapSelectType selectionType, bool isLowering);
void AcceptParameters(GameActionParameterVisitor&) final;
+1 -1
View File
@@ -108,7 +108,7 @@ namespace OpenRCT2
gPressedWidget.window_classification = WindowClass::Null;
gPickupPeepImage = ImageId();
ResetTooltipNotShown();
gMapSelectFlags = 0;
gMapSelectFlags.clearAll();
ClearPatrolAreaToRender();
TextinputCancel();
}
+1 -1
View File
@@ -698,7 +698,7 @@ static constexpr float kWindowScrollLocations[][2] = {
MapInvalidateMapSelectionTiles();
// Reset map selection
gMapSelectFlags = 0;
gMapSelectFlags.clearAll();
if (gCurrentToolWidget.widget_index != kWidgetIndexNull)
{
+6 -6
View File
@@ -99,13 +99,13 @@ void VirtualFloorInvalidate(const bool alwaysInvalidate)
CoordsXY min_position = { std::numeric_limits<int32_t>::max(), std::numeric_limits<int32_t>::max() };
CoordsXY max_position = { std::numeric_limits<int32_t>::lowest(), std::numeric_limits<int32_t>::lowest() };
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
min_position = gMapSelectPositionA;
max_position = gMapSelectPositionB;
}
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
for (const auto& tile : gMapSelectionTiles)
{
@@ -168,12 +168,12 @@ bool VirtualFloorTileIsFloor(const CoordsXY& loc)
// and if the current tile is near or on them
// (short-circuit to false otherwise - we don't want to show a second
// virtual floor from e. g. an open ride construction window)
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
return loc >= gMapSelectPositionA - kVirtualFloorBaseSizeXY && loc <= gMapSelectPositionB + kVirtualFloorBaseSizeXY;
}
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
// Check if we are anywhere near the selection tiles (larger scenery / rides)
for (const auto& tile : gMapSelectionTiles)
@@ -201,7 +201,7 @@ static void VirtualFloorGetTileProperties(
*tileOwned = false;
// See if we are a selected tile
if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if ((gMapSelectFlags.has(MapSelectFlag::enable)))
{
if (loc >= gMapSelectPositionA && loc <= gMapSelectPositionB)
{
@@ -210,7 +210,7 @@ static void VirtualFloorGetTileProperties(
}
// See if we are on top of the selection tiles
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
for (const auto& tile : gMapSelectionTiles)
{
@@ -808,7 +808,7 @@ static std::pair<int32_t, int32_t> SurfaceGetHeightAboveWater(
std::optional<colour_t> GetPatrolAreaTileColour(const CoordsXY& pos)
{
bool selected = gMapSelectFlags & MAP_SELECT_FLAG_ENABLE && gMapSelectType == MAP_SELECT_TYPE_FULL
bool selected = gMapSelectFlags.has(MapSelectFlag::enable) && gMapSelectType == MapSelectType::full
&& pos.x >= gMapSelectPositionA.x && pos.x <= gMapSelectPositionB.x && pos.y >= gMapSelectPositionA.y
&& pos.y <= gMapSelectPositionB.y;
@@ -1090,41 +1090,41 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
// ebp[4] = ebp;
// ebp[8] = ebx
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
if (gMapSelectFlags.has(MapSelectFlag::enable))
{
// Loc660FB8:
const CoordsXY& pos = session.MapPosition;
if (pos.x >= gMapSelectPositionA.x && pos.x <= gMapSelectPositionB.x && pos.y >= gMapSelectPositionA.y
&& pos.y <= gMapSelectPositionB.y)
{
const uint16_t mapSelectionType = gMapSelectType;
if (mapSelectionType >= MAP_SELECT_TYPE_EDGE_0)
const auto mapSelectionType = gMapSelectType;
if (mapSelectionType >= MapSelectType::edge0)
{
// Walls
// Loc661089:
const auto fpId = static_cast<FilterPaletteID>(
(((mapSelectionType - MAP_SELECT_TYPE_EDGE_0 + 1) + rotation) & 3)
(((EnumValue(mapSelectionType) - EnumValue(MapSelectType::edge0) + 1) + rotation) & 3)
+ static_cast<uint32_t>(FilterPaletteID::PaletteLandMarker0));
const auto image_id = ImageId(SPR_TERRAIN_SELECTION_EDGE + Byte97B444[surfaceShape], fpId);
PaintAttachToPreviousPS(session, image_id, 0, 0);
}
else if (mapSelectionType >= MAP_SELECT_TYPE_QUARTER_0)
else if (mapSelectionType >= MapSelectType::quarter0)
{
// Loc661051:(no jump)
// Selection split into four quarter segments
const auto fpId = static_cast<FilterPaletteID>(
(((mapSelectionType - MAP_SELECT_TYPE_QUARTER_0) + rotation) & 3)
(((EnumValue(mapSelectionType) - EnumValue(MapSelectType::quarter0)) + rotation) & 3)
+ static_cast<uint32_t>(FilterPaletteID::PaletteQuarterMarker0));
const auto image_id = ImageId(SPR_TERRAIN_SELECTION_QUARTER + Byte97B444[surfaceShape], fpId);
PaintAttachToPreviousPS(session, image_id, 0, 0);
}
else if (mapSelectionType <= MAP_SELECT_TYPE_FULL)
else if (mapSelectionType <= MapSelectType::full)
{
// Corners
uint32_t eax = mapSelectionType;
if (mapSelectionType != MAP_SELECT_TYPE_FULL)
uint32_t eax = EnumValue(mapSelectionType);
if (mapSelectionType != MapSelectType::full)
{
eax = (mapSelectionType + rotation) & 3;
eax = (eax + rotation) & 3;
}
const auto fpId = static_cast<FilterPaletteID>(
@@ -1132,7 +1132,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
const auto image_id = ImageId(SPR_TERRAIN_SELECTION_CORNER + Byte97B444[surfaceShape], fpId);
PaintAttachToPreviousPS(session, image_id, 0, 0);
}
else if (mapSelectionType == MAP_SELECT_TYPE_FULL_LAND_RIGHTS)
else if (mapSelectionType == MapSelectType::fullLandRights)
{
auto [waterHeight, waterSurfaceShape] = SurfaceGetHeightAboveWater(tileElement, height, surfaceShape);
@@ -1164,7 +1164,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
}
}
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
if (gMapSelectFlags.has(MapSelectFlag::enableConstruct))
{
const CoordsXY& pos = session.MapPosition;
@@ -1176,7 +1176,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
}
FilterPaletteID fpId = FilterPaletteID::PaletteSceneryGroundMarker;
if (gMapSelectFlags & MAP_SELECT_FLAG_GREEN)
if (gMapSelectFlags.has(MapSelectFlag::green))
{
fpId = FilterPaletteID::PaletteRideGroundMarker;
}
@@ -163,7 +163,7 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor
int32_t screenMinY = Translate3DTo2DWithZ(rotation, { coords, 0 }).y;
// Display little yellow arrow when building footpaths?
if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_ARROW) && session.MapPosition.x == gMapSelectArrowPosition.x
if ((gMapSelectFlags.has(MapSelectFlag::enableArrow)) && session.MapPosition.x == gMapSelectArrowPosition.x
&& session.MapPosition.y == gMapSelectArrowPosition.y)
{
uint8_t arrowRotation = (rotation + (gMapSelectArrowDirection & 3)) & 3;
+6 -6
View File
@@ -526,7 +526,7 @@ void RideConstructionInvalidateCurrentTrack()
if (_currentTrackSelectionFlags.has(TrackSelectionFlag::arrow))
{
_currentTrackSelectionFlags.unset(TrackSelectionFlag::arrow);
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
MapInvalidateTileFull(_currentTrackBegin);
}
RideConstructionRemoveGhosts();
@@ -769,7 +769,7 @@ void RideSelectNextSection()
}
else if (_rideConstructionState == RideConstructionState::Back)
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
if (RideSelectForwardsFromBack())
{
@@ -825,7 +825,7 @@ void RideSelectPreviousSection()
}
else if (_rideConstructionState == RideConstructionState::Front)
{
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
if (RideSelectBackwardsFromFront())
{
@@ -890,7 +890,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement)
}
WindowRideConstructionUpdateActiveElements();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
}
else
{
@@ -934,7 +934,7 @@ static bool ride_modify_maze(const CoordsXYE& tileElement)
_currentTrackBegin.z = trackElement->GetBaseZ();
_currentTrackSelectionFlags.clearAll();
_rideConstructionNextArrowPulse = 0;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
auto intent = Intent(INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION);
ContextBroadcastIntent(&intent);
@@ -1018,7 +1018,7 @@ bool RideModify(const CoordsXYE& input)
_currentTrackPieceType = type;
_currentTrackSelectionFlags.clearAll();
_rideConstructionNextArrowPulse = 0;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack))
{
+9 -9
View File
@@ -345,9 +345,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con
// Resave global vars for scenery reasons.
tds.origin = startPos;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
gMapSelectFlags.unset(MapSelectFlag::green);
statistics.spaceRequired = TileCoordsXY(tds.previewMax - tds.previewMin) + TileCoordsXY{ 1, 1 };
return { true, warningMessage };
@@ -457,9 +457,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons
TrackDesignPreviewDrawOutlines(tds, *this, RideGetTemporaryForPreview(), { 4096, 4096, 0, _currentTrackPieceDirection });
tds.origin = { startLoc.x, startLoc.y, startZ };
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
gMapSelectFlags.unset(MapSelectFlag::enableArrow);
gMapSelectFlags.unset(MapSelectFlag::green);
statistics.spaceRequired = TileCoordsXY(tds.previewMax - tds.previewMin) + TileCoordsXY{ 1, 1 };
@@ -1806,9 +1806,9 @@ static GameActions::Result TrackDesignPlaceVirtual(
// 0x6D0FE6
if (tds.placeOperation == TrackPlaceOperation::drawOutlines)
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
gMapSelectFlags.set(MapSelectFlag::enableConstruct);
gMapSelectFlags.set(MapSelectFlag::enableArrow);
gMapSelectFlags.unset(MapSelectFlag::green);
MapInvalidateMapSelectionTiles();
}
+4 -4
View File
@@ -12,8 +12,8 @@
#include "../interface/Viewport.h"
#include "Map.h"
uint16_t gMapSelectFlags;
uint16_t gMapSelectType;
MapSelectFlags gMapSelectFlags;
MapSelectType gMapSelectType;
CoordsXY gMapSelectPositionA;
CoordsXY gMapSelectPositionB;
CoordsXYZ gMapSelectArrowPosition;
@@ -27,7 +27,7 @@ std::vector<CoordsXY> gMapSelectionTiles;
*/
void MapInvalidateMapSelectionTiles()
{
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT))
if (!(gMapSelectFlags.has(MapSelectFlag::enableConstruct)))
return;
for (const auto& position : gMapSelectionTiles)
@@ -42,7 +42,7 @@ void MapInvalidateSelectionRect()
{
int32_t x0, y0, x1, y1, left, right, top, bottom;
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
if (!(gMapSelectFlags.has(MapSelectFlag::enable)))
return;
x0 = gMapSelectPositionA.x + 16;
+37 -23
View File
@@ -9,39 +9,53 @@
#pragma once
#include "../core/FlagHolder.hpp"
#include "Location.hpp"
#include <vector>
enum
enum class MapSelectFlag : uint8_t
{
MAP_SELECT_FLAG_ENABLE = 1 << 0,
MAP_SELECT_FLAG_ENABLE_CONSTRUCT = 1 << 1,
MAP_SELECT_FLAG_ENABLE_ARROW = 1 << 2,
MAP_SELECT_FLAG_GREEN = 1 << 3,
enable,
enableConstruct,
enableArrow,
green,
};
using MapSelectFlags = FlagHolder<uint8_t, MapSelectFlag>;
enum
enum class MapSelectType : uint8_t
{
MAP_SELECT_TYPE_CORNER_0,
MAP_SELECT_TYPE_CORNER_1,
MAP_SELECT_TYPE_CORNER_2,
MAP_SELECT_TYPE_CORNER_3,
MAP_SELECT_TYPE_FULL,
MAP_SELECT_TYPE_FULL_WATER,
MAP_SELECT_TYPE_FULL_LAND_RIGHTS,
MAP_SELECT_TYPE_QUARTER_0,
MAP_SELECT_TYPE_QUARTER_1,
MAP_SELECT_TYPE_QUARTER_2,
MAP_SELECT_TYPE_QUARTER_3,
MAP_SELECT_TYPE_EDGE_0,
MAP_SELECT_TYPE_EDGE_1,
MAP_SELECT_TYPE_EDGE_2,
MAP_SELECT_TYPE_EDGE_3,
corner0,
corner1,
corner2,
corner3,
full,
fullWater,
fullLandRights,
quarter0,
quarter1,
quarter2,
quarter3,
edge0,
edge1,
edge2,
edge3,
};
constexpr MapSelectType getMapSelectCorner(Direction direction)
{
return static_cast<MapSelectType>(EnumValue(MapSelectType::corner0) + direction);
}
constexpr MapSelectType getMapSelectQuarter(Direction direction)
{
return static_cast<MapSelectType>(EnumValue(MapSelectType::quarter0) + direction);
}
constexpr MapSelectType getMapSelectEdge(Direction direction)
{
return static_cast<MapSelectType>(EnumValue(MapSelectType::edge0) + direction);
}
extern uint16_t gMapSelectFlags;
extern uint16_t gMapSelectType;
extern MapSelectFlags gMapSelectFlags;
extern MapSelectType gMapSelectType;
extern CoordsXY gMapSelectPositionA;
extern CoordsXY gMapSelectPositionB;
extern CoordsXYZ gMapSelectArrowPosition;
+18 -18
View File
@@ -18,7 +18,7 @@ using namespace OpenRCT2;
// 0x1F = new slope
// 0x20 = base height increases
constexpr uint8_t kTileElementRaiseStyles[9][32] = {
// MAP_SELECT_TYPE_CORNER_0
// MapSelectType::corner0
{ kTileSlopeNCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeWCornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp,
@@ -52,7 +52,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_CORNER_1
// MapSelectType::corner1
{ kTileSlopeECornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp,
@@ -86,7 +86,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_CORNER_2
// MapSelectType::corner2
{ kTileSlopeSCornerUp,
kTileSlopeNCornerUp | kTileSlopeSCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp,
@@ -120,7 +120,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeDiagonalFlag | kTileSlopeECornerUp | kTileSlopeSCornerUp
| kTileSlopeWCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_CORNER_3
// MapSelectType::corner3
{ kTileSlopeWCornerUp,
kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeWCornerUp,
@@ -154,7 +154,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
| kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_FULL
// MapSelectType::full
{ kTileSlopeRaiseOrLowerBaseHeight,
kTileSlopeRaiseOrLowerBaseHeight,
kTileSlopeRaiseOrLowerBaseHeight,
@@ -187,7 +187,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp,
kTileSlopeRaiseOrLowerBaseHeight },
// MAP_SELECT_TYPE_EDGE_0
// MapSelectType::edge0
{ kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
@@ -220,7 +220,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_EDGE_1
// MapSelectType::edge1
{ kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeWCornerUp,
@@ -253,7 +253,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_EDGE_2
// MapSelectType::edge2
{ kTileSlopeNCornerUp | kTileSlopeECornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp,
@@ -286,7 +286,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp },
// MAP_SELECT_TYPE_EDGE_3
// MapSelectType::edge3
{ kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp,
@@ -327,7 +327,7 @@ constexpr uint8_t kTileElementRaiseStyles[9][32] = {
// 0x1F = new slope
// 0x20 = base height increases
constexpr uint8_t kTileElementLowerStyles[9][32] = {
// MAP_SELECT_TYPE_CORNER_0
// MapSelectType::corner0
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
0,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
@@ -365,7 +365,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeDiagonalFlag | kTileSlopeECornerUp | kTileSlopeSCornerUp
| kTileSlopeWCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_CORNER_1
// MapSelectType::corner1
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
0,
@@ -403,7 +403,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
| kTileSlopeWCornerUp,
kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_CORNER_2
// MapSelectType::corner2
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp
| kTileSlopeWCornerUp,
@@ -441,7 +441,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_CORNER_3
// MapSelectType::corner3
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp
@@ -479,7 +479,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeDiagonalFlag | kTileSlopeNCornerUp | kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_FULL
// MapSelectType::full
{ kTileSlopeRaiseOrLowerBaseHeight,
0,
0,
@@ -512,7 +512,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
0 },
// MAP_SELECT_TYPE_EDGE_0
// MapSelectType::edge0
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeECornerUp,
@@ -545,7 +545,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeNCornerUp | kTileSlopeECornerUp },
// MAP_SELECT_TYPE_EDGE_1
// MapSelectType::edge1
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeECornerUp | kTileSlopeSCornerUp,
0,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeECornerUp | kTileSlopeSCornerUp,
@@ -578,7 +578,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeNCornerUp | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp,
kTileSlopeECornerUp | kTileSlopeSCornerUp },
// MAP_SELECT_TYPE_EDGE_2
// MapSelectType::edge2
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeSCornerUp | kTileSlopeWCornerUp,
0,
0,
@@ -611,7 +611,7 @@ constexpr uint8_t kTileElementLowerStyles[9][32] = {
kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeSCornerUp | kTileSlopeWCornerUp,
kTileSlopeSCornerUp | kTileSlopeWCornerUp },
// MAP_SELECT_TYPE_EDGE_3
// MapSelectType::edge3
{ kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeWCornerUp,
kTileSlopeRaiseOrLowerBaseHeight | kTileSlopeNCornerUp | kTileSlopeWCornerUp,
0,