v1.6.17.0 (Unto the Breach update)
This commit is contained in:
@@ -3,7 +3,6 @@ using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -16,7 +15,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
terminalButtonStyles = new string[RequiredSignalCount];
|
||||
terminalButtonStyles = new string[requiredSignalCount];
|
||||
int i = 0;
|
||||
foreach (var childElement in element.GetChildElements("TerminalButton"))
|
||||
{
|
||||
@@ -38,11 +37,11 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
paddedFrame.OnAddedToGUIUpdateList += (component) =>
|
||||
{
|
||||
bool buttonsEnabled = AllowUsingButtons;
|
||||
foreach (var child in component.Children)
|
||||
bool buttonsEnabled = IsActivated;
|
||||
foreach (GUIComponent child in component.Children)
|
||||
{
|
||||
if (!(child is GUIButton)) { continue; }
|
||||
if (!(child.UserData is int)) { continue; }
|
||||
if (child is not GUIButton) { continue; }
|
||||
if (child.UserData is not int) { continue; }
|
||||
child.Enabled = buttonsEnabled;
|
||||
child.Children.ForEach(c => c.Enabled = buttonsEnabled);
|
||||
}
|
||||
@@ -59,7 +58,7 @@ namespace Barotrauma.Items.Components
|
||||
containerIndicator.OverrideState = itemsContained ? GUIComponent.ComponentState.Selected : GUIComponent.ComponentState.None;
|
||||
};
|
||||
|
||||
float x = 1.0f / (1 + RequiredSignalCount);
|
||||
float x = 1.0f / (1 + requiredSignalCount);
|
||||
float y = Math.Min((x * paddedFrame.Rect.Width) / paddedFrame.Rect.Height, 0.5f);
|
||||
Vector2 relativeSize = new Vector2(x, y);
|
||||
|
||||
@@ -69,7 +68,7 @@ namespace Barotrauma.Items.Components
|
||||
containerIndicator = new GUIImage(new RectTransform(new Vector2(0.5f, 0.5f * (1.0f - y)), containerSection.RectTransform, anchor: Anchor.BottomCenter),
|
||||
style: "IndicatorLightRed", scaleToFit: true);
|
||||
|
||||
for (int i = 0; i < RequiredSignalCount; i++)
|
||||
for (int i = 0; i < requiredSignalCount; i++)
|
||||
{
|
||||
var button = new GUIButton(new RectTransform(relativeSize, paddedFrame.RectTransform), style: null)
|
||||
{
|
||||
@@ -111,7 +110,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
SendSignal(msg.ReadRangedInteger(0, Signals.Length - 1), sender: null, isServerMessage: true);
|
||||
SendSignal(msg.ReadRangedInteger(0, Signals.Length - 1), sender: null, ignoreState: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -129,7 +129,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void RemoveComponents(IReadOnlyCollection<CircuitBoxComponent> node)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
var ids = node.Select(static n => n.ID).ToImmutableArray();
|
||||
|
||||
if (GameMain.NetworkMember is null)
|
||||
@@ -146,7 +146,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void AddWire(CircuitBoxConnection one, CircuitBoxConnection two)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
if (GameMain.NetworkMember is null)
|
||||
{
|
||||
Connect(one, two, static delegate { }, CircuitBoxWire.SelectedWirePrefab);
|
||||
@@ -160,7 +160,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void RemoveWires(IReadOnlyCollection<CircuitBoxWire> wires)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
var ids = wires.Select(static w => w.ID).ToImmutableArray();
|
||||
if (GameMain.NetworkMember is null)
|
||||
{
|
||||
@@ -230,7 +230,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void MoveComponent(Vector2 moveAmount, IReadOnlyCollection<CircuitBoxNode> moveables)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
var ids = ImmutableArray.CreateBuilder<ushort>();
|
||||
var ios = ImmutableArray.CreateBuilder<CircuitBoxInputOutputNode.Type>();
|
||||
var labelIds = ImmutableArray.CreateBuilder<ushort>();
|
||||
@@ -265,7 +265,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void AddComponent(ItemPrefab prefab, Vector2 pos)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
if (GameMain.NetworkMember is null)
|
||||
{
|
||||
ItemPrefab resource;
|
||||
@@ -292,7 +292,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void RenameLabel(CircuitBoxLabelNode label, Color color, NetLimitedString header, NetLimitedString body)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
if (GameMain.NetworkMember is null)
|
||||
{
|
||||
label.EditText(header, body);
|
||||
@@ -316,7 +316,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ResizeNode(CircuitBoxNode node, CircuitBoxResizeDirection dir, Vector2 amount)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
var resize = node.ResizeBy(dir, amount);
|
||||
if (GameMain.NetworkMember is null)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void AddLabel(Vector2 pos)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
if (GameMain.NetworkMember is null)
|
||||
{
|
||||
AddLabelInternal(ICircuitBoxIdentifiable.FindFreeID(Labels), GUIStyle.Blue, pos, CircuitBoxLabelNode.DefaultHeaderText, NetLimitedString.Empty);
|
||||
@@ -353,7 +353,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void RemoveLabel(IReadOnlyCollection<CircuitBoxLabelNode> labels)
|
||||
{
|
||||
if (Locked) { return; }
|
||||
if (IsLocked()) { return; }
|
||||
if (!labels.Any()) { return; }
|
||||
|
||||
var ids = labels.Select(static n => n.ID).ToImmutableArray();
|
||||
|
||||
+90
-56
@@ -14,6 +14,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private bool readingNetworkEvent;
|
||||
|
||||
private GUIComponent insufficientPowerWarning;
|
||||
|
||||
private Point ElementMaxSize => new Point(uiElementContainer.Rect.Width, (int)(65 * GUI.yScale));
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
@@ -40,7 +42,7 @@ namespace Barotrauma.Items.Components
|
||||
float elementSize = Math.Min(1.0f / visibleElements.Count(), 1);
|
||||
foreach (CustomInterfaceElement ciElement in visibleElements)
|
||||
{
|
||||
if (ciElement.HasPropertyName)
|
||||
if (ciElement.InputType is CustomInterfaceElement.InputTypeOption.Number or CustomInterfaceElement.InputTypeOption.Text)
|
||||
{
|
||||
var layoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, elementSize), uiElementContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
@@ -49,7 +51,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform),
|
||||
TextManager.Get(ciElement.Label).Fallback(ciElement.Label));
|
||||
if (!ciElement.IsNumberInput)
|
||||
if (ciElement.InputType is CustomInterfaceElement.InputTypeOption.Text)
|
||||
{
|
||||
var textBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), ciElement.Signal, style: "GUITextBoxNoIcon")
|
||||
{
|
||||
@@ -149,7 +151,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ciElement.ContinuousSignal)
|
||||
else if (ciElement.InputType is CustomInterfaceElement.InputTypeOption.TickBox)
|
||||
{
|
||||
var tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, elementSize), uiElementContainer.RectTransform)
|
||||
{
|
||||
@@ -175,7 +177,7 @@ namespace Barotrauma.Items.Components
|
||||
tickBox.RectTransform.MaxSize = new Point(int.MaxValue, int.MaxValue);
|
||||
uiElements.Add(tickBox);
|
||||
}
|
||||
else
|
||||
else if (ciElement.InputType is CustomInterfaceElement.InputTypeOption.Button)
|
||||
{
|
||||
var btn = new GUIButton(new RectTransform(new Vector2(1.0f, elementSize), uiElementContainer.RectTransform),
|
||||
TextManager.Get(ciElement.Label).Fallback(ciElement.Label), style: "DeviceButton")
|
||||
@@ -203,6 +205,16 @@ namespace Barotrauma.Items.Components
|
||||
uiElements.Add(btn);
|
||||
}
|
||||
}
|
||||
|
||||
if (ShowInsufficientPowerWarning)
|
||||
{
|
||||
insufficientPowerWarning = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), GuiFrame.RectTransform, Anchor.BottomCenter, Pivot.TopCenter) { MinSize = new Point(0, GUI.IntScale(30)) },
|
||||
TextManager.Get("SteeringNoPowerTip"), font: GUIStyle.Font, wrap: true, style: "GUIToolTip", textAlignment: Alignment.Center)
|
||||
{
|
||||
AutoScaleHorizontal = true,
|
||||
Visible = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void CreateEditingHUD(SerializableEntityEditor editor)
|
||||
@@ -253,7 +265,20 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (uiElement.UserData is not CustomInterfaceElement element) { continue; }
|
||||
bool visible = Screen.Selected == GameMain.SubEditorScreen || element.StatusEffects.Any() || element.HasPropertyName || (element.Connection != null && element.Connection.Wires.Count > 0);
|
||||
if (visible) { visibleElementCount++; }
|
||||
if (visible)
|
||||
{
|
||||
visibleElementCount++;
|
||||
if (element.GetValueInterval > 0.0f)
|
||||
{
|
||||
element.GetValueTimer -= deltaTime;
|
||||
if (element.GetValueTimer <= 0.0f)
|
||||
{
|
||||
SetSignalToPropertyValue(element);
|
||||
UpdateSignalProjSpecific(uiElement);
|
||||
element.GetValueTimer = element.GetValueInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uiElement.Visible != visible)
|
||||
{
|
||||
uiElement.Visible = visible;
|
||||
@@ -274,6 +299,11 @@ namespace Barotrauma.Items.Components
|
||||
GuiFrame.Visible = visibleElementCount > 0;
|
||||
uiElementContainer.Recalculate();
|
||||
}
|
||||
|
||||
if (insufficientPowerWarning != null)
|
||||
{
|
||||
insufficientPowerWarning.Visible = item.GetComponents<Powered>().Any(p => p.PowerConsumption > 0.0f && p.Voltage < p.MinVoltage);
|
||||
}
|
||||
}
|
||||
|
||||
partial void UpdateLabelsProjSpecific()
|
||||
@@ -336,22 +366,32 @@ namespace Barotrauma.Items.Components
|
||||
if (signals == null) { return; }
|
||||
for (int i = 0; i < signals.Length && i < uiElements.Count; i++)
|
||||
{
|
||||
string signal = customInterfaceElementList[i].Signal;
|
||||
if (uiElements[i] is GUITextBox tb)
|
||||
UpdateSignalProjSpecific(uiElements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSignalProjSpecific(GUIComponent uiElement)
|
||||
{
|
||||
if (uiElement.UserData is not CustomInterfaceElement element) { return; }
|
||||
string signal = element.Signal;
|
||||
if (uiElement is GUITextBox tb)
|
||||
{
|
||||
tb.Text = Screen.Selected is { IsEditor: true } ?
|
||||
signal :
|
||||
TextManager.Get(signal).Fallback(signal).Value;
|
||||
}
|
||||
else if (uiElement is GUINumberInput ni)
|
||||
{
|
||||
if (ni.InputType == NumberType.Int)
|
||||
{
|
||||
tb.Text = Screen.Selected is { IsEditor: true } ?
|
||||
signal :
|
||||
TextManager.Get(signal).Fallback(signal).Value;
|
||||
}
|
||||
else if (uiElements[i] is GUINumberInput ni)
|
||||
{
|
||||
if (ni.InputType == NumberType.Int)
|
||||
{
|
||||
int.TryParse(signal, out int value);
|
||||
ni.IntValue = value;
|
||||
}
|
||||
int.TryParse(signal, out int value);
|
||||
ni.IntValue = value;
|
||||
}
|
||||
}
|
||||
else if (uiElement is GUITickBox tickBox)
|
||||
{
|
||||
tickBox.Selected = signal.Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
@@ -360,14 +400,9 @@ namespace Barotrauma.Items.Components
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
var element = customInterfaceElementList[i];
|
||||
if (element.HasPropertyName)
|
||||
switch (element.InputType)
|
||||
{
|
||||
if (!element.IsNumberInput)
|
||||
{
|
||||
msg.WriteString(((GUITextBox)uiElements[i]).Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
case CustomInterfaceElement.InputTypeOption.Number:
|
||||
switch (element.NumberType)
|
||||
{
|
||||
case NumberType.Float:
|
||||
@@ -378,15 +413,16 @@ namespace Barotrauma.Items.Components
|
||||
msg.WriteString(((GUINumberInput)uiElements[i]).IntValue.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (element.ContinuousSignal)
|
||||
{
|
||||
msg.WriteBoolean(((GUITickBox)uiElements[i]).Selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.WriteBoolean(extraData is Item.ComponentStateEventData { ComponentData: EventData eventData } && eventData.BtnElement == customInterfaceElementList[i]);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Text:
|
||||
msg.WriteString(((GUITextBox)uiElements[i]).Text);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.TickBox:
|
||||
msg.WriteBoolean(((GUITickBox)uiElements[i]).Selected);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Button:
|
||||
msg.WriteBoolean(extraData is Item.ComponentStateEventData { ComponentData: EventData eventData } && eventData.BtnElement == customInterfaceElementList[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,15 +435,10 @@ namespace Barotrauma.Items.Components
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
var element = customInterfaceElementList[i];
|
||||
if (element.HasPropertyName)
|
||||
switch (element.InputType)
|
||||
{
|
||||
string newValue = msg.ReadString();
|
||||
if (!element.IsNumberInput)
|
||||
{
|
||||
TextChanged(element, newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
case CustomInterfaceElement.InputTypeOption.Number:
|
||||
string newValue = msg.ReadString();
|
||||
switch (element.NumberType)
|
||||
{
|
||||
case NumberType.Int when int.TryParse(newValue, out int value):
|
||||
@@ -417,20 +448,23 @@ namespace Barotrauma.Items.Components
|
||||
ValueChanged(element, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool elementState = msg.ReadBoolean();
|
||||
if (element.ContinuousSignal)
|
||||
{
|
||||
((GUITickBox)uiElements[i]).Selected = elementState;
|
||||
TickBoxToggled(element, elementState);
|
||||
}
|
||||
else if (elementState)
|
||||
{
|
||||
ButtonClicked(element);
|
||||
}
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Text:
|
||||
string newTextValue = msg.ReadString();
|
||||
TextChanged(element, newTextValue);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.TickBox:
|
||||
bool tickBoxState = msg.ReadBoolean();
|
||||
((GUITickBox)uiElements[i]).Selected = tickBoxState;
|
||||
TickBoxToggled(element, tickBoxState);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Button:
|
||||
bool buttonState = msg.ReadBoolean();
|
||||
if (buttonState)
|
||||
{
|
||||
ButtonClicked(element);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Barotrauma.Items.Components
|
||||
private static int? selectedNodeIndex;
|
||||
private static int? highlightedNodeIndex;
|
||||
|
||||
[Serialize(0.3f, IsPropertySaveable.No)]
|
||||
[Serialize(0.3f, IsPropertySaveable.No), Editable(MinValueFloat = 0.01f, MaxValueFloat = 10.0f, DecimalCount = 2)]
|
||||
public float Width
|
||||
{
|
||||
get;
|
||||
|
||||
Reference in New Issue
Block a user