Elaztek Developer Hub
Blamite Game Engine - blam!  00346.12.11.21.0529.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 
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 
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);
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
ImGui::Checkbox
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition: imgui_widgets.cpp:974
Blam::Content::Fonts::GetFontList
BLAM std::map< std::string, Font > * GetFontList()
Retrieves the list of loaded fonts.
Definition: fonts.cpp:835
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
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
ImGui::SameLine
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f)
Definition: imgui.cpp:7147
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
Blam::DebugUI::Windows::FontEditor::SetActiveFont
void SetActiveFont(std::string font_id)
Definition: font_editor.hpp:80
NULL
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
ImGui::BeginCombo
IMGUI_API bool BeginCombo(const char *label, const char *preview_value, ImGuiComboFlags flags=0)
Definition: imgui_widgets.cpp:1416
ImGui::Selectable
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:5469
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
Blam::Content::Fonts::Font
Structure to contain data for a Font.
Definition: fonts.h:70
IM_ARRAYSIZE
#define IM_ARRAYSIZE(_ARR)
Definition: imgui.h:75
ImGui::EndCombo
IMGUI_API void EndCombo()
Definition: imgui_widgets.cpp:1522
ImGui::DragShort
IMGUI_API bool DragShort(const char *label, short *v, float v_speed=1.0f, short v_min=0, short v_max=0, const char *format="%d")
Definition: imgui_extensions.cpp:3
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: ui.h:14
Blam::Content::Fonts
Definition: fonts.h:35
font
io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels,...) font
Definition: README.txt:86
Blam::DebugUI::Windows::FontEditor::Draw
void Draw()
Draws the contents of the group.
Definition: font_editor.hpp:33
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644
imgui_extensions.h