|
|
using System;
|
|
|
using ImGuiNET;
|
|
|
|
|
|
using Num = System.Numerics;
|
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
using isometricparkfna.Engines;
|
|
|
using isometricparkfna.Messages;
|
|
|
using isometricparkfna.UI;
|
|
|
|
|
|
namespace isometricparkfna.UI
|
|
|
{
|
|
|
|
|
|
public static class OptionsWindow
|
|
|
{
|
|
|
|
|
|
public static bool hadFocus = false;
|
|
|
public static bool newFullscreen;
|
|
|
public static Vector2 newResolution;
|
|
|
|
|
|
private static string fontName = "Iosevka";
|
|
|
private static int fontSize = 15;
|
|
|
|
|
|
public static void Initialize(Vector2 resolution, bool fullscreen)
|
|
|
{
|
|
|
|
|
|
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.PushFont(font);
|
|
|
// ImGui.PushFont(smallFont);
|
|
|
//
|
|
|
if(ForestWindow.hadFocus)
|
|
|
{
|
|
|
ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
|
|
|
}
|
|
|
ImGui.Begin("Options", ref newShow, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
|
|
|
|
|
|
if (ForestWindow.hadFocus)
|
|
|
{
|
|
|
ImGui.PopStyleColor();
|
|
|
}
|
|
|
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}",
|
|
|
newResolution.X, newResolution.Y)))
|
|
|
{
|
|
|
|
|
|
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)))
|
|
|
{
|
|
|
newResolution.X = width_option;
|
|
|
newResolution.Y = height_option;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ImGui.EndCombo();
|
|
|
}
|
|
|
ImGui.Text("Font:");
|
|
|
|
|
|
ImGui.SameLine();
|
|
|
|
|
|
if (ImGui.BeginCombo("##Font", fontName))
|
|
|
{
|
|
|
|
|
|
foreach(var font_name in new[]{"Iosevka", "Roboto"})
|
|
|
{
|
|
|
if(ImGui.Selectable(font_name))
|
|
|
{
|
|
|
OptionsWindow.fontName = font_name;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ImGui.EndCombo();
|
|
|
}
|
|
|
ImGui.Text("Size:");
|
|
|
ImGui.SameLine();
|
|
|
if (ImGui.BeginCombo("##FontSize", fontSize.ToString()))
|
|
|
{
|
|
|
|
|
|
foreach(var size in new[]{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20})
|
|
|
{
|
|
|
if(ImGui.Selectable(size.ToString()))
|
|
|
{
|
|
|
OptionsWindow.fontSize = size;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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 = newResolution,
|
|
|
fullscreen = newFullscreen
|
|
|
});
|
|
|
bridgeEngine.fontMessages.Add(new SetFontMessage{
|
|
|
fontSize = OptionsWindow.fontSize,
|
|
|
fontName = OptionsWindow.fontName});
|
|
|
|
|
|
}
|
|
|
|
|
|
ImGui.End();
|
|
|
|
|
|
ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
|
|
|
StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
|
|
|
StyleSet.popColorSet(StyleSet.defaultWindowColors);
|
|
|
ImGui.PopFont();
|
|
|
|
|
|
if (!newShow)
|
|
|
{
|
|
|
bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|