diff --git a/ShiftOS.Updater.exe/App.config b/ShiftOS.Updater.exe/App.config
new file mode 100644
index 0000000..88fa402
--- /dev/null
+++ b/ShiftOS.Updater.exe/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ShiftOS.Updater.exe/Program.cs b/ShiftOS.Updater.exe/Program.cs
new file mode 100644
index 0000000..aa87901
--- /dev/null
+++ b/ShiftOS.Updater.exe/Program.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShiftOS.Updater.exe
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ }
+ }
+}
diff --git a/ShiftOS.Updater.exe/Properties/AssemblyInfo.cs b/ShiftOS.Updater.exe/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..69ba9c9
--- /dev/null
+++ b/ShiftOS.Updater.exe/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ShiftOS.Updater.exe")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ShiftOS.Updater.exe")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8031adf5-caf0-4210-bec0-964a9db130a9")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ShiftOS.Updater.exe/ShiftOS.Updater.exe.csproj b/ShiftOS.Updater.exe/ShiftOS.Updater.exe.csproj
new file mode 100644
index 0000000..6142844
--- /dev/null
+++ b/ShiftOS.Updater.exe/ShiftOS.Updater.exe.csproj
@@ -0,0 +1,60 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {8031ADF5-CAF0-4210-BEC0-964A9DB130A9}
+ Exe
+ Properties
+ ShiftOS.Updater.exe
+ ShiftOS.Updater.exe
+ v4.5.2
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ShiftOS.Updater/App.config b/ShiftOS.Updater/App.config
new file mode 100644
index 0000000..88fa402
--- /dev/null
+++ b/ShiftOS.Updater/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ShiftOS.Updater/Program.cs b/ShiftOS.Updater/Program.cs
new file mode 100644
index 0000000..df41492
--- /dev/null
+++ b/ShiftOS.Updater/Program.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace ShiftOS.Updater
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ if (Directory.Exists("updater-work"))
+ {
+ //Give the engine time to shutdown before invoking this app.
+ Thread.Sleep(5000);
+ foreach (var f in Directory.GetFiles("updater-work"))
+ {
+ var bytes = File.ReadAllBytes(f);
+ var finf = new FileInfo(f);
+ File.WriteAllBytes(finf.Name, bytes);
+ }
+ Directory.Delete("updater-work", true);
+ }
+
+ //Restart the actual game.
+ System.Diagnostics.Process.Start("ShiftOS.WinForms.exe");
+ }
+ }
+}
diff --git a/ShiftOS.Updater/Properties/AssemblyInfo.cs b/ShiftOS.Updater/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..74602cb
--- /dev/null
+++ b/ShiftOS.Updater/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ShiftOS.Updater")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ShiftOS.Updater")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("36bc512f-6fd4-4139-aed7-565fc8d5bcbc")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ShiftOS.Updater/ShiftOS.Updater.csproj b/ShiftOS.Updater/ShiftOS.Updater.csproj
new file mode 100644
index 0000000..70d8263
--- /dev/null
+++ b/ShiftOS.Updater/ShiftOS.Updater.csproj
@@ -0,0 +1,66 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {36BC512F-6FD4-4139-AED7-565FC8D5BCBC}
+ Exe
+ Properties
+ ShiftOS.Updater
+ ShiftOS.Updater
+ v4.5.2
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {2295d2e2-3a00-4e02-b66f-b961ac329fe6}
+ ShiftOS.WinForms
+
+
+
+
+
\ No newline at end of file
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs
index c1c81d5..501fa56 100644
--- a/ShiftOS.WinForms/Applications/Shiftnet.cs
+++ b/ShiftOS.WinForms/Applications/Shiftnet.cs
@@ -36,34 +36,53 @@ using Newtonsoft.Json;
using static ShiftOS.Engine.SkinEngine;
using ShiftOS.WinForms.Tools;
-namespace ShiftOS.WinForms.Applications {
+namespace ShiftOS.WinForms.Applications
+{
+ //OH MY GOD. I HAD TO CORRECT HEAPS OF BADLY PLACED CURLY BRACES.
+ //
+ //I DO NOT CARE WHAT THE BLUE SMILEY FACE SAYS. CURLY BRACES BELONG ON THEIR OWN LINE.
+ //
+ //READ THE DAMN SHIFTOS CODING GUIDELINES.
+
[Launcher("Shiftnet", false, null, "Networking")]
[MultiplayerOnly]
[DefaultIcon("iconShiftnet")]
- public partial class Shiftnet : UserControl, IShiftOSWindow {
- public Shiftnet() {
+ public partial class Shiftnet : UserControl, IShiftOSWindow
+ {
+ public Shiftnet()
+ {
InitializeComponent();
- ServerManager.MessageReceived += (msg) => {
- try {
- if (msg.Name == "shiftnet_file") {
- if (Objects.ShiftFS.Utils.FileExists("0:/md.txt")) {
- this.Invoke(new Action(() => {
+ ServerManager.MessageReceived += (msg) =>
+ {
+ try
+ {
+ if (msg.Name == "shiftnet_file")
+ {
+ if (Objects.ShiftFS.Utils.FileExists("0:/md.txt"))
+ {
+ this.Invoke(new Action(() =>
+ {
wbcanvas.DocumentText = ConstructHtml(Objects.ShiftFS.Utils.ReadAllText("0:/md.txt"));
}));
- } else {
+ }
+ else
+ {
this.Invoke(new Action(() =>
{
wbcanvas.DocumentText = ConstructHtml(msg.Contents);
}));
}
}
- } catch {
+ }
+ catch
+ {
}
};
}
- public string ConstructHtml(string markdown) {
+ public string ConstructHtml(string markdown)
+ {
var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC);
var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC);
string html = $@"
@@ -105,7 +124,8 @@ namespace ShiftOS.WinForms.Applications {
";
string body = CommonMark.CommonMarkConverter.Convert(markdown);
- for (int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed()) {
+ for (int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed())
+ {
//halt the page load until 'download' finishes.
}
html = html.Replace("", body);
@@ -115,12 +135,15 @@ namespace ShiftOS.WinForms.Applications {
public string CurrentUrl { get; set; }
- private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
+ private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e)
+ {
string Url = e.Url.ToString().Replace("http://", "");
- if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:")) {
+ if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:"))
+ {
e.Cancel = true;
Future.Clear();
- if (Url.StartsWith("runsyscmd/")) {
+ if (Url.StartsWith("runsyscmd/"))
+ {
ProcessShiftnetCmd(Url.Replace("runsyscmd/", ""));
}
@@ -128,16 +151,23 @@ namespace ShiftOS.WinForms.Applications {
}
}
- public void ProcessShiftnetCmd(string cmd) {
+ public void ProcessShiftnetCmd(string cmd)
+ {
var args = cmd.Split('/');
- switch (args[0]) {
+ switch (args[0])
+ {
case "setsnsub":
- for (int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++) {
- if (DownloadManager.GetAllSubscriptions()[i].Name == args[1]) {
+ for (int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++)
+ {
+ if (DownloadManager.GetAllSubscriptions()[i].Name == args[1])
+ {
var sub = DownloadManager.GetAllSubscriptions()[i];
- Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action((answer) => {
- if (answer == true) {
- if (SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth) {
+ Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action((answer) =>
+ {
+ if (answer == true)
+ {
+ if (SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth)
+ {
//Initial fee gets deducted.
SaveSystem.CurrentSave.Codepoints -= sub.CostPerMonth;
//Then we set the subscription.
@@ -147,7 +177,9 @@ namespace ShiftOS.WinForms.Applications {
//Then we send our save to the MUD.
SaveSystem.SaveGame();
- } else {
+ }
+ else
+ {
//User can't afford this subscription.
Infobox.Show("Shiftnet - Not enough Codepoints", $"You cannot afford to pay for this subscription at this time. You need {sub.CostPerMonth - SaveSystem.CurrentSave.Codepoints} more Codepoints.");
}
@@ -162,39 +194,51 @@ namespace ShiftOS.WinForms.Applications {
public Stack History = new Stack();
public Stack Future = new Stack();
- public void ShiftnetNavigate(string Url, bool pushHistory = true) {
- if (Url.EndsWith(".rnp") || !Url.Contains(".")) {
+ public void ShiftnetNavigate(string Url, bool pushHistory = true)
+ {
+ if (Url.EndsWith(".rnp") || !Url.Contains("."))
+ {
if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory)
History.Push(CurrentUrl);
CurrentUrl = Url;
- ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new {
+ ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new
+ {
url = Url
}));
txturl.Text = Url;
- } else {
+ }
+ else
+ {
ServerMessageReceived smr = null;
- smr = (msg) => {
- if (msg.Name == "download_meta") {
+ smr = (msg) =>
+ {
+ if (msg.Name == "download_meta")
+ {
var bytes = JsonConvert.DeserializeObject(msg.Contents);
string destPath = null;
string ext = Url.Split('.')[Url.Split('.').Length - 1];
- this.Invoke(new Action(() => {
- FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action((file) => {
+ this.Invoke(new Action(() =>
+ {
+ FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action((file) =>
+ {
destPath = file;
}));
}));
- while (string.IsNullOrEmpty(destPath)) {
+ while (string.IsNullOrEmpty(destPath))
+ {
}
- var d = new Download {
+ var d = new Download
+ {
ShiftnetUrl = Url,
Destination = destPath,
Bytes = bytes,
Progress = 0,
};
DownloadManager.StartDownload(d);
- this.Invoke(new Action(() => {
+ this.Invoke(new Action(() =>
+ {
AppearanceManager.SetupWindow(new Downloader());
}));
ServerManager.MessageReceived -= smr;
@@ -205,60 +249,79 @@ namespace ShiftOS.WinForms.Applications {
}
}
- public void OnLoad() {
+ public void OnLoad()
+ {
ShiftnetNavigate("shiftnet/main");
}
- public void OnSkinLoad() {
+ public void OnSkinLoad()
+ {
ShiftnetNavigate(CurrentUrl);
}
- public bool OnUnload() {
+ public bool OnUnload()
+ {
return true;
}
- public void OnUpgrade() {
+ public void OnUpgrade()
+ {
}
- private void btnback_Click(object sender, EventArgs e) {
- try {
+ private void btnback_Click(object sender, EventArgs e)
+ {
+ try
+ {
string hist = History.Pop();
- if (!string.IsNullOrEmpty(hist)) {
+ if (!string.IsNullOrEmpty(hist))
+ {
Future.Push(hist);
ShiftnetNavigate(hist, false);
}
- } catch {
+ }
+ catch
+ {
}
}
- private void btnforward_Click(object sender, EventArgs e) {
- try {
+ private void btnforward_Click(object sender, EventArgs e)
+ {
+ try
+ {
string fut = Future.Pop();
- if (!string.IsNullOrEmpty(fut)) {
+ if (!string.IsNullOrEmpty(fut))
+ {
ShiftnetNavigate(fut);
}
- } catch {
+ }
+ catch
+ {
}
}
- private void btngo_Click(object sender, EventArgs e) {
- if (!string.IsNullOrWhiteSpace(txturl.Text)) {
+ private void btngo_Click(object sender, EventArgs e)
+ {
+ if (!string.IsNullOrWhiteSpace(txturl.Text))
+ {
Future.Clear();
ShiftnetNavigate(txturl.Text);
}
}
- private void txturl_KeyDown(object sender, KeyEventArgs e) {
- if (e.KeyCode == Keys.Enter) {
+ private void txturl_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
btngo_Click(sender, EventArgs.Empty);
e.SuppressKeyPress = true;
}
}
- private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e) {
+ private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e)
+ {
}
}
}
diff --git a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs
new file mode 100644
index 0000000..466151a
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs
@@ -0,0 +1,130 @@
+namespace ShiftOS.WinForms.Applications
+{
+ partial class UpdateManager
+ {
+ ///
+ /// 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.lbupdatetitle = new System.Windows.Forms.Label();
+ this.pnlupdatebar = new System.Windows.Forms.Panel();
+ this.btnclose = new System.Windows.Forms.Button();
+ this.btnaction = new System.Windows.Forms.Button();
+ this.pgdownload = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
+ this.wbstatus = new System.Windows.Forms.WebBrowser();
+ this.pnlupdatebar.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // lbupdatetitle
+ //
+ this.lbupdatetitle.AutoSize = true;
+ this.lbupdatetitle.Dock = System.Windows.Forms.DockStyle.Top;
+ this.lbupdatetitle.Location = new System.Drawing.Point(0, 0);
+ this.lbupdatetitle.Margin = new System.Windows.Forms.Padding(10);
+ this.lbupdatetitle.Name = "lbupdatetitle";
+ this.lbupdatetitle.Size = new System.Drawing.Size(117, 13);
+ this.lbupdatetitle.TabIndex = 0;
+ this.lbupdatetitle.Tag = "header1";
+ this.lbupdatetitle.Text = "Checking for updates...";
+ //
+ // pnlupdatebar
+ //
+ this.pnlupdatebar.Controls.Add(this.pgdownload);
+ this.pnlupdatebar.Controls.Add(this.btnaction);
+ this.pnlupdatebar.Controls.Add(this.btnclose);
+ this.pnlupdatebar.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.pnlupdatebar.Location = new System.Drawing.Point(0, 426);
+ this.pnlupdatebar.Name = "pnlupdatebar";
+ this.pnlupdatebar.Size = new System.Drawing.Size(597, 33);
+ this.pnlupdatebar.TabIndex = 1;
+ //
+ // btnclose
+ //
+ this.btnclose.Location = new System.Drawing.Point(4, 4);
+ this.btnclose.Name = "btnclose";
+ this.btnclose.Size = new System.Drawing.Size(75, 23);
+ this.btnclose.TabIndex = 0;
+ this.btnclose.Text = "{CLOSE}";
+ this.btnclose.UseVisualStyleBackColor = true;
+ this.btnclose.Click += new System.EventHandler(this.btnclose_Click);
+ //
+ // btnaction
+ //
+ this.btnaction.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnaction.Location = new System.Drawing.Point(519, 4);
+ this.btnaction.Name = "btnaction";
+ this.btnaction.Size = new System.Drawing.Size(75, 23);
+ this.btnaction.TabIndex = 1;
+ this.btnaction.Text = "Update";
+ this.btnaction.UseVisualStyleBackColor = true;
+ //
+ // pgdownload
+ //
+ this.pgdownload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pgdownload.BlockSize = 5;
+ this.pgdownload.Location = new System.Drawing.Point(86, 4);
+ this.pgdownload.Maximum = 100;
+ this.pgdownload.Name = "pgdownload";
+ this.pgdownload.Size = new System.Drawing.Size(427, 23);
+ this.pgdownload.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+ this.pgdownload.TabIndex = 2;
+ this.pgdownload.Text = "Updating...";
+ this.pgdownload.Value = 0;
+ //
+ // wbstatus
+ //
+ this.wbstatus.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.wbstatus.Location = new System.Drawing.Point(0, 13);
+ this.wbstatus.MinimumSize = new System.Drawing.Size(20, 20);
+ this.wbstatus.Name = "wbstatus";
+ this.wbstatus.Size = new System.Drawing.Size(597, 413);
+ this.wbstatus.TabIndex = 2;
+ //
+ // UpdateManager
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.wbstatus);
+ this.Controls.Add(this.pnlupdatebar);
+ this.Controls.Add(this.lbupdatetitle);
+ this.Name = "UpdateManager";
+ this.Size = new System.Drawing.Size(597, 459);
+ this.pnlupdatebar.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label lbupdatetitle;
+ private System.Windows.Forms.Panel pnlupdatebar;
+ private Controls.ShiftedProgressBar pgdownload;
+ private System.Windows.Forms.Button btnaction;
+ private System.Windows.Forms.Button btnclose;
+ private System.Windows.Forms.WebBrowser wbstatus;
+ }
+}
diff --git a/ShiftOS.WinForms/Applications/UpdateManager.cs b/ShiftOS.WinForms/Applications/UpdateManager.cs
new file mode 100644
index 0000000..05ae9d0
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/UpdateManager.cs
@@ -0,0 +1,279 @@
+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.Tools;
+using static ShiftOS.Engine.SkinEngine;
+using System.Net;
+using Newtonsoft.Json;
+using System.Reflection;
+using System.IO;
+using System.IO.Compression;
+
+namespace ShiftOS.WinForms.Applications
+{
+ [Launcher("Update Manager", true, "al_update_manager", "Networking")]
+ [DefaultTitle("Update Manager")]
+ [WinOpen("update_manager")]
+ public partial class UpdateManager : UserControl, IShiftOSWindow
+ {
+ public UpdateManager()
+ {
+ InitializeComponent();
+ btnaction.Click += (o, a) => OnActionButtonClick?.Invoke();
+ }
+
+ public void OnLoad()
+ {
+ CheckForUpdate();
+ }
+
+ public void CheckForUpdate()
+ {
+ ConstructHtml(@"ShiftOS is grabbing information on the latest version. Please be patient.");
+ pgdownload.Show();
+ btnaction.Show();
+ lbupdatetitle.Text = "Checking for updates...";
+ pgdownload.Value = 0;
+ pgdownload.Maximum = 100;
+
+ var wc = new WebClient();
+
+ wc.DownloadProgressChanged += (o, a) =>
+ {
+ this.Invoke(new Action(() =>
+ {
+ pgdownload.Text = "Grabbing update data from multi-user-domain...";
+ pgdownload.Value = a.ProgressPercentage;
+ }));
+ };
+
+ wc.DownloadStringCompleted += (o, a) =>
+ {
+ var releases = JsonConvert.DeserializeObject(a.Result);
+
+ var download = releases.OrderByDescending(x => x.PostDate).First();
+
+ var thisBuildDate = Assembly.GetExecutingAssembly().GetBuildDate(TimeZoneInfo.Utc);
+
+ if(download.PostDate > thisBuildDate)
+ {
+ this.Invoke(new Action(() =>
+ {
+ //This build is more recent than the currently running ShiftOS client.
+ SetupBuildUpdate(download);
+ }));
+ }
+ else
+ {
+ if (thisBuildDate > download.PostDate)
+ {
+ this.Invoke(new Action(() => ConstructHtml($@"### Unreleased build.
+
+You are currently running an unreleased build of ShiftOS, compiled on {thisBuildDate}, after the latest released version, {download.Name}, compiled on {download.PostDate}.")));
+ }
+ else
+ {
+ this.Invoke(new Action(() => ConstructHtml($@"### Up to date.
+
+You are currently running {download.Name}, compiled on {download.PostDate}.")));
+
+ }
+ this.Invoke(new Action(() =>
+ {
+ lbupdatetitle.Text = "No update available";
+ pgdownload.Hide();
+ btnaction.Hide();
+ }));
+ }
+ };
+
+ wc.DownloadStringAsync(new Uri("http://getshiftos.ml/API/Releases?showUnstable=true&showObsolete=false"));
+ }
+
+ public void OnSkinLoad()
+ {
+ ConstructHtml(CurrentMD);
+ }
+
+ public bool OnUnload()
+ {
+ return true;
+ }
+
+ public void OnUpgrade()
+ {
+ ConstructHtml(CurrentMD);
+ }
+
+ public void SetupBuildUpdate(ShiftOS.Objects.Unite.Download download)
+ {
+ string devUpdate = "";
+ if (!string.IsNullOrEmpty(download.DevUpdateId))
+ {
+ devUpdate = $@"## Development update
+
+
+";
+ }
+
+ string screenshot = "";
+
+ if(!string.IsNullOrEmpty(download.ScreenshotUrl))
+ {
+ screenshot = $"";
+ }
+
+ lbupdatetitle.Text = download.Name;
+ string markdown = $@"**Built on {download.PostDate}**
+
+{devUpdate}
+
+{screenshot}
+
+## Changelog
+
+{download.Changelog}";
+
+ ConstructHtml(markdown);
+
+ pgdownload.Value = 0;
+ pgdownload.Text = "Waiting.";
+ btnaction.Text = "Update";
+ btnaction.Show();
+ OnActionButtonClick = () =>
+ {
+ pgdownload.Show();
+ var wc = new WebClient();
+ wc.DownloadProgressChanged += (o, a) =>
+ {
+ this.Invoke(new Action(() =>
+ {
+ pgdownload.Text = "Downloading " + download.Name + "...";
+ pgdownload.Value = a.ProgressPercentage;
+ }));
+ };
+
+ wc.DownloadDataCompleted += (o, a) =>
+ {
+ if (Directory.Exists("updater-work"))
+ Directory.Delete("updater-work", true);
+ Directory.CreateDirectory("updater-work");
+
+ string temp_guid = Guid.NewGuid().ToString();
+
+ File.WriteAllBytes($"{temp_guid}.zip", a.Result);
+
+ ZipFile.ExtractToDirectory($"{temp_guid}.zip", "updater-work");
+
+ File.Delete($"{temp_guid}.zip");
+
+ //Start the updater helper.
+ System.Diagnostics.Process.Start("ShiftOS.Updater.exe");
+
+ //Now we stop the engine.
+ TerminalBackend.InvokeCommand("sos.shutdown");
+
+ };
+
+ wc.DownloadDataAsync(new Uri($"http://getshiftos.ml{download.DownloadUrl}"));
+ };
+ }
+
+ public Action OnActionButtonClick = () => { };
+
+ public void ConstructHtml(string markdown)
+ {
+ CurrentMD = markdown;
+ var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC);
+ var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC);
+ string html = $@"
+
+
+
+
+
+
+";
+
+ string body = CommonMark.CommonMarkConverter.Convert(markdown);
+
+ html = html.Replace("", body);
+ wbstatus.DocumentText = html;
+ }
+
+ public string CurrentMD = "";
+
+ private void btnclose_Click(object sender, EventArgs e)
+ {
+ AppearanceManager.Close(this);
+ }
+ }
+
+ public static class UpdateHelpers
+ {
+ ///
+ /// Grabs the build date from the assembly's PE header.
+ ///
+ /// The assembly to probe.
+ /// The target timezone.
+ /// The assembly's build date.
+ public static DateTime GetBuildDate(this Assembly assembly, TimeZoneInfo target = null)
+ {
+ var filePath = assembly.Location;
+ const int c_PeHeaderOffset = 60;
+ const int c_LinkerTimestampOffset = 8;
+
+ var buffer = new byte[2048];
+
+ using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
+ stream.Read(buffer, 0, 2048);
+
+ var offset = BitConverter.ToInt32(buffer, c_PeHeaderOffset);
+ var secondsSince1970 = BitConverter.ToInt32(buffer, offset + c_LinkerTimestampOffset);
+ var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ var linkTimeUtc = epoch.AddSeconds(secondsSince1970);
+
+ var tz = target ?? TimeZoneInfo.Local;
+ var localTime = TimeZoneInfo.ConvertTimeFromUtc(linkTimeUtc, tz);
+
+ return localTime;
+ }
+ }
+}
diff --git a/ShiftOS.WinForms/Applications/UpdateManager.resx b/ShiftOS.WinForms/Applications/UpdateManager.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/UpdateManager.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/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt
index 0c4e0c6..5310c40 100644
--- a/ShiftOS.WinForms/Resources/Shiftorium.txt
+++ b/ShiftOS.WinForms/Resources/Shiftorium.txt
@@ -945,6 +945,16 @@
Description: "In the shiftorium GUI but dont know what you can spend because you can't see how many code points are on hand? Well shop easy, because with this upgrade that is now possible! You have to restart the shiftorium for it to work."
},
+ //UPDATE MANAGER
+ {
+ Name: "AL Update Manager",
+ Cost: 150,
+ Description: "Want to get the latest features of ShiftOS, right from your App Launcher? This upgrade is for you!",
+ Dependencies: "app_launcher",
+ Category: "GUI"
+ },
+
+
// SHIFTSWEEPER
{
diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj
index d865c62..ca0001e 100644
--- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj
+++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj
@@ -43,6 +43,7 @@
+
@@ -226,6 +227,12 @@
TutorialBox.cs
+
+ UserControl
+
+
+ UpdateManager.cs
+
@@ -377,6 +384,9 @@
TutorialBox.cs
+
+ UpdateManager.cs
+
DownloadControl.cs
diff --git a/ShiftOS_TheReturn.sln b/ShiftOS_TheReturn.sln
index 8bb8ef4..04f0c5d 100644
--- a/ShiftOS_TheReturn.sln
+++ b/ShiftOS_TheReturn.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftOS.Engine", "ShiftOS_TheReturn\ShiftOS.Engine.csproj", "{7C979B07-0585-4033-A110-E5555B9D6651}"
EndProject
@@ -19,6 +19,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ShiftOS.Modding.VB.LegacySk
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModLauncher", "ModLauncher\ModLauncher.csproj", "{AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftOS.Updater", "ShiftOS.Updater\ShiftOS.Updater.csproj", "{36BC512F-6FD4-4139-AED7-565FC8D5BCBC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
{AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {36BC512F-6FD4-4139-AED7-565FC8D5BCBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {36BC512F-6FD4-4139-AED7-565FC8D5BCBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {36BC512F-6FD4-4139-AED7-565FC8D5BCBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {36BC512F-6FD4-4139-AED7-565FC8D5BCBC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE