From c3deaa23fffb7011efb2b5b0f7fc3e754d21f600 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 10 Jun 2017 22:02:10 -0400 Subject: Even more menu work. --- ShiftOS_TheReturn/AudioManager.cs | 4 ++++ ShiftOS_TheReturn/Paths.cs | 9 +++++++++ ShiftOS_TheReturn/SaveSystem.cs | 41 +++++++++++++++++++++------------------ 3 files changed, 35 insertions(+), 19 deletions(-) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 0a1a210..0950b55 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -125,6 +125,10 @@ namespace ShiftOS.Engine } if (play) { + while(_out.PlaybackState == PlaybackState.Playing) + { + Thread.Sleep(10); + } ShiftOS.Engine.AudioManager.Stop(); _out = new WaveOut(); var mp3 = new WaveFileReader(str); diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index 5b75ae6..332cdd3 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -94,6 +94,15 @@ namespace ShiftOS.Engine } + public static string SaveDirectory + { + get + { + string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + return System.IO.Path.Combine(appdata, "ShiftOS", "saves"); + } + } + /// /// Gets all full paths without their keynames. /// diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index c5a6a51..18f8f78 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -575,14 +575,14 @@ namespace ShiftOS.Engine public static void ReadSave() { //Migrate old saves. - if(System.IO.Directory.Exists("C:\\ShiftOS2")) + if (System.IO.Directory.Exists("C:\\ShiftOS2")) { Console.WriteLine("Old save detected. Migrating filesystem to MFS..."); foreach (string file in System.IO.Directory.EnumerateDirectories("C:\\ShiftOS2") .Select(d => new DirectoryInfo(d).FullName)) { - if(!Utils.DirectoryExists(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"))) - Utils.CreateDirectory(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/")); + if (!Utils.DirectoryExists(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"))) + Utils.CreateDirectory(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/")); } foreach (string file in System.IO.Directory.EnumerateFiles("C:\\ShiftOS2")) { @@ -594,25 +594,18 @@ namespace ShiftOS.Engine } + string path = Path.Combine(Paths.SaveDirectory, "autosave.save"); - if (Utils.FileExists(Paths.SaveFileInner)) + if (System.IO.File.Exists(Path.Combine(Paths.SaveDirectory, "autosave.save"))) { - oobe.ShowSaveTransfer(JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.SaveFileInner))); + CurrentSave = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(path)); } else { - if (Utils.FileExists(Paths.GetPath("user.dat"))) - { - string token = Utils.ReadAllText(Paths.GetPath("user.dat")); - - ServerManager.SendMessage("mud_token_login", token); - } - else - { - NewSave(); - } + NewSave(); } + } /// @@ -644,15 +637,25 @@ namespace ShiftOS.Engine Console.Write("{SE_SAVING}... "); if (SaveSystem.CurrentSave != null) { - Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken); var serialisedSaveFile = JsonConvert.SerializeObject(CurrentSave, Formatting.Indented); new Thread(() => { - // please don't do networking on the main thread if you're just going to - // discard the response, it's extremely slow - ServerManager.SendMessage("mud_save", serialisedSaveFile); + try + { + // please don't do networking on the main thread if you're just going to + // discard the response, it's extremely slow + ServerManager.SendMessage("mud_save", serialisedSaveFile); + } + catch { } }) { IsBackground = false }.Start(); + if (!System.IO.Directory.Exists(Paths.SaveDirectory)) + { + System.IO.Directory.CreateDirectory(Paths.SaveDirectory); + + } + + System.IO.File.WriteAllText(Path.Combine(Paths.SaveDirectory, "autosave.save"), serialisedSaveFile); } if (!Shiftorium.Silent) Console.WriteLine(" ...{DONE}."); -- cgit v1.2.3