forked from bobsayshilol/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinfo_cluster.cpp
More file actions
106 lines (86 loc) · 2.89 KB
/
info_cluster.cpp
File metadata and controls
106 lines (86 loc) · 2.89 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "../include/info_cluster.h"
#include "../include/engine_sim_application.h"
#include <sstream>
#include <iomanip>
InfoCluster::InfoCluster() {
m_engine = nullptr;
m_logMessage = "Started";
}
InfoCluster::~InfoCluster() {
/* void */
}
void InfoCluster::initialize(EngineSimApplication *app) {
UiElement::initialize(app);
}
void InfoCluster::destroy() {
UiElement::destroy();
}
void InfoCluster::update(float dt) {
UiElement::update(dt);
}
void InfoCluster::render() {
Grid grid;
grid.h_cells = 6;
grid.v_cells = 4;
const Bounds logoBounds = grid.get(m_bounds, 0, 0, 1, 2);
drawFrame(logoBounds, 1.0f, m_app->getWhite(), m_app->getBackgroundColor());
drawModel(
m_app->getAssetManager()->GetModelAsset("Logo"),
m_app->getWhite(),
logoBounds.getPosition(Bounds::center),
Point(logoBounds.height(), logoBounds.height()) * 0.75f);
const Bounds titleBounds = grid.get(m_bounds, 1, 0, 5, 2);
drawFrame(titleBounds, 1.0f, m_app->getWhite(), m_app->getBackgroundColor());
Grid titleSplit;
titleSplit.h_cells = 1;
titleSplit.v_cells = 3;
drawAlignedText(
"ENGINE SIMULATOR",
titleSplit.get(titleBounds, 0, 0).inset(10.0f).move({ 0.0f, -21.0f }),
42.0f,
Bounds::bl,
Bounds::bl);
drawAlignedText(
"YOUTUBE/ANGETHEGREAT",
titleSplit.get(titleBounds, 0, 1).inset(10.0f).move({ 0.0f, 5.0f }),
24.0f,
Bounds::tl,
Bounds::tl);
drawAlignedText(
"BUILD: v" + EngineSimApplication::getBuildVersion() + " // " __DATE__,
titleSplit.get(titleBounds, 0, 2).inset(10.0f).move({ 0.0f, 10.0f }),
16.0f,
Bounds::tl,
Bounds::tl);
const Bounds engineInfoBounds = grid.get(m_bounds, 0, 2, 6, 1);
drawFrame(engineInfoBounds, 1.0f, m_app->getWhite(), m_app->getBackgroundColor());
drawAlignedText(
m_engine->getName(),
engineInfoBounds.inset(10.0f),
24.0f,
Bounds::lm,
Bounds::lm);
std::stringstream ss;
ss << std::fixed;
if (m_engine->getDisplacement() < units::volume(1.0, units::L)) {
ss << std::setprecision(0) << units::convert(m_engine->getDisplacement(), units::cc) << " cc -- ";
}
else {
ss << std::setprecision(1) << units::convert(m_engine->getDisplacement(), units::L) << " L -- ";
}
ss << std::setprecision(0) << units::convert(m_engine->getDisplacement(), units::cubic_inches) << " CI";
drawAlignedText(
ss.str(),
engineInfoBounds.inset(10.0f),
24.0f,
Bounds::rm,
Bounds::rm);
const Bounds infoMessagesBounds = grid.get(m_bounds, 0, 3, 6, 1);
drawFrame(infoMessagesBounds, 1.0f, m_app->getWhite(), m_app->getBackgroundColor());
drawAlignedText(
m_logMessage,
infoMessagesBounds.inset(10.0f),
24.0f,
Bounds::lm,
Bounds::lm);
}