MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / renderDebug

Method renderDebug

source/frontend/StarMainInterface.cpp:1371–1457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1369}
1370
1371void MainInterface::renderDebug() {
1372 if (!isDebugDisplayed()) {
1373 SpatialLogger::clear();
1374 m_debugTextRect = RectF::null();
1375 LogMap::clear();
1376 SpatialLogger::setObserved(false);
1377 return;
1378 }
1379 SpatialLogger::setObserved(true);
1380
1381 if (m_clientCommandProcessor->debugHudEnabled()) {
1382 auto assets = Root::singleton().assets();
1383 m_guiContext->setTextStyle(m_config->debugTextStyle);
1384 m_guiContext->setLineSpacing(0.5f);
1385
1386 bool clearMap = m_debugMapClearTimer.wrapTick();
1387 auto logMapValues = LogMap::getValues();
1388 if (clearMap)
1389 LogMap::clear();
1390
1391 List<String> formatted;
1392 formatted.reserve(logMapValues.size());
1393
1394 int counter = 0;
1395 for (auto const& pair : logMapValues) {
1396 TextPositioning positioning = { Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->textStyle.fontSize * interfaceScale() * counter++) };
1397 String& text = formatted.emplace_back(strf("{}^lightgray;:^green,set; {}", pair.first, pair.second));
1398 m_debugTextRect.combine(m_guiContext->determineTextSize(text, positioning).padded(m_config->debugBackgroundPad));
1399 }
1400
1401 if (!m_debugTextRect.isNull()) {
1402 RenderQuad& quad = m_guiContext->renderer()->immediatePrimitives()
1403 .emplace_back(std::in_place_type_t<RenderQuad>(), m_debugTextRect, m_config->debugBackgroundColor.toRgba(), 0.0f).get<RenderQuad>();
1404
1405 quad.b.color[3] = quad.c.color[3] = 0;
1406 };
1407
1408 m_debugTextRect = RectF::null();
1409
1410 for (size_t index = 0; index != formatted.size(); ++index) {
1411 TextPositioning positioning = { Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->textStyle.fontSize * interfaceScale() * index) };
1412 m_guiContext->renderText(formatted[index], positioning);
1413 }
1414 }
1415
1416 auto const& camera = m_worldPainter->camera();
1417
1418 bool clearSpatial = m_debugSpatialClearTimer.wrapTick();
1419
1420 for (auto const& line : SpatialLogger::getLines("world", clearSpatial)) {
1421 Vec2F begin = camera.worldToScreen(line.begin);
1422 Vec2F end = camera.worldGeometry().diff(line.end, line.begin) * camera.pixelRatio() * TilePixels + begin;
1423 m_guiContext->drawLine(begin, end, line.color, 1);
1424 }
1425
1426 for (auto const& line : SpatialLogger::getLines("screen", clearSpatial))
1427 m_guiContext->drawLine(Vec2F(line.begin), Vec2F(line.end), line.color, 1);
1428

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
strfFunction · 0.85
debugHudEnabledMethod · 0.80
assetsMethod · 0.80
setTextStyleMethod · 0.80
wrapTickMethod · 0.80
paddedMethod · 0.80
toRgbaMethod · 0.80
worldToScreenMethod · 0.80
worldGeometryMethod · 0.80
pixelRatioMethod · 0.80
setLineSpacingMethod · 0.45

Tested by

no test coverage detected