Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.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
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
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
NULL
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
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
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
it
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font or adding deleting some characters in from glyph table PL means Public License Copyright Holder means whoever is named in the copyright or copyrights for the Font You means the or person redistributing or modifying the Font Freely Available means that you have the freedom to copy or modify the Font as well as redistribute copies of the Font under the same conditions you not price If you you can charge for this service Copying &Distribution You may copy and distribute verbatim copies of this Font in any without provided that you retain this license including modifying reordering converting changing font or adding deleting some characters in from glyph and copy and distribute such modifications under the terms of Section provided that the following conditions are such as by offering access to copy the modifications from a designated or distributing the modifications on a medium customarily used for software interchange c If the modified fonts normally reads commands interactively when you must cause it
Definition: ARPHICPL.TXT:36
Blam::Content::Fonts::Font
Structure to contain data for a Font.
Definition: fonts.h:134
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:26
Blam::Content::Fonts
Definition: fonts.h:99
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