diff --git a/isometric-park-fna/Engines/GameBridgeEngine.cs b/isometric-park-fna/Engines/GameBridgeEngine.cs --- a/isometric-park-fna/Engines/GameBridgeEngine.cs +++ b/isometric-park-fna/Engines/GameBridgeEngine.cs @@ -11,7 +11,8 @@ [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage), typeof(GameStateMessage), typeof(ToggleVisibilityMessage), - typeof(SetResolutionMessage))] + typeof(SetResolutionMessage), + typeof(SetFontMessage))] [Reads(typeof(AreaComponent), typeof(ContractStatusComponent))] class GameBridgeEngine : Engine @@ -66,6 +67,11 @@ resolutionMessage.fullscreen); } + foreach (ref readonly var fontMessage in ReadMessages()) + { + game.setFont(fontMessage.fontName, fontMessage.fontSize); + + } game.in_zone = false; foreach (ref readonly var entity in ReadEntities()) diff --git a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs --- a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs +++ b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs @@ -118,6 +118,7 @@ message.fontSize, true); debugWindow.setItalicFont(this.italicFont); + SendMessage(message); } @@ -127,6 +128,7 @@ var type = GetComponent(entity).type; var visibility = GetComponent(entity).visible; windowStatuses[type] = visibility; + } this.messages.Clear(); diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -392,6 +392,28 @@ Logging.Success("Content loaded."); } + + public void setFont(string font, int size) + { + var font_path = DebugWindow.fonts[font]; + + var baked = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), + size, + 1024, + 1024, + new[] + { + CharacterRange.BasicLatin, + CharacterRange.Latin1Supplement, + CharacterRange.LatinExtendedA, + CharacterRange.Cyrillic, + CharacterRange.LatinExtendedB, + new CharacterRange((char) 0x00B7) + } + ); + + this.monoFont = baked.CreateSpriteFont(GraphicsDevice); + } protected override void UnloadContent() diff --git a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs --- a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs +++ b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs @@ -19,7 +19,6 @@ { class ImGuiWindowRenderer : GeneralRenderer { - // private ImFontPtr font; private ImFontPtr italicFont; private ImGuiWindowBridgeEngine BridgeEngine; private FNAGame game; @@ -111,16 +110,12 @@ break; } } - } - } public void setFont(ImFontPtr font) { this.BridgeEngine.font = font; } - - } } diff --git a/isometric-park-fna/UI/MainMenu.cs b/isometric-park-fna/UI/MainMenu.cs --- a/isometric-park-fna/UI/MainMenu.cs +++ b/isometric-park-fna/UI/MainMenu.cs @@ -31,7 +31,7 @@ StyleSets.defaultSet.push(); - ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar); + ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar); if (ImGui.Button("New Game", button_size)) { diff --git a/isometric-park-fna/UI/OptionsWindow.cs b/isometric-park-fna/UI/OptionsWindow.cs --- a/isometric-park-fna/UI/OptionsWindow.cs +++ b/isometric-park-fna/UI/OptionsWindow.cs @@ -83,7 +83,7 @@ ImGui.EndCombo(); } - ImGui.Text("Font:"); + ImGui.Text("Font:\t"); ImGui.SameLine(); @@ -100,7 +100,7 @@ ImGui.EndCombo(); } - ImGui.Text("Size:"); + ImGui.Text("Size:\t"); ImGui.SameLine(); if (ImGui.BeginCombo("##FontSize", fontSize.ToString())) { @@ -119,7 +119,10 @@ ImGuiIOPtr io = ImGui.GetIO(); - ImGui.DragFloat("Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f"); + ImGui.Text("Scale:\t"); + + ImGui.SameLine(); + ImGui.DragFloat("##Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f"); ImGui.SameLine(); ImGui.TextDisabled("(?)");