(8ba0db51b) Load connection displaynames from the prefab xml if not present in a sub or itemassembly xml, use display names in the connection panel interface

This commit is contained in:
Joonas Rikkonen
2019-05-16 06:04:24 +03:00
parent c73fe6e132
commit 4b9fbe596c
13 changed files with 241 additions and 261 deletions
@@ -82,9 +82,36 @@ namespace Barotrauma.Items.Components
IsOutput = (element.Name.ToString() == "output");
Name = element.GetAttributeString("name", (IsOutput) ? "output" : "input");
DisplayName = element.Attributes("displayname") == null ?
Name :
TextManager.GetServerMessage(element.GetAttributeString("displayname", Name));
//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)
{
DisplayName = TextManager.GetServerMessage(connectionElement.GetAttributeString("displayname", Name));
}
}
}
#if DEBUG
if (string.IsNullOrEmpty(DisplayName))
{
DebugConsole.ThrowError("Missing display name in connection " + item.Name + ": " + Name);
}
#endif
}
else
{
DisplayName = TextManager.GetServerMessage(element.GetAttributeString("displayname", Name));
}
IsPower = Name == "power_in" || Name == "power" || Name == "power_out";