Skip to content

Commit

Permalink
Render selection grid for Map ownership on the water
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast committed Jan 29, 2024
1 parent fc1b580 commit 8bd80c8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/openrct2-ui/windows/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,24 +430,29 @@ class MapWindow final : public Window
{
MapInvalidateSelectionRect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
auto mapCoords = ScreenGetMapXY(screenCoords, nullptr);
if (!mapCoords.has_value())

auto info = GetMapCoordinatesFromPos(
screenCoords, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water));
if (info.SpriteType == ViewportInteractionItem::None)
return;

auto mapCoords = info.Loc;

gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MAP_SELECT_TYPE_FULL_LAND_RIGHTS;

int32_t landRightsToolSize = _landRightsToolSize;
if (landRightsToolSize == 0)
landRightsToolSize = 1;

int32_t size = (landRightsToolSize * 32) - 32;
int32_t radius = (landRightsToolSize * 16) - 16;
mapCoords->x = (mapCoords->x - radius) & 0xFFE0;
mapCoords->y = (mapCoords->y - radius) & 0xFFE0;
gMapSelectPositionA = *mapCoords;
gMapSelectPositionB.x = mapCoords->x + size;
gMapSelectPositionB.y = mapCoords->y + size;
mapCoords.x -= radius;
mapCoords.y -= radius;
mapCoords = mapCoords.ToTileStart();
gMapSelectPositionA = mapCoords;
gMapSelectPositionB.x = mapCoords.x + size;
gMapSelectPositionB.y = mapCoords.y + size;
MapInvalidateSelectionRect();
}

Expand Down Expand Up @@ -687,7 +692,7 @@ class MapWindow final : public Window

MapInvalidateSelectionRect();
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectType = MAP_SELECT_TYPE_FULL_LAND_RIGHTS;
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
MapInvalidateSelectionRect();
Expand Down

0 comments on commit 8bd80c8

Please sign in to comment.