(e42047dc1) Tester's build, January 30th 2020
This commit is contained in:
@@ -18,13 +18,20 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
if (GuiFrame == null) return;
|
||||
if (GuiFrame == null) { return; }
|
||||
|
||||
var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.75f, 0.75f), GuiFrame.RectTransform, Anchor.Center)
|
||||
{
|
||||
//RelativeOffset = new Vector2(0, 0.05f)
|
||||
}, style: null);
|
||||
|
||||
var upperArea = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), paddedFrame.RectTransform, Anchor.TopCenter), style: null);
|
||||
var lowerArea = new GUIFrame(new RectTransform(new Vector2(1, 0.6f), paddedFrame.RectTransform, Anchor.BottomCenter), style: null);
|
||||
|
||||
GUILayoutGroup paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.7f), GuiFrame.RectTransform, Anchor.Center))
|
||||
{ RelativeSpacing = 0.1f, Stretch = true };
|
||||
|
||||
string rechargeStr = TextManager.Get("PowerContainerRechargeRate");
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform), "RechargeRate", textAlignment: Alignment.Center)
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), upperArea.RectTransform, Anchor.TopCenter),
|
||||
"RechargeRate", textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.Center)
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
@@ -32,21 +39,14 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
var sliderArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform, Anchor.BottomCenter), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), sliderArea.RectTransform),
|
||||
"0 %", textAlignment: Alignment.Center);
|
||||
rechargeSpeedSlider = new GUIScrollBar(new RectTransform(new Vector2(0.8f, 1.0f), sliderArea.RectTransform), barSize: 0.25f, style: "GUISlider")
|
||||
rechargeSpeedSlider = new GUIScrollBar(new RectTransform(new Vector2(0.9f, 0.4f), upperArea.RectTransform, Anchor.BottomCenter),
|
||||
barSize: 0.15f, style: "DeviceSlider")
|
||||
{
|
||||
Step = 0.1f,
|
||||
OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
||||
{
|
||||
float newRechargeSpeed = maxRechargeSpeed * barScroll;
|
||||
if (Math.Abs(newRechargeSpeed - rechargeSpeed) < 0.1f) return false;
|
||||
if (Math.Abs(newRechargeSpeed - rechargeSpeed) < 0.1f) { return false; }
|
||||
|
||||
RechargeSpeed = newRechargeSpeed;
|
||||
if (GameMain.Client != null)
|
||||
@@ -57,21 +57,30 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), sliderArea.RectTransform),
|
||||
"100 %", textAlignment: Alignment.Center);
|
||||
rechargeSpeedSlider.Bar.RectTransform.MaxSize = new Point(rechargeSpeedSlider.Bar.Rect.Height);
|
||||
|
||||
// lower area --------------------------
|
||||
|
||||
string chargeStr = TextManager.Get("PowerContainerCharge");
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform), "Charge", textAlignment: Alignment.Center)
|
||||
var textArea = 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), textArea.RectTransform, Anchor.CenterLeft),
|
||||
TextManager.Get("charge"), textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
return chargeStr.Replace("[charge]", (int)charge + "/" + (int)capacity).Replace("[percentage]", ((int)((charge / capacity) * 100.0f)).ToString());
|
||||
}
|
||||
ToolTip = TextManager.Get("PowerTransferTipPower")
|
||||
};
|
||||
|
||||
chargeIndicator = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), barSize: 0.0f)
|
||||
string kWmin = TextManager.Get("kilowattminute");
|
||||
var chargeText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1), textArea.RectTransform, Anchor.CenterRight),
|
||||
"", textColor: GUI.Style.TextColor, font: GUI.Font, textAlignment: Alignment.CenterRight)
|
||||
{
|
||||
ProgressGetter = () =>
|
||||
TextGetter = () => $"{(int)charge}/{(int)capacity} {kWmin} ({((int)MathUtils.Percentage(charge, capacity)).ToString()} %)"
|
||||
};
|
||||
if (chargeText.TextSize.X > chargeText.Rect.Width) { chargeText.Font = GUI.SmallFont; }
|
||||
|
||||
chargeIndicator = new GUIProgressBar(new RectTransform(new Vector2(1.1f, 0.5f), lowerArea.RectTransform, Anchor.BottomCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0, 0.1f)
|
||||
}, barSize: 0.0f, style: "DeviceProgressBar")
|
||||
{
|
||||
ProgressGetter = () =>
|
||||
{
|
||||
return capacity <= 0.0f ? 1.0f : charge / capacity;
|
||||
}
|
||||
@@ -95,7 +104,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
if (indicatorSize.X <= 1.0f || indicatorSize.Y <= 1.0f) return;
|
||||
if (indicatorSize.X <= 1.0f || indicatorSize.Y <= 1.0f) { return; }
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -13,66 +12,95 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjectSpecific(XElement element)
|
||||
{
|
||||
if (GuiFrame == null) return;
|
||||
if (GuiFrame == null) { return; }
|
||||
|
||||
Point indicatorSize = new Point((int)(30 * GUI.Scale));
|
||||
|
||||
var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.7f), GuiFrame.RectTransform, Anchor.Center), style: null);
|
||||
powerIndicator = new GUITickBox(new RectTransform(indicatorSize, paddedFrame.RectTransform),
|
||||
TextManager.Get("PowerTransferPowered"), style: "IndicatorLightGreen")
|
||||
var paddedFrame = new GUIFrame(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center) { AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
style: null)
|
||||
{
|
||||
Enabled = false
|
||||
CanBeFocused = false
|
||||
};
|
||||
powerIndicator.TextColor = powerIndicator.DefaultTextColor.Value;
|
||||
|
||||
highVoltageIndicator = new GUITickBox(new RectTransform(indicatorSize, paddedFrame.RectTransform) { AbsoluteOffset = new Point(0, (int)(40 * GUI.yScale)) },
|
||||
TextManager.Get("PowerTransferHighVoltage"), style: "IndicatorLightRed")
|
||||
var lightsArea = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 1), paddedFrame.RectTransform, Anchor.CenterLeft))
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
powerIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.3f), lightsArea.RectTransform),
|
||||
TextManager.Get("PowerTransferPowered"), font: GUI.SubHeadingFont, style: "IndicatorLightGreen")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
highVoltageIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.3f), lightsArea.RectTransform),
|
||||
TextManager.Get("PowerTransferHighVoltage"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
|
||||
{
|
||||
ToolTip = TextManager.Get("PowerTransferTipOvervoltage"),
|
||||
Enabled = false
|
||||
};
|
||||
highVoltageIndicator.TextColor = highVoltageIndicator.DefaultTextColor.Value;
|
||||
|
||||
lowVoltageIndicator = new GUITickBox(new RectTransform(indicatorSize, paddedFrame.RectTransform) { AbsoluteOffset = new Point(0, (int)(80 * GUI.yScale)) },
|
||||
TextManager.Get("PowerTransferLowVoltage"), style: "IndicatorLightRed")
|
||||
lowVoltageIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.3f), lightsArea.RectTransform),
|
||||
TextManager.Get("PowerTransferLowVoltage"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
|
||||
{
|
||||
ToolTip = TextManager.Get("PowerTransferTipLowvoltage"),
|
||||
Enabled = false
|
||||
};
|
||||
lowVoltageIndicator.TextColor = lowVoltageIndicator.DefaultTextColor.Value;
|
||||
powerIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
highVoltageIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
lowVoltageIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
GUITextBlock.AutoScaleAndNormalize(powerIndicator.TextBlock, highVoltageIndicator.TextBlock, lowVoltageIndicator.TextBlock);
|
||||
|
||||
var textContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), paddedFrame.RectTransform, Anchor.TopRight));
|
||||
var textContainer = new GUIFrame(new RectTransform(new Vector2(0.58f, 1.0f), paddedFrame.RectTransform, Anchor.CenterRight), style: null);
|
||||
var upperTextArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), textContainer.RectTransform, Anchor.TopLeft), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
var lowerTextArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), textContainer.RectTransform, Anchor.BottomLeft), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContainer.RectTransform),
|
||||
TextManager.Get("PowerTransferPowerLabel"), font: GUI.LargeFont)
|
||||
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)
|
||||
{
|
||||
ToolTip = TextManager.Get("PowerTransferTipPower")
|
||||
};
|
||||
string powerStr = TextManager.Get("PowerTransferPower");
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), textContainer.RectTransform), "", textColor: Color.LightGreen)
|
||||
{
|
||||
ToolTip = TextManager.Get("PowerTransferTipPower"),
|
||||
TextGetter = () => { return powerStr.Replace("[power]", ((int)Math.Round(-currPowerConsumption)).ToString()); }
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContainer.RectTransform),
|
||||
TextManager.Get("PowerTransferLoadLabel"), font: GUI.LargeFont)
|
||||
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)
|
||||
{
|
||||
ToolTip = TextManager.Get("PowerTransferTipLoad")
|
||||
|
||||
};
|
||||
string loadStr = TextManager.Get("PowerTransferLoad");
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), textContainer.RectTransform), "", textColor: Color.LightBlue)
|
||||
|
||||
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)
|
||||
{
|
||||
ToolTip = TextManager.Get("PowerTransferTipLoad"),
|
||||
TextGetter = () =>
|
||||
{
|
||||
return loadStr.Replace("[load]",
|
||||
this is RelayComponent relay ?
|
||||
((int)Math.Round(relay.DisplayLoad)).ToString() :
|
||||
((int)Math.Round(powerLoad)).ToString());
|
||||
}
|
||||
TextAlignment = Alignment.CenterRight,
|
||||
ToolTip = TextManager.Get("PowerTransferTipPower"),
|
||||
TextGetter = () => ((int)Math.Round(-currPowerConsumption)).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)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
TextAlignment = Alignment.BottomCenter
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
TextAlignment = Alignment.CenterRight,
|
||||
ToolTip = TextManager.Get("PowerTransferTipLoad"),
|
||||
TextGetter = () => ((int)Math.Round(this is RelayComponent relay ? relay.DisplayLoad : powerLoad)).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)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
TextAlignment = Alignment.BottomCenter
|
||||
};
|
||||
|
||||
GUITextBlock.AutoScaleAndNormalize(powerLabel, loadLabel);
|
||||
GUITextBlock.AutoScaleAndNormalize(powerText, loadText);
|
||||
GUITextBlock.AutoScaleAndNormalize(kw1, kw2);
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
|
||||
Reference in New Issue
Block a user