(e42047dc1) Tester's build, January 30th 2020
This commit is contained in:
@@ -43,9 +43,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (storeOriginalState)
|
||||
{
|
||||
crewAreaOriginalState = crewManager.ToggleCrewAreaOpen;
|
||||
crewAreaOriginalState = crewManager.ToggleCrewListOpen;
|
||||
}
|
||||
crewManager.ToggleCrewAreaOpen = value;
|
||||
crewManager.ToggleCrewListOpen = value;
|
||||
}
|
||||
|
||||
private void ToggleChatBox(bool value, bool storeOriginalState)
|
||||
|
||||
+41
-7
@@ -22,34 +22,68 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.2f, 0.7f), paddedFrame.RectTransform), style: null);
|
||||
var topFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), paddedFrame.RectTransform), style: null);
|
||||
var paddedLine = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), topFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
var inputText = new GUITextBlock(new RectTransform(new Vector2(0f, 1.0f), paddedLine.RectTransform), TextManager.Get("uilabel.input"), font: GUI.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
new GUIFrame(new RectTransform(new Vector2(1f, 1.0f), paddedLine.RectTransform), style: "HorizontalLine");
|
||||
|
||||
// Resize GUITextBlock width according to the text length
|
||||
inputText.RectTransform.Resize(new Point((int)inputText.Font.MeasureString(inputText.Text).X, inputText.RectTransform.Rect.Height));
|
||||
|
||||
|
||||
var inputArea = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1.2f), topFrame.RectTransform, Anchor.CenterLeft), childAnchor: Anchor.BottomLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.045f
|
||||
};
|
||||
inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.7f, 1f), inputArea.RectTransform), style: null);
|
||||
inputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawOverLay, null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
activateButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.1f), paddedFrame.RectTransform),
|
||||
TextManager.Get("DeconstructorDeconstruct"))
|
||||
var buttonContainer = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.75f), inputArea.RectTransform), style: null);
|
||||
activateButton = new GUIButton(new RectTransform(new Vector2(0.95f, 0.65f), buttonContainer.RectTransform, Anchor.CenterLeft),
|
||||
TextManager.Get("DeconstructorDeconstruct"), style: "DeviceButton")
|
||||
{
|
||||
TextBlock = { AutoScale = true },
|
||||
OnClicked = ToggleActive
|
||||
};
|
||||
|
||||
|
||||
inSufficientPowerWarning = new GUITextBlock(new RectTransform(Vector2.One, activateButton.RectTransform), TextManager.Get("DeconstructorNoPower"),
|
||||
textColor: Color.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow")
|
||||
textColor: GUI.Style.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow")
|
||||
{
|
||||
HoverColor = Color.Black,
|
||||
IgnoreLayoutGroups = true,
|
||||
Visible = false,
|
||||
CanBeFocused = false
|
||||
};
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.3f), paddedFrame.RectTransform), style: null);
|
||||
|
||||
var bottomFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), paddedFrame.RectTransform), style: null);
|
||||
var paddedBottomLine = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), bottomFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
var outputText = new GUITextBlock(new RectTransform(new Vector2(0f, 1.0f), paddedBottomLine.RectTransform), TextManager.Get("uilabel.output"), font: GUI.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
new GUIFrame(new RectTransform(new Vector2(1f, 1.0f), paddedBottomLine.RectTransform), style: "HorizontalLine");
|
||||
|
||||
// Resize GUITextBlock width according to the text length
|
||||
outputText.RectTransform.Resize(new Point((int)outputText.Font.MeasureString(outputText.Text).X, outputText.RectTransform.Rect.Height));
|
||||
|
||||
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f, 1.2f), bottomFrame.RectTransform, Anchor.CenterLeft), style: null);
|
||||
}
|
||||
|
||||
partial void OnItemLoadedProjSpecific()
|
||||
@@ -69,7 +103,7 @@ namespace Barotrauma.Items.Components
|
||||
new Rectangle(
|
||||
lastSlot.Rect.X, lastSlot.Rect.Y + (int)(lastSlot.Rect.Height * (1.0f - progressState)),
|
||||
lastSlot.Rect.Width, (int)(lastSlot.Rect.Height * progressState)),
|
||||
Color.Green * 0.5f, isFilled: true);
|
||||
GUI.Style.Green * 0.5f, isFilled: true);
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
|
||||
@@ -30,37 +30,45 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
var content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center))
|
||||
var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.85f, 0.65f), GuiFrame.RectTransform, Anchor.Center)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
RelativeOffset = new Vector2(0, 0.04f)
|
||||
}, style: null);
|
||||
|
||||
float indicatorSize = 0.3f;
|
||||
powerIndicator = new GUITickBox(new RectTransform(new Vector2(indicatorSize), content.RectTransform),
|
||||
TextManager.Get("EnginePowered"), style: "IndicatorLightGreen")
|
||||
var lightsArea = new GUIFrame(new RectTransform(new Vector2(1, 0.38f), paddedFrame.RectTransform, Anchor.TopLeft), style: null);
|
||||
powerIndicator = new GUITickBox(new RectTransform(new Vector2(0.45f, 0.8f), lightsArea.RectTransform, Anchor.Center, Pivot.CenterRight)
|
||||
{
|
||||
RelativeOffset = new Vector2(-0.05f, 0)
|
||||
}, TextManager.Get("EnginePowered"), font: GUI.SubHeadingFont, style: "IndicatorLightGreen")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
autoControlIndicator = new GUITickBox(new RectTransform(new Vector2(indicatorSize), content.RectTransform), TextManager.Get("PumpAutoControl", fallBackTag: "ReactorAutoControl"), style: "IndicatorLightRed")
|
||||
autoControlIndicator = new GUITickBox(new RectTransform(new Vector2(0.45f, 0.8f), lightsArea.RectTransform, Anchor.Center, Pivot.CenterLeft)
|
||||
{
|
||||
RelativeOffset = new Vector2(0.05f, 0)
|
||||
}, TextManager.Get("PumpAutoControl", fallBackTag: "ReactorAutoControl"), font: GUI.SubHeadingFont, style: "IndicatorLightYellow")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
powerIndicator.TextBlock.Wrap = autoControlIndicator.TextBlock.Wrap = true;
|
||||
powerIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
autoControlIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
GUITextBlock.AutoScaleAndNormalize(powerIndicator.TextBlock, autoControlIndicator.TextBlock);
|
||||
|
||||
var sliderArea = new GUIFrame(new RectTransform(new Vector2(1, 0.6f), paddedFrame.RectTransform, Anchor.BottomLeft), style: null);
|
||||
string powerLabel = TextManager.Get("EngineForce");
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), content.RectTransform), "", textAlignment: Alignment.Center)
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), sliderArea.RectTransform, Anchor.TopCenter), "", textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.Center)
|
||||
{
|
||||
AutoScale = true,
|
||||
TextGetter = () => { return TextManager.AddPunctuation(':', powerLabel, (int)(targetForce) + " %"); }
|
||||
};
|
||||
|
||||
forceSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform), barSize: 0.15f, style: "GUISlider")
|
||||
forceSlider = new GUIScrollBar(new RectTransform(new Vector2(0.95f, 0.45f), sliderArea.RectTransform, Anchor.Center), barSize: 0.1f, style: "DeviceSlider")
|
||||
{
|
||||
Step = 0.05f,
|
||||
OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
||||
{
|
||||
float newTargetForce = barScroll * 200.0f - 100.0f;
|
||||
if (Math.Abs(newTargetForce - targetForce) < 0.01) return false;
|
||||
if (Math.Abs(newTargetForce - targetForce) < 0.01) { return false; }
|
||||
|
||||
targetForce = newTargetForce;
|
||||
|
||||
@@ -73,16 +81,13 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
var textArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), content.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
var textsArea = new GUIFrame(new RectTransform(new Vector2(1, 0.25f), sliderArea.RectTransform, Anchor.BottomCenter), style: null);
|
||||
var backwardsLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1.0f), textsArea.RectTransform, Anchor.CenterLeft), TextManager.Get("EngineBackwards"),
|
||||
textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft);
|
||||
var forwardsLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1.0f), textsArea.RectTransform, Anchor.CenterRight), TextManager.Get("EngineForwards"),
|
||||
textColor: GUI.Style.TextColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterRight);
|
||||
GUITextBlock.AutoScaleAndNormalize(backwardsLabel, forwardsLabel);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textArea.RectTransform), TextManager.Get("EngineBackwards"),
|
||||
font: GUI.SmallFont, textAlignment: Alignment.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textArea.RectTransform), TextManager.Get("EngineForwards"),
|
||||
font: GUI.SmallFont, textAlignment: Alignment.CenterRight);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
@@ -113,11 +118,16 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void UpdateAnimation(float deltaTime)
|
||||
{
|
||||
if (propellerSprite == null) return;
|
||||
|
||||
if (propellerSprite == null) { return; }
|
||||
spriteIndex += (force / 100.0f) * AnimSpeed * deltaTime;
|
||||
if (spriteIndex < 0) spriteIndex = propellerSprite.FrameCount;
|
||||
if (spriteIndex >= propellerSprite.FrameCount) spriteIndex = 0.0f;
|
||||
if (spriteIndex < 0)
|
||||
{
|
||||
spriteIndex = propellerSprite.FrameCount;
|
||||
}
|
||||
if (spriteIndex >= propellerSprite.FrameCount)
|
||||
{
|
||||
spriteIndex = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
@@ -136,7 +146,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 drawPos = item.DrawPosition;
|
||||
drawPos += PropellerPos;
|
||||
drawPos.Y = -drawPos.Y;
|
||||
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, Color.Red);
|
||||
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, GUI.Style.Red);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Barotrauma.Items.Components
|
||||
private GUIListBox itemList;
|
||||
|
||||
private GUIFrame selectedItemFrame;
|
||||
private GUIFrame selectedItemReqsFrame;
|
||||
|
||||
public GUIButton ActivateButton
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUITextBox itemFilterBox;
|
||||
|
||||
private GUIComponent outputSlot;
|
||||
private GUIComponent inputInventoryHolder, outputInventoryHolder;
|
||||
private GUICustomComponent inputInventoryOverlay, outputInventoryOverlay;
|
||||
|
||||
@@ -39,54 +41,81 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
itemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.5f), paddedFrame.RectTransform))
|
||||
var topFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.7f), paddedFrame.RectTransform), "InnerFrameDark");
|
||||
|
||||
var paddedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 1.0f), topFrame.RectTransform), style: null);
|
||||
var itemListFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), paddedItemFrame.RectTransform, Anchor.Center))
|
||||
{
|
||||
OnSelected = (GUIComponent component, object userdata) =>
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), itemListFrame.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f,
|
||||
UserData = "filterarea"
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 0.5f), filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.SubHeadingFont)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
AutoScale = true
|
||||
};
|
||||
itemFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), createClearButton: true);
|
||||
itemFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
|
||||
|
||||
itemList = new GUIListBox(new RectTransform(new Vector2(1f, 0.85f), itemListFrame.RectTransform), style: null)
|
||||
{
|
||||
OnSelected = (component, userdata) =>
|
||||
{
|
||||
selectedItem = userdata as FabricationRecipe;
|
||||
if (selectedItem != null) { SelectItem(Character.Controlled, selectedItem); }
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), topFrame.RectTransform, Anchor.Center), style: "VerticalLine");
|
||||
|
||||
var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), paddedFrame.RectTransform), isHorizontal: true)
|
||||
var paddedOutputFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 1f), topFrame.RectTransform, Anchor.TopRight), style: null);
|
||||
var outputArea = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), paddedOutputFrame.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
// TODO, take off the duct tape and figure out a proper way to do this \/
|
||||
var scaledFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.55f), outputArea.RectTransform), style: null);
|
||||
outputSlot = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.5f), outputArea.RectTransform), style: null);
|
||||
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1.1f, 1.5f), scaledFrame.RectTransform, Anchor.BottomCenter), style: null);
|
||||
outputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, outputArea.RectTransform), DrawOutputOverLay) { CanBeFocused = false };
|
||||
|
||||
selectedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.6f, 0.5f), outputArea.RectTransform, Anchor.TopRight), style: null);
|
||||
selectedItemReqsFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), outputArea.RectTransform, Anchor.BottomLeft), style: null);
|
||||
|
||||
var bottomFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.35f), paddedFrame.RectTransform), style: null);
|
||||
|
||||
var paddedLine = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), bottomFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
UserData = "filterarea"
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font);
|
||||
itemFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font);
|
||||
itemFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
|
||||
var clearButton = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), filterArea.RectTransform), "x")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { ClearFilter(); itemFilterBox.Flash(Color.White); return true; }
|
||||
};
|
||||
|
||||
inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.15f), paddedFrame.RectTransform), style: null);
|
||||
inputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawInputOverLay, null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), paddedFrame.RectTransform), isHorizontal: true);
|
||||
|
||||
selectedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.0f), outputArea.RectTransform), style: "InnerFrame");
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), outputArea.RectTransform), style: null);
|
||||
outputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, outputArea.RectTransform), DrawOutputOverLay, null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
var inputText = new GUITextBlock(new RectTransform(new Vector2(0f, 1.0f), paddedLine.RectTransform), TextManager.Get("uilabel.input"), font: GUI.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
new GUIFrame(new RectTransform(new Vector2(1f, 1.0f), paddedLine.RectTransform), style: "HorizontalLine");
|
||||
|
||||
// Resize GUITextBlock width according to the text length
|
||||
inputText.RectTransform.Resize(new Point((int)inputText.Font.MeasureString(inputText.Text).X, inputText.RectTransform.Rect.Height));
|
||||
|
||||
var inputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 1f), bottomFrame.RectTransform, Anchor.BottomCenter), isHorizontal: true, childAnchor: Anchor.BottomLeft);
|
||||
inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.8f, 1f), inputArea.RectTransform), style: null);
|
||||
inputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawInputOverLay) { CanBeFocused = false };
|
||||
|
||||
CreateRecipes();
|
||||
|
||||
activateButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.07f), paddedFrame.RectTransform),
|
||||
TextManager.Get("FabricatorCreate"), style: "GUIButtonLarge")
|
||||
var buttonFrame = new GUIFrame(new RectTransform(new Vector2(0.2f, 0.8f), inputArea.RectTransform), style: null);
|
||||
activateButton = new GUIButton(new RectTransform(new Vector2(1f, 0.6f), buttonFrame.RectTransform, Anchor.CenterRight),
|
||||
TextManager.Get("FabricatorCreate"), style: "DeviceButton")
|
||||
{
|
||||
OnClicked = StartButtonClicked,
|
||||
UserData = selectedItem,
|
||||
@@ -94,7 +123,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
inSufficientPowerWarning = new GUITextBlock(new RectTransform(Vector2.One, activateButton.RectTransform), TextManager.Get("FabricatorNoPower"),
|
||||
textColor: Color.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow")
|
||||
textColor: GUI.Style.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow")
|
||||
{
|
||||
HoverColor = Color.Black,
|
||||
IgnoreLayoutGroups = true,
|
||||
@@ -117,7 +146,7 @@ namespace Barotrauma.Items.Components
|
||||
ToolTip = fi.TargetItem.Description
|
||||
};
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(new RectTransform(Vector2.Zero, frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(50 * GUI.xScale), 0) },
|
||||
new GUITextBlock(new RectTransform(Vector2.Zero, frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(50 * GUI.xScale), 0) },
|
||||
fi.DisplayName)
|
||||
{
|
||||
ToolTip = fi.TargetItem.Description
|
||||
@@ -126,7 +155,7 @@ namespace Barotrauma.Items.Components
|
||||
var itemIcon = fi.TargetItem.InventoryIcon ?? fi.TargetItem.sprite;
|
||||
if (itemIcon != null)
|
||||
{
|
||||
GUIImage img = new GUIImage(new RectTransform(new Point((int)(30 * GUI.Scale)), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(3 * GUI.xScale), 0) },
|
||||
new GUIImage(new RectTransform(new Point((int)(30 * GUI.Scale)), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(3 * GUI.xScale), 0) },
|
||||
itemIcon, scaleToFit: true)
|
||||
{
|
||||
Color = fi.TargetItem.InventoryIconColor,
|
||||
@@ -166,15 +195,17 @@ namespace Barotrauma.Items.Components
|
||||
});
|
||||
|
||||
var sufficientSkillsText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), itemList.Content.RectTransform),
|
||||
TextManager.Get("fabricatorsufficientskills", returnNull: true) ?? "Sufficient skills to fabricate", textColor: Color.LightGreen)
|
||||
TextManager.Get("fabricatorsufficientskills", returnNull: true) ?? "Sufficient skills to fabricate", textColor: GUI.Style.Green, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true,
|
||||
CanBeFocused = false
|
||||
};
|
||||
sufficientSkillsText.RectTransform.SetAsFirstChild();
|
||||
|
||||
var insufficientSkillsText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), itemList.Content.RectTransform),
|
||||
TextManager.Get("fabricatorinsufficientskills", returnNull: true) ?? "Insufficient skills to fabricate", textColor: Color.Orange)
|
||||
TextManager.Get("fabricatorinsufficientskills", returnNull: true) ?? "Insufficient skills to fabricate", textColor: Color.Orange, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true,
|
||||
CanBeFocused = false
|
||||
};
|
||||
var firstinSufficient = itemList.Content.Children.FirstOrDefault(c => c.UserData is FabricationRecipe fabricableItem && DegreeOfSuccess(character, fabricableItem.RequiredSkills) < 0.5f);
|
||||
@@ -223,7 +254,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (item.ParentInventory.slots[availableSlotIndex].HighlightTimer <= 0.0f)
|
||||
{
|
||||
item.ParentInventory.slots[availableSlotIndex].ShowBorderHighlight(Color.LightGreen * 0.5f, 0.5f, 0.5f);
|
||||
item.ParentInventory.slots[availableSlotIndex].ShowBorderHighlight(GUI.Style.Green * 0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,7 +308,7 @@ namespace Barotrauma.Items.Components
|
||||
new Rectangle(
|
||||
slotRect.X, slotRect.Y + (int)(slotRect.Height * (1.0f - progressState)),
|
||||
slotRect.Width, (int)(slotRect.Height * progressState)),
|
||||
Color.Green * 0.5f, isFilled: true);
|
||||
GUI.Style.Green * 0.5f, isFilled: true);
|
||||
}
|
||||
|
||||
itemIcon.Draw(
|
||||
@@ -327,8 +358,10 @@ namespace Barotrauma.Items.Components
|
||||
private bool SelectItem(Character user, FabricationRecipe selectedItem)
|
||||
{
|
||||
selectedItemFrame.ClearChildren();
|
||||
selectedItemReqsFrame.ClearChildren();
|
||||
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), selectedItemFrame.RectTransform, Anchor.Center)) { RelativeSpacing = 0.03f, Stretch = true };
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.9f), selectedItemFrame.RectTransform, Anchor.Center)) { RelativeSpacing = 0.03f };
|
||||
var paddedReqFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), selectedItemReqsFrame.RectTransform, Anchor.Center)) { RelativeSpacing = 0.03f };
|
||||
|
||||
/*var itemIcon = selectedItem.TargetItem.InventoryIcon ?? selectedItem.TargetItem.sprite;
|
||||
if (itemIcon != null)
|
||||
@@ -340,19 +373,27 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
}*/
|
||||
var nameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
|
||||
selectedItem.TargetItem.Name, textAlignment: Alignment.CenterLeft);
|
||||
|
||||
selectedItem.TargetItem.Name, textAlignment: Alignment.CenterLeft, textColor: Color.Aqua, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true
|
||||
};
|
||||
|
||||
nameBlock.Padding = new Vector4(0, nameBlock.Padding.Y, nameBlock.Padding.Z, nameBlock.Padding.W);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(selectedItem.TargetItem.Description))
|
||||
{
|
||||
var description = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
|
||||
selectedItem.TargetItem.Description,
|
||||
font: GUI.SmallFont, wrap: true);
|
||||
if (description.Rect.Height > paddedFrame.Rect.Height * 0.4f)
|
||||
description.Padding = new Vector4(0, description.Padding.Y, description.Padding.Z, description.Padding.W);
|
||||
|
||||
while (description.Rect.Height + nameBlock.Rect.Height > paddedFrame.Rect.Height)
|
||||
{
|
||||
description.Wrap = false;
|
||||
description.Text = description.WrappedText.Split('\n').First()+"...";
|
||||
nameBlock.ToolTip = description.ToolTip = selectedItem.TargetItem.Description;
|
||||
description.RectTransform.MaxSize = new Point(int.MaxValue, (int)description.Font.MeasureString(description.Text).Y);
|
||||
var lines = description.WrappedText.Split('\n');
|
||||
var newString = string.Join('\n', lines.Take(lines.Length - 1));
|
||||
description.Text = newString.Substring(0, newString.Length - 4) + "...";
|
||||
description.CalculateHeightFromText();
|
||||
description.ToolTip = selectedItem.TargetItem.Description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,24 +405,33 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (selectedItem.RequiredSkills.Any())
|
||||
{
|
||||
string text = TextManager.Get("FabricatorRequiredSkills") + ":\n";
|
||||
string text = "";
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedReqFrame.RectTransform),
|
||||
TextManager.Get("FabricatorRequiredSkills"), textColor: inadequateSkills.Any() ? GUI.Style.Red : GUI.Style.Green, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true,
|
||||
};
|
||||
foreach (Skill skill in selectedItem.RequiredSkills)
|
||||
{
|
||||
text += " - " + TextManager.Get("SkillName." + skill.Identifier) + " " + TextManager.Get("Lvl").ToLower() + " " + skill.Level;
|
||||
text += TextManager.Get("SkillName." + skill.Identifier) + " " + TextManager.Get("Lvl").ToLower() + " " + skill.Level;
|
||||
if (skill != selectedItem.RequiredSkills.Last()) { text += "\n"; }
|
||||
}
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform), text,
|
||||
textColor: inadequateSkills.Any() ? Color.Red : Color.LightGreen, font: GUI.SmallFont);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedReqFrame.RectTransform), text, font: GUI.SmallFont);
|
||||
}
|
||||
|
||||
float degreeOfSuccess = user == null ? 0.0f : DegreeOfSuccess(user, selectedItem.RequiredSkills);
|
||||
if (degreeOfSuccess > 0.5f) { degreeOfSuccess = 1.0f; }
|
||||
|
||||
float requiredTime = user == null ? selectedItem.RequiredTime : GetRequiredTime(selectedItem, user);
|
||||
string requiredTimeText = TextManager.AddPunctuation(':', TextManager.Get("FabricatorRequiredTime"), ToolBox.SecondsToReadableTime(requiredTime));
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
|
||||
requiredTimeText, textColor: ToolBox.GradientLerp(degreeOfSuccess, Color.Red, Color.Yellow, Color.LightGreen), font: GUI.SmallFont);
|
||||
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedReqFrame.RectTransform),
|
||||
TextManager.Get("FabricatorRequiredTime") , textColor: ToolBox.GradientLerp(degreeOfSuccess, GUI.Style.Red, Color.Yellow, GUI.Style.Green), font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true,
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedReqFrame.RectTransform), ToolBox.SecondsToReadableTime(requiredTime),
|
||||
font: GUI.SmallFont);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -413,7 +463,7 @@ namespace Barotrauma.Items.Components
|
||||
if (selectedItem == null) { return false; }
|
||||
if (!outputContainer.Inventory.IsEmpty())
|
||||
{
|
||||
outputInventoryHolder.Flash(Color.Red);
|
||||
outputSlot.Flash(GUI.Style.Red);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,25 +19,25 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private string noPowerTip = "";
|
||||
|
||||
private List<Submarine> displayedSubs = new List<Submarine>();
|
||||
private readonly List<Submarine> displayedSubs = new List<Submarine>();
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
noPowerTip = TextManager.Get("SteeringNoPowerTip");
|
||||
|
||||
GuiFrame.RectTransform.RelativeOffset = new Vector2(0.05f, 0.0f);
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center),
|
||||
new GUICustomComponent(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center) { AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
DrawHUDBack, null);
|
||||
submarineContainer = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center),
|
||||
new GUICustomComponent(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center) { AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
DrawHUDFront, null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
hullInfoFrame = new GUIFrame(new RectTransform(new Vector2(0.13f, 0.13f), GUI.Canvas, minSize: new Point(250, 150)),
|
||||
style: "InnerFrame")
|
||||
style: "GUIToolTip")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -120,7 +120,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 textPos = GuiFrame.Rect.Center.ToVector2();
|
||||
|
||||
GUI.DrawString(spriteBatch, textPos - textSize / 2, noPowerTip,
|
||||
Color.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f);
|
||||
GUI.Style.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f, font: GUI.SubHeadingFont);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Barotrauma.Items.Components
|
||||
if (textPos.X - textSize.X / 2 < submarineContainer.Rect.X)
|
||||
textPos.X += (submarineContainer.Rect.X - (textPos.X - textSize.X / 2)) + 10 * GUI.xScale;
|
||||
GUI.DrawString(spriteBatch, textPos - textSize / 2, text,
|
||||
Color.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f);
|
||||
GUI.Style.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ namespace Barotrauma.Items.Components
|
||||
if (ShowHullIntegrity)
|
||||
{
|
||||
gapOpenSum = hull.ConnectedGaps.Where(g => !g.IsRoomToRoom).Sum(g => g.Open);
|
||||
borderColor = Color.Lerp(neutralColor, Color.Red, Math.Min((float)gapOpenSum, 1.0f));
|
||||
borderColor = Color.Lerp(neutralColor, GUI.Style.Red, Math.Min((float)gapOpenSum, 1.0f));
|
||||
}
|
||||
|
||||
float? oxygenAmount = null;
|
||||
@@ -222,7 +222,7 @@ namespace Barotrauma.Items.Components
|
||||
oxygenAmount = RequireOxygenDetectors ? hullData.Oxygen : hull.OxygenPercentage;
|
||||
GUI.DrawRectangle(
|
||||
spriteBatch, hullFrame.Rect,
|
||||
Color.Lerp(Color.Red * 0.5f, Color.Green * 0.3f, (float)oxygenAmount / 100.0f),
|
||||
Color.Lerp(GUI.Style.Red * 0.5f, GUI.Style.Green * 0.3f, (float)oxygenAmount / 100.0f),
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -271,15 +271,15 @@ namespace Barotrauma.Items.Components
|
||||
waterAmount /= (hullData.LinkedHulls.Count + 1);
|
||||
|
||||
hullBreachText.Text = gapOpenSum > 0.1f ? TextManager.Get("MiniMapHullBreach") : "";
|
||||
hullBreachText.TextColor = Color.Red;
|
||||
hullBreachText.TextColor = GUI.Style.Red;
|
||||
|
||||
hullAirQualityText.Text = oxygenAmount == null ? TextManager.Get("MiniMapAirQualityUnavailable") :
|
||||
TextManager.AddPunctuation(':', TextManager.Get("MiniMapAirQuality"), + (int)oxygenAmount + " %");
|
||||
hullAirQualityText.TextColor = oxygenAmount == null ? Color.Red : Color.Lerp(Color.Red, Color.LightGreen, (float)oxygenAmount / 100.0f);
|
||||
hullAirQualityText.TextColor = oxygenAmount == null ? GUI.Style.Red : Color.Lerp(GUI.Style.Red, Color.LightGreen, (float)oxygenAmount / 100.0f);
|
||||
|
||||
hullWaterText.Text = waterAmount == null ? TextManager.Get("MiniMapWaterLevelUnavailable") :
|
||||
TextManager.AddPunctuation(':', TextManager.Get("MiniMapWaterLevel"), (int)(waterAmount * 100.0f) + " %");
|
||||
hullWaterText.TextColor = waterAmount == null ? Color.Red : Color.Lerp(Color.LightGreen, Color.Red, (float)waterAmount);
|
||||
hullWaterText.TextColor = waterAmount == null ? GUI.Style.Red : Color.Lerp(Color.LightGreen, GUI.Style.Red, (float)waterAmount);
|
||||
}
|
||||
|
||||
hullFrame.Color = borderColor;
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Pump : Powered, IServerSerializable, IClientSerializable
|
||||
{
|
||||
public GUIScrollBar IsActiveSlider { get; private set; }
|
||||
public GUIButton PowerButton { get; private set; }
|
||||
|
||||
private GUIScrollBar pumpSpeedSlider;
|
||||
private GUITickBox powerIndicator;
|
||||
private GUITickBox powerLight;
|
||||
private GUITickBox autoControlIndicator;
|
||||
|
||||
private List<Pair<Vector2, ParticleEmitter>> pumpOutEmitters = new List<Pair<Vector2, ParticleEmitter>>();
|
||||
@@ -40,70 +40,67 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (GuiFrame == null) { return; }
|
||||
|
||||
GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
IsActiveSlider = new GUIScrollBar(new RectTransform(new Point((int)(50 * GUI.Scale), (int)(100 * GUI.Scale)), paddedFrame.RectTransform, Anchor.CenterLeft),
|
||||
barSize: 0.2f, style: "OnOffLever")
|
||||
GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.85f, 0.65f), GuiFrame.RectTransform, Anchor.Center)
|
||||
{
|
||||
IsBooleanSwitch = true,
|
||||
MinValue = 0.25f,
|
||||
MaxValue = 0.75f
|
||||
RelativeOffset = new Vector2(0, 0.04f)
|
||||
}, style: null);
|
||||
|
||||
// Power button
|
||||
float powerButtonSize = 1f;
|
||||
var powerArea = new GUIFrame(new RectTransform(new Vector2(0.3f, 1) * powerButtonSize, paddedFrame.RectTransform, Anchor.CenterLeft), style: null);
|
||||
var paddedPowerArea = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.8f), powerArea.RectTransform, Anchor.Center), style: "PowerButtonFrame");
|
||||
var powerLightArea = new GUIFrame(new RectTransform(new Vector2(0.87f, 0.2f), powerArea.RectTransform, Anchor.TopRight), style: null);
|
||||
powerLight = new GUITickBox(new RectTransform(Vector2.One, powerLightArea.RectTransform, Anchor.Center),
|
||||
TextManager.Get("PowerLabel"), font: GUI.SubHeadingFont, style: "IndicatorLightPower")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
var sliderHandle = IsActiveSlider.GetChild<GUIButton>();
|
||||
sliderHandle.RectTransform.NonScaledSize = new Point((int)(84 * GUI.Scale), sliderHandle.Rect.Height);
|
||||
IsActiveSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
||||
powerLight.TextBlock.AutoScale = true;
|
||||
powerLight.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
PowerButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.75f), paddedPowerArea.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
bool active = scrollBar.BarScroll < 0.5f;
|
||||
if (active == IsActive) return false;
|
||||
|
||||
targetLevel = null;
|
||||
IsActive = active;
|
||||
if (!IsActive) currPowerConsumption = 0.0f;
|
||||
|
||||
if (GameMain.Client != null)
|
||||
RelativeOffset = new Vector2(0, 0.1f)
|
||||
}, style: "PowerButton")
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
correctionTimer = CorrectionDelay;
|
||||
item.CreateClientEvent(this);
|
||||
targetLevel = null;
|
||||
IsActive = !IsActive;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
correctionTimer = CorrectionDelay;
|
||||
item.CreateClientEvent(this);
|
||||
}
|
||||
powerLight.Selected = IsActive;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var rightArea = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 0.95f), paddedFrame.RectTransform, Anchor.CenterRight))
|
||||
{
|
||||
RelativeSpacing = 0.1f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
powerIndicator = new GUITickBox(new RectTransform(new Point((int)(30 * GUI.Scale)), rightArea.RectTransform), TextManager.Get("PumpPowered"), style: "IndicatorLightGreen")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
autoControlIndicator = new GUITickBox(new RectTransform(new Point((int)(30 * GUI.Scale)), rightArea.RectTransform), TextManager.Get("PumpAutoControl", fallBackTag: "ReactorAutoControl"), style: "IndicatorLightRed")
|
||||
var rightArea = new GUIFrame(new RectTransform(new Vector2(0.65f, 1), paddedFrame.RectTransform, Anchor.CenterRight), style: null);
|
||||
|
||||
autoControlIndicator = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.25f), rightArea.RectTransform, Anchor.TopLeft),
|
||||
TextManager.Get("PumpAutoControl", fallBackTag: "ReactorAutoControl"), font: GUI.SubHeadingFont, style: "IndicatorLightYellow")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
autoControlIndicator.TextBlock.AutoScale = true;
|
||||
autoControlIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
|
||||
var pumpSpeedText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), rightArea.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.0f) },
|
||||
"", textAlignment: Alignment.BottomLeft, wrap: true);
|
||||
var sliderArea = new GUIFrame(new RectTransform(new Vector2(1, 0.65f), rightArea.RectTransform, Anchor.BottomLeft), style: null);
|
||||
var pumpSpeedText = new GUITextBlock(new RectTransform(new Vector2(1, 0.3f), sliderArea.RectTransform, Anchor.TopLeft), "",
|
||||
textColor: GUI.Style.TextColor, textAlignment: Alignment.CenterLeft, wrap: false, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true
|
||||
};
|
||||
string pumpSpeedStr = TextManager.Get("PumpSpeed");
|
||||
pumpSpeedText.TextGetter = () => { return TextManager.AddPunctuation(':', pumpSpeedStr, (int)flowPercentage + " %"); };
|
||||
|
||||
var sliderArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), rightArea.RectTransform, Anchor.CenterLeft), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
|
||||
var outLabel = new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), sliderArea.RectTransform),
|
||||
TextManager.Get("PumpOut"), textAlignment: Alignment.Center, wrap: false, font: GUI.SmallFont);
|
||||
pumpSpeedSlider = new GUIScrollBar(new RectTransform(new Vector2(0.5f, 1.0f), sliderArea.RectTransform), barSize: 0.25f, style: "GUISlider")
|
||||
pumpSpeedSlider = new GUIScrollBar(new RectTransform(new Vector2(1, 0.35f), sliderArea.RectTransform, Anchor.Center), barSize: 0.1f, style: "DeviceSlider")
|
||||
{
|
||||
Step = 0.05f,
|
||||
OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
||||
{
|
||||
float newValue = barScroll * 200.0f - 100.0f;
|
||||
if (Math.Abs(newValue - FlowPercentage) < 0.1f) return false;
|
||||
if (Math.Abs(newValue - FlowPercentage) < 0.1f) { return false; }
|
||||
|
||||
FlowPercentage = newValue;
|
||||
|
||||
@@ -115,11 +112,11 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var inLabel = new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), sliderArea.RectTransform),
|
||||
TextManager.Get("PumpIn"), textAlignment: Alignment.Center, wrap: false, font: GUI.SmallFont);
|
||||
|
||||
rightArea.Recalculate();
|
||||
sliderArea.Recalculate();
|
||||
var textsArea = new GUIFrame(new RectTransform(new Vector2(1, 0.25f), sliderArea.RectTransform, Anchor.BottomCenter), style: null);
|
||||
var outLabel = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textsArea.RectTransform, Anchor.CenterLeft), TextManager.Get("PumpOut"),
|
||||
textColor: GUI.Style.TextColor, textAlignment: Alignment.CenterLeft, wrap: false, font: GUI.SubHeadingFont);
|
||||
var inLabel = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textsArea.RectTransform, Anchor.CenterRight), TextManager.Get("PumpIn"),
|
||||
textColor: GUI.Style.TextColor, textAlignment: Alignment.CenterRight, wrap: false, font: GUI.SubHeadingFont);
|
||||
GUITextBlock.AutoScaleAndNormalize(outLabel, inLabel);
|
||||
}
|
||||
|
||||
@@ -156,19 +153,36 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private float flickerTimer;
|
||||
private readonly float flickerFrequency = 1;
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
{
|
||||
pumpSpeedLockTimer -= deltaTime;
|
||||
isActiveLockTimer -= deltaTime;
|
||||
powerIndicator.Selected = hasPower && IsActive;
|
||||
autoControlIndicator.Selected = pumpSpeedLockTimer > 0.0f || isActiveLockTimer > 0.0f;
|
||||
IsActiveSlider.Enabled = isActiveLockTimer <= 0.0f;
|
||||
PowerButton.Enabled = isActiveLockTimer <= 0.0f;
|
||||
if (HasPower)
|
||||
{
|
||||
flickerTimer = 0;
|
||||
powerLight.Selected = IsActive;
|
||||
}
|
||||
else if (IsActive)
|
||||
{
|
||||
flickerTimer += deltaTime;
|
||||
if (flickerTimer > flickerFrequency)
|
||||
{
|
||||
flickerTimer = 0;
|
||||
powerLight.Selected = !powerLight.Selected;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flickerTimer = 0;
|
||||
powerLight.Selected = false;
|
||||
}
|
||||
pumpSpeedSlider.Enabled = pumpSpeedLockTimer <= 0.0f && IsActive;
|
||||
|
||||
if (!PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
IsActiveSlider.BarScroll += (IsActive ? -10.0f : 10.0f) * deltaTime;
|
||||
|
||||
float pumpSpeedScroll = (FlowPercentage + 100.0f) / 200.0f;
|
||||
if (Math.Abs(pumpSpeedScroll - pumpSpeedSlider.BarScroll) > 0.01f)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -10,21 +11,15 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Reactor : Powered, IServerSerializable, IClientSerializable
|
||||
{
|
||||
public GUIScrollBar AutoTempSlider
|
||||
{
|
||||
get { return autoTempSlider; }
|
||||
}
|
||||
private GUIScrollBar autoTempSlider;
|
||||
public GUIButton AutoTempSwitch { get; private set; }
|
||||
|
||||
public GUIScrollBar OnOffSwitch
|
||||
{
|
||||
get { return onOffSwitch; }
|
||||
}
|
||||
private GUIScrollBar onOffSwitch;
|
||||
public GUIButton PowerButton { get; private set; }
|
||||
private GUITickBox powerLight;
|
||||
private GUITickBox autoTempLight;
|
||||
|
||||
private const int GraphSize = 25;
|
||||
private float graphTimer;
|
||||
private int updateGraphInterval = 500;
|
||||
private readonly int updateGraphInterval = 500;
|
||||
|
||||
private Sprite fissionRateMeter, turbineOutputMeter;
|
||||
private Sprite meterPointer;
|
||||
@@ -34,21 +29,23 @@ namespace Barotrauma.Items.Components
|
||||
private Sprite tempRangeIndicator;
|
||||
|
||||
private Sprite graphLine;
|
||||
//private GUIFrame graph;
|
||||
|
||||
public GUIScrollBar FissionRateScrollBar
|
||||
{
|
||||
get { return fissionRateScrollBar; }
|
||||
}
|
||||
private GUIScrollBar fissionRateScrollBar;
|
||||
private Color optimalRangeColor = new Color(74,238,104,255);
|
||||
private Color offRangeColor = Color.Orange;
|
||||
private Color warningColor = Color.Red;
|
||||
private Color coldColor = Color.LightBlue;
|
||||
private Color warmColor = Color.Orange;
|
||||
private Color hotColor = Color.Red;
|
||||
private Color outputColor = Color.Goldenrod;
|
||||
private Color loadColor = Color.LightSteelBlue;
|
||||
|
||||
public GUIScrollBar TurbineOutputScrollBar
|
||||
{
|
||||
get { return turbineOutputScrollBar; }
|
||||
}
|
||||
private GUIScrollBar turbineOutputScrollBar;
|
||||
public GUIScrollBar FissionRateScrollBar { get; private set; }
|
||||
|
||||
private float[] outputGraph = new float[GraphSize];
|
||||
private float[] loadGraph = new float[GraphSize];
|
||||
public GUIScrollBar TurbineOutputScrollBar { get; private set; }
|
||||
|
||||
private readonly float[] outputGraph = new float[GraphSize];
|
||||
private readonly float[] loadGraph = new float[GraphSize];
|
||||
|
||||
private GUITickBox criticalHeatWarning;
|
||||
private GUITickBox lowTemperatureWarning;
|
||||
@@ -56,147 +53,149 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUIFrame inventoryContainer;
|
||||
|
||||
private GUIComponent leftHUDColumn;
|
||||
private GUIComponent midHUDColumn;
|
||||
private GUIComponent rightHUDColumn;
|
||||
private readonly Dictionary<string, GUIButton> warningButtons = new Dictionary<string, GUIButton>();
|
||||
|
||||
private GUILayoutGroup sliderControlsContainer;
|
||||
|
||||
private Dictionary<string, GUIButton> warningButtons = new Dictionary<string, GUIButton>();
|
||||
|
||||
private static string[] warningTexts = new string[]
|
||||
private static readonly string[] warningTexts = new string[]
|
||||
{
|
||||
"ReactorWarningLowTemp","ReactorWarningOverheating",
|
||||
"ReactorWarningLowOutput", "ReactorWarningHighOutput",
|
||||
"ReactorWarningLowFuel", "ReactorWarningFuelOut",
|
||||
"ReactorWarningMeltdown","ReactorWarningSCRAM"
|
||||
"ReactorWarningLowTemp", "ReactorWarningLowOutput", "ReactorWarningLowFuel", "ReactorWarningMeltdown",
|
||||
"ReactorWarningOverheating", "ReactorWarningHighOutput", "ReactorWarningFuelOut", "ReactorWarningSCRAM"
|
||||
};
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "fissionratemeter":
|
||||
fissionRateMeter = new Sprite(subElement);
|
||||
break;
|
||||
case "turbineoutputmeter":
|
||||
turbineOutputMeter = new Sprite(subElement);
|
||||
break;
|
||||
case "meterpointer":
|
||||
meterPointer = new Sprite(subElement);
|
||||
break;
|
||||
case "sectorsprite":
|
||||
sectorSprite = new Sprite(subElement);
|
||||
break;
|
||||
case "tempmeterframe":
|
||||
tempMeterFrame = new Sprite(subElement);
|
||||
break;
|
||||
case "tempmeterbar":
|
||||
tempMeterBar = new Sprite(subElement);
|
||||
break;
|
||||
case "temprangeindicator":
|
||||
tempRangeIndicator = new Sprite(subElement);
|
||||
break;
|
||||
case "graphline":
|
||||
graphLine = new Sprite(subElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: need to recreate the gui when the resolution changes
|
||||
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.85f), GuiFrame.RectTransform, Anchor.Center), isHorizontal: true)
|
||||
fissionRateMeter = new Sprite(element.GetChildElement("fissionratemeter")?.GetChildElement("sprite"));
|
||||
turbineOutputMeter = new Sprite(element.GetChildElement("turbineoutputmeter")?.GetChildElement("sprite"));
|
||||
meterPointer = new Sprite(element.GetChildElement("meterpointer")?.GetChildElement("sprite"));
|
||||
sectorSprite = new Sprite(element.GetChildElement("sectorsprite")?.GetChildElement("sprite"));
|
||||
tempMeterFrame = new Sprite(element.GetChildElement("tempmeterframe")?.GetChildElement("sprite"));
|
||||
tempMeterBar = new Sprite(element.GetChildElement("tempmeterbar")?.GetChildElement("sprite"));
|
||||
tempRangeIndicator = new Sprite(element.GetChildElement("temprangeindicator")?.GetChildElement("sprite"));
|
||||
graphLine = new Sprite(element.GetChildElement("graphline")?.GetChildElement("sprite"));
|
||||
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(
|
||||
GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin.Multiply(new Vector2(1.4f, 1.2f)), GuiFrame.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
isHorizontal: true)
|
||||
{
|
||||
RelativeSpacing = 0.012f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
GUIFrame columnLeft = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), paddedFrame.RectTransform), style: null);
|
||||
GUIFrame columnMid = new GUIFrame(new RectTransform(new Vector2(0.45f, 1.0f), paddedFrame.RectTransform), style: null);
|
||||
GUIFrame columnRight = new GUIFrame(new RectTransform(new Vector2(0.3f, 1.0f), paddedFrame.RectTransform), style: null);
|
||||
leftHUDColumn = columnLeft;
|
||||
midHUDColumn = columnMid;
|
||||
rightHUDColumn = columnRight;
|
||||
GUILayoutGroup columnLeft = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), paddedFrame.RectTransform))
|
||||
{
|
||||
RelativeSpacing = 0.012f,
|
||||
Stretch = true
|
||||
};
|
||||
GUILayoutGroup columnRight = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 1.0f), paddedFrame.RectTransform))
|
||||
{
|
||||
RelativeSpacing = 0.012f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
||||
//left column
|
||||
//----------------------------------------------------------
|
||||
|
||||
int buttonsPerRow = 2;
|
||||
int spacing = 5;
|
||||
int buttonWidth = columnLeft.Rect.Width / buttonsPerRow - (spacing * (buttonsPerRow - 1));
|
||||
int buttonHeight = (int)(columnLeft.Rect.Height * 0.5f) / 4;
|
||||
for (int i = 0; i < warningTexts.Length; i++)
|
||||
GUIFrame inventoryWindow = new GUIFrame(new RectTransform(new Vector2(0.1f, 0.5f), GuiFrame.RectTransform, Anchor.TopLeft, Pivot.TopRight)
|
||||
{
|
||||
var warningBtn = new GUIButton(new RectTransform(new Point(buttonWidth, buttonHeight), columnLeft.RectTransform)
|
||||
{ AbsoluteOffset = new Point((i % buttonsPerRow) * (buttonWidth + spacing), (int)Math.Floor(i / (float)buttonsPerRow) * (buttonHeight + spacing)) },
|
||||
TextManager.Get(warningTexts[i]), style: "IndicatorButton")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
MinSize = new Point(85, 220),
|
||||
RelativeOffset = new Vector2(-0.02f, 0)
|
||||
}, style: "ItemUI");
|
||||
|
||||
var btnText = warningBtn.GetChild<GUITextBlock>();
|
||||
btnText.Font = GUI.Font;
|
||||
btnText.Wrap = false;
|
||||
btnText.SetTextPos();
|
||||
warningButtons.Add(warningTexts[i], warningBtn);
|
||||
}
|
||||
GUITextBlock.AutoScaleAndNormalize(warningButtons.Values.Select(b => b.TextBlock));
|
||||
GUILayoutGroup inventoryContent = new GUILayoutGroup(new RectTransform(inventoryWindow.Rect.Size - GUIStyle.ItemFrameMargin.Multiply(0.75f), inventoryWindow.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
inventoryContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.45f), columnLeft.RectTransform, Anchor.BottomLeft), style: null);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), inventoryContent.RectTransform), "",
|
||||
textAlignment: Alignment.Center, font: GUI.SubHeadingFont, wrap: true);
|
||||
inventoryContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), inventoryContent.RectTransform), style: null);
|
||||
|
||||
//----------------------------------------------------------
|
||||
//mid column
|
||||
//----------------------------------------------------------
|
||||
|
||||
criticalHeatWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform),
|
||||
TextManager.Get("ReactorWarningCriticalTemp"), font: GUI.SmallFont, style: "IndicatorLightRed")
|
||||
|
||||
var topLeftArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform),
|
||||
isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
lowTemperatureWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform) { RelativeOffset = new Vector2(0.27f, 0.0f) },
|
||||
TextManager.Get("ReactorWarningCriticalLowTemp"), font: GUI.SmallFont, style: "IndicatorLightRed")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
criticalOutputWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform) { RelativeOffset = new Vector2(0.66f, 0.0f) },
|
||||
TextManager.Get("ReactorWarningCriticalOutput"), font: GUI.SmallFont, style: "IndicatorLightRed")
|
||||
{
|
||||
CanBeFocused = false
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
GUITextBlock.AutoScaleAndNormalize(criticalHeatWarning.TextBlock, lowTemperatureWarning.TextBlock, criticalOutputWarning.TextBlock);
|
||||
|
||||
float gaugeOffset = criticalHeatWarning.Rect.Height / (float)columnMid.Rect.Height + 0.05f * GUI.Scale;
|
||||
Point maxIndicatorSize = new Point(int.MaxValue, (int)(50 * GUI.Scale));
|
||||
criticalHeatWarning = new GUITickBox(new RectTransform(new Vector2(0.3f, 1.0f), topLeftArea.RectTransform) { MaxSize = maxIndicatorSize },
|
||||
TextManager.Get("ReactorWarningCriticalTemp"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
lowTemperatureWarning = new GUITickBox(new RectTransform(new Vector2(0.4f, 1.0f), topLeftArea.RectTransform) { MaxSize = maxIndicatorSize },
|
||||
TextManager.Get("ReactorWarningCriticalLowTemp"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
criticalOutputWarning = new GUITickBox(new RectTransform(new Vector2(0.3f, 1.0f), topLeftArea.RectTransform) { MaxSize = maxIndicatorSize },
|
||||
TextManager.Get("ReactorWarningCriticalOutput"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
criticalHeatWarning.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
lowTemperatureWarning.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
criticalOutputWarning.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnMid.RectTransform) { RelativeOffset = new Vector2(0.0f, gaugeOffset) },
|
||||
TextManager.Get("ReactorFissionRate"));
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.5f, 0.5f), columnMid.RectTransform) { RelativeOffset = new Vector2(0.0f, gaugeOffset + 0.05f) },
|
||||
topLeftArea.Recalculate();
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.01f), columnLeft.RectTransform), style: "HorizontalLine");
|
||||
|
||||
float relativeYMargin = 0.02f;
|
||||
Vector2 relativeTextSize = new Vector2(0.8f, 0.1f);
|
||||
Vector2 sliderSize = new Vector2(1.0f, 0.125f);
|
||||
Vector2 meterSize = new Vector2(1, 1 - relativeTextSize.Y - relativeYMargin - sliderSize.Y - 0.1f);
|
||||
|
||||
var meterArea = new GUIFrame(new RectTransform(new Vector2(1, 0.6f - relativeYMargin * 2), columnLeft.RectTransform), style: null);
|
||||
var leftArea = new GUIFrame(new RectTransform(new Vector2(0.49f, 1), meterArea.RectTransform), style: null);
|
||||
var rightArea = new GUIFrame(new RectTransform(new Vector2(0.49f, 1), meterArea.RectTransform, Anchor.TopCenter, Pivot.TopLeft), style: null);
|
||||
|
||||
var fissionRateTextBox = new GUITextBlock(new RectTransform(relativeTextSize, leftArea.RectTransform, Anchor.TopCenter),
|
||||
TextManager.Get("ReactorFissionRate"), textColor: GUI.Style.TextColor, textAlignment: Alignment.Center, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true
|
||||
};
|
||||
var fissionMeter = new GUICustomComponent(new RectTransform(meterSize, leftArea.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0.0f, relativeTextSize.Y + relativeYMargin)
|
||||
},
|
||||
DrawFissionRateMeter, null)
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipFissionRate")
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnMid.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, gaugeOffset) },
|
||||
TextManager.Get("ReactorTurbineOutput"));
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.5f, 0.5f), columnMid.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, gaugeOffset + 0.05f) },
|
||||
var turbineOutputTextBox = new GUITextBlock(new RectTransform(relativeTextSize, rightArea.RectTransform, Anchor.TopCenter),
|
||||
TextManager.Get("ReactorTurbineOutput"), textColor: GUI.Style.TextColor, textAlignment: Alignment.Center, font: GUI.SubHeadingFont)
|
||||
{
|
||||
AutoScale = true
|
||||
};
|
||||
GUITextBlock.AutoScaleAndNormalize(turbineOutputTextBox, fissionRateTextBox);
|
||||
|
||||
var turbineMeter = new GUICustomComponent(new RectTransform(meterSize, rightArea.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0.0f, relativeTextSize.Y + relativeYMargin)
|
||||
},
|
||||
DrawTurbineOutputMeter, null)
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipTurbineOutput")
|
||||
};
|
||||
|
||||
GUILayoutGroup sliderControls = new GUILayoutGroup(new RectTransform(new Point(columnMid.Rect.Width, (int)(114 * GUI.Scale)), columnMid.RectTransform, Anchor.BottomCenter))
|
||||
FissionRateScrollBar = new GUIScrollBar(new RectTransform(sliderSize, leftArea.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true,
|
||||
AbsoluteSpacing = (int)(5 * GUI.Scale)
|
||||
};
|
||||
sliderControlsContainer = sliderControls;
|
||||
|
||||
new GUITextBlock(new RectTransform(new Point(0, (int)(20 * GUI.Scale)), sliderControls.RectTransform, Anchor.TopLeft),
|
||||
TextManager.Get("ReactorFissionRate"));
|
||||
fissionRateScrollBar = new GUIScrollBar(new RectTransform(new Point(sliderControls.Rect.Width, (int)(30 * GUI.Scale)), sliderControls.RectTransform, Anchor.TopCenter),
|
||||
style: "GUISlider", barSize: 0.1f)
|
||||
RelativeOffset = new Vector2(0, fissionMeter.RectTransform.RelativeOffset.Y + meterSize.Y)
|
||||
},
|
||||
style: "DeviceSlider", barSize: 0.1f)
|
||||
{
|
||||
Enabled = false,
|
||||
OnMoved = (GUIScrollBar bar, float scrollAmount) =>
|
||||
{
|
||||
LastUser = Character.Controlled;
|
||||
@@ -207,11 +206,13 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Point(0, (int)(20 * GUI.Scale)), sliderControls.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("ReactorTurbineOutput"));
|
||||
turbineOutputScrollBar = new GUIScrollBar(new RectTransform(new Point(sliderControls.Rect.Width, (int)(30 * GUI.Scale)), sliderControls.RectTransform, Anchor.BottomCenter),
|
||||
style: "GUISlider", barSize: 0.1f, isHorizontal: true)
|
||||
TurbineOutputScrollBar = new GUIScrollBar(new RectTransform(sliderSize, rightArea.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0, turbineMeter.RectTransform.RelativeOffset.Y + meterSize.Y)
|
||||
},
|
||||
style: "DeviceSlider", barSize: 0.1f, isHorizontal: true)
|
||||
{
|
||||
Enabled = false,
|
||||
OnMoved = (GUIScrollBar bar, float scrollAmount) =>
|
||||
{
|
||||
LastUser = Character.Controlled;
|
||||
@@ -222,134 +223,219 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform))
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
var upperButtons = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.5f), buttonArea.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
var lowerButtons = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.5f), buttonArea.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
int buttonCount = warningTexts.Length;
|
||||
for (int i = 0; i < buttonCount; i++)
|
||||
{
|
||||
string text = warningTexts[i];
|
||||
var b = new GUIButton(new RectTransform(Vector2.One, (i < 4) ? upperButtons.RectTransform : lowerButtons.RectTransform),
|
||||
TextManager.Get(text), style: "IndicatorButton")
|
||||
{
|
||||
Font = GUI.SubHeadingFont,
|
||||
CanBeFocused = false
|
||||
};
|
||||
b.TextBlock.Wrap = false;
|
||||
warningButtons.Add(text, b);
|
||||
}
|
||||
upperButtons.Recalculate();
|
||||
lowerButtons.Recalculate();
|
||||
GUITextBlock.AutoScaleAndNormalize(warningButtons.Values.Select(b => b.TextBlock));
|
||||
|
||||
//----------------------------------------------------------
|
||||
//right column
|
||||
//----------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.1f), columnRight.RectTransform), TextManager.Get("ReactorAutoTemp"))
|
||||
// Auto temp
|
||||
var topRightArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), columnRight.RectTransform),
|
||||
isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipAutoTemp"),
|
||||
AutoScale = true
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
autoTempSlider = new GUIScrollBar(new RectTransform(new Vector2(0.6f, 0.15f), columnRight.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.1f) },
|
||||
barSize: 0.55f, style: "OnOffSlider", isHorizontal: true)
|
||||
topRightArea.RectTransform.MaxSize = new Point(int.MaxValue, topLeftArea.Rect.Height);
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(0.01f, 1.0f), topRightArea.RectTransform), style: "VerticalLine");
|
||||
|
||||
AutoTempSwitch = new GUIButton(new RectTransform(new Vector2(0.15f, 0.9f), topRightArea.RectTransform),
|
||||
style: "SwitchVertical")
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipAutoTemp"),
|
||||
IsBooleanSwitch = true,
|
||||
BarScroll = 1.0f,
|
||||
OnMoved = (scrollBar, scrollAmount) =>
|
||||
Enabled = false,
|
||||
Selected = AutoTemp,
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
AutoTemp = !AutoTemp;
|
||||
LastUser = Character.Controlled;
|
||||
unsentChanges = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var sliderSprite = autoTempSlider.Frame.Style.Sprites[GUIComponent.ComponentState.None].First();
|
||||
autoTempSlider.RectTransform.MaxSize = new Point((int)(sliderSprite.Sprite.SourceRect.Size.X * GUI.Scale), (int)(sliderSprite.Sprite.SourceRect.Size.Y * GUI.Scale));
|
||||
AutoTempSwitch.RectTransform.MaxSize = new Point((int)(AutoTempSwitch.Rect.Height * 0.4f), int.MaxValue);
|
||||
|
||||
onOffSwitch = new GUIScrollBar(new RectTransform(new Vector2(0.4f, 0.3f), columnRight.RectTransform, Anchor.TopRight),
|
||||
barSize: 0.2f, style: "OnOffLever", isHorizontal: false)
|
||||
{
|
||||
IsBooleanSwitch = true,
|
||||
MinValue = 0.25f,
|
||||
MaxValue = 0.75f,
|
||||
OnMoved = (scrollBar, scrollAmount) =>
|
||||
autoTempLight = new GUITickBox(new RectTransform(new Vector2(0.4f, 1.0f), topRightArea.RectTransform),
|
||||
TextManager.Get("ReactorAutoTemp"), font: GUI.SubHeadingFont, style: "IndicatorLightYellow")
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipAutoTemp"),
|
||||
CanBeFocused = true,
|
||||
Selected = AutoTemp
|
||||
};
|
||||
autoTempLight.RectTransform.MaxSize = new Point(int.MaxValue, criticalHeatWarning.Rect.Height);
|
||||
autoTempLight.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(0.01f, 1.0f), topRightArea.RectTransform), style: "VerticalLine");
|
||||
|
||||
// Power button
|
||||
var powerArea = new GUIFrame(new RectTransform(new Vector2(0.4f, 1.0f), topRightArea.RectTransform), style: null);
|
||||
var paddedPowerArea = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), powerArea.RectTransform, Anchor.Center, scaleBasis: ScaleBasis.BothHeight), style: "PowerButtonFrame");
|
||||
powerLight = new GUITickBox(new RectTransform(new Vector2(0.87f, 0.2f), paddedPowerArea.RectTransform, Anchor.TopCenter, Pivot.Center),
|
||||
TextManager.Get("PowerLabel"), font: GUI.SubHeadingFont, style: "IndicatorLightPower")
|
||||
{
|
||||
CanBeFocused = false,
|
||||
Selected = _powerOn
|
||||
};
|
||||
powerLight.TextBlock.AutoScale = true;
|
||||
powerLight.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
PowerButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.75f), paddedPowerArea.RectTransform, Anchor.BottomCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0, 0.1f)
|
||||
}, style: "PowerButton")
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
PowerOn = !PowerOn;
|
||||
LastUser = Character.Controlled;
|
||||
unsentChanges = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var switchSprite = onOffSwitch.Frame.Style.Sprites[GUIComponent.ComponentState.None].First();
|
||||
onOffSwitch.RectTransform.MaxSize = new Point((int)(switchSprite.Sprite.SourceRect.Size.X * GUI.Scale), (int)(switchSprite.Sprite.SourceRect.Size.Y * GUI.Scale));
|
||||
|
||||
var lever = onOffSwitch.GetChild<GUIButton>();
|
||||
lever.RectTransform.NonScaledSize = new Point(lever.Rect.Width + (int)(30 * GUI.Scale), lever.Rect.Height);
|
||||
topRightArea.Recalculate();
|
||||
autoTempLight.TextBlock.Wrap = true;
|
||||
GUITextBlock.AutoScaleAndNormalize(
|
||||
criticalHeatWarning.TextBlock, lowTemperatureWarning.TextBlock, criticalOutputWarning.TextBlock, autoTempLight.TextBlock);
|
||||
|
||||
var graphArea = new GUICustomComponent(new RectTransform(new Vector2(1.0f, 0.5f), columnRight.RectTransform, Anchor.BottomCenter) { AbsoluteOffset = new Point(0, 30) },
|
||||
DrawGraph, null);
|
||||
// right bottom (graph area) -----------------------
|
||||
|
||||
Point textSize = new Point((int)(100 * GUI.Scale), (int)(30 * GUI.Scale));
|
||||
new GUIFrame(new RectTransform(new Vector2(0.95f, 0.01f), columnRight.RectTransform), style: "HorizontalLine");
|
||||
|
||||
var loadText = new GUITextBlock(new RectTransform(textSize, graphArea.RectTransform, Anchor.TopLeft, Pivot.BottomLeft),
|
||||
"Load", textColor: Color.LightBlue, textAlignment: Alignment.CenterLeft)
|
||||
var bottomRightArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), columnRight.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(0.01f, 1.0f), bottomRightArea.RectTransform), style: "VerticalLine");
|
||||
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.1f, 1), bottomRightArea.RectTransform, Anchor.Center), DrawTempMeter, null);
|
||||
|
||||
var graphArea = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 1.0f), bottomRightArea.RectTransform))
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
relativeTextSize = new Vector2(1.0f, 0.0f);
|
||||
var loadText = new GUITextBlock(new RectTransform(relativeTextSize, graphArea.RectTransform),
|
||||
"Load", textColor: loadColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipLoad")
|
||||
};
|
||||
string loadStr = TextManager.Get("ReactorLoad");
|
||||
loadText.TextGetter += () => { return loadStr.Replace("[kw]", ((int)load).ToString()); };
|
||||
string kW = TextManager.Get("kilowatt");
|
||||
loadText.TextGetter += () => $"{loadStr.Replace("[kw]", ((int)load).ToString())} {kW}";
|
||||
|
||||
var graph = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), graphArea.RectTransform), style: "InnerFrameRed");
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.9f, 0.98f), graph.RectTransform, Anchor.Center), DrawGraph, null);
|
||||
|
||||
var outputText = new GUITextBlock(new RectTransform(textSize, graphArea.RectTransform, Anchor.BottomLeft, Pivot.TopLeft),
|
||||
"Output", textColor: Color.LightGreen, textAlignment: Alignment.CenterLeft)
|
||||
var outputText = new GUITextBlock(new RectTransform(relativeTextSize, graphArea.RectTransform),
|
||||
"Output", textColor: outputColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
ToolTip = TextManager.Get("ReactorTipPower")
|
||||
};
|
||||
string outputStr = TextManager.Get("ReactorOutput");
|
||||
outputText.TextGetter += () => { return outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString()); };
|
||||
outputText.TextGetter += () => $"{outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString())} {kW}";
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
{
|
||||
base.OnItemLoaded();
|
||||
turbineOutputScrollBar.BarScroll = targetTurbineOutput / 100.0f;
|
||||
fissionRateScrollBar.BarScroll = targetFissionRate / 100.0f;
|
||||
TurbineOutputScrollBar.BarScroll = targetTurbineOutput / 100.0f;
|
||||
FissionRateScrollBar.BarScroll = targetFissionRate / 100.0f;
|
||||
var itemContainer = item.GetComponent<ItemContainer>();
|
||||
if (itemContainer != null)
|
||||
{
|
||||
itemContainer.AllowUIOverlap = true;
|
||||
itemContainer.Inventory.RectTransform = inventoryContainer.RectTransform;
|
||||
var inventoryLabel = inventoryContainer.Parent?.GetChild<GUITextBlock>();
|
||||
if (inventoryLabel != null)
|
||||
{
|
||||
inventoryLabel.RectTransform.MinSize = new Point(100, 0);
|
||||
inventoryLabel.Text = itemContainer.GetUILabel();
|
||||
inventoryLabel.CalculateHeightFromText();
|
||||
(inventoryLabel.Parent as GUILayoutGroup).Recalculate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGraph(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
private void DrawTempMeter(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
{
|
||||
if (item.Removed) { return; }
|
||||
Vector2 meterPos = new Vector2(container.Rect.X, container.Rect.Y);
|
||||
Vector2 meterScale = new Vector2(container.Rect.Width / (float)tempMeterFrame.SourceRect.Width, container.Rect.Height / (float)tempMeterFrame.SourceRect.Height);
|
||||
tempMeterFrame.Draw(spriteBatch, meterPos, Color.White, tempMeterFrame.Origin, 0.0f, scale: meterScale);
|
||||
|
||||
Rectangle graphArea = new Rectangle(container.Rect.X + 30, container.Rect.Y, container.Rect.Width - 30, container.Rect.Height);
|
||||
|
||||
float maxLoad = loadGraph.Max();
|
||||
|
||||
float xOffset = graphTimer / updateGraphInterval;
|
||||
DrawGraph(outputGraph, spriteBatch,
|
||||
graphArea, Math.Max(10000.0f, maxLoad), xOffset, Color.LightGreen);
|
||||
|
||||
DrawGraph(loadGraph, spriteBatch,
|
||||
graphArea, Math.Max(10000.0f, maxLoad), xOffset, Color.LightBlue);
|
||||
|
||||
tempMeterFrame.Draw(spriteBatch, new Vector2(graphArea.X - 30, graphArea.Y), Color.White, Vector2.Zero, 0.0f, new Vector2(1.0f, graphArea.Height / tempMeterFrame.size.Y));
|
||||
float tempFill = temperature / 100.0f;
|
||||
|
||||
int barPadding = 5;
|
||||
Vector2 meterBarPos = new Vector2(graphArea.X - 30 + tempMeterFrame.size.X / 2, graphArea.Bottom - tempMeterBar.size.Y);
|
||||
while (meterBarPos.Y > graphArea.Bottom - graphArea.Height * tempFill)
|
||||
float meterBarScale = container.Rect.Width / (float)tempMeterBar.SourceRect.Width;
|
||||
Vector2 meterBarPos = new Vector2(container.Center.X, container.Rect.Bottom - tempMeterBar.size.Y * meterBarScale - (int)(5 * GUI.yScale));
|
||||
while (meterBarPos.Y > container.Rect.Bottom + (int)(5 * GUI.yScale) - container.Rect.Height * tempFill)
|
||||
{
|
||||
float tempRatio = 1.0f - ((meterBarPos.Y - graphArea.Y) / graphArea.Height);
|
||||
Color color = tempRatio < 0.5f ?
|
||||
Color.Lerp(Color.Green, Color.Orange, tempRatio * 2.0f) :
|
||||
Color.Lerp(Color.Orange, Color.Red, (tempRatio - 0.5f) * 2.0f);
|
||||
|
||||
tempMeterBar.Draw(spriteBatch, meterBarPos, color);
|
||||
meterBarPos.Y -= (tempMeterBar.size.Y + barPadding);
|
||||
float tempRatio = 1.0f - ((meterBarPos.Y - container.Rect.Y) / container.Rect.Height);
|
||||
Color color = ToolBox.GradientLerp(tempRatio, coldColor, optimalRangeColor, warmColor, hotColor);
|
||||
tempMeterBar.Draw(spriteBatch, meterBarPos, color: color, scale: meterBarScale);
|
||||
int spacing = 2;
|
||||
meterBarPos.Y -= tempMeterBar.size.Y * meterBarScale + spacing;
|
||||
}
|
||||
|
||||
if (temperature > optimalTemperature.Y)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(graphArea.X - 30, graphArea.Y),
|
||||
new Vector2(tempMeterFrame.SourceRect.Width, (graphArea.Bottom - graphArea.Height * optimalTemperature.Y / 100.0f) - graphArea.Y),
|
||||
Color.Red * (float)Math.Sin(Timing.TotalTime * 5.0f) * 0.7f, isFilled: true);
|
||||
meterPos,
|
||||
new Vector2(container.Rect.Width, (container.Rect.Bottom - container.Rect.Height * optimalTemperature.Y / 100.0f) - container.Rect.Y),
|
||||
warningColor * (float)Math.Sin(Timing.TotalTime * 5.0f) * 0.7f, isFilled: true);
|
||||
}
|
||||
if (temperature < optimalTemperature.X)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(graphArea.X - 30, graphArea.Bottom - graphArea.Height * optimalTemperature.X / 100.0f),
|
||||
new Vector2(tempMeterFrame.SourceRect.Width, graphArea.Bottom - (graphArea.Bottom - graphArea.Height * optimalTemperature.X / 100.0f)),
|
||||
Color.Red * (float)Math.Sin(Timing.TotalTime * 5.0f) * 0.7f, isFilled: true);
|
||||
new Vector2(meterPos.X, container.Rect.Bottom - container.Rect.Height * optimalTemperature.X / 100.0f),
|
||||
new Vector2(container.Rect.Width, container.Rect.Bottom - (container.Rect.Bottom - container.Rect.Height * optimalTemperature.X / 100.0f)),
|
||||
warningColor * (float)Math.Sin(Timing.TotalTime * 5.0f) * 0.7f, isFilled: true);
|
||||
}
|
||||
|
||||
tempRangeIndicator.Draw(spriteBatch, new Vector2(meterBarPos.X, graphArea.Bottom - graphArea.Height * optimalTemperature.X / 100.0f));
|
||||
tempRangeIndicator.Draw(spriteBatch, new Vector2(meterBarPos.X, graphArea.Bottom - graphArea.Height * optimalTemperature.Y / 100.0f));
|
||||
float tempRangeIndicatorScale = container.Rect.Width / (float)tempRangeIndicator.SourceRect.Width;
|
||||
tempRangeIndicator.Draw(spriteBatch, new Vector2(container.Center.X, container.Rect.Bottom - container.Rect.Height * optimalTemperature.X / 100.0f), Color.White, tempRangeIndicator.Origin, 0, scale: tempRangeIndicatorScale);
|
||||
tempRangeIndicator.Draw(spriteBatch, new Vector2(container.Center.X, container.Rect.Bottom - container.Rect.Height * optimalTemperature.Y / 100.0f), Color.White, tempRangeIndicator.Origin, 0, scale: tempRangeIndicatorScale);
|
||||
}
|
||||
|
||||
private void DrawGraph(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
{
|
||||
if (item.Removed) { return; }
|
||||
float maxLoad = loadGraph.Max();
|
||||
float xOffset = graphTimer / updateGraphInterval;
|
||||
Rectangle graphRect = new Rectangle(container.Rect.X, container.Rect.Y, container.Rect.Width, container.Rect.Height - (int)(5 * GUI.yScale));
|
||||
DrawGraph(outputGraph, spriteBatch, graphRect, Math.Max(10000.0f, maxLoad), xOffset, outputColor);
|
||||
DrawGraph(loadGraph, spriteBatch, graphRect, Math.Max(10000.0f, maxLoad), xOffset, loadColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -367,8 +453,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (autoTemp)
|
||||
{
|
||||
fissionRateScrollBar.BarScroll = FissionRate / 100.0f;
|
||||
turbineOutputScrollBar.BarScroll = TurbineOutput / 100.0f;
|
||||
FissionRateScrollBar.BarScroll = FissionRate / 100.0f;
|
||||
TurbineOutputScrollBar.BarScroll = TurbineOutput / 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,10 +497,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
IsActive = true;
|
||||
|
||||
bool lightOn = Timing.TotalTime % 0.5f < 0.25f && onOffSwitch.BarScroll < 0.5f;
|
||||
|
||||
fissionRateScrollBar.Enabled = !autoTemp;
|
||||
turbineOutputScrollBar.Enabled = !autoTemp;
|
||||
bool lightOn = Timing.TotalTime % 0.5f < 0.25f && PowerOn;
|
||||
|
||||
criticalHeatWarning.Selected = temperature > allowedTemperature.Y && lightOn;
|
||||
lowTemperatureWarning.Selected = temperature < allowedTemperature.X && lightOn;
|
||||
@@ -427,21 +510,19 @@ namespace Barotrauma.Items.Components
|
||||
warningButtons["ReactorWarningFuelOut"].Selected = prevAvailableFuel < fissionRate * 0.01f && lightOn;
|
||||
warningButtons["ReactorWarningLowFuel"].Selected = prevAvailableFuel < fissionRate && lightOn;
|
||||
warningButtons["ReactorWarningMeltdown"].Selected = meltDownTimer > MeltdownDelay * 0.5f || item.Condition == 0.0f && lightOn;
|
||||
warningButtons["ReactorWarningSCRAM"].Selected = temperature > 0.1f && onOffSwitch.BarScroll > 0.5f;
|
||||
warningButtons["ReactorWarningSCRAM"].Selected = temperature > 0.1f && !PowerOn;
|
||||
|
||||
AutoTemp = autoTempSlider.BarScroll < 0.5f;
|
||||
shutDown = onOffSwitch.BarScroll > 0.5f;
|
||||
|
||||
if ((sliderControlsContainer.Rect.Contains(PlayerInput.MousePosition) || sliderControlsContainer.Children.Contains(GUIScrollBar.DraggingBar)) &&
|
||||
if ((FissionRateScrollBar.Rect.Contains(PlayerInput.MousePosition) || FissionRateScrollBar.Children.Contains(GUIScrollBar.DraggingBar) ||
|
||||
TurbineOutputScrollBar.Rect.Contains(PlayerInput.MousePosition) || TurbineOutputScrollBar.Children.Contains(GUIScrollBar.DraggingBar)) &&
|
||||
!PlayerInput.KeyDown(InputType.Deselect) && !PlayerInput.KeyHit(InputType.Deselect))
|
||||
{
|
||||
Character.DisableControls = true;
|
||||
}
|
||||
|
||||
if (shutDown)
|
||||
if (!PowerOn)
|
||||
{
|
||||
fissionRateScrollBar.BarScroll = FissionRate / 100.0f;
|
||||
turbineOutputScrollBar.BarScroll = TurbineOutput / 100.0f;
|
||||
FissionRateScrollBar.BarScroll = FissionRate / 100.0f;
|
||||
TurbineOutputScrollBar.BarScroll = TurbineOutput / 100.0f;
|
||||
}
|
||||
else if (!autoTemp && Character.DisableControls && GUI.KeyboardDispatcher.Subscriber == null)
|
||||
{
|
||||
@@ -465,29 +546,20 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
LastUser = Character.Controlled;
|
||||
unsentChanges = true;
|
||||
if (input.X != 0.0f && GUIScrollBar.DraggingBar != fissionRateScrollBar)
|
||||
if (input.X != 0.0f && GUIScrollBar.DraggingBar != FissionRateScrollBar)
|
||||
{
|
||||
targetFissionRate = MathHelper.Clamp(targetFissionRate + input.X, 0.0f, 100.0f);
|
||||
fissionRateScrollBar.BarScroll += input.X / 100.0f;
|
||||
FissionRateScrollBar.BarScroll += input.X / 100.0f;
|
||||
}
|
||||
if (input.Y != 0.0f && GUIScrollBar.DraggingBar != turbineOutputScrollBar)
|
||||
if (input.Y != 0.0f && GUIScrollBar.DraggingBar != TurbineOutputScrollBar)
|
||||
{
|
||||
targetTurbineOutput = MathHelper.Clamp(targetTurbineOutput + input.Y, 0.0f, 100.0f);
|
||||
turbineOutputScrollBar.BarScroll += input.Y / 100.0f;
|
||||
TurbineOutputScrollBar.BarScroll += input.Y / 100.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool ToggleAutoTemp(GUITickBox tickBox)
|
||||
{
|
||||
unsentChanges = true;
|
||||
autoTemp = tickBox.Selected;
|
||||
LastUser = Character.Controlled;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DrawMeter(SpriteBatch spriteBatch, Rectangle rect, Sprite meterSprite, float value, Vector2 range, Vector2 optimalRange, Vector2 allowedRange)
|
||||
{
|
||||
float scale = Math.Min(rect.Width / meterSprite.size.X, rect.Height / meterSprite.size.Y);
|
||||
@@ -513,7 +585,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (optimalRangeNormalized.X == optimalRangeNormalized.Y)
|
||||
{
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Red, MathHelper.PiOver2, scale);
|
||||
sectorSprite.Draw(spriteBatch, pos, GUI.Style.Red, MathHelper.PiOver2, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -522,13 +594,12 @@ namespace Barotrauma.Items.Components
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, (int)(pos.Y + (meterSprite.size.Y - meterSprite.Origin.Y) * scale) - 3);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
|
||||
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.LightGreen, MathHelper.PiOver2 + (allowedSectorRad.X + allowedSectorRad.Y) / 2.0f, scale);
|
||||
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Orange, optimalSectorRad.X, scale);
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Red, allowedSectorRad.X, scale);
|
||||
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Orange, MathHelper.Pi + optimalSectorRad.Y, scale);
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Red, MathHelper.Pi + allowedSectorRad.Y, scale);
|
||||
float scaleMultiplier = 0.95f;
|
||||
sectorSprite.Draw(spriteBatch, pos, optimalRangeColor, MathHelper.PiOver2 + (allowedSectorRad.X + allowedSectorRad.Y) / 2.0f, scale * scaleMultiplier);
|
||||
sectorSprite.Draw(spriteBatch, pos, offRangeColor, optimalSectorRad.X, scale * scaleMultiplier);
|
||||
sectorSprite.Draw(spriteBatch, pos, warningColor, allowedSectorRad.X, scale * scaleMultiplier);
|
||||
sectorSprite.Draw(spriteBatch, pos, offRangeColor, MathHelper.Pi + optimalSectorRad.Y, scale * scaleMultiplier);
|
||||
sectorSprite.Draw(spriteBatch, pos, warningColor, MathHelper.Pi + allowedSectorRad.Y, scale * scaleMultiplier);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
|
||||
@@ -539,7 +610,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
float normalizedValue = (value - range.X) / (range.Y - range.X);
|
||||
float valueRad = MathHelper.Lerp(sectorRad.X, sectorRad.Y, normalizedValue);
|
||||
meterPointer.Draw(spriteBatch, pos, valueRad, scale);
|
||||
Vector2 offset = new Vector2(0, 40) * scale;
|
||||
meterPointer.Draw(spriteBatch, pos - offset, valueRad, scale);
|
||||
}
|
||||
|
||||
static void UpdateGraph<T>(IList<T> graph, T newValue)
|
||||
@@ -561,8 +633,6 @@ namespace Barotrauma.Items.Components
|
||||
float lineWidth = (float)rect.Width / (float)(graph.Count - 2);
|
||||
float yScale = (float)rect.Height / maxVal;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, Color.White);
|
||||
|
||||
Vector2 prevPoint = new Vector2(rect.Right, rect.Bottom - (graph[1] + (graph[0] - graph[1]) * xOffset) * yScale);
|
||||
|
||||
float currX = rect.Right - ((xOffset - 1.0f) * lineWidth);
|
||||
@@ -619,7 +689,7 @@ namespace Barotrauma.Items.Components
|
||||
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
|
||||
{
|
||||
msg.Write(autoTemp);
|
||||
msg.Write(shutDown);
|
||||
msg.Write(PowerOn);
|
||||
msg.WriteRangedSingle(targetFissionRate, 0.0f, 100.0f, 8);
|
||||
msg.WriteRangedSingle(targetTurbineOutput, 0.0f, 100.0f, 8);
|
||||
|
||||
@@ -635,17 +705,41 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
AutoTemp = msg.ReadBoolean();
|
||||
shutDown = msg.ReadBoolean();
|
||||
PowerOn = msg.ReadBoolean();
|
||||
Temperature = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
targetFissionRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
targetTurbineOutput = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
degreeOfSuccess = msg.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
|
||||
fissionRateScrollBar.BarScroll = targetFissionRate / 100.0f;
|
||||
turbineOutputScrollBar.BarScroll = targetTurbineOutput / 100.0f;
|
||||
onOffSwitch.BarScroll = shutDown ? Math.Max(onOffSwitch.BarScroll, 0.55f) : Math.Min(onOffSwitch.BarScroll, 0.45f);
|
||||
FissionRateScrollBar.BarScroll = targetFissionRate / 100.0f;
|
||||
TurbineOutputScrollBar.BarScroll = targetTurbineOutput / 100.0f;
|
||||
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
private void UpdateUIElementStates()
|
||||
{
|
||||
if (powerLight != null)
|
||||
{
|
||||
powerLight.Selected = _powerOn;
|
||||
}
|
||||
if (AutoTempSwitch != null)
|
||||
{
|
||||
AutoTempSwitch.Selected = autoTemp;
|
||||
AutoTempSwitch.Enabled = _powerOn;
|
||||
}
|
||||
if (autoTempLight != null)
|
||||
{
|
||||
autoTempLight.Selected = autoTemp && _powerOn;
|
||||
}
|
||||
if (FissionRateScrollBar != null)
|
||||
{
|
||||
FissionRateScrollBar.Enabled = _powerOn && !autoTemp;
|
||||
}
|
||||
if (TurbineOutputScrollBar != null)
|
||||
{
|
||||
TurbineOutputScrollBar.Enabled = _powerOn && !autoTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,30 +6,32 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Sonar : Powered, IServerSerializable, IClientSerializable
|
||||
{
|
||||
public enum BlipType
|
||||
{
|
||||
Default,
|
||||
Disruption
|
||||
}
|
||||
|
||||
private bool dynamicDockingIndicator = true;
|
||||
|
||||
private bool unsentChanges;
|
||||
private float networkUpdateTimer;
|
||||
|
||||
public GUITickBox ActiveTickBox
|
||||
{
|
||||
get { return activeTickBox; }
|
||||
}
|
||||
public GUIButton SonarModeSwitch { get; private set; }
|
||||
private GUITickBox activeTickBox, passiveTickBox;
|
||||
private GUITextBlock signalWarningText;
|
||||
|
||||
private GUIScrollBar zoomSlider;
|
||||
|
||||
private GUITickBox directionalTickBox;
|
||||
private GUIScrollBar directionalSlider;
|
||||
private GUIButton directionalModeSwitch;
|
||||
private Vector2? pingDragDirection = null;
|
||||
|
||||
private GUILayoutGroup activeControlsContainer;
|
||||
private GUIFrame controlContainer;
|
||||
|
||||
private GUICustomComponent sonarView;
|
||||
@@ -54,21 +56,32 @@ namespace Barotrauma.Items.Components
|
||||
private Vector2 center;
|
||||
private float displayScale;
|
||||
|
||||
private const float DisruptionUpdateInterval = 0.2f;
|
||||
private float disruptionUpdateTimer;
|
||||
|
||||
private float zoomSqrt;
|
||||
|
||||
private float showDirectionalIndicatorTimer;
|
||||
|
||||
|
||||
//Vector2 = vector from the ping source to the position of the disruption
|
||||
//float = strength of the disruption, between 0-1
|
||||
List<Pair<Vector2, float>> disruptedDirections = new List<Pair<Vector2, float>>();
|
||||
|
||||
private static readonly Color[] blipColorGradient =
|
||||
|
||||
private readonly Color positiveColor = Color.Green;
|
||||
private readonly Color warningColor = Color.Orange;
|
||||
private readonly Color negativeColor = Color.Red;
|
||||
private readonly Color markerColor = Color.Red;
|
||||
|
||||
private static readonly Dictionary<BlipType, Color[]> blipColorGradient = new Dictionary<BlipType, Color[]>()
|
||||
{
|
||||
Color.TransparentBlack,
|
||||
new Color(0, 50, 160),
|
||||
new Color(0, 133, 166),
|
||||
new Color(2, 159, 30),
|
||||
new Color(255, 255, 255)
|
||||
{
|
||||
BlipType.Default,
|
||||
new Color[] { Color.TransparentBlack, new Color(0, 50, 160), new Color(0, 133, 166), new Color(2, 159, 30), new Color(255, 255, 255) }
|
||||
},
|
||||
{
|
||||
BlipType.Disruption,
|
||||
new Color[] { Color.TransparentBlack, new Color(254, 68, 19), new Color(255, 220, 62), new Color(255, 255, 255) }
|
||||
}
|
||||
};
|
||||
|
||||
private float prevDockingDist;
|
||||
@@ -79,102 +92,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(Enum.GetValues(typeof(BlipType)).Cast<BlipType>().All(t => blipColorGradient.ContainsKey(t)));
|
||||
sonarBlips = new List<SonarBlip>();
|
||||
|
||||
sonarView = new GUICustomComponent(new RectTransform(Point.Zero, GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawSonar(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), GuiFrame.RectTransform, Anchor.TopLeft)
|
||||
{ MinSize = new Point(150, 0) }, "SonarFrame");
|
||||
|
||||
controlContainer.RectTransform.SetAsFirstChild();
|
||||
|
||||
var paddedControlContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), controlContainer.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.03f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
passiveTickBox = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.2f), paddedControlContainer.RectTransform), TextManager.Get("SonarPassive"), style: "GUIRadioButton")
|
||||
{
|
||||
ToolTip = TextManager.Get("SonarTipPassive"),
|
||||
Selected = true
|
||||
};
|
||||
|
||||
activeTickBox = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.2f), paddedControlContainer.RectTransform), TextManager.Get("SonarActive"), style: "GUIRadioButton")
|
||||
{
|
||||
ToolTip = TextManager.Get("SonarTipActive"),
|
||||
OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
CurrentMode = box.Selected ? Mode.Active : Mode.Passive;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var zoomContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedControlContainer.RectTransform), isHorizontal: true);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.35f, 1.0f), zoomContainer.RectTransform), TextManager.Get("SonarZoom"), font: GUI.SmallFont)
|
||||
{
|
||||
Padding = Vector4.Zero
|
||||
};
|
||||
zoomSlider = new GUIScrollBar(new RectTransform(new Vector2(0.65f, 1.0f), zoomContainer.RectTransform), barSize: 0.1f, isHorizontal: true)
|
||||
{
|
||||
OnMoved = (scrollbar, scroll) =>
|
||||
{
|
||||
zoom = MathHelper.Lerp(MinZoom, MaxZoom, scroll);
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var activeControls = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.6f), paddedControlContainer.RectTransform) { RelativeOffset = new Vector2(0.1f, 0.0f) }, "InnerFrame");
|
||||
activeControlsContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), activeControls.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.03f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
directionalTickBox = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.3f), activeControlsContainer.RectTransform), TextManager.Get("SonarDirectionalPing"))
|
||||
{
|
||||
OnSelected = (tickBox) =>
|
||||
{
|
||||
useDirectionalPing = tickBox.Selected;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
directionalSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.3f), activeControlsContainer.RectTransform), barSize: 0.1f, isHorizontal: true)
|
||||
{
|
||||
OnMoved = (scrollbar, scroll) =>
|
||||
{
|
||||
showDirectionalIndicatorTimer = 1.0f;
|
||||
float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, scroll);
|
||||
SetPingDirection(new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle)));
|
||||
return true;
|
||||
},
|
||||
Range = new Vector2(0,MathHelper.TwoPi)
|
||||
};
|
||||
|
||||
signalWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedControlContainer.RectTransform), "", Color.Orange, textAlignment: Alignment.Center);
|
||||
|
||||
GUIRadioButtonGroup sonarMode = new GUIRadioButtonGroup();
|
||||
sonarMode.AddRadioButton((int)Mode.Active, activeTickBox);
|
||||
sonarMode.AddRadioButton((int)Mode.Passive, passiveTickBox);
|
||||
sonarMode.Selected = (int)Mode.Passive;
|
||||
|
||||
GuiFrame.CanBeFocused = false;
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
@@ -212,20 +131,125 @@ namespace Barotrauma.Items.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetUILayout();
|
||||
|
||||
GameMain.Instance.OnResolutionChanged += SetUILayout;
|
||||
GameMain.Config.OnHUDScaleChanged += SetUILayout;
|
||||
CreateGUI();
|
||||
GameMain.Instance.OnResolutionChanged += ResetLayout;
|
||||
// TODO: do we need to react on this?
|
||||
GameMain.Config.OnHUDScaleChanged += ResetLayout;
|
||||
}
|
||||
|
||||
private void SetUILayout()
|
||||
private void ResetLayout()
|
||||
{
|
||||
int viewSize = (int)Math.Min(GuiFrame.Rect.Width - 150, GuiFrame.Rect.Height * 0.9f);
|
||||
sonarView.RectTransform.NonScaledSize = new Point(viewSize);
|
||||
controlContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
GuiFrame.RectTransform.Children.ForEachMod(c => c.Parent = null);
|
||||
CreateGUI();
|
||||
}
|
||||
|
||||
private void CreateGUI()
|
||||
{
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(controlContainerRelativeWidth, 0.32f), GuiFrame.RectTransform, Anchor.TopRight)
|
||||
{
|
||||
RelativeOffset = new Vector2(controlContainerRelativeOffset, 0)
|
||||
}, "ItemUI");
|
||||
|
||||
var paddedControlContainer = new GUIFrame(new RectTransform(controlContainer.Rect.Size - GUIStyle.ItemFrameMargin, controlContainer.RectTransform, Anchor.Center)
|
||||
{
|
||||
AbsoluteOffset = GUIStyle.ItemFrameOffset
|
||||
}, style: null);
|
||||
var sonarModeArea = new GUIFrame(new RectTransform(new Vector2(1, 0.5f), paddedControlContainer.RectTransform, Anchor.TopCenter), style: null);
|
||||
SonarModeSwitch = new GUIButton(new RectTransform(new Vector2(0.2f, 1), sonarModeArea.RectTransform), string.Empty, style: "SwitchVertical")
|
||||
{
|
||||
Selected = false,
|
||||
Enabled = true,
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
button.Selected = !button.Selected;
|
||||
CurrentMode = button.Selected ? Mode.Active : Mode.Passive;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var sonarModeRightSide = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.8f), sonarModeArea.RectTransform, Anchor.CenterLeft)
|
||||
{
|
||||
RelativeOffset = new Vector2(SonarModeSwitch.RectTransform.RelativeSize.X, 0)
|
||||
}, style: null);
|
||||
passiveTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), sonarModeRightSide.RectTransform, Anchor.TopLeft),
|
||||
TextManager.Get("SonarPassive"), font: GUI.SubHeadingFont, style: "IndicatorLightRedSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("SonarTipPassive"),
|
||||
Selected = true,
|
||||
Enabled = false
|
||||
};
|
||||
activeTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), sonarModeRightSide.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("SonarActive"), font: GUI.SubHeadingFont, style: "IndicatorLightRedSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("SonarTipActive"),
|
||||
Selected = false,
|
||||
Enabled = false
|
||||
};
|
||||
passiveTickBox.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
activeTickBox.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
|
||||
var zoomContainer = new GUIFrame(new RectTransform(new Vector2(1, 0.2f), paddedControlContainer.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0, sonarModeArea.RectTransform.RelativeSize.Y + 0.025f)
|
||||
}, style: null);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 0.6f), zoomContainer.RectTransform, Anchor.CenterLeft),
|
||||
TextManager.Get("SonarZoom"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterRight);
|
||||
zoomSlider = new GUIScrollBar(new RectTransform(new Vector2(0.6f, 0.8f), zoomContainer.RectTransform, Anchor.CenterLeft)
|
||||
{
|
||||
RelativeOffset = new Vector2(0.35f, 0)
|
||||
}, barSize: 0.15f, isHorizontal: true, style: "DeviceSlider")
|
||||
{
|
||||
OnMoved = (scrollbar, scroll) =>
|
||||
{
|
||||
zoom = MathHelper.Lerp(MinZoom, MaxZoom, scroll);
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var directionalModeFrame = new GUIFrame(new RectTransform(new Vector2(1, 0.2f), paddedControlContainer.RectTransform, Anchor.BottomCenter), style: null);
|
||||
new GUIFrame(new RectTransform(new Vector2(0.9f, 0.01f), directionalModeFrame.RectTransform, Anchor.TopCenter, Pivot.BottomCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(0, -0.15f)
|
||||
}, style: "HorizontalLine");
|
||||
directionalModeSwitch = new GUIButton(new RectTransform(new Vector2(0.3f, 0.8f), directionalModeFrame.RectTransform, Anchor.CenterLeft), string.Empty, style: "SwitchHorizontal")
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
useDirectionalPing = !useDirectionalPing;
|
||||
button.Selected = useDirectionalPing;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var directionalModeSwitchText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1), directionalModeFrame.RectTransform, Anchor.CenterRight),
|
||||
TextManager.Get("SonarDirectionalPing"), GUI.Style.TextColor, GUI.SubHeadingFont, Alignment.CenterLeft);
|
||||
|
||||
signalWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedControlContainer.RectTransform), "", warningColor, textAlignment: Alignment.Center);
|
||||
|
||||
GuiFrame.CanBeFocused = false;
|
||||
|
||||
sonarView = new GUICustomComponent(new RectTransform(SonarAreaSize, GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawSonar(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
sonarView.RectTransform.SetAsFirstChild();
|
||||
}
|
||||
|
||||
public static readonly float controlContainerRelativeWidth = 0.35f;
|
||||
public static readonly float controlContainerRelativeOffset = 0.1f;
|
||||
public static Vector2 SonarAreaSize => Vector2.One - new Vector2(controlContainerRelativeWidth + controlContainerRelativeOffset);
|
||||
|
||||
private void SetPingDirection(Vector2 direction)
|
||||
{
|
||||
pingDirection = direction;
|
||||
@@ -278,15 +302,7 @@ namespace Barotrauma.Items.Components
|
||||
sonarBlips[i].FadeTimer -= deltaTime * MathHelper.Lerp(0.5f, 2.0f, distort);
|
||||
sonarBlips[i].Position += sonarBlips[i].Velocity * deltaTime;
|
||||
|
||||
if (sonarBlips[i].FadeTimer <= 0.0f) sonarBlips.RemoveAt(i);
|
||||
}
|
||||
|
||||
foreach (GUIComponent component in activeControlsContainer.Parent.GetAllChildren())
|
||||
{
|
||||
if (component is GUITextBlock textBlock)
|
||||
{
|
||||
textBlock.TextColor = currentMode == Mode.Active ? textBlock.Style.textColor : textBlock.Style.textColor * 0.5f;
|
||||
}
|
||||
if (sonarBlips[i].FadeTimer <= 0.0f) { sonarBlips.RemoveAt(i); }
|
||||
}
|
||||
|
||||
//sonar view can only get focus when the cursor is inside the circle
|
||||
@@ -415,44 +431,46 @@ namespace Barotrauma.Items.Components
|
||||
null;
|
||||
}
|
||||
|
||||
if (useDirectionalPing && PlayerInput.PrimaryMouseButtonHeld())
|
||||
if (useDirectionalPing)
|
||||
{
|
||||
if ((MouseInDirectionalPingRing(sonarView.Rect, false) && PlayerInput.PrimaryMouseButtonDown()) || pingDragDirection != null)
|
||||
Vector2 newDragDir = Vector2.Normalize(PlayerInput.MousePosition - sonarView.Rect.Center.ToVector2());
|
||||
if (MouseInDirectionalPingRing(sonarView.Rect, true) && PlayerInput.PrimaryMouseButtonDown())
|
||||
{
|
||||
Vector2 newDragDir = Vector2.Normalize(PlayerInput.MousePosition - sonarView.Rect.Center.ToVector2());
|
||||
if (pingDragDirection == null && !MouseInDirectionalPingRing(sonarView.Rect, true))
|
||||
{
|
||||
directionalSlider.BarScrollValue = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(newDragDir));
|
||||
directionalSlider.OnMoved(directionalSlider, directionalSlider.BarScroll);
|
||||
}
|
||||
else if (pingDragDirection != null)
|
||||
{
|
||||
float newAngle = MathUtils.VectorToAngle(newDragDir);
|
||||
float oldAngle = MathUtils.VectorToAngle(pingDragDirection.Value);
|
||||
float pingAngle = MathUtils.VectorToAngle(pingDirection);
|
||||
pingAngle = MathUtils.WrapAngleTwoPi(pingAngle + MathUtils.GetShortestAngle(oldAngle, newAngle));
|
||||
directionalSlider.BarScrollValue = pingAngle;
|
||||
directionalSlider.OnMoved(directionalSlider, directionalSlider.BarScroll);
|
||||
}
|
||||
|
||||
pingDragDirection = newDragDir;
|
||||
}
|
||||
|
||||
if (pingDragDirection != null && PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
float newAngle = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(newDragDir));
|
||||
SetPingDirection(new Vector2((float)Math.Cos(newAngle), (float)Math.Sin(newAngle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
pingDragDirection = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pingDragDirection = null;
|
||||
}
|
||||
|
||||
disruptionUpdateTimer -= deltaTime;
|
||||
|
||||
for (var pingIndex = 0; pingIndex < activePingsCount; ++pingIndex)
|
||||
{
|
||||
var activePing = activePings[pingIndex];
|
||||
float pingRadius = DisplayRadius * activePing.State / zoom;
|
||||
UpdateDisruptions(transducerCenter, pingRadius / displayScale, activePing.PrevPingRadius / displayScale);
|
||||
if (disruptionUpdateTimer <= 0.0f) { UpdateDisruptions(transducerCenter, pingRadius / displayScale); }
|
||||
Ping(transducerCenter, transducerCenter,
|
||||
pingRadius, activePing.PrevPingRadius, displayScale, range / zoom, passive: false, pingStrength: 2.0f);
|
||||
activePing.PrevPingRadius = pingRadius;
|
||||
|
||||
}
|
||||
|
||||
if (disruptionUpdateTimer <= 0.0f)
|
||||
{
|
||||
disruptionUpdateTimer = DisruptionUpdateInterval;
|
||||
}
|
||||
|
||||
if (currentMode == Mode.Active && currentPingIndex != -1)
|
||||
{
|
||||
return;
|
||||
@@ -464,7 +482,7 @@ namespace Barotrauma.Items.Components
|
||||
disruptedDirections.Clear();
|
||||
foreach (AITarget t in AITarget.List)
|
||||
{
|
||||
if (t.SoundRange <= 0.0f || !t.Enabled) { continue; }
|
||||
if (t.SoundRange <= 0.0f || !t.Enabled || float.IsNaN(t.SoundRange) || float.IsInfinity(t.SoundRange)) { continue; }
|
||||
|
||||
float distSqr = Vector2.DistanceSquared(t.WorldPosition, transducerCenter);
|
||||
if (distSqr > t.SoundRange * t.SoundRange * 2) { continue; }
|
||||
@@ -610,7 +628,7 @@ namespace Barotrauma.Items.Components
|
||||
if (signalStrength <= 0.5f)
|
||||
{
|
||||
signalWarningText.Text = TextManager.Get(signalStrength <= 0.0f ? "SonarNoSignal" : "SonarSignalWeak");
|
||||
signalWarningText.Color = signalStrength <= 0.0f ? Color.Red : Color.Orange;
|
||||
signalWarningText.Color = signalStrength <= 0.0f ? negativeColor : warningColor;
|
||||
signalWarningText.Visible = true;
|
||||
}
|
||||
else
|
||||
@@ -796,7 +814,7 @@ namespace Barotrauma.Items.Components
|
||||
size.Y = 0.0f;
|
||||
}
|
||||
GUI.DrawLine(spriteBatch, center + offset - size - Vector2.Normalize(size) * zoom, center + offset + size + Vector2.Normalize(size) * zoom, Color.Black * signalStrength * 0.5f, width: (int)(zoom * 5.0f));
|
||||
GUI.DrawLine(spriteBatch, center + offset - size, center + offset + size, Color.LightGreen * signalStrength, width: (int)(zoom * 2.5f));
|
||||
GUI.DrawLine(spriteBatch, center + offset - size, center + offset + size, positiveColor * signalStrength, width: (int)(zoom * 2.5f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,7 +863,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Vector2 midNormal = new Vector2(-normalizedDockingDir.Y, normalizedDockingDir.X);
|
||||
|
||||
DrawLine(spriteBatch, targetPortPos, targetPortPos + normalizedDockingDir * midLength, readyToDock ? Color.LightGreen : staticLineColor, width: 2);
|
||||
DrawLine(spriteBatch, targetPortPos, targetPortPos + normalizedDockingDir * midLength, readyToDock ? positiveColor : staticLineColor, width: 2);
|
||||
DrawLine(spriteBatch, targetPortPos,
|
||||
targetPortPos + MathUtils.RotatePoint(normalizedDockingDir, sector) * sectorLength, staticLineColor, width: 2);
|
||||
DrawLine(spriteBatch, targetPortPos,
|
||||
@@ -859,7 +877,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (readyToDock)
|
||||
{
|
||||
Color indicatorColor = Color.LightGreen * 0.8f;
|
||||
Color indicatorColor = positiveColor * 0.8f;
|
||||
|
||||
float indicatorSize = (float)Math.Sin((float)Timing.TotalTime * 5.0f) * DisplayRadius * 0.75f;
|
||||
Vector2 midPoint = (sourcePortPos + targetPortPos) / 2.0f;
|
||||
@@ -882,7 +900,8 @@ namespace Barotrauma.Items.Components
|
||||
Vector2.Dot(normalizedDockingDir, MathUtils.RotatePoint(normalizedDockingDir, indicatorSector)) <
|
||||
Vector2.Dot(normalizedDockingDir, Vector2.Normalize(dockingDir));
|
||||
|
||||
Color indicatorColor = withinSector ? Color.LightGreen * 0.8f : Color.Red * 0.8f;
|
||||
Color indicatorColor = withinSector ? positiveColor : negativeColor;
|
||||
indicatorColor *= 0.8f;
|
||||
|
||||
DrawLine(spriteBatch, targetPortPos,
|
||||
targetPortPos + MathUtils.RotatePoint(normalizedDockingDir,indicatorSector) * indicatorSectorLength, indicatorColor, width: 3);
|
||||
@@ -892,7 +911,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
}
|
||||
|
||||
private void UpdateDisruptions(Vector2 pingSource, float worldPingRadius, float worldPrevPingRadius)
|
||||
private void UpdateDisruptions(Vector2 pingSource, float worldPingRadius)
|
||||
{
|
||||
float worldPingRadiusSqr = worldPingRadius * worldPingRadius;
|
||||
|
||||
@@ -912,10 +931,8 @@ namespace Barotrauma.Items.Components
|
||||
float disruptionDist = Vector2.Distance(pingSource, disruptionPos);
|
||||
disruptedDirections.Add(new Pair<Vector2, float>((disruptionPos - pingSource) / disruptionDist, disruptionStrength));
|
||||
|
||||
if (disruptionDist > worldPrevPingRadius && disruptionDist <= worldPingRadius)
|
||||
{
|
||||
CreateBlipsForDisruption(disruptionPos, disruptionStrength);
|
||||
}
|
||||
CreateBlipsForDisruption(disruptionPos, disruptionStrength);
|
||||
|
||||
}
|
||||
foreach (AITarget aiTarget in AITarget.List)
|
||||
{
|
||||
@@ -926,18 +943,23 @@ namespace Barotrauma.Items.Components
|
||||
float disruptionDist = (float)Math.Sqrt(distSqr);
|
||||
disruptedDirections.Add(new Pair<Vector2, float>((aiTarget.WorldPosition - pingSource) / disruptionDist, aiTarget.SonarDisruption));
|
||||
|
||||
if (disruptionDist > worldPrevPingRadius && disruptionDist <= worldPingRadius)
|
||||
{
|
||||
CreateBlipsForDisruption(aiTarget.WorldPosition, aiTarget.SonarDisruption);
|
||||
}
|
||||
CreateBlipsForDisruption(aiTarget.WorldPosition, aiTarget.SonarDisruption);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateBlipsForDisruption(Vector2 disruptionPos, float disruptionStrength)
|
||||
{
|
||||
for (int i = 0; i < disruptionStrength * Level.GridCellSize * 0.02f; i++)
|
||||
disruptionStrength = Math.Min(disruptionStrength, 10.0f);
|
||||
Vector2 dir = disruptionPos - pingSource;
|
||||
for (int i = 0; i < disruptionStrength * 10.0f; i++)
|
||||
{
|
||||
var blip = new SonarBlip(disruptionPos + Rand.Vector(Rand.Range(0.0f, Level.GridCellSize * 4 * disruptionStrength)), MathHelper.Lerp(1.0f, 1.5f, disruptionStrength), Rand.Range(1.0f, 2.0f + disruptionStrength));
|
||||
Vector2 pos = disruptionPos + Rand.Vector(Rand.Range(0.0f, Level.GridCellSize * 4 * disruptionStrength));
|
||||
if (Vector2.Dot(pos - pingSource, -dir) > 1.0f - disruptionStrength) { continue; }
|
||||
var blip = new SonarBlip(
|
||||
pos,
|
||||
MathHelper.Lerp(0.1f, 1.5f, Math.Min(disruptionStrength, 1.0f)),
|
||||
Rand.Range(0.2f, 1.0f + disruptionStrength),
|
||||
BlipType.Disruption);
|
||||
sonarBlips.Add(blip);
|
||||
}
|
||||
}
|
||||
@@ -1143,6 +1165,8 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 lineDir = (point2 - point1) / length;
|
||||
for (float x = 0; x < length; x += lineStep * Rand.Range(0.8f, 1.2f))
|
||||
{
|
||||
if (Rand.Int(sonarBlips.Count) > 500) { continue; }
|
||||
|
||||
Vector2 point = point1 + lineDir * x;
|
||||
|
||||
//ignore if outside the display
|
||||
@@ -1253,7 +1277,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 dir = pos / (float)Math.Sqrt(posDistSqr);
|
||||
Vector2 normal = new Vector2(dir.Y, -dir.X);
|
||||
float scale = (strength + 3.0f) * blip.Scale * zoomSqrt;
|
||||
Color color = ToolBox.GradientLerp(strength, blipColorGradient);
|
||||
Color color = ToolBox.GradientLerp(strength, blipColorGradient[blip.BlipType]);
|
||||
|
||||
sonarBlip.Draw(spriteBatch, center + pos, color, sonarBlip.Origin, blip.Rotation ?? MathUtils.VectorToAngle(pos),
|
||||
blip.Size * scale * 0.04f, SpriteEffects.None, 0);
|
||||
@@ -1304,7 +1328,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (string.IsNullOrEmpty(iconIdentifier) || !targetIcons.ContainsKey(iconIdentifier))
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X - 3, (int)markerPos.Y - 3, 6, 6), Color.Red, thickness: 2);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X - 3, (int)markerPos.Y - 3, 6, 6), markerColor, thickness: 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1355,7 +1379,8 @@ namespace Barotrauma.Items.Components
|
||||
msg.Write(useDirectionalPing);
|
||||
if (useDirectionalPing)
|
||||
{
|
||||
msg.WriteRangedSingle(directionalSlider.BarScroll, 0.0f, 1.0f, 8);
|
||||
float pingAngle = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(pingDirection));
|
||||
msg.WriteRangedSingle(MathUtils.InverseLerp(0.0f, MathHelper.TwoPi, pingAngle), 0.0f, 1.0f, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1380,7 +1405,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (correctionTimer > 0.0f)
|
||||
{
|
||||
int msgLength = (int)(msg.BitPosition - msgStartPos);
|
||||
int msgLength = msg.BitPosition - msgStartPos;
|
||||
msg.BitPosition = msgStartPos;
|
||||
StartDelayedCorrection(type, msg.ExtractBits(msgLength), sendingTime);
|
||||
return;
|
||||
@@ -1389,22 +1414,25 @@ namespace Barotrauma.Items.Components
|
||||
CurrentMode = isActive ? Mode.Active : Mode.Passive;
|
||||
if (isActive)
|
||||
{
|
||||
activeTickBox.Selected = true;
|
||||
zoomSlider.BarScroll = zoomT;
|
||||
zoom = MathHelper.Lerp(MinZoom, MaxZoom, zoomT);
|
||||
if (directionalPing)
|
||||
{
|
||||
directionalSlider.BarScroll = directionT;
|
||||
float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, directionalSlider.BarScroll);
|
||||
float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, directionT);
|
||||
pingDirection = new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle));
|
||||
}
|
||||
useDirectionalPing = directionalTickBox.Selected = directionalPing;
|
||||
}
|
||||
else
|
||||
{
|
||||
passiveTickBox.Selected = true;
|
||||
useDirectionalPing = directionalModeSwitch.Selected = directionalPing;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGUIElements()
|
||||
{
|
||||
bool isActive = CurrentMode == Mode.Active;
|
||||
SonarModeSwitch.Selected = isActive;
|
||||
passiveTickBox.Selected = !isActive;
|
||||
activeTickBox.Selected = isActive;
|
||||
directionalModeSwitch.Selected = useDirectionalPing;
|
||||
}
|
||||
}
|
||||
|
||||
class SonarBlip
|
||||
@@ -1415,13 +1443,15 @@ namespace Barotrauma.Items.Components
|
||||
public Vector2 Velocity;
|
||||
public float? Rotation;
|
||||
public Vector2 Size;
|
||||
public Sonar.BlipType BlipType;
|
||||
|
||||
public SonarBlip(Vector2 pos, float fadeTimer, float scale)
|
||||
public SonarBlip(Vector2 pos, float fadeTimer, float scale, Sonar.BlipType blipType = Sonar.BlipType.Default)
|
||||
{
|
||||
Position = pos;
|
||||
FadeTimer = Math.Max(fadeTimer, 0.0f);
|
||||
Scale = scale;
|
||||
Size = new Vector2(0.5f, 1.0f);
|
||||
BlipType = blipType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,14 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Steering : Powered, IServerSerializable, IClientSerializable
|
||||
{
|
||||
enum Mode
|
||||
{
|
||||
AutoPilot,
|
||||
Manual
|
||||
};
|
||||
private GUITickBox autopilotTickBox, manualTickBox;
|
||||
private GUIButton steeringModeSwitch;
|
||||
private GUITickBox autopilotIndicator, manualPilotIndicator;
|
||||
|
||||
enum Destination
|
||||
{
|
||||
@@ -34,8 +31,6 @@ namespace Barotrauma.Items.Components
|
||||
private GUIButton dockingButton;
|
||||
private string dockText, undockText;
|
||||
|
||||
private GUIFrame autoPilotControlsDisabler;
|
||||
|
||||
private GUIComponent steerArea;
|
||||
|
||||
private GUITextBlock pressureWarningText;
|
||||
@@ -92,67 +87,84 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), GuiFrame.RectTransform, Anchor.CenterLeft)
|
||||
{ MinSize = new Point(150, 0) }, "SonarFrame");
|
||||
var paddedControlContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), controlContainer.RectTransform, Anchor.Center))
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
RelativeSpacing = 0.03f,
|
||||
Stretch = true
|
||||
};
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "steeringindicator":
|
||||
steeringIndicator = new Sprite(subElement);
|
||||
break;
|
||||
case "maintainposindicator":
|
||||
maintainPosIndicator = new Sprite(subElement);
|
||||
break;
|
||||
case "maintainposoriginindicator":
|
||||
maintainPosOriginIndicator = new Sprite(subElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
CreateGUI();
|
||||
GameMain.Instance.OnResolutionChanged += ResetGUI;
|
||||
// TODO: do we need to react on this?
|
||||
GameMain.Config.OnHUDScaleChanged += ResetGUI;
|
||||
}
|
||||
|
||||
statusContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0) }, "SonarFrame");
|
||||
var paddedStatusContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), statusContainer.RectTransform, Anchor.Center))
|
||||
private void CreateGUI()
|
||||
{
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.36f), GuiFrame.RectTransform, Anchor.CenterRight)
|
||||
{
|
||||
RelativeSpacing = 0.03f,
|
||||
Stretch = true
|
||||
};
|
||||
RelativeOffset = new Vector2(Sonar.controlContainerRelativeOffset / 2, 0.01f) // Based on the relative size differende of the steering and the status windows
|
||||
}, "ItemUI");
|
||||
var paddedControlContainer = new GUIFrame(new RectTransform(controlContainer.Rect.Size - GUIStyle.ItemFrameMargin, controlContainer.RectTransform, Anchor.Center)
|
||||
{
|
||||
AbsoluteOffset = GUIStyle.ItemFrameOffset
|
||||
}, style: null);
|
||||
|
||||
manualTickBox = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.3f), paddedControlContainer.RectTransform),
|
||||
TextManager.Get("SteeringManual"), style: "GUIRadioButton")
|
||||
var steeringModeArea = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), paddedControlContainer.RectTransform, Anchor.TopLeft), style: null);
|
||||
steeringModeSwitch = new GUIButton(new RectTransform(new Vector2(0.2f, 1), steeringModeArea.RectTransform), string.Empty, style: "SwitchVertical")
|
||||
{
|
||||
Selected = false,
|
||||
Enabled = true,
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
button.Selected = !button.Selected;
|
||||
AutoPilot = button.Selected;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
user = Character.Controlled;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var steeringModeRightSide = new GUIFrame(new RectTransform(new Vector2(1.0f - steeringModeSwitch.RectTransform.RelativeSize.X, 0.8f), steeringModeArea.RectTransform, Anchor.CenterLeft)
|
||||
{
|
||||
RelativeOffset = new Vector2(steeringModeSwitch.RectTransform.RelativeSize.X, 0)
|
||||
}, style: null);
|
||||
manualPilotIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), steeringModeRightSide.RectTransform, Anchor.TopLeft),
|
||||
TextManager.Get("SteeringManual"), font: GUI.SubHeadingFont, style: "IndicatorLightRedSmall")
|
||||
{
|
||||
Selected = true,
|
||||
OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
AutoPilot = !box.Selected;
|
||||
unsentChanges = true;
|
||||
user = Character.Controlled;
|
||||
|
||||
return true;
|
||||
}
|
||||
Enabled = false
|
||||
};
|
||||
autopilotTickBox = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.3f), paddedControlContainer.RectTransform),
|
||||
TextManager.Get("SteeringAutoPilot"), style: "GUIRadioButton")
|
||||
autopilotIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), steeringModeRightSide.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("SteeringAutoPilot"), font: GUI.SubHeadingFont, style: "IndicatorLightRedSmall")
|
||||
{
|
||||
OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
AutoPilot = box.Selected;
|
||||
if (AutoPilot && MaintainPos)
|
||||
{
|
||||
posToMaintain = controlledSub != null ?
|
||||
controlledSub.WorldPosition :
|
||||
item.Submarine == null ? item.WorldPosition : item.Submarine.WorldPosition;
|
||||
}
|
||||
unsentChanges = true;
|
||||
user = Character.Controlled;
|
||||
|
||||
return true;
|
||||
}
|
||||
Selected = false,
|
||||
Enabled = false
|
||||
};
|
||||
manualPilotIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
autopilotIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
|
||||
GUITextBlock.AutoScaleAndNormalize(manualPilotIndicator.TextBlock, autopilotIndicator.TextBlock);
|
||||
|
||||
GUIRadioButtonGroup modes = new GUIRadioButtonGroup();
|
||||
modes.AddRadioButton((int)Mode.AutoPilot, autopilotTickBox);
|
||||
modes.AddRadioButton((int)Mode.Manual, manualTickBox);
|
||||
modes.Selected = (int)Mode.Manual;
|
||||
|
||||
var autoPilotControls = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.6f), paddedControlContainer.RectTransform), "InnerFrame");
|
||||
var paddedAutoPilotControls = new GUILayoutGroup(new RectTransform(new Vector2(0.8f), autoPilotControls.RectTransform, Anchor.Center))
|
||||
var autoPilotControls = new GUIFrame(new RectTransform(new Vector2(0.8f, 0.6f), paddedControlContainer.RectTransform, Anchor.BottomRight), "OutlineFrame");
|
||||
var paddedAutoPilotControls = new GUILayoutGroup(new RectTransform(new Vector2(0.9f), autoPilotControls.RectTransform, Anchor.Center))
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.03f
|
||||
RelativeSpacing = 0.03f,
|
||||
ChildAnchor = Anchor.TopCenter
|
||||
};
|
||||
|
||||
maintainPosTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), paddedAutoPilotControls.RectTransform),
|
||||
maintainPosTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.2f), paddedAutoPilotControls.RectTransform),
|
||||
TextManager.Get("SteeringMaintainPos"), font: GUI.SmallFont, style: "GUIRadioButton")
|
||||
{
|
||||
Enabled = false,
|
||||
@@ -188,7 +200,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
levelStartTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), paddedAutoPilotControls.RectTransform),
|
||||
levelStartTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.2f), paddedAutoPilotControls.RectTransform),
|
||||
GameMain.GameSession?.StartLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.StartLocation.Name, 20),
|
||||
font: GUI.SmallFont, style: "GUIRadioButton")
|
||||
{
|
||||
@@ -215,7 +227,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
levelEndTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), paddedAutoPilotControls.RectTransform),
|
||||
levelEndTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.2f), paddedAutoPilotControls.RectTransform),
|
||||
GameMain.GameSession?.EndLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, 20),
|
||||
font: GUI.SmallFont, style: "GUIRadioButton")
|
||||
{
|
||||
@@ -242,53 +254,103 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
|
||||
autoPilotControlsDisabler = new GUIFrame(new RectTransform(Vector2.One, autoPilotControls.RectTransform), "InnerFrame");
|
||||
GUITextBlock.AutoScaleAndNormalize(maintainPosTickBox.TextBlock, levelStartTickBox.TextBlock, levelEndTickBox.TextBlock);
|
||||
maintainPosTickBox.RectTransform.IsFixedSize = levelStartTickBox.RectTransform.IsFixedSize = levelEndTickBox.RectTransform.IsFixedSize = false;
|
||||
maintainPosTickBox.RectTransform.MaxSize = levelStartTickBox.RectTransform.MaxSize = levelEndTickBox.RectTransform.MaxSize =
|
||||
new Point(int.MaxValue, paddedAutoPilotControls.Rect.Height / 3);
|
||||
maintainPosTickBox.RectTransform.MinSize = levelStartTickBox.RectTransform.MinSize = levelEndTickBox.RectTransform.MinSize =
|
||||
Point.Zero;
|
||||
|
||||
GUIRadioButtonGroup destinations = new GUIRadioButtonGroup();
|
||||
destinations.AddRadioButton((int)Destination.MaintainPos, maintainPosTickBox);
|
||||
destinations.AddRadioButton((int)Destination.LevelStart, levelStartTickBox);
|
||||
destinations.AddRadioButton((int)Destination.LevelEnd, levelEndTickBox);
|
||||
destinations.Selected = (int)(maintainPos ? Destination.MaintainPos :
|
||||
levelStartSelected ? Destination.LevelStart : Destination.LevelEnd);
|
||||
|
||||
string steeringVelX = TextManager.Get("SteeringVelocityX");
|
||||
string steeringVelY = TextManager.Get("SteeringVelocityY");
|
||||
string steeringDepth = TextManager.Get("SteeringDepth");
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), paddedStatusContainer.RectTransform), "")
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
Vector2 vel = controlledSub == null ? Vector2.Zero : controlledSub.Velocity;
|
||||
var realWorldVel = ConvertUnits.ToDisplayUnits(vel.Y * Physics.DisplayToRealWorldRatio) * 3.6f;
|
||||
return steeringVelY.Replace("[kph]", ((int)-realWorldVel).ToString());
|
||||
}
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), paddedStatusContainer.RectTransform), "")
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
Vector2 vel = controlledSub == null ? Vector2.Zero : controlledSub.Velocity;
|
||||
var realWorldVel = ConvertUnits.ToDisplayUnits(vel.X * Physics.DisplayToRealWorldRatio) * 3.6f;
|
||||
return steeringVelX.Replace("[kph]", ((int)realWorldVel).ToString());
|
||||
}
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), paddedStatusContainer.RectTransform), "")
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
Vector2 pos = controlledSub == null ? Vector2.Zero : controlledSub.Position;
|
||||
float realWorldDepth = Level.Loaded == null ? 0.0f : Math.Abs(pos.Y - Level.Loaded.Size.Y) * Physics.DisplayToRealWorldRatio;
|
||||
return steeringDepth.Replace("[m]", ((int)realWorldDepth).ToString());
|
||||
}
|
||||
};
|
||||
destinations.Selected = (int)(maintainPos ? Destination.MaintainPos :
|
||||
levelStartSelected ? Destination.LevelStart : Destination.LevelEnd);
|
||||
|
||||
pressureWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), paddedStatusContainer.RectTransform), TextManager.Get("SteeringDepthWarning"), Color.Red)
|
||||
// Status ->
|
||||
statusContainer = new GUIFrame(new RectTransform(new Vector2(0.33f, 0.3f), GuiFrame.RectTransform, Anchor.BottomRight)
|
||||
{
|
||||
RelativeOffset = new Vector2(Sonar.controlContainerRelativeOffset, 0)
|
||||
}, "ItemUI");
|
||||
var paddedStatusContainer = new GUIFrame(new RectTransform(statusContainer.Rect.Size - GUIStyle.ItemFrameMargin, statusContainer.RectTransform, Anchor.Center)
|
||||
{
|
||||
AbsoluteOffset = GUIStyle.ItemFrameOffset
|
||||
}, style: null);
|
||||
|
||||
var elements = GUI.CreateElements(3, new Vector2(1f, 0.323f), paddedStatusContainer.RectTransform, rt => new GUIFrame(rt, style: null), Anchor.TopCenter, relativeSpacing: 0.01f);
|
||||
List<GUIComponent> leftElements = new List<GUIComponent>(), centerElements = new List<GUIComponent>(), rightElements = new List<GUIComponent>();
|
||||
for (int i = 0; i < elements.Count; i++)
|
||||
{
|
||||
var e = elements[i];
|
||||
var group = new GUILayoutGroup(new RectTransform(Vector2.One, e.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
RelativeSpacing = 0.01f,
|
||||
Stretch = true
|
||||
};
|
||||
var left = new GUIFrame(new RectTransform(new Vector2(0.5f, 1), group.RectTransform), style: null);
|
||||
var center = new GUIFrame(new RectTransform(new Vector2(0.175f, 1), group.RectTransform), style: null);
|
||||
var right = new GUIFrame(new RectTransform(new Vector2(0.325f, 0.8f), group.RectTransform), style: null);
|
||||
leftElements.Add(left);
|
||||
centerElements.Add(center);
|
||||
rightElements.Add(right);
|
||||
string leftText = string.Empty, centerText = string.Empty;
|
||||
GUITextBlock.TextGetterHandler rightTextGetter = null;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
leftText = TextManager.Get("DescentVelocity");
|
||||
centerText = $"({TextManager.Get("KilometersPerHour")})";
|
||||
rightTextGetter = () =>
|
||||
{
|
||||
Vector2 vel = controlledSub == null ? Vector2.Zero : controlledSub.Velocity;
|
||||
var realWorldVel = ConvertUnits.ToDisplayUnits(vel.Y * Physics.DisplayToRealWorldRatio) * 3.6f;
|
||||
return ((int)(-realWorldVel)).ToString();
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
leftText = TextManager.Get("Velocity");
|
||||
centerText = $"({TextManager.Get("KilometersPerHour")})";
|
||||
rightTextGetter = () =>
|
||||
{
|
||||
Vector2 vel = controlledSub == null ? Vector2.Zero : controlledSub.Velocity;
|
||||
var realWorldVel = ConvertUnits.ToDisplayUnits(vel.X * Physics.DisplayToRealWorldRatio) * 3.6f;
|
||||
return ((int)realWorldVel).ToString();
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
leftText = TextManager.Get("Depth");
|
||||
centerText = $"({TextManager.Get("Meter")})";
|
||||
rightTextGetter = () =>
|
||||
{
|
||||
Vector2 pos = controlledSub == null ? Vector2.Zero : controlledSub.Position;
|
||||
float realWorldDepth = Level.Loaded == null ? 0.0f : Math.Abs(pos.Y - Level.Loaded.Size.Y) * Physics.DisplayToRealWorldRatio;
|
||||
return ((int)realWorldDepth).ToString();
|
||||
};
|
||||
break;
|
||||
}
|
||||
new GUITextBlock(new RectTransform(Vector2.One, left.RectTransform), leftText, font: GUI.SubHeadingFont, wrap: true, textAlignment: Alignment.CenterRight);
|
||||
new GUITextBlock(new RectTransform(Vector2.One, center.RectTransform), centerText, font: GUI.Font, textAlignment: Alignment.Center) { Padding = Vector4.Zero };
|
||||
var digitalFrame = new GUIFrame(new RectTransform(Vector2.One, right.RectTransform), style: "DigitalFrameDark");
|
||||
new GUITextBlock(new RectTransform(Vector2.One * 0.85f, digitalFrame.RectTransform, Anchor.Center), "12345", GUI.Style.TextColorDark, GUI.DigitalFont, Alignment.CenterRight)
|
||||
{
|
||||
TextGetter = rightTextGetter
|
||||
};
|
||||
}
|
||||
GUITextBlock.AutoScaleAndNormalize(leftElements.SelectMany(e => e.GetAllChildren<GUITextBlock>()));
|
||||
// TODO: center texts are too small on low resolutions
|
||||
GUITextBlock.AutoScaleAndNormalize(centerElements.SelectMany(e => e.GetAllChildren<GUITextBlock>()));
|
||||
GUITextBlock.AutoScaleAndNormalize(rightElements.SelectMany(e => e.GetAllChildren<GUITextBlock>()));
|
||||
|
||||
pressureWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), paddedStatusContainer.RectTransform), TextManager.Get("SteeringDepthWarning"), GUI.Style.Red)
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
|
||||
tipContainer = new GUITextBlock(new RectTransform(new Vector2(0.25f, 0.12f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0), RelativeOffset = new Vector2(0.0f, -0.05f) }, "", wrap: true, style: "GUIToolTip")
|
||||
tipContainer = new GUITextBlock(new RectTransform(new Vector2(0.3f, 0.1f), GuiFrame.RectTransform, Anchor.BottomCenter, Pivot.TopCenter)
|
||||
{
|
||||
RelativeOffset = new Vector2(-0.2f, 0.0f)
|
||||
}, "", font: GUI.Font, wrap: true, style: "GUIToolTip", textAlignment: Alignment.Center)
|
||||
{
|
||||
AutoScale = true
|
||||
};
|
||||
@@ -300,17 +362,17 @@ namespace Barotrauma.Items.Components
|
||||
autoPilotLevelEndTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]",
|
||||
GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.Name);
|
||||
|
||||
steerArea = new GUICustomComponent(new RectTransform(Point.Zero, GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawHUD(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
|
||||
//docking interface ----------------------------------------------------
|
||||
dockingContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0) }, style: null);
|
||||
var paddedDockingContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), dockingContainer.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
float dockingButtonSize = 1.1f;
|
||||
float elementScale = 0.6f;
|
||||
dockingContainer = new GUIFrame(new RectTransform(new Point(160).Multiply(GUI.Scale * dockingButtonSize), GuiFrame.RectTransform, Anchor.BottomRight)
|
||||
{
|
||||
RelativeOffset = new Vector2(Sonar.controlContainerRelativeOffset + 0.05f, -0.05f)
|
||||
}, style: null);
|
||||
|
||||
dockText = TextManager.Get("label.navterminaldock", fallBackTag: "captain.dock");
|
||||
undockText = TextManager.Get("label.navterminalundock", fallBackTag: "captain.undock");
|
||||
dockingButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.5f), paddedDockingContainer.RectTransform, Anchor.Center), dockText, style: "GUIButtonLarge")
|
||||
dockingButton = new GUIButton(new RectTransform(new Vector2(elementScale), dockingContainer.RectTransform, Anchor.Center), dockText, style: "PowerButton")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
@@ -326,65 +388,45 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
};
|
||||
dockingButton.Font = GUI.SmallFont;
|
||||
dockingButton.Font = GUI.SubHeadingFont;
|
||||
|
||||
var leftButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.5f), paddedDockingContainer.RectTransform, Anchor.CenterLeft), "")
|
||||
var style = GUI.Style.GetComponentStyle("DockingButtonUp");
|
||||
Sprite buttonSprite = style.Sprites.FirstOrDefault().Value.FirstOrDefault()?.Sprite;
|
||||
Point buttonSize = buttonSprite != null ? buttonSprite.size.ToPoint() : new Point(149, 52);
|
||||
Point horizontalButtonSize = buttonSize.Multiply(elementScale * GUI.Scale * dockingButtonSize);
|
||||
Point verticalButtonSize = horizontalButtonSize.Flip();
|
||||
var leftButton = new GUIButton(new RectTransform(verticalButtonSize, dockingContainer.RectTransform, Anchor.CenterLeft), "", style: "DockingButtonLeft")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = -Vector2.UnitX
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.7f), leftButton.RectTransform, Anchor.Center), "GUIButtonHorizontalArrow").SpriteEffects = SpriteEffects.FlipHorizontally;
|
||||
var rightButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.5f), paddedDockingContainer.RectTransform, Anchor.CenterRight), "")
|
||||
var rightButton = new GUIButton(new RectTransform(verticalButtonSize, dockingContainer.RectTransform, Anchor.CenterRight), "", style: "DockingButtonRight")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = Vector2.UnitX
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.7f), rightButton.RectTransform, Anchor.Center), "GUIButtonHorizontalArrow");
|
||||
var upButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.2f), paddedDockingContainer.RectTransform, Anchor.TopCenter), "")
|
||||
var upButton = new GUIButton(new RectTransform(horizontalButtonSize, dockingContainer.RectTransform, Anchor.TopCenter), "", style: "DockingButtonUp")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = Vector2.UnitY
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.7f), upButton.RectTransform, Anchor.Center), "GUIButtonVerticalArrow");
|
||||
var downButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.2f), paddedDockingContainer.RectTransform, Anchor.BottomCenter), "")
|
||||
var downButton = new GUIButton(new RectTransform(horizontalButtonSize, dockingContainer.RectTransform, Anchor.BottomCenter), "", style: "DockingButtonDown")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = -Vector2.UnitY
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.7f), downButton.RectTransform, Anchor.Center), "GUIButtonVerticalArrow").SpriteEffects = SpriteEffects.FlipVertically;
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "steeringindicator":
|
||||
steeringIndicator = new Sprite(subElement);
|
||||
break;
|
||||
case "maintainposindicator":
|
||||
maintainPosIndicator = new Sprite(subElement);
|
||||
break;
|
||||
case "maintainposoriginindicator":
|
||||
maintainPosOriginIndicator = new Sprite(subElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetUILayout();
|
||||
|
||||
GameMain.Instance.OnResolutionChanged += SetUILayout;
|
||||
GameMain.Config.OnHUDScaleChanged += SetUILayout;
|
||||
steerArea = new GUICustomComponent(new RectTransform(Sonar.SonarAreaSize, GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawHUD(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
steerArea.RectTransform.SetAsFirstChild();
|
||||
steerRadius = steerArea.Rect.Width / 2;
|
||||
}
|
||||
|
||||
private void SetUILayout()
|
||||
|
||||
private void ResetGUI()
|
||||
{
|
||||
int viewSize = (int)Math.Min(GuiFrame.Rect.Width - 150, GuiFrame.Rect.Height * 0.9f);
|
||||
|
||||
controlContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.99f), (int)(viewSize * 0.05f));
|
||||
statusContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
steerArea.RectTransform.NonScaledSize = new Point(viewSize);
|
||||
dockingContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
|
||||
steerRadius = steerArea.Rect.Width / 2;
|
||||
GuiFrame.RectTransform.Children.ForEachMod(c => c.Parent = null);
|
||||
CreateGUI();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -434,7 +476,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (velRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)steeringInputPos.X - 4, (int)steeringInputPos.Y - 4, 8, 8), Color.Red, thickness: 2);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)steeringInputPos.X - 4, (int)steeringInputPos.Y - 4, 8, 8), GUI.Style.Red, thickness: 2);
|
||||
}
|
||||
}
|
||||
else if (posToMaintain.HasValue && !LevelStartSelected && !LevelEndSelected)
|
||||
@@ -447,7 +489,7 @@ namespace Barotrauma.Items.Components
|
||||
displayPosToMaintain = displayPosToMaintain.ClampLength(velRect.Width / 2);
|
||||
displayPosToMaintain = steerArea.Rect.Center.ToVector2() + displayPosToMaintain;
|
||||
|
||||
Color crosshairColor = Color.Orange * (0.5f + ((float)Math.Sin(Timing.TotalTime * 5.0f) + 1.0f) / 4.0f);
|
||||
Color crosshairColor = GUI.Style.Orange * (0.5f + ((float)Math.Sin(Timing.TotalTime * 5.0f) + 1.0f) / 4.0f);
|
||||
if (maintainPosIndicator != null)
|
||||
{
|
||||
maintainPosIndicator.Draw(spriteBatch, displayPosToMaintain, crosshairColor, scale: 0.5f * sonar.Zoom);
|
||||
@@ -461,11 +503,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (maintainPosOriginIndicator != null)
|
||||
{
|
||||
maintainPosOriginIndicator.Draw(spriteBatch, displaySubPos, Color.Orange, scale: 0.5f * sonar.Zoom);
|
||||
maintainPosOriginIndicator.Draw(spriteBatch, displaySubPos, GUI.Style.Orange, scale: 0.5f * sonar.Zoom);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)displaySubPos.X - 5, (int)displaySubPos.Y - 5, 10, 10), Color.Orange);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)displaySubPos.X - 5, (int)displaySubPos.Y - 5, 10, 10), GUI.Style.Orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -507,11 +549,11 @@ namespace Barotrauma.Items.Components
|
||||
pos.Y = -pos.Y;
|
||||
pos += center;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - 3 / 2, (int)pos.Y - 3, 6, 6), (SteeringPath.CurrentNode == wp) ? Color.LightGreen : Color.Green, false);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - 3 / 2, (int)pos.Y - 3, 6, 6), (SteeringPath.CurrentNode == wp) ? Color.LightGreen : GUI.Style.Green, false);
|
||||
|
||||
if (prevPos != Vector2.Zero)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green);
|
||||
GUI.DrawLine(spriteBatch, pos, prevPos, GUI.Style.Green);
|
||||
}
|
||||
|
||||
prevPos = pos;
|
||||
@@ -529,14 +571,14 @@ namespace Barotrauma.Items.Components
|
||||
GUI.DrawLine(spriteBatch,
|
||||
pos1,
|
||||
pos2,
|
||||
Color.Red * 0.6f, width: 3);
|
||||
GUI.Style.Red * 0.6f, width: 3);
|
||||
|
||||
if (obstacle.Intersection.HasValue)
|
||||
{
|
||||
Vector2 intersectionPos = (obstacle.Intersection.Value - transducerCenter) *displayScale;
|
||||
intersectionPos.Y = -intersectionPos.Y;
|
||||
intersectionPos += center;
|
||||
GUI.DrawRectangle(spriteBatch, intersectionPos - Vector2.One * 2, Vector2.One * 4, Color.Red);
|
||||
GUI.DrawRectangle(spriteBatch, intersectionPos - Vector2.One * 2, Vector2.One * 4, GUI.Style.Red);
|
||||
}
|
||||
|
||||
Vector2 obstacleCenter = (pos1 + pos2) / 2;
|
||||
@@ -545,7 +587,7 @@ namespace Barotrauma.Items.Components
|
||||
GUI.DrawLine(spriteBatch,
|
||||
obstacleCenter,
|
||||
obstacleCenter + new Vector2(obstacle.AvoidStrength.X, -obstacle.AvoidStrength.Y) * 100,
|
||||
Color.Lerp(Color.Green, Color.Orange, obstacle.Dot), width: 2);
|
||||
Color.Lerp(GUI.Style.Green, GUI.Style.Orange, obstacle.Dot), width: 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -580,7 +622,7 @@ namespace Barotrauma.Items.Components
|
||||
dockingButton.Text = dockText;
|
||||
if (dockingButton.FlashTimer <= 0.0f)
|
||||
{
|
||||
dockingButton.Flash(Color.LightGreen, 0.5f);
|
||||
dockingButton.Flash(GUI.Style.Blue, 0.5f, useCircularFlash: true);
|
||||
dockingButton.Pulsate(Vector2.One, Vector2.One * 1.2f, dockingButton.FlashTimer);
|
||||
}
|
||||
}
|
||||
@@ -592,7 +634,7 @@ namespace Barotrauma.Items.Components
|
||||
statusContainer.Visible = false;
|
||||
if (dockingButton.FlashTimer <= 0.0f)
|
||||
{
|
||||
dockingButton.Flash(Color.OrangeRed);
|
||||
dockingButton.Flash(GUI.Style.Orange, useCircularFlash: true);
|
||||
dockingButton.Pulsate(Vector2.One, Vector2.One * 1.2f, dockingButton.FlashTimer);
|
||||
}
|
||||
}
|
||||
@@ -601,8 +643,6 @@ namespace Barotrauma.Items.Components
|
||||
dockingButton.Text = dockText;
|
||||
}
|
||||
|
||||
autoPilotControlsDisabler.Visible = !AutoPilot;
|
||||
|
||||
if (Voltage < MinVoltage)
|
||||
{
|
||||
tipContainer.Visible = true;
|
||||
@@ -781,11 +821,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
|
||||
{
|
||||
msg.Write(autoPilot);
|
||||
msg.Write(AutoPilot);
|
||||
msg.Write(dockingNetworkMessagePending);
|
||||
dockingNetworkMessagePending = false;
|
||||
|
||||
if (!autoPilot)
|
||||
if (!AutoPilot)
|
||||
{
|
||||
//no need to write steering info if autopilot is controlling
|
||||
msg.Write(steeringInput.X);
|
||||
@@ -879,5 +919,15 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGUIElements()
|
||||
{
|
||||
steeringModeSwitch.Selected = AutoPilot;
|
||||
autopilotIndicator.Selected = AutoPilot;
|
||||
manualPilotIndicator.Selected = !AutoPilot;
|
||||
maintainPosTickBox.Enabled = AutoPilot;
|
||||
levelEndTickBox.Enabled = AutoPilot;
|
||||
levelStartTickBox.Enabled = AutoPilot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user