Creation of new games is possible again!

This commit is contained in:
Michael 2017-06-11 17:58:35 -04:00
parent 7ec048fe85
commit c0017e35a4
9 changed files with 91 additions and 340 deletions

View file

@ -624,7 +624,7 @@ Your goal: Earn 1,000 Codepoints.");
{
if (AppearanceManager.OpenForms.Count <= 1)
{
Console.WriteLine("");
//Console.WriteLine("");
Console.WriteLine("{WIN_CANTCLOSETERMINAL}");
try
{

View file

@ -63,6 +63,7 @@ namespace ShiftOS.WinForms.Controls
public void Write(string text)
{
Thread.Sleep(5);
this.HideSelection = true;
this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor);
this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor);
@ -86,6 +87,7 @@ namespace ShiftOS.WinForms.Controls
public void WriteLine(string text)
{
Thread.Sleep(5);
Engine.AudioManager.PlayStream(Properties.Resources.writesound);
this.HideSelection = true;
this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor);

View file

@ -194,137 +194,14 @@ namespace ShiftOS.WinForms
}
[Obsolete("Unite code stub.")]
public void PromptForLogin()
{
Infobox.Show("Login", "Since the last time you've played ShiftOS, some changes have been made to the login system. You must now login using your website credentials.", () =>
{
Infobox.PromptYesNo("Website account", "Do you have an account at http://getshiftos.ml?", (hasAccount) =>
{
if(hasAccount == true)
{
var loginDialog = new UniteLoginDialog((success)=>
{
string token = success;
var uClient = new UniteClient("http://getshiftos.ml", token);
Infobox.Show("Welcome to ShiftOS.", $"Hello, {uClient.GetDisplayName()}! We've signed you into your account. We'll now try to link your ShiftOS account with your save file.", () =>
{
ServerMessageReceived smr = null;
smr = (msg) =>
{
if (msg.Name == "mud_savefile")
{
ServerManager.MessageReceived -= smr;
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
SaveSystem.SaveGame();
}
else if(msg.Name=="mud_login_denied")
{
ServerManager.MessageReceived -= smr;
LinkSaveFile(token);
}
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("mud_token_login", token);
});
});
AppearanceManager.SetupDialog(loginDialog);
}
else
{
var signupDialog = new UniteSignupDialog((token) =>
{
ServerMessageReceived smr = null;
smr = (msg) =>
{
ServerManager.MessageReceived -= smr;
if (msg.Name == "mud_savefile")
{
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
SaveSystem.SaveGame();
}
else if (msg.Name == "mud_login_denied")
{
LinkSaveFile(token);
}
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("mud_token_login", token);
});
AppearanceManager.SetupDialog(signupDialog);
}
});
});
}
[Obsolete("Unite code stub.")]
public void LinkSaveFile(string token)
{
if (Utils.FileExists(Paths.GetPath("user.dat")))
{
try
{
var details = JsonConvert.DeserializeObject<ClientSave>(Utils.ReadAllText(Paths.GetPath("user.dat")));
ServerMessageReceived smr = null;
bool msgreceived = false;
bool found = false;
smr = (msg) =>
{
if (msg.Name == "mud_savefile")
{
var save = JsonConvert.DeserializeObject<Save>(msg.Contents);
save.UniteAuthToken = token;
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 if (msg.Name == "mud_login_denied")
{
found = false;
msgreceived = true;
}
ServerManager.MessageReceived -= smr;
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new
{
username = details.Username,
password = details.Password
}));
while (msgreceived == false)
Thread.Sleep(10);
if (found == true)
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<string, bool>();
sve.ID = Guid.NewGuid();
sve.StoriesExperienced = new List<string>();
sve.StoriesExperienced.Add("mud_fundamentals");
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;
Shiftorium.Silent = true;
SaveSystem.SaveGame();
Shiftorium.Silent = false;
});
}
public void ForceReboot()

View file

@ -143,7 +143,37 @@ namespace ShiftOS.WinForms
Console.WriteLine();
Console.WriteLine("Next, let's get user information.");
Console.WriteLine();
ShiftOS.Engine.OutOfBoxExperience.PromptForLogin();
Desktop.InvokeOnWorkerThread(() =>
{
var uSignUpDialog = new UniteSignupDialog((result) =>
{
var sve = new Save();
sve.SystemName = result.SystemName;
sve.Codepoints = 0;
sve.Upgrades = new Dictionary<string, bool>();
sve.ID = Guid.NewGuid();
sve.StoriesExperienced = new List<string>();
sve.StoriesExperienced.Add("mud_fundamentals");
sve.Users = new List<ClientSave>
{
new ClientSave
{
Username = "root",
Password = result.RootPassword,
Permissions = 0
}
};
sve.StoryPosition = 8675309;
SaveSystem.CurrentSave = sve;
Shiftorium.Silent = true;
SaveSystem.SaveGame();
Shiftorium.Silent = false;
});
AppearanceManager.SetupDialog(uSignUpDialog);
});
}
private static bool isValid(string text, string chars)

View file

@ -28,165 +28,83 @@
/// </summary>
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.txtsys = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.txtsysname = new System.Windows.Forms.TextBox();
this.txtroot = new System.Windows.Forms.TextBox();
this.label7 = 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, 479);
this.btnlogin.Location = new System.Drawing.Point(462, 168);
this.btnlogin.Name = "btnlogin";
this.btnlogin.Size = new System.Drawing.Size(75, 23);
this.btnlogin.TabIndex = 11;
this.btnlogin.Text = "Submit";
this.btnlogin.Text = "{UI_SUBMIT}";
this.btnlogin.UseVisualStyleBackColor = true;
this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click);
//
// 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(120, 13);
this.label1.Size = new System.Drawing.Size(169, 13);
this.label1.TabIndex = 6;
this.label1.Tag = "header2";
this.label1.Text = "Create ShiftOS Account";
this.label1.Text = "{INIT_SYSTEM_PREPARATION}";
//
// txtconfirm
// txtsys
//
this.txtconfirm.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.txtsys.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;
this.txtsys.Location = new System.Drawing.Point(113, 100);
this.txtsys.Name = "txtsys";
this.txtsys.Size = new System.Drawing.Size(424, 20);
this.txtsys.TabIndex = 15;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(17, 200);
this.label5.Location = new System.Drawing.Point(17, 103);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(73, 13);
this.label5.Size = new System.Drawing.Size(116, 13);
this.label5.TabIndex = 14;
this.label5.Text = "Display name:";
this.label5.Text = "{SE_SYSTEM_NAME}";
//
// label6
// txtroot
//
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
this.txtroot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label6.Location = new System.Drawing.Point(20, 267);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(517, 209);
this.label6.TabIndex = 16;
this.label6.Text = resources.GetString("label6.Text");
//
// txtsysname
//
this.txtsysname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtsysname.Location = new System.Drawing.Point(113, 223);
this.txtsysname.Name = "txtsysname";
this.txtsysname.Size = new System.Drawing.Size(424, 20);
this.txtsysname.TabIndex = 18;
this.txtroot.Location = new System.Drawing.Point(113, 126);
this.txtroot.Name = "txtroot";
this.txtroot.Size = new System.Drawing.Size(424, 20);
this.txtroot.TabIndex = 18;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(17, 226);
this.label7.Location = new System.Drawing.Point(17, 129);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(73, 13);
this.label7.Size = new System.Drawing.Size(135, 13);
this.label7.TabIndex = 17;
this.label7.Text = "System name:";
this.label7.Text = "{SE_ROOT_PASSWORD}";
//
// UniteSignupDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.txtsysname);
this.Controls.Add(this.txtroot);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.txtdisplay);
this.Controls.Add(this.txtsys);
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, 519);
this.Size = new System.Drawing.Size(555, 208);
this.ResumeLayout(false);
this.PerformLayout();
@ -195,17 +113,10 @@
#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.TextBox txtsys;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtsysname;
private System.Windows.Forms.TextBox txtroot;
private System.Windows.Forms.Label label7;
}
}

View file

@ -16,13 +16,19 @@ namespace ShiftOS.WinForms
{
public partial class UniteSignupDialog : UserControl, IShiftOSWindow
{
public UniteSignupDialog(Action<string> callback)
public class SignupCredentials
{
public string SystemName { get; set; }
public string RootPassword { get; set; }
}
public UniteSignupDialog(Action<SignupCredentials> callback)
{
InitializeComponent();
Callback = callback;
}
private Action<string> Callback { get; set; }
private Action<SignupCredentials> Callback { get; set; }
public void OnLoad()
@ -45,92 +51,25 @@ namespace ShiftOS.WinForms
private void btnlogin_Click(object sender, EventArgs e)
{
string u = txtusername.Text;
string p = txtpassword.Text;
string sys = txtsys.Text;
string root = txtroot.Text;
if (string.IsNullOrWhiteSpace(u))
if (string.IsNullOrWhiteSpace(sys))
{
Infobox.Show("Please enter a username.", "You must enter a proper email address.");
Infobox.Show("{TITLE_EMPTY_SYSNAME}", "{MSG_EMPTY_SYSNAME}");
return;
}
if(sys.Length < 5)
{
Infobox.Show("{TITLE_VALIDATION_ERROR}", "{MSG_VALIDATION_ERROR_SYSNAME_LENGTH}");
return;
}
if (string.IsNullOrWhiteSpace(p))
Callback?.Invoke(new SignupCredentials
{
Infobox.Show("Please enter a password.", "You must enter a valid password.");
return;
}
if(p != txtconfirm.Text)
{
Infobox.Show("Passwords don't match.", "The \"Password\" and \"Confirm\" boxes must match.");
return;
}
if (string.IsNullOrWhiteSpace(txtdisplay.Text))
{
Infobox.Show("Empty display name", "Please choose a proper display name.");
return;
}
if (string.IsNullOrWhiteSpace(txtsysname.Text))
{
Infobox.Show("Empty system name", "Please name your computer!");
return;
}
if(p.Length < 7)
{
Infobox.Show("Password error", "Your password must have at least 7 characters.");
return;
}
if (!(p.Any(char.IsUpper) &&
p.Any(char.IsLower) &&
p.Any(char.IsDigit)))
{
Infobox.Show("Password error", "Your password must contain at least one uppercase, lowercase, digit and symbol character.");
return;
}
if (!u.Contains("@"))
{
Infobox.Show("Valid email required.", "You must specify a valid email address.");
return;
}
try
{
var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text);
string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}"));
webrequest.Headers.Add("Authentication: Basic " + base64);
var response = webrequest.GetResponse();
var str = response.GetResponseStream();
var reader = new System.IO.StreamReader(str);
string result = reader.ReadToEnd();
if (result.StartsWith("{"))
{
var exc = JsonConvert.DeserializeObject<Exception>(result);
Infobox.Show("Error", exc.Message);
return;
}
reader.Close();
str.Close();
str.Dispose();
response.Dispose();
Callback?.Invoke(result);
AppearanceManager.Close(this);
}
#if DEBUG
catch (Exception ex)
{
Infobox.Show("Error", ex.ToString());
}
#else
catch
{
Infobox.Show("Login failed.", "The login attempt failed due to an incorrect username and password pair.");
}
#endif
SystemName = sys,
RootPassword = root
});
}
}

View file

@ -117,15 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label6.Text" xml:space="preserve">
<value>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.</value>
</data>
</root>

View file

@ -527,8 +527,10 @@ namespace ShiftOS.Engine
{
try
{
Story.Start(CurrentSave.PickupPoint);
TerminalBackend.PrintPrompt();
if (Story.Context == null)
{
Story.Start(CurrentSave.PickupPoint);
}
}
catch { }
}

View file

@ -109,6 +109,7 @@ namespace ShiftOS.Engine
{
Thread.Sleep(5000);
}
Thread.Sleep(500);
CurrentObjectives.Remove(obj);
obj.Complete();
});