Build 0.20.0.0

This commit is contained in:
Markus Isberg
2022-10-27 17:54:57 +03:00
parent 05c7b1f869
commit edaf4b09fe
197 changed files with 4344 additions and 1773 deletions
@@ -1136,6 +1136,17 @@ namespace Barotrauma
});
AssignRelayToServer("debugdraw", false);
AssignOnExecute("debugdrawlocalization", (string[] args) =>
{
if (args.None() || !bool.TryParse(args[0], out bool state))
{
state = !TextManager.DebugDraw;
}
TextManager.DebugDraw = state;
NewMessage("Localization debug draw mode " + (TextManager.DebugDraw ? "enabled" : "disabled"), Color.White);
});
AssignRelayToServer("debugdraw", false);
AssignOnExecute("togglevoicechatfilters", (string[] args) =>
{
if (args.None() || !bool.TryParse(args[0], out bool state))
@@ -1695,6 +1706,8 @@ namespace Barotrauma
config.Language = language;
GameSettings.SetCurrentConfig(config);
}
HashSet<string> missingTexts = new HashSet<string>();
//key = text tag, value = list of languages the tag is missing from
Dictionary<Identifier, HashSet<LanguageIdentifier>> missingTags = new Dictionary<Identifier, HashSet<LanguageIdentifier>>();
@@ -1755,20 +1768,38 @@ namespace Barotrauma
foreach (Type itemComponentType in typeof(ItemComponent).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ItemComponent))))
{
foreach (var property in itemComponentType.GetProperties())
checkSerializableEntityType(itemComponentType);
}
checkSerializableEntityType(typeof(Item));
checkSerializableEntityType(typeof(Hull));
checkSerializableEntityType(typeof(Structure));
void checkSerializableEntityType(Type t)
{
foreach (var property in t.GetProperties())
{
if (!property.IsDefined(typeof(InGameEditable), false)) { continue; }
if (!property.IsDefined(typeof(Editable), false)) { continue; }
string propertyTag = $"{property.DeclaringType.Name}.{property.Name}";
addIfMissingAll(language,
if (addIfMissingAll(language,
propertyTag.ToIdentifier(),
property.Name.ToIdentifier(),
$"sp.{propertyTag}.name".ToIdentifier());
$"sp.{property.Name}.name".ToIdentifier(),
$"sp.{propertyTag}.name".ToIdentifier()) && language == "English".ToLanguageIdentifier())
{
missingTexts.Add($"<sp.{propertyTag.ToLower()}.name>{property.Name.FormatCamelCaseWithSpaces()}</sp.{propertyTag.ToLower()}.name>");
}
addIfMissingAll(language,
var description = (property.GetCustomAttributes(true).First(a => a is Serialize) as Serialize).Description;
if (addIfMissingAll(language,
$"sp.{propertyTag}.description".ToIdentifier(),
$"{property.Name.ToIdentifier()}.description".ToIdentifier());
$"sp.{property.Name}.description".ToIdentifier(),
$"{property.Name.ToIdentifier()}.description".ToIdentifier()) && language == "English".ToLanguageIdentifier())
{
missingTexts.Add($"<sp.{propertyTag.ToLower()}.description>{description}</sp.{propertyTag.ToLower()}.description>");
}
}
}
@@ -1889,6 +1920,23 @@ namespace Barotrauma
ToolBox.OpenFileWithShell(Path.GetFullPath(filePath));
SwapLanguage(TextManager.DefaultLanguage);
if (missingTexts.Any())
{
ShowQuestionPrompt("Dump the property names and descriptions missing from English to a new xml file? Y/N",
(option) =>
{
if (option.ToLowerInvariant() == "y")
{
string path = "newtexts.txt";
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = true;
File.WriteAllLines(path, missingTexts);
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
ToolBox.OpenFileWithShell(Path.GetFullPath(path));
SwapLanguage(TextManager.DefaultLanguage);
}
});
}
void addIfMissing(Identifier tag, LanguageIdentifier language)
{
if (!tags[language].Contains(tag))
@@ -1897,15 +1945,90 @@ namespace Barotrauma
missingTags[tag].Add(language);
}
}
void addIfMissingAll(LanguageIdentifier language, params Identifier[] potentialTags)
bool addIfMissingAll(LanguageIdentifier language, params Identifier[] potentialTags)
{
if (!potentialTags.Any(t => tags[language].Contains(t)))
{
var tag = potentialTags.First();
if (!missingTags.ContainsKey(tag)) { missingTags[tag] = new HashSet<LanguageIdentifier>(); }
missingTags[tag].Add(language);
return true;
}
return false;
}
}));
commands.Add(new Command("checkduplicateloca", "", (string[] args) =>
{
if (args.Length < 1)
{
ThrowError("Please specify a file path.");
return;
}
XDocument doc1 = XMLExtensions.TryLoadXml(args[0]);
if (doc1?.Root == null)
{
ThrowError($"Could not load the file \"{args[0]}\"");
return;
}
List<(string tag, string text)> texts = new List<(string tag, string text)>();
bool duplicatesFound = false;
foreach (XElement element in doc1.Root.Elements())
{
string tag = element.Name.ToString();
string text = element.ElementInnerText();
if (texts.Any(t => t.tag == tag))
{
ThrowError($"Duplicate tag \"{tag}\".");
duplicatesFound = true;
}
}
if (duplicatesFound)
{
ThrowError($"Aborting, please fix duplicate tags in the file and try again.");
return;
}
foreach (XElement element in doc1.Root.Elements())
{
string tag = element.Name.ToString();
string text = element.ElementInnerText();
if (texts.Any(t => t.text == text))
{
if (tag.StartsWith("sp."))
{
string[] split = tag.Split('.');
if (split.Length > 3)
{
texts.RemoveAll(t => t.text == text);
string newTag = $"sp.{split[2]}.{split[3]}";
texts.Add((newTag, text));
NewMessage($"Duplicate text \"{tag}\", merging to \"{newTag}\".");
}
else
{
NewMessage($"Duplicate text \"{tag}\", using existing one \"{texts.Find(t => t.text == text).tag}\".");
}
}
else
{
texts.Add((tag, text));
ThrowError($"Duplicate text \"{tag}\". Could not determine if the text can be merged with an existing one, please check it manually.");
}
}
else
{
texts.Add((tag, text));
}
}
string filePath = "uniquetexts.xml";
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = true;
File.WriteAllLines(filePath, texts.Select(t => $"<{t.tag}>{t.text}</{t.tag}>"));
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
ToolBox.OpenFileWithShell(Path.GetFullPath(filePath));
}));
commands.Add(new Command("comparelocafiles", "comparelocafiles [file1] [file2]", (string[] args) =>
@@ -2585,99 +2708,6 @@ namespace Barotrauma
}));
#endif
commands.Add(new Command("cleanbuild", "", (string[] args) =>
{
/*GameSettings.CurrentConfig.MusicVolume = 0.5f;
GameSettings.CurrentConfig.SoundVolume = 0.5f;
GameSettings.CurrentConfig.DynamicRangeCompressionEnabled = true;
GameSettings.CurrentConfig.VoipAttenuationEnabled = true;
NewMessage("Music and sound volume set to 0.5", Color.Green);
GameSettings.CurrentConfig.GraphicsWidth = 0;
GameSettings.CurrentConfig.GraphicsHeight = 0;
GameSettings.CurrentConfig.WindowMode = WindowMode.BorderlessWindowed;
NewMessage("Resolution set to 0 x 0 (screen resolution will be used)", Color.Green);
NewMessage("Fullscreen enabled", Color.Green);
GameSettings.CurrentConfig.VerboseLogging = false;
if (GameSettings.CurrentConfig.MasterServerUrl != "http://www.undertowgames.com/baromaster")
{
ThrowError("MasterServerUrl \"" + GameSettings.CurrentConfig.MasterServerUrl + "\"!");
}
GameSettings.SaveCurrentConfig();*/
throw new NotImplementedException();
#warning TODO: reimplement
var saveFiles = Barotrauma.IO.Directory.GetFiles(SaveUtil.SaveFolder);
foreach (string saveFile in saveFiles)
{
Barotrauma.IO.File.Delete(saveFile);
NewMessage("Deleted " + saveFile, Color.Green);
}
if (Barotrauma.IO.Directory.Exists(Barotrauma.IO.Path.Combine(SaveUtil.SaveFolder, "temp")))
{
Barotrauma.IO.Directory.Delete(Barotrauma.IO.Path.Combine(SaveUtil.SaveFolder, "temp"), true);
NewMessage("Deleted temp save folder", Color.Green);
}
if (Barotrauma.IO.Directory.Exists(ServerLog.SavePath))
{
var logFiles = Barotrauma.IO.Directory.GetFiles(ServerLog.SavePath);
foreach (string logFile in logFiles)
{
Barotrauma.IO.File.Delete(logFile);
NewMessage("Deleted " + logFile, Color.Green);
}
}
if (Barotrauma.IO.File.Exists("filelist.xml"))
{
Barotrauma.IO.File.Delete("filelist.xml");
NewMessage("Deleted filelist", Color.Green);
}
if (Barotrauma.IO.File.Exists("Data/bannedplayers.txt"))
{
Barotrauma.IO.File.Delete("Data/bannedplayers.txt");
NewMessage("Deleted bannedplayers.txt", Color.Green);
}
if (Barotrauma.IO.File.Exists("Submarines/TutorialSub.sub"))
{
Barotrauma.IO.File.Delete("Submarines/TutorialSub.sub");
NewMessage("Deleted TutorialSub from the submarine folder", Color.Green);
}
/*if (Barotrauma.IO.File.Exists(GameServer.SettingsFile))
{
Barotrauma.IO.File.Delete(GameServer.SettingsFile);
NewMessage("Deleted server settings", Color.Green);
}
if (Barotrauma.IO.File.Exists(GameServer.ClientPermissionsFile))
{
Barotrauma.IO.File.Delete(GameServer.ClientPermissionsFile);
NewMessage("Deleted client permission file", Color.Green);
}*/
if (Barotrauma.IO.File.Exists("crashreport.log"))
{
Barotrauma.IO.File.Delete("crashreport.log");
NewMessage("Deleted crashreport.log", Color.Green);
}
if (!Barotrauma.IO.File.Exists("Content/Map/TutorialSub.sub"))
{
ThrowError("TutorialSub.sub not found!");
}
}));
commands.Add(new Command("reloadcorepackage", "", (string[] args) =>
{
if (args.Length < 1)