Merge remote-tracking branch 'upstream/dev' into develop
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Barotrauma
|
||||
|
||||
public void ClientExecute(string[] args)
|
||||
{
|
||||
bool allowCheats = GameMain.NetworkMember == null && (GameMain.GameSession?.GameMode is TestGameMode || Screen.Selected is EditorScreen);
|
||||
bool allowCheats = GameMain.NetworkMember == null && (GameMain.GameSession?.GameMode is TestGameMode || Screen.Selected is { IsEditor: true });
|
||||
if (!allowCheats && !CheatsEnabled && IsCheat)
|
||||
{
|
||||
NewMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + names[0] + "\".", Color.Red);
|
||||
@@ -128,21 +128,17 @@ namespace Barotrauma
|
||||
|
||||
public static void Update(float deltaTime)
|
||||
{
|
||||
lock (queuedMessages)
|
||||
while (queuedMessages.TryDequeue(out var newMsg))
|
||||
{
|
||||
while (queuedMessages.Count > 0)
|
||||
{
|
||||
var newMsg = queuedMessages.Dequeue();
|
||||
AddMessage(newMsg);
|
||||
AddMessage(newMsg);
|
||||
|
||||
if (GameSettings.CurrentConfig.SaveDebugConsoleLogs || GameSettings.CurrentConfig.VerboseLogging)
|
||||
if (GameSettings.CurrentConfig.SaveDebugConsoleLogs || GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
unsavedMessages.Add(newMsg);
|
||||
if (unsavedMessages.Count >= messagesPerFile)
|
||||
{
|
||||
unsavedMessages.Add(newMsg);
|
||||
if (unsavedMessages.Count >= messagesPerFile)
|
||||
{
|
||||
SaveLogs();
|
||||
unsavedMessages.Clear();
|
||||
}
|
||||
SaveLogs();
|
||||
unsavedMessages.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,9 +174,9 @@ namespace Barotrauma
|
||||
|
||||
Character.DisableControls = true;
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Tab))
|
||||
if (PlayerInput.KeyHit(Keys.Tab) && !textBox.IsIMEActive)
|
||||
{
|
||||
textBox.Text = AutoComplete(textBox.Text, increment: string.IsNullOrEmpty(currentAutoCompletedCommand) ? 0 : 1 );
|
||||
textBox.Text = AutoComplete(textBox.Text, increment: string.IsNullOrEmpty(currentAutoCompletedCommand) ? 0 : 1 );
|
||||
}
|
||||
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl))
|
||||
@@ -260,25 +256,21 @@ namespace Barotrauma
|
||||
|
||||
public static void DequeueMessages()
|
||||
{
|
||||
lock (queuedMessages)
|
||||
while (queuedMessages.TryDequeue(out var newMsg))
|
||||
{
|
||||
while (queuedMessages.Count > 0)
|
||||
if (listBox == null)
|
||||
{
|
||||
var newMsg = queuedMessages.Dequeue();
|
||||
if (listBox == null)
|
||||
{
|
||||
//don't attempt to add to the listbox if it hasn't been created yet
|
||||
Messages.Add(newMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMessage(newMsg);
|
||||
}
|
||||
//don't attempt to add to the listbox if it hasn't been created yet
|
||||
Messages.Add(newMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMessage(newMsg);
|
||||
}
|
||||
|
||||
if (GameSettings.CurrentConfig.SaveDebugConsoleLogs || GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
unsavedMessages.Add(newMsg);
|
||||
}
|
||||
if (GameSettings.CurrentConfig.SaveDebugConsoleLogs || GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
unsavedMessages.Add(newMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1138,6 +1130,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))
|
||||
@@ -1697,6 +1700,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>>();
|
||||
@@ -1757,20 +1762,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>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1794,7 +1817,18 @@ namespace Barotrauma
|
||||
|
||||
Identifier afflictionId = affliction.TranslationIdentifier;
|
||||
addIfMissing($"afflictionname.{afflictionId}".ToIdentifier(), language);
|
||||
addIfMissing($"afflictiondescription.{afflictionId}".ToIdentifier(), language);
|
||||
|
||||
if (affliction.Descriptions.Any())
|
||||
{
|
||||
foreach (var description in affliction.Descriptions)
|
||||
{
|
||||
addIfMissing(description.TextTag, language);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addIfMissing($"afflictiondescription.{afflictionId}".ToIdentifier(), language);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var talentTree in TalentTree.JobTalentTrees)
|
||||
@@ -1891,6 +1925,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))
|
||||
@@ -1899,15 +1950,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) =>
|
||||
@@ -2087,6 +2213,15 @@ namespace Barotrauma
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("spawnallitems", "", (string[] args) =>
|
||||
{
|
||||
var cursorPos = Screen.Selected.Cam?.ScreenToWorld(PlayerInput.MousePosition) ?? Vector2.Zero;
|
||||
foreach (ItemPrefab itemPrefab in ItemPrefab.Prefabs)
|
||||
{
|
||||
Entity.Spawner?.AddItemToSpawnQueue(itemPrefab, cursorPos);
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) =>
|
||||
{
|
||||
float defaultZoom = Screen.Selected.Cam.DefaultZoom;
|
||||
@@ -2587,99 +2722,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)
|
||||
|
||||
Reference in New Issue
Block a user