Peoplemon  0.1.0
Peoplemon 3 game source documentation
DebugBanner.cpp
Go to the documentation of this file.
2 
3 #include <Core/Properties.hpp>
4 
5 #ifdef PEOPLEMON_DEBUG
6 
7 namespace core
8 {
9 namespace debug
10 {
11 DebugBanner* DebugBanner::banner = nullptr;
12 
13 DebugBanner::DebugBanner()
14 : engine(nullptr)
15 , showing(false)
16 , displayTime(0.f)
17 , timeout(2.f) {
18  banner = this;
19 }
20 
21 void DebugBanner::display(const std::string& m, float time) {
22  auto& t = banner->text;
23 
24  if (t.entity() == bl::ecs::InvalidEntity) {
25  t.create(*banner->engine, Properties::MenuFont(), m, 20, sf::Color::Cyan);
26  t.getSection().setOutlineColor(sf::Color::Black);
27  t.getSection().setOutlineThickness(2.f);
28  }
29  else { t.getSection().setString(m); }
30 
31  t.getTransform().setPosition(
32  static_cast<float>(Properties::WindowWidth() - t.getLocalBounds().width - 10.f), 10.f);
33  t.addToScene(banner->engine->renderer().getObserver().getOrCreateSceneOverlay(),
34  bl::rc::UpdateSpeed::Static);
35  banner->timeout = time;
36  banner->displayTime = 0.f;
37  banner->showing = true;
38 }
39 
40 void DebugBanner::init(bl::engine::Engine& e) { engine = &e; }
41 
42 void DebugBanner::update(std::mutex&, float dt, float, float, float) {
43  if (showing) {
44  displayTime += dt;
45  if (displayTime >= timeout) {
46  showing = false;
47  text.removeFromScene();
48  }
49  }
50 }
51 
52 } // namespace debug
53 } // namespace core
54 
55 #endif
Core classes and functionality for both the editor and game.