Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
crash_screen.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <sstream>
4 #include <iomanip>
5 
6 #include "../../render_stack.h"
7 #include "components/core/config/config.h"
8 #include "components/3rdparty/imgui/imgui.h"
9 
11 {
13  {
14  private:
15  BitmapText* crash_message;
16 
17  public:
19  {
21 
22  stats = new BitmapText();
23 
24  stats->font_id = Blam::Config::GetConfig()->GetString("ui_default_font");
25  stats->use_shadow = true;
26  stats->color = D2D1::ColorF(1, 1, 1, 1);
27 
28  stats->SetTranslation(10, 30);
29 
30  //BlamRendering::RenderStack::AddToStack("stats", stats);
31  }
32 
34  {
35  delete stats;
36  delete this;
37  }
38 
39  void Draw()
40  {
41  stats->visible = visible;
42 
43  if (visible)
44  {
45  // We aren't actually drawing anything, just updating fps counter data
46 
47  std::stringstream fps_stream;
48  fps_stream << std::fixed << std::setprecision(2) << ImGui::GetIO().Framerate;
49  std::string fps = fps_stream.str();
50 
51  if (ImGui::GetIO().Framerate >= 30)
52  {
53  stats->color = D2D1::ColorF(0, 1, 0, 1);
54  }
55  else if (ImGui::GetIO().Framerate < 15)
56  {
57  stats->color = D2D1::ColorF(1, 0, 0, 1);
58  }
59  else if (ImGui::GetIO().Framerate < 30)
60  {
61  stats->color = D2D1::ColorF(1, 1, 0, 1);
62  }
63 
64  stats->text = "fps: " + fps + "";
65  }
66 
67  stats->Draw();
68  }
69 
71  {
72 
73  }
74  };
75 }
BlamRendering::RenderStack::CrashScreen::ShowImPropertyEditor
void ShowImPropertyEditor()
Shows a set of ImGUI properties associated with the object.
Definition: crash_screen.hpp:70
BlamRendering::RenderStack::StackObjectBase::visible
bool visible
Whether or not the object is visible.
Definition: render_stack.h:375
Blam::EngineDefs::CrashScreen
@ CrashScreen
Definition: engine_definitions.h:100
BitmapText
@ BitmapText
Bitmap-based text, uses Blamite font system.
Definition: render_stack.h:72
BlamRendering::RenderStack::StackObjectBase::type_label
StackType type_label
The type of the object.
Definition: render_stack.h:372
Blam::Config::GetConfig
BLAM ConfigFile * GetConfig()
Definition: compat.cpp:5
BlamRendering::RenderStack
Namespace containing things relating to the Render Stack.
Definition: drawing.h:14
BlamRendering::RenderStack::CrashScreen::~CrashScreen
~CrashScreen()
Definition: crash_screen.hpp:33
BlamRendering::RenderStack::CrashScreen::CrashScreen
CrashScreen()
Definition: crash_screen.hpp:18
BlamRendering::RenderStack::CrashScreen::Draw
void Draw()
Draws the stack object.
Definition: crash_screen.hpp:39
Blam::Config::ConfigFile::GetString
std::string GetString(std::string option)
Definition: compat.cpp:58
BlamRendering::RenderStack::BitmapText
Class representing text drawn using a Bitmap-based engine font.
Definition: render_stack.h:794
BlamRendering::RenderStack::StackObjectBase
Base class for all render stack objects.
Definition: render_stack.h:194
BlamRendering::RenderStack::CrashScreen
Definition: crash_screen.hpp:12