v0.19.8.0
This commit is contained in:
@@ -4,6 +4,7 @@ using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -177,7 +178,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
Color color = item.SpriteColor;
|
||||
Color color = item.GetSpriteColor(withHighlight: true);
|
||||
if (brokenSprite == null)
|
||||
{
|
||||
//broken doors turn black if no broken sprite has been configured
|
||||
@@ -220,11 +221,15 @@ namespace Barotrauma.Items.Components
|
||||
color, 0.0f, doorSprite.Origin, item.Scale, item.SpriteEffects, doorSprite.Depth);
|
||||
}
|
||||
|
||||
if (brokenSprite != null && item.Health < item.MaxCondition)
|
||||
float maxCondition = item.Repairables.Any() ?
|
||||
item.Repairables.Min(r => r.RepairThreshold) / 100.0f * item.MaxCondition :
|
||||
item.MaxCondition;
|
||||
float healthRatio = item.Health / maxCondition;
|
||||
if (brokenSprite != null && healthRatio < 1.0f)
|
||||
{
|
||||
Vector2 scale = scaleBrokenSprite ? new Vector2(1.0f - item.Health / item.MaxCondition) : Vector2.One;
|
||||
Vector2 scale = scaleBrokenSprite ? new Vector2(1.0f - healthRatio) : Vector2.One;
|
||||
if (IsHorizontal) { scale.X = 1; } else { scale.Y = 1; }
|
||||
float alpha = fadeBrokenSprite ? 1.0f - item.Health / item.MaxCondition : 1.0f;
|
||||
float alpha = fadeBrokenSprite ? 1.0f - healthRatio : 1.0f;
|
||||
spriteBatch.Draw(brokenSprite.Texture, pos,
|
||||
getSourceRect(brokenSprite, openState, IsHorizontal),
|
||||
color * alpha, 0.0f, brokenSprite.Origin, scale * item.Scale, item.SpriteEffects,
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace Barotrauma.Items.Components
|
||||
GameMain.Instance.ResolutionChanged += OnResolutionChangedPrivate;
|
||||
}
|
||||
|
||||
protected void TryCreateDragHandle()
|
||||
protected virtual void TryCreateDragHandle()
|
||||
{
|
||||
if (GuiFrame != null && GuiFrameSource.GetAttributeBool("draggable", true))
|
||||
{
|
||||
@@ -593,6 +593,7 @@ namespace Barotrauma.Items.Components
|
||||
int iconHeight = GUIStyle.ItemFrameMargin.Y / 4;
|
||||
var dragIcon = new GUIImage(new RectTransform(new Point(GuiFrame.Rect.Width, iconHeight), handle.RectTransform, Anchor.TopCenter) { AbsoluteOffset = new Point(0, iconHeight / 2) },
|
||||
style: "GUIDragIndicatorHorizontal");
|
||||
dragIcon.RectTransform.MinSize = new Point(0, iconHeight);
|
||||
|
||||
handle.ValidatePosition = (RectTransform rectT) =>
|
||||
{
|
||||
@@ -622,7 +623,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
int buttonHeight = (int)(GUIStyle.ItemFrameMargin.Y * 0.4f);
|
||||
new GUIButton(new RectTransform(new Point(buttonHeight), handle.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(buttonHeight / 4) },
|
||||
new GUIButton(new RectTransform(new Point(buttonHeight), handle.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(buttonHeight / 4), MinSize = new Point(buttonHeight) },
|
||||
style: "GUIButtonSettings")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
|
||||
@@ -324,6 +324,8 @@ namespace Barotrauma.Items.Components
|
||||
int i = 0;
|
||||
foreach (Item containedItem in Inventory.AllItems)
|
||||
{
|
||||
if (containedItem?.Sprite == null) { continue; }
|
||||
|
||||
if (AutoInteractWithContained)
|
||||
{
|
||||
containedItem.IsHighlighted = item.IsHighlighted;
|
||||
@@ -344,7 +346,7 @@ namespace Barotrauma.Items.Components
|
||||
containedItem.Sprite.Draw(
|
||||
spriteBatch,
|
||||
new Vector2(currentItemPos.X, -currentItemPos.Y),
|
||||
isWiringMode ? containedItem.GetSpriteColor() * 0.15f : containedItem.GetSpriteColor(),
|
||||
isWiringMode ? containedItem.GetSpriteColor(withHighlight: true) * 0.15f : containedItem.GetSpriteColor(withHighlight: true),
|
||||
origin,
|
||||
-(containedItem.body == null ? 0.0f : containedItem.body.DrawRotation ),
|
||||
containedItem.Scale,
|
||||
|
||||
+13
-7
@@ -96,6 +96,7 @@ namespace Barotrauma.Items.Components
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 0.8f), inputArea.RectTransform), childAnchor: Anchor.CenterLeft);
|
||||
activateButton = new GUIButton(new RectTransform(new Vector2(0.95f, 0.8f), buttonContainer.RectTransform), TextManager.Get("DeconstructorDeconstruct"), style: "DeviceButton")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.DeconstructButton,
|
||||
TextBlock = { AutoScaleHorizontal = true },
|
||||
OnClicked = OnActivateButtonClicked
|
||||
};
|
||||
@@ -432,17 +433,22 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private bool OnActivateButtonClicked(GUIButton button, object obj)
|
||||
{
|
||||
var disallowedItem = inputContainer.Inventory.FindItem(i => !i.AllowDeconstruct, recursive: false);
|
||||
if (disallowedItem != null && !DeconstructItemsSimultaneously)
|
||||
if (!IsActive)
|
||||
{
|
||||
int index = inputContainer.Inventory.FindIndex(disallowedItem);
|
||||
if (index >= 0 && index < inputContainer.Inventory.visualSlots.Length)
|
||||
//don't allow turning on if there's non-deconstructable items in the queue
|
||||
var disallowedItem = inputContainer.Inventory.FindItem(i => !i.AllowDeconstruct, recursive: false);
|
||||
if (disallowedItem != null && !DeconstructItemsSimultaneously)
|
||||
{
|
||||
var slot = inputContainer.Inventory.visualSlots[index];
|
||||
slot?.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.9f);
|
||||
int index = inputContainer.Inventory.FindIndex(disallowedItem);
|
||||
if (index >= 0 && index < inputContainer.Inventory.visualSlots.Length)
|
||||
{
|
||||
var slot = inputContainer.Inventory.visualSlots[index];
|
||||
slot?.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.9f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
pendingState = !IsActive;
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
private FabricationRecipe selectedItem;
|
||||
|
||||
public Identifier SelectedItemIdentifier => SelectedItem?.TargetItem.Identifier ?? Identifier.Empty;
|
||||
|
||||
private GUIComponent inSufficientPowerWarning;
|
||||
|
||||
private FabricationRecipe pendingFabricatedItem;
|
||||
|
||||
@@ -1013,12 +1013,14 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else if (hullData.LinkedHulls.Any())
|
||||
{
|
||||
hullData.HullWaterAmount = 0.0f;
|
||||
float waterVolume = 0.0f;
|
||||
float totalVolume = 0.0f;
|
||||
foreach (Hull linkedHull in hullData.LinkedHulls)
|
||||
{
|
||||
hullData.HullWaterAmount += WaterDetector.GetWaterPercentage(linkedHull);
|
||||
waterVolume += linkedHull.WaterVolume;
|
||||
totalVolume += linkedHull.Volume;
|
||||
}
|
||||
hullData.HullWaterAmount /= hullData.LinkedHulls.Count;
|
||||
hullData.HullWaterAmount = MathHelper.Clamp((int)Math.Ceiling(waterVolume / totalVolume * 100), 0, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -58,6 +56,7 @@ namespace Barotrauma.Items.Components
|
||||
RelativeOffset = new Vector2(0, 0.1f)
|
||||
}, style: "PowerButton")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.PowerButton,
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
TargetLevel = null;
|
||||
@@ -114,6 +113,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
};
|
||||
pumpSpeedSlider.Frame.UserData = UIHighlightAction.ElementId.PumpSpeedSlider;
|
||||
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: GUIStyle.TextColorNormal, textAlignment: Alignment.CenterLeft, wrap: false, font: GUIStyle.SubHeadingFont);
|
||||
|
||||
@@ -234,6 +234,7 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
};
|
||||
FissionRateScrollBar.Frame.UserData = UIHighlightAction.ElementId.FissionRateSlider;
|
||||
|
||||
TurbineOutputScrollBar = new GUIScrollBar(new RectTransform(sliderSize, rightArea.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
@@ -252,6 +253,7 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
};
|
||||
TurbineOutputScrollBar.Frame.UserData = UIHighlightAction.ElementId.TurbineOutputSlider;
|
||||
|
||||
var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform))
|
||||
{
|
||||
@@ -302,9 +304,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
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),
|
||||
AutoTempSwitch = new GUIButton(new RectTransform(new Vector2(0.15f, 0.9f), topRightArea.RectTransform),
|
||||
style: "SwitchVertical")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.AutoTempSwitch,
|
||||
Enabled = false,
|
||||
Selected = AutoTemp,
|
||||
ClickSound = GUISoundType.UISwitch,
|
||||
@@ -347,6 +350,7 @@ namespace Barotrauma.Items.Components
|
||||
RelativeOffset = new Vector2(0, 0.1f)
|
||||
}, style: "PowerButton")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.PowerButton,
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
PowerOn = !PowerOn;
|
||||
|
||||
@@ -216,6 +216,7 @@ namespace Barotrauma.Items.Components
|
||||
var sonarModeArea = new GUIFrame(new RectTransform(new Vector2(1, 0.4f + extraHeight), paddedControlContainer.RectTransform, Anchor.TopCenter), style: null);
|
||||
SonarModeSwitch = new GUIButton(new RectTransform(new Vector2(0.2f, 1), sonarModeArea.RectTransform), string.Empty, style: "SwitchVertical")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.SonarModeSwitch,
|
||||
Selected = false,
|
||||
Enabled = true,
|
||||
ClickSound = GUISoundType.UISwitch,
|
||||
@@ -238,6 +239,7 @@ namespace Barotrauma.Items.Components
|
||||
passiveTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), sonarModeRightSide.RectTransform, Anchor.TopLeft),
|
||||
TextManager.Get("SonarPassive"), font: GUIStyle.SubHeadingFont, style: "IndicatorLightRedSmall")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.PassiveSonarIndicator,
|
||||
ToolTip = TextManager.Get("SonarTipPassive"),
|
||||
Selected = true,
|
||||
Enabled = false
|
||||
@@ -245,6 +247,7 @@ namespace Barotrauma.Items.Components
|
||||
activeTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), sonarModeRightSide.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("SonarActive"), font: GUIStyle.SubHeadingFont, style: "IndicatorLightRedSmall")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.ActiveSonarIndicator,
|
||||
ToolTip = TextManager.Get("SonarTipActive"),
|
||||
Selected = false,
|
||||
Enabled = false
|
||||
@@ -279,9 +282,14 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(0.8f, 0.01f), paddedControlContainer.RectTransform, Anchor.Center), style: "HorizontalLine")
|
||||
{ UserData = "horizontalline" };
|
||||
{
|
||||
UserData = "horizontalline"
|
||||
};
|
||||
|
||||
var directionalModeFrame = new GUIFrame(new RectTransform(new Vector2(1, 0.45f), lowerAreaFrame.RectTransform, Anchor.BottomCenter), style: null);
|
||||
var directionalModeFrame = new GUIFrame(new RectTransform(new Vector2(1, 0.45f), lowerAreaFrame.RectTransform, Anchor.BottomCenter), style: null)
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.DirectionalSonarFrame
|
||||
};
|
||||
directionalModeSwitch = new GUIButton(new RectTransform(new Vector2(0.3f, 0.8f), directionalModeFrame.RectTransform, Anchor.CenterLeft), string.Empty, style: "SwitchHorizontal")
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
@@ -334,6 +342,18 @@ namespace Barotrauma.Items.Components
|
||||
sonarView.RectTransform.RelativeOffset = new Vector2(0.13f * GUI.RelativeHorizontalAspectRatio, 0);
|
||||
sonarView.RectTransform.SetPosition(Anchor.BottomRight);
|
||||
}
|
||||
var handle = GuiFrame.GetChild<GUIDragHandle>();
|
||||
if (handle != null)
|
||||
{
|
||||
handle.RectTransform.Parent = controlContainer.RectTransform;
|
||||
handle.RectTransform.Resize(Vector2.One);
|
||||
handle.RectTransform.SetAsFirstChild();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void TryCreateDragHandle()
|
||||
{
|
||||
base.TryCreateDragHandle();
|
||||
}
|
||||
|
||||
private void SetPingDirection(Vector2 direction)
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -141,6 +139,7 @@ namespace Barotrauma.Items.Components
|
||||
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")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.SteeringModeSwitch,
|
||||
Selected = autoPilot,
|
||||
Enabled = true,
|
||||
ClickSound = GUISoundType.UISwitch,
|
||||
@@ -182,6 +181,7 @@ namespace Barotrauma.Items.Components
|
||||
maintainPosTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.TopCenter),
|
||||
TextManager.Get("SteeringMaintainPos"), font: GUIStyle.SmallFont, style: "GUIRadioButton")
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.MaintainPosTickBox,
|
||||
Enabled = autoPilot,
|
||||
Selected = maintainPos,
|
||||
OnSelected = tickBox =>
|
||||
|
||||
@@ -83,7 +83,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
rechargeSpeedSlider.Bar.RectTransform.MaxSize = new Point(rechargeSpeedSlider.Bar.Rect.Height);
|
||||
|
||||
rechargeSpeedSlider.Frame.UserData = UIHighlightAction.ElementId.RechargeSpeedSlider;
|
||||
|
||||
// lower area --------------------------
|
||||
|
||||
var chargeTextContainer = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), lowerArea.RectTransform), style: null);
|
||||
|
||||
@@ -165,6 +165,7 @@ namespace Barotrauma.Items.Components
|
||||
repairingText = TextManager.Get("Repairing");
|
||||
RepairButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), progressBarHolder.RectTransform, Anchor.TopCenter), repairButtonText)
|
||||
{
|
||||
UserData = UIHighlightAction.ElementId.RepairButton,
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
requestStartFixAction = FixActions.Repair;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ShowError($"Error creating a CustomInterface component: unexpected NumberType \"{(ciElement.NumberType.HasValue ? ciElement.NumberType.Value.ToString() : "none")}\"");
|
||||
DebugConsole.LogError($"Error creating a CustomInterface component: unexpected NumberType \"{(ciElement.NumberType.HasValue ? ciElement.NumberType.Value.ToString() : "none")}\"");
|
||||
}
|
||||
if (numberInput != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user