Pausing all sounds when switching to editor screen, temp save folder is cleared before saving (fixes unnecessary files being included in saves)

This commit is contained in:
Regalis
2016-12-13 23:10:52 +02:00
parent 6a189c6ec4
commit 73eb6a2f1b
2 changed files with 37 additions and 2 deletions

View File

@@ -314,6 +314,10 @@ namespace Barotrauma
}
SoundPlayer.OverrideMusicType = "none";
for (int i = 0; i < Sounds.SoundManager.DefaultSourceCount; i++)
{
Sounds.SoundManager.Pause(i);
}
cam.UpdateTransform();
}
@@ -333,6 +337,10 @@ namespace Barotrauma
if (wiringMode) ToggleWiringMode();
SoundPlayer.OverrideMusicType = null;
for (int i = 0; i < Sounds.SoundManager.DefaultSourceCount; i++)
{
Sounds.SoundManager.Resume(i);
}
if (dummyCharacter != null)
{

View File

@@ -22,9 +22,19 @@ namespace Barotrauma
fileName = Path.Combine(SaveFolder, fileName);
string tempPath = Path.Combine(SaveFolder, "temp");
Directory.CreateDirectory(tempPath);
DirectoryInfo dir = new DirectoryInfo(tempPath);
Directory.CreateDirectory(tempPath);
try
{
ClearFolder(tempPath);
}
catch
{
}
try
{
if (Submarine.MainSub != null)
@@ -274,5 +284,22 @@ namespace Barotrauma
using (GZipStream zipStream = new GZipStream(inFile, CompressionMode.Decompress, true))
while (DecompressFile(sDir, zipStream, progress)) ;
}
private static void ClearFolder(string FolderName)
{
DirectoryInfo dir = new DirectoryInfo(FolderName);
foreach (FileInfo fi in dir.GetFiles())
{
fi.IsReadOnly = false;
fi.Delete();
}
foreach (DirectoryInfo di in dir.GetDirectories())
{
ClearFolder(di.FullName);
di.Delete();
}
}
}
}