Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
font_editor.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../debug_ui.h"
4 
5 #include "components/3rdparty/imgui/extensions/imgui_extensions.h"
6 
7 using namespace Blam::Content::Fonts;
8 
10 {
17  {
18  private:
19  // nothing here atm
20  char current_font[1024] = "";
21  Font* font = NULL;
22  public:
26  FontEditor() {};
27 
32 
33  void Draw()
34  {
35  if (show)
36  {
37  ImGui::Begin("Font Editor", &show);
38 
39  if (ImGui::BeginCombo("font", current_font))
40  {
41  std::map<std::string, Font>::iterator it;
42 
43  for (it = GetFontList()->begin(); it != GetFontList()->end(); it++)
44  {
45  std::string font_id = it->first;
46 
47  if (ImGui::Selectable(font_id.c_str()))
48  {
49  SetActiveFont(font_id);
50  }
51  }
52 
53  ImGui::EndCombo();
54  }
55 
56  //make sure we only draw controls if font is not null
57  if (font)
58  {
59  ImGui::DragShort("char spacing", &(font->charspacing), 1.0f, 0, 32767);
60  ImGui::DragShort("size", &(font->size), 1.0f, 0, 32767);
61  ImGui::DragShort("char width", &(font->mono_width), 1.0f, 0, 32767);
62  ImGui::SameLine();
63  Widgets::ShowHelpMarker("controls width (in px) each character will be drawn with\r\n\r\nonly applies when monospaced is set to true");
64 
65  ImGui::Checkbox("monospaced", &font->monospaced);
66 
67  if (ImGui::Button("reload"))
68  {
69  std::string font_id = font->id;
70 
72  SetActiveFont(font_id);
73  }
74  }
75 
76  ImGui::End();
77  }
78  }
79 
80  void SetActiveFont(std::string font_id)
81  {
82  memcpy(&current_font, font_id.c_str(), IM_ARRAYSIZE(current_font));
83 
84  font = GetFont(font_id);
85  }
86  };
87 }
Blam::Content::Fonts::ReloadFont
BLAM HRESULT ReloadFont(std::string id)
Reloads all data for the specified font.
Definition: fonts.cpp:867
Blam::DebugUI::Windows::FontEditor::~FontEditor
~FontEditor()
Empty destructor.
Definition: font_editor.hpp:31
Blam::DebugUI::Widgets::ShowHelpMarker
BLAM void ShowHelpMarker(const char *desc)
Shows a help indicator.
Definition: widgets.cpp:7
Blam::DebugUI::Windows::FontEditor
Class for the Font Editor.
Definition: font_editor.hpp:16
Blam::Content::Fonts::GetFontList
BLAM std::map< std::string, Font > * GetFontList()
Retrieves the list of loaded fonts.
Definition: fonts.cpp:835
Blam::DebugUI::Windows::FontEditor::FontEditor
FontEditor()
Empty constructor.
Definition: font_editor.hpp:26
Blam::Content::Fonts::GetFont
BLAM Font * GetFont(std::string id)
Retrieves a font from the list of loaded fonts.
Definition: fonts.cpp:806
Blam::Content::Fonts::Font::charspacing
short charspacing
The amount of space, in pixels, between each character.
Definition: fonts.h:78
Blam::DebugUI::Windows::FontEditor::SetActiveFont
void SetActiveFont(std::string font_id)
Definition: font_editor.hpp:80
Blam::Content::Fonts::Font::size
short size
The size of the font.
Definition: fonts.h:77
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
Blam::Content::Fonts::Font::monospaced
bool monospaced
Whether or not to treat the font as a monospace font.
Definition: fonts.h:79
Blam::Content::Fonts::Font::mono_width
short mono_width
The width for each character to be. Extra space will be left as needed if the glyph width is too smal...
Definition: fonts.h:80
Blam::Content::Fonts::Font
Structure to contain data for a Font.
Definition: fonts.h:68
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:434
Blam::Content::Fonts
Definition: fonts.h:33
Blam::Content::Fonts::Font::id
std::string id
The unique ID of the font.
Definition: fonts.h:76
Blam::DebugUI::Windows::FontEditor::Draw
void Draw()
Draws the contents of the group.
Definition: font_editor.hpp:33