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 @@ -62,7 +62,8 @@ } foreach (ref readonly var resolutionMessage in ReadMessages()) { - game.setResolution(resolutionMessage.resolution); + game.setResolution(resolutionMessage.resolution, + resolutionMessage.fullscreen); } 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 @@ -214,6 +214,7 @@ Quad.Initialize(GraphicsDevice, texture); Logging.Success("Initialized Quad texture."); ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap); + OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen); //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded: this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap); @@ -239,7 +240,7 @@ WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar)); WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); - WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, FNAGame.width), 2); + WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, FNAGame.width), 2); var contractWindow = WorldBuilder.CreateEntity(); WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false }); WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts }); @@ -980,14 +981,15 @@ base.Draw(gameTime); } - public void setResolution(Vector2 newResolution) + + public void setResolution(Vector2 newResolution, bool fullscreen) { FNAGame.width = (int)newResolution.X; FNAGame.height = (int)newResolution.Y; - this.gdm.PreferredBackBufferWidth = (int)newResolution.X; this.gdm.PreferredBackBufferHeight = (int)newResolution.Y; + this.gdm.IsFullScreen = fullscreen; this.gdm.ApplyChanges(); } 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 @@ -17,18 +17,20 @@ namespace isometricparkfna.Renderers { - public class ImGuiWindowRenderer : GeneralRenderer + class ImGuiWindowRenderer : GeneralRenderer { private ImFontPtr font; private ImFontPtr italicFont; private ImGuiWindowBridgeEngine BridgeEngine; private int width; - public ImGuiWindowRenderer(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, int width) + private FNAGame game; + public ImGuiWindowRenderer(FNAGame game, ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, int width) { this.font = font; this.italicFont = italicFont; this.BridgeEngine = engine; this.width = width; + this.game = game; } private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) @@ -99,7 +101,7 @@ InGameMenu.Render(this.font, this.BridgeEngine, width); break; case Window.Options: - OptionsWindow.Render(this.font, this.BridgeEngine, width); + OptionsWindow.Render(this.font, this.italicFont, this.BridgeEngine, width); break; default: break; diff --git a/isometric-park-fna/UI/ContractsWindow.cs b/isometric-park-fna/UI/ContractsWindow.cs --- a/isometric-park-fna/UI/ContractsWindow.cs +++ b/isometric-park-fna/UI/ContractsWindow.cs @@ -72,10 +72,7 @@ if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0)) { engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity}); - - } - ImGui.SameLine(); switch (contract.status) 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 @@ -16,21 +16,28 @@ { public static bool hadFocus = false; + public static bool newFullscreen; + public static Vector2 newResolution; - private static int selectedHeight = 1280; - private static int selectedWidth = 640; + public static void Initialize(Vector2 resolution, bool fullscreen) + { - public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine, int width) + newFullscreen = fullscreen; + newResolution = resolution; + } + + public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine, int width) { ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; bool newShow = true; + // Num.Vector2 button_size = new Num.Vector2(120, 20); StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars); StyleSet.pushColorSet(StyleSet.defaultWindowColors); - ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200)); + // ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200)); ImGui.PushFont(font); // ImGui.PushFont(smallFont); @@ -47,43 +54,52 @@ } ForestWindow.hadFocus = ImGui.IsWindowFocused(); + ImGui.PushFont(italicFont); + ImGui.Text("Graphics"); + ImGui.PopFont(); + + ImGui.Text("Resolution:"); ImGui.SameLine(); if (ImGui.BeginCombo("", string.Format("{0}x{1}", - OptionsWindow.selectedWidth, - OptionsWindow.selectedHeight))) + newResolution.X, newResolution.Y))) { - foreach(var (width_option, height_option) in new[]{(1280, 640), (640, 320), (960, 480), (1600, 800)}) + foreach(var (width_option, height_option) in new[]{(1280, 640), (640, 320), (960, 480), (1600, 800), + (2560, 1440), (1280, 720), (1920, 1080) + }) { if (ImGui.Selectable(string.Format("{0}x{1}", width_option, height_option))) { - OptionsWindow.selectedWidth = width_option; - OptionsWindow.selectedHeight = height_option; + newResolution.X = width_option; + newResolution.Y = height_option; } - - } - - // ImGui.Selectable("Test"); - // ImGui.Selectable("Test2"); - ImGui.EndCombo(); } + ImGuiIOPtr io = ImGui.GetIO(); + ImGui.DragFloat("Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f"); + + ImGui.Checkbox("Fullscreen", ref newFullscreen); + + ImGui.Separator(); + if (ImGui.Button("Okay")) { bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options}); - bridgeEngine.resolutionMessages.Add(new SetResolutionMessage {resolution = new Vector2(selectedWidth, selectedHeight)}); + bridgeEngine.resolutionMessages.Add(new SetResolutionMessage { + resolution = newResolution, + fullscreen = newFullscreen + }); } ImGui.End(); - ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; StyleSet.popStyleVarSet(StyleSet.defaultWindowVars); StyleSet.popColorSet(StyleSet.defaultWindowColors);