(d2355e315) Added a debug command for finding missing entity name translations, fixed a couple of missing ones
This commit is contained in:
@@ -903,6 +903,26 @@ namespace Barotrauma
|
|||||||
}, isCheat: false));
|
}, isCheat: false));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
commands.Add(new Command("checkmissingloca", "", (string[] args) =>
|
||||||
|
{
|
||||||
|
foreach (MapEntityPrefab me in MapEntityPrefab.List)
|
||||||
|
{
|
||||||
|
string name = TextManager.Get("entityname." + me.Identifier, returnNull: true);
|
||||||
|
if (!string.IsNullOrEmpty(name)) { continue; }
|
||||||
|
|
||||||
|
if (me is ItemPrefab itemPrefab)
|
||||||
|
{
|
||||||
|
string nameIdentifier = itemPrefab.ConfigElement?.GetAttributeString("nameidentifier", "");
|
||||||
|
if (nameIdentifier != null)
|
||||||
|
{
|
||||||
|
name = TextManager.Get("entityname." + nameIdentifier, returnNull: true);
|
||||||
|
if (!string.IsNullOrEmpty(name)) { continue; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NewMessage("Entity name not translated (" + me.Name + ", " + me.Identifier + ")!", me is ItemPrefab ? Color.Red : Color.Yellow);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
commands.Add(new Command("spamchatmessages", "", (string[] args) =>
|
commands.Add(new Command("spamchatmessages", "", (string[] args) =>
|
||||||
{
|
{
|
||||||
int msgCount = 1000;
|
int msgCount = 1000;
|
||||||
@@ -1114,6 +1134,151 @@ namespace Barotrauma
|
|||||||
NPCConversation.WriteToCSV();
|
NPCConversation.WriteToCSV();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (args.Length == 0) return;
|
||||||
|
LocalizationCSVtoXML.Convert(args[0]);
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
commands.Add(new Command("cleanbuild", "", (string[] args) =>
|
||||||
|
{
|
||||||
|
GameMain.Config.MusicVolume = 0.5f;
|
||||||
|
GameMain.Config.SoundVolume = 0.5f;
|
||||||
|
NewMessage("Music and sound volume set to 0.5", Color.Green);
|
||||||
|
|
||||||
|
GameMain.Config.GraphicsWidth = 0;
|
||||||
|
GameMain.Config.GraphicsHeight = 0;
|
||||||
|
GameMain.Config.WindowMode = WindowMode.Fullscreen;
|
||||||
|
NewMessage("Resolution set to 0 x 0 (screen resolution will be used)", Color.Green);
|
||||||
|
NewMessage("Fullscreen enabled", Color.Green);
|
||||||
|
|
||||||
|
GameSettings.ShowUserStatisticsPrompt = true;
|
||||||
|
|
||||||
|
GameSettings.VerboseLogging = false;
|
||||||
|
|
||||||
|
if (GameMain.Config.MasterServerUrl != "http://www.undertowgames.com/baromaster")
|
||||||
|
{
|
||||||
|
ThrowError("MasterServerUrl \"" + GameMain.Config.MasterServerUrl + "\"!");
|
||||||
|
}
|
||||||
|
}, isCheat: false));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GameMain.Config.SaveNewPlayerConfig();
|
||||||
|
|
||||||
|
var saveFiles = System.IO.Directory.GetFiles(SaveUtil.SaveFolder);
|
||||||
|
|
||||||
|
foreach (string saveFile in saveFiles)
|
||||||
|
{
|
||||||
|
lines.Add(element.ElementInnerText());
|
||||||
|
}
|
||||||
|
File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines);
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/"));
|
||||||
|
return new string[][]
|
||||||
|
{
|
||||||
|
TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray()
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) =>
|
||||||
|
{
|
||||||
|
string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt";
|
||||||
|
string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml";
|
||||||
|
|
||||||
|
string[] lines;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lines = File.ReadAllLines(sourcePath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ThrowError("Reading the file \"" + sourcePath + "\" failed.", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var doc = XMLExtensions.TryLoadXml(destinationPath);
|
||||||
|
int i = 0;
|
||||||
|
foreach (XElement element in doc.Root.Elements())
|
||||||
|
{
|
||||||
|
if (i >= lines.Length)
|
||||||
|
{
|
||||||
|
ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.Value = lines[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
doc.Save(destinationPath);
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/"));
|
||||||
|
return new string[][]
|
||||||
|
{
|
||||||
|
files.Where(f => Path.GetExtension(f)==".txt").ToArray(),
|
||||||
|
files.Where(f => Path.GetExtension(f)==".xml").ToArray()
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (args.Length < 2) return;
|
||||||
|
string sourcePath = args[0];
|
||||||
|
string destinationPath = args[1];
|
||||||
|
|
||||||
|
var sourceDoc = XMLExtensions.TryLoadXml(sourcePath);
|
||||||
|
var destinationDoc = XMLExtensions.TryLoadXml(destinationPath);
|
||||||
|
|
||||||
|
XElement destinationElement = destinationDoc.Root.Elements().First();
|
||||||
|
foreach (XElement element in sourceDoc.Root.Elements())
|
||||||
|
{
|
||||||
|
if (destinationDoc.Root.Element(element.Name) == null)
|
||||||
|
{
|
||||||
|
element.Value = "!!!!!!!!!!!!!" + element.Value;
|
||||||
|
destinationElement.AddAfterSelf(element);
|
||||||
|
}
|
||||||
|
XNode nextNode = destinationElement.NextNode;
|
||||||
|
while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode;
|
||||||
|
destinationElement = nextNode as XElement;
|
||||||
|
}
|
||||||
|
destinationDoc.Save(destinationPath);
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray();
|
||||||
|
return new string[][]
|
||||||
|
{
|
||||||
|
files,
|
||||||
|
files
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) =>
|
||||||
|
{
|
||||||
|
string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt";
|
||||||
|
List<string> lines = new List<string>();
|
||||||
|
foreach (MapEntityPrefab me in MapEntityPrefab.List)
|
||||||
|
{
|
||||||
|
lines.Add("<EntityName." + me.Identifier + ">" + me.Name + "</EntityName." + me.Identifier + ">");
|
||||||
|
lines.Add("<EntityDescription." + me.Identifier + ">" + me.Description + "</EntityDescription." + me.Identifier + ">");
|
||||||
|
}
|
||||||
|
File.WriteAllLines(filePath, lines);
|
||||||
|
}));
|
||||||
|
#if DEBUG
|
||||||
|
commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (args.Length != 1) return;
|
||||||
|
TextManager.CheckForDuplicates(args[0]);
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) =>
|
||||||
|
{
|
||||||
|
TextManager.WriteToCSV();
|
||||||
|
NPCConversation.WriteToCSV();
|
||||||
|
}));
|
||||||
|
|
||||||
commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) =>
|
commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) =>
|
||||||
{
|
{
|
||||||
if (args.Length == 0) return;
|
if (args.Length == 0) return;
|
||||||
|
|||||||
@@ -218,22 +218,6 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool RefreshJoinButtonState(GUIComponent component, object obj)
|
|
||||||
{
|
|
||||||
if (obj == null || waitingForRefresh) { return false; }
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(clientNameBox.Text) && !string.IsNullOrWhiteSpace(ipBox.Text))
|
|
||||||
{
|
|
||||||
joinButton.Enabled = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
joinButton.Enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool SelectServer(GUIComponent component, object obj)
|
private bool SelectServer(GUIComponent component, object obj)
|
||||||
{
|
{
|
||||||
if (obj == null || waitingForRefresh) { return false; }
|
if (obj == null || waitingForRefresh) { return false; }
|
||||||
|
|||||||
@@ -424,79 +424,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Language = doc.Root.GetAttributeString("language", "English");
|
Language = doc.Root.GetAttributeString("language", "English");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckBindings(bool useDefaults)
|
|
||||||
{
|
|
||||||
foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
|
|
||||||
{
|
|
||||||
var binding = keyMapping[(int)inputType];
|
|
||||||
if (binding == null)
|
|
||||||
{
|
|
||||||
switch (inputType)
|
|
||||||
{
|
|
||||||
case InputType.Deselect:
|
|
||||||
if (useDefaults)
|
|
||||||
{
|
|
||||||
binding = new KeyOrMouse(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Legacy support
|
|
||||||
var selectKey = keyMapping[(int)InputType.Select];
|
|
||||||
if (selectKey != null && selectKey.Key != Keys.None)
|
|
||||||
{
|
|
||||||
binding = new KeyOrMouse(selectKey.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case InputType.Shoot:
|
|
||||||
if (useDefaults)
|
|
||||||
{
|
|
||||||
binding = new KeyOrMouse(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Legacy support
|
|
||||||
var useKey = keyMapping[(int)InputType.Use];
|
|
||||||
if (useKey != null && useKey.MouseButton.HasValue)
|
|
||||||
{
|
|
||||||
binding = new KeyOrMouse(useKey.MouseButton.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (binding == null)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
|
|
||||||
binding = new KeyOrMouse(Keys.D1);
|
|
||||||
}
|
|
||||||
keyMapping[(int)inputType] = binding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Load DefaultConfig
|
|
||||||
private void LoadDefaultConfig(bool setLanguage = true)
|
|
||||||
{
|
|
||||||
XDocument doc = XMLExtensions.TryLoadXml(savePath);
|
|
||||||
|
|
||||||
if (setLanguage || string.IsNullOrEmpty(Language))
|
|
||||||
{
|
|
||||||
Language = doc.Root.GetAttributeString("language", "English");
|
|
||||||
}
|
|
||||||
|
|
||||||
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
|
||||||
|
|
||||||
AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true);
|
|
||||||
WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", false);
|
|
||||||
|
|
||||||
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false);
|
|
||||||
SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false);
|
|
||||||
|
|
||||||
QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", "");
|
|
||||||
|
|
||||||
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
||||||
|
|
||||||
@@ -959,6 +886,55 @@ namespace Barotrauma
|
|||||||
|
|
||||||
selectedContentPackagePaths = new HashSet<string>();
|
selectedContentPackagePaths = new HashSet<string>();
|
||||||
|
|
||||||
|
foreach (XElement subElement in doc.Root.Elements())
|
||||||
|
{
|
||||||
|
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "keymapping":
|
||||||
|
LoadKeyBinds(subElement);
|
||||||
|
break;
|
||||||
|
case "gameplay":
|
||||||
|
jobPreferences = new List<string>();
|
||||||
|
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||||
|
{
|
||||||
|
string jobIdentifier = ele.GetAttributeString("identifier", "");
|
||||||
|
if (string.IsNullOrEmpty(jobIdentifier)) continue;
|
||||||
|
jobPreferences.Add(jobIdentifier);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "player":
|
||||||
|
defaultPlayerName = subElement.GetAttributeString("name", defaultPlayerName);
|
||||||
|
CharacterHeadIndex = subElement.GetAttributeInt("headindex", CharacterHeadIndex);
|
||||||
|
if (Enum.TryParse(subElement.GetAttributeString("gender", "none"), true, out Gender g))
|
||||||
|
{
|
||||||
|
CharacterGender = g;
|
||||||
|
}
|
||||||
|
if (Enum.TryParse(subElement.GetAttributeString("race", "white"), true, out Race r))
|
||||||
|
{
|
||||||
|
CharacterRace = r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CharacterRace = Race.White;
|
||||||
|
}
|
||||||
|
CharacterHairIndex = subElement.GetAttributeInt("hairindex", CharacterHairIndex);
|
||||||
|
CharacterBeardIndex = subElement.GetAttributeInt("beardindex", CharacterBeardIndex);
|
||||||
|
CharacterMoustacheIndex = subElement.GetAttributeInt("moustacheindex", CharacterMoustacheIndex);
|
||||||
|
CharacterFaceAttachmentIndex = subElement.GetAttributeInt("faceattachmentindex", CharacterFaceAttachmentIndex);
|
||||||
|
break;
|
||||||
|
case "tutorials":
|
||||||
|
foreach (XElement tutorialElement in subElement.Elements())
|
||||||
|
{
|
||||||
|
CompletedTutorialNames.Add(tutorialElement.GetAttributeString("name", ""));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UnsavedSettings = false;
|
||||||
|
|
||||||
|
selectedContentPackagePaths = new HashSet<string>();
|
||||||
|
|
||||||
foreach (XElement subElement in doc.Root.Elements())
|
foreach (XElement subElement in doc.Root.Elements())
|
||||||
{
|
{
|
||||||
gSettings = new XElement("graphicssettings");
|
gSettings = new XElement("graphicssettings");
|
||||||
|
|||||||
Reference in New Issue
Block a user