MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / mapWindowPosToLocation

Function mapWindowPosToLocation

src/OpenLoco/src/Ui/Windows/MapWindow.cpp:129–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127 );
128
129 static Pos2 mapWindowPosToLocation(Point pos)
130 {
131 pos.x = ((pos.x + 8) - kMapColumns) / 2;
132 pos.y = ((pos.y + 8)) / 2;
133 Pos2 location = { static_cast<coord_t>(pos.y - pos.x), static_cast<coord_t>(pos.x + pos.y) };
134 location.x *= kTileSize;
135 location.y *= kTileSize;
136
137 switch (getCurrentRotation())
138 {
139 case 0:
140 return location;
141 case 1:
142 return { static_cast<coord_t>(kMapWidth - 1 - location.y), location.x };
143 case 2:
144 return { static_cast<coord_t>(kMapWidth - 1 - location.x), static_cast<coord_t>(kMapHeight - 1 - location.y) };
145 case 3:
146 return { location.y, static_cast<coord_t>(kMapHeight - 1 - location.x) };
147 }
148
149 return { 0, 0 }; // unreachable
150 }
151
152 static Point locationToMapWindowPos(Pos2 pos)
153 {

Callers 1

scrollMouseDownFunction · 0.85

Calls 1

getCurrentRotationFunction · 0.85

Tested by

no test coverage detected