diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 6339588..35efca4 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -259,45 +259,81 @@ You must join the digital society, rise up the ranks, and save us. }); AppearanceManager.SetupDialog(loginDialog); } + else + { + var signupDialog = new UniteSignupDialog((token) => + { + + }); + AppearanceManager.SetupDialog(signupDialog); + } }); }); } public void LinkSaveFile(string token) { - Infobox.PromptText("Enter username", "Please enter the username you used for your save file before these changes.", (cuname) => + if (Utils.FileExists(Paths.GetPath("user.dat"))) { - Infobox.PromptText("Enter password", "Now, please enter the corresponding password.", (cpass) => + try { - ServerMessageReceived nsmr = null; - nsmr = (nmsg) => + var details = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("user.dat"))); + ServerMessageReceived smr = null; + bool msgreceived = false; + bool found = false; + smr = (msg) => { - ServerManager.MessageReceived -= nsmr; - if (nmsg.Name == "mud_savefile") + if (msg.Name == "mud_savefile") { - var save = JsonConvert.DeserializeObject(nmsg.Contents); + var save = JsonConvert.DeserializeObject(msg.Contents); save.UniteAuthToken = token; - Infobox.Show("That'll do it.", "Your save has been linked up! Next time you log into the ShiftOS site, your Codepoints should show on your profile. There's just a few more things we have to do.", () => + Infobox.Show("Migration complete.", "We have migrated your old save file to the new system successfully. You can still log in using the old system on old builds of ShiftOS.", () => { SaveSystem.CurrentSave = save; SaveSystem.SaveGame(); + found = true; + msgreceived = true; }); } else { - Infobox.Show("Uh oh.", "We couldn't find a save file with those values. Please try again", () => - { - LinkSaveFile(token); - }); + found = false; + msgreceived = true; } + ServerManager.MessageReceived -= smr; }; - ServerManager.MessageReceived += nsmr; + ServerManager.MessageReceived += smr; ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new { - username = cuname, - password = cpass + username = details.Username, + password = details.Password })); - }, true); + while (msgreceived == false) + Thread.Sleep(10); + if (found) + return; + } + catch + { + + } + } + + var client = new UniteClient("http://getshiftos.ml", token); + var sve = new Save(); + sve.Username = client.GetEmail(); + sve.Password = Guid.NewGuid().ToString(); + sve.SystemName = client.GetSysName(); + sve.UniteAuthToken = token; + sve.Codepoints = 0; + sve.Upgrades = new Dictionary(); + sve.ID = Guid.NewGuid(); + Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () => + { + sve.StoryPosition = 8675309; + SaveSystem.CurrentSave = sve; + SaveSystem.SaveGame(); + }); } diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 97ba8ef..1d4e91a 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -373,6 +373,12 @@ UniteLoginDialog.cs + + UserControl + + + UniteSignupDialog.cs + @@ -534,6 +540,9 @@ UniteLoginDialog.cs + + UniteSignupDialog.cs + WindowBorder.cs diff --git a/ShiftOS.WinForms/UniteSignupDialog.Designer.cs b/ShiftOS.WinForms/UniteSignupDialog.Designer.cs new file mode 100644 index 0000000..752f5c0 --- /dev/null +++ b/ShiftOS.WinForms/UniteSignupDialog.Designer.cs @@ -0,0 +1,186 @@ +namespace ShiftOS.WinForms +{ + partial class UniteSignupDialog + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UniteSignupDialog)); + this.btnlogin = new System.Windows.Forms.Button(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtconfirm = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.txtdisplay = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btnlogin + // + this.btnlogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnlogin.Location = new System.Drawing.Point(462, 407); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(75, 23); + this.btnlogin.TabIndex = 11; + this.btnlogin.Text = "Submit"; + this.btnlogin.UseVisualStyleBackColor = true; + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(113, 133); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(424, 20); + this.txtpassword.TabIndex = 10; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(113, 100); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(424, 20); + this.txtusername.TabIndex = 9; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(17, 136); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(56, 13); + this.label3.TabIndex = 8; + this.label3.Text = "Password:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(17, 103); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(76, 13); + this.label2.TabIndex = 7; + this.label2.Text = "Email Address:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(17, 36); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.TabIndex = 6; + this.label1.Tag = "header2"; + this.label1.Text = "Login to ShiftOS"; + // + // txtconfirm + // + this.txtconfirm.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtconfirm.Location = new System.Drawing.Point(113, 159); + this.txtconfirm.Name = "txtconfirm"; + this.txtconfirm.Size = new System.Drawing.Size(424, 20); + this.txtconfirm.TabIndex = 13; + this.txtconfirm.UseSystemPasswordChar = true; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(17, 162); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(45, 13); + this.label4.TabIndex = 12; + this.label4.Text = "Confirm:"; + // + // txtdisplay + // + this.txtdisplay.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtdisplay.Location = new System.Drawing.Point(113, 197); + this.txtdisplay.Name = "txtdisplay"; + this.txtdisplay.Size = new System.Drawing.Size(424, 20); + this.txtdisplay.TabIndex = 15; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(17, 200); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(73, 13); + this.label5.TabIndex = 14; + this.label5.Text = "Display name:"; + // + // label6 + // + this.label6.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.label6.Location = new System.Drawing.Point(20, 251); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(517, 153); + this.label6.TabIndex = 16; + this.label6.Text = resources.GetString("label6.Text"); + // + // UniteSignupDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label6); + this.Controls.Add(this.txtdisplay); + this.Controls.Add(this.label5); + this.Controls.Add(this.txtconfirm); + this.Controls.Add(this.label4); + this.Controls.Add(this.btnlogin); + this.Controls.Add(this.txtpassword); + this.Controls.Add(this.txtusername); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "UniteSignupDialog"; + this.Size = new System.Drawing.Size(555, 447); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnlogin; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtconfirm; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtdisplay; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + } +} diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs new file mode 100644 index 0000000..2f20d9f --- /dev/null +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -0,0 +1,43 @@ +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 +{ + public partial class UniteSignupDialog : UserControl, IShiftOSWindow + { + public UniteSignupDialog(Action callback) + { + InitializeComponent(); + Callback = callback; + } + + private Action Callback { get; set; } + + + public void OnLoad() + { + this.ParentForm.AcceptButton = btnlogin; + } + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + } + } +} diff --git a/ShiftOS.WinForms/UniteSignupDialog.resx b/ShiftOS.WinForms/UniteSignupDialog.resx new file mode 100644 index 0000000..5fecdcd --- /dev/null +++ b/ShiftOS.WinForms/UniteSignupDialog.resx @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Your ShiftOS Account is your gateway to the world of ShiftOS. + +What does this account do for you? + + - It holds all your Codepoints, Shiftorium Upgrades, and other in-game save details in a secure spot. + - It gives you access to the ShiftOS Forums, Wiki, Developer Blog and the bugtracker. + - It gives you your own personal profile that you can shift your own way - just like you can ShiftOS. + +You can customize more information for this account at http://getshiftos.ml/, but first, we must create it. + + \ No newline at end of file diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 8d9eef2..88e44af 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -15,7 +15,7 @@ namespace ShiftOS.Unite public UniteClient(string baseurl, string usertoken) { BaseURL = baseurl; - Token = Token; + Token = usertoken; } internal string MakeCall(string url) @@ -34,6 +34,21 @@ namespace ShiftOS.Unite } } + public string GetEmail() + { + return MakeCall("/API/GetEmail"); + } + + public string GetSysName() + { + return MakeCall("/API/GetSysName"); + } + + public void SetSysName(string value) + { + MakeCall("/API/SetSysName/" + value); + } + public string GetDisplayName() { return MakeCall("/API/GetDisplayName");