From 2bd4a815d327c5035c13074e01ff23fde49e2a56 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 23 Feb 2017 16:25:29 -0500 Subject: [PATCH] Fix savesystem oddities. --- ShiftOS_TheReturn/Commands.cs | 32 +++++++++++++++++++++++++++++--- ShiftOS_TheReturn/SaveSystem.cs | 5 +---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index f58ceff..488d843 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -591,11 +591,11 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); [Command("list")] public static bool List() { - Console.WriteLine("{ID}\t{WINDOW}"); + Console.WriteLine("Window ID\tName"); foreach (var app in AppearanceManager.OpenForms) { - //All .NET object instances have a unique hash code. Good for fake process management. - Console.WriteLine($"{app.GetHashCode()}\t{app.Text}"); + //Windows are displayed the order in which they were opened. + Console.WriteLine($"{AppearanceManager.OpenForms.IndexOf(app)}\t{app.Text}"); } return true; } @@ -702,6 +702,32 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); } } + [RemoteLock] + [Command("close", usage = "{win:integer32}", description ="Closes the specified window.")] + [RequiresArgument("win")] + [RequiresUpgrade("close_command")] + public static bool CloseWindow(Dictionary args) + { + int winNum = -1; + if (args.ContainsKey("win")) + winNum = Convert.ToInt32(args["win"].ToString()); + string err = null; + + if (winNum < 0 || winNum >= AppearanceManager.OpenForms.Count) + err = "The window number must be between 0 and " + (AppearanceManager.OpenForms.Count - 1).ToString() + "."; + + if (string.IsNullOrEmpty(err)) + { + Console.WriteLine($"Closing {AppearanceManager.OpenForms[winNum].Text}..."); + AppearanceManager.Close(AppearanceManager.OpenForms[winNum].ParentWindow); + } + else + { + Console.WriteLine(err); + } + + return true; + } } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index ec3c3b3..fb7070a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -288,14 +288,11 @@ namespace ShiftOS.Engine string username = CurrentSave.Username; string password = CurrentSave.Password; - if (!Utils.FileExists(Paths.GetPath("user.dat"))) - { Utils.WriteAllText(Paths.GetPath("user.dat"), $@"{{ username: ""{username}"", password: ""{password}"" }}"); - } - + ServerManager.SendMessage("mud_save", JsonConvert.SerializeObject(CurrentSave, Formatting.Indented)); } if (!Shiftorium.Silent)