v0.19.0.0 (unstable)
This commit is contained in:
@@ -23,11 +23,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ExtractJobPrefab(IReadOnlyDictionary<Identifier, string> tags)
|
||||
{
|
||||
if (!tags.TryGetValue("jobid".ToIdentifier(), out string jobId)) { return; }
|
||||
|
||||
if (!tags.TryGetValue("jobid".ToIdentifier(), out string jobId)) { return; }
|
||||
if (!jobId.IsNullOrEmpty())
|
||||
{
|
||||
JobPrefab = JobPrefab.Get(jobId);
|
||||
JobPrefab = JobPrefab.Get(jobId.ToIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -522,13 +522,11 @@ namespace Barotrauma.Items.Components
|
||||
if (soundSelectionModes == null) soundSelectionModes = new Dictionary<ActionType, SoundSelectionMode>();
|
||||
if (!soundSelectionModes.ContainsKey(type) || soundSelectionModes[type] == SoundSelectionMode.Random)
|
||||
{
|
||||
SoundSelectionMode selectionMode = SoundSelectionMode.Random;
|
||||
Enum.TryParse(subElement.GetAttributeString("selectionmode", "Random"), out selectionMode);
|
||||
Enum.TryParse(subElement.GetAttributeString("selectionmode", "Random"), out SoundSelectionMode selectionMode);
|
||||
soundSelectionModes[type] = selectionMode;
|
||||
}
|
||||
|
||||
List<ItemSound> soundList = null;
|
||||
if (!sounds.TryGetValue(itemSound.Type, out soundList))
|
||||
if (!sounds.TryGetValue(itemSound.Type, out List<ItemSound> soundList))
|
||||
{
|
||||
soundList = new List<ItemSound>();
|
||||
sounds.Add(itemSound.Type, soundList);
|
||||
@@ -566,6 +564,9 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
string style = GuiFrameSource.Attribute("style") == null ? null : GuiFrameSource.GetAttributeString("style", "");
|
||||
GuiFrame = new GUIFrame(RectTransform.Load(GuiFrameSource, GUI.Canvas, Anchor.Center), style, color);
|
||||
|
||||
TryCreateDragHandle();
|
||||
|
||||
DefaultLayout = GUILayoutSettings.Load(GuiFrameSource);
|
||||
if (GuiFrame != null)
|
||||
{
|
||||
@@ -574,6 +575,22 @@ namespace Barotrauma.Items.Components
|
||||
GameMain.Instance.ResolutionChanged += OnResolutionChanged;
|
||||
}
|
||||
|
||||
protected void TryCreateDragHandle()
|
||||
{
|
||||
if (GuiFrame != null && GuiFrameSource.GetAttributeBool("draggable", true))
|
||||
{
|
||||
var handle = new GUIDragHandle(new RectTransform(Vector2.One, GuiFrame.RectTransform, Anchor.Center),
|
||||
GuiFrame.RectTransform, style: null)
|
||||
{
|
||||
DragArea = HUDLayoutSettings.ItemHUDArea
|
||||
};
|
||||
|
||||
int iconHeight = GUIStyle.ItemFrameMargin.Y / 4;
|
||||
new GUIImage(new RectTransform(new Point(GuiFrame.Rect.Width, iconHeight), handle.RectTransform, Anchor.TopCenter) { AbsoluteOffset = new Point(0, iconHeight / 2) },
|
||||
style: "GUIDragIndicatorHorizontal");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overload this method and implement. The method is automatically called when the resolution changes.
|
||||
/// </summary>
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Barotrauma.Items.Components
|
||||
onDraw: (SpriteBatch spriteBatch, GUICustomComponent component) => { Inventory.Draw(spriteBatch); },
|
||||
onUpdate: null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
CanBeFocused = true
|
||||
};
|
||||
|
||||
// Expand the frame vertically if it's too small to fit the text
|
||||
@@ -381,10 +381,15 @@ namespace Barotrauma.Items.Components
|
||||
guiCustomComponent.RectTransform.Parent = Inventory.RectTransform;
|
||||
}
|
||||
|
||||
if (item.ParentInventory?.Owner == character && character.SelectedItem == item)
|
||||
{
|
||||
character.SelectedItem = null;
|
||||
}
|
||||
|
||||
//if the item is in the character's inventory, no need to update the item's inventory
|
||||
//because the player can see it by hovering the cursor over the item
|
||||
guiCustomComponent.Visible = item.ParentInventory?.Owner != character && DrawInventory;
|
||||
if (!guiCustomComponent.Visible) { return; }
|
||||
//because the player can see it by hovering the cursor over the item
|
||||
guiCustomComponent.Visible = DrawInventory && item.ParentInventory?.Owner != character;
|
||||
if (!guiCustomComponent.Visible) { return; }
|
||||
|
||||
Inventory.Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
+205
-22
@@ -1,4 +1,5 @@
|
||||
using Barotrauma.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -15,6 +16,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
private GUIButton activateButton;
|
||||
private GUIComponent inputInventoryHolder, outputInventoryHolder;
|
||||
private GUIListBox outputDisplayListBox;
|
||||
|
||||
private GUIComponent inSufficientPowerWarning;
|
||||
|
||||
@@ -44,32 +46,43 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
protected override void CreateGUI()
|
||||
{
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.90f, 0.80f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.88f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true,
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.08f
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1f, 0.07f), paddedFrame.RectTransform), item.Name, font: GUIStyle.SubHeadingFont)
|
||||
new GUITextBlock(new RectTransform(new Vector2(1f, 0.07f), paddedFrame.RectTransform) { MinSize = new Point(0, GUI.IntScale(25)) }, item.Name, font: GUIStyle.SubHeadingFont)
|
||||
{
|
||||
TextAlignment = Alignment.Center,
|
||||
AutoScaleHorizontal = true
|
||||
};
|
||||
|
||||
var topFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), paddedFrame.RectTransform), style: null);
|
||||
|
||||
var topFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.375f), paddedFrame.RectTransform), style: null);
|
||||
|
||||
// === INPUT LABEL === //
|
||||
var inputLabelArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.15f), topFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
var inputLabel = new GUITextBlock(new RectTransform(Vector2.One, inputLabelArea.RectTransform), TextManager.Get("deconstructor.input", "uilabel.input"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
inputLabel.RectTransform.Resize(new Point((int) inputLabel.Font.MeasureString(inputLabel.Text).X, inputLabel.RectTransform.Rect.Height));
|
||||
new GUIFrame(new RectTransform(Vector2.One, inputLabelArea.RectTransform), style: "HorizontalLine");
|
||||
var inputLabelArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.15f), topFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true);
|
||||
|
||||
var queueLabelLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.43f, 1f), inputLabelArea.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
var queueLabel = new GUITextBlock(new RectTransform(Vector2.One, queueLabelLayout.RectTransform), TextManager.Get("deconstructor.inputqueue"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
queueLabel.RectTransform.Resize(new Point((int) queueLabel.Font.MeasureString(queueLabel.Text).X, queueLabel.RectTransform.Rect.Height));
|
||||
new GUIFrame(new RectTransform(Vector2.One, queueLabelLayout.RectTransform), style: "HorizontalLine");
|
||||
|
||||
var inputLabelLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.57f, 1f), inputLabelArea.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
var inputLabel = new GUITextBlock(new RectTransform(Vector2.One, inputLabelLayout.RectTransform), TextManager.Get("deconstructor.input", "uilabel.input"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
inputLabel.RectTransform.Resize(new Point((int) inputLabel.Font.MeasureString(inputLabel.Text).X, inputLabel.RectTransform.Rect.Height));
|
||||
new GUIFrame(new RectTransform(Vector2.One, inputLabelLayout.RectTransform), style: "HorizontalLine");
|
||||
|
||||
var inputArea = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), topFrame.RectTransform, Anchor.CenterLeft), childAnchor: Anchor.BottomLeft, isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f };
|
||||
|
||||
|
||||
// === INPUT SLOTS === //
|
||||
inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.7f, 1f), inputArea.RectTransform), style: null);
|
||||
new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawOverLay, null) { CanBeFocused = false };
|
||||
@@ -92,8 +105,8 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
// === OUTPUT AREA === //
|
||||
var bottomFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), paddedFrame.RectTransform), style: null);
|
||||
|
||||
var bottomFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.375f), paddedFrame.RectTransform), style: null);
|
||||
|
||||
// === OUTPUT LABEL === //
|
||||
var outputLabelArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.15f), bottomFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true)
|
||||
{
|
||||
@@ -104,10 +117,16 @@ namespace Barotrauma.Items.Components
|
||||
outputLabel.RectTransform.Resize(new Point((int) outputLabel.Font.MeasureString(outputLabel.Text).X, outputLabel.RectTransform.Rect.Height));
|
||||
new GUIFrame(new RectTransform(Vector2.One, outputLabelArea.RectTransform), style: "HorizontalLine");
|
||||
|
||||
var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), bottomFrame.RectTransform, Anchor.CenterLeft), childAnchor: Anchor.BottomLeft, isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f };
|
||||
var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), bottomFrame.RectTransform, Anchor.CenterLeft), childAnchor: Anchor.BottomLeft, isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f };
|
||||
|
||||
// === OUTPUT SLOTS === //
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f - InfoAreaWidth, 1f), outputArea.RectTransform, Anchor.CenterLeft), style: null);
|
||||
// === OUTPUT SLOTS === //
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f - InfoAreaWidth, 1f), outputArea.RectTransform, Anchor.CenterLeft), style: null);
|
||||
|
||||
GUILayoutGroup outputDisplayLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), paddedFrame.RectTransform), childAnchor: Anchor.TopCenter);
|
||||
GUILayoutGroup outDisplayTopGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.2f), outputDisplayLayout.RectTransform), isHorizontal: true);
|
||||
GUITextBlock outDisplayBlock = new GUITextBlock(new RectTransform(Vector2.One, outDisplayTopGroup.RectTransform), TextManager.Get("deconstructor.output"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
GUILayoutGroup outDisplayBottomGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.975f, 0.8f), outputDisplayLayout.RectTransform), isHorizontal: true);
|
||||
outputDisplayListBox = new GUIListBox(new RectTransform(new Vector2(1f, 1f), outDisplayBottomGroup.RectTransform), isHorizontal: true, style: null);
|
||||
|
||||
if (InfoAreaWidth >= 0.0f)
|
||||
{
|
||||
@@ -181,7 +200,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (!(linkedTo is Item { DisplaySideBySideWhenLinked: true } linkedItem)) { continue; }
|
||||
if (!linkedItem.Components.Any()) { continue; }
|
||||
|
||||
|
||||
var itemContainer = linkedItem.GetComponent<ItemContainer>();
|
||||
if (itemContainer?.GuiFrame == null || itemContainer.AllowUIOverlap) { continue; }
|
||||
|
||||
@@ -195,6 +214,170 @@ namespace Barotrauma.Items.Components
|
||||
return base.Select(character);
|
||||
}
|
||||
|
||||
partial void OnItemSlotsChanged(ItemContainer container)
|
||||
{
|
||||
if (container.Inventory is null) { return; }
|
||||
RefreshOutputDisplay(container.Inventory.AllItems.ToImmutableArray());
|
||||
}
|
||||
|
||||
private void RefreshOutputDisplay(ImmutableArray<Item> items)
|
||||
{
|
||||
const string outputItemCountUserData = "OutputItemCount";
|
||||
const string questionMarkUserData = "UnknownItemOutput";
|
||||
|
||||
if (outputDisplayListBox is null || inputContainer.Inventory is null) { return; }
|
||||
|
||||
Dictionary<Identifier, int> itemCounts = new Dictionary<Identifier, int>();
|
||||
Dictionary<Identifier, GUIComponent> children = new Dictionary<Identifier, GUIComponent>();
|
||||
|
||||
bool addQuestionMark = false;
|
||||
|
||||
foreach (GUIComponent child in outputDisplayListBox.Content.Children)
|
||||
{
|
||||
if (child.UserData is Identifier it)
|
||||
{
|
||||
children.Add(it, child);
|
||||
}
|
||||
}
|
||||
|
||||
if (outputDisplayListBox.Content.FindChild(questionMarkUserData) is { } foundChild)
|
||||
{
|
||||
outputDisplayListBox.RemoveChild(foundChild);
|
||||
}
|
||||
|
||||
foreach (Item it in items)
|
||||
{
|
||||
if (it.Prefab.RandomDeconstructionOutput)
|
||||
{
|
||||
addQuestionMark = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (DeconstructItem deconstructItem in it.Prefab.DeconstructItems)
|
||||
{
|
||||
RegisterItem(deconstructItem.ItemIdentifier);
|
||||
}
|
||||
|
||||
if (it.OwnInventory is { } inventory)
|
||||
{
|
||||
foreach (Item inventoryItems in inventory.AllItems)
|
||||
{
|
||||
RegisterItem(inventoryItems.Prefab.Identifier);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterItem(Identifier identifier)
|
||||
{
|
||||
if (itemCounts.ContainsKey(identifier))
|
||||
{
|
||||
itemCounts[identifier]++;
|
||||
return;
|
||||
}
|
||||
|
||||
itemCounts.Add(identifier, 1);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (it, child) in children)
|
||||
{
|
||||
if (!itemCounts.ContainsKey(it))
|
||||
{
|
||||
outputDisplayListBox.RemoveChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (it, amount) in itemCounts)
|
||||
{
|
||||
if (!children.TryGetValue(it, out GUIComponent child))
|
||||
{
|
||||
child = CreateOutputDisplayItem(it, outputDisplayListBox.Content);
|
||||
}
|
||||
|
||||
if (child is null) { continue; }
|
||||
UpdateOutputDisplayItemCount(child, amount);
|
||||
}
|
||||
|
||||
if (addQuestionMark)
|
||||
{
|
||||
CreateQuestionMark(outputDisplayListBox.Content);
|
||||
}
|
||||
|
||||
static void CreateQuestionMark(GUIComponent parent)
|
||||
{
|
||||
GUIFrame itemFrame = new GUIFrame(new RectTransform(new Vector2(0.1f, 1f), parent.RectTransform), style: null)
|
||||
{
|
||||
UserData = questionMarkUserData,
|
||||
ToolTip = TextManager.Get("deconstructor.unknownitemsoutput")
|
||||
};
|
||||
|
||||
GUIFrame questionMarkFrame = new GUIFrame(new RectTransform(Vector2.One, itemFrame.RectTransform, scaleBasis: ScaleBasis.Smallest, anchor: Anchor.Center), style: "GUIFrameListBox")
|
||||
{
|
||||
CanBeFocused = false,
|
||||
};
|
||||
|
||||
// question mark text
|
||||
new GUITextBlock(new RectTransform(Vector2.One, questionMarkFrame.RectTransform, anchor: Anchor.Center), text: "?", textAlignment: Alignment.Center, font: GUIStyle.LargeFont)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
|
||||
static GUIComponent CreateOutputDisplayItem(Identifier identifier, GUIComponent parent)
|
||||
{
|
||||
ItemPrefab prefab = ItemPrefab.Find(null, identifier);
|
||||
if (prefab is null) { return null; }
|
||||
|
||||
GUIFrame itemFrame = new GUIFrame(new RectTransform(new Vector2(0.1f, 1f), parent.RectTransform), style: null)
|
||||
{
|
||||
UserData = identifier,
|
||||
ToolTip = GetTooltip(prefab)
|
||||
};
|
||||
|
||||
Sprite icon = prefab.InventoryIcon ?? prefab.Sprite;
|
||||
Color iconColor = prefab.InventoryIcon is null ? prefab.SpriteColor : prefab.InventoryIconColor;
|
||||
|
||||
GUIImage itemIcon = new GUIImage(new RectTransform(Vector2.One, itemFrame.RectTransform, scaleBasis: ScaleBasis.Smallest, anchor: Anchor.Center), sprite: icon, scaleToFit: true)
|
||||
{
|
||||
Color = iconColor,
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
// item count text
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.5f), itemIcon.RectTransform, anchor: Anchor.BottomRight), "", font: GUIStyle.Font, textAlignment: Alignment.BottomRight)
|
||||
{
|
||||
UserData = outputItemCountUserData,
|
||||
Shadow = true,
|
||||
CanBeFocused = false,
|
||||
Padding = Vector4.Zero,
|
||||
TextColor = Color.White,
|
||||
};
|
||||
|
||||
return itemFrame;
|
||||
}
|
||||
|
||||
static void UpdateOutputDisplayItemCount(GUIComponent component, int count)
|
||||
{
|
||||
if (!(component.FindChild(outputItemCountUserData, recursive: true) is GUITextBlock textBlock)) { return; }
|
||||
|
||||
textBlock.Text = TextManager.GetWithVariable("campaignstore.quantity", "[amount]", count.ToString());
|
||||
}
|
||||
|
||||
static RichString GetTooltip(ItemPrefab prefab)
|
||||
{
|
||||
LocalizedString toolTip = $"‖color:{Color.White.ToStringHex()}‖{prefab.Name}‖color:end‖";
|
||||
|
||||
LocalizedString description = prefab.Description;
|
||||
if (!description.IsNullOrEmpty()) { toolTip += '\n' + description; }
|
||||
|
||||
if (prefab.ContentPackage != GameMain.VanillaContent && prefab.ContentPackage != null)
|
||||
{
|
||||
toolTip += $"\n‖color:{Color.MediumPurple.ToStringHex()}‖{prefab.ContentPackage.Name}‖color:end‖";
|
||||
}
|
||||
|
||||
return RichString.Rich(toolTip);
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnItemLoadedProjSpecific()
|
||||
{
|
||||
inputContainer.AllowUIOverlap = true;
|
||||
@@ -208,7 +391,7 @@ namespace Barotrauma.Items.Components
|
||||
overlayComponent.RectTransform.SetAsLastChild();
|
||||
|
||||
if (!(inputContainer?.Inventory?.visualSlots is { } visualSlots)) { return; }
|
||||
|
||||
|
||||
if (DeconstructItemsSimultaneously)
|
||||
{
|
||||
for (int i = 0; i < InputContainer.Inventory.Capacity; i++)
|
||||
|
||||
@@ -246,6 +246,7 @@ namespace Barotrauma.Items.Components
|
||||
protected override void CreateGUI()
|
||||
{
|
||||
GuiFrame.ClearChildren();
|
||||
TryCreateDragHandle();
|
||||
|
||||
GuiFrame.RectTransform.RelativeOffset = new Vector2(0.05f, 0.0f);
|
||||
GuiFrame.CanBeFocused = true;
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (Character.Controlled?.SelectedConstruction != item)
|
||||
if (Character.Controlled?.SelectedItem != item)
|
||||
{
|
||||
IsActive = false;
|
||||
return;
|
||||
|
||||
@@ -871,13 +871,11 @@ namespace Barotrauma.Items.Components
|
||||
posToMaintain = item.Submarine.WorldPosition;
|
||||
}
|
||||
MaintainPos = true;
|
||||
if (userdata is Vector2)
|
||||
if (userdata is Vector2 nudgeAmount)
|
||||
{
|
||||
Sonar sonar = item.GetComponent<Sonar>();
|
||||
Vector2 nudgeAmount = (Vector2)userdata;
|
||||
if (sonar != null)
|
||||
if (item.GetComponent<Sonar>() is Sonar sonar)
|
||||
{
|
||||
nudgeAmount *= sonar == null ? 500.0f : 500.0f / sonar.Zoom;
|
||||
nudgeAmount *= 500.0f / sonar.Zoom;
|
||||
}
|
||||
PosToMaintain += nudgeAmount;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Barotrauma.Items.Components
|
||||
public override bool ShouldDrawHUD(Character character)
|
||||
{
|
||||
if (item.HiddenInGame) { return false; }
|
||||
if (!HasRequiredItems(character, false) || character.SelectedConstruction != item) { return false; }
|
||||
if (!HasRequiredItems(character, false) || character.SelectedItem != item) { return false; }
|
||||
if (character.IsTraitor && item.ConditionPercentage > MinSabotageCondition) { return true; }
|
||||
|
||||
float defaultMaxCondition = item.MaxCondition / item.MaxRepairConditionMultiplier;
|
||||
@@ -110,6 +110,7 @@ namespace Barotrauma.Items.Components
|
||||
if (GuiFrame != null)
|
||||
{
|
||||
GuiFrame.ClearChildren();
|
||||
TryCreateDragHandle();
|
||||
CreateGUI();
|
||||
}
|
||||
}
|
||||
@@ -265,7 +266,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentFixer != null && CurrentFixer.SelectedConstruction == item)
|
||||
if (CurrentFixer != null && CurrentFixer.SelectedItem == item)
|
||||
{
|
||||
if (repairSoundChannel == null || !repairSoundChannel.IsPlaying)
|
||||
{
|
||||
|
||||
+10
-4
@@ -33,10 +33,16 @@ namespace Barotrauma.Items.Components
|
||||
originalMaxSize = GuiFrame.RectTransform.MaxSize;
|
||||
originalRelativeSize = GuiFrame.RectTransform.RelativeSize;
|
||||
CheckForLabelOverlap();
|
||||
new GUICustomComponent(new RectTransform(Vector2.One, GuiFrame.RectTransform), DrawConnections, null)
|
||||
var content = new GUICustomComponent(new RectTransform(Vector2.One, GuiFrame.RectTransform), DrawConnections, null)
|
||||
{
|
||||
UserData = this
|
||||
};
|
||||
content.RectTransform.SetAsFirstChild();
|
||||
|
||||
//prevents inputs from going through the GUICustomComponent to the drag handle
|
||||
var blocker = new GUIFrame(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
style: null);
|
||||
}
|
||||
|
||||
public void TriggerRewiringSound()
|
||||
@@ -62,7 +68,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
rewireSoundTimer -= deltaTime;
|
||||
if (user != null && user.SelectedConstruction == item && rewireSoundTimer > 0.0f)
|
||||
if (user != null && user.SelectedItem == item && rewireSoundTimer > 0.0f)
|
||||
{
|
||||
if (rewireSoundChannel == null || !rewireSoundChannel.IsPlaying)
|
||||
{
|
||||
@@ -85,12 +91,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool ShouldDrawHUD(Character character)
|
||||
{
|
||||
return character == Character.Controlled && character == user && character.SelectedConstruction == item;
|
||||
return character == Character.Controlled && character == user && character.SelectedItem == item;
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
{
|
||||
if (character != Character.Controlled || character != user || character.SelectedConstruction != item) { return; }
|
||||
if (character != Character.Controlled || character != user || character.SelectedItem != item) { return; }
|
||||
|
||||
if (HighlightedWire != null)
|
||||
{
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Barotrauma.Items.Components
|
||||
Wire equippedWire = Character.Controlled.HeldItems.FirstOrDefault(it => it.GetComponent<Wire>() != null)?.GetComponent<Wire>();
|
||||
if (equippedWire != null && GUI.MouseOn == null)
|
||||
{
|
||||
if (PlayerInput.PrimaryMouseButtonClicked() && Character.Controlled.SelectedConstruction == null)
|
||||
if (PlayerInput.PrimaryMouseButtonClicked() && Character.Controlled.SelectedItem == null)
|
||||
{
|
||||
equippedWire.Use(1.0f, Character.Controlled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user