aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-10 22:02:10 -0400
committerMichael <[email protected]>2017-06-10 22:02:10 -0400
commitc3deaa23fffb7011efb2b5b0f7fc3e754d21f600 (patch)
tree4e1cb7c846de1dd454c813eb8e49119a6ef54c70 /ShiftOS_TheReturn
parent920e33a2fd329ccbdfeb38ddedd0b4d87e97ed86 (diff)
downloadshiftos_thereturn-c3deaa23fffb7011efb2b5b0f7fc3e754d21f600.tar.gz
shiftos_thereturn-c3deaa23fffb7011efb2b5b0f7fc3e754d21f600.tar.bz2
shiftos_thereturn-c3deaa23fffb7011efb2b5b0f7fc3e754d21f600.zip
Even more menu work.
Diffstat (limited to 'ShiftOS_TheReturn')
-rw-r--r--ShiftOS_TheReturn/AudioManager.cs4
-rw-r--r--ShiftOS_TheReturn/Paths.cs9
-rw-r--r--ShiftOS_TheReturn/SaveSystem.cs41
3 files changed, 35 insertions, 19 deletions
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");
+ }
+ }
+
/// <summary>
/// Gets all full paths without their keynames.
/// </summary>
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<Save>(Utils.ReadAllText(Paths.SaveFileInner)));
+ CurrentSave = JsonConvert.DeserializeObject<Save>(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();
}
+
}
/// <summary>
@@ -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}.");