show threat rate in debug output
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QPolygonF>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
|
||||
#include "BeltSystem.h"
|
||||
@@ -924,10 +925,18 @@ void GameWorldView::drawDebugOverlay(QPainter& painter)
|
||||
{
|
||||
painter.resetTransform();
|
||||
|
||||
const QString line1 = tr("Accumulated Threat Level: %1")
|
||||
.arg(m_sim->threatLevel(), 0, 'f', 1);
|
||||
const QString line2 = tr("Time until Wave: %1s")
|
||||
.arg(ticksToSeconds(m_sim->normalGapRemainingTicks()), 0, 'f', 1);
|
||||
const QStringList lines = {
|
||||
tr("Accumulated Threat Level: %1")
|
||||
.arg(m_sim->threatLevel(), 0, 'f', 1),
|
||||
tr("Time until Wave: %1s")
|
||||
.arg(ticksToSeconds(m_sim->normalGapRemainingTicks()), 0, 'f', 1),
|
||||
tr("Threat Accumulation Rate: %1 threat/s")
|
||||
.arg(m_sim->threatAccumulationRate(), 0, 'f', 1),
|
||||
tr("Max Factory Production: %1 threat/s")
|
||||
.arg(m_sim->maxFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
tr("Current Factory Production: %1 threat/s")
|
||||
.arg(m_sim->currentFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
};
|
||||
|
||||
QFont font = painter.font();
|
||||
font.setPointSize(m_visuals->toast.fontSize);
|
||||
@@ -937,19 +946,26 @@ void GameWorldView::drawDebugOverlay(QPainter& painter)
|
||||
const int lineH = fm.height();
|
||||
const int padding = 8;
|
||||
const int spacing = 4;
|
||||
const int textW = std::max(fm.horizontalAdvance(line1),
|
||||
fm.horizontalAdvance(line2));
|
||||
|
||||
int textW = 0;
|
||||
for (const QString& line : lines)
|
||||
{
|
||||
textW = std::max(textW, fm.horizontalAdvance(line));
|
||||
}
|
||||
const int bgW = textW + padding * 2;
|
||||
const int bgH = lineH * 2 + spacing + padding * 2;
|
||||
const int bgH = lineH * lines.size() + spacing * (lines.size() - 1) + padding * 2;
|
||||
|
||||
const QRect bgRect(padding, padding, bgW, bgH);
|
||||
painter.fillRect(bgRect, QColor(0, 0, 0, 160));
|
||||
|
||||
painter.setPen(Qt::white);
|
||||
const QRect textRect1(padding * 2, padding + padding, textW, lineH);
|
||||
const QRect textRect2(padding * 2, textRect1.bottom() + spacing, textW, lineH);
|
||||
painter.drawText(textRect1, Qt::AlignLeft | Qt::AlignVCenter, line1);
|
||||
painter.drawText(textRect2, Qt::AlignLeft | Qt::AlignVCenter, line2);
|
||||
int y = padding * 2;
|
||||
for (const QString& line : lines)
|
||||
{
|
||||
const QRect textRect(padding * 2, y, textW, lineH);
|
||||
painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, line);
|
||||
y += lineH + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
void GameWorldView::drawBeams(QPainter& painter)
|
||||
|
||||
Reference in New Issue
Block a user