From 2acfa34596061a9236bb6a9df1e3f3a0c01d6ff0 Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Tue, 13 Jun 2017 20:06:38 +1000 Subject: Python API It uses a meta-language and a CSharpCodeProvider on startup. I will release a tutorial on the forums soon showing how to use it. This commit also adds an extremely basic loading screen which shows while Desktop is getting everything ready. Which can take a while if you have any Python mods. Thanks, IronPython. --- ShiftOS.WinForms/MainMenu/Loading.Designer.cs | 66 ++++++++++++++ ShiftOS.WinForms/MainMenu/Loading.cs | 31 +++++++ ShiftOS.WinForms/MainMenu/Loading.resx | 120 ++++++++++++++++++++++++++ ShiftOS.WinForms/MainMenu/MainMenu.cs | 13 ++- 4 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 ShiftOS.WinForms/MainMenu/Loading.Designer.cs create mode 100644 ShiftOS.WinForms/MainMenu/Loading.cs create mode 100644 ShiftOS.WinForms/MainMenu/Loading.resx (limited to 'ShiftOS.WinForms/MainMenu') diff --git a/ShiftOS.WinForms/MainMenu/Loading.Designer.cs b/ShiftOS.WinForms/MainMenu/Loading.Designer.cs new file mode 100644 index 0000000..95619d9 --- /dev/null +++ b/ShiftOS.WinForms/MainMenu/Loading.Designer.cs @@ -0,0 +1,66 @@ +namespace ShiftOS.WinForms.MainMenu +{ + partial class Loading + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label + // + this.label.Dock = System.Windows.Forms.DockStyle.Fill; + this.label.Font = new System.Drawing.Font("Tahoma", 72F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label.ForeColor = System.Drawing.Color.White; + this.label.Location = new System.Drawing.Point(0, 0); + this.label.Name = "label"; + this.label.Size = new System.Drawing.Size(284, 262); + this.label.TabIndex = 0; + this.label.Text = "Loading..."; + this.label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // Loading + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.label); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "Loading"; + this.Text = "Loading"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Shown += new System.EventHandler(this.Loading_FormShown); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/MainMenu/Loading.cs b/ShiftOS.WinForms/MainMenu/Loading.cs new file mode 100644 index 0000000..555f1d4 --- /dev/null +++ b/ShiftOS.WinForms/MainMenu/Loading.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.MainMenu +{ + public partial class Loading : Form + { + public Loading() + { + InitializeComponent(); + } + + private void Loading_FormShown(object sender, EventArgs e) + { + // This hideous timer thing is the most reliable way to make the form update + // before it starts doing stuff. + var callback = new Timer(); + callback.Tick += (o, a) => { Desktop.CurrentDesktop.Show(); Hide(); callback.Stop(); }; + callback.Interval = 1; + callback.Start(); + } + } +} diff --git a/ShiftOS.WinForms/MainMenu/Loading.resx b/ShiftOS.WinForms/MainMenu/Loading.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/MainMenu/Loading.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.cs b/ShiftOS.WinForms/MainMenu/MainMenu.cs index e11edc2..1936fec 100644 --- a/ShiftOS.WinForms/MainMenu/MainMenu.cs +++ b/ShiftOS.WinForms/MainMenu/MainMenu.cs @@ -15,6 +15,11 @@ namespace ShiftOS.WinForms.MainMenu { public partial class MainMenu : Form { + private void StartGame() + { + new Loading().Show(); + } + public MainMenu(IDesktop desk) { InitializeComponent(); @@ -163,7 +168,7 @@ namespace ShiftOS.WinForms.MainMenu private void button2_Click(object sender, EventArgs e) { (Desktop.CurrentDesktop as WinformsDesktop).IsSandbox = true; - Desktop.CurrentDesktop.Show(); + StartGame(); } private void button3_Click(object sender, EventArgs e) @@ -239,7 +244,7 @@ namespace ShiftOS.WinForms.MainMenu private void btncontinue_Click(object sender, EventArgs e) { - Desktop.CurrentDesktop.Show(); + StartGame(); } @@ -253,13 +258,13 @@ namespace ShiftOS.WinForms.MainMenu if (result == true) { System.IO.File.Delete(path); - Desktop.CurrentDesktop.Show(); + StartGame(); } }); } else { - Desktop.CurrentDesktop.Show(); + StartGame(); } } } -- cgit v1.2.3