aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/MainMenu.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-25 23:25:52 -0400
committerMichael <[email protected]>2017-07-25 23:25:52 -0400
commit68c7de273f4930b54f8504cc777660fc3c68156c (patch)
tree28c0c68b08113ba1ef9ee93d71574c3553efd24f /ShiftOS.Frontend/MainMenu.cs
parente38da782aaa9398b6659d72cf20588c5418ac9ba (diff)
downloadshiftos_thereturn-68c7de273f4930b54f8504cc777660fc3c68156c.tar.gz
shiftos_thereturn-68c7de273f4930b54f8504cc777660fc3c68156c.tar.bz2
shiftos_thereturn-68c7de273f4930b54f8504cc777660fc3c68156c.zip
resolution settings
Diffstat (limited to 'ShiftOS.Frontend/MainMenu.cs')
-rw-r--r--ShiftOS.Frontend/MainMenu.cs114
1 files changed, 112 insertions, 2 deletions
diff --git a/ShiftOS.Frontend/MainMenu.cs b/ShiftOS.Frontend/MainMenu.cs
index e12989c..a501924 100644
--- a/ShiftOS.Frontend/MainMenu.cs
+++ b/ShiftOS.Frontend/MainMenu.cs
@@ -7,6 +7,7 @@ using ShiftOS.Engine;
using ShiftOS.Frontend.GUI;
using ShiftOS.Frontend.GraphicsSubsystem;
using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
namespace ShiftOS.Frontend
{
@@ -16,6 +17,11 @@ namespace ShiftOS.Frontend
private TextControl _menuTitle = new TextControl();
private Button _campaign = new Button();
private Button _sandbox = new Button();
+ private Button _options = new Button();
+ private Button _resDown = new Button();
+ private Button _resUp = new Button();
+ private TextControl _resDisplay = new TextControl();
+ private Button _optionsSave = new Button();
public MainMenu()
{
@@ -28,6 +34,18 @@ namespace ShiftOS.Frontend
AddControl(_menuTitle);
AddControl(_campaign);
AddControl(_sandbox);
+ AddControl(_options);
+ AddControl(_resUp);
+ AddControl(_resDown);
+ AddControl(_resDisplay);
+ AddControl(_optionsSave);
+
+ _optionsSave.Text = "Save sentience settings";
+ _optionsSave.Width = (Width / 4) - 60;
+ _optionsSave.X = 30;
+ _optionsSave.Y = 300;
+
+ _optionsSave.Height = 6 + _optionsSave.Font.Height;
_campaign.Text = "Campaign";
_campaign.Font = new System.Drawing.Font("Lucida Console", 10F);
@@ -35,12 +53,22 @@ namespace ShiftOS.Frontend
_campaign.Height = 6 + _campaign.Font.Height;
_campaign.X = 30;
+ _optionsSave.Font = _campaign.Font;
+ _optionsSave.Height = 6 + _optionsSave.Font.Height;
+
+
_sandbox.Text = "Sandbox";
_sandbox.Width = 200;
_sandbox.Height = 6 + _campaign.Font.Height;
_sandbox.Font = _campaign.Font;
_sandbox.X = 30;
+ _options.Text = "Options";
+ _options.Width = 200;
+ _options.Height = 6 + _campaign.Font.Height;
+ _options.Font = _campaign.Font;
+ _options.X = 30;
+
_mainTitle.X = 30;
_mainTitle.Y = 30;
_mainTitle.Font = new System.Drawing.Font("Lucida Console", 48F);
@@ -54,6 +82,7 @@ namespace ShiftOS.Frontend
_campaign.Y = _menuTitle.Y + _menuTitle.Font.Height + 15;
_sandbox.Y = _campaign.Y + _campaign.Font.Height + 15;
+ _options.Y = _sandbox.Y + _sandbox.Font.Height + 15;
_campaign.Click += () =>
{
SaveSystem.IsSandbox = false;
@@ -66,14 +95,90 @@ namespace ShiftOS.Frontend
SaveSystem.Begin(false);
Close();
};
+ _options.Click += () =>
+ {
+ _menuTitle.Text = "Options";
+ ShowOptions();
+ };
+
+ _resDown.Text = "<<";
+ _resUp.Text = ">>";
+ _resDown.Font = _campaign.Font;
+ _resDown.Height = _campaign.Height;
+ _resDown.Width = 40;
+ _resUp.Font = _resDown.Font;
+ _resUp.Height = _resDown.Height;
+ _resUp.Width = _resDown.Width;
+ _resDown.Y = _campaign.Y;
+ _resUp.Y = _campaign.Y;
+ _resDown.X = 30;
+ _resUp.X = ((Width / 4) - _resUp.Width) - 30;
+ _resDisplay.X = _resDown.X + _resDown.Width;
+ _resDisplay.Width = (_resUp.X - _resDown.X);
+ _resDisplay.Y = _resDown.Y;
+ _resDisplay.Height = _resDown.Height;
+ _resDisplay.TextAlign = TextAlign.MiddleCenter;
+ _resDown.Click += () =>
+ {
+ if (_resIndex > 0)
+ {
+ _resIndex--;
+ var res = _screenResolutions[_resIndex];
+ _resDisplay.Text = $"{res.Width}x{res.Height}";
+ }
+ };
+ _resUp.Click += () =>
+ {
+ if(_resIndex < _screenResolutions.Count - 1)
+ {
+ _resIndex++;
+ var res = _screenResolutions[_resIndex];
+ _resDisplay.Text = $"{res.Width}x{res.Height}";
+
+ }
+ };
+
+ _optionsSave.Click += () =>
+ {
+ var uconf = Objects.UserConfig.Get();
+
+ Engine.Infobox.PromptYesNo("Confirm sentience edit", "Performing this operation requires your sentience to be re-established which may cause you to go unconscious. Do you wish to continue?", (sleep) =>
+ {
+ if (sleep == true)
+ {
+ var res = _screenResolutions[_resIndex];
+ uconf.ScreenWidth = res.Width;
+ uconf.ScreenHeight = res.Height;
+ System.IO.File.WriteAllText("config.json", Newtonsoft.Json.JsonConvert.SerializeObject(uconf, Newtonsoft.Json.Formatting.Indented));
+ System.Diagnostics.Process.Start("ShiftOS.Frontend.exe");
+ Environment.Exit(-1);
+ }
+ });
+ };
+
+ foreach(var mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.OrderBy(x=>x.Width * x.Height))
+ {
+ _screenResolutions.Add(new System.Drawing.Size(mode.Width, mode.Height));
+ if (UIManager.Viewport == _screenResolutions.Last())
+ _resIndex = _screenResolutions.Count - 1;
+ }
+ }
+
+ public void ShowOptions()
+ {
+ _campaign.Visible = false;
+ _sandbox.Visible = false;
+ _options.Visible = false;
+ var res = _screenResolutions[_resIndex];
+ _resDisplay.Text = $"{res.Width}x{res.Height}";
}
private string _tipText = "This is some tip text.";
private float _tipFade = 0.0f;
private int _tipTime = 0;
-
-
+ private List<System.Drawing.Size> _screenResolutions = new List<System.Drawing.Size>();
+ private int _resIndex = 0;
public void Close()
{
@@ -161,6 +266,11 @@ namespace ShiftOS.Frontend
}
}
+ _resDown.Visible = (_menuTitle.Text == "Options" && _resIndex > 0);
+ _resUp.Visible = (_menuTitle.Text == "Options" && _resIndex < _screenResolutions.Count - 1);
+ _resDisplay.Visible = _menuTitle.Text == "Options";
+ _optionsSave.Visible = _resDisplay.Visible;
+
Invalidate();
}