Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -10,10 +10,10 @@ namespace Barotrauma.Items.Components
private GUIProgressBar chargeIndicator;
private GUIScrollBar rechargeSpeedSlider;
[Serialize(0.0f, true)]
[Serialize(0.0f, IsPropertySaveable.Yes)]
public float RechargeWarningIndicatorLow { get; set; }
[Serialize(0.0f, true)]
[Serialize(0.0f, IsPropertySaveable.Yes)]
public float RechargeWarningIndicatorHigh { get; set; }
public Vector2 DrawSize
@@ -36,17 +36,17 @@ namespace Barotrauma.Items.Components
var rechargeRateContainer = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), upperArea.RectTransform), style: null);
var rechargeLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 0.0f), rechargeRateContainer.RectTransform, Anchor.CenterLeft),
TextManager.Get("rechargerate"), textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft);
string kW = TextManager.Get("kilowatt");
TextManager.Get("rechargerate"), textColor: GUIStyle.TextColorNormal, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.CenterLeft);
LocalizedString kW = TextManager.Get("kilowatt");
var rechargeText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1), rechargeRateContainer.RectTransform, Anchor.CenterRight),
"", textColor: GUI.Style.TextColor, font: GUI.Font, textAlignment: Alignment.CenterRight)
"", textColor: GUIStyle.TextColorNormal, font: GUIStyle.Font, textAlignment: Alignment.CenterRight)
{
TextGetter = () => $"{(int)MathF.Round(currPowerConsumption)} {kW} ({(int)MathF.Round(RechargeRatio * 100)} %)"
};
if (rechargeText.TextSize.X > rechargeText.Rect.Width) { rechargeText.Font = GUI.SmallFont; }
if (rechargeText.TextSize.X > rechargeText.Rect.Width) { rechargeText.Font = GUIStyle.SmallFont; }
var rechargeSliderContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.4f), upperArea.RectTransform, Anchor.BottomCenter));
if (RechargeWarningIndicatorLow > 0.0f || RechargeWarningIndicatorHigh > 0.0f)
{
var rechargeSliderFill = new GUICustomComponent(new RectTransform(new Vector2(0.95f, 0.9f), rechargeSliderContainer.RectTransform, Anchor.Center), (SpriteBatch sb, GUICustomComponent c) =>
@@ -54,12 +54,12 @@ namespace Barotrauma.Items.Components
if (RechargeWarningIndicatorLow > 0.0f)
{
float warningLow = c.Rect.Width * RechargeWarningIndicatorLow;
GUI.DrawRectangle(sb, new Vector2(c.Rect.X + warningLow, c.Rect.Y), new Vector2(c.Rect.Width - warningLow, c.Rect.Height), GUI.Style.Orange, isFilled: true);
GUI.DrawRectangle(sb, new Vector2(c.Rect.X + warningLow, c.Rect.Y), new Vector2(c.Rect.Width - warningLow, c.Rect.Height), GUIStyle.Orange, isFilled: true);
}
if (RechargeWarningIndicatorHigh > 0.0f)
{
float warningHigh = c.Rect.Width * RechargeWarningIndicatorHigh;
GUI.DrawRectangle(sb, new Vector2(c.Rect.X + warningHigh, c.Rect.Y), new Vector2(c.Rect.Width - warningHigh, c.Rect.Height), GUI.Style.Red, isFilled: true);
GUI.DrawRectangle(sb, new Vector2(c.Rect.X + warningHigh, c.Rect.Y), new Vector2(c.Rect.Width - warningHigh, c.Rect.Height), GUIStyle.Red, isFilled: true);
}
});
}
@@ -88,17 +88,17 @@ namespace Barotrauma.Items.Components
var chargeTextContainer = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), lowerArea.RectTransform), style: null);
var chargeLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 0.0f), chargeTextContainer.RectTransform, Anchor.CenterLeft),
TextManager.Get("charge"), textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
TextManager.Get("charge"), textColor: GUIStyle.TextColorNormal, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.CenterLeft)
{
ToolTip = TextManager.Get("PowerTransferTipPower")
};
string kWmin = TextManager.Get("kilowattminute");
LocalizedString kWmin = TextManager.Get("kilowattminute");
var chargeText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1), chargeTextContainer.RectTransform, Anchor.CenterRight),
"", textColor: GUI.Style.TextColor, font: GUI.Font, textAlignment: Alignment.CenterRight)
"", textColor: GUIStyle.TextColorNormal, font: GUIStyle.Font, textAlignment: Alignment.CenterRight)
{
TextGetter = () => $"{(int)MathF.Round(charge)}/{(int)capacity} {kWmin} ({(int)MathF.Round(MathUtils.Percentage(charge, capacity))} %)"
};
if (chargeText.TextSize.X > chargeText.Rect.Width) { chargeText.Font = GUI.SmallFont; }
if (chargeText.TextSize.X > chargeText.Rect.Width) { chargeText.Font = GUIStyle.SmallFont; }
chargeIndicator = new GUIProgressBar(new RectTransform(new Vector2(1.1f, 0.5f), lowerArea.RectTransform, Anchor.BottomCenter)
{
@@ -25,25 +25,25 @@ namespace Barotrauma.Items.Components
Stretch = true
};
powerIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.33f), lightsArea.RectTransform),
TextManager.Get("PowerTransferPowered"), font: GUI.SubHeadingFont, style: "IndicatorLightGreen")
TextManager.Get("PowerTransferPowered"), font: GUIStyle.SubHeadingFont, style: "IndicatorLightGreen")
{
CanBeFocused = false
};
highVoltageIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.33f), lightsArea.RectTransform),
TextManager.Get("PowerTransferHighVoltage"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
TextManager.Get("PowerTransferHighVoltage"), font: GUIStyle.SubHeadingFont, style: "IndicatorLightRed")
{
ToolTip = TextManager.Get("PowerTransferTipOvervoltage"),
Enabled = false
};
lowVoltageIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.33f), lightsArea.RectTransform),
TextManager.Get("PowerTransferLowVoltage"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
TextManager.Get("PowerTransferLowVoltage"), font: GUIStyle.SubHeadingFont, style: "IndicatorLightRed")
{
ToolTip = TextManager.Get("PowerTransferTipLowvoltage"),
Enabled = false
};
powerIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
highVoltageIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
lowVoltageIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
powerIndicator.TextBlock.OverrideTextColor(GUIStyle.TextColorNormal);
highVoltageIndicator.TextBlock.OverrideTextColor(GUIStyle.TextColorNormal);
lowVoltageIndicator.TextBlock.OverrideTextColor(GUIStyle.TextColorNormal);
GUITextBlock.AutoScaleAndNormalize(powerIndicator.TextBlock, highVoltageIndicator.TextBlock, lowVoltageIndicator.TextBlock);
var textContainer = new GUIFrame(new RectTransform(new Vector2(0.58f, 1.0f), paddedFrame.RectTransform, Anchor.CenterRight), style: null);
@@ -57,26 +57,33 @@ namespace Barotrauma.Items.Components
};
var powerLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1), upperTextArea.RectTransform),
TextManager.Get("PowerTransferPowerLabel"), textColor: GUI.Style.TextColorBright, font: GUI.LargeFont, textAlignment: Alignment.CenterRight)
TextManager.Get("PowerTransferPowerLabel"), textColor: GUIStyle.TextColorBright, font: GUIStyle.LargeFont, textAlignment: Alignment.CenterRight)
{
ToolTip = TextManager.Get("PowerTransferTipPower")
};
var loadLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1), lowerTextArea.RectTransform),
TextManager.Get("PowerTransferLoadLabel"), textColor: GUI.Style.TextColorBright, font: GUI.LargeFont, textAlignment: Alignment.CenterRight)
TextManager.Get("PowerTransferLoadLabel"), textColor: GUIStyle.TextColorBright, font: GUIStyle.LargeFont, textAlignment: Alignment.CenterRight)
{
ToolTip = TextManager.Get("PowerTransferTipLoad")
};
var digitalBackground = new GUIFrame(new RectTransform(new Vector2(0.55f, 0.8f), upperTextArea.RectTransform), style: "DigitalFrameDark");
var powerText = new GUITextBlock(new RectTransform(new Vector2(0.9f, 0.95f), digitalBackground.RectTransform, Anchor.Center),
"", font: GUI.DigitalFont, textColor: GUI.Style.TextColorDark)
"", font: GUIStyle.DigitalFont, textColor: GUIStyle.TextColorDark)
{
TextAlignment = Alignment.CenterRight,
ToolTip = TextManager.Get("PowerTransferTipPower"),
TextGetter = () => ((int)Math.Round(-currPowerConsumption)).ToString()
TextGetter = () => {
float currPower = powerLoad < 0 ? -powerLoad: 0;
if (!(this is RelayComponent) && PowerConnections != null && PowerConnections.Count > 0 && PowerConnections[0].Grid != null)
{
currPower = PowerConnections[0].Grid.Power;
}
return ((int)Math.Round(currPower)).ToString();
}
};
var kw1 = new GUITextBlock(new RectTransform(new Vector2(0.15f, 0.5f), upperTextArea.RectTransform),
TextManager.Get("kilowatt"), textColor: GUI.Style.TextColor, font: GUI.Font)
TextManager.Get("kilowatt"), textColor: GUIStyle.TextColorNormal, font: GUIStyle.Font)
{
Padding = Vector4.Zero,
TextAlignment = Alignment.BottomCenter
@@ -84,14 +91,26 @@ namespace Barotrauma.Items.Components
digitalBackground = new GUIFrame(new RectTransform(new Vector2(0.55f, 0.8f), lowerTextArea.RectTransform), style: "DigitalFrameDark");
var loadText = new GUITextBlock(new RectTransform(new Vector2(0.9f, 0.95f), digitalBackground.RectTransform, Anchor.Center),
"", font: GUI.DigitalFont, textColor: GUI.Style.TextColorDark)
"", font: GUIStyle.DigitalFont, textColor: GUIStyle.TextColorDark)
{
TextAlignment = Alignment.CenterRight,
ToolTip = TextManager.Get("PowerTransferTipLoad"),
TextGetter = () => ((int)Math.Round(this is RelayComponent relay ? relay.DisplayLoad : powerLoad)).ToString()
TextGetter = () =>
{
float load = PowerLoad;
if (this is RelayComponent relay)
{
load = relay.DisplayLoad;
}
else if (load < 0)
{
load = 0;
}
return ((int)Math.Round(load)).ToString();
}
};
var kw2 = new GUITextBlock(new RectTransform(new Vector2(0.15f, 0.5f), lowerTextArea.RectTransform),
TextManager.Get("kilowatt"), textColor: GUI.Style.TextColor, font: GUI.Font)
TextManager.Get("kilowatt"), textColor: GUIStyle.TextColorNormal, font: GUIStyle.Font)
{
Padding = Vector4.Zero,
TextAlignment = Alignment.BottomCenter
@@ -106,8 +125,8 @@ namespace Barotrauma.Items.Components
{
if (GuiFrame == null) return;
float voltage = powerLoad <= 0.0f ? 1.0f : -currPowerConsumption / powerLoad;
powerIndicator.Selected = IsActive && currPowerConsumption < -0.1f;
float voltage = (PowerConnections.Count > 0 && PowerConnections[0].Grid != null) ? PowerConnections[0].Grid.Voltage : 0f;
powerIndicator.Selected = IsActive && voltage > 0;
highVoltageIndicator.Selected = Timing.TotalTime % 0.5f < 0.25f && powerIndicator.Selected && voltage > 1.2f;
lowVoltageIndicator.Selected = Timing.TotalTime % 0.5f < 0.25f && powerIndicator.Selected && voltage < 0.8f;
}
@@ -9,14 +9,14 @@ namespace Barotrauma.Items.Components
private RoundSound powerOnSound;
private bool powerOnSoundPlayed;
partial void InitProjectSpecific(XElement element)
partial void InitProjectSpecific(ContentXElement element)
{
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "poweronsound":
powerOnSound = Submarine.LoadRoundSound(subElement, false);
powerOnSound = RoundSound.Load(subElement, false);
break;
}
}