Description:
Adjust SpriteFonts when user changes font option.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r345:ea073e7c2737 -

@@ -11,7 +11,8
11 11 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
12 12 typeof(GameStateMessage),
13 13 typeof(ToggleVisibilityMessage),
14 typeof(SetResolutionMessage))]
14 typeof(SetResolutionMessage),
15 typeof(SetFontMessage))]
15 16 [Reads(typeof(AreaComponent),
16 17 typeof(ContractStatusComponent))]
17 18 class GameBridgeEngine : Engine
@@ -66,6 +67,11
66 67 resolutionMessage.fullscreen);
67 68
68 69 }
70 foreach (ref readonly var fontMessage in ReadMessages<SetFontMessage>())
71 {
72 game.setFont(fontMessage.fontName, fontMessage.fontSize);
73
74 }
69 75
70 76 game.in_zone = false;
71 77 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
@@ -118,6 +118,7
118 118 message.fontSize, true);
119 119
120 120 debugWindow.setItalicFont(this.italicFont);
121 SendMessage(message);
121 122 }
122 123
123 124
@@ -127,6 +128,7
127 128 var type = GetComponent<WindowTypeComponent>(entity).type;
128 129 var visibility = GetComponent<VisibilityComponent>(entity).visible;
129 130 windowStatuses[type] = visibility;
131
130 132 }
131 133
132 134 this.messages.Clear();
@@ -392,6 +392,28
392 392 Logging.Success("Content loaded.");
393 393 }
394 394
395
396 public void setFont(string font, int size)
397 {
398 var font_path = DebugWindow.fonts[font];
399
400 var baked = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
401 size,
402 1024,
403 1024,
404 new[]
405 {
406 CharacterRange.BasicLatin,
407 CharacterRange.Latin1Supplement,
408 CharacterRange.LatinExtendedA,
409 CharacterRange.Cyrillic,
410 CharacterRange.LatinExtendedB,
411 new CharacterRange((char) 0x00B7)
412 }
413 );
414
415 this.monoFont = baked.CreateSpriteFont(GraphicsDevice);
416 }
395 417
396 418
397 419 protected override void UnloadContent()
@@ -19,7 +19,6
19 19 {
20 20 class ImGuiWindowRenderer : GeneralRenderer
21 21 {
22 // private ImFontPtr font;
23 22 private ImFontPtr italicFont;
24 23 private ImGuiWindowBridgeEngine BridgeEngine;
25 24 private FNAGame game;
@@ -111,16 +110,12
111 110 break;
112 111 }
113 112 }
114
115 113 }
116
117 114 }
118 115
119 116 public void setFont(ImFontPtr font)
120 117 {
121 118 this.BridgeEngine.font = font;
122 119 }
123
124
125 120 }
126 121 }
@@ -31,7 +31,7
31 31
32 32 StyleSets.defaultSet.push();
33 33
34 ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar);
34 ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar);
35 35
36 36 if (ImGui.Button("New Game", button_size))
37 37 {
@@ -83,7 +83,7
83 83
84 84 ImGui.EndCombo();
85 85 }
86 ImGui.Text("Font:");
86 ImGui.Text("Font:\t");
87 87
88 88 ImGui.SameLine();
89 89
@@ -100,7 +100,7
100 100
101 101 ImGui.EndCombo();
102 102 }
103 ImGui.Text("Size:");
103 ImGui.Text("Size:\t");
104 104 ImGui.SameLine();
105 105 if (ImGui.BeginCombo("##FontSize", fontSize.ToString()))
106 106 {
@@ -119,7 +119,10
119 119 ImGuiIOPtr io = ImGui.GetIO();
120 120
121 121
122 ImGui.DragFloat("Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f");
122 ImGui.Text("Scale:\t");
123
124 ImGui.SameLine();
125 ImGui.DragFloat("##Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f");
123 126
124 127 ImGui.SameLine();
125 128 ImGui.TextDisabled("(?)");
You need to be logged in to leave comments. Login now