Description:
Add fullscreen support and more resolutions.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r310:39385bdd9d30 -

@@ -62,7 +62,8
62 }
62 }
63 foreach (ref readonly var resolutionMessage in ReadMessages<SetResolutionMessage>())
63 foreach (ref readonly var resolutionMessage in ReadMessages<SetResolutionMessage>())
64 {
64 {
65 game.setResolution(resolutionMessage.resolution);
65 game.setResolution(resolutionMessage.resolution,
66 resolutionMessage.fullscreen);
66
67
67 }
68 }
68
69
@@ -214,6 +214,7
214 Quad.Initialize(GraphicsDevice, texture);
214 Quad.Initialize(GraphicsDevice, texture);
215 Logging.Success("Initialized Quad texture.");
215 Logging.Success("Initialized Quad texture.");
216 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
216 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
217 OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen);
217
218
218 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
219 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
219 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
220 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
@@ -239,7 +240,7
239 WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar));
240 WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar));
240
241
241 WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1);
242 WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1);
242 WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, FNAGame.width), 2);
243 WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, FNAGame.width), 2);
243 var contractWindow = WorldBuilder.CreateEntity();
244 var contractWindow = WorldBuilder.CreateEntity();
244 WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false });
245 WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false });
245 WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts });
246 WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts });
@@ -980,14 +981,15
980 base.Draw(gameTime);
981 base.Draw(gameTime);
981 }
982 }
982
983
983 public void setResolution(Vector2 newResolution)
984
985 public void setResolution(Vector2 newResolution, bool fullscreen)
984 {
986 {
985 FNAGame.width = (int)newResolution.X;
987 FNAGame.width = (int)newResolution.X;
986 FNAGame.height = (int)newResolution.Y;
988 FNAGame.height = (int)newResolution.Y;
987
989
988
989 this.gdm.PreferredBackBufferWidth = (int)newResolution.X;
990 this.gdm.PreferredBackBufferWidth = (int)newResolution.X;
990 this.gdm.PreferredBackBufferHeight = (int)newResolution.Y;
991 this.gdm.PreferredBackBufferHeight = (int)newResolution.Y;
992 this.gdm.IsFullScreen = fullscreen;
991 this.gdm.ApplyChanges();
993 this.gdm.ApplyChanges();
992 }
994 }
993
995
@@ -17,18 +17,20
17
17
18 namespace isometricparkfna.Renderers
18 namespace isometricparkfna.Renderers
19 {
19 {
20 public class ImGuiWindowRenderer : GeneralRenderer
20 class ImGuiWindowRenderer : GeneralRenderer
21 {
21 {
22 private ImFontPtr font;
22 private ImFontPtr font;
23 private ImFontPtr italicFont;
23 private ImFontPtr italicFont;
24 private ImGuiWindowBridgeEngine BridgeEngine;
24 private ImGuiWindowBridgeEngine BridgeEngine;
25 private int width;
25 private int width;
26 public ImGuiWindowRenderer(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, int width)
26 private FNAGame game;
27 public ImGuiWindowRenderer(FNAGame game, ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, int width)
27 {
28 {
28 this.font = font;
29 this.font = font;
29 this.italicFont = italicFont;
30 this.italicFont = italicFont;
30 this.BridgeEngine = engine;
31 this.BridgeEngine = engine;
31 this.width = width;
32 this.width = width;
33 this.game = game;
32 }
34 }
33
35
34 private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)
36 private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)
@@ -99,7 +101,7
99 InGameMenu.Render(this.font, this.BridgeEngine, width);
101 InGameMenu.Render(this.font, this.BridgeEngine, width);
100 break;
102 break;
101 case Window.Options:
103 case Window.Options:
102 OptionsWindow.Render(this.font, this.BridgeEngine, width);
104 OptionsWindow.Render(this.font, this.italicFont, this.BridgeEngine, width);
103 break;
105 break;
104 default:
106 default:
105 break;
107 break;
@@ -72,10 +72,7
72 if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0))
72 if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0))
73 {
73 {
74 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity});
74 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity});
75
76
77 }
75 }
78
79
76
80 ImGui.SameLine();
77 ImGui.SameLine();
81 switch (contract.status)
78 switch (contract.status)
@@ -16,21 +16,28
16 {
16 {
17
17
18 public static bool hadFocus = false;
18 public static bool hadFocus = false;
19 public static bool newFullscreen;
20 public static Vector2 newResolution;
19
21
20 private static int selectedHeight = 1280;
22 public static void Initialize(Vector2 resolution, bool fullscreen)
21 private static int selectedWidth = 640;
23 {
22
24
23 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine, int width)
25 newFullscreen = fullscreen;
26 newResolution = resolution;
27 }
28
29 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine, int width)
24 {
30 {
25
31
26 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
32 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
27 bool newShow = true;
33 bool newShow = true;
34
28 // Num.Vector2 button_size = new Num.Vector2(120, 20);
35 // Num.Vector2 button_size = new Num.Vector2(120, 20);
29 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
36 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
30 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
37 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
31
38
32
39
33 ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200));
40 // ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200));
34
41
35 ImGui.PushFont(font);
42 ImGui.PushFont(font);
36 // ImGui.PushFont(smallFont);
43 // ImGui.PushFont(smallFont);
@@ -47,43 +54,52
47 }
54 }
48 ForestWindow.hadFocus = ImGui.IsWindowFocused();
55 ForestWindow.hadFocus = ImGui.IsWindowFocused();
49
56
57 ImGui.PushFont(italicFont);
58 ImGui.Text("Graphics");
59 ImGui.PopFont();
60
61
50 ImGui.Text("Resolution:");
62 ImGui.Text("Resolution:");
51
63
52 ImGui.SameLine();
64 ImGui.SameLine();
53
65
54 if (ImGui.BeginCombo("", string.Format("{0}x{1}",
66 if (ImGui.BeginCombo("", string.Format("{0}x{1}",
55 OptionsWindow.selectedWidth,
67 newResolution.X, newResolution.Y)))
56 OptionsWindow.selectedHeight)))
57 {
68 {
58
69
59 foreach(var (width_option, height_option) in new[]{(1280, 640), (640, 320), (960, 480), (1600, 800)})
70 foreach(var (width_option, height_option) in new[]{(1280, 640), (640, 320), (960, 480), (1600, 800),
71 (2560, 1440), (1280, 720), (1920, 1080)
72 })
60 {
73 {
61 if (ImGui.Selectable(string.Format("{0}x{1}", width_option, height_option)))
74 if (ImGui.Selectable(string.Format("{0}x{1}", width_option, height_option)))
62 {
75 {
63 OptionsWindow.selectedWidth = width_option;
76 newResolution.X = width_option;
64 OptionsWindow.selectedHeight = height_option;
77 newResolution.Y = height_option;
65 }
78 }
66
67
68 }
79 }
69
80
70
71 // ImGui.Selectable("Test");
72 // ImGui.Selectable("Test2");
73
74 ImGui.EndCombo();
81 ImGui.EndCombo();
75 }
82 }
76
83
84 ImGuiIOPtr io = ImGui.GetIO();
85 ImGui.DragFloat("Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f");
86
87 ImGui.Checkbox("Fullscreen", ref newFullscreen);
88
89 ImGui.Separator();
90
77
91
78 if (ImGui.Button("Okay"))
92 if (ImGui.Button("Okay"))
79 {
93 {
80 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options});
94 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options});
81 bridgeEngine.resolutionMessages.Add(new SetResolutionMessage {resolution = new Vector2(selectedWidth, selectedHeight)});
95 bridgeEngine.resolutionMessages.Add(new SetResolutionMessage {
96 resolution = newResolution,
97 fullscreen = newFullscreen
98 });
82 }
99 }
83
100
84 ImGui.End();
101 ImGui.End();
85
102
86
87 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
103 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
88 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
104 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
89 StyleSet.popColorSet(StyleSet.defaultWindowColors);
105 StyleSet.popColorSet(StyleSet.defaultWindowColors);
You need to be logged in to leave comments. Login now