Build 0.20.8.0
This commit is contained in:
@@ -408,6 +408,8 @@ namespace Barotrauma.Items.Components
|
||||
var wire = it.GetComponent<Wire>();
|
||||
if (wire != null && wire.Connections.Any(c => c != null)) { return false; }
|
||||
|
||||
if (it.Container?.GetComponent<ItemContainer>() is { DrawInventory: false }) { return false; }
|
||||
|
||||
if (it.HasTag("traitormissionitem")) { return false; }
|
||||
|
||||
return true;
|
||||
|
||||
@@ -29,7 +29,11 @@ namespace Barotrauma.Items.Components
|
||||
private Sprite tempRangeIndicator;
|
||||
|
||||
private Sprite graphLine;
|
||||
//private GUIFrame graph;
|
||||
private GUICustomComponent graph;
|
||||
|
||||
private GUIFrame inventoryWindow;
|
||||
private GUILayoutGroup buttonArea;
|
||||
private GUIFrame infographic;
|
||||
|
||||
private Color optimalRangeColor = new Color(74,238,104,255);
|
||||
private Color offRangeColor = Color.Orange;
|
||||
@@ -66,6 +70,8 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
public bool TriggerInfographic { get; set; }
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
@@ -122,7 +128,7 @@ namespace Barotrauma.Items.Components
|
||||
//left column
|
||||
//----------------------------------------------------------
|
||||
|
||||
GUIFrame inventoryWindow = new GUIFrame(new RectTransform(new Vector2(0.1f, 0.75f), GuiFrame.RectTransform, Anchor.TopLeft, Pivot.TopRight)
|
||||
inventoryWindow = new GUIFrame(new RectTransform(new Vector2(0.1f, 0.75f), GuiFrame.RectTransform, Anchor.TopLeft, Pivot.TopRight)
|
||||
{
|
||||
MinSize = new Point(85, 220),
|
||||
RelativeOffset = new Vector2(-0.02f, 0)
|
||||
@@ -255,7 +261,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
TurbineOutputScrollBar.Frame.UserData = UIHighlightAction.ElementId.TurbineOutputSlider;
|
||||
|
||||
var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform))
|
||||
buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform))
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
@@ -436,8 +442,8 @@ namespace Barotrauma.Items.Components
|
||||
LocalizedString 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 graphFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), graphArea.RectTransform), style: "InnerFrameRed");
|
||||
graph = new GUICustomComponent(new RectTransform(new Vector2(0.9f, 0.98f), graphFrame.RectTransform, Anchor.Center), DrawGraph, null);
|
||||
|
||||
var outputText = new GUITextBlock(new RectTransform(relativeTextSize, graphArea.RectTransform),
|
||||
"Output", textColor: outputColor, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.CenterLeft)
|
||||
@@ -448,6 +454,22 @@ namespace Barotrauma.Items.Components
|
||||
outputText.TextGetter += () => $"{outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString())} {kW}";
|
||||
|
||||
InitInventoryUI();
|
||||
|
||||
// Infographic overlay ---------------------
|
||||
int buttonHeight = (int)(GUIStyle.ItemFrameMargin.Y * 0.4f);
|
||||
var helpButtonRt = new RectTransform(new Point(buttonHeight), parent: GuiFrame.RectTransform, anchor: Anchor.TopRight)
|
||||
{
|
||||
AbsoluteOffset = new Point(buttonHeight / 4),
|
||||
MinSize = new Point(buttonHeight)
|
||||
};
|
||||
new GUIButton(helpButtonRt, "", style: "HelpIcon")
|
||||
{
|
||||
OnClicked = (_, _) =>
|
||||
{
|
||||
CreateInfrographic();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void InitInventoryUI()
|
||||
@@ -469,7 +491,6 @@ namespace Barotrauma.Items.Components
|
||||
InitInventoryUI();
|
||||
}
|
||||
|
||||
|
||||
private void DrawTempMeter(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
{
|
||||
Vector2 meterPos = new Vector2(container.Rect.X, container.Rect.Y);
|
||||
@@ -518,7 +539,6 @@ namespace Barotrauma.Items.Components
|
||||
DrawGraph(loadGraph, spriteBatch, graphRect, Math.Max(10000.0f, maxLoad), xOffset, loadColor);
|
||||
}
|
||||
|
||||
|
||||
private void UpdateGraph(float deltaTime)
|
||||
{
|
||||
graphTimer += deltaTime * 1000.0f;
|
||||
@@ -645,6 +665,12 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TriggerInfographic)
|
||||
{
|
||||
CreateInfrographic();
|
||||
TriggerInfographic = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMeter(SpriteBatch spriteBatch, Rectangle rect, Sprite meterSprite, float value, Vector2 range, Vector2 optimalRange, Vector2 allowedRange)
|
||||
@@ -760,7 +786,96 @@ namespace Barotrauma.Items.Components
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred);
|
||||
}
|
||||
|
||||
private enum InfographicArrowStyle { Straight, Curved };
|
||||
|
||||
private void CreateInfrographic()
|
||||
{
|
||||
if (infographic != null) { return; }
|
||||
var dimColor = Color.Lerp(Color.Black, Color.TransparentBlack, 0.25f);
|
||||
// Dim reactor interface
|
||||
infographic = new GUIFrame(new RectTransform(Vector2.One, GuiFrame.RectTransform))
|
||||
{
|
||||
CanBeFocused = false,
|
||||
Color = dimColor
|
||||
};
|
||||
// Dim inventory window
|
||||
new GUIFrame(new RectTransform(inventoryWindow.Rect.Size, infographic.RectTransform) { AbsoluteOffset = inventoryWindow.Rect.Location - GuiFrame.Rect.Location}, color: dimColor)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
int arrowSize = (int)(70 * GUI.Scale);
|
||||
var arrows = new Dictionary<string, GUIImage>()
|
||||
{
|
||||
{ "fuelslots", CreateArrow(InfographicArrowStyle.Curved, inventoryWindow, Anchor.TopLeft, Pivot.TopRight, SpriteEffects.FlipVertically) },
|
||||
{ "temperature", CreateArrow(InfographicArrowStyle.Straight, temperatureBoostDownButton, Anchor.Center, Pivot.Center) },
|
||||
{ "automaticcontrol", CreateArrow(InfographicArrowStyle.Curved, AutoTempSwitch, Anchor.TopRight, Pivot.BottomRight, rotationDegrees: 90f) },
|
||||
{ "power", CreateArrow(InfographicArrowStyle.Straight, PowerButton, Anchor.BottomCenter, Pivot.TopCenter) }
|
||||
};
|
||||
CreateArrow(InfographicArrowStyle.Straight, FissionRateScrollBar, Anchor.Center, Pivot.Center);
|
||||
CreateArrow(InfographicArrowStyle.Straight, TurbineOutputScrollBar, Anchor.Center, Pivot.Center);
|
||||
CreateArrow(InfographicArrowStyle.Straight, graph, Anchor.TopLeft, Pivot.TopLeft, SpriteEffects.FlipHorizontally, additionalOffset: new Point(arrowSize / 2, 0));
|
||||
CreateArrow(InfographicArrowStyle.Straight, graph, Anchor.BottomLeft, Pivot.BottomLeft, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically, additionalOffset: new Point(arrowSize / 2, 0));
|
||||
new GUICustomComponent(new RectTransform(Vector2.One, infographic.RectTransform),
|
||||
onDraw: (sb, c) =>
|
||||
{
|
||||
DrawToolTip("fuelslots", Anchor.TopLeft, Pivot.BottomCenter, arrows["fuelslots"]);
|
||||
DrawToolTip("fissionrate", Anchor.TopCenter, Pivot.TopCenter, buttonArea);
|
||||
DrawToolTip("temperature", Anchor.BottomLeft, Pivot.TopLeft, arrows["temperature"]);
|
||||
DrawToolTip("automaticcontrol", Anchor.TopLeft, Pivot.CenterRight, arrows["automaticcontrol"]);
|
||||
DrawToolTip("power", Anchor.BottomCenter, Pivot.TopCenter, arrows["power"]);
|
||||
DrawToolTip("load", Anchor.CenterLeft, Pivot.CenterLeft, graph);
|
||||
|
||||
void DrawToolTip(string textTag, Anchor anchor, Pivot pivot, GUIComponent targetComponent)
|
||||
{
|
||||
GUIComponent.DrawToolTip(sb,
|
||||
TextManager.Get($"infographic.reactor.{textTag}"),
|
||||
targetComponent.Rect,
|
||||
anchor: anchor,
|
||||
pivot: pivot);
|
||||
}
|
||||
})
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
var closeButtonRt = new RectTransform(new Point(200, 50).Multiply(GUI.Scale), infographic.RectTransform, Anchor.TopRight, Pivot.BottomRight)
|
||||
{
|
||||
AbsoluteOffset = new Point(0, -50).Multiply(GUI.Scale)
|
||||
};
|
||||
new GUIButton(closeButtonRt, TextManager.Get("close"))
|
||||
{
|
||||
OnClicked = (_, _) =>
|
||||
{
|
||||
CloseInfographic(Character.Controlled);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
item.OnDeselect += CloseInfographic;
|
||||
|
||||
GUIImage CreateArrow(InfographicArrowStyle arrowStyle, GUIComponent parent, Anchor anchor, Pivot pivot, SpriteEffects spriteEffects = SpriteEffects.None, float rotationDegrees = 0f, Point? additionalOffset = null)
|
||||
{
|
||||
Point offset = (additionalOffset ?? Point.Zero) + RectTransform.CalculateAnchorPoint(anchor, parent.Rect) - GuiFrame.Rect.Location;
|
||||
var rt = new RectTransform(new Point(arrowSize), infographic.RectTransform, pivot: pivot)
|
||||
{
|
||||
AbsoluteOffset = offset
|
||||
};
|
||||
string style = arrowStyle == InfographicArrowStyle.Straight ? "InfographicArrow" : "InfographicArrowCurved";
|
||||
return new GUIImage(rt, style)
|
||||
{
|
||||
Rotation = MathHelper.ToRadians(rotationDegrees),
|
||||
SpriteEffects = spriteEffects
|
||||
};
|
||||
}
|
||||
|
||||
void CloseInfographic(Character character)
|
||||
{
|
||||
if (character != Character.Controlled) { return; }
|
||||
GuiFrame.RemoveChild(infographic);
|
||||
infographic = null;
|
||||
item.OnDeselect -= CloseInfographic;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RemoveComponentSpecific()
|
||||
{
|
||||
base.RemoveComponentSpecific();
|
||||
|
||||
@@ -812,7 +812,7 @@ namespace Barotrauma.Items.Components
|
||||
if (distSqr > t.SoundRange * t.SoundRange * 2) { continue; }
|
||||
|
||||
float dist = (float)Math.Sqrt(distSqr);
|
||||
if (dist > prevPassivePingRadius * Range && dist <= passivePingRadius * Range && Rand.Int(sonarBlips.Count) < 500)
|
||||
if (dist > prevPassivePingRadius * Range && dist <= passivePingRadius * Range && Rand.Int(sonarBlips.Count) < 500 && t.IsWithinSector(transducerCenter))
|
||||
{
|
||||
int prevBlipCount = sonarBlips.Count;
|
||||
Ping(t.WorldPosition, transducerCenter,
|
||||
|
||||
@@ -35,6 +35,13 @@ namespace Barotrauma.Items.Components
|
||||
if (GuiFrame == null) { return; }
|
||||
originalMaxSize = GuiFrame.RectTransform.MaxSize;
|
||||
originalRelativeSize = GuiFrame.RectTransform.RelativeSize;
|
||||
CreateGUI();
|
||||
}
|
||||
|
||||
protected override void CreateGUI()
|
||||
{
|
||||
if (GuiFrame == null) { return; }
|
||||
|
||||
CheckForLabelOverlap();
|
||||
var content = new GUICustomComponent(new RectTransform(Vector2.One, GuiFrame.RectTransform), DrawConnections, null)
|
||||
{
|
||||
@@ -43,8 +50,8 @@ namespace Barotrauma.Items.Components
|
||||
content.RectTransform.SetAsFirstChild();
|
||||
|
||||
//prevents inputs from going through the GUICustomComponent to the drag handle
|
||||
dragArea = new GUIFrame(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset }, style: null);
|
||||
dragArea = new GUIFrame(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset }, style: null);
|
||||
}
|
||||
|
||||
public void TriggerRewiringSound()
|
||||
@@ -121,12 +128,6 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnResolutionChanged()
|
||||
{
|
||||
if (GuiFrame == null) { return; }
|
||||
CheckForLabelOverlap();
|
||||
}
|
||||
|
||||
private void CheckForLabelOverlap()
|
||||
{
|
||||
GuiFrame.RectTransform.MaxSize = originalMaxSize;
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace Barotrauma.Items.Components
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
Character.Controlled.FocusedItem = null;
|
||||
Character.Controlled.ResetInteract = true;
|
||||
Character.Controlled.DisableInteract = true;
|
||||
Character.Controlled.ClearInputs();
|
||||
}
|
||||
//cancel dragging
|
||||
@@ -401,7 +401,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
Character.Controlled.ResetInteract = true;
|
||||
Character.Controlled.DisableInteract = true;
|
||||
Character.Controlled.ClearInputs();
|
||||
}
|
||||
int closestSectionIndex = selectedWire.GetClosestSectionIndex(mousePos, sectionSelectDist, out _);
|
||||
@@ -431,7 +431,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
Character.Controlled.ResetInteract = true;
|
||||
Character.Controlled.DisableInteract = true;
|
||||
Character.Controlled.ClearInputs();
|
||||
}
|
||||
draggingWire = selectedWire;
|
||||
|
||||
Reference in New Issue
Block a user