-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugInfoObject.cpp
More file actions
54 lines (43 loc) · 1.16 KB
/
DebugInfoObject.cpp
File metadata and controls
54 lines (43 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "stdafx.h"
#include "DebugInfoObject.h"
#include "GObjectHandler.h"
using namespace LarasEngine;
DebugInfoObject::DebugInfoObject ()
: GameObject (0, 0, TYPID_DEBUG_INFO, false)
{
textRect.setWidth (screenW / 4);
textRect.setHeight (screenH / 2);
font = QApplication::font ();
font.setPointSize (12);
}
void DebugInfoObject::Draw (QPainter* painter)
{
painter->save ();
painter->setPen (Qt::red);
painter->setFont (font);
QRectF r = textRect;
r.translate (GetPosition ());
painter->drawText (r, Qt::AlignLeft, text);
painter->restore ();
GameObject::Draw (painter);
}
void DebugInfoObject::Update ()
{
text = GetFpsAsString ();
text += GetObjectVecAsString ();
}
QString DebugInfoObject::GetFpsAsString () const
{
QString text;
qint64 frameTime = TimeInfo::Me ().GetFrameTime ();
text += "Frametime: " + QString::number (frameTime) + "\n";
text += "FPS: " + QString::number (std::floor (1000.f / frameTime)) + "\n";
return text;
}
QString DebugInfoObject::GetObjectVecAsString () const
{
QString text;
for (const auto& i : LE_OH.GetMap ())
text += QString::fromStdString (i.first) + ": " + QString::number (i.second.size()) + "\n";
return text;
}