MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / DrawView

Function DrawView

Source/engine/render/scrollrt.cpp:1160–1292  ·  view source on GitHub ↗

* @brief Start rendering of screen, town variation * @param out Buffer to render to * @param startPosition Center of view in dPiece coordinates */

Source from the content-addressed store, hash-verified

1158 * @param startPosition Center of view in dPiece coordinates
1159 */
1160void DrawView(const Surface &out, Point startPosition)
1161{
1162#ifdef _DEBUG
1163 DebugCoordsMap.clear();
1164#endif
1165 Displacement offset = {};
1166 CalcFirstTilePosition(startPosition, offset);
1167 DrawGame(out, startPosition, offset);
1168 if (AutomapActive) {
1169 DrawAutomap(out.subregionY(0, gnViewportHeight));
1170 }
1171#ifdef _DEBUG
1172 bool debugGridTextNeeded = IsDebugGridTextNeeded();
1173 if (debugGridTextNeeded || DebugGrid) {
1174 // force redrawing or debug stuff stays on panel on 640x480 resolution
1175 RedrawEverything();
1176 char debugGridTextBuffer[10];
1177 bool megaTiles = IsDebugGridInMegatiles();
1178
1179 for (auto m : DebugCoordsMap) {
1180 Point dunCoords = { m.first % MAXDUNX, m.first / MAXDUNX };
1181 if (megaTiles && (dunCoords.x % 2 == 1 || dunCoords.y % 2 == 1))
1182 continue;
1183 Point pixelCoords = m.second;
1184 if (megaTiles)
1185 pixelCoords += Displacement { 0, TILE_HEIGHT / 2 };
1186 if (*sgOptions.Graphics.zoom)
1187 pixelCoords *= 2;
1188 if (debugGridTextNeeded && GetDebugGridText(dunCoords, debugGridTextBuffer)) {
1189 Size tileSize = { TILE_WIDTH, TILE_HEIGHT };
1190 if (*sgOptions.Graphics.zoom)
1191 tileSize *= 2;
1192 DrawString(out, debugGridTextBuffer, { pixelCoords - Displacement { 0, tileSize.height }, tileSize }, { UiFlags::ColorRed | UiFlags::AlignCenter | UiFlags::VerticalCenter });
1193 }
1194 if (DebugGrid) {
1195 auto DrawDebugSquare = [&out](Point center, Displacement hor, Displacement ver, uint8_t col) {
1196 auto DrawLine = [&out](Point from, Point to, uint8_t col) {
1197 int dx = to.x - from.x;
1198 int dy = to.y - from.y;
1199 int steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
1200 float ix = dx / (float)steps;
1201 float iy = dy / (float)steps;
1202 float sx = from.x;
1203 float sy = from.y;
1204
1205 for (int i = 0; i <= steps; i++, sx += ix, sy += iy)
1206 out.SetPixel({ (int)sx, (int)sy }, col);
1207 };
1208 DrawLine(center - hor, center + ver, col);
1209 DrawLine(center + hor, center + ver, col);
1210 DrawLine(center - hor, center - ver, col);
1211 DrawLine(center + hor, center - ver, col);
1212 };
1213
1214 Displacement hor = { TILE_WIDTH / 2, 0 };
1215 Displacement ver = { 0, TILE_HEIGHT / 2 };
1216 if (*sgOptions.Graphics.zoom) {
1217 hor *= 2;

Callers 1

DrawAndBlitFunction · 0.85

Calls 15

CalcFirstTilePositionFunction · 0.85
DrawGameFunction · 0.85
DrawAutomapFunction · 0.85
IsDebugGridTextNeededFunction · 0.85
RedrawEverythingFunction · 0.85
IsDebugGridInMegatilesFunction · 0.85
GetDebugGridTextFunction · 0.85
DrawItemNameLabelsFunction · 0.85
DrawMonsterHealthBarFunction · 0.85
DrawFloatingNumbersFunction · 0.85
DrawSTextFunction · 0.85
DrawInvFunction · 0.85

Tested by

no test coverage detected