Unstable v0.19.3.0

This commit is contained in:
Juan Pablo Arce
2022-09-02 15:10:56 -03:00
parent 28789616bd
commit 3f2c843247
336 changed files with 7152 additions and 7739 deletions
@@ -155,7 +155,7 @@ namespace Barotrauma.Items.Components
{
//use semicolon as a separator because comma may be needed in the signals (for color or vector values for example)
//kind of hacky, we should probably add support for (string) arrays to SerializableEntityEditor so this wouldn't be needed
get { return signals == null ? "" : string.Join(";", signals); }
get { return signals == null ? string.Empty : string.Join(";", signals); }
set
{
if (value == null) { return; }
@@ -167,7 +167,31 @@ namespace Barotrauma.Items.Components
}
}
public override bool RecreateGUIOnResolutionChange => true;
private bool[] elementStates;
[Serialize("", IsPropertySaveable.Yes, description: "", alwaysUseInstanceValues: true)]
public string ElementStates
{
get { return elementStates == null ? string.Empty : string.Join(",", elementStates); }
set
{
if (value == null) { return; }
if (customInterfaceElementList.Count > 0)
{
string[] splitValues = value == "" ? Array.Empty<string>() : value.Split(',');
for (int i = 0; i < customInterfaceElementList.Count && i < splitValues.Length; i++)
{
if (!bool.TryParse(splitValues[i], out bool val)) { continue; }
customInterfaceElementList[i].State = val;
#if CLIENT
if (uiElements != null && i < uiElements.Count && uiElements[i] is GUITickBox tickBox)
{
tickBox.Selected = val;
}
#endif
}
}
}
}
private readonly List<CustomInterfaceElement> customInterfaceElementList = new List<CustomInterfaceElement>();
@@ -207,8 +231,10 @@ namespace Barotrauma.Items.Components
}
IsActive = true;
InitProjSpecific();
//load these here to ensure the UI elements (created in InitProjSpecific) are up-to-date
Labels = element.GetAttributeString("labels", "");
Signals = element.GetAttributeString("signals", "");
ElementStates = element.GetAttributeString("elementstates", "");
}
private void UpdateLabels(string[] newLabels)
@@ -386,6 +412,7 @@ namespace Barotrauma.Items.Components
{
labels = customInterfaceElementList.Select(ci => ci.Label).ToArray();
signals = customInterfaceElementList.Select(ci => ci.Signal).ToArray();
elementStates = customInterfaceElementList.Select(ci => ci.State).ToArray();
return base.Save(parentElement);
}