aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/ShiftOS.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.Frontend/ShiftOS.cs')
-rw-r--r--ShiftOS.Frontend/ShiftOS.cs99
1 files changed, 77 insertions, 22 deletions
diff --git a/ShiftOS.Frontend/ShiftOS.cs b/ShiftOS.Frontend/ShiftOS.cs
index f50c7d9..a2b1d67 100644
--- a/ShiftOS.Frontend/ShiftOS.cs
+++ b/ShiftOS.Frontend/ShiftOS.cs
@@ -1,8 +1,10 @@
using System;
+using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
+using ShiftOS.Engine;
using ShiftOS.Frontend.GraphicsSubsystem;
namespace ShiftOS.Frontend
@@ -18,15 +20,14 @@ namespace ShiftOS.Frontend
public ShiftOS()
{
GraphicsDevice = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- //Make the mouse cursor visible.
- this.IsMouseVisible = true;
+ GraphicsDevice.PreferredBackBufferHeight = 1080;
+ GraphicsDevice.PreferredBackBufferWidth = 1920;
- //Don't allow ALT+F4
- this.Window.AllowAltF4 = false;
+ Content.RootDirectory = "Content";
+
//Make window borderless
- Window.IsBorderless = true;
+ Window.IsBorderless = false;
//Set the title
Window.Title = "ShiftOS";
@@ -34,10 +35,12 @@ namespace ShiftOS.Frontend
//Fullscreen
- GraphicsDevice.IsFullScreen = true;
+ GraphicsDevice.IsFullScreen = false;
}
+ private GUI.TextControl _titleLabel = null;
+
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
@@ -46,21 +49,39 @@ namespace ShiftOS.Frontend
/// </summary>
protected override void Initialize()
{
- //We'll start by initializing the BARE FUNDAMENTALS of the ShiftOS engine.
- //This'll be enough to do skinning, fs, windowmanagement etc
- //so that we can make the main menu and yeah
-
- //Let's add a control to test something
- var textControl = new GUI.TextControl();
- textControl.Width = 640;
- textControl.Height = 480;
- UIManager.AddTopLevel(textControl);
-
- UIManager.AddTopLevel(framerate);
- framerate.Width = 640;
- framerate.Height = 480;
- framerate.TextAlign = GUI.TextAlign.BottomRight;
-
+ //Before we do ANYTHING, we've got to initiate the ShiftOS engine.
+
+ //First things first, let's initiate the window manager.
+ AppearanceManager.Initiate(new Desktop.WindowManager());
+ //Cool. Now the engine's window management system talks to us.
+
+ //Also initiate the desktop
+ Engine.Desktop.Init(new Desktop.Desktop());
+
+ //Now we can initiate the Infobox subsystem
+ Engine.Infobox.Init(new Infobox());
+
+
+ //Let's give it a try.
+ Engine.Infobox.Show("Welcome to ShiftOS!", "This is a test infobox. Clicking OK will dismiss it.");
+
+ //Let's set up the Main Menu UI.
+
+ var justthes = new GUI.PictureBox();
+ justthes.AutoSize = true;
+ justthes.ImageLayout = GUI.ImageLayout.Stretch;
+ justthes.Image = Properties.Resources.justthes;
+ justthes.X = 15;
+ justthes.Y = 15;
+ UIManager.AddTopLevel(justthes);
+
+ _titleLabel = new GUI.TextControl();
+ _titleLabel.Text = " - main menu - ";
+ _titleLabel.AutoSize = true;
+ _titleLabel.X = justthes.X;
+ _titleLabel.Y = justthes.Y + justthes.Height + 15;
+ _titleLabel.Font = SkinEngine.LoadedSkin.HeaderFont;
+ UIManager.AddTopLevel(_titleLabel);
base.Initialize();
@@ -100,9 +121,43 @@ namespace ShiftOS.Frontend
//Now let's process it.
UIManager.ProcessMouseState(mouseState);
+ //Cause layout update on all elements
+ UIManager.LayoutUpdate();
+
//set framerate
framerate.Text = "ShiftOS 1.0 Beta 4\r\nCopyright (c) 2017 ShiftOS\r\nFPS: " + (1 / gameTime.ElapsedGameTime.TotalSeconds);
+ //So we have mouse input, and the UI layout system working...
+
+ //But an OS isn't useful without the keyboard!
+
+ //Let's see how keyboard input works.
+
+ //Hmmm... just like the mouse...
+ var keystate = Keyboard.GetState();
+
+ //Simple... just iterate through this list and generate some key events?
+ var keys = keystate.GetPressedKeys();
+ if (keys.Length > 0)
+ {
+ //Of course, we need modifier keys...
+ //First for Control.
+ bool controlDown = keys.Contains(Keys.LeftControl) || keys.Contains(Keys.RightControl);
+ //Now SHIFT.
+ bool shiftDown = keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift);
+ //And ALT.
+ bool altDown = keys.Contains(Keys.LeftAlt) || keys.Contains(Keys.RightAlt);
+
+ foreach(var key in keys)
+ {
+ //This'll make it so we skip the modifier keys.
+ if(key != Keys.LeftAlt && key != Keys.RightAlt && key != Keys.LeftControl && key != Keys.RightControl && key != Keys.LeftShift && key != Keys.RightShift)
+ {
+ var keyevent = new KeyEvent(controlDown, altDown, shiftDown, key);
+ UIManager.ProcessKeyEvent(keyevent);
+ }
+ }
+ }
base.Update(gameTime);
}