Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
theme_editor.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
8 
13 {
14 private:
15  std::string selected_theme = ENGINE_TEXT("choose");
16  std::string selected_metrics = ENGINE_TEXT("choose");
17  float global_ui_scale = 1.0f;
18  int active_theme_index = -1;
19 
20 public:
21  void Draw()
22  {
23  if (!show)
24  {
25  return;
26  }
27 
28  if (ImGui::Begin("Theme Editor", &show))
29  {
30  if (ImGui::BeginCombo("theme", selected_theme.c_str()))
31  {
32  for (int i = 0; i < Blam::UI::Themes::GetColorSchemeList()->size(); i++)
33  {
35 
36  if (ImGui::Selectable(theme.name.c_str()))
37  {
38  selected_theme = theme.name;
39  active_theme_index = i;
40  theme.ApplyTheme();
41  }
42  }
43 
45  }
46 
47  if (ImGui::BeginCombo("metrics", selected_metrics.c_str()))
48  {
49  for (int i = 0; i < Blam::UI::Themes::GetMetricsList()->size(); i++)
50  {
52 
53  if (ImGui::Selectable(metrics.name.c_str()))
54  {
55  selected_metrics = metrics.name;
56  active_theme_index = i;
57  metrics.ApplyMetrics();
58  }
59  }
60 
62  }
63 
64  ImGuiIO& io = ImGui::GetIO();
65  ImFont* font_current = ImGui::GetFont();
66 
67  if (ImGui::BeginCombo("imgui font", font_current->GetDebugName()))
68  {
69  for (int i = 0; i < io.Fonts->Fonts.Size; i++)
70  {
71  ImFont* font = io.Fonts->Fonts[i];
72  ImGui::PushID((void*)font);
73 
74  if (ImGui::Selectable(font->GetDebugName(), font == font_current))
75  {
76  io.FontDefault = font;
77  }
78 
79  ImGui::PopID();
80  }
81 
83  }
84 
86  Blam::UI::ImGUI::Widgets::ShowHelpMarker(ENGINE_TEXT("imgui_theme_picker_font_info").c_str());
87 
88  ImGui::InputFloat("imgui ui scale", &global_ui_scale, 1.0f, 0.0f, 20.0f);
90  Blam::UI::ImGUI::Widgets::ShowHelpMarker(ENGINE_TEXT("imgui_theme_editor_ui_scale_help_text").c_str());
91 
92  if (ImGui::Button("Update Scale"))
93  {
94  ImGui::GetStyle().ScaleAllSizes(global_ui_scale);
95  }
96  }
97 
98  ImGui::End();
99  }
100 };
font
io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels,...) font
Definition: README.txt:86
ImGuiIO::FontDefault
ImFont * FontDefault
Definition: imgui.h:1362
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
Blam::UI::Themes::GetMetricsList
BLAM std::vector< BlamThemeMetrics > * GetMetricsList()
Retrieves the list of currently loaded theme metrics.
Definition: themes.cpp:456
BlamImGuiWindow_ModernThemeEditor::Draw
void Draw()
Draws the contents of the group.
Definition: theme_editor.hpp:21
themes.h
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ImGuiIO
Definition: imgui.h:1338
engine_text.h
ImGuiStyle::ScaleAllSizes
IMGUI_API void ScaleAllSizes(float scale_factor)
Definition: imgui.cpp:1171
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
ImFont
Definition: imgui.h:2180
BlamColorScheme::name
std::string name
The name of the theme.
Definition: themes.h:31
Blam::UI::Themes::GetColorSchemeList
BLAM std::vector< BlamColorScheme > * GetColorSchemeList()
Retrieves the list of currently loaded color schemes.
Definition: themes.cpp:451
BlamThemeMetrics
Class representing Blamite theme metrics.
Definition: themes.h:76
ImGuiIO::Fonts
ImFontAtlas * Fonts
Definition: imgui.h:1359
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
ImFontAtlas::Fonts
ImVector< ImFont * > Fonts
Definition: imgui.h:2167
BlamColorScheme::ApplyTheme
void ApplyTheme()
Applies the theme to the engine UI.
Definition: BlamColorScheme.cpp:13
ImFont::GetDebugName
const char * GetDebugName() const
Definition: imgui.h:2211
ImGui::GetFont
IMGUI_API ImFont * GetFont()
Definition: imgui.cpp:6867
ImGui::GetIO
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:3300
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
BlamColorScheme
Class representing a Blam Color Scheme.
Definition: themes.h:28
ImGui::PopID
IMGUI_API void PopID()
Definition: imgui.cpp:7026
ImGui::EndCombo
IMGUI_API void EndCombo()
Definition: imgui_widgets.cpp:1522
ImGui::GetStyle
IMGUI_API ImGuiStyle & GetStyle()
Definition: imgui.cpp:3306
ENGINE_TEXT
#define ENGINE_TEXT(string_id)
Definition: engine_text.h:7
imgui.h
config.h
BlamThemeMetrics::ApplyMetrics
void ApplyMetrics()
Applies the metrics to the engine UI.
Definition: BlamThemeMetrics.cpp:6
BlamThemeMetrics::name
std::string name
The name of the theme metrics.
Definition: themes.h:79
ImVector::Size
int Size
Definition: imgui.h:1229
ImGui::InputFloat
IMGUI_API bool InputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition: imgui_widgets.cpp:2975
ImGui::PushID
IMGUI_API void PushID(const char *str_id)
Definition: imgui.cpp:6995
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644
BlamImGuiWindow_ModernThemeEditor
Class for the modern Theme Editor.
Definition: theme_editor.hpp:12