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 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
11 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
12 typeof(GameStateMessage),
12 typeof(GameStateMessage),
13 typeof(ToggleVisibilityMessage),
13 typeof(ToggleVisibilityMessage),
14 typeof(SetResolutionMessage))]
14 typeof(SetResolutionMessage),
15 typeof(SetFontMessage))]
15 [Reads(typeof(AreaComponent),
16 [Reads(typeof(AreaComponent),
16 typeof(ContractStatusComponent))]
17 typeof(ContractStatusComponent))]
17 class GameBridgeEngine : Engine
18 class GameBridgeEngine : Engine
@@ -66,6 +67,11
66 resolutionMessage.fullscreen);
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 game.in_zone = false;
76 game.in_zone = false;
71 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
77 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
@@ -118,6 +118,7
118 message.fontSize, true);
118 message.fontSize, true);
119
119
120 debugWindow.setItalicFont(this.italicFont);
120 debugWindow.setItalicFont(this.italicFont);
121 SendMessage(message);
121 }
122 }
122
123
123
124
@@ -127,6 +128,7
127 var type = GetComponent<WindowTypeComponent>(entity).type;
128 var type = GetComponent<WindowTypeComponent>(entity).type;
128 var visibility = GetComponent<VisibilityComponent>(entity).visible;
129 var visibility = GetComponent<VisibilityComponent>(entity).visible;
129 windowStatuses[type] = visibility;
130 windowStatuses[type] = visibility;
131
130 }
132 }
131
133
132 this.messages.Clear();
134 this.messages.Clear();
@@ -392,6 +392,28
392 Logging.Success("Content loaded.");
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 protected override void UnloadContent()
419 protected override void UnloadContent()
@@ -19,7 +19,6
19 {
19 {
20 class ImGuiWindowRenderer : GeneralRenderer
20 class ImGuiWindowRenderer : GeneralRenderer
21 {
21 {
22 // private ImFontPtr font;
23 private ImFontPtr italicFont;
22 private ImFontPtr italicFont;
24 private ImGuiWindowBridgeEngine BridgeEngine;
23 private ImGuiWindowBridgeEngine BridgeEngine;
25 private FNAGame game;
24 private FNAGame game;
@@ -111,16 +110,12
111 break;
110 break;
112 }
111 }
113 }
112 }
114
115 }
113 }
116
117 }
114 }
118
115
119 public void setFont(ImFontPtr font)
116 public void setFont(ImFontPtr font)
120 {
117 {
121 this.BridgeEngine.font = font;
118 this.BridgeEngine.font = font;
122 }
119 }
123
124
125 }
120 }
126 }
121 }
@@ -31,7 +31,7
31
31
32 StyleSets.defaultSet.push();
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 if (ImGui.Button("New Game", button_size))
36 if (ImGui.Button("New Game", button_size))
37 {
37 {
@@ -83,7 +83,7
83
83
84 ImGui.EndCombo();
84 ImGui.EndCombo();
85 }
85 }
86 ImGui.Text("Font:");
86 ImGui.Text("Font:\t");
87
87
88 ImGui.SameLine();
88 ImGui.SameLine();
89
89
@@ -100,7 +100,7
100
100
101 ImGui.EndCombo();
101 ImGui.EndCombo();
102 }
102 }
103 ImGui.Text("Size:");
103 ImGui.Text("Size:\t");
104 ImGui.SameLine();
104 ImGui.SameLine();
105 if (ImGui.BeginCombo("##FontSize", fontSize.ToString()))
105 if (ImGui.BeginCombo("##FontSize", fontSize.ToString()))
106 {
106 {
@@ -119,7 +119,10
119 ImGuiIOPtr io = ImGui.GetIO();
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 ImGui.SameLine();
127 ImGui.SameLine();
125 ImGui.TextDisabled("(?)");
128 ImGui.TextDisabled("(?)");
You need to be logged in to leave comments. Login now