(d9829ac) v0.9.4.0
This commit is contained in:
@@ -119,6 +119,7 @@ namespace Barotrauma
|
||||
DecompressToDirectory(filePath, TempPath, null);
|
||||
|
||||
XDocument doc = XMLExtensions.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||
if (doc == null) { return; }
|
||||
|
||||
string subPath = Path.Combine(TempPath, doc.Root.GetAttributeString("submarine", "")) + ".sub";
|
||||
Submarine selectedSub = new Submarine(subPath, "");
|
||||
@@ -130,6 +131,7 @@ namespace Barotrauma
|
||||
DebugConsole.Log("Loading save file for an existing game session (" + filePath + ")");
|
||||
DecompressToDirectory(filePath, TempPath, null);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||
if (doc == null) { return; }
|
||||
gameSession.Load(doc.Root);
|
||||
}
|
||||
|
||||
@@ -303,12 +305,6 @@ namespace Barotrauma
|
||||
|
||||
public static Stream DecompressFiletoStream(string fileName)
|
||||
{
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
DebugConsole.ThrowError("File \"" + fileName + " doesn't exist!");
|
||||
return null;
|
||||
}
|
||||
|
||||
using (FileStream originalFileStream = new FileStream(fileName, FileMode.Open))
|
||||
{
|
||||
MemoryStream decompressedFileStream = new MemoryStream();
|
||||
|
||||
@@ -140,6 +140,15 @@ namespace Barotrauma
|
||||
return fileName;
|
||||
}
|
||||
|
||||
private static System.Text.RegularExpressions.Regex removeBBCodeRegex =
|
||||
new System.Text.RegularExpressions.Regex(@"\[\/?(?:b|i|u|url|quote|code|img|color|size)*?.*?\]");
|
||||
|
||||
public static string RemoveBBCodeTags(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) { return str; }
|
||||
return removeBBCodeRegex.Replace(str, "");
|
||||
}
|
||||
|
||||
public static string LimitString(string str, int maxCharacters)
|
||||
{
|
||||
if (str == null || maxCharacters < 0) return null;
|
||||
@@ -418,5 +427,14 @@ namespace Barotrauma
|
||||
hex.AppendFormat("{0:x2}", b);
|
||||
return hex.ToString();
|
||||
}
|
||||
|
||||
public static string ConvertAbsoluteToRelativePath(string path)
|
||||
{
|
||||
string[] splitted = path.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
|
||||
string currentFolder = Environment.CurrentDirectory.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }).Last();
|
||||
// Filter out the current folder -> result is "Content/blaahblaah" or "Mods/blaahblaah" etc.
|
||||
IEnumerable<string> filtered = splitted.SkipWhile(part => part != currentFolder).Skip(1);
|
||||
return string.Join("/", filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user