(e3fee50d9) Use roughly matching "fallback translations" for ConnectionPanel texts that haven't been translated yet (e.g. "signal_1" -> "signal_in_1", "trigger_out" -> "shoot"). Still missing the charge-related connection names in batteries, couldn't find any suitable replacements for them
This commit is contained in:
@@ -79,8 +79,59 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
wires = new Wire[MaxLinked];
|
||||
|
||||
IsOutput = (element.Name.ToString() == "output");
|
||||
Name = element.GetAttributeString("name", (IsOutput) ? "output" : "input");
|
||||
IsOutput = element.Name.ToString() == "output";
|
||||
Name = element.GetAttributeString("name", IsOutput ? "output" : "input");
|
||||
|
||||
string displayNameTag = "", fallbackTag = "";
|
||||
//if displayname is not present, attempt to find it from the prefab
|
||||
if (element.Attribute("displayname") == null)
|
||||
{
|
||||
foreach (XElement subElement in item.Prefab.ConfigElement.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "connectionpanel") { continue; }
|
||||
|
||||
foreach (XElement connectionElement in subElement.Elements())
|
||||
{
|
||||
if (connectionElement.Name.ToString() != element.Name.ToString()) { continue; }
|
||||
|
||||
string prefabConnectionName = element.GetAttributeString("name", IsOutput ? "output" : "input");
|
||||
if (prefabConnectionName == Name)
|
||||
{
|
||||
displayNameTag = connectionElement.GetAttributeString("displayname", "");
|
||||
fallbackTag = connectionElement.GetAttributeString("fallbackdisplayname", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
displayNameTag = element.GetAttributeString("displayname", "");
|
||||
fallbackTag = element.GetAttributeString("fallbackdisplayname", null);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(displayNameTag))
|
||||
{
|
||||
//extract the tag parts in case the tags contains variables
|
||||
string tagWithoutVariables = displayNameTag?.Split('~')?.FirstOrDefault();
|
||||
string fallbackTagWithoutVariables = fallbackTag?.Split('~')?.FirstOrDefault();
|
||||
//use displayNameTag if found, otherwise fallBack
|
||||
if (TextManager.ContainsTag(tagWithoutVariables))
|
||||
{
|
||||
DisplayName = TextManager.GetServerMessage(displayNameTag);
|
||||
}
|
||||
else if (TextManager.ContainsTag(fallbackTagWithoutVariables))
|
||||
{
|
||||
DisplayName = TextManager.GetServerMessage(fallbackTag);
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(DisplayName))
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Missing display name in connection " + item.Name + ": " + Name);
|
||||
#endif
|
||||
DisplayName = Name;
|
||||
}
|
||||
|
||||
//if displayname is not present, attempt to find it from the prefab
|
||||
if (element.Attribute("displayname") == null)
|
||||
|
||||
Reference in New Issue
Block a user