MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / render

Method render

game/ui/tileview/citytileview.cpp:296–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296void CityTileView::render()
297{
298 Renderer &r = *fw().renderer;
299 r.clear();
300
301 // Rotate Icons
302 {
303 selectionFrameTicksAccumulated++;
304 selectionFrameTicksAccumulated %= 2 * SELECTION_FRAME_ANIMATION_DELAY;
305 portalImageTicksAccumulated++;
306 portalImageTicksAccumulated %=
307 state.city_common_image_list->portalStrategic.size() * PORTAL_FRAME_ANIMATION_DELAY;
308 }
309
310 // screenOffset.x/screenOffset.y is the 'amount added to the tile coords' - so we want
311 // the inverse to tell which tiles are at the screen bounds
312 auto topLeft = offsetScreenToTileCoords(Vec2<int>{-isoTileSize.x, -isoTileSize.y}, 0);
313 auto topRight = offsetScreenToTileCoords(Vec2<int>{dpySize.x, -isoTileSize.y}, 0);
314 auto bottomLeft = offsetScreenToTileCoords(Vec2<int>{-isoTileSize.x, dpySize.y}, map.size.z);
315 auto bottomRight = offsetScreenToTileCoords(Vec2<int>{dpySize.x, dpySize.y}, map.size.z);
316
317 int minX = std::max(0, topLeft.x);
318 int maxX = std::min(map.size.x, bottomRight.x);
319
320 int minY = std::max(0, topRight.y);
321 int maxY = std::min(map.size.y, bottomLeft.y);
322
323 switch (this->viewMode)
324 {
325 case TileViewMode::Isometric:
326 {
327 r.setPalette(this->pal);
328
329 // List of vehicles that require drawing of brackets
330 std::set<sp<Vehicle>> vehiclesToDrawBrackets;
331 std::map<sp<Vehicle>, int> vehiclesBracketsIndex;
332
333 // Go through every selected vehicle and add target to list of bracket draws
334 for (auto &vehicle : state.current_city->cityViewSelectedVehicles)
335 {
336 if (vehicle->owner != state.getPlayer())
337 {
338 continue;
339 }
340 for (auto &m : vehicle->missions)
341 {
342 if (m.type == VehicleMission::MissionType::AttackVehicle ||
343 m.type == VehicleMission::MissionType::RecoverVehicle)
344 {
345 if (m.targetVehicle)
346 {
347 vehiclesToDrawBrackets.insert(m.targetVehicle);
348 vehiclesBracketsIndex[m.targetVehicle] = 2;
349 }
350 }
351 else if (m.type == VehicleMission::MissionType::FollowVehicle)
352 {
353 if (m.targetVehicle)

Callers

nothing calls this directly

Calls 15

ColourClass · 0.85
getPlayerMethod · 0.80
insertMethod · 0.80
getLayerCountMethod · 0.80
getTileMethod · 0.80
getCenterMethod · 0.80
getVehicleMethod · 0.80
emptyMethod · 0.80
endMethod · 0.80
getVoxelMapFacingMethod · 0.80
isRelatedToMethod · 0.80

Tested by

no test coverage detected