From 5b01c364e65616a41332f76e445a9dbd8e64a53f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 22 Jan 2017 19:03:59 -0500 Subject: [PATCH] Implement save migration from client to server --- ShiftOS.WinForms/FakeSetupScreen.Designer.cs | 117 +++++++++++++++++++ ShiftOS.WinForms/FakeSetupScreen.cs | 62 +++++++++- ShiftOS.WinForms/Oobe.Designer.cs | 4 +- ShiftOS.WinForms/Oobe.cs | 30 ++++- 4 files changed, 209 insertions(+), 4 deletions(-) diff --git a/ShiftOS.WinForms/FakeSetupScreen.Designer.cs b/ShiftOS.WinForms/FakeSetupScreen.Designer.cs index b220367..b54737f 100644 --- a/ShiftOS.WinForms/FakeSetupScreen.Designer.cs +++ b/ShiftOS.WinForms/FakeSetupScreen.Designer.cs @@ -51,12 +51,23 @@ this.page4 = new System.Windows.Forms.Panel(); this.txtlicenseagreement = new System.Windows.Forms.RichTextBox(); this.label10 = new System.Windows.Forms.Label(); + this.pgrereg = new System.Windows.Forms.Panel(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.label7 = new System.Windows.Forms.Label(); + this.txtruname = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.txtrpass = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.txtrsys = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); this.flbuttons.SuspendLayout(); this.page1.SuspendLayout(); this.page2.SuspendLayout(); this.page3.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.page4.SuspendLayout(); + this.pgrereg.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); this.SuspendLayout(); // // pnlheader @@ -300,11 +311,104 @@ this.label10.TabIndex = 3; this.label10.Text = "License Agreement"; // + // pgrereg + // + this.pgrereg.Controls.Add(this.tableLayoutPanel2); + this.pgrereg.Controls.Add(this.label11); + this.pgrereg.Dock = System.Windows.Forms.DockStyle.Fill; + this.pgrereg.Location = new System.Drawing.Point(138, 0); + this.pgrereg.Name = "pgrereg"; + this.pgrereg.Size = new System.Drawing.Size(352, 300); + this.pgrereg.TabIndex = 8; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.AutoSize = true; + this.tableLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Controls.Add(this.label7, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.txtruname, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.label8, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.txtrpass, 1, 1); + this.tableLayoutPanel2.Controls.Add(this.label9, 0, 2); + this.tableLayoutPanel2.Controls.Add(this.txtrsys, 1, 2); + this.tableLayoutPanel2.Location = new System.Drawing.Point(20, 61); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 3; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(212, 72); + this.tableLayoutPanel2.TabIndex = 4; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(3, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(58, 13); + this.label7.TabIndex = 0; + this.label7.Text = "Username:"; + // + // txtruname + // + this.txtruname.Location = new System.Drawing.Point(109, 3); + this.txtruname.Name = "txtruname"; + this.txtruname.Size = new System.Drawing.Size(100, 20); + this.txtruname.TabIndex = 1; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(3, 26); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(56, 13); + this.label8.TabIndex = 2; + this.label8.Text = "Password:"; + // + // txtrpass + // + this.txtrpass.Location = new System.Drawing.Point(109, 29); + this.txtrpass.Name = "txtrpass"; + this.txtrpass.PasswordChar = '*'; + this.txtrpass.Size = new System.Drawing.Size(100, 20); + this.txtrpass.TabIndex = 3; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(3, 52); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(75, 13); + this.label9.TabIndex = 4; + this.label9.Text = "System Name:"; + // + // txtrsys + // + this.txtrsys.Location = new System.Drawing.Point(109, 55); + this.txtrsys.Name = "txtrsys"; + this.txtrsys.Size = new System.Drawing.Size(100, 20); + this.txtrsys.TabIndex = 5; + // + // label11 + // + this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); + this.label11.Location = new System.Drawing.Point(16, 9); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(321, 26); + this.label11.TabIndex = 3; + this.label11.Text = "User information"; + // // FakeSetupScreen // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(490, 329); + this.Controls.Add(this.pgrereg); this.Controls.Add(this.page3); this.Controls.Add(this.page4); this.Controls.Add(this.page2); @@ -328,6 +432,10 @@ this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); this.page4.ResumeLayout(false); + this.pgrereg.ResumeLayout(false); + this.pgrereg.PerformLayout(); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -358,5 +466,14 @@ private System.Windows.Forms.Panel page4; private System.Windows.Forms.RichTextBox txtlicenseagreement; private System.Windows.Forms.Label label10; + private System.Windows.Forms.Panel pgrereg; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox txtruname; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox txtrpass; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox txtrsys; + private System.Windows.Forms.Label label11; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/FakeSetupScreen.cs b/ShiftOS.WinForms/FakeSetupScreen.cs index b223cb2..cc38d9b 100644 --- a/ShiftOS.WinForms/FakeSetupScreen.cs +++ b/ShiftOS.WinForms/FakeSetupScreen.cs @@ -18,10 +18,11 @@ namespace ShiftOS.WinForms public Action MUDUserFound = null; - public FakeSetupScreen(Oobe _oobe) + public FakeSetupScreen(Oobe _oobe, int page = 0) { oobe = _oobe; InitializeComponent(); + currentPage = page; SetupUI(); ServerManager.MessageReceived += (msg) => { @@ -133,9 +134,68 @@ So make sure your password is secure enough that it can't be guessed, but easy f CanClose = true; this.Close(); break; + case 7: + btnnext.Show(); + btnback.Hide(); + pgrereg.BringToFront(); + TextType("You have two choices - either you can migrate your local user file to this multi-user domain, or you can restart with 0 Codepoints, no upgrades, and still keep your files."); + break; + case 8: + btnnext.Hide(); + ServerMessageReceived rc = null; + + rc = (msg) => + { + if(msg.Name == "mud_found") + { + TextType("That username and password already exists in this multi-user domain. Please choose another."); + currentPage = 7; + } + else if(msg.Name == "mud_notfound") + { + currentPage = 9; + SetupUI(); + } + ServerManager.MessageReceived -= rc; + }; + + if (string.IsNullOrEmpty(txtruname.Text)) + { + TextType("You must provide a username."); + currentPage = 7; + } + + if (string.IsNullOrEmpty(txtrpass.Text)) + { + TextType("You must provide a password."); + currentPage = 7; + } + + if (string.IsNullOrEmpty(txtrsys.Text)) + { + TextType("You must provide a system hostname."); + currentPage = 7; + } + + if (currentPage == 7) + return; + + ServerManager.MessageReceived += rc; + ServerManager.SendMessage("mud_checkuserexists", $@"{{ + username: ""{txtruname.Text}"", + password: ""{txtrpass.Text}"" +}}"); + break; + case 9: + UserReregistered?.Invoke(txtruname.Text, txtrpass.Text, txtrsys.Text); + this.CanClose = true; + this.Close(); + break; } } + public event Action UserReregistered; + public void StartWipingInBackground(long arbitraryAmountOfBytes) { pgformatprogress.Maximum = (int)arbitraryAmountOfBytes; diff --git a/ShiftOS.WinForms/Oobe.Designer.cs b/ShiftOS.WinForms/Oobe.Designer.cs index cca1522..587f50a 100644 --- a/ShiftOS.WinForms/Oobe.Designer.cs +++ b/ShiftOS.WinForms/Oobe.Designer.cs @@ -96,7 +96,7 @@ namespace ShiftOS.WinForms // this.hackeffecttimer.Interval = 50; // - // HijackScreen + // Oobe // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -104,7 +104,7 @@ namespace ShiftOS.WinForms this.ClientSize = new System.Drawing.Size(653, 457); this.Controls.Add(this.lblhackwords); this.Controls.Add(this.lblHijack); - this.Name = "HijackScreen"; + this.Name = "Oobe"; this.Text = "ShiftOS"; this.TransparencyKey = System.Drawing.Color.White; this.ResumeLayout(false); diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 0a55602..0e249fa 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -215,7 +215,35 @@ namespace ShiftOS.WinForms public void ShowSaveTransfer(Save save) { - throw new NotImplementedException(); + var fSetup = new FakeSetupScreen(this, 7); + + var t = new Thread(() => + { + textgeninput = lblhackwords; + Clear(); + TextType("Welcome back to ShiftOS."); + Thread.Sleep(500); + TextType("Since your last time inside ShiftOS, the operating system has changed. Your user account is no longer stored on your local system."); + Thread.Sleep(500); + this.Invoke(new Action(() => + { + //UPS is drunky heaven over here... it's a liquor store, I think... - Drunk Michael + fSetup.UserReregistered += (u, p, s) => + { + save.Username = u; + save.Password = p; + save.SystemName = s; + SaveSystem.CurrentSave = save; + SaveSystem.SaveGame(); + if(Utils.FileExists(Paths.SaveFileInner)) + Utils.Delete(Paths.SaveFileInner); + this.Close(); + }; + fSetup.Show(); + })); + }); + t.IsBackground = true; + t.Start(); } public void PromptForLogin()