From a9754b7df28795b6bb2c5cfe04c1b38b19fb0d05 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Mar 2017 12:29:28 -0500 Subject: Lock certain apps away when system offline. --- ShiftOS.WinForms/WinformsWindowManager.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index b8f0cae..eeaa6c9 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -106,6 +106,24 @@ namespace ShiftOS.WinForms return; } + foreach(var attr in form.GetType().GetCustomAttributes(true)) + { + if(attr is MultiplayerOnlyAttribute) + { + if(KernelWatchdog.MudConnected == false) + { + Infobox.PromptYesNo("Disconnected from MUD", "This application requires a connection to the MUD. Would you like to reconnect?", new Action((answer) => + { + if(answer == true) + { + KernelWatchdog.MudConnected = true; + SetupWindow(form); + } + })); + return; + } + } + } if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) { -- cgit v1.2.3 From f89cd092830a8e88bd9aaf8048c18b0dda7dea25 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Apr 2017 14:26:25 -0400 Subject: Various bugfixes. --- ShiftOS.WinForms/Controls/TerminalBox.cs | 8 +++ ShiftOS.WinForms/Oobe.cs | 22 +++---- ShiftOS.WinForms/WinformsDesktop.cs | 5 +- ShiftOS.WinForms/WinformsWindowManager.cs | 104 +++++++++++++++++++++++++++++- ShiftOS_TheReturn/AudioManager.cs | 2 +- ShiftOS_TheReturn/TerminalTextWriter.cs | 8 +-- 6 files changed, 129 insertions(+), 20 deletions(-) (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 9e4c61c..bc2bcc0 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -47,6 +47,14 @@ namespace ShiftOS.WinForms.Controls catch { } } + protected override void Dispose(bool disposing) + { + if (disposing == true) + if(AppearanceManager.ConsoleOut == this) + AppearanceManager.ConsoleOut = null; + base.Dispose(disposing); + } + protected override void OnClick(EventArgs e) { base.OnClick(e); diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 7370396..898f60b 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -419,7 +419,7 @@ namespace ShiftOS.WinForms Clear(); textgeninput = lblhackwords; Clear(); - + this.Invoke(new Action(() => { textgeninput.Font = SkinEngine.LoadedSkin.TerminalFont; @@ -450,7 +450,7 @@ namespace ShiftOS.WinForms TextType("In ShiftOS, the Terminal is your main control centre for the operating system. You can see system status, check Codepoints, open other programs, buy upgrades, and more."); Thread.Sleep(500); TextType("Go ahead and type 'sos.help' to see a list of commands."); - while(TutorialProgress == 0) + while (TutorialProgress == 0) { } @@ -459,7 +459,7 @@ namespace ShiftOS.WinForms TextType("You can run any command, by typing in their Namespace, followed by a period (.), followed by their Command Name."); Thread.Sleep(500); TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does."); - while(TutorialProgress == 1) + while (TutorialProgress == 1) { } @@ -476,7 +476,7 @@ namespace ShiftOS.WinForms TextType("You can easily get upgrades using the Shiftorium - a repository of approved ShiftOS upgrades."); Thread.Sleep(500); TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades."); - while(TutorialProgress == 2) + while (TutorialProgress == 2) { } @@ -500,17 +500,17 @@ namespace ShiftOS.WinForms TextType("If you want to escape a backslash inside a string, simply type two backslashes instead of one - for example key:\"Back\\\\slash.\""); Thread.Sleep(500); TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID."); - while(TutorialProgress == 3) + while (TutorialProgress == 3) { - } + } TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!"); Thread.Sleep(500); TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!"); while (!Shiftorium.UpgradeInstalled("mud_fundamentals")) { - } + } TextType("Hooray! You now have the MUD Fundamentals upgrade."); Thread.Sleep(500); TextType("You can also earn more Codepoints by playing Pong. To open Pong, you can use the win.open command."); @@ -518,20 +518,20 @@ namespace ShiftOS.WinForms TextType("If you run win.open without arguments, you can see a list of applications that you can open."); Thread.Sleep(500); TextType("Just run win.open without arguments, and this tutorial will be completed!"); - while(TutorialProgress == 4) + while (TutorialProgress == 4) { } TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world."); Thread.Sleep(2000); - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(() => { OnComplete?.Invoke(this, EventArgs.Empty); - this.Close(); SaveSystem.CurrentSave.StoryPosition = 2; SaveSystem.SaveGame(); AppearanceManager.SetupWindow(new Applications.Terminal()); - })); + }); + }); t.IsBackground = true; t.Start(); diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index d30adb4..06f103e 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -664,7 +664,10 @@ namespace ShiftOS.WinForms /// Act. public void InvokeOnWorkerThread(Action act) { - this.Invoke(act); + this.Invoke(new Action(()=> + { + act?.Invoke(); + })); } public void OpenAppLauncher(Point loc) diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index eeaa6c9..40177be 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -36,6 +36,24 @@ namespace ShiftOS.WinForms { internal class WinformsWindowManager : WindowManager { + public int DesktopHeight + { + get + { + return Desktop.Size.Height - ((Shiftorium.UpgradeInstalled("desktop_panel") == true) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0); + } + } + + public int TopLocation + { + get + { + if (!Shiftorium.UpgradeInstalled("desktop_panel")) + return 0; + return ((SkinEngine.LoadedSkin.DesktopPanelPosition == 0) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0); + } + } + public override void Close(IShiftOSWindow win) { (win as UserControl).Close(); @@ -160,9 +178,11 @@ namespace ShiftOS.WinForms { List formstoclose = new List(); - foreach (WindowBorder frm in AppearanceManager.OpenForms) + for (int i = 0; i < maxWindows && i < AppearanceManager.OpenForms.Count; i++) { - formstoclose.Add(frm); + var frm = AppearanceManager.OpenForms[i] as WindowBorder; + if(!frm.IsDialog) + formstoclose.Add(frm); } @@ -177,7 +197,85 @@ namespace ShiftOS.WinForms var wb = new WindowBorder(form as UserControl); - ControlManager.SetupWindows(); + SetupWindows(); + } + + public void SetupWindows() + { + var windows = new List(); + foreach(var win in AppearanceManager.OpenForms) + { + if (win is WindowBorder) + if ((win as WindowBorder).IsDialog == false) + windows.Add(win as WindowBorder); + } + + if (Shiftorium.UpgradeInstalled("wm_free_placement")) + return; + + else if (windows.Count == 4) + { + var w1 = windows[0]; + var w2 = windows[1]; + var w3 = windows[2]; + var w4 = windows[3]; + w1.Location = new Point(0, TopLocation); + w1.Width = Desktop.Size.Width / 2; + w1.Height = DesktopHeight / 2; + w2.Left = w1.Width; + w2.Width = w1.Width; + w2.Height = w1.Height; + w2.Top = w1.Top; + w3.Top = w2.Height; + w3.Height = w1.Height; + w3.Left = 0; + w3.Width = w1.Width; + w4.Width = w3.Width; + w4.Top = w3.Top; + w4.Left = w3.Width; + w4.Height = w3.Height; + } + else if(windows.Count == 3) + { + var w1 = windows[0]; + var w2 = windows[1]; + var w3 = windows[2]; + w1.Location = new Point(0, TopLocation); + w1.Width = Desktop.Size.Width / 2; + w1.Height = DesktopHeight / 2; + w2.Left = w1.Width; + w2.Width = w1.Width; + w2.Height = w1.Height; + w2.Top = w1.Top; + w3.Top = w2.Height; + w3.Height = w1.Height; + w3.Left = 0; + w3.Width = w1.Width + w2.Width; + } + else if (windows.Count == 2) + { + var w1 = windows[0]; + var w2 = windows[1]; + + w1.Location = new Point(0, TopLocation); + w1.Width = Desktop.Size.Width / 2; + w1.Height = DesktopHeight; + w2.Left = w1.Width; + w2.Width = w1.Width; + w2.Height = w1.Height; + w2.Top = w1.Top; + + } + else if(windows.Count == 1) + { + var win = windows.FirstOrDefault(); + if(win != null) + { + win.Size = new Size(Desktop.Size.Width, DesktopHeight); + win.Location = new Point(0, this.TopLocation); + } + } + } } } diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 7f6f5e9..7466eeb 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -22,7 +22,7 @@ * SOFTWARE. */ -//#define NOSOUND +#define NOSOUND using System; using System.Collections.Generic; diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index bc242a9..55e27cf 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -58,7 +58,7 @@ namespace ShiftOS.Engine { Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl.SelectBottom(); + UnderlyingControl?.SelectBottom(); })); } @@ -76,7 +76,7 @@ namespace ShiftOS.Engine { Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl.Write(value.ToString()); + UnderlyingControl?.Write(value.ToString()); select(); })); } @@ -96,7 +96,7 @@ namespace ShiftOS.Engine Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl.WriteLine(value); + UnderlyingControl?.WriteLine(value); select(); })); } @@ -120,7 +120,7 @@ namespace ShiftOS.Engine Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl.Write(value.ToString()); + UnderlyingControl?.Write(value.ToString()); select(); })); } -- cgit v1.2.3 From a3f3e03569e0268ddc70c699d49bc70331f60ab2 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Apr 2017 14:37:59 -0400 Subject: Call OnUpgrade() when upgrade installed. --- ShiftOS.WinForms/WindowBorder.cs | 8 +++++++- ShiftOS.WinForms/WinformsWindowManager.cs | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 0308f8a..4fba470 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -124,7 +124,6 @@ namespace ShiftOS.WinForms } }; - this.Width = LoadedSkin.LeftBorderWidth + _parentWindow.Width + LoadedSkin.RightBorderWidth; this.Height = LoadedSkin.TitlebarHeight + _parentWindow.Height + LoadedSkin.BottomBorderWidth; @@ -133,6 +132,13 @@ namespace ShiftOS.WinForms this._parentWindow.Show(); ControlManager.SetupControls(this._parentWindow); + ParentWindow.OnSkinLoad(); + ParentWindow.OnUpgrade(); + Shiftorium.Installed += () => + { + Setup(); + ParentWindow.OnUpgrade(); + }; Desktop.ShowWindow(this); diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index 40177be..494c572 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -197,6 +197,13 @@ namespace ShiftOS.WinForms var wb = new WindowBorder(form as UserControl); + FormClosedEventHandler onClose = (o,a)=> { }; + onClose = (o, a) => + { + SetupWindows(); + wb.FormClosed -= onClose; + }; + wb.FormClosed += onClose; SetupWindows(); } -- cgit v1.2.3 From 2612721346bc59807c4963d5e8c2f936852aa48b Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Apr 2017 18:29:42 -0400 Subject: Reconnect to MUD after unexpected loss --- ShiftOS.WinForms/WinformsWindowManager.cs | 12 ++++++++++-- ShiftOS_TheReturn/ServerManager.cs | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index 494c572..26438bf 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -40,7 +40,7 @@ namespace ShiftOS.WinForms { get { - return Desktop.Size.Height - ((Shiftorium.UpgradeInstalled("desktop_panel") == true) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0); + return Desktop.Size.Height - ((Shiftorium.UpgradeInstalled("desktop") == true) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0); } } @@ -48,7 +48,7 @@ namespace ShiftOS.WinForms { get { - if (!Shiftorium.UpgradeInstalled("desktop_panel")) + if (!Shiftorium.UpgradeInstalled("desktop")) return 0; return ((SkinEngine.LoadedSkin.DesktopPanelPosition == 0) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0); } @@ -64,6 +64,14 @@ namespace ShiftOS.WinForms Desktop.InvokeOnWorkerThread(act); } + public WinformsWindowManager() + { + Shiftorium.Installed += () => + { + SetupWindows(); + }; + } + public override void Maximize(IWindowBorder form) { try diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 31b3129..4fce247 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -51,9 +51,11 @@ namespace ShiftOS.Engine public static Guid thisGuid { get; private set; } private static NetObjectClient client { get; set; } + private static bool UserDisconnect = false; public static void Disconnect() { + UserDisconnect = true; if (client != null) { client.Disconnect(); @@ -117,7 +119,23 @@ namespace ShiftOS.Engine public static void Initiate(string mud_address, int port) { client = new NetObjectClient(); - + client.OnDisconnected += (o, a) => + { + if (!UserDisconnect) + { + TerminalBackend.PrefixEnabled = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + ConsoleEx.Bold = true; + Console.Write($@"Disconnected from MUD: "); + ConsoleEx.Bold = false; + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine("You have been disconnected from the multi-user domain for an unknown reason. Your save data is preserved within the kernel and you will be reconnected shortly."); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + Initiate(mud_address, port); + } + }; client.OnReceived += (o, a) => { var msg = a.Data.Object as ServerMessage; -- cgit v1.2.3 From f43f6fe17d054f83c686b552201d6b4bfc83524d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 3 Apr 2017 18:36:13 -0400 Subject: LOADS of optimizations and Pong fixes. --- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 - ShiftOS.Objects/ShiftOSMenuRenderer.cs | 51 ------- ShiftOS.WinForms/Applications/Pong.Designer.cs | 177 +++++++++++++------------ ShiftOS.WinForms/Applications/Pong.cs | 36 ++++- ShiftOS.WinForms/Oobe.cs | 30 ++++- ShiftOS.WinForms/Tools/ControlManager.cs | 107 +++------------ ShiftOS.WinForms/WinformsDesktop.cs | 13 +- ShiftOS.WinForms/WinformsWindowManager.cs | 17 +-- ShiftOS_TheReturn/Shiftorium.cs | 28 +++- 9 files changed, 217 insertions(+), 243 deletions(-) delete mode 100644 ShiftOS.Objects/ShiftOSMenuRenderer.cs (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 3dc0c33..4514b68 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -54,7 +54,6 @@ - diff --git a/ShiftOS.Objects/ShiftOSMenuRenderer.cs b/ShiftOS.Objects/ShiftOSMenuRenderer.cs deleted file mode 100644 index c76bd35..0000000 --- a/ShiftOS.Objects/ShiftOSMenuRenderer.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ShiftOS.Objects -{ - class ShiftOSMenuRenderer : ToolStripProfessionalRenderer - { - public ShiftOSMenuRenderer() : base(new ShiftOSColorTable()) - { - - } - - protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) - { - - } - } - - public class ShiftOSColorTable : ProfessionalColorTable - { - - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index faaf0f5..e619eaa 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -79,6 +79,11 @@ namespace ShiftOS.WinForms.Applications this.tmrcountdown = new System.Windows.Forms.Timer(this.components); this.tmrstoryline = new System.Windows.Forms.Timer(this.components); this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); + this.pnlhighscore = new System.Windows.Forms.Panel(); + this.lbhighscore = new System.Windows.Forms.ListBox(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.button2 = new System.Windows.Forms.Button(); + this.label10 = new System.Windows.Forms.Label(); this.pnlgamestats = new System.Windows.Forms.Panel(); this.button1 = new System.Windows.Forms.Button(); this.label12 = new System.Windows.Forms.Label(); @@ -91,9 +96,6 @@ namespace ShiftOS.WinForms.Applications this.btncashout = new System.Windows.Forms.Button(); this.Label2 = new System.Windows.Forms.Label(); this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListBox(); - this.label10 = new System.Windows.Forms.Label(); this.pnlfinalstats = new System.Windows.Forms.Panel(); this.btnplayagain = new System.Windows.Forms.Button(); this.lblfinalcodepoints = new System.Windows.Forms.Label(); @@ -122,16 +124,14 @@ namespace ShiftOS.WinForms.Applications this.lblstatscodepoints = new System.Windows.Forms.Label(); this.lblstatsY = new System.Windows.Forms.Label(); this.lblstatsX = new System.Windows.Forms.Label(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); this.pgcontents.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); this.pnlhighscore.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + this.pnlgamestats.SuspendLayout(); this.pnlfinalstats.SuspendLayout(); this.pnllose.SuspendLayout(); this.pnlintro.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // gameTimer @@ -174,11 +174,67 @@ namespace ShiftOS.WinForms.Applications this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; this.pgcontents.Location = new System.Drawing.Point(0, 0); this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(700, 400); + this.pgcontents.Size = new System.Drawing.Size(1867, 819); this.pgcontents.TabIndex = 20; this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); // + // pnlhighscore + // + this.pnlhighscore.Controls.Add(this.lbhighscore); + this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); + this.pnlhighscore.Controls.Add(this.label10); + this.pnlhighscore.Location = new System.Drawing.Point(688, 302); + this.pnlhighscore.Name = "pnlhighscore"; + this.pnlhighscore.Size = new System.Drawing.Size(539, 311); + this.pnlhighscore.TabIndex = 14; + this.pnlhighscore.Visible = false; + // + // lbhighscore + // + this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbhighscore.FormattingEnabled = true; + this.lbhighscore.Location = new System.Drawing.Point(0, 36); + this.lbhighscore.MultiColumn = true; + this.lbhighscore.Name = "lbhighscore"; + this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None; + this.lbhighscore.Size = new System.Drawing.Size(539, 246); + this.lbhighscore.TabIndex = 1; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.button2); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); + this.flowLayoutPanel1.TabIndex = 2; + // + // button2 + // + this.button2.AutoSize = true; + this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button2.Location = new System.Drawing.Point(476, 3); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(60, 23); + this.button2.TabIndex = 0; + this.button2.Text = "{CLOSE}"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label10 + // + this.label10.Dock = System.Windows.Forms.DockStyle.Top; + this.label10.Location = new System.Drawing.Point(0, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(539, 36); + this.label10.TabIndex = 0; + this.label10.Text = "{HIGH_SCORES}"; + this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // // pnlgamestats // this.pnlgamestats.Controls.Add(this.button1); @@ -192,7 +248,7 @@ namespace ShiftOS.WinForms.Applications this.pnlgamestats.Controls.Add(this.btncashout); this.pnlgamestats.Controls.Add(this.Label2); this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(56, 76); + this.pnlgamestats.Location = new System.Drawing.Point(104, 375); this.pnlgamestats.Name = "pnlgamestats"; this.pnlgamestats.Size = new System.Drawing.Size(466, 284); this.pnlgamestats.TabIndex = 6; @@ -307,38 +363,6 @@ namespace ShiftOS.WinForms.Applications this.lbllevelreached.TabIndex = 0; this.lbllevelreached.Text = "You Reached Level 2!"; // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(67, 29); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.FormattingEnabled = true; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.MultiColumn = true; - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // // pnlfinalstats // this.pnlfinalstats.Controls.Add(this.btnplayagain); @@ -373,6 +397,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinalcodepoints.Name = "lblfinalcodepoints"; this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); this.lblfinalcodepoints.TabIndex = 15; + this.lblfinalcodepoints.Tag = "header1"; this.lblfinalcodepoints.Text = "134 CP"; this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -384,6 +409,7 @@ namespace ShiftOS.WinForms.Applications this.Label11.Name = "Label11"; this.Label11.Size = new System.Drawing.Size(33, 33); this.Label11.TabIndex = 14; + this.Label11.Tag = "header2"; this.Label11.Text = "+"; this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -394,6 +420,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); this.lblfinalcomputerreward.TabIndex = 12; + this.lblfinalcomputerreward.Tag = "header2"; this.lblfinalcomputerreward.Text = "34"; this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -413,6 +440,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinallevelreward.Name = "lblfinallevelreward"; this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); this.lblfinallevelreward.TabIndex = 10; + this.lblfinallevelreward.Tag = "header2"; this.lblfinallevelreward.Text = "100"; this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -432,6 +460,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); this.lblfinalcodepointswithtext.TabIndex = 1; + this.lblfinalcodepointswithtext.Tag = "header2"; this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -502,10 +531,11 @@ namespace ShiftOS.WinForms.Applications this.pnlintro.Controls.Add(this.Label6); this.pnlintro.Controls.Add(this.btnstartgame); this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(52, 29); + this.pnlintro.Location = new System.Drawing.Point(1139, 41); this.pnlintro.Name = "pnlintro"; this.pnlintro.Size = new System.Drawing.Size(595, 303); this.pnlintro.TabIndex = 13; + this.pnlintro.Tag = "header2"; // // Label6 // @@ -548,6 +578,7 @@ namespace ShiftOS.WinForms.Applications this.lblbeatai.Name = "lblbeatai"; this.lblbeatai.Size = new System.Drawing.Size(600, 30); this.lblbeatai.TabIndex = 8; + this.lblbeatai.Tag = "header2"; this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblbeatai.Visible = false; @@ -577,7 +608,6 @@ namespace ShiftOS.WinForms.Applications // this.paddleHuman.BackColor = System.Drawing.Color.Black; this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); this.paddleHuman.Name = "paddleHuman"; this.paddleHuman.Size = new System.Drawing.Size(20, 100); this.paddleHuman.TabIndex = 3; @@ -587,7 +617,7 @@ namespace ShiftOS.WinForms.Applications // this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(666, 134); + this.paddleComputer.Location = new System.Drawing.Point(1833, 134); this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); this.paddleComputer.Name = "paddleComputer"; this.paddleComputer.Size = new System.Drawing.Size(20, 100); @@ -599,69 +629,52 @@ namespace ShiftOS.WinForms.Applications this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); this.lbllevelandtime.Name = "lbllevelandtime"; - this.lbllevelandtime.Size = new System.Drawing.Size(700, 22); + this.lbllevelandtime.Size = new System.Drawing.Size(1867, 22); this.lbllevelandtime.TabIndex = 4; + this.lbllevelandtime.Tag = "header1"; this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblstatscodepoints // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.lblstatscodepoints.AutoSize = true; this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 356); + this.lblstatscodepoints.Location = new System.Drawing.Point(239, 775); this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(219, 35); + this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23); this.lblstatscodepoints.TabIndex = 12; + this.lblstatscodepoints.Tag = "header2"; this.lblstatscodepoints.Text = "Codepoints: "; this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblstatsY // this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lblstatsY.AutoSize = true; this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsY.Location = new System.Drawing.Point(542, 356); + this.lblstatsY.Location = new System.Drawing.Point(1395, 775); this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(144, 35); + this.lblstatsY.Size = new System.Drawing.Size(76, 23); this.lblstatsY.TabIndex = 11; + this.lblstatsY.Tag = "header2"; this.lblstatsY.Text = "Yspeed:"; this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblstatsX // this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblstatsX.AutoSize = true; this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsX.Location = new System.Drawing.Point(3, 356); + this.lblstatsX.Location = new System.Drawing.Point(3, 775); this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(144, 35); + this.lblstatsX.Size = new System.Drawing.Size(83, 23); this.lblstatsX.TabIndex = 5; + this.lblstatsX.Tag = "header2"; this.lblstatsX.Text = "Xspeed: "; this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // // Pong // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -670,23 +683,23 @@ namespace ShiftOS.WinForms.Applications this.Controls.Add(this.pgcontents); this.DoubleBuffered = true; this.Name = "Pong"; - this.Text = "{PONG_NAME}"; - this.Size = new System.Drawing.Size(820, 500); + this.Size = new System.Drawing.Size(1867, 819); this.Load += new System.EventHandler(this.Pong_Load); this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); this.pgcontents.ResumeLayout(false); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); + this.pgcontents.PerformLayout(); this.pnlhighscore.ResumeLayout(false); this.pnlhighscore.PerformLayout(); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); + this.pnlgamestats.ResumeLayout(false); + this.pnlgamestats.PerformLayout(); this.pnlfinalstats.ResumeLayout(false); this.pnlfinalstats.PerformLayout(); this.pnllose.ResumeLayout(false); this.pnlintro.ResumeLayout(false); this.pnlintro.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 157ce8c..a7b1aeb 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { @@ -83,6 +84,26 @@ namespace ShiftOS.WinForms.Applications paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); } + private void CenterPanels() + { + pnlfinalstats.CenterParent(); + pnlgamestats.CenterParent(); + pnlhighscore.CenterParent(); + pnlintro.CenterParent(); + pnllose.CenterParent(); + lblcountdown.CenterParent(); + lblbeatai.Left = (this.Width - lblbeatai.Width) / 2; + SetupStats(); + } + + public void SetupStats() + { + lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5); + lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5); + lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5; + lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2; + } + // ERROR: Handles clauses are not supported in C# private void gameTimer_Tick(object sender, EventArgs e) @@ -102,7 +123,7 @@ namespace ShiftOS.WinForms.Applications //Set the computer player to move according to the ball's position. if (aiShouldIsbeEnabled) - if (ball.Location.X > 500 - xVel * 10 && xVel > 0) + if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) { if (ball.Location.Y > paddleComputer.Location.Y + 50) { @@ -116,12 +137,12 @@ namespace ShiftOS.WinForms.Applications } else { - //used to be me.location.y + //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) { paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); } - //used to be me.location.y + //Rylan is hot. Used to be //used to be me.location.y if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) { paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); @@ -269,6 +290,7 @@ namespace ShiftOS.WinForms.Applications } lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); } + SetupStats(); } public void SendHighscores() @@ -652,10 +674,17 @@ namespace ShiftOS.WinForms.Applications pnlhighscore.Hide(); pnlgamestats.Hide(); pnlfinalstats.Hide(); + CenterPanels(); + lblbeatai.Hide(); } public void OnSkinLoad() { + CenterPanels(); + this.SizeChanged += (o, a) => + { + CenterPanels(); + }; } public bool OnUnload() @@ -665,6 +694,7 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + CenterPanels(); } private void button2_Click(object sender, EventArgs e) diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 898f60b..d6d3b92 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -64,7 +64,10 @@ namespace ShiftOS.WinForms { while(typing == true) { + //JESUS CHRIST PAST MICHAEL. + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } charcount = texttotype.Length; @@ -452,6 +455,10 @@ namespace ShiftOS.WinForms TextType("Go ahead and type 'sos.help' to see a list of commands."); while (TutorialProgress == 0) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("As you can see, sos.help gives you a list of all commands in the system."); @@ -461,6 +468,10 @@ namespace ShiftOS.WinForms TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does."); while (TutorialProgress == 1) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available."); @@ -478,6 +489,10 @@ namespace ShiftOS.WinForms TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades."); while (TutorialProgress == 2) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } Clear(); @@ -502,13 +517,21 @@ namespace ShiftOS.WinForms TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID."); while (TutorialProgress == 3) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!"); Thread.Sleep(500); TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!"); while (!Shiftorium.UpgradeInstalled("mud_fundamentals")) - { + { //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); + } TextType("Hooray! You now have the MUD Fundamentals upgrade."); @@ -520,6 +543,10 @@ namespace ShiftOS.WinForms TextType("Just run win.open without arguments, and this tutorial will be completed!"); while (TutorialProgress == 4) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world."); @@ -528,6 +555,7 @@ namespace ShiftOS.WinForms { OnComplete?.Invoke(this, EventArgs.Empty); SaveSystem.CurrentSave.StoryPosition = 2; + this.Close(); SaveSystem.SaveGame(); AppearanceManager.SetupWindow(new Applications.Terminal()); }); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 52663d7..a2a76b7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -67,91 +67,6 @@ namespace ShiftOS.WinForms.Tools } - public static void SetupWindows() - { - if (SaveSystem.CurrentSave != null) - { - int screen_height_start = 0; - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - } - else if (Shiftorium.UpgradeInstalled("wm_4_windows")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height_half = (Screen.PrimaryScreen.Bounds.Height - screen_height_start) / 2; - - for (int i = 0; i < OpenForms.Count; i++) - { - var frm = OpenForms[i] as WindowBorder; - - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - case 2: - frm.Location = new System.Drawing.Point(0, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 3) ? screen_width_half : screen_width_half * 2, screen_height_half); - break; - case 3: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - } - } - - } - else if (Shiftorium.UpgradeInstalled("window_manager")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height = (Screen.PrimaryScreen.Bounds.Height) - screen_height_start; - - - - for (int i = 0; i < OpenForms.Count; i++) - { - - - var frm = OpenForms[i] as WindowBorder; - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, screen_height); - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, screen_height); - break; - } - OpenForms[i] = frm; - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - internal static Color ConvertColor(ConsoleColor cCol) { switch (cCol) @@ -214,9 +129,22 @@ namespace ShiftOS.WinForms.Tools #endif } + /// + /// Centers the control along its parent. + /// + /// The control to center (this is an extension method - you can call it on a control as though it was a method in that control) + public static void CenterParent(this Control ctrl) + { + ctrl.Location = new Point( + (ctrl.Parent.Width - ctrl.Width) / 2, + (ctrl.Parent.Height - ctrl.Height) / 2 + ); + } + public static void SetupControl(Control ctrl) { SuspendDrawing(ctrl); + ctrl.SuspendLayout(); SetCursor(ctrl); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { @@ -270,13 +198,7 @@ namespace ShiftOS.WinForms.Tools a.SuppressKeyPress = true; - if (SaveSystem.CurrentSave != null) - { - if (Shiftorium.UpgradeInstalled("window_manager")) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - } + Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); } ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); @@ -293,6 +215,7 @@ namespace ShiftOS.WinForms.Tools } MakeDoubleBuffered(ctrl); + ctrl.ResumeLayout(); ResumeDrawing(ctrl); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 06f103e..033802e 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -664,10 +664,17 @@ namespace ShiftOS.WinForms /// Act. public void InvokeOnWorkerThread(Action act) { - this.Invoke(new Action(()=> + try { - act?.Invoke(); - })); + this.Invoke(new Action(() => + { + act?.Invoke(); + })); + } + catch + { + + } } public void OpenAppLauncher(Point loc) diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index 26438bf..cfcb6d3 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -184,20 +184,21 @@ namespace ShiftOS.WinForms if (maxWindows > 0) { - List formstoclose = new List(); - - for (int i = 0; i < maxWindows && i < AppearanceManager.OpenForms.Count; i++) + var windows = new List(); + foreach(var WB in AppearanceManager.OpenForms) { - var frm = AppearanceManager.OpenForms[i] as WindowBorder; - if(!frm.IsDialog) - formstoclose.Add(frm); - + if (WB is WindowBorder) + windows.Add(WB as WindowBorder); } + List formstoclose = new List(windows.Where(x => x.IsDialog == false).ToArray()); + while (formstoclose.Count > maxWindows - 1) { - formstoclose[0].Close(); + this.Close(formstoclose[0].ParentWindow); + AppearanceManager.OpenForms.Remove(formstoclose[0]); formstoclose.RemoveAt(0); + } } } diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 0bdd9f4..4556cd6 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -46,6 +46,23 @@ namespace ShiftOS.Engine Installed?.Invoke(); } + public static string GetCategory(string id) + { + var upg = GetDefaults().FirstOrDefault(x => x.ID == id); + if (upg == null) + return "Other"; + return (upg.Category == null) ? "Other" : upg.Category; + } + + public static IEnumerable GetAllInCategory(string cat) + { + return GetDefaults().Where(x => x.Category == cat); + } + + public static bool IsCategoryEmptied(string cat) + { + return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null; + } public static bool Buy(string id, int cost) { @@ -278,8 +295,15 @@ namespace ShiftOS.Engine public string Description { get; set; } public int Cost { get; set; } public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } - public string Id { get; } - + public string Id { get; set; } + public string Category { get; set; } + public bool Installed + { + get + { + return Shiftorium.UpgradeInstalled(ID); + } + } public string Dependencies { get; set; } } } -- cgit v1.2.3 From 791290857f6feed7da6b583b8f39cb45698d69e8 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 10:03:28 -0400 Subject: Huge optimizations. Windows load A LOT faster, and Shifter has a preview. --- ShiftOS.WinForms/Applications/Shifter.Designer.cs | 467 +++++++++++++++++++--- ShiftOS.WinForms/Applications/Shifter.cs | 245 +++++++++++- ShiftOS.WinForms/Applications/Shifter.resx | 52 +++ ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs | 51 ++- ShiftOS.WinForms/WindowBorder.cs | 75 ++-- ShiftOS.WinForms/WinformsWindowManager.cs | 4 +- ShiftOS_TheReturn/Skinning.cs | 10 +- 7 files changed, 793 insertions(+), 111 deletions(-) (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.Designer.cs b/ShiftOS.WinForms/Applications/Shifter.Designer.cs index 44045b5..4520e2a 100644 --- a/ShiftOS.WinForms/Applications/Shifter.Designer.cs +++ b/ShiftOS.WinForms/Applications/Shifter.Designer.cs @@ -52,103 +52,284 @@ namespace ShiftOS.WinForms.Applications /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Shifter)); this.panel1 = new System.Windows.Forms.Panel(); - this.panel4 = new System.Windows.Forms.Panel(); + this.pnlpreview = new System.Windows.Forms.Panel(); + this.pnlwindow = new System.Windows.Forms.Panel(); + this.pnlcontents = new System.Windows.Forms.Panel(); + this.pnltitle = new System.Windows.Forms.Panel(); + this.pnlicon = new System.Windows.Forms.Panel(); + this.pnlminimize = new System.Windows.Forms.Panel(); + this.pnlmaximize = new System.Windows.Forms.Panel(); + this.pnlclose = new System.Windows.Forms.Panel(); + this.pnltitleleft = new System.Windows.Forms.Panel(); + this.pnltitleright = new System.Windows.Forms.Panel(); + this.lbtitletext = new System.Windows.Forms.Label(); + this.pnlbottom = new System.Windows.Forms.Panel(); + this.pnlbottomr = new System.Windows.Forms.Panel(); + this.pnlbottoml = new System.Windows.Forms.Panel(); + this.pnlright = new System.Windows.Forms.Panel(); + this.pnlleft = new System.Windows.Forms.Panel(); + this.pnlsettingsholder = new System.Windows.Forms.Panel(); this.flbody = new System.Windows.Forms.FlowLayoutPanel(); this.flcategory = new System.Windows.Forms.FlowLayoutPanel(); - this.panel3 = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.panel2 = new System.Windows.Forms.Panel(); + this.pnlcategoryholder = new System.Windows.Forms.Panel(); this.flmeta = new System.Windows.Forms.FlowLayoutPanel(); this.btnapply = new System.Windows.Forms.Button(); + this.mspreview = new System.Windows.Forms.MenuStrip(); + this.menuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuItem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuItem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subitem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subitem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subitem3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.separatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator(); + this.menuItem3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tspreview = new System.Windows.Forms.ToolStrip(); + this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox(); this.panel1.SuspendLayout(); - this.panel4.SuspendLayout(); - this.panel3.SuspendLayout(); - this.panel2.SuspendLayout(); + this.pnlpreview.SuspendLayout(); + this.pnlwindow.SuspendLayout(); + this.pnlcontents.SuspendLayout(); + this.pnltitle.SuspendLayout(); + this.pnlbottom.SuspendLayout(); + this.pnlsettingsholder.SuspendLayout(); + this.pnlcategoryholder.SuspendLayout(); + this.mspreview.SuspendLayout(); + this.tspreview.SuspendLayout(); this.SuspendLayout(); // // panel1 // - this.panel1.Controls.Add(this.panel4); - this.panel1.Controls.Add(this.panel3); - this.panel1.Controls.Add(this.panel2); + this.panel1.Controls.Add(this.pnlpreview); + this.panel1.Controls.Add(this.pnlsettingsholder); + this.panel1.Controls.Add(this.pnlcategoryholder); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(893, 539); this.panel1.TabIndex = 0; // - // panel4 + // pnlpreview // - this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.pnlpreview.Controls.Add(this.pnlwindow); + this.pnlpreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlpreview.Location = new System.Drawing.Point(136, 0); + this.pnlpreview.Name = "pnlpreview"; + this.pnlpreview.Size = new System.Drawing.Size(757, 286); + this.pnlpreview.TabIndex = 1; + // + // pnlwindow + // + this.pnlwindow.Controls.Add(this.pnlcontents); + this.pnlwindow.Controls.Add(this.pnltitle); + this.pnlwindow.Controls.Add(this.pnlbottom); + this.pnlwindow.Controls.Add(this.pnlright); + this.pnlwindow.Controls.Add(this.pnlleft); + this.pnlwindow.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlwindow.Location = new System.Drawing.Point(0, 0); + this.pnlwindow.Name = "pnlwindow"; + this.pnlwindow.Size = new System.Drawing.Size(757, 286); + this.pnlwindow.TabIndex = 0; + // + // pnlcontents + // + this.pnlcontents.BackColor = System.Drawing.Color.Black; + this.pnlcontents.Controls.Add(this.tspreview); + this.pnlcontents.Controls.Add(this.mspreview); + this.pnlcontents.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcontents.ForeColor = System.Drawing.Color.White; + this.pnlcontents.Location = new System.Drawing.Point(2, 30); + this.pnlcontents.Name = "pnlcontents"; + this.pnlcontents.Size = new System.Drawing.Size(753, 254); + this.pnlcontents.TabIndex = 9; + // + // pnltitle + // + this.pnltitle.BackColor = System.Drawing.Color.Black; + this.pnltitle.Controls.Add(this.pnlicon); + this.pnltitle.Controls.Add(this.pnlminimize); + this.pnltitle.Controls.Add(this.pnlmaximize); + this.pnltitle.Controls.Add(this.pnlclose); + this.pnltitle.Controls.Add(this.pnltitleleft); + this.pnltitle.Controls.Add(this.pnltitleright); + this.pnltitle.Controls.Add(this.lbtitletext); + this.pnltitle.Dock = System.Windows.Forms.DockStyle.Top; + this.pnltitle.Location = new System.Drawing.Point(2, 0); + this.pnltitle.Name = "pnltitle"; + this.pnltitle.Size = new System.Drawing.Size(753, 30); + this.pnltitle.TabIndex = 5; + // + // pnlicon + // + this.pnlicon.Location = new System.Drawing.Point(9, -76); + this.pnlicon.Name = "pnlicon"; + this.pnlicon.Size = new System.Drawing.Size(200, 100); + this.pnlicon.TabIndex = 6; + // + // pnlminimize + // + this.pnlminimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlminimize.BackColor = System.Drawing.Color.Green; + this.pnlminimize.Location = new System.Drawing.Point(672, 3); + this.pnlminimize.Name = "pnlminimize"; + this.pnlminimize.Size = new System.Drawing.Size(24, 24); + this.pnlminimize.TabIndex = 3; + // + // pnlmaximize + // + this.pnlmaximize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlmaximize.BackColor = System.Drawing.Color.Yellow; + this.pnlmaximize.Location = new System.Drawing.Point(699, 3); + this.pnlmaximize.Name = "pnlmaximize"; + this.pnlmaximize.Size = new System.Drawing.Size(24, 24); + this.pnlmaximize.TabIndex = 2; + // + // pnlclose + // + this.pnlclose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlclose.BackColor = System.Drawing.Color.Red; + this.pnlclose.Location = new System.Drawing.Point(726, 3); + this.pnlclose.Name = "pnlclose"; + this.pnlclose.Size = new System.Drawing.Size(24, 24); + this.pnlclose.TabIndex = 1; + // + // pnltitleleft + // + this.pnltitleleft.Dock = System.Windows.Forms.DockStyle.Left; + this.pnltitleleft.Location = new System.Drawing.Point(0, 0); + this.pnltitleleft.Name = "pnltitleleft"; + this.pnltitleleft.Size = new System.Drawing.Size(2, 30); + this.pnltitleleft.TabIndex = 4; + // + // pnltitleright + // + this.pnltitleright.Dock = System.Windows.Forms.DockStyle.Right; + this.pnltitleright.Location = new System.Drawing.Point(751, 0); + this.pnltitleright.Name = "pnltitleright"; + this.pnltitleright.Size = new System.Drawing.Size(2, 30); + this.pnltitleright.TabIndex = 5; + // + // lbtitletext + // + this.lbtitletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.panel4.Controls.Add(this.flbody); - this.panel4.Controls.Add(this.flcategory); - this.panel4.Location = new System.Drawing.Point(154, 283); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(734, 253); - this.panel4.TabIndex = 2; + this.lbtitletext.AutoSize = true; + this.lbtitletext.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.lbtitletext.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Bold); + this.lbtitletext.ForeColor = System.Drawing.Color.White; + this.lbtitletext.Location = new System.Drawing.Point(75, 9); + this.lbtitletext.Name = "lbtitletext"; + this.lbtitletext.Size = new System.Drawing.Size(77, 14); + this.lbtitletext.TabIndex = 0; + this.lbtitletext.Text = "Title text"; + this.lbtitletext.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.lbtitletext.UseMnemonic = false; + // + // pnlbottom + // + this.pnlbottom.BackColor = System.Drawing.Color.Black; + this.pnlbottom.Controls.Add(this.pnlbottomr); + this.pnlbottom.Controls.Add(this.pnlbottoml); + this.pnlbottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlbottom.Location = new System.Drawing.Point(2, 284); + this.pnlbottom.Name = "pnlbottom"; + this.pnlbottom.Size = new System.Drawing.Size(753, 2); + this.pnlbottom.TabIndex = 6; + // + // pnlbottomr + // + this.pnlbottomr.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlbottomr.Location = new System.Drawing.Point(751, 0); + this.pnlbottomr.Name = "pnlbottomr"; + this.pnlbottomr.Size = new System.Drawing.Size(2, 2); + this.pnlbottomr.TabIndex = 3; + // + // pnlbottoml + // + this.pnlbottoml.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlbottoml.Location = new System.Drawing.Point(0, 0); + this.pnlbottoml.Name = "pnlbottoml"; + this.pnlbottoml.Size = new System.Drawing.Size(2, 2); + this.pnlbottoml.TabIndex = 2; + // + // pnlright + // + this.pnlright.BackColor = System.Drawing.Color.Black; + this.pnlright.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlright.Location = new System.Drawing.Point(755, 0); + this.pnlright.Name = "pnlright"; + this.pnlright.Size = new System.Drawing.Size(2, 286); + this.pnlright.TabIndex = 8; + // + // pnlleft + // + this.pnlleft.BackColor = System.Drawing.Color.Black; + this.pnlleft.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlleft.Location = new System.Drawing.Point(0, 0); + this.pnlleft.Name = "pnlleft"; + this.pnlleft.Size = new System.Drawing.Size(2, 286); + this.pnlleft.TabIndex = 7; + // + // pnlsettingsholder + // + this.pnlsettingsholder.Controls.Add(this.flbody); + this.pnlsettingsholder.Controls.Add(this.flcategory); + this.pnlsettingsholder.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlsettingsholder.Location = new System.Drawing.Point(136, 286); + this.pnlsettingsholder.Name = "pnlsettingsholder"; + this.pnlsettingsholder.Padding = new System.Windows.Forms.Padding(10); + this.pnlsettingsholder.Size = new System.Drawing.Size(757, 253); + this.pnlsettingsholder.TabIndex = 2; // // flbody // this.flbody.AutoScroll = true; this.flbody.Dock = System.Windows.Forms.DockStyle.Fill; - this.flbody.Location = new System.Drawing.Point(126, 0); + this.flbody.Location = new System.Drawing.Point(136, 10); this.flbody.Name = "flbody"; - this.flbody.Size = new System.Drawing.Size(608, 253); + this.flbody.Size = new System.Drawing.Size(611, 233); this.flbody.TabIndex = 3; // // flcategory // this.flcategory.Dock = System.Windows.Forms.DockStyle.Left; - this.flcategory.Location = new System.Drawing.Point(0, 0); + this.flcategory.Location = new System.Drawing.Point(10, 10); this.flcategory.Name = "flcategory"; - this.flcategory.Size = new System.Drawing.Size(126, 253); + this.flcategory.Size = new System.Drawing.Size(126, 233); this.flcategory.TabIndex = 2; // - // panel3 - // - this.panel3.Controls.Add(this.label1); - this.panel3.Location = new System.Drawing.Point(155, 12); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(640, 360); - this.panel3.TabIndex = 1; - // - // label1 - // - this.label1.Dock = System.Windows.Forms.DockStyle.Fill; - this.label1.Location = new System.Drawing.Point(0, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(640, 360); - this.label1.TabIndex = 0; - this.label1.Text = "Preview not available."; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // pnlcategoryholder // - // panel2 - // - this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.panel2.Controls.Add(this.flmeta); - this.panel2.Controls.Add(this.btnapply); - this.panel2.Location = new System.Drawing.Point(12, 12); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(136, 511); - this.panel2.TabIndex = 0; + this.pnlcategoryholder.Controls.Add(this.flmeta); + this.pnlcategoryholder.Controls.Add(this.btnapply); + this.pnlcategoryholder.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlcategoryholder.Location = new System.Drawing.Point(0, 0); + this.pnlcategoryholder.Name = "pnlcategoryholder"; + this.pnlcategoryholder.Padding = new System.Windows.Forms.Padding(10); + this.pnlcategoryholder.Size = new System.Drawing.Size(136, 539); + this.pnlcategoryholder.TabIndex = 0; // // flmeta // this.flmeta.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.flmeta.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flmeta.Location = new System.Drawing.Point(4, 4); + this.flmeta.Location = new System.Drawing.Point(14, 14); this.flmeta.Name = "flmeta"; - this.flmeta.Size = new System.Drawing.Size(126, 450); + this.flmeta.Size = new System.Drawing.Size(126, 458); this.flmeta.TabIndex = 1; // // btnapply // this.btnapply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnapply.Location = new System.Drawing.Point(3, 460); + this.btnapply.Location = new System.Drawing.Point(13, 478); this.btnapply.Name = "btnapply"; this.btnapply.Size = new System.Drawing.Size(127, 48); this.btnapply.TabIndex = 0; @@ -156,19 +337,155 @@ namespace ShiftOS.WinForms.Applications this.btnapply.UseVisualStyleBackColor = true; this.btnapply.Click += new System.EventHandler(this.btnapply_Click); // + // mspreview + // + this.mspreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuToolStripMenuItem}); + this.mspreview.Location = new System.Drawing.Point(0, 0); + this.mspreview.Name = "mspreview"; + this.mspreview.Size = new System.Drawing.Size(753, 24); + this.mspreview.TabIndex = 0; + this.mspreview.Text = "menuStrip1"; + // + // menuToolStripMenuItem + // + this.menuToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuItem1ToolStripMenuItem, + this.menuItem2ToolStripMenuItem, + this.separatorToolStripMenuItem, + this.menuItem3ToolStripMenuItem}); + this.menuToolStripMenuItem.Name = "menuToolStripMenuItem"; + this.menuToolStripMenuItem.Size = new System.Drawing.Size(50, 20); + this.menuToolStripMenuItem.Text = "Menu"; + // + // menuItem1ToolStripMenuItem + // + this.menuItem1ToolStripMenuItem.Name = "menuItem1ToolStripMenuItem"; + this.menuItem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.menuItem1ToolStripMenuItem.Text = "Menu Item 1"; + // + // menuItem2ToolStripMenuItem + // + this.menuItem2ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.subitem1ToolStripMenuItem, + this.subitem2ToolStripMenuItem, + this.subitem3ToolStripMenuItem}); + this.menuItem2ToolStripMenuItem.Name = "menuItem2ToolStripMenuItem"; + this.menuItem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.menuItem2ToolStripMenuItem.Text = "Menu Item 2"; + // + // subitem1ToolStripMenuItem + // + this.subitem1ToolStripMenuItem.Name = "subitem1ToolStripMenuItem"; + this.subitem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.subitem1ToolStripMenuItem.Text = "Subitem 1"; + // + // subitem2ToolStripMenuItem + // + this.subitem2ToolStripMenuItem.Name = "subitem2ToolStripMenuItem"; + this.subitem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.subitem2ToolStripMenuItem.Text = "Subitem 2"; + // + // subitem3ToolStripMenuItem + // + this.subitem3ToolStripMenuItem.Name = "subitem3ToolStripMenuItem"; + this.subitem3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.subitem3ToolStripMenuItem.Text = "Subitem 3"; + // + // separatorToolStripMenuItem + // + this.separatorToolStripMenuItem.Name = "separatorToolStripMenuItem"; + this.separatorToolStripMenuItem.Size = new System.Drawing.Size(149, 6); + // + // menuItem3ToolStripMenuItem + // + this.menuItem3ToolStripMenuItem.Name = "menuItem3ToolStripMenuItem"; + this.menuItem3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.menuItem3ToolStripMenuItem.Text = "Menu Item 3"; + // + // tspreview + // + this.tspreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripLabel1, + this.toolStripButton2, + this.toolStripButton3, + this.toolStripButton1, + this.toolStripSeparator1, + this.toolStripTextBox1}); + this.tspreview.Location = new System.Drawing.Point(0, 24); + this.tspreview.Name = "tspreview"; + this.tspreview.Size = new System.Drawing.Size(753, 25); + this.tspreview.TabIndex = 1; + this.tspreview.Text = "toolStrip1"; + // + // toolStripLabel1 + // + this.toolStripLabel1.Name = "toolStripLabel1"; + this.toolStripLabel1.Size = new System.Drawing.Size(81, 22); + this.toolStripLabel1.Text = "Toolbar Label:"; + // + // toolStripButton1 + // + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton1.Enabled = false; + this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(56, 22); + this.toolStripButton1.Text = "Disabled"; + // + // toolStripButton2 + // + this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); + this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton2.Name = "toolStripButton2"; + this.toolStripButton2.Size = new System.Drawing.Size(51, 22); + this.toolStripButton2.Text = "Regular"; + // + // toolStripButton3 + // + this.toolStripButton3.Checked = true; + this.toolStripButton3.CheckState = System.Windows.Forms.CheckState.Checked; + this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); + this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton3.Name = "toolStripButton3"; + this.toolStripButton3.Size = new System.Drawing.Size(57, 22); + this.toolStripButton3.Text = "Checked"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); + // + // toolStripTextBox1 + // + this.toolStripTextBox1.Name = "toolStripTextBox1"; + this.toolStripTextBox1.Size = new System.Drawing.Size(100, 25); + // // Shifter // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.panel1); this.Name = "Shifter"; - this.Text = "{SHIFTER_NAME}"; this.Size = new System.Drawing.Size(893, 539); this.Load += new System.EventHandler(this.Shifter_Load); this.panel1.ResumeLayout(false); - this.panel4.ResumeLayout(false); - this.panel3.ResumeLayout(false); - this.panel2.ResumeLayout(false); + this.pnlpreview.ResumeLayout(false); + this.pnlwindow.ResumeLayout(false); + this.pnlcontents.ResumeLayout(false); + this.pnlcontents.PerformLayout(); + this.pnltitle.ResumeLayout(false); + this.pnltitle.PerformLayout(); + this.pnlbottom.ResumeLayout(false); + this.pnlsettingsholder.ResumeLayout(false); + this.pnlcategoryholder.ResumeLayout(false); + this.mspreview.ResumeLayout(false); + this.mspreview.PerformLayout(); + this.tspreview.ResumeLayout(false); + this.tspreview.PerformLayout(); this.ResumeLayout(false); } @@ -176,13 +493,43 @@ namespace ShiftOS.WinForms.Applications #endregion private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel pnlcategoryholder; private System.Windows.Forms.FlowLayoutPanel flmeta; private System.Windows.Forms.Button btnapply; - private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.Panel pnlsettingsholder; private System.Windows.Forms.FlowLayoutPanel flbody; private System.Windows.Forms.FlowLayoutPanel flcategory; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel pnlpreview; + private System.Windows.Forms.Panel pnlwindow; + private System.Windows.Forms.Panel pnlcontents; + private System.Windows.Forms.Panel pnltitle; + private System.Windows.Forms.Panel pnlicon; + private System.Windows.Forms.Panel pnlminimize; + private System.Windows.Forms.Panel pnlmaximize; + private System.Windows.Forms.Panel pnlclose; + private System.Windows.Forms.Panel pnltitleleft; + private System.Windows.Forms.Panel pnltitleright; + private System.Windows.Forms.Label lbtitletext; + private System.Windows.Forms.Panel pnlbottom; + private System.Windows.Forms.Panel pnlbottomr; + private System.Windows.Forms.Panel pnlbottoml; + private System.Windows.Forms.Panel pnlright; + private System.Windows.Forms.Panel pnlleft; + private System.Windows.Forms.MenuStrip mspreview; + private System.Windows.Forms.ToolStripMenuItem menuToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem menuItem1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem menuItem2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subitem1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subitem2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subitem3ToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator separatorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem menuItem3ToolStripMenuItem; + private System.Windows.Forms.ToolStrip tspreview; + private System.Windows.Forms.ToolStripLabel toolStripLabel1; + private System.Windows.Forms.ToolStripButton toolStripButton2; + private System.Windows.Forms.ToolStripButton toolStripButton3; + private System.Windows.Forms.ToolStripButton toolStripButton1; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripTextBox toolStripTextBox1; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 02e2d0a..e7ad768 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -47,6 +47,193 @@ namespace ShiftOS.WinForms.Applications PopulateShifter(); } + [ShifterMeta("Windows")] + public void SetupWindowPreview() + { + pnlwindow.BringToFront(); + WBSetup(); + } + + [ShifterMeta("Menus")] + public void SetupMenusPreview() + { + SetupWindowPreview(); + } + + [ShifterMeta("System")] + public void SetupSystemPreview() + { + SetupWindowPreview(); + } + + /// + /// Setup this instance. + /// + public void WBSetup() + { + this.lbtitletext.Text = "Window Preview"; + + if (SaveSystem.CurrentSave != null) + { + this.pnltitle.Visible = Shiftorium.UpgradeInstalled("wm_titlebar"); + this.pnlclose.Visible = Shiftorium.UpgradeInstalled("close_button"); + this.pnlminimize.Visible = Shiftorium.UpgradeInstalled("minimize_button"); + this.pnlmaximize.Visible =Shiftorium.UpgradeInstalled("maximize_button"); + WBSetupSkin(); + } + else + { + this.pnltitle.Visible = false; + this.pnlclose.Visible = false; + this.pnlminimize.Visible = false; + this.pnlmaximize.Visible = false; + + } + } + + public Image GetImage(string id) + { + var type = typeof(ShiftOS.Engine.Skin); + foreach(var field in type.GetFields(BindingFlags.Public | BindingFlags.Instance)) + { + foreach(var attrib in field.GetCustomAttributes(false)) + { + if(attrib is ImageAttribute) + { + var img = attrib as ImageAttribute; + if(img.Name == id) + { + return SkinEngine.ImageFromBinary((byte[])field.GetValue(LoadedSkin)); + } + } + } + } + return null; + } + + public ImageLayout GetImageLayout(string img) + { + if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) + { + return LoadedSkin.SkinImageLayouts[img]; + } + else + { + LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); + return ImageLayout.Tile; + } + + } + + /// + /// Setups the skin. + /// + /// The skin. + public void WBSetupSkin() + { + this.DoubleBuffered = true; + var renderer = new ShiftOSMenuRenderer(LoadedSkin); + mspreview.Renderer = renderer; + tspreview.Renderer = renderer; + pnltitle.Height = LoadedSkin.TitlebarHeight; + pnltitle.BackColor = LoadedSkin.TitleBackgroundColor; + pnltitle.BackgroundImage = GetImage("titlebar"); + pnltitleleft.Visible = LoadedSkin.ShowTitleCorners; + pnltitleright.Visible = LoadedSkin.ShowTitleCorners; + pnltitleleft.BackColor = LoadedSkin.TitleLeftCornerBackground; + pnltitleright.BackColor = LoadedSkin.TitleRightCornerBackground; + pnltitleleft.Width = LoadedSkin.TitleLeftCornerWidth; + pnltitleright.Width = LoadedSkin.TitleRightCornerWidth; + pnltitleleft.BackgroundImage = GetImage("titleleft"); + pnltitleleft.BackgroundImageLayout = GetImageLayout("titleleft"); + pnltitleright.BackgroundImage = GetImage("titleright"); + pnltitleright.BackgroundImageLayout = GetImageLayout("titleright"); + pnltitle.BackgroundImageLayout = GetImageLayout("titlebar"); //RETARD ALERT. WHY WASN'T THIS THERE WHEN IMAGELAYOUTS WERE FIRST IMPLEMENTED? + + lbtitletext.BackColor = (pnltitle.BackgroundImage != null) ? Color.Transparent : LoadedSkin.TitleBackgroundColor; + lbtitletext.ForeColor = LoadedSkin.TitleTextColor; + lbtitletext.Font = LoadedSkin.TitleFont; + + pnlleft.BackColor = LoadedSkin.BorderLeftBackground; + pnlleft.BackgroundImage = GetImage("leftborder"); + pnlleft.BackgroundImageLayout = GetImageLayout("leftborder"); + pnlleft.Width = LoadedSkin.LeftBorderWidth; + pnlright.BackColor = LoadedSkin.BorderRightBackground; + pnlright.BackgroundImage = GetImage("rightborder"); + pnlright.BackgroundImageLayout = GetImageLayout("rightborder"); + pnlright.Width = LoadedSkin.RightBorderWidth; + + pnlbottom.BackColor = LoadedSkin.BorderBottomBackground; + pnlbottom.BackgroundImage = GetImage("bottomborder"); + pnlbottom.BackgroundImageLayout = GetImageLayout("bottomborder"); + pnlbottom.Height = LoadedSkin.BottomBorderWidth; + + pnlbottomr.BackColor = LoadedSkin.BorderBottomRightBackground; + pnlbottomr.BackgroundImage = GetImage("bottomrborder"); + pnlbottomr.BackgroundImageLayout = GetImageLayout("bottomrborder"); + pnlbottoml.BackColor = LoadedSkin.BorderBottomLeftBackground; + pnlbottoml.BackgroundImage = GetImage("bottomlborder"); + pnlbottoml.BackgroundImageLayout = GetImageLayout("bottomlborder"); + + lbtitletext.ForeColor = LoadedSkin.TitleTextColor; + lbtitletext.Font = LoadedSkin.TitleFont; + pnlclose.BackColor = LoadedSkin.CloseButtonColor; + pnlclose.BackgroundImage = GetImage("closebutton"); + pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); + pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; + pnlminimize.BackgroundImage = GetImage("minimizebutton"); + pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); + pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; + pnlmaximize.BackgroundImage = GetImage("maximizebutton"); + pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); + + pnlclose.Size = LoadedSkin.CloseButtonSize; + pnlminimize.Size = LoadedSkin.MinimizeButtonSize; + pnlmaximize.Size = LoadedSkin.MaximizeButtonSize; + pnlclose.Location = FromRight(LoadedSkin.CloseButtonFromSide); + pnlminimize.Location = FromRight(LoadedSkin.MinimizeButtonFromSide); + pnlmaximize.Location = FromRight(LoadedSkin.MaximizeButtonFromSide); + pnlclose.Left -= pnlclose.Width; + pnlmaximize.Left -= pnlmaximize.Width; + pnlminimize.Left -= pnlminimize.Width; + + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } + + if (Shiftorium.UpgradeInstalled("app_icons")) + { + pnlicon.Show(); + pnlicon.Size = new Size(16, 16); + pnlicon.BackColor = Color.Transparent; + pnlicon.BackgroundImageLayout = ImageLayout.Stretch; + pnlicon.Location = LoadedSkin.TitlebarIconFromSide; + } + else + { + pnlicon.Hide(); + } + } + + /// + /// Froms the right. + /// + /// The right. + /// Input. + public Point FromRight(Point input) + { + return new Point(pnltitle.Width - input.X, input.Y); + } + + public int CodepointValue = 0; public List settings = new List(); public Skin LoadedSkin = null; @@ -123,6 +310,21 @@ namespace ShiftOS.WinForms.Applications btn.FlatStyle = FlatStyle.Flat; btn.Click += (o, a) => { + foreach(var mth in this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance)) + { + foreach(var attrib in mth.GetCustomAttributes(false)) + { + if(attrib is ShifterMetaAttribute) + { + var meta = attrib as ShifterMetaAttribute; + if(meta.Meta == btn.Text) + { + mth?.Invoke(this, null); + } + } + } + } + PopulateSubcategories(c); }; @@ -164,6 +366,21 @@ namespace ShiftOS.WinForms.Applications } } + public void InvokeSetup(string cat) + { + foreach(var mth in this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance)) + { + foreach(var attr in mth.GetCustomAttributes(false)) + { + if(attr is ShifterMetaAttribute) + { + if ((attr as ShifterMetaAttribute).Meta == cat) + mth.Invoke(this, null); + } + } + } + } + public void PopulateBody(string cat, string subcat) { flbody.Controls.Clear(); @@ -233,6 +450,7 @@ namespace ShiftOS.WinForms.Applications width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); } + InvokeSetup(cat); }; width.TextChanged += tc; @@ -247,7 +465,12 @@ namespace ShiftOS.WinForms.Applications labelHeight = str.Height; str.Text = c.Field.GetValue(LoadedSkin).ToString(); flbody.SetFlowBreak(str, true); - str.TextChanged += (o, a) => { c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; }; + str.TextChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; + + InvokeSetup(cat); + }; flbody.Controls.Add(str); str.Show(); } @@ -271,6 +494,8 @@ namespace ShiftOS.WinForms.Applications color.BackgroundImageLayout = layout; LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; CodepointValue += 700; + InvokeSetup(cat); + }))); }; flbody.Controls.Add(color); @@ -316,6 +541,8 @@ namespace ShiftOS.WinForms.Applications width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); } + InvokeSetup(cat); + }; width.TextChanged += tc; @@ -331,6 +558,8 @@ namespace ShiftOS.WinForms.Applications { c.Field.SetValue(LoadedSkin, check.Checked); CodepointValue += 50; + InvokeSetup(cat); + }; flbody.SetFlowBreak(check, true); @@ -377,6 +606,8 @@ namespace ShiftOS.WinForms.Applications c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); CodepointValue += 100; + InvokeSetup(cat); + }; style.SelectedIndexChanged += (o, a) => @@ -387,6 +618,8 @@ namespace ShiftOS.WinForms.Applications c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); CodepointValue += 50; + InvokeSetup(cat); + }; size.TextChanged += (o, a) => @@ -404,6 +637,8 @@ namespace ShiftOS.WinForms.Applications size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); } CodepointValue += 50; + InvokeSetup(cat); + }; flbody.Controls.Add(name); @@ -434,6 +669,8 @@ namespace ShiftOS.WinForms.Applications { color.BackColor = col; CodepointValue += 300; + InvokeSetup(cat); + }))); }; flbody.SetFlowBreak(color, true); @@ -457,6 +694,8 @@ namespace ShiftOS.WinForms.Applications cBox.SelectedIndexChanged += (o, a) => { c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); + InvokeSetup(cat); + }; labelHeight = cBox.Height; @@ -482,6 +721,8 @@ namespace ShiftOS.WinForms.Applications { c.Field.SetValue(LoadedSkin, name.SelectedIndex); CodepointValue += 75; + InvokeSetup(cat); + }; labelHeight = name.Height; flbody.Controls.Add(name); @@ -517,6 +758,8 @@ namespace ShiftOS.WinForms.Applications { width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); } + InvokeSetup(cat); + }; width.TextChanged += tc; diff --git a/ShiftOS.WinForms/Applications/Shifter.resx b/ShiftOS.WinForms/Applications/Shifter.resx index 1af7de1..f16904f 100644 --- a/ShiftOS.WinForms/Applications/Shifter.resx +++ b/ShiftOS.WinForms/Applications/Shifter.resx @@ -117,4 +117,56 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 127, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs index 28623ef..a31edd9 100644 --- a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs +++ b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs @@ -28,16 +28,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; -using static ShiftOS.Engine.SkinEngine; +using ShiftOS.Engine; using System.Windows.Forms; namespace ShiftOS.WinForms.Tools { public class ShiftOSMenuRenderer : ToolStripProfessionalRenderer { - public ShiftOSMenuRenderer() : base(new ShiftOSColorTable()) + public ShiftOSMenuRenderer() : base(new ShiftOSColorTable(ShiftOS.Engine.SkinEngine.LoadedSkin)) { - + } public ShiftOSMenuRenderer(ProfessionalColorTable table) : base(table) @@ -45,6 +45,26 @@ namespace ShiftOS.WinForms.Tools } + public ShiftOSMenuRenderer(Skin skn) : base(new ShiftOSColorTable(skn)) + { + + } + + public Skin LoadedSkin + { + get + { + if(ColorTable is ShiftOSColorTable) + { + return (ColorTable as ShiftOSColorTable).LoadedSkin; + } + else + { + return SkinEngine.LoadedSkin; + } + } + } + protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { if (e.Item.Tag?.ToString() == "applauncherbutton") @@ -99,6 +119,18 @@ namespace ShiftOS.WinForms.Tools public class ShiftOSColorTable : ProfessionalColorTable { + public ShiftOSColorTable(ShiftOS.Engine.Skin skn) + { + LoadedSkin = skn; + } + + public Skin LoadedSkin { get; private set; } + + public Image GetImage(string id) + { + return SkinEngine.GetImage(id); + } + public override Color ButtonSelectedHighlight { get { return LoadedSkin.Menu_ButtonSelectedHighlight; } @@ -327,6 +359,19 @@ namespace ShiftOS.WinForms.Tools public class AppLauncherColorTable : ProfessionalColorTable { + public Image GetImage(string id) + { + return SkinEngine.GetImage(id); + } + + public Skin LoadedSkin + { + get + { + return SkinEngine.LoadedSkin; + } + } + public override Color ButtonSelectedHighlight { get { return LoadedSkin.Menu_ButtonSelectedHighlight; } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 4fba470..4babbbd 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -129,7 +129,6 @@ namespace ShiftOS.WinForms this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; - this._parentWindow.Show(); ControlManager.SetupControls(this._parentWindow); ParentWindow.OnSkinLoad(); @@ -139,9 +138,40 @@ namespace ShiftOS.WinForms Setup(); ParentWindow.OnUpgrade(); }; + Setup(); + this._parentWindow.TextChanged += (o, a) => + { + Setup(); + Desktop.ResetPanelButtons(); + + }; + + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - Desktop.ShowWindow(this); + if (!this.IsDialog) + { + Engine.AppearanceManager.OpenForms.Add(this); + } + SaveSystem.GameReady += () => + { + if (Shiftorium.UpgradeInstalled("wm_free_placement")) + { + AppearanceManager.Invoke(new Action(() => + { + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; + + })); + } + AppearanceManager.Invoke(new Action(() => + { + Setup(); + })); + }; + + ParentWindow.OnLoad(); } /// @@ -178,46 +208,7 @@ namespace ShiftOS.WinForms public void WindowBorder_Load(object sender, EventArgs e) { this.DoubleBuffered = true; - - this._parentWindow.TextChanged += (o, a) => - { - Setup(); - Desktop.ResetPanelButtons(); - - }; - - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - if (!this.IsDialog) - { - Engine.AppearanceManager.OpenForms.Add(this); - } - - SaveSystem.GameReady += () => - { - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - AppearanceManager.Invoke(new Action(() => - { - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - })); - } - AppearanceManager.Invoke(new Action(() => - { - Setup(); - })); - }; - - ControlManager.SetupControls(this); - - Setup(); - - var sWin = (IShiftOSWindow)ParentWindow; - - sWin.OnLoad(); + this._parentWindow.Show(); } /// diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index cfcb6d3..4fcd185 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -120,8 +120,7 @@ namespace ShiftOS.WinForms var wb = new WindowBorder(form as UserControl); wb.IsDialog = true; - - wb.Show(); + Desktop.ShowWindow(wb); } public override void SetupWindow(IShiftOSWindow form) @@ -213,6 +212,7 @@ namespace ShiftOS.WinForms wb.FormClosed -= onClose; }; wb.FormClosed += onClose; + Desktop.ShowWindow(wb); SetupWindows(); } diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 800b107..48b7c0b 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -64,10 +64,14 @@ namespace ShiftOS.Engine { public static class SkinEngine { - public static ImageLayout GetImageLayout(string img) { - if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) { + public static ImageLayout GetImageLayout(string img) + { + if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) + { return LoadedSkin.SkinImageLayouts[img]; - } else { + } + else + { LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); return ImageLayout.Tile; } -- cgit v1.2.3 From a0fc2b5e701659d1ed17eba9c2888cae6d519c1e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Apr 2017 09:48:33 -0400 Subject: More documentation --- ShiftOS.WinForms/Applications/Pong.cs | 11 ++-- ShiftOS.WinForms/Applications/Terminal.cs | 1 - ShiftOS.WinForms/Resources/Shiftorium.txt | 7 --- ShiftOS.WinForms/WinformsWindowManager.cs | 6 -- ShiftOS_TheReturn/ConsoleEx.cs | 24 +++++++ ShiftOS_TheReturn/CrashHandler.cs | 1 - ShiftOS_TheReturn/Desktop.cs | 101 +++++++++++++++++++++++++++++- 7 files changed, 129 insertions(+), 22 deletions(-) (limited to 'ShiftOS.WinForms/WinformsWindowManager.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 5d09ca0..0ef4da3 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -115,11 +115,12 @@ namespace ShiftOS.WinForms.Applications paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; //Check if paddle upgrade has been bought and change paddles accordingly - if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) - { - paddleHuman.Height = 150; - paddleComputer.Height = 150; - } + //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) + //{ + // paddleHuman.Height = 150; + // paddleComputer.Height = 150; + //} + //I don't know the point of this but I'm fucking 86ing it. - Michael //Set the computer player to move according to the ball's position. if (aiShouldIsbeEnabled) diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index c0fdf01..8d29cba 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -321,7 +321,6 @@ namespace ShiftOS.WinForms.Applications { if (SaveSystem.CurrentSave != null) { if (!ShiftoriumFrontend.UpgradeInstalled("window_manager")) { - rtbterm.Text = AppearanceManager.LastTerminalText; rtbterm.Select(rtbterm.TextLength, 0); } TerminalBackend.PrintPrompt(); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 2260198..82ee613 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -259,13 +259,6 @@ Category: "Device Drivers", Description: "With the free placement upgrade, you can place windows of any size anywhere on the desktop, which means theoretically you could add kernel coherence between ShiftOS and another GUI-based operating system and run their applications inside ShiftOS. This upgrade unlocks that.", }, - { - Name: "Pong Increased Paddle Size", - Cost: 1000, - Dependencies: "pong_upgrade", - Category: "Enhancements", - Description: "Having trouble keeping that darn ball in front of you? Well, with this upgrade, your paddle increases in height.... slightly.", - }, { Name: "WM 4 Windows", Cost: 150, diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index 4fcd185..8bff387 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -125,12 +125,6 @@ namespace ShiftOS.WinForms public override void SetupWindow(IShiftOSWindow form) { - if (!AppearanceManager.CanOpenWindow(form)) - { - Infobox.Show("{MULTIPLAYER_ONLY}", "{MULTIPLAYER_ONLY_EXP}"); - return; - } - foreach(var attr in form.GetType().GetCustomAttributes(true)) { if(attr is MultiplayerOnlyAttribute) diff --git a/ShiftOS_TheReturn/ConsoleEx.cs b/ShiftOS_TheReturn/ConsoleEx.cs index 69f6a18..90f9cc0 100644 --- a/ShiftOS_TheReturn/ConsoleEx.cs +++ b/ShiftOS_TheReturn/ConsoleEx.cs @@ -6,8 +6,14 @@ using System.Threading.Tasks; namespace ShiftOS.Engine { + /// + /// Provides extra eye candy data that can be used by ShiftOS terminals. + /// public static class ConsoleEx { + /// + /// Initializes the class, performing core configuration. + /// static ConsoleEx() { ForegroundColor = ConsoleColor.White; @@ -18,11 +24,29 @@ namespace ShiftOS.Engine Underline = false; } + /// + /// Gets or sets the foreground color of text in the Terminal. + /// public static ConsoleColor ForegroundColor { get; set; } + + /// + /// Gets or sets the background color of text in the Terminal. + /// public static ConsoleColor BackgroundColor { get; set; } + /// + /// Gets or sets whether text in the Terminal is bold. + /// public static bool Bold { get; set; } + + /// + /// Gets or sets whether text in the Terminal is italic. + /// public static bool Italic { get; set; } + + /// + /// Gets or sets whether text in the Terminal is underlined. + /// public static bool Underline { get; set; } } } diff --git a/ShiftOS_TheReturn/CrashHandler.cs b/ShiftOS_TheReturn/CrashHandler.cs index 734f1a9..ed42ea5 100644 --- a/ShiftOS_TheReturn/CrashHandler.cs +++ b/ShiftOS_TheReturn/CrashHandler.cs @@ -97,7 +97,6 @@ namespace ShiftOS.Engine { if(SaveSystem.CurrentSave != null) TerminalBackend.InvokeCommand("sos.save"); - AudioManager.Kill(); ServerManager.Disconnect(); while (Application.OpenForms.Count > 0) diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index b72f0cc..bc17a8e 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -37,6 +37,10 @@ using static ShiftOS.Engine.SkinEngine; namespace ShiftOS.Engine { + /// + /// Denotes that this class is launchable from the App Launcher. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class LauncherAttribute : Attribute { /// @@ -54,10 +58,29 @@ namespace ShiftOS.Engine ID = upgradeID; } + /// + /// Gets or sets the name of the launcher item + /// public string Name { get; set; } + + /// + /// Gets or sets whether this entry requires a Shiftorium upgrade. + /// public bool RequiresUpgrade { get; set; } + + /// + /// Gets or sets the ID of the required upgrade. + /// public string ID { get; set; } + + /// + /// Gets or sets this item's category. + /// public string Category { get; private set; } + + /// + /// Gets whether or not the required upgrade is installed. + /// public bool UpgradeInstalled { get @@ -70,36 +93,110 @@ namespace ShiftOS.Engine } } - + /// + /// Provides core functionality for a typical ShiftOS desktop. + /// public interface IDesktop { + /// + /// Gets the name of the desktop. + /// string DesktopName { get; } + + /// + /// Performs most of the skinning and layout handling for the desktop. + /// void SetupDesktop(); + /// + /// Hides the currently-opened app launcher menu. + /// void HideAppLauncher(); + + /// + /// Populates the app launcher menu. + /// + /// All items to be placed in the menu. void PopulateAppLauncher(LauncherItem[] items); + + /// + /// Handles desktop-specific routines for showing ShiftOS windows. + /// + /// The calling window. void ShowWindow(IWindowBorder border); + + /// + /// Handles desktop-specific routines for closing ShiftOS windows. + /// + /// The calling window. void KillWindow(IWindowBorder border); + + /// + /// Populates the panel button list with all open windows. + /// void PopulatePanelButtons(); + + /// + /// Performs desktop-specific routines for minimizing a window. + /// + /// The calling window. void MinimizeWindow(IWindowBorder brdr); + + + /// + /// Performs desktop-specific routines for maximizing a window. + /// + /// The calling window. void MaximizeWindow(IWindowBorder brdr); + + + /// + /// Performs desktop-specific routines for restoring a window to its default state. + /// + /// The calling window. void RestoreWindow(IWindowBorder brdr); + + /// + /// Invokes an action on the UI thread. + /// + /// The action to invoke. void InvokeOnWorkerThread(Action act); + + /// + /// Calculates the screen size of the desktop. + /// + /// The desktop's screen size. Size GetSize(); + /// + /// Opens the app launcher at a specific point. + /// + /// Where the app launcher should be opened. void OpenAppLauncher(Point loc); + /// + /// Opens the desktop. + /// void Show(); + + /// + /// Closes the desktop. + /// void Close(); } public static class Desktop { + /// + /// The underlying desktop object. + /// private static IDesktop _desktop = null; - public static Size Size { get + public static Size Size + { + get { return _desktop.GetSize(); } -- cgit v1.2.3