mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Fixed loading UI font
This commit is contained in:
@@ -125,6 +125,10 @@ class LogWindow : EditorWindow
|
|||||||
ImGui.Checkbox("Collapse", &_collapseMessages);
|
ImGui.Checkbox("Collapse", &_collapseMessages);
|
||||||
ImGui.AttachTooltip("If checked, identical messages will be collapsed into one.");
|
ImGui.AttachTooltip("If checked, identical messages will be collapsed into one.");
|
||||||
|
|
||||||
|
var maxSpace = ImGui.GetFontSize();
|
||||||
|
|
||||||
|
ImGui.Vec2 buttonSize = .(maxSpace, maxSpace);
|
||||||
|
|
||||||
var col = ImGui.GetStyleColorVec4(.Button);
|
var col = ImGui.GetStyleColorVec4(.Button);
|
||||||
|
|
||||||
if (_visibleMessageTypes.HasFlag(.Trace))
|
if (_visibleMessageTypes.HasFlag(.Trace))
|
||||||
@@ -132,7 +136,7 @@ class LogWindow : EditorWindow
|
|||||||
else
|
else
|
||||||
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
||||||
|
|
||||||
if (ImGui.ImageButtonEx(1, s_TraceIcon, .(14, 14), .Zero, .Ones, .(2, 2)))
|
if (ImGui.ImageButtonEx(1, s_TraceIcon, buttonSize, .Zero, .Ones, .(2, 2)))
|
||||||
_visibleMessageTypes ^= .Trace;
|
_visibleMessageTypes ^= .Trace;
|
||||||
|
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
@@ -142,7 +146,7 @@ class LogWindow : EditorWindow
|
|||||||
else
|
else
|
||||||
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
||||||
|
|
||||||
if (ImGui.ImageButtonEx(2, s_InfoIcon, .(16, 16)))
|
if (ImGui.ImageButtonEx(2, s_InfoIcon, buttonSize, .Zero, .Ones, .(2, 2)))
|
||||||
_visibleMessageTypes ^= .Info;
|
_visibleMessageTypes ^= .Info;
|
||||||
|
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
@@ -152,7 +156,7 @@ class LogWindow : EditorWindow
|
|||||||
else
|
else
|
||||||
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
||||||
|
|
||||||
if (ImGui.ImageButtonEx(3, s_WarningIcon, .(16, 16)))
|
if (ImGui.ImageButtonEx(3, s_WarningIcon, buttonSize, .Zero, .Ones, .(2, 2)))
|
||||||
_visibleMessageTypes ^= .Warning;
|
_visibleMessageTypes ^= .Warning;
|
||||||
|
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
@@ -162,7 +166,8 @@ class LogWindow : EditorWindow
|
|||||||
else
|
else
|
||||||
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
ImGui.PushStyleColor(.Button, .(0, 0, 0, 0));
|
||||||
|
|
||||||
if (ImGui.ImageButtonEx(4, s_ErrorIcon, .(16, 16)))
|
|
||||||
|
if (ImGui.ImageButtonEx(4, s_ErrorIcon, buttonSize, .Zero, .Ones, .(2, 2)))
|
||||||
_visibleMessageTypes ^= .Error;
|
_visibleMessageTypes ^= .Error;
|
||||||
|
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
|
|||||||
@@ -86,29 +86,42 @@ namespace GlitchyEngine.ImGui
|
|||||||
ImGuizmo.BeginFrame();
|
ImGuizmo.BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadFont()
|
||||||
|
{
|
||||||
|
var settings = Application.Instance.Settings.ImGuiSettings;
|
||||||
|
|
||||||
|
ImGui.GetIO().Fonts.Clear();
|
||||||
|
|
||||||
|
Stream fontFile = Application.Instance.ContentManager.GetStream(settings.FontName);
|
||||||
|
|
||||||
|
if (fontFile != null)
|
||||||
|
{
|
||||||
|
// We need to use ImGuis memory allocator because ImGui takes ownership
|
||||||
|
uint8* fontData = (uint8*)ImGui.MemAlloc((uint64)fontFile.Length);
|
||||||
|
var result = fontFile.TryRead(Span<uint8>(fontData, fontFile.Length));
|
||||||
|
|
||||||
|
if (result case .Err)
|
||||||
|
Log.EngineLogger.Error($"Failed to load font \"{settings.FontName}\" from stream.");
|
||||||
|
|
||||||
|
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(fontData, (int32)fontFile.Length, settings.FontSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui.GetIO().Fonts.AddFontDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.GetIO().Fonts.AddFontDefault();
|
||||||
|
|
||||||
|
delete fontFile;
|
||||||
|
}
|
||||||
|
|
||||||
public void ImGuiRender()
|
public void ImGuiRender()
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileFunction!();
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if (SettingsInvalid)
|
if (SettingsInvalid)
|
||||||
{
|
{
|
||||||
var settings = Application.Get().Settings.ImGuiSettings;
|
LoadFont();
|
||||||
|
|
||||||
ImGui.GetIO().Fonts.Clear();
|
|
||||||
|
|
||||||
// TODO: Fix fonts
|
|
||||||
//String fullpath = scope String();
|
|
||||||
//Application.Get().ContentManager.GetFilePath(fullpath, settings.FontName);
|
|
||||||
/*Application.Get().ContentManager.GetStream(settings.FontName);
|
|
||||||
if (File.Exists(fullpath))
|
|
||||||
{
|
|
||||||
ImGui.GetIO().Fonts.AddFontFromMemoryTTF();
|
|
||||||
ImGui.GetIO().Fonts.AddFontFromFileTTF(fullpath, settings.FontSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
ImGui.GetIO().Fonts.AddFontDefault();
|
|
||||||
//}
|
|
||||||
|
|
||||||
#if GE_GRAPHICS_DX11
|
#if GE_GRAPHICS_DX11
|
||||||
ImGuiImplDX11.CreateDeviceObjects();
|
ImGuiImplDX11.CreateDeviceObjects();
|
||||||
|
|||||||
Reference in New Issue
Block a user