From 37ac4c684ce3904c5ec614362ed99bb9867ca0f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 May 2017 20:08:30 -0400 Subject: It's amazing what talking to Rylan can do to an integer datatype. --- ShiftOS.WinForms/WinformsDesktop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 85eab55..95e7c1a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -192,7 +192,7 @@ namespace ShiftOS.WinForms SetupDesktop(); }; - long lastcp = 0; + ulong lastcp = 0; var storythread = new Thread(() => { -- cgit v1.2.3 From ecf5297dbb9fd551005963dc1d430ed348848390 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 May 2017 21:50:19 -0400 Subject: slightly fix balloon notes --- ShiftOS.WinForms/WinformsDesktop.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 95e7c1a..76c5050 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -47,8 +47,24 @@ namespace ShiftOS.WinForms /// /// Winforms desktop. /// + [Namespace("desktop")] public partial class WinformsDesktop : Form, IDesktop { + [Command("pushnote")] + [RequiresArgument("target")] + [RequiresArgument("title")] + [RequiresArgument("body")] + public static bool PushNote(Dictionary args) + { + string ta = args["target"].ToString(); + string ti = args["title"].ToString(); + string bo = args["body"].ToString(); + + Desktop.PushNotification(ta, ti, bo); + + return true; + } + public List Widgets = new List(); @@ -64,7 +80,7 @@ namespace ShiftOS.WinForms pnlnotificationbox.Left = desktoppanel.Width - pnlnotificationbox.Width; else { - int left = ctl.PointToScreen(ctl.Location).X; + int left = ctl.Parent.PointToScreen(ctl.Location).X; int realleft = left - pnlnotificationbox.Width; realleft += ctl.Width; pnlnotificationbox.Left = realleft; @@ -75,6 +91,7 @@ namespace ShiftOS.WinForms pnlnotificationbox.Top = desktoppanel.Height; else pnlnotificationbox.Top = this.Height - desktoppanel.Height - pnlnotificationbox.Height; + ControlManager.SetupControls(pnlnotificationbox); var notekiller = new System.Windows.Forms.Timer(); notekiller.Interval = 10000; notekiller.Tick += (o, a) => @@ -83,6 +100,7 @@ namespace ShiftOS.WinForms }; Engine.AudioManager.PlayStream(Properties.Resources.infobox); pnlnotificationbox.Show(); + pnlnotificationbox.BringToFront(); notekiller.Start(); } -- cgit v1.2.3 From 3dd402277bba874f24fab11865d257133c6f782c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 08:40:29 -0400 Subject: Fix sizing issue with notifications, and UP key in terminal --- ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/WinformsDesktop.cs | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 080e8bb..a4b77ae 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -338,6 +338,7 @@ namespace ShiftOS.WinForms.Applications var tostring3 = txt.Lines[txt.Lines.Length - 1]; if (tostring3 == $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") Console.Write(TerminalBackend.LastCommand); + ConsoleEx.OnFlush?.Invoke(); a.SuppressKeyPress = true; } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 76c5050..643c02a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -74,6 +74,10 @@ namespace ShiftOS.WinForms { lbnotemsg.Text = msg; lbnotetitle.Text = title; + int height = pnlnotificationbox.Height; + pnlnotificationbox.AutoSize = false; + pnlnotificationbox.Height = height; + pnlnotificationbox.Width = lbnotetitle.Width; var ctl = flnotifications.Controls.ToList().FirstOrDefault(x => x.Tag.ToString() == app); if (ctl == null) @@ -97,8 +101,11 @@ namespace ShiftOS.WinForms notekiller.Tick += (o, a) => { pnlnotificationbox.Hide(); + pnlnotificationbox.AutoSize = true; }; Engine.AudioManager.PlayStream(Properties.Resources.infobox); + + pnlnotificationbox.Show(); pnlnotificationbox.BringToFront(); notekiller.Start(); -- cgit v1.2.3 From c63117276194d18890f14c75b8864749fbd33a0e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 09:03:19 -0400 Subject: modular notifications --- ShiftOS.WinForms/WinformsDesktop.cs | 44 +++++++++++++++++++++++++++++++++ ShiftOS_TheReturn/IStatusIcon.cs | 14 +++++++++++ ShiftOS_TheReturn/NotificationDaemon.cs | 30 ++++++++++++++++++++++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + 4 files changed, 89 insertions(+) create mode 100644 ShiftOS_TheReturn/IStatusIcon.cs (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 643c02a..0cfd667 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -70,6 +70,46 @@ namespace ShiftOS.WinForms private int millisecondsUntilScreensaver = 300000; + public void LoadIcons() + { + //That shot me back to 0.0.x with that name. Whatever. + flnotifications.Controls.Clear(); //Clear the status tray + + foreach(var itype in NotificationDaemon.GetAllStatusIcons()) + { + //We have the types. No need for shiftorium calls or anything. + //First create the icon control... + + var ic = new PictureBox(); + //We can use the type name, in lowercase, for the icon tag. + ic.Tag = itype.Name.ToLower(); + //Next get the icon data if any. + + var iconattrib = itype.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultIconAttribute) as DefaultIconAttribute; + if(iconattrib != null) + { + //We can use this attribute's ID in the skin engine to get an icon. + var img = GetIcon(iconattrib.ID); + //Make it transparent. + (img as Bitmap).MakeTransparent(LoadedSkin.SystemKey); + //Assign it to the control + ic.Image = img; + //Set the sizing mode + ic.SizeMode = PictureBoxSizeMode.StretchImage; + } + else + { + ic.BackColor = Color.White; //TODO: Make it skinnable. + } + ic.Size = new Size(20, 20); //TODO: make it skinnable + //add to the notification tray + flnotifications.Controls.Add(ic); + ic.Show(); + + //TODO: Settings pane on click. + } + } + public void PushNotification(string app, string title, string msg) { lbnotemsg.Text = msg; @@ -134,6 +174,8 @@ namespace ShiftOS.WinForms widget.OnUpgrade(); } + LoadIcons(); + //Only if the DevX Legions story hasn't been experienced yet. if (!Shiftorium.UpgradeInstalled("devx_legions")) { @@ -180,6 +222,7 @@ namespace ShiftOS.WinForms SaveSystem.GameReady += () => { + this.Invoke(new Action(LoadIcons)); if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); }; @@ -208,6 +251,7 @@ namespace ShiftOS.WinForms }; SkinEngine.SkinLoaded += () => { + LoadIcons(); foreach (var widget in Widgets) { widget.OnSkinLoad(); diff --git a/ShiftOS_TheReturn/IStatusIcon.cs b/ShiftOS_TheReturn/IStatusIcon.cs new file mode 100644 index 0000000..f32d1c1 --- /dev/null +++ b/ShiftOS_TheReturn/IStatusIcon.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public interface IStatusIcon + { + void Setup(); + + } +} diff --git a/ShiftOS_TheReturn/NotificationDaemon.cs b/ShiftOS_TheReturn/NotificationDaemon.cs index a90510a..0725782 100644 --- a/ShiftOS_TheReturn/NotificationDaemon.cs +++ b/ShiftOS_TheReturn/NotificationDaemon.cs @@ -25,6 +25,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; @@ -34,6 +35,35 @@ namespace ShiftOS.Engine { public static class NotificationDaemon { + /// + /// Gets a list of all objects that meet their Shiftorium dependencies. + /// + /// An array of s containing the found objects. + public static Type[] GetAllStatusIcons() + { + List lst = new List(); + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IStatusIcon)))) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + lst.Add(type); + } + } + } + catch { } + } + } + return lst.ToArray(); + } + + //if the notifications file already exists then get them public static Notification[] GetAllFromFile() { diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 4cbce72..f70c41e 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -109,6 +109,7 @@ + -- cgit v1.2.3 From b0da30bbde2bb198850ea45dc0006762b23f99a3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 09:14:27 -0400 Subject: COMPLETELY WORKING notification system! --- ShiftOS.WinForms/WinformsDesktop.cs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 0cfd667..b9c4f37 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -106,7 +106,32 @@ namespace ShiftOS.WinForms flnotifications.Controls.Add(ic); ic.Show(); - //TODO: Settings pane on click. + ic.Click += (o, a) => + { + HideAppLauncher(); + + if(itype.BaseType == typeof(UserControl)) + { + UserControl ctrl = (UserControl)Activator.CreateInstance(itype); + (ctrl as IStatusIcon).Setup(); + currentSettingsPane = ctrl; + if(LoadedSkin.DesktopPanelPosition == 0) + { + ctrl.Top = desktoppanel.Height; + } + else + { + ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height; + } + int noteleft = flnotifications.PointToScreen(ic.Location).X; + int realleft = (this.Width - (noteleft + ic.Width)) - ctrl.Width; + ctrl.Left = realleft; + ControlManager.SetupControls(ctrl); + ctrl.Show(); + } + + + }; } } @@ -151,6 +176,8 @@ namespace ShiftOS.WinForms notekiller.Start(); } + private UserControl currentSettingsPane = null; + /// /// Initializes a new instance of the class. /// @@ -1101,6 +1128,8 @@ namespace ShiftOS.WinForms { this.Invoke(new Action(() => { + currentSettingsPane?.Hide(); + currentSettingsPane = null; pnladvancedal.Hide(); })); } -- cgit v1.2.3 From 324104eb0b8650969b2205404e3ad83401fb100e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 19:23:40 -0400 Subject: volume control slider and other goodies --- ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 88 ++++++++------- ShiftOS.WinForms/Properties/Resources.Designer.cs | 16 ++- ShiftOS.WinForms/Properties/Resources.resx | 3 + ShiftOS.WinForms/Resources/iconSpeaker.bmp | Bin 0 -> 3382 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 19 ++++ .../StatusIcons/ShiftnetStatus.Designer.cs | 90 ++++++++++++++++ ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs | 33 ++++++ ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/StatusIcons/Volume.Designer.cs | 59 ++++++++++ ShiftOS.WinForms/StatusIcons/Volume.cs | 67 ++++++++++++ ShiftOS.WinForms/StatusIcons/Volume.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/Tools/ControlManager.cs | 15 ++- ShiftOS.WinForms/WinformsDesktop.Designer.cs | 29 ++--- ShiftOS.WinForms/WinformsDesktop.cs | 32 +++--- ShiftOS.WinForms/WinformsDesktop.resx | 3 - 15 files changed, 617 insertions(+), 77 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/iconSpeaker.bmp create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.cs create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.resx (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index ceaff02..c5a6d05 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -140,51 +140,65 @@ namespace ShiftOS.WinForms.Controls protected override void OnPaint(PaintEventArgs pe) { - pe.Graphics.Clear(this.RealBackColor); - if(RealBackgroundImage != null) + try { - pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); - } - switch (Style) - { - case ProgressBarStyle.Continuous: - double width = linear(this.Value, 0, this.Maximum, 0, this.Width); - if (ProgressImage != null) - { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); - } - else - { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); - } - break; - case ProgressBarStyle.Blocks: - int block_count = this.Width / (this.BlockSize + 2); - int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); - for(int i = 0; i < blocks - 1; i++) - { - int position = i * (BlockSize + 2); + pe.Graphics.Clear(this.RealBackColor); + if (RealBackgroundImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); + } + switch (Style) + { + case ProgressBarStyle.Continuous: + double width = linear(this.Value, 0, this.Maximum, 0, this.Width); if (ProgressImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); + } + break; + case ProgressBarStyle.Blocks: + int block_count = this.Width / (this.BlockSize + 2); + int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); + for (int i = 0; i < blocks - 1; i++) + { + int position = i * (BlockSize + 2); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + } + } + break; + case ProgressBarStyle.Marquee: + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } else { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } - } - break; - case ProgressBarStyle.Marquee: - if (ProgressImage != null) - { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - } - else - { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - } - break; + break; + } + } + catch + { + pe.Graphics.Clear(Color.Black); + string text = "Preview mode. This control can't be drawn without an initiated ShiftOS engine."; + SizeF sz = pe.Graphics.MeasureString(text, this.Font); + PointF loc = new PointF( + (this.Width - sz.Width) / 2, + (this.Height - sz.Height) / 2 + ); + pe.Graphics.DrawString(text, Font, new SolidBrush(Color.White), loc); } } diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 3e83c3f..0386237 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -947,6 +947,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap iconSpeaker { + get { + object obj = ResourceManager.GetObject("iconSpeaker", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1103,9 +1113,9 @@ namespace ShiftOS.WinForms.Properties { /// Category: "Enhancements", /// }, /// { - /// Name: "GUI Based Login Screen", - /// Cost: 500, - /// Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, w [rest of string was truncated]";. + /// Name: "Shift Progress Bar", + /// Cost: 150, + /// Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground an [rest of string was truncated]";. /// internal static string Shiftorium { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 1db7a46..d1a3544 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34603,4 +34603,7 @@ ..\Resources\notestate_connection_full.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\iconSpeaker.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/iconSpeaker.bmp b/ShiftOS.WinForms/Resources/iconSpeaker.bmp new file mode 100644 index 0000000..ec2defb Binary files /dev/null and b/ShiftOS.WinForms/Resources/iconSpeaker.bmp differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 65a512e..fd875e9 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -403,6 +403,18 @@ + + UserControl + + + ShiftnetStatus.cs + + + UserControl + + + Volume.cs + @@ -601,6 +613,12 @@ ShiftSoft_Ping.cs + + ShiftnetStatus.cs + + + Volume.cs + UniteLoginDialog.cs @@ -827,6 +845,7 @@ + diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs new file mode 100644 index 0000000..65aed28 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs @@ -0,0 +1,90 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class ShiftnetStatus + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.lbserviceprovider = new System.Windows.Forms.Label(); + this.lbstatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(5); + this.label1.Size = new System.Drawing.Size(53, 23); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "Shiftnet"; + // + // lbserviceprovider + // + this.lbserviceprovider.AutoSize = true; + this.lbserviceprovider.Dock = System.Windows.Forms.DockStyle.Top; + this.lbserviceprovider.Location = new System.Drawing.Point(0, 23); + this.lbserviceprovider.Name = "lbserviceprovider"; + this.lbserviceprovider.Padding = new System.Windows.Forms.Padding(5); + this.lbserviceprovider.Size = new System.Drawing.Size(98, 23); + this.lbserviceprovider.TabIndex = 1; + this.lbserviceprovider.Tag = "header3"; + this.lbserviceprovider.Text = "Freebie Solutions"; + // + // lbstatus + // + this.lbstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbstatus.Location = new System.Drawing.Point(0, 46); + this.lbstatus.Name = "lbstatus"; + this.lbstatus.Padding = new System.Windows.Forms.Padding(5); + this.lbstatus.Size = new System.Drawing.Size(331, 144); + this.lbstatus.TabIndex = 2; + this.lbstatus.Text = "This will show the Shiftnet status."; + // + // ShiftnetStatus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbstatus); + this.Controls.Add(this.lbserviceprovider); + this.Controls.Add(this.label1); + this.Name = "ShiftnetStatus"; + this.Size = new System.Drawing.Size(331, 190); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lbserviceprovider; + private System.Windows.Forms.Label lbstatus; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs new file mode 100644 index 0000000..f1d31af --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.StatusIcons +{ + [DefaultIcon("iconShiftnet")] + [RequiresUpgrade("victortran_shiftnet")] + public partial class ShiftnetStatus : UserControl, IStatusIcon + { + public ShiftnetStatus() + { + InitializeComponent(); + } + + public void Setup() + { + var subscription = Applications.DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription]; + float kilobytes = (float)subscription.DownloadSpeed / 1024F; + lbserviceprovider.Text = subscription.Name; + lbstatus.Text = $@"Company: {subscription.Company} +Download speed (KB/s): {kilobytes}"; + + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs b/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs new file mode 100644 index 0000000..aa8aa7a --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs @@ -0,0 +1,59 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class Volume + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lbvolume = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbvolume + // + this.lbvolume.AutoSize = true; + this.lbvolume.Location = new System.Drawing.Point(4, 4); + this.lbvolume.Name = "lbvolume"; + this.lbvolume.Size = new System.Drawing.Size(81, 13); + this.lbvolume.TabIndex = 0; + this.lbvolume.Text = "System volume:"; + // + // Volume + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbvolume); + this.Name = "Volume"; + this.Size = new System.Drawing.Size(444, 44); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbvolume; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/Volume.cs b/ShiftOS.WinForms/StatusIcons/Volume.cs new file mode 100644 index 0000000..329faf0 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Controls; + +namespace ShiftOS.WinForms.StatusIcons +{ + [DefaultIcon("iconSpeaker")] + public partial class Volume : UserControl, IStatusIcon + { + public Volume() + { + InitializeComponent(); + } + + public void Setup() + { + lbvolume.Top = (this.Height - lbvolume.Height) / 2; + bool moving = false; + var prg = new ShiftedProgressBar(); + prg.Tag = "ignoreal"; //Don't close AL or current widget when this control is clicked. + this.Controls.Add(prg); + prg.Height = this.Height / 3; + prg.Maximum = 100; + prg.Value = SaveSystem.CurrentSave.MusicVolume; + prg.Width = this.Width - lbvolume.Width - 50; + prg.Left = lbvolume.Left + lbvolume.Width + 15; + prg.Top = (this.Height - prg.Height) / 2; + prg.MouseDown += (o, a) => + { + moving = true; + }; + + prg.MouseMove += (o, a) => + { + if (moving) + { + int val = (int)linear(a.X, 0, prg.Width, 0, 100); + SaveSystem.CurrentSave.MusicVolume = val; + prg.Value = val; + } + }; + + prg.MouseUp += (o, a) => + { + moving = false; + }; + prg.Show(); + } + + static public double linear(double x, double x0, double x1, double y0, double y1) + { + if ((x1 - x0) == 0) + { + return (y0 + y1) / 2; + } + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/Volume.resx b/ShiftOS.WinForms/StatusIcons/Volume.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 92482fa..548a62a 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -158,6 +158,15 @@ namespace ShiftOS.WinForms.Tools } catch { } + if (!tag.Contains("ignoreal")) + { + ctrl.Click += (o, a) => + { + Desktop.HideAppLauncher(); + }; + + } + if (!tag.Contains("keepbg")) { if (ctrl.BackColor != Control.DefaultBackColor) @@ -279,6 +288,8 @@ namespace ShiftOS.WinForms.Tools { (ctrl as WindowBorder).Setup(); } + + MakeDoubleBuffered(ctrl); ControlSetup?.Invoke(ctrl); }); @@ -305,10 +316,6 @@ namespace ShiftOS.WinForms.Tools public static void SetupControls(Control frm, bool runInThread = true) { - frm.Click += (o, a) => - { - Desktop.HideAppLauncher(); - }; var ctrls = frm.Controls.ToList(); for (int i = 0; i < ctrls.Count(); i++) { diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 968a31c..d82bc0c 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -55,6 +55,7 @@ namespace ShiftOS.WinForms this.desktoppanel = new System.Windows.Forms.Panel(); this.pnlnotifications = new System.Windows.Forms.Panel(); this.flnotifications = new System.Windows.Forms.FlowLayoutPanel(); + this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); this.lbtime = new System.Windows.Forms.Label(); this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); this.sysmenuholder = new System.Windows.Forms.Panel(); @@ -63,7 +64,6 @@ namespace ShiftOS.WinForms this.pnlscreensaver = new System.Windows.Forms.Panel(); this.pnlssicon = new System.Windows.Forms.Panel(); this.pnlwidgetlayer = new System.Windows.Forms.Panel(); - this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); this.pnlnotificationbox = new System.Windows.Forms.Panel(); this.lbnotemsg = new System.Windows.Forms.Label(); this.lbnotetitle = new System.Windows.Forms.Label(); @@ -77,10 +77,10 @@ namespace ShiftOS.WinForms this.desktoppanel.SuspendLayout(); this.pnlnotifications.SuspendLayout(); this.flnotifications.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.pnlscreensaver.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); this.pnlnotificationbox.SuspendLayout(); this.pnladvancedal.SuspendLayout(); this.pnlalsystemactions.SuspendLayout(); @@ -121,6 +121,18 @@ namespace ShiftOS.WinForms this.flnotifications.Name = "flnotifications"; this.flnotifications.Size = new System.Drawing.Size(22, 24); this.flnotifications.TabIndex = 1; + this.flnotifications.WrapContents = false; + // + // ntconnectionstatus + // + this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; + this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); + this.ntconnectionstatus.Name = "ntconnectionstatus"; + this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); + this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.ntconnectionstatus.TabIndex = 0; + this.ntconnectionstatus.TabStop = false; + this.ntconnectionstatus.Tag = "digitalsociety"; // // lbtime // @@ -200,17 +212,6 @@ namespace ShiftOS.WinForms this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); this.pnlwidgetlayer.TabIndex = 1; // - // ntconnectionstatus - // - this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; - this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); - this.ntconnectionstatus.Name = "ntconnectionstatus"; - this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); - this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.ntconnectionstatus.TabIndex = 0; - this.ntconnectionstatus.TabStop = false; - this.ntconnectionstatus.Tag = "digitalsociety"; - // // pnlnotificationbox // this.pnlnotificationbox.AutoSize = true; @@ -341,12 +342,12 @@ namespace ShiftOS.WinForms this.pnlnotifications.PerformLayout(); this.flnotifications.ResumeLayout(false); this.flnotifications.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); this.sysmenuholder.ResumeLayout(false); this.sysmenuholder.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.pnlscreensaver.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); this.pnlnotificationbox.ResumeLayout(false); this.pnlnotificationbox.PerformLayout(); this.pnladvancedal.ResumeLayout(false); diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index b9c4f37..f1dbe48 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -85,27 +85,24 @@ namespace ShiftOS.WinForms ic.Tag = itype.Name.ToLower(); //Next get the icon data if any. - var iconattrib = itype.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultIconAttribute) as DefaultIconAttribute; - if(iconattrib != null) - { //We can use this attribute's ID in the skin engine to get an icon. - var img = GetIcon(iconattrib.ID); + var img = GetIcon(itype.Name); //Make it transparent. - (img as Bitmap).MakeTransparent(LoadedSkin.SystemKey); + (img as Bitmap).MakeTransparent(Color.White); //Assign it to the control ic.Image = img; //Set the sizing mode ic.SizeMode = PictureBoxSizeMode.StretchImage; - } - else - { - ic.BackColor = Color.White; //TODO: Make it skinnable. - } - ic.Size = new Size(20, 20); //TODO: make it skinnable + ic.Size = new Size(16, 16); //TODO: make it skinnable //add to the notification tray flnotifications.Controls.Add(ic); ic.Show(); + ic.BringToFront(); + + flnotifications.Show(); + + ic.Click += (o, a) => { HideAppLauncher(); @@ -115,7 +112,14 @@ namespace ShiftOS.WinForms UserControl ctrl = (UserControl)Activator.CreateInstance(itype); (ctrl as IStatusIcon).Setup(); currentSettingsPane = ctrl; - if(LoadedSkin.DesktopPanelPosition == 0) + ControlManager.SetupControls(ctrl); + this.Controls.Add(ctrl); + ctrl.BringToFront(); + int left = ic.Parent.PointToScreen(ic.Location).X; + int realleft = left - ctrl.Width; + realleft += ic.Width; + ctrl.Left = realleft; + if (LoadedSkin.DesktopPanelPosition == 0) { ctrl.Top = desktoppanel.Height; } @@ -123,10 +127,6 @@ namespace ShiftOS.WinForms { ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height; } - int noteleft = flnotifications.PointToScreen(ic.Location).X; - int realleft = (this.Width - (noteleft + ic.Width)) - ctrl.Width; - ctrl.Left = realleft; - ControlManager.SetupControls(ctrl); ctrl.Show(); } diff --git a/ShiftOS.WinForms/WinformsDesktop.resx b/ShiftOS.WinForms/WinformsDesktop.resx index b77504b..d5494e3 100644 --- a/ShiftOS.WinForms/WinformsDesktop.resx +++ b/ShiftOS.WinForms/WinformsDesktop.resx @@ -120,7 +120,4 @@ 17, 17 - - 17, 17 - \ No newline at end of file -- cgit v1.2.3 From 5246798b0ad07ac1a2dd9a1369da4ecad2383488 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Jun 2017 08:05:53 -0400 Subject: Make stories not happen until user is logged in. --- ShiftOS.WinForms/WinformsDesktop.cs | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index f1dbe48..4614842 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -196,38 +196,14 @@ namespace ShiftOS.WinForms SetupControl(desktoppanel); Shiftorium.Installed += () => { - foreach(var widget in Widgets) + foreach (var widget in Widgets) { widget.OnUpgrade(); } LoadIcons(); - //Only if the DevX Legions story hasn't been experienced yet. - if (!Shiftorium.UpgradeInstalled("devx_legions")) - { - //Check for shiftnet story experience - if (Shiftorium.UpgradeInstalled("shiftnet")) - { - //Check for saturation of the "GUI" upgrade set - if (Shiftorium.IsCategoryEmptied("GUI")) - { - //Start the MUD Control Centre story. - Story.Start("devx_legions"); - } - } - } - if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) - { - if (SaveSystem.CurrentSave.Codepoints >= 50000) - { - if (Shiftorium.IsCategoryEmptied("Applications")) - { - Story.Start("victortran_shiftnet"); - } - } - } }; this.TopMost = false; @@ -294,6 +270,9 @@ namespace ShiftOS.WinForms { do { + while (SaveSystem.CurrentUser == null) + Thread.Sleep(10); + if (SaveSystem.CurrentSave != null) { if (SaveSystem.CurrentSave.Codepoints != lastcp) -- cgit v1.2.3 From c40d071d58859e25b3781299b949b91caa0548fe Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 10 Jun 2017 10:17:10 -0400 Subject: main menu system + sandbox mode --- ShiftOS.Objects/Save.cs | 6 + ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs | 147 ++++++++++++++++ ShiftOS.WinForms/MainMenu/MainMenu.cs | 100 +++++++++++ ShiftOS.WinForms/MainMenu/MainMenu.resx | 120 +++++++++++++ ShiftOS.WinForms/Program.cs | 35 ++-- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 + .../ShiftnetSites/ShiftSoft.Designer.cs | 188 ++++++++++++++++++++- ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs | 56 ++++++ ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx | 10 ++ ShiftOS.WinForms/Stories/LegionStory.cs | 42 ++--- ShiftOS.WinForms/WinformsDesktop.cs | 32 +++- ShiftOS_TheReturn/AppearanceManager.cs | 1 + ShiftOS_TheReturn/SaveSystem.cs | 152 ++++++++++++----- ShiftOS_TheReturn/ServerManager.cs | 18 +- ShiftOS_TheReturn/Shiftorium.cs | 3 + ShiftOS_TheReturn/Story.cs | 8 + 16 files changed, 825 insertions(+), 102 deletions(-) create mode 100644 ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs create mode 100644 ShiftOS.WinForms/MainMenu/MainMenu.cs create mode 100644 ShiftOS.WinForms/MainMenu/MainMenu.resx (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 7891a22..6e7f167 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -76,10 +76,14 @@ namespace ShiftOS.Objects _setCpCallbacks.Remove(callback); } + public bool IsSandbox = false; + public ulong Codepoints { get { + if (IsSandbox == true) + return 0; if (_updTimer == null) _updTimer = new Timer((o) => syncCp(), null, 0, 300000); lock (_cpLock) @@ -89,6 +93,8 @@ namespace ShiftOS.Objects } set { + if (IsSandbox == true) + return; lock (_cpLock) { _cp = value; diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs b/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs new file mode 100644 index 0000000..62db46d --- /dev/null +++ b/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs @@ -0,0 +1,147 @@ +namespace ShiftOS.WinForms.MainMenu +{ + partial class MainMenu + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.flmenu = new System.Windows.Forms.FlowLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.lbticker = new System.Windows.Forms.Label(); + this.flmenu.SuspendLayout(); + this.SuspendLayout(); + // + // flmenu + // + this.flmenu.AutoSize = true; + this.flmenu.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flmenu.Controls.Add(this.button1); + this.flmenu.Controls.Add(this.button2); + this.flmenu.Controls.Add(this.button3); + this.flmenu.Controls.Add(this.button4); + this.flmenu.Controls.Add(this.button5); + this.flmenu.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flmenu.Location = new System.Drawing.Point(46, 218); + this.flmenu.Name = "flmenu"; + this.flmenu.Size = new System.Drawing.Size(187, 145); + this.flmenu.TabIndex = 0; + // + // button1 + // + this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button1.Location = new System.Drawing.Point(3, 3); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(181, 23); + this.button1.TabIndex = 0; + this.button1.Text = "Campaign"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button2.Location = new System.Drawing.Point(3, 32); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(181, 23); + this.button2.TabIndex = 1; + this.button2.Text = "Sandbox"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button3.Location = new System.Drawing.Point(3, 61); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(181, 23); + this.button3.TabIndex = 2; + this.button3.Text = "Settings"; + this.button3.UseVisualStyleBackColor = true; + // + // button4 + // + this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button4.Location = new System.Drawing.Point(3, 90); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(181, 23); + this.button4.TabIndex = 3; + this.button4.Text = "About"; + this.button4.UseVisualStyleBackColor = true; + // + // button5 + // + this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button5.Location = new System.Drawing.Point(3, 119); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(181, 23); + this.button5.TabIndex = 4; + this.button5.Text = "Exit"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // lbticker + // + this.lbticker.AutoSize = true; + this.lbticker.Location = new System.Drawing.Point(29, 515); + this.lbticker.Name = "lbticker"; + this.lbticker.Size = new System.Drawing.Size(93, 13); + this.lbticker.TabIndex = 1; + this.lbticker.Tag = "header3"; + this.lbticker.Text = "This is a tickerbar."; + // + // MainMenu + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(1161, 566); + this.Controls.Add(this.lbticker); + this.Controls.Add(this.flmenu); + this.ForeColor = System.Drawing.Color.White; + this.Name = "MainMenu"; + this.Text = "MainMenu"; + this.Load += new System.EventHandler(this.MainMenu_Load); + this.flmenu.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flmenu; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Label lbticker; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.cs b/ShiftOS.WinForms/MainMenu/MainMenu.cs new file mode 100644 index 0000000..20cd4ec --- /dev/null +++ b/ShiftOS.WinForms/MainMenu/MainMenu.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms.MainMenu +{ + public partial class MainMenu : Form + { + public MainMenu(IDesktop desk) + { + InitializeComponent(); + (desk as WinformsDesktop).ParentMenu = this; + + var tickermove = new Timer(); + var tickerreset = new Timer(); + tickermove.Tick += (o, a) => + { + if(lbticker.Left <= (0 - lbticker.Width)) + { + tickermove.Stop(); + tickerreset.Start(); + } + else + { + lbticker.Top = (this.ClientSize.Height - (lbticker.Height * 2)); + lbticker.Left -= 2; + } + }; + tickerreset.Tick += (o, a) => + { + lbticker.Visible = false; + lbticker.Text = GetTickerMessage(); + lbticker.Left = this.Width; + lbticker.Visible = true; + tickerreset.Stop(); + tickermove.Start(); + }; + + tickermove.Interval = 1; + tickerreset.Interval = 1000; + + flmenu.CenterParent(); + + tickerreset.Start(); + } + + private void MainMenu_Load(object sender, EventArgs e) + { + Tools.ControlManager.SetupControls(this); + + } + + private Random rnd = new Random(); + + private string GetTickerMessage() + { + switch (rnd.Next(0, 10)) + { + case 0: + return "Did you know that you can skin this very menu? Just goes to show how much you can shift it your way."; + case 1: + return "Want to pick up a few skins or mods from the community? Head on over to http://getshiftos.ml/Skins!"; + case 2: + return "Sandbox mode is a special version of ShiftOS that allows you to use the operating system without having to deal with Codepoints, the Shiftorium or having to play through the storyline. Handy..."; + case 3: + return "ArtPad not good enough? You can use an external image editor to create ShiftOS skin textures. Just save your files to the Shared Directory and they'll be imported into ShiftOS on the 1:/ drive."; + case 4: + return "Terminal too weird for ya? You can use the Format Editor to generate your own Terminal command parser. No coding knowledge needed!"; + case 5: + return "Contests are a good way to earn heaps of Codepoints. Head on over to http://getshiftos.ml/Contests for info on current community contests."; + default: + return "Good God. We don't know what to put here."; + } + } + + private void button1_Click(object sender, EventArgs e) + { + Desktop.CurrentDesktop.Show(); + } + + private void button5_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + (Desktop.CurrentDesktop as WinformsDesktop).IsSandbox = true; + Desktop.CurrentDesktop.Show(); + } + } +} diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.resx b/ShiftOS.WinForms/MainMenu/MainMenu.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/MainMenu/MainMenu.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 8f65265..b07d97a 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -50,6 +50,21 @@ namespace ShiftOS.WinForms Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael SkinEngine.SetPostProcessor(new DitheringSkinPostProcessor()); + LoginManager.Init(new GUILoginFrontend()); + CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); + SkinEngine.SetIconProber(new ShiftOSIconProvider()); + TerminalBackend.TerminalRequested += () => + { + AppearanceManager.SetupWindow(new Applications.Terminal()); + }; + Localization.RegisterProvider(new WFLanguageProvider()); + Infobox.Init(new Dialog()); + FileSkimmerBackend.Init(new WinformsFSFrontend()); + var desk = new WinformsDesktop(); + Desktop.Init(desk); + OutOfBoxExperience.Init(new Oobe()); + AppearanceManager.Initiate(new WinformsWindowManager()); +#if OLD SaveSystem.PreDigitalSocietyConnection += () => { Action completed = null; @@ -63,25 +78,11 @@ namespace ShiftOS.WinForms Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); }; - LoginManager.Init(new GUILoginFrontend()); - CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); - SkinEngine.SetIconProber(new ShiftOSIconProvider()); - ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); - Localization.RegisterProvider(new WFLanguageProvider()); - TutorialManager.RegisterTutorial(new Oobe()); - - TerminalBackend.TerminalRequested += () => - { - AppearanceManager.SetupWindow(new Applications.Terminal()); - }; - Infobox.Init(new Dialog()); - FileSkimmerBackend.Init(new WinformsFSFrontend()); - var desk = new WinformsDesktop(); - Desktop.Init(desk); - OutOfBoxExperience.Init(new Oobe()); - AppearanceManager.Initiate(new WinformsWindowManager()); Application.Run(desk); +#else + Application.Run(new MainMenu.MainMenu(desk)); +#endif } } diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index e1afa84..d589ed4 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -356,6 +356,12 @@ + + Form + + + MainMenu.cs + Form @@ -603,6 +609,9 @@ GUILogin.cs + + MainMenu.cs + Oobe.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs index a62b5a8..b3e408f 100644 --- a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs @@ -28,27 +28,198 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShiftSoft)); this.label1 = new System.Windows.Forms.Label(); + this.pnldivider = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.flbuttons = new System.Windows.Forms.FlowLayoutPanel(); + this.btnhome = new System.Windows.Forms.Button(); + this.btnservices = new System.Windows.Forms.Button(); + this.btnping = new System.Windows.Forms.Button(); + this.pnlhome = new System.Windows.Forms.Panel(); + this.lbwhere = new System.Windows.Forms.Label(); + this.lbdesc = new System.Windows.Forms.Label(); + this.pnlservices = new System.Windows.Forms.Panel(); + this.lbfreebiedesc = new System.Windows.Forms.Label(); + this.lbfreebie = new System.Windows.Forms.Label(); + this.btnjoinfreebie = new System.Windows.Forms.Button(); + this.flbuttons.SuspendLayout(); + this.pnlhome.SuspendLayout(); + this.pnlservices.SuspendLayout(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Franklin Gothic Heavy", 24.75F, System.Drawing.FontStyle.Italic); - this.label1.Location = new System.Drawing.Point(13, 17); + this.label1.Location = new System.Drawing.Point(13, 8); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(152, 38); this.label1.TabIndex = 0; this.label1.Tag = "keepfont"; this.label1.Text = "Shiftsoft"; // + // pnldivider + // + this.pnldivider.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnldivider.Location = new System.Drawing.Point(20, 71); + this.pnldivider.Name = "pnldivider"; + this.pnldivider.Size = new System.Drawing.Size(654, 2); + this.pnldivider.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(17, 46); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(163, 13); + this.label2.TabIndex = 2; + this.label2.Text = "What do you want to shift today?"; + // + // flbuttons + // + this.flbuttons.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.flbuttons.AutoSize = true; + this.flbuttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flbuttons.Controls.Add(this.btnhome); + this.flbuttons.Controls.Add(this.btnservices); + this.flbuttons.Controls.Add(this.btnping); + this.flbuttons.Location = new System.Drawing.Point(515, 17); + this.flbuttons.Name = "flbuttons"; + this.flbuttons.Size = new System.Drawing.Size(159, 29); + this.flbuttons.TabIndex = 3; + // + // btnhome + // + this.btnhome.AutoSize = true; + this.btnhome.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnhome.Location = new System.Drawing.Point(3, 3); + this.btnhome.Name = "btnhome"; + this.btnhome.Size = new System.Drawing.Size(45, 23); + this.btnhome.TabIndex = 0; + this.btnhome.Tag = "header3"; + this.btnhome.Text = "Home"; + this.btnhome.UseVisualStyleBackColor = true; + this.btnhome.Click += new System.EventHandler(this.btnhome_Click); + // + // btnservices + // + this.btnservices.AutoSize = true; + this.btnservices.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnservices.Location = new System.Drawing.Point(54, 3); + this.btnservices.Name = "btnservices"; + this.btnservices.Size = new System.Drawing.Size(58, 23); + this.btnservices.TabIndex = 1; + this.btnservices.Tag = "header3"; + this.btnservices.Text = "Services"; + this.btnservices.UseVisualStyleBackColor = true; + this.btnservices.Click += new System.EventHandler(this.btnservices_Click); + // + // btnping + // + this.btnping.AutoSize = true; + this.btnping.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnping.Location = new System.Drawing.Point(118, 3); + this.btnping.Name = "btnping"; + this.btnping.Size = new System.Drawing.Size(38, 23); + this.btnping.TabIndex = 2; + this.btnping.Tag = "header3"; + this.btnping.Text = "Ping"; + this.btnping.UseVisualStyleBackColor = true; + this.btnping.Click += new System.EventHandler(this.btnping_Click); + // + // pnlhome + // + this.pnlhome.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.pnlhome.Controls.Add(this.lbdesc); + this.pnlhome.Controls.Add(this.lbwhere); + this.pnlhome.Location = new System.Drawing.Point(20, 92); + this.pnlhome.Name = "pnlhome"; + this.pnlhome.Size = new System.Drawing.Size(654, 271); + this.pnlhome.TabIndex = 4; + // + // lbwhere + // + this.lbwhere.AutoSize = true; + this.lbwhere.Location = new System.Drawing.Point(4, 4); + this.lbwhere.Name = "lbwhere"; + this.lbwhere.Size = new System.Drawing.Size(169, 13); + this.lbwhere.TabIndex = 0; + this.lbwhere.Tag = "header2"; + this.lbwhere.Text = "Where do you want to shift today?"; + // + // lbdesc + // + this.lbdesc.Location = new System.Drawing.Point(4, 17); + this.lbdesc.Name = "lbdesc"; + this.lbdesc.Size = new System.Drawing.Size(361, 160); + this.lbdesc.TabIndex = 1; + this.lbdesc.Text = resources.GetString("lbdesc.Text"); + // + // pnlservices + // + this.pnlservices.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.pnlservices.Controls.Add(this.btnjoinfreebie); + this.pnlservices.Controls.Add(this.lbfreebiedesc); + this.pnlservices.Controls.Add(this.lbfreebie); + this.pnlservices.Location = new System.Drawing.Point(20, 92); + this.pnlservices.Name = "pnlservices"; + this.pnlservices.Size = new System.Drawing.Size(654, 271); + this.pnlservices.TabIndex = 5; + // + // lbfreebiedesc + // + this.lbfreebiedesc.Location = new System.Drawing.Point(4, 17); + this.lbfreebiedesc.Name = "lbfreebiedesc"; + this.lbfreebiedesc.Size = new System.Drawing.Size(361, 105); + this.lbfreebiedesc.TabIndex = 1; + this.lbfreebiedesc.Text = resources.GetString("lbfreebiedesc.Text"); + // + // lbfreebie + // + this.lbfreebie.AutoSize = true; + this.lbfreebie.Location = new System.Drawing.Point(4, 4); + this.lbfreebie.Name = "lbfreebie"; + this.lbfreebie.Size = new System.Drawing.Size(88, 13); + this.lbfreebie.TabIndex = 0; + this.lbfreebie.Tag = "header2"; + this.lbfreebie.Text = "Freebie Solutions"; + // + // btnjoinfreebie + // + this.btnjoinfreebie.AutoSize = true; + this.btnjoinfreebie.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnjoinfreebie.Location = new System.Drawing.Point(245, 125); + this.btnjoinfreebie.Name = "btnjoinfreebie"; + this.btnjoinfreebie.Size = new System.Drawing.Size(120, 23); + this.btnjoinfreebie.TabIndex = 2; + this.btnjoinfreebie.Text = "Join Freebie Solutions"; + this.btnjoinfreebie.UseVisualStyleBackColor = true; + this.btnjoinfreebie.Click += new System.EventHandler(this.btnjoinfreebie_Click); + // // ShiftSoft // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pnlservices); + this.Controls.Add(this.pnlhome); + this.Controls.Add(this.flbuttons); + this.Controls.Add(this.label2); + this.Controls.Add(this.pnldivider); this.Controls.Add(this.label1); this.Name = "ShiftSoft"; - this.Size = new System.Drawing.Size(523, 384); + this.Size = new System.Drawing.Size(694, 384); + this.flbuttons.ResumeLayout(false); + this.flbuttons.PerformLayout(); + this.pnlhome.ResumeLayout(false); + this.pnlhome.PerformLayout(); + this.pnlservices.ResumeLayout(false); + this.pnlservices.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -57,5 +228,18 @@ #endregion private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel pnldivider; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.FlowLayoutPanel flbuttons; + private System.Windows.Forms.Button btnhome; + private System.Windows.Forms.Button btnservices; + private System.Windows.Forms.Button btnping; + private System.Windows.Forms.Panel pnlhome; + private System.Windows.Forms.Label lbdesc; + private System.Windows.Forms.Label lbwhere; + private System.Windows.Forms.Panel pnlservices; + private System.Windows.Forms.Label lbfreebiedesc; + private System.Windows.Forms.Label lbfreebie; + private System.Windows.Forms.Button btnjoinfreebie; } } diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs index 18968cd..0d84ecc 100644 --- a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs @@ -25,6 +25,18 @@ namespace ShiftOS.WinForms.ShiftnetSites public void OnSkinLoad() { + pnldivider.Tag = "keepbg"; + pnldivider.BackColor = SkinEngine.LoadedSkin.ControlTextColor; + Tools.ControlManager.SetupControls(flbuttons); + Tools.ControlManager.SetupControls(pnlhome); + Tools.ControlManager.SetupControls(pnlservices); + + lbfreebiedesc.Top = lbfreebie.Top + lbfreebie.Height + 5; + btnjoinfreebie.Top = lbfreebiedesc.Top + lbfreebiedesc.Height + 5; + + SetupFreebieUI(); + + lbdesc.Top = lbwhere.Top + lbwhere.Height + 5; } public void OnUpgrade() @@ -33,6 +45,50 @@ namespace ShiftOS.WinForms.ShiftnetSites public void Setup() { + pnlhome.BringToFront(); + } + + private void btnping_Click(object sender, EventArgs e) + { + GoToUrl?.Invoke("shiftnet/shiftsoft/ping"); + } + + private void btnhome_Click(object sender, EventArgs e) + { + pnlhome.BringToFront(); + } + + private void btnservices_Click(object sender, EventArgs e) + { + pnlservices.BringToFront(); + SetupFreebieUI(); + } + + public void SetupFreebieUI() + { + if(SaveSystem.CurrentSave.ShiftnetSubscription == 0) + { + btnjoinfreebie.Enabled = false; + btnjoinfreebie.Text = "You are already subscribed to Freebie Solutions."; + } + else + { + btnjoinfreebie.Enabled = true; + btnjoinfreebie.Text = "Join Freebie Solutions"; + } + btnjoinfreebie.Left = (lbfreebiedesc.Left + lbfreebiedesc.Width) - btnjoinfreebie.Width; + } + + private void btnjoinfreebie_Click(object sender, EventArgs e) + { + Infobox.PromptYesNo("Switch providers", "Would you like to switch from your current Shiftnet provider, " + Applications.DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].Name + ", to Freebie Solutions by ShiftSoft?", (res) => + { + if(res == true) + { + SaveSystem.CurrentSave.ShiftnetSubscription = 0; + Infobox.Show("Switch providers", "The operation has completed successfully."); + } + }); } } } diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx index 1af7de1..cd314f0 100644 --- a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx @@ -117,4 +117,14 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Welcome to ShiftSoft. We understand the troubles of being locked within a digital society. For some, it's a prison. For others, it's all they know. It's what life means for them. + +But for us, it's a safe-haven. We may all be locked within an evolving operating system with no possibility of escaping, but we can at least develop ways of improving life within this binary world, and that's what we at ShiftSoft are doing. + + + The Shiftnet is a wonderful place full of apps, utilities, enhancements and much more for ShiftOS, but it comes at a cost. + +Freebie Solutions takes that cost away. You get free Shiftnet usage, but are locked to sites listed on Ping and you are limited to 256 byte-per-second downloads. Perfect for those situations where Codepoints and shiftnet connectivity are a needed resource. + \ No newline at end of file diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 056fe85..c52732e 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -74,22 +74,10 @@ namespace ShiftOS.WinForms.Stories WriteLine("Anyways, that's all I'll say for now. Have fun on the Shiftnet. I have to go work on something."); WriteLine("One of my friends'll contact you once you've gotten a new service provider."); - Story.PushObjective("Register with a new Shiftnet service provider.", "You've just unlocked the Shiftnet, which has opened up a whole new world of applications and features for ShiftOS. Before you go nuts with it, you may want to register with a better service provider than Freebie Solutions.", () => - { - return SaveSystem.CurrentSave.ShiftnetSubscription != 0; - }, - () => - { - Story.Context.MarkComplete(); - SaveSystem.SaveGame(); - TerminalBackend.PrintPrompt(); - Story.Start("hacker101_breakingbonds_1"); - }); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - Story.Context.AutoComplete = false; + Story.Context.MarkComplete(); + Story.Start("aiden_shiftnet2"); } [Story("hacker101_breakingbonds_1")] @@ -111,6 +99,9 @@ namespace ShiftOS.WinForms.Stories WriteLine("Before I can do that, however, I need you to do a few things."); WriteLine("I'll assign what I need you to do as an objective. When you're done, I'll tell you what you need to know."); + Story.Context.MarkComplete(); + TerminalBackend.PrefixEnabled = true; + Story.PushObjective("Breaking the Bonds: Errand Boy", @"hacker101 has something he needs to show you, however before he can, you need to do the following: - Buy ""TriWrite"" from Appscape @@ -127,14 +118,25 @@ namespace ShiftOS.WinForms.Stories SaveSystem.SaveGame(); Story.Start("hacker101_breakingbonds_2"); }); - - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - Story.Context.AutoComplete = false; - } + [Story("aiden_shiftnet2")] + public static void AidenShiftnet2() + { + Story.PushObjective("Register with a new Shiftnet service provider.", "You've just unlocked the Shiftnet, which has opened up a whole new world of applications and features for ShiftOS. Before you go nuts with it, you may want to register with a better service provider than Freebie Solutions.", () => + { + return SaveSystem.CurrentSave.ShiftnetSubscription != 0; + }, + () => + { + Story.Context.MarkComplete(); + SaveSystem.SaveGame(); + TerminalBackend.PrintPrompt(); + Story.Start("hacker101_breakingbonds_1"); + }); + Story.Context.AutoComplete = false; + } private static void WriteLine(string text, bool showCharacterName=true) { @@ -159,7 +161,7 @@ namespace ShiftOS.WinForms.Stories { Console.Write(c); ConsoleEx.OnFlush?.Invoke(); - Thread.Sleep(45); + Thread.Sleep(5); } Thread.Sleep(1000); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 4614842..f6c4383 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -50,6 +50,8 @@ namespace ShiftOS.WinForms [Namespace("desktop")] public partial class WinformsDesktop : Form, IDesktop { + public MainMenu.MainMenu ParentMenu = null; + [Command("pushnote")] [RequiresArgument("target")] [RequiresArgument("title")] @@ -921,7 +923,7 @@ namespace ShiftOS.WinForms /// E. private void Desktop_Load(object sender, EventArgs e) { - + SaveSystem.IsSandbox = this.IsSandbox; SaveSystem.Begin(); SetupDesktop(); @@ -964,6 +966,7 @@ namespace ShiftOS.WinForms } private IWindowBorder focused = null; + internal bool IsSandbox = false; public string DesktopName { @@ -1033,10 +1036,17 @@ namespace ShiftOS.WinForms { try { - this.Invoke(new Action(() => + if (this.Visible == true) { - act?.Invoke(); - })); + this.Invoke(new Action(() => + { + act?.Invoke(); + })); + } + else + { + ParentMenu?.Invoke(act); + } } catch { @@ -1105,12 +1115,16 @@ namespace ShiftOS.WinForms public void HideAppLauncher() { - this.Invoke(new Action(() => + try { - currentSettingsPane?.Hide(); - currentSettingsPane = null; - pnladvancedal.Hide(); - })); + this.Invoke(new Action(() => + { + currentSettingsPane?.Hide(); + currentSettingsPane = null; + pnladvancedal.Hide(); + })); + } + catch { } } } diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 7cf06c9..e244b77 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -126,6 +126,7 @@ namespace ShiftOS.Engine } + // Provides a list of all open ShiftOS windows. public static List OpenForms = new List(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index e98a51e..e36fee6 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -67,6 +67,7 @@ namespace ShiftOS.Engine /// Boolean representing whether the save system is ready to be used. /// public static bool Ready = false; + public static bool IsSandbox = false; /// /// Occurs before the save system connects to the ShiftOS Digital Society. @@ -140,63 +141,126 @@ namespace ShiftOS.Engine Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); Console.WriteLine("[termdb] Building command database from filesystem..."); TerminalBackend.PopulateTerminalCommands(); - Console.WriteLine("[inetd] Connecting to network..."); - Ready = false; - - if (PreDigitalSocietyConnection != null) + if (IsSandbox == false) { - PreDigitalSocietyConnection?.Invoke(); + Console.WriteLine("[inetd] Connecting to network..."); + + Ready = false; - while (!Ready) + if (PreDigitalSocietyConnection != null) { - Thread.Sleep(10); + PreDigitalSocietyConnection?.Invoke(); + + while (!Ready) + { + Thread.Sleep(10); + } } - } - - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { - //Connection successful! Stop waiting! - guidReceived = true; - Console.WriteLine("[inetd] Connection successful."); - }; - try - { + bool guidReceived = false; + ServerManager.GUIDReceived += (str) => + { + //Connection successful! Stop waiting! + guidReceived = true; + Console.WriteLine("[inetd] Connection successful."); + }; - ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); - //This haults the client until the connection is successful. - while (ServerManager.thisGuid == new Guid()) + try { - Thread.Sleep(10); + + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); + //This haults the client until the connection is successful. + while (ServerManager.thisGuid == new Guid()) + { + Thread.Sleep(10); + } + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); + FinishBootstrap(); } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); + catch (Exception ex) + { + //No errors, this never gets called. + Console.WriteLine("[inetd] SEVERE: " + ex.Message); + Thread.Sleep(3000); + Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 4..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 3..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 2..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 1..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] Bye bye."); + System.Diagnostics.Process.GetCurrentProcess().Kill(); + } + + //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. } - catch (Exception ex) + else { - //No errors, this never gets called. - Console.WriteLine("[inetd] SEVERE: " + ex.Message); - Thread.Sleep(3000); - Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5..."); - Thread.Sleep(1000); - Console.WriteLine("[sys] 4..."); - Thread.Sleep(1000); - Console.WriteLine("[sys] 3..."); - Thread.Sleep(1000); - Console.WriteLine("[sys] 2..."); - Thread.Sleep(1000); - Console.WriteLine("[sys] 1..."); - Thread.Sleep(1000); - Console.WriteLine("[sys] Bye bye."); - System.Diagnostics.Process.GetCurrentProcess().Kill(); - } + Console.WriteLine("[inetd] Sandbox mode initiating..."); + CurrentSave = new Save + { + IsSandbox = true, + Username = "sandbox", + Password = "sandbox", + SystemName = "shiftos", + Users = new List + { + new ClientSave + { + Username = "user", + Password = "", + Permissions = 0 + } + }, + Class = 0, + ID = new Guid(), + Upgrades = new Dictionary(), + CurrentLegions = null, + IsMUDAdmin = false, + IsPatreon = false, + Language = "english", + LastMonthPaid = 0, + MajorVersion = 1, + MinorVersion = 0, + MusicEnabled = false, + MusicVolume = 100, + MyShop = "", + PasswordHashed = false, + PickupPoint = "", + RawReputation = 0.0f, + Revision = 0, + ShiftnetSubscription = 0, + SoundEnabled = true, + StoriesExperienced = null, + StoryPosition = 0, + UniteAuthToken = "", + }; + + CurrentUser = CurrentSave.Users.First(); + + Localization.SetupTHETRUEDefaultLocals(); + + Shiftorium.Init(); + + TerminalBackend.InStory = false; + TerminalBackend.PrefixEnabled = true; + + Desktop.InvokeOnWorkerThread(new Action(() => + { + ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); + })); - //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. + Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); + GameReady?.Invoke(); + } })); thread.IsBackground = true; @@ -243,10 +307,6 @@ namespace ShiftOS.Engine Thread.Sleep(10); } - Localization.SetupTHETRUEDefaultLocals(); - - Shiftorium.Init(); - while (CurrentSave.StoryPosition < 1) { Thread.Sleep(10); diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 1439c0d..be4f086 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -302,15 +302,17 @@ Ping: {ServerManager.DigitalSocietyPing} ms /// The message body public static void SendMessage(string name, string contents) { - var sMsg = new ServerMessage + if (!SaveSystem.IsSandbox) { - Name = name, - Contents = contents, - GUID = thisGuid.ToString(), - }; - PingTimer.Start(); - client.Send(new NetObject("msg", sMsg)); - + var sMsg = new ServerMessage + { + Name = name, + Contents = contents, + GUID = thisGuid.ToString(), + }; + PingTimer.Start(); + client.Send(new NetObject("msg", sMsg)); + } } private static bool singleplayer = false; diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 975939f..7faf336 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -429,6 +429,9 @@ namespace ShiftOS.Engine /// Whether the upgrade is installed. public static bool UpgradeInstalled(string id) { + if (SaveSystem.IsSandbox == true) + return true; + if (string.IsNullOrWhiteSpace(id)) return true; if (SaveSystem.CurrentSave != null) diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index f473f89..e44d2be 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -115,8 +115,16 @@ namespace ShiftOS.Engine t.IsBackground = true; t.Start(); + Console.WriteLine(); + ConsoleEx.ForegroundColor = ConsoleColor.Red; + ConsoleEx.Bold = true; Console.WriteLine("NEW OBJECTIVE:"); + Console.WriteLine(); + + ConsoleEx.ForegroundColor = ConsoleColor.White; + ConsoleEx.Bold = false; Console.WriteLine("A new objective has been added to your system. Run sos.status to find out what you need to do."); + TerminalBackend.PrintPrompt(); } -- cgit v1.2.3 From 79fe2101aef62b744b150203dee6953b0d17f5aa Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Jun 2017 20:36:43 -0400 Subject: Get rid of namespaces in commands. --- ModLauncher/Program.cs | 11 - ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb | 1 - ShiftOS.Modding.VirtualMachine/Form1.cs | 1 - .../Applications/CoherenceOverlay.Designer.cs | 61 -- ShiftOS.WinForms/Applications/CoherenceOverlay.cs | 123 ---- ShiftOS.WinForms/Applications/Downloader.cs | 1 - ShiftOS.WinForms/Applications/Pong.cs | 25 +- ShiftOS.WinForms/Commands.cs | 299 --------- ShiftOS.WinForms/HackerCommands.cs | 723 +-------------------- ShiftOS.WinForms/OobeStory.cs | 1 - ShiftOS.WinForms/Servers/RemoteTerminalServer.cs | 1 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 6 - ShiftOS.WinForms/SkinCommands.cs | 1 - ShiftOS.WinForms/TestCommandsForUpgrades.cs | 22 +- ShiftOS.WinForms/TrailerCommands.cs | 48 -- ShiftOS.WinForms/WinformsDesktop.cs | 1 - ShiftOS_TheReturn/Command.cs | 36 - ShiftOS_TheReturn/Commands.cs | 274 +------- ShiftOS_TheReturn/PythonAPI.cs | 1 - ShiftOS_TheReturn/ReflectMan.cs | 1 - ShiftOS_TheReturn/TerminalBackend.cs | 66 +- ShiftOS_TheReturn/UserManagementCommands.cs | 2 - 22 files changed, 66 insertions(+), 1639 deletions(-) delete mode 100644 ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/CoherenceOverlay.cs (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ModLauncher/Program.cs b/ModLauncher/Program.cs index 4b99cf5..4637b4e 100644 --- a/ModLauncher/Program.cs +++ b/ModLauncher/Program.cs @@ -32,7 +32,6 @@ using ShiftOS.Engine; namespace ModLauncher { - [Namespace("modlauncher")] public static class Program { /// @@ -43,15 +42,5 @@ namespace ModLauncher { ShiftOS.WinForms.Program.Main(); } - - [Command("throwcrash")] - public static bool ThrowCrash() - { - new Thread(() => - { - throw new Exception("User triggered crash using modlauncher.throwcrash command."); - }).Start(); - return true; - } } } diff --git a/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb b/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb index 161012d..3a2e106 100644 --- a/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb +++ b/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb @@ -14,7 +14,6 @@ Module Module1 End Module - Public Class SkinConverterCommands diff --git a/ShiftOS.Modding.VirtualMachine/Form1.cs b/ShiftOS.Modding.VirtualMachine/Form1.cs index 5b6b047..1615091 100644 --- a/ShiftOS.Modding.VirtualMachine/Form1.cs +++ b/ShiftOS.Modding.VirtualMachine/Form1.cs @@ -154,7 +154,6 @@ namespace ShiftOS.Modding.VirtualMachine } } - [Namespace("svm")] public static class Compiler { public static byte[] Compile(string prg) diff --git a/ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs b/ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs deleted file mode 100644 index 0764059..0000000 --- a/ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs +++ /dev/null @@ -1,61 +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. - */ - -namespace ShiftOS.WinForms.Applications -{ - partial class CoherenceOverlay - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - } - - #endregion - } -} diff --git a/ShiftOS.WinForms/Applications/CoherenceOverlay.cs b/ShiftOS.WinForms/Applications/CoherenceOverlay.cs deleted file mode 100644 index 1bfc8e8..0000000 --- a/ShiftOS.WinForms/Applications/CoherenceOverlay.cs +++ /dev/null @@ -1,123 +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.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using System.Threading; - -namespace ShiftOS.WinForms.Applications -{ - public partial class CoherenceOverlay : UserControl, IShiftOSWindow - { - public CoherenceOverlay(IntPtr handle, CoherenceCommands.RECT rect) - { - InitializeComponent(); - this.Load += (o, a) => - { - try - { - int left = this.ParentForm.Left; - int top = this.ParentForm.Top; - int oldwidth = this.ParentForm.Width; - int oldheight = this.ParentForm.Height; - - var t = new Thread(new ThreadStart(() => - { - while (CoherenceCommands.GetWindowRect(handle, ref rect)) - { - - if (left != rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth) - { - this.Invoke(new Action(() => - { - this.ParentForm.Left = rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth; - left = rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth; - })); - } - if (top != rect.Top - SkinEngine.LoadedSkin.TitlebarHeight) - { - this.Invoke(new Action(() => - { - - this.ParentForm.Top = rect.Top - SkinEngine.LoadedSkin.TitlebarHeight; - top = rect.Top - SkinEngine.LoadedSkin.TitlebarHeight; - })); - } - int width = (rect.Right - rect.Left) + 1; - int height = (rect.Bottom - rect.Top) + 1; - - if (oldheight != SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth) - { - this.Invoke(new Action(() => - { - this.ParentForm.Height = SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth; - oldheight = SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth; - })); - } - if (oldwidth != SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth) - { - this.Invoke(new Action(() => - { - this.ParentForm.Width = SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth; - oldwidth = SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth; - })); - } - } - })); - t.IsBackground = true; - t.Start(); - } - catch - { - - } - }; - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - } -} diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs index b3d2cea..bcad56a 100644 --- a/ShiftOS.WinForms/Applications/Downloader.cs +++ b/ShiftOS.WinForms/Applications/Downloader.cs @@ -216,7 +216,6 @@ namespace ShiftOS.WinForms.Applications public int Progress { get; set; } } - [Namespace("dev")] public static class DownloaderDebugCommands { [Command("setsubscription", description ="Use to set the current shiftnet subscription.", usage ="{value:int32}")] diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 87b7a93..3f06676 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -42,6 +42,15 @@ namespace ShiftOS.WinForms.Applications LevelComplete(); } }; +#if DEBUG + this.KeyDown += (o, a) => + { + if(a.KeyCode == Keys.D) + { + drawAiBall = !drawAiBall; + } + }; +#endif } private double ballX = 0.0f; @@ -266,11 +275,14 @@ namespace ShiftOS.WinForms.Applications ballX = 0; ballY = 0; opponentY = 0; + xVel = 1; aiBallX = 0; aiBallY = 0; doAi = true; } + private bool drawAiBall = false; + private void pnlcanvas_Paint(object sender, PaintEventArgs e) { @@ -281,11 +293,22 @@ namespace ShiftOS.WinForms.Applications ballXLocal -= ((double)paddleWidth / 2); ballYLocal -= ((double)paddleWidth / 2); + double aiballXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width); + double aiballYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height); + + aiballXLocal -= ((double)paddleWidth / 2); + aiballYLocal -= ((double)paddleWidth / 2); + e.Graphics.Clear(pnlcanvas.BackColor); + //draw the ai ball + if (drawAiBall) + e.Graphics.FillEllipse(new SolidBrush(Color.Gray), new RectangleF((float)aiballXLocal, (float)aiballYLocal, (float)paddleWidth, (float)paddleWidth)); + + //draw the ball - if(doBallCalc) + if (doBallCalc) e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth)); double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); diff --git a/ShiftOS.WinForms/Commands.cs b/ShiftOS.WinForms/Commands.cs index b04ffe7..e69de29 100644 --- a/ShiftOS.WinForms/Commands.cs +++ b/ShiftOS.WinForms/Commands.cs @@ -1,299 +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 ShiftOS.Engine; -using System.IO; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Threading; -using Newtonsoft.Json; - -/// -/// Coherence commands. -/// -namespace ShiftOS.WinForms -{ - [Namespace("trm")] - public static class TerminalExtensions - { - [Command("exit")] - public static bool StopRemoting() - { - if(TerminalBackend.IsForwardingConsoleWrites == true) - { - ServerManager.SendMessage("trm_handshake_stop", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"" -}}"); - Console.WriteLine("Goodbye!"); - } - else - { - return false; - } - - return true; - } - - - [Command("setpass", true)] - [RequiresArgument("pass")] - public static bool setPass(Dictionary args) - { - SaveSystem.CurrentSave.Password = args["pass"] as string; - return true; - } - - [Command("remote", "username:,sysname:,password:", "Allows you to control a remote system on the multi-user domain given a username, password and system name.")] - [RequiresArgument("username")] - [RequiresArgument("sysname")] - [RequiresArgument("password")] - public static bool RemoteControl(Dictionary args) - { - ServerManager.SendMessage("trm_handshake_request", JsonConvert.SerializeObject(args)); - return true; - } - } - - [Namespace("coherence")] - [RequiresUpgrade("kernel_coherence")] - public static class CoherenceCommands - { - /// - /// Sets the window position. - /// - /// The window position. - /// H window. - /// H window insert after. - /// X. - /// Y. - /// Cx. - /// Cy. - /// U flags. - [DllImport("user32.dll")] - static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); - - /// - /// The HWN d TOPMOS. - /// - static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); - - /// - /// The SW p SHOWWINDO. - /// - const UInt32 SWP_SHOWWINDOW = 0x0040; - - - [DllImport("user32.dll")] - /// - /// Gets the window rect. - /// - /// The window rect. - /// H window. - /// Lp rect. - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); - - /// - /// REC. - /// - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int Left; // x position of upper-left corner - public int Top; // y position of upper-left corner - public int Right; // x position of lower-right corner - public int Bottom; // y position of lower-right corner - } - - [Command("launch", "process: \"C:\\path\\to\\process\" - The process path to launch.", "Launch a process inside kernel coherence.")] - [RequiresArgument("process")] - /// - /// Launchs the app. - /// - /// The app. - /// Arguments. - public static bool LaunchApp(Dictionary args) - { - string process = args["process"].ToString(); - var prc = Process.Start(process); - StartCoherence(prc); - return true; - } - - /// - /// Starts the coherence. - /// - /// The coherence. - /// Prc. - private static void StartCoherence(Process prc) - { - RECT rct = new RECT(); - - - while (!GetWindowRect(prc.MainWindowHandle, ref rct)) - { - } - - - - AppearanceManager.Invoke(new Action(() => - { - IShiftOSWindow coherenceWindow = new Applications.CoherenceOverlay(prc.MainWindowHandle, rct); - - AppearanceManager.SetupWindow(coherenceWindow); - SetWindowPos(prc.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - - //MakeExternalWindowBorderless(prc.MainWindowHandle); - })); - - } - - /// - /// The W s BORDE. - /// - const int WS_BORDER = 8388608; - - /// - /// The W s DLGFRAM. - /// - const int WS_DLGFRAME = 4194304; - - /// - /// The W s CAPTIO. - /// - const int WS_CAPTION = WS_BORDER | WS_DLGFRAME; - - /// - /// The W s SYSMEN. - /// - const int WS_SYSMENU = 524288; - - /// - /// The W s THICKFRAM. - /// - const int WS_THICKFRAME = 262144; - - /// - /// The W s MINIMIZ. - /// - const int WS_MINIMIZE = 536870912; - - /// - /// The W s MAXIMIZEBO. - /// - const int WS_MAXIMIZEBOX = 65536; - - /// - /// The GW l STYL. - /// - const int GWL_STYLE = -16; - - /// - /// The GW l EXSTYL. - /// - const int GWL_EXSTYLE = -20; - - /// - /// The W s E x DLGMODALFRAM. - /// - const int WS_EX_DLGMODALFRAME = 0x1; - - /// - /// The SW p NOMOV. - /// - const int SWP_NOMOVE = 0x2; - - /// - /// The SW p NOSIZ. - /// - const int SWP_NOSIZE = 0x1; - - /// - /// The SW p FRAMECHANGE. - /// - const int SWP_FRAMECHANGED = 0x20; - - /// - /// The M f BYPOSITIO. - /// - const uint MF_BYPOSITION = 0x400; - - /// - /// The M f REMOV. - /// - const uint MF_REMOVE = 0x1000; - - /// - /// Gets the window long. - /// - /// The window long. - /// H window. - /// N index. - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - public static extern int GetWindowLong(IntPtr hWnd, int nIndex); - - /// - /// Sets the window long. - /// - /// The window long. - /// H window. - /// N index. - /// Dw new long. - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); - - /// - /// Sets the window position. - /// - /// The window position. - /// H window. - /// H window insert after. - /// X. - /// Y. - /// Cx. - /// Cy. - /// U flags. - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); - public static void MakeExternalWindowBorderless(IntPtr MainWindowHandle) - { - int Style = 0; - Style = GetWindowLong(MainWindowHandle, GWL_STYLE); - Style = Style & ~WS_CAPTION; - Style = Style & ~WS_SYSMENU; - Style = Style & ~WS_THICKFRAME; - Style = Style & ~WS_MINIMIZE; - Style = Style & ~WS_MAXIMIZEBOX; - SetWindowLong(MainWindowHandle, GWL_STYLE, Style); - Style = GetWindowLong(MainWindowHandle, GWL_EXSTYLE); - SetWindowLong(MainWindowHandle, GWL_EXSTYLE, Style | WS_EX_DLGMODALFRAME); - SetWindowPos(MainWindowHandle, new IntPtr(0), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } - } -} diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index dd8bde8..5f28270 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -1,722 +1 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.Objects.ShiftFS; -using ShiftOS.WinForms.Applications; -using static ShiftOS.Objects.ShiftFS.Utils; - -namespace ShiftOS.WinForms -{ - [Namespace("puppy")] - [RequiresUpgrade("hacker101_deadaccts")] - [KernelMode] - public static class KernelPuppyCommands - { - [Command("clear", true)] - public static bool ClearLogs() - { - WriteAllText("0:/system/data/kernel.log", ""); - Console.WriteLine(" logs cleared successfully."); - return true; - } - } - - [Namespace("krnl")] - public static class KernelCommands - { - [Command("control", true)] - [RequiresArgument("pass")] - public static bool Control(Dictionary args) - { - if(args["pass"].ToString() == ServerManager.thisGuid.ToString()) - { - KernelWatchdog.Log("warn", "User has breached the kernel."); - KernelWatchdog.EnterKernelMode(); - TerminalBackend.PrintPrompt(); - } - return true; - } - - [Command("lock_session")] - [KernelMode] - public static bool LeaveControl() - { - KernelWatchdog.Log("inf", "User has left the kernel-mode session."); - KernelWatchdog.LeaveKernelMode(); - KernelWatchdog.MudConnected = true; - return true; - } - } - - [Namespace("hacker101")] - [RequiresUpgrade("hacker101_deadaccts")] - public static class HackerCommands - { - private static void writeSlow(string text) - { - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - ConsoleEx.Bold = false; - ConsoleEx.Italic = false; - Console.Write("["); - ConsoleEx.ForegroundColor = ConsoleColor.Magenta; - ConsoleEx.Bold = true; - Console.Write("hacker101"); - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - ConsoleEx.Italic = true; - Console.Write("@"); - ConsoleEx.ForegroundColor = ConsoleColor.White; - Console.Write("undisclosed"); - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - ConsoleEx.Bold = false; - ConsoleEx.Italic = false; - Console.Write("]: "); - Thread.Sleep(850); - Console.WriteLine(text); - Thread.Sleep(4000); - } - - [Story("hacker101_deadaccts")] - public static void DeadAccountsStory() - { - if (!terminalIsOpen()) - { - AppearanceManager.SetupWindow(new Terminal()); - } - - var t = new Thread(() => - { - Console.WriteLine("[sys@mud]: Warning: User connecting to system..."); - Thread.Sleep(75); - Console.WriteLine("[sys@mud]: UBROADCAST: Username: hacker101 - Sysname: undisclosed"); - Thread.Sleep(50); - Console.Write("--locking mud connection resources..."); - Thread.Sleep(50); - Console.WriteLine("...done."); - Console.Write("--locking user input... "); - Thread.Sleep(75); - TerminalBackend.PrefixEnabled = false; - TerminalBackend.InStory = true; - Console.WriteLine("...done."); - - Thread.Sleep(2000); - writeSlow($"Hello there, fellow multi-user domain user."); - writeSlow("My name, as you can tell, is hacker101."); - writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentUser.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?"); - writeSlow("Of course it is."); - writeSlow("And I bet you 10,000 Codepoints that you have... " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints."); - writeSlow("Oh, and how much upgrades have you installed since you first started using ShiftOS?"); - writeSlow("That would be... uhh... " + SaveSystem.CurrentSave.CountUpgrades().ToString() + "."); - writeSlow("I'm probably freaking you out right now. You are probably thinking that you're unsafe and need to lock yourself down."); - writeSlow("But, don't worry, I mean no harm."); - writeSlow("In fact, I am a multi-user domain safety activist and security professional."); - writeSlow("I need your help with something."); - writeSlow("Inside the multi-user domain, every now and then these 'dead' user accounts pop up."); - writeSlow("They're infesting everything. They're in every legion, they infest chatrooms, and they take up precious hard drive space."); - writeSlow("Eventually there's going to be tons of them just sitting there taking over the MUD. We can't have that."); - writeSlow("It sounds like a conspiracy theory indeed, but it's true, in fact, these dead accounts hold some valuable treasures."); - writeSlow("I'm talking Codepoints, skins, documents, the possibilities are endless."); - writeSlow("I'm going to execute a quick sys-script that will show you how you can help get rid of these accounts, and also gain some valuable resources to help you on your digital frontier."); - writeSlow("This script will also show you the fundamentals of security exploitation and theft of resources - which if you want to survive in the multi-user domain is paramount."); - writeSlow("Good luck."); - Thread.Sleep(1000); - Console.WriteLine("--user disconnected"); - Thread.Sleep(75); - Console.WriteLine("--commands unlocked - check sos.help."); - Thread.Sleep(45); - SaveSystem.SaveGame(); - Console.Write("--unlocking user input..."); - Thread.Sleep(75); - Console.Write(" ..done"); - TerminalBackend.InStory = false; - TerminalBackend.PrefixEnabled = true; - Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - StartHackerTutorial(); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - }); - t.IsBackground = true; - t.Start(); - TerminalBackend.PrefixEnabled = false; - } - - internal static void StartHackerTutorial() - { - Desktop.InvokeOnWorkerThread(() => - { - var tut = new TutorialBox(); - AppearanceManager.SetupWindow(tut); - - new Thread(() => - { - - - int tutPos = 0; - Action ondec = () => - { - tutPos++; - }; - TerminalBackend.CommandProcessed += (o, a) => - { - switch (tutPos) - { - - case 0: - case 10: - if (o.ToLower().StartsWith("mud.disconnect")) - { - tutPos++; - } - break; - case 11: - if (o.ToLower().StartsWith("krnl.lock_session")) - tutPos++; - break; - case 1: - if (o.ToLower().StartsWith("hacker101.brute_decrypt")) - { - if (a.Contains("0:/system/data/kernel.log")) - { - tutPos++; - } - } - break; - case 3: - if (o.ToLower().StartsWith("krnl.control")) - { - tutPos++; - } - break; - case 4: - if (o.ToLower().StartsWith("puppy.clear")) - tutPos++; - break; - case 5: - if (o.ToLower().StartsWith("mud.reconnect")) - tutPos++; - break; - case 6: - if (o.ToLower().StartsWith("mud.sendmsg")) - { - var msg = JsonConvert.DeserializeObject(a); - try - { - if (msg.header == "getusers" && msg.body == "dead") - tutPos++; - } - catch - { - - } - } - break; - case 7: - if (o.ToLower().StartsWith("hacker101.breach_user_password")) - tutPos++; - break; - case 8: - if (o.ToLower().StartsWith("hacker101.print_user_info")) - tutPos++; - break; - case 9: - if (o.ToLower().StartsWith("hacker101.steal_codepoints")) - tutPos++; - break; - } - }; - tut.SetObjective("Welcome to the dead account exploitation tutorial. In this tutorial you will learn the basics of hacking within the multi-user domain."); - Thread.Sleep(1000); - tut.SetObjective("We will start with a simple system exploit - gaining kernel-level access to ShiftOS. This can help you perform actions not ever possible in the user level."); - Thread.Sleep(1000); - tut.SetObjective("To gain root access, you will first need to breach the system watchdog to keep it from dialing home to DevX."); - Thread.Sleep(1000); - tut.SetObjective("The watchdog can only function when it has a successful connection to the multi-user domain. You will need to use the MUD Control Centre to disconnect yourself from the MUD. This will lock you out of most features. To disconnect from the multi-user domain, simply run the 'mud.disconnect' command."); - while(tutPos == 0) - { - - } - tut.SetObjective("As you can see, the kernel watchdog has shut down temporarily, however before the disconnect it was able to tell DevX that it has gone offline."); - Thread.Sleep(1000); - tut.SetObjective("You'll also notice that commands like the shiftorium, MUD control centre and various applications that utilize these system components no longer function."); - Thread.Sleep(1000); - tut.SetObjective("The watchdog, however, is still watching. DevX was smart and programmed the kernel to log all events to a local file in 0:/system/data/kernel.log."); - Thread.Sleep(1000); - tut.SetObjective("You will need to empty out this file before you can connect to the multi-user domain, as the watchdog will send the contents of this file straight to DevX."); - Thread.Sleep(1000); - tut.SetObjective("Or, you can do what we're about to do and attempt to decrypt the log and sniff out the kernel-mode access password."); - Thread.Sleep(1000); - tut.SetObjective("This will allow us to gain kernel-level access to our system using the krnl.control{pass:} command."); - Thread.Sleep(1000); - tut.SetObjective("Let's start decrypting the log file using the hacker101.brute_decrypt{file:} script. The file: argument is a string and should point to a .log file. When the script succeeds, you will see a TextPad open with the decrypted contents."); - while(tutPos == 1) - { - - } - onCompleteDecrypt += ondec; - tut.SetObjective("This script isn't the most agile script ever, but it'll get the job done."); - tutPos = 3; // For some reason, it refuses to go to part 3. - while(tutPos == 2) - { - - } - onCompleteDecrypt -= ondec; - tut.SetObjective("Alright - it's done. Here's how it's laid out. In each log entry, you have the timestamp, then the event name, then the event description."); - Thread.Sleep(1000); - tut.SetObjective("Look for the most recent 'mudhandshake' event. This contains the kernel access code."); - Thread.Sleep(1000); - tut.SetObjective("Once you have it, run 'krnl.control{pass:\"the-kernel-code-here\"}. This will allow you to gain access to the kernel."); - while(tutPos == 3) - { - - } - tut.SetObjective("You are now in kernel mode. Every command you enter will run on the kernel. Now, let's clear the watchdog's logfile and reconnect to the multi-user domain."); - Thread.Sleep(1000); - tut.SetObjective("To clear the log, simply run 'puppy.clear'."); - while(tutPos == 4) - { - - } - tut.SetObjective("Who's a good dog... You are, ShiftOS. Now, we can connect back to the MUD using 'mud.reconnect'."); - Thread.Sleep(1000); - while(tutPos == 5) - { - - } - tut.SetObjective("We have now snuck by the watchdog and DevX has no idea. With kernel-level access, everything you do is not logged, however if you perform too much in one shot, you'll get kicked off and locked out of the multi-user domain temporarily."); - Thread.Sleep(1000); - tut.SetObjective("So, let's focus on the job. You want to get into one of those fancy dead accounts, don't ya? Well, first, we need to talk with the MUD to get a list of these accounts."); - Thread.Sleep(1000); - tut.SetObjective("Simply run the `mud.sendmsg` command, specifying a 'header' of \"getusers\", and a body of \"dead\"."); - while(tutPos == 6) - { - - } - tut.SetObjective("Great. We now have the usernames and sysnames of all dead accounts on the MUD. Now let's use the hacker101.breach_user_password{user:,sys:} command to breach one of these accounts' passwords."); - while(tutPos == 7) - { - - } - tut.SetObjective("There - you now have access to that account. Use its password, username and sysname and run the hacker101.print_user_info{user:,pass:,sys:} command to print the entirety of this user's information."); - while(tutPos == 8) - { - - } - tut.SetObjective("Now you can see a list of the user's Codepoints among other things. Now you can steal their codepoints by using the hacker101.steal_codepoints{user:,pass:,sys;,amount:} command. Be careful. This may alert DevX."); - while(tutPos == 9) - { - - } - if(devx_alerted == true) - { - tut.SetObjective("Alright... enough fun and games. DevX just found out we were doing this."); - Thread.Sleep(500); - tut.SetObjective("Quick! Disconnect from the MUD!!"); - while(tutPos == 10) - { - - } - tut.SetObjective("Now, get out of kernel mode! To do that, run krnl.lock_session."); - while(tutPos == 11) - { - - } - - } - else - { - tut.SetObjective("OK, that was risky, but we pulled it off. Treat yourself! But first, let's get you out of kernel mode."); - Thread.Sleep(500); - tut.SetObjective("First we need to get you off the MUD. Simply run mud.disconnect again."); - while (tutPos == 10) - { - - } - tut.SetObjective("Now, let's run krnl.lock_session. This will lock you back into the user mode, and reconnect you to the MUD."); - while (tutPos == 11) - { - - } - tut.SetObjective("If, for some reason, DevX DOES find out, you have to be QUICK to get off of kernel mode. You don't want to make him mad."); - } - - Thread.Sleep(1000); - tut.SetObjective("So that's all for now. Whenever you're in kernel mode again, and you have access to a user account, try breaching their filesystem next time. You can use sos.help{ns:} to show commands from a specific namespace to help you find more commands easily."); - Thread.Sleep(1000); - tut.SetObjective("You can now close this window."); - tut.IsComplete = true; - - }).Start(); - }); - } - - private static bool devx_alerted = false; - - private static event Action onCompleteDecrypt; - - private static bool terminalIsOpen() - { - foreach(var win in AppearanceManager.OpenForms) - { - if (win.ParentWindow is Terminal) - return true; - } - return false; - } - - const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_"; - - [MultiplayerOnly] - [Command("breach_user_password")] - [KernelMode] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool BreachUserPassword(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking system thread..."); - - msgReceived = (msg) => - { - if(msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - var rnd = new Random(); - var sw = new Stopwatch(); - sw.Start(); - Thread.Sleep(2000); - if(rnd.Next(0, 100) >= 75) - { - Console.WriteLine("--operation took too long - failed."); - ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrefixEnabled = true; - return; - } - sw.Stop(); - Console.WriteLine(sve.Password); - Console.WriteLine(); - Console.WriteLine("--password breached. Operation took " + sw.ElapsedMilliseconds + " milliseconds."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - else if(msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "..."); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - TerminalBackend.PrefixEnabled = false; - Thread.Sleep(500); - return true; - } - - - [MultiplayerOnly] - [Command("print_user_info")] - [KernelMode] - [RequiresArgument("pass")] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool PrintUserInfo(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - string pass = args["pass"].ToString(); - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking multi-user domain response call..."); - - msgReceived = (msg) => - { - if (msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - if(sve.Password == pass) - { - Console.WriteLine("Username: " + SaveSystem.CurrentUser.Username); - Console.WriteLine("Password: " + sve.Password); - Console.WriteLine("System name: " + sve.SystemName); - Console.WriteLine(); - Console.WriteLine("Codepoints: " + sve.Codepoints.ToString()); - - } - else - { - Console.WriteLine("--access denied."); - } - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - - } - else if (msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--contacting multi-user domain..."); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - Thread.Sleep(500); - TerminalBackend.PrefixEnabled = false; - return true; - } - - [MultiplayerOnly] - [Command("steal_codepoints")] - [KernelMode] - [RequiresArgument("amount")] - [RequiresArgument("pass")] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool StealCodepoints(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - string pass = args["pass"].ToString(); - ulong amount = (ulong)args["amount"]; - if(amount < 0) - { - Console.WriteLine("--invalid codepoint amount - halting..."); - return true; - } - - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking multi-user domain response call..."); - - msgReceived = (msg) => - { - if (msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - if (sve.Password == pass) - { - if(amount > sve.Codepoints) - { - Console.WriteLine("--can't steal this many codepoints from user."); - ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); - TerminalBackend.PrefixEnabled = true; - return; - } - - sve.Codepoints -= amount; - SaveSystem.TransferCodepointsFrom(SaveSystem.CurrentUser.Username, amount); - ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); - SaveSystem.SaveGame(); - } - else - { - Console.WriteLine("--access denied."); - } - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - else if (msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--contacting multi-user domain..."); - Thread.Sleep(500); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - Thread.Sleep(500); - TerminalBackend.PrefixEnabled = false; - return true; - } - - [MultiplayerOnly] - [Command("purge_user")] - [KernelMode] - [RequiresArgument("pass")] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool PurgeUser(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - string pass = args["pass"].ToString(); - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking multi-user domain response call..."); - - msgReceived = (msg) => - { - if (msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - if (sve.Password == pass) - { - ServerManager.SendMessage("delete_dead_save", JsonConvert.SerializeObject(sve)); - Console.WriteLine(" User purged successfully."); - } - else - { - Console.WriteLine("--access denied."); - } - ServerManager.MessageReceived -= msgReceived; - } - else if (msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - } - TerminalBackend.PrintPrompt(); - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--contacting multi-user domain..."); - Thread.Sleep(500); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - Thread.Sleep(500); - TerminalBackend.PrefixEnabled = false; - return true; - } - - - [Command("brute_decrypt", true)] - [RequiresArgument("file")] - public static bool BruteDecrypt(Dictionary args) - { - if (FileExists(args["file"].ToString())) - { - string pass = new Random().Next(1000, 10000).ToString(); - string fake = ""; - Console.WriteLine("Beginning brute-force attack on password."); - var s = new Stopwatch(); - s.Start(); - for(int i = 0; i < pass.Length; i++) - { - for(int num = 0; num < 10; num++) - { - if(pass[i].ToString() == num.ToString()) - { - fake += num.ToString(); - Console.Write(num); - } - } - } - s.Stop(); - - Console.WriteLine("...password cracked - operation took " + s.ElapsedMilliseconds + " milliseconds."); - var tp = new TextPad(); - AppearanceManager.SetupWindow(tp); - WriteAllText("0:/temp.txt", ReadAllText(args["file"].ToString())); - tp.LoadFile("0:/temp.txt"); - Delete("0:/temp.txt"); - onCompleteDecrypt?.Invoke(); - } - else - { - Console.WriteLine("brute_decrypt: file not found"); - } - return true; - } - } - - [MultiplayerOnly] - [Namespace("storydev")] - public static class StoryDevCommands - { - [Command("start", description = "Starts a story plot.", usage ="id:string")] - [RequiresArgument("id")] - [RemoteLock] - public static bool StartStory(Dictionary args) - { - Story.Start(args["id"].ToString()); - return true; - } - - [Command("list", description ="Lists all story IDs.")] - public static bool ListIds() - { - foreach(var type in ReflectMan.Types) - foreach(var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - var attr = method.GetCustomAttributes(false).FirstOrDefault(x => x is StoryAttribute); - if (attr != null) - Console.WriteLine(" - " + (attr as StoryAttribute).StoryID); - } - return true; - } - - [Command("unexperience", description = "Marks a story plot as not-experienced yet.", usage ="id:string")] - [RemoteLock] - [RequiresArgument("id")] - public static bool Unexperience(Dictionary args) - { - string id = args["id"].ToString(); - if (SaveSystem.CurrentSave.StoriesExperienced.Contains(id)) - { - Console.WriteLine("Unexperiencing " + id + "."); - SaveSystem.CurrentSave.StoriesExperienced.Remove(id); - SaveSystem.SaveGame(); - } - else - { - Console.WriteLine("Story ID not found."); - } - - return true; - } - - [Command("experience", description = "Marks a story plot as experienced without triggering the plot.", usage ="{id:}")] - [RequiresArgument("id")] - [RemoteLock] - public static bool Experience(Dictionary args) - { - SaveSystem.CurrentSave.StoriesExperienced.Add(args["id"].ToString()); - SaveSystem.SaveGame(); - return true; - } - } -} + \ No newline at end of file diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index cab1ec8..0d9b817 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -13,7 +13,6 @@ using ShiftOS.Objects; namespace ShiftOS.WinForms { - [Namespace("test")] public class OobeStory { [Command("test")] diff --git a/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs index d57e28f..849049f 100644 --- a/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs +++ b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs @@ -10,7 +10,6 @@ using ShiftOS.Objects; namespace ShiftOS.WinForms.Servers { - [Namespace("rts")] [Server("Remote Terminal Server", 21)] //[RequiresUpgrade("story_hacker101_breakingthebonds")] //Uncomment when story is implemented. public class RemoteTerminalServer : Server diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9e16b19..00b4d83 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -131,12 +131,6 @@ Chat.cs - - UserControl - - - CoherenceOverlay.cs - UserControl diff --git a/ShiftOS.WinForms/SkinCommands.cs b/ShiftOS.WinForms/SkinCommands.cs index 1f32d96..f35c449 100644 --- a/ShiftOS.WinForms/SkinCommands.cs +++ b/ShiftOS.WinForms/SkinCommands.cs @@ -9,7 +9,6 @@ using ShiftOS.Objects.ShiftFS; namespace ShiftOS.WinForms { - [Namespace("skins")] public static class SkinCommands { [Command("reset")] diff --git a/ShiftOS.WinForms/TestCommandsForUpgrades.cs b/ShiftOS.WinForms/TestCommandsForUpgrades.cs index 739a2a2..5f28270 100644 --- a/ShiftOS.WinForms/TestCommandsForUpgrades.cs +++ b/ShiftOS.WinForms/TestCommandsForUpgrades.cs @@ -1,21 +1 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - [Namespace("test")] - public static class TestCommandsForUpgrades - { - [Command("simpletest")] - public static bool Simple() - { - return true; - } - } - - -} + \ No newline at end of file diff --git a/ShiftOS.WinForms/TrailerCommands.cs b/ShiftOS.WinForms/TrailerCommands.cs index 182d03d..e69de29 100644 --- a/ShiftOS.WinForms/TrailerCommands.cs +++ b/ShiftOS.WinForms/TrailerCommands.cs @@ -1,48 +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. - */ - -#define TRAILER -#if TRAILER -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - [Namespace("trailer")] - public static class TrailerCommands - { - [Command("init")] - public static bool TrailerInit() - { - var oobe = new Oobe(); - oobe.StartTrailer(); - return true; - } - } -} -#endif \ No newline at end of file diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index f6c4383..82d99f0 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -47,7 +47,6 @@ namespace ShiftOS.WinForms /// /// Winforms desktop. /// - [Namespace("desktop")] public partial class WinformsDesktop : Form, IDesktop { public MainMenu.MainMenu ParentMenu = null; diff --git a/ShiftOS_TheReturn/Command.cs b/ShiftOS_TheReturn/Command.cs index 09cf206..b90f604 100644 --- a/ShiftOS_TheReturn/Command.cs +++ b/ShiftOS_TheReturn/Command.cs @@ -135,42 +135,6 @@ namespace ShiftOS.Engine } } - /// - /// Denotes a Terminal command namespace. - /// - public class Namespace : Attribute - { - /// - /// The namespace's name. - /// - public string name; - /// - /// Whether the namespace should be hidden from the help system. Overrides all child s' hide values. - /// - public bool hide; - - /// - /// Creates a new instance of the . - /// - /// The name of the namespace. - public Namespace(string n) - { - name = n; - } - - - /// - /// Creates a new instance of the . - /// - /// The name of the namespace. - /// Whether this namespace should be hidden from the user. - public Namespace(string n, bool hide) - { - name = n; - this.hide = hide; - } - } - /// /// Marks a Terminal command as obsolete. /// diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 6f3ab15..9221bba 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -44,7 +44,6 @@ using ShiftOS.Objects.ShiftFS; namespace ShiftOS.Engine { - [Namespace("infobox", hide = true)] [RequiresUpgrade("desktop;wm_free_placement")] public static class InfoboxDebugCommands { @@ -107,7 +106,6 @@ namespace ShiftOS.Engine } - [Namespace("audio")] public static class AudioCommands { [Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")] @@ -129,79 +127,7 @@ namespace ShiftOS.Engine } } - [RequiresUpgrade("mud_fundamentals")] - [Namespace("mud")] - public static class MUDCommands - { - [MultiplayerOnly] - [Command("status")] - public static bool Status() - { - ServerManager.PrintDiagnostics(); - return true; - } - - [Command("connect")] - public static bool Connect(Dictionary args) - { - try - { - string ip = (args.ContainsKey("addr") == true) ? args["addr"] as string : "michaeltheshifter.me"; - int port = (args.ContainsKey("port") == true) ? Convert.ToInt32(args["port"] as string) : 13370; - try - { - ServerManager.Initiate(ip, port); - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - } - - TerminalBackend.PrefixEnabled = false; - return true; - } - catch (Exception ex) - { - Console.WriteLine("Error running script:" + ex); - return false; - } - } - - [Command("reconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Reconnect() - { - Console.WriteLine("--reconnecting to multi-user domain..."); - KernelWatchdog.MudConnected = true; - Console.WriteLine("--done."); - return true; - } - - [MultiplayerOnly] - [Command("disconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Disconnect() - { - Console.WriteLine("--connection to multi-user domain severed..."); - KernelWatchdog.MudConnected = false; - return true; - } - - [MultiplayerOnly] - [Command("sendmsg")] - [KernelMode] - [RequiresUpgrade("hacker101_deadaccts")] - [RequiresArgument("header")] - [RequiresArgument("body")] - public static bool SendMessage(Dictionary args) - { - ServerManager.SendMessage(args["header"].ToString(), args["body"].ToString()); - return true; - } - } - [TutorialLock] - [Namespace("trm")] public static class TerminalCommands { [Command("clear")] @@ -220,167 +146,6 @@ namespace ShiftOS.Engine } } -#if DEVEL - internal class Rock : Exception - { - internal Rock() : base("Someone threw a rock at the window, and the Terminal shattered.") - { - - } - } - - [MultiplayerOnly] - [Namespace("dev")] - public static class ShiftOSDevCommands - { - [Command("buy")] - public static bool UnlockUpgrade(Dictionary args) - { - string upg = args["id"].ToString(); - try - { - SaveSystem.CurrentSave.Upgrades[upg] = true; - Shiftorium.InvokeUpgradeInstalled(); - SaveSystem.SaveGame(); - } - catch - { - Console.WriteLine("Upgrade not found."); - } - return true; - } - - [Command("rock", description = "A little surprise for unstable builds...")] - public static bool ThrowASandwichingRock() - { - Infobox.Show("He who lives in a glass house shouldn't throw stones...", new Rock().Message); - return false; - } - - - [Command("unbuy")] - [RequiresArgument("upgrade")] - public static bool UnbuyUpgrade(Dictionary args) - { - try - { - SaveSystem.CurrentSave.Upgrades[args["upgrade"].ToString()] = false; - SaveSystem.SaveGame(); - Desktop.PopulateAppLauncher(); - Desktop.CurrentDesktop.SetupDesktop(); - } - catch - { - Console.WriteLine("Upgrade not found."); - } - return true; - } - - [Command("getallupgrades")] - public static bool GetAllUpgrades() - { - Console.WriteLine(JsonConvert.SerializeObject(SaveSystem.CurrentSave.Upgrades, Formatting.Indented)); - return true; - } - - [Command("multarg")] - [RequiresArgument("id")] - [RequiresArgument("name")] - [RequiresArgument("type")] - public static bool MultArg(Dictionary args) - { - Console.WriteLine("Success! "+args.ToString()); - return true; - } - - [Command("restart")] - public static bool Restart() - { - SaveSystem.CurrentSave.Upgrades = new Dictionary(); - SaveSystem.CurrentSave.Codepoints = 0; - SaveSystem.CurrentSave.StoriesExperienced.Clear(); - SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals"); - SaveSystem.SaveGame(); - Shiftorium.InvokeUpgradeInstalled(); - return true; - } - - [Command("freecp")] - public static bool FreeCodepoints(Dictionary args) - { - if (args.ContainsKey("amount")) - try - { - ulong codepointsToAdd = Convert.ToUInt64(args["amount"].ToString()); - SaveSystem.CurrentSave.Codepoints += codepointsToAdd; - return true; - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - return true; - } - - SaveSystem.CurrentSave.Codepoints += 1000; - return true; - } - - [Command("unlockeverything")] - public static bool UnlockAllUpgrades() - { - foreach (var upg in Shiftorium.GetDefaults()) - { - if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.ID)) - SaveSystem.CurrentSave.Upgrades.Add(upg.ID, true); - else - SaveSystem.CurrentSave.Upgrades[upg.ID] = true; - } - Shiftorium.InvokeUpgradeInstalled(); - SkinEngine.LoadSkin(); - return true; - } - - [Command("info")] - public static bool DevInformation() - { - Console.WriteLine("{SHIFTOS_PLUS_MOTTO}"); - Console.WriteLine("{SHIFTOS_VERSION_INFO}" + Assembly.GetExecutingAssembly().GetName().Version); - return true; - } - [Command("pullfile")] - public static bool PullFile(Dictionary args) - { - if (args.ContainsKey("physical") && args.ContainsKey("virtual")) - { - string file = (string)args["physical"]; - string dest = (string)args["virtual"]; - if (System.IO.File.Exists(file)) - { - Console.WriteLine("Pulling physical file to virtual drive..."); - byte[] filebytes = System.IO.File.ReadAllBytes(file); - ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(dest, filebytes); - } - else - { - Console.WriteLine("The specified file does not exist on the physical drive."); - } - } - else - { - Console.WriteLine("You must supply a physical path."); - } - return true; - } - [Command("crash")] - public static bool CrashInstantly() - { - CrashHandler.Start(new Exception("ShiftOS was sent a command to forcefully crash.")); - return true; - } - } -#endif - - [Namespace("sos")] public static class ShiftOSCommands { @@ -478,38 +243,17 @@ namespace ShiftOS.Engine } [Command("help", "{COMMAND_HELP_USAGE", "{COMMAND_HELP_DESCRIPTION}")] - public static bool Help(Dictionary args) + public static bool Help() { var sb = new StringBuilder(); sb.AppendLine("Retrieving help data."); - - if (args.ContainsKey("ns")) + //print all unique namespaces. + foreach (var n in TerminalBackend.Commands.Select(x => x.CommandInfo).Distinct().OrderBy(x=>x.name)) { - string ns = args["ns"].ToString(); - //First let's check for a command that has this namespace. - var cmdtest = TerminalBackend.Commands.FirstOrDefault(x => x.NamespaceInfo.name == ns); - if (cmdtest == null) //Namespace not found. - sb.AppendLine("Error retrieving help for namespace \"" + ns + "\". Namespace not found."); - else - { - //Now do the actual scan. - sb.AppendLine("Namespace: " + ns); - foreach(var cmd in TerminalBackend.Commands.Where(x => x.NamespaceInfo.name == ns)) - { - string str = cmd.ToString(); - str = str.Replace(str.Substring(str.LastIndexOf("|")), ""); - sb.AppendLine(str); - } - } - } - else - { - - //print all unique namespaces. - foreach(var n in TerminalBackend.Commands.Select(x => x.NamespaceInfo.name).Distinct()) - { - sb.AppendLine("sos.help{ns:\"" + n + "\"}"); - } + sb.Append(n.name); + if (Shiftorium.UpgradeInstalled("help_descriptions")) + sb.Append(" - " + n.description); + sb.AppendLine(); } Console.WriteLine(sb.ToString()); @@ -565,7 +309,6 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, } [MultiplayerOnly] - [Namespace("shiftorium")] public static class ShiftoriumCommands { [Command("buy")] @@ -668,7 +411,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); return true; } - [Command("list")] + [Command("shiftorium", description ="Lists all available Shiftorium upgrades.")] public static bool ListAll(Dictionary args) { try @@ -742,7 +485,6 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); } } - [Namespace("win")] public static class WindowCommands { diff --git a/ShiftOS_TheReturn/PythonAPI.cs b/ShiftOS_TheReturn/PythonAPI.cs index cc3798c..7db4c45 100644 --- a/ShiftOS_TheReturn/PythonAPI.cs +++ b/ShiftOS_TheReturn/PythonAPI.cs @@ -291,7 +291,6 @@ namespace ShiftOS.Engine } #if DEBUG - [Namespace("dev")] public static class PythonCmds { [Command("runpystring", description = "Run some Python code. (Only present in DEBUG builds of ShiftOS)")] diff --git a/ShiftOS_TheReturn/ReflectMan.cs b/ShiftOS_TheReturn/ReflectMan.cs index 78f6bf3..d194754 100644 --- a/ShiftOS_TheReturn/ReflectMan.cs +++ b/ShiftOS_TheReturn/ReflectMan.cs @@ -104,7 +104,6 @@ namespace ShiftOS.Engine } #if DEBUG - [Namespace("dev")] public static class ReflectDebug { [Command("listalltypes", description = "List all types that were found by ReflectMan. Only present in DEBUG builds of ShiftOS.")] diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 81ea971..4594eb3 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -148,7 +148,6 @@ namespace ShiftOS.Engine return hash; } - public Namespace NamespaceInfo { get; set; } public Command CommandInfo { get; set; } public List RequiredArguments { get; set; } @@ -161,16 +160,14 @@ namespace ShiftOS.Engine public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append(this.NamespaceInfo.name); - sb.Append("."); sb.Append(this.CommandInfo.name); if (this.RequiredArguments.Count > 0) { - sb.Append("{"); + sb.Append(" "); foreach (var arg in RequiredArguments) { - sb.Append(arg); - sb.Append(":"); + sb.Append("--" + arg); + sb.Append(" "); if (RequiredArguments.IndexOf(arg) < RequiredArguments.Count - 1) sb.Append(','); } @@ -295,41 +292,42 @@ namespace ShiftOS.Engine public static void PopulateTerminalCommands() { Commands = new List(); - foreach(var type in ReflectMan.Types) + foreach (var type in ReflectMan.Types) { - var ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; - if(ns != null) + foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); + if (cmd != null) { - var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); - if(cmd != null) - { - var tc = new TerminalCommand(); - tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + var tc = new TerminalCommand(); + tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); - tc.NamespaceInfo = ns; - tc.CommandInfo = cmd as Command; - tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); - tc.RequiredArguments = new List(); - foreach (var arg in mth.GetCustomAttributes(false).Where(x=>x is RequiresArgument)) - { - var rarg = arg as RequiresArgument; - tc.RequiredArguments.Add(rarg.argument); - } - var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; - if (rupg != null) - tc.Dependencies = rupg.Upgrade; - else - tc.Dependencies = ""; - tc.CommandType = type; - tc.CommandHandler = mth; - if (!Commands.Contains(tc)) - Commands.Add(tc); + tc.CommandInfo = cmd as Command; + tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + tc.RequiredArguments = new List(); + foreach (var arg in mth.GetCustomAttributes(false).Where(x => x is RequiresArgument)) + { + var rarg = arg as RequiresArgument; + tc.RequiredArguments.Add(rarg.argument); } + var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; + if (rupg != null) + tc.Dependencies = rupg.Upgrade; + else + tc.Dependencies = ""; + tc.CommandType = type; + tc.CommandHandler = mth; + + var ambiguity = Commands.FirstOrDefault(x => x.CommandInfo.name == tc.CommandInfo.name); + if (ambiguity != null) + throw new Exception("Command ambiguity error. You can't have two commands with the same name: " + $"{tc} == {ambiguity}"); + + if (!Commands.Contains(tc)) + Commands.Add(tc); } } + } Console.WriteLine("[termdb] " + Commands.Count + " commands found."); } @@ -465,7 +463,7 @@ namespace ShiftOS.Engine string[] split = text.Split('.'); - var cmd = Commands.FirstOrDefault(x => x.NamespaceInfo.name == split[0] && x.CommandInfo.name == split[1]); + var cmd = Commands.FirstOrDefault(x => x.CommandInfo.name == text); if (cmd == null) return false; if (!Shiftorium.UpgradeInstalled(cmd.Dependencies)) diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index a64c99c..cac535b 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -10,7 +10,6 @@ namespace ShiftOS.Engine /// /// Administrative user management terminal commands. /// - [Namespace("admin")] [KernelMode] [RequiresUpgrade("mud_fundamentals")] public static class AdminUserManagementCommands @@ -173,7 +172,6 @@ namespace ShiftOS.Engine /// /// Non-administrative user management terminal commands. /// - [Namespace("user")] [RequiresUpgrade("mud_fundamentals")] public static class UserManagementCommands { -- cgit v1.2.3 From 77cb4a9a14de07023e86a9a5cda7171fcb4ec8ec Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Sat, 17 Jun 2017 14:23:39 +1000 Subject: Changed how bounces work in Pong + Fixed Shutdown --- ShiftOS.WinForms/Applications/Pong.cs | 36 +++++++++++++++++------------------ ShiftOS.WinForms/WinformsDesktop.cs | 6 +++--- 2 files changed, 20 insertions(+), 22 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 3f06676..c260ae3 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -83,6 +83,15 @@ namespace ShiftOS.WinForms.Applications private string counter = ""; + private void Bounce(Rectangle ball, Rectangle paddle) + { + // reverse x velocity to send the ball the other way + xVel = -xVel; + + // adjust y velocity based on where the ball hit the paddle + yVel += linear((ball.Top + (ball.Height / 2)), paddle.Top, paddle.Bottom, -1, 1); + } + public void UpdateBall() { if (doBallCalc) @@ -141,11 +150,7 @@ namespace ShiftOS.WinForms.Applications //check if the ball x is greater than the player paddle's middle coordinate if (ballRect.Right >= opponentRect.Left) { - //reverse x velocity to send the ball the other way - xVel = -xVel; - - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); + Bounce(ballRect, opponentRect); doAi = false; } @@ -169,11 +174,7 @@ namespace ShiftOS.WinForms.Applications { if (ballRect.Left <= playerRect.Right) { - //reverse x velocity to send the ball the other way - xVel = -xVel; - - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); + Bounce(ballRect, playerRect); //reset the ai location aiBallX = ballX; @@ -255,15 +256,12 @@ namespace ShiftOS.WinForms.Applications new System.Threading.Thread(() => { doBallCalc = false; - counter = "3"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); - counter = "2"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); - counter = "1"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); + for (int i = 3; i > 0; i--) + { + counter = i.ToString(); + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + System.Threading.Thread.Sleep(1000); + } doBallCalc = true; header = ""; counter = ""; diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 82d99f0..e8ad298 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -824,7 +824,7 @@ namespace ShiftOS.WinForms item.Text = Localization.Parse("{SHUTDOWN}"); item.Click += (o, a) => { - TerminalBackend.InvokeCommand("sos.shutdown"); + TerminalBackend.InvokeCommand("shutdown"); }; apps.DropDownItems.Add(item); if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) @@ -853,7 +853,7 @@ namespace ShiftOS.WinForms catbtn.Height = 24; flcategories.Controls.Add(catbtn); catbtn.Show(); - catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("sos.shutdown"); + catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("shutdown"); } } } @@ -1109,7 +1109,7 @@ namespace ShiftOS.WinForms private void btnshutdown_Click(object sender, EventArgs e) { - TerminalBackend.InvokeCommand("sos.shutdown"); + TerminalBackend.InvokeCommand("shutdown"); } public void HideAppLauncher() -- cgit v1.2.3 From 81f10b0686fed7254af3f43d15ad39fe44a48de3 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Jun 2017 20:02:24 -0400 Subject: Remove a CPU-murdering unused story thingy --- ShiftOS.WinForms/WinformsDesktop.cs | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index e8ad298..855e66d 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -265,40 +265,6 @@ namespace ShiftOS.WinForms SetupDesktop(); }; - ulong lastcp = 0; - - var storythread = new Thread(() => - { - do - { - while (SaveSystem.CurrentUser == null) - Thread.Sleep(10); - - if (SaveSystem.CurrentSave != null) - { - if (SaveSystem.CurrentSave.Codepoints != lastcp) - lastcp = SaveSystem.CurrentSave.Codepoints; - if (lastcp >= 2500) - { - if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) - { - Story.Start("victortran_shiftnet"); - } - } - if(lastcp >= 5000) - { - if(Shiftorium.UpgradeInstalled("triwrite") && Shiftorium.UpgradeInstalled("simplesrc") && Shiftorium.UpgradeInstalled("victortran_shiftnet") && Shiftorium.UpgradeInstalled("story_hacker101_breakingthebonds")) - { - if (!Shiftorium.UpgradeInstalled("story_thefennfamily")) - Story.Start("story_thefennfamily"); - } - } - } - } while (!SaveSystem.ShuttingDown); - }); - storythread.IsBackground = true; - storythread.Start(); - time.Tick += (o, a) => { if (Shiftorium.IsInitiated == true) -- cgit v1.2.3