Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
font_editor.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
7 
14 {
15 private:
16  std::string current_font_name = "<choose>";
17  BlamFontPackage* font = nullptr;
18 
19 public:
20  void Draw()
21  {
22  if (!show)
23  {
24  return;
25  }
26 
27  ImGui::Begin("Font Editor", &show);
28 
29  if (ImGui::BeginCombo("font", current_font_name.c_str()))
30  {
31  BlamMap<std::string, BlamFontPackage*> font_list = Blam::Content::Fonts::GetFontList();
32 
33  for (std::string font_name : font_list.KeySet())
34  {
35  BlamFontPackage* font_package = font_list.At(font_name);
36 
37  if (ImGui::Selectable(font_package->name.c_str()))
38  {
39  SetActiveFont(font_package->name, font_package);
40  }
41  }
42 
44  }
45 
46  if (font)
47  {
48  ImGui::DragInt("char spacing", &font->charspacing, 1.0f, 0, 32767);
49  ImGui::DragInt("line height", &font->line_height, 1.0f, 0, 32767);
50  ImGui::DragInt("monospace width", &font->monospace_width, 1.0f, 0, 32767);
52  Blam::UI::ImGUI::Widgets::ShowHelpMarker("controls width (in px) each character will be drawn with\r\n\r\nonly applies when monospaced is set to true");
53 
54  ImGui::Checkbox("monospaced", &font->monospace);
55 
56  if (ImGui::Button("reload"))
57  {
58  //std::string font_id = font->id;
59  //
60  //Blam::Content::Fonts::ReloadFont(font_id);
61  //SetActiveFont(font_id);
62  Blam::Logger::LogEvent("unavailable");
63  }
64  }
65 
66  ImGui::End();
67  }
68 
75  void SetActiveFont(std::string font_id, BlamFontPackage* font_package)
76  {
77  current_font_name = font_id;
78  font = font_package;
79  }
80 };
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
font
io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels,...) font
Definition: README.txt:86
ImGui::Checkbox
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition: imgui_widgets.cpp:974
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
BlamImGuiWindow_FontEditor
Class for the Font Editor.
Definition: font_editor.hpp:13
BlamFontPackage::name
std::string name
The name/ID of the font. Must be unique.
Definition: fonts.h:89
BlamFontPackage
Class representing a Blamite font package.
Definition: fonts.h:86
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ImGui::DragInt
IMGUI_API bool DragInt(const char *label, int *v, float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d")
Definition: imgui_widgets.cpp:2209
ImGui::SameLine
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f)
Definition: imgui.cpp:7147
BlamImGuiWindow
Class representing an ImGUI window.
Definition: imgui.h:31
Blam::UI::ImGUI::Widgets::ShowHelpMarker
BLAM void ShowHelpMarker(const char *desc)
Shows a help indicator.
Definition: widgets.cpp:7
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
BlamImGuiWindow_FontEditor::SetActiveFont
void SetActiveFont(std::string font_id, BlamFontPackage *font_package)
Updates the currently selected font package.
Definition: font_editor.hpp:75
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::Content::Fonts::GetFontList
BLAM BlamMap< std::string, BlamFontPackage * > GetFontList()
Retrieves the map of all available fonts.
Definition: fonts.cpp:734
ImGui::EndCombo
IMGUI_API void EndCombo()
Definition: imgui_widgets.cpp:1522
imgui.h
fonts.h
BlamImGuiWindow_FontEditor::Draw
void Draw()
Draws the contents of the group.
Definition: font_editor.hpp:20
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644
imgui_extensions.h