Description:
Add fullscreen support and more resolutions.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -62,7 +62,8 | |||
|
62 | 62 | } |
|
63 | 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 | 214 | Quad.Initialize(GraphicsDevice, texture); |
|
215 | 215 | Logging.Success("Initialized Quad texture."); |
|
216 | 216 | ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap); |
|
217 | OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen); | |
|
217 | 218 | |
|
218 | 219 | //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded: |
|
219 | 220 | this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap); |
@@ -239,7 +240,7 | |||
|
239 | 240 | WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar)); |
|
240 | 241 | |
|
241 | 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 | 244 | var contractWindow = WorldBuilder.CreateEntity(); |
|
244 | 245 | WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false }); |
|
245 | 246 | WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts }); |
@@ -980,14 +981,15 | |||
|
980 | 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 | 987 | FNAGame.width = (int)newResolution.X; |
|
986 | 988 | FNAGame.height = (int)newResolution.Y; |
|
987 | 989 | |
|
988 | ||
|
989 | 990 | this.gdm.PreferredBackBufferWidth = (int)newResolution.X; |
|
990 | 991 | this.gdm.PreferredBackBufferHeight = (int)newResolution.Y; |
|
992 | this.gdm.IsFullScreen = fullscreen; | |
|
991 | 993 | this.gdm.ApplyChanges(); |
|
992 | 994 | } |
|
993 | 995 |
@@ -17,18 +17,20 | |||
|
17 | 17 | |
|
18 | 18 | namespace isometricparkfna.Renderers |
|
19 | 19 | { |
|
20 |
|
|
|
20 | class ImGuiWindowRenderer : GeneralRenderer | |
|
21 | 21 | { |
|
22 | 22 | private ImFontPtr font; |
|
23 | 23 | private ImFontPtr italicFont; |
|
24 | 24 | private ImGuiWindowBridgeEngine BridgeEngine; |
|
25 | 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 | 29 | this.font = font; |
|
29 | 30 | this.italicFont = italicFont; |
|
30 | 31 | this.BridgeEngine = engine; |
|
31 | 32 | this.width = width; |
|
33 | this.game = game; | |
|
32 | 34 | } |
|
33 | 35 | |
|
34 | 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 | 101 | InGameMenu.Render(this.font, this.BridgeEngine, width); |
|
100 | 102 | break; |
|
101 | 103 | case Window.Options: |
|
102 | OptionsWindow.Render(this.font, this.BridgeEngine, width); | |
|
104 | OptionsWindow.Render(this.font, this.italicFont, this.BridgeEngine, width); | |
|
103 | 105 | break; |
|
104 | 106 | default: |
|
105 | 107 | break; |
@@ -72,10 +72,7 | |||
|
72 | 72 | if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0)) |
|
73 | 73 | { |
|
74 | 74 | engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity}); |
|
75 | ||
|
76 | ||
|
77 | 75 | } |
|
78 | ||
|
79 | 76 | |
|
80 | 77 | ImGui.SameLine(); |
|
81 | 78 | switch (contract.status) |
@@ -16,21 +16,28 | |||
|
16 | 16 | { |
|
17 | 17 | |
|
18 | 18 | public static bool hadFocus = false; |
|
19 | public static bool newFullscreen; | |
|
20 | public static Vector2 newResolution; | |
|
19 | 21 | |
|
20 | private static int selectedHeight = 1280; | |
|
21 | private static int selectedWidth = 640; | |
|
22 | public static void Initialize(Vector2 resolution, bool fullscreen) | |
|
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 | 32 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; |
|
27 | 33 | bool newShow = true; |
|
34 | ||
|
28 | 35 | // Num.Vector2 button_size = new Num.Vector2(120, 20); |
|
29 | 36 | StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars); |
|
30 | 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 | 42 | ImGui.PushFont(font); |
|
36 | 43 | // ImGui.PushFont(smallFont); |
@@ -47,43 +54,52 | |||
|
47 | 54 | } |
|
48 | 55 | ForestWindow.hadFocus = ImGui.IsWindowFocused(); |
|
49 | 56 | |
|
57 | ImGui.PushFont(italicFont); | |
|
58 | ImGui.Text("Graphics"); | |
|
59 | ImGui.PopFont(); | |
|
60 | ||
|
61 | ||
|
50 | 62 | ImGui.Text("Resolution:"); |
|
51 | 63 | |
|
52 | 64 | ImGui.SameLine(); |
|
53 | 65 | |
|
54 | 66 | if (ImGui.BeginCombo("", string.Format("{0}x{1}", |
|
55 | OptionsWindow.selectedWidth, | |
|
56 | OptionsWindow.selectedHeight))) | |
|
67 | newResolution.X, newResolution.Y))) | |
|
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 | 74 | if (ImGui.Selectable(string.Format("{0}x{1}", width_option, height_option))) |
|
62 | 75 | { |
|
63 |
|
|
|
64 |
|
|
|
76 | newResolution.X = width_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 | 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 | 92 | if (ImGui.Button("Okay")) |
|
79 | 93 | { |
|
80 | 94 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options}); |
|
81 |
bridgeEngine.resolutionMessages.Add(new SetResolutionMessage { |
|
|
95 | bridgeEngine.resolutionMessages.Add(new SetResolutionMessage { | |
|
96 | resolution = newResolution, | |
|
97 | fullscreen = newFullscreen | |
|
98 | }); | |
|
82 | 99 | } |
|
83 | 100 | |
|
84 | 101 | ImGui.End(); |
|
85 | 102 | |
|
86 | ||
|
87 | 103 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; |
|
88 | 104 | StyleSet.popStyleVarSet(StyleSet.defaultWindowVars); |
|
89 | 105 | StyleSet.popColorSet(StyleSet.defaultWindowColors); |
You need to be logged in to leave comments.
Login now