(d9829ac) v0.9.4.0

This commit is contained in:
Regalis
2019-10-24 18:05:42 +02:00
parent 9aa12bcac2
commit b39922a074
319 changed files with 12516 additions and 6815 deletions
@@ -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);
}
}
}