Unstable v0.9.707.0
This commit is contained in:
@@ -11,7 +11,7 @@ using System.Xml.Linq;
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class CharacterInventory : Inventory
|
||||
{
|
||||
{
|
||||
public enum Layout
|
||||
{
|
||||
Default,
|
||||
@@ -35,20 +35,13 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
private static Dictionary<InvSlotType, Sprite> limbSlotIcons;
|
||||
private static Sprite inventoryBackgroundSprite, inventoryExtendButton, inventoryExtendUpArrow, inventoryExtendDownArrow;
|
||||
|
||||
public Rectangle InventoryToggleArea;
|
||||
public bool InventoryToggleContains = false;
|
||||
private Vector2 inventoryExtendButtonOffset, inventoryArrowOffset;
|
||||
private int inventoryOpeningOffset;
|
||||
|
||||
private Point prevResolution;
|
||||
|
||||
public const InvSlotType PersonalSlots = InvSlotType.Card | InvSlotType.Headset | InvSlotType.InnerClothes | InvSlotType.OuterClothes | InvSlotType.Head;
|
||||
|
||||
public Vector2[] SlotPositions;
|
||||
private Vector2 bgScale;
|
||||
private Point screenResolution;
|
||||
|
||||
public Vector2[] SlotPositions;
|
||||
|
||||
private Layout layout;
|
||||
public Layout CurrentLayout
|
||||
{
|
||||
@@ -57,7 +50,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (layout == value) return;
|
||||
layout = value;
|
||||
SetSlotPositions();
|
||||
SetSlotPositions(layout);
|
||||
}
|
||||
}
|
||||
public bool Hidden { get; set; }
|
||||
@@ -66,8 +59,6 @@ namespace Barotrauma
|
||||
private float hidePersonalSlotsState;
|
||||
private GUIButton hideButton;
|
||||
private Rectangle personalSlotArea;
|
||||
private bool inventoryOpen = false;
|
||||
private bool wasInventoryToggledAutomatically = false;
|
||||
|
||||
public bool HidePersonalSlots
|
||||
{
|
||||
@@ -112,16 +103,10 @@ namespace Barotrauma
|
||||
limbSlotIcons.Add(InvSlotType.LeftHand, new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(634, 0, 128, 128)));
|
||||
limbSlotIcons.Add(InvSlotType.RightHand, new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(762, 0, 128, 128)));
|
||||
limbSlotIcons.Add(InvSlotType.OuterClothes, new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(256 + margin, 128 + margin, 128 - margin * 2, 128 - margin * 2)));
|
||||
|
||||
inventoryBackgroundSprite = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(252, 317, 263, 197));
|
||||
inventoryExtendButton = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(533, 300, 96, 19));
|
||||
inventoryExtendUpArrow = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(640, 310, 10, 10));
|
||||
inventoryExtendDownArrow = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(668, 310, 10, 10));
|
||||
}
|
||||
|
||||
SlotPositions = new Vector2[SlotTypes.Length];
|
||||
CurrentLayout = Layout.Default;
|
||||
SetSlotPositions();
|
||||
SetSlotPositions(layout);
|
||||
}
|
||||
|
||||
protected override ItemInventory GetActiveEquippedSubInventory(int slotIndex)
|
||||
@@ -157,6 +142,8 @@ namespace Barotrauma
|
||||
public override void CreateSlots()
|
||||
{
|
||||
if (slots == null) { slots = new InventorySlot[capacity]; }
|
||||
|
||||
float multiplier = !GUI.IsFourByThree() ? UIScale : UIScale * 0.925f;
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
@@ -166,7 +153,7 @@ namespace Barotrauma
|
||||
Rectangle slotRect = new Rectangle(
|
||||
(int)(SlotPositions[i].X),
|
||||
(int)(SlotPositions[i].Y),
|
||||
(int)(slotSprite.size.X * UIScale), (int)(slotSprite.size.Y * UIScale));
|
||||
(int)(slotSprite.size.X * multiplier), (int)(slotSprite.size.Y * multiplier));
|
||||
|
||||
if (Items[i] != null)
|
||||
{
|
||||
@@ -208,54 +195,31 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
CalculateBackgroundFrame();
|
||||
}
|
||||
|
||||
protected override void CalculateBackgroundFrame()
|
||||
{
|
||||
Rectangle frame = Rectangle.Empty;
|
||||
int firstSlotLocationY = 0;
|
||||
int lastSlotLocationY = 0;
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (HideSlot(i)) continue;
|
||||
if (PersonalSlots.HasFlag(SlotTypes[i])) continue;
|
||||
if (IsHandSlot(SlotTypes[i])) continue;
|
||||
if (frame == Rectangle.Empty)
|
||||
{
|
||||
firstSlotLocationY = slots[i].Rect.Location.Y;
|
||||
frame = slots[i].Rect;
|
||||
continue;
|
||||
}
|
||||
frame = Rectangle.Union(frame, slots[i].Rect);
|
||||
lastSlotLocationY = slots[i].Rect.Location.Y;
|
||||
}
|
||||
|
||||
frame.Inflate(25f * UIScale, 25f * UIScale);
|
||||
|
||||
if (layout == Layout.Default)
|
||||
{
|
||||
inventoryOpeningOffset = firstSlotLocationY - lastSlotLocationY;
|
||||
|
||||
bgScale = new Vector2((float)frame.Width / (float)inventoryBackgroundSprite.SourceRect.Width, (float)frame.Height / (float)inventoryBackgroundSprite.SourceRect.Height);
|
||||
|
||||
inventoryExtendButtonOffset = new Vector2(inventoryExtendButton.size.X * UIScale * 1.5f / 2f, inventoryExtendButton.size.Y * UIScale * 1.5f / 2f + UIScale * 6);
|
||||
inventoryArrowOffset = new Vector2(inventoryExtendUpArrow.size.X * UIScale * 1.25f / 2f, inventoryExtendUpArrow.size.Y * UIScale * 1.25f / 2f);
|
||||
InventoryToggleArea = new Rectangle(new Point(frame.Center.X, frame.Top) - inventoryExtendButtonOffset.ToPoint(), inventoryExtendButton.size.ToPoint() + new Point(0, (int)(UIScale * 6f)));
|
||||
if (!inventoryOpen)
|
||||
{
|
||||
frame.Offset(0, inventoryOpeningOffset);
|
||||
InventoryToggleArea.Offset(0, inventoryOpeningOffset);
|
||||
}
|
||||
}
|
||||
|
||||
frame.Inflate(10, 30);
|
||||
frame.Location -= new Point(0, 25);
|
||||
BackgroundFrame = frame;
|
||||
}
|
||||
|
||||
protected override bool HideSlot(int i)
|
||||
{
|
||||
if (slots[i].Disabled) return true;
|
||||
if (slots[i].Disabled || (hideEmptySlot[i] && Items[i] == null)) return true;
|
||||
|
||||
if (layout == Layout.Default)
|
||||
{
|
||||
@@ -268,23 +232,34 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
//don't show the equip slot if the item is also in the default inventory
|
||||
if (SlotTypes[i] != InvSlotType.Any && Items[i] != null)
|
||||
{
|
||||
for (int j = 0; j < capacity; j++)
|
||||
{
|
||||
if (SlotTypes[j] == InvSlotType.Any && Items[j] == Items[i]) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool IsSlotHiddenDueToToggleState(int i)
|
||||
private void SetSlotPositions(Layout layout)
|
||||
{
|
||||
return layout == Layout.Default && !inventoryOpen && slots[i].QuickUseKey == Keys.None && SlotTypes[i] == InvSlotType.Any;
|
||||
}
|
||||
int spacing;
|
||||
|
||||
private void SetSlotPositions()
|
||||
{
|
||||
Layout layout = CurrentLayout;
|
||||
int spacing = (int)(10 * UIScale);
|
||||
Point slotSize = (SlotSpriteSmall.size * UIScale).ToPoint();
|
||||
bool isFourByThree = GUI.IsFourByThree();
|
||||
if (isFourByThree)
|
||||
{
|
||||
spacing = (int)(5 * UIScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
spacing = (int)(10 * UIScale);
|
||||
}
|
||||
|
||||
Point slotSize = !isFourByThree ? (SlotSpriteSmall.size * UIScale).ToPoint() : (SlotSpriteSmall.size * UIScale * .925f).ToPoint();
|
||||
int bottomOffset = slotSize.Y + spacing * 2 + ContainedIndicatorHeight;
|
||||
|
||||
prevResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
if (slots == null) { CreateSlots(); }
|
||||
|
||||
hideButton.Visible = false;
|
||||
@@ -296,47 +271,27 @@ namespace Barotrauma
|
||||
int personalSlotCount = SlotTypes.Count(s => PersonalSlots.HasFlag(s));
|
||||
int normalSlotCount = SlotTypes.Count(s => !PersonalSlots.HasFlag(s));
|
||||
|
||||
int firstRowSlotCount = hotkeyCount > normalSlotCount ? normalSlotCount : hotkeyCount;
|
||||
|
||||
int startX = GameMain.GraphicsWidth / 2 - firstRowSlotCount * (slotSize.X + spacing) / 2;
|
||||
int x = startX;
|
||||
int equipmentX = GameMain.GraphicsWidth - slotSize.X * 2;
|
||||
int buttonIndex = 0;
|
||||
int startY = GameMain.GraphicsHeight - bottomOffset;
|
||||
int y = startY;
|
||||
int handIndex = 1;
|
||||
int x = GameMain.GraphicsWidth / 2 - normalSlotCount * (slotSize.X + spacing) / 2;
|
||||
int upperX = GameMain.GraphicsWidth - slotSize.X * 2;
|
||||
|
||||
//make sure the rightmost normal slot doesn't overlap with the personal slots
|
||||
x -= Math.Max(x + firstRowSlotCount * (slotSize.X + spacing) - (equipmentX - personalSlotCount * (slotSize.X + spacing)), 0);
|
||||
x -= Math.Max((x + normalSlotCount * (slotSize.X + spacing)) - (upperX - personalSlotCount * (slotSize.X + spacing)), 0);
|
||||
|
||||
int hideButtonSlotIndex = -1;
|
||||
for (int i = 0; i < SlotPositions.Length; i++)
|
||||
{
|
||||
if (PersonalSlots.HasFlag(SlotTypes[i]))
|
||||
{
|
||||
SlotPositions[i] = new Vector2(equipmentX, startY);
|
||||
equipmentX -= slotSize.X + spacing;
|
||||
SlotPositions[i] = new Vector2(upperX, GameMain.GraphicsHeight - bottomOffset);
|
||||
upperX -= slotSize.X + spacing;
|
||||
personalSlotArea = (hideButtonSlotIndex == -1) ?
|
||||
new Rectangle(SlotPositions[i].ToPoint(), slotSize) :
|
||||
Rectangle.Union(personalSlotArea, new Rectangle(SlotPositions[i].ToPoint(), slotSize));
|
||||
hideButtonSlotIndex = i;
|
||||
}
|
||||
else if (IsHandSlot(SlotTypes[i]))
|
||||
{
|
||||
SlotPositions[i] = new Vector2(startX - (slotSize.X + spacing * 4) - (slotSize.X + spacing) * handIndex, startY);
|
||||
handIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buttonIndex >= hotkeyCount)
|
||||
{
|
||||
y -= bottomOffset;
|
||||
buttonIndex = 0;
|
||||
x = startX;
|
||||
}
|
||||
|
||||
buttonIndex++;
|
||||
SlotPositions[i] = new Vector2(x, y);
|
||||
SlotPositions[i] = new Vector2(x, GameMain.GraphicsHeight - bottomOffset);
|
||||
x += slotSize.X + spacing;
|
||||
}
|
||||
}
|
||||
@@ -354,6 +309,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case Layout.Right:
|
||||
{
|
||||
int extraOffset = 0;
|
||||
int x = HUDLayoutSettings.InventoryAreaLower.Right;
|
||||
int personalSlotX = HUDLayoutSettings.InventoryAreaLower.Right - slotSize.X - spacing;
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
@@ -364,35 +320,24 @@ namespace Barotrauma
|
||||
//upperX -= slotSize.X + spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i < slots.Length - 5)
|
||||
{
|
||||
x -= slotSize.X + spacing;
|
||||
}
|
||||
{
|
||||
x -= slotSize.X + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
int lowerX = x;
|
||||
int y = GameMain.GraphicsHeight - bottomOffset;
|
||||
|
||||
for (int i = 0; i < SlotPositions.Length; i++)
|
||||
{
|
||||
if (HideSlot(i)) continue;
|
||||
if (PersonalSlots.HasFlag(SlotTypes[i]))
|
||||
{
|
||||
SlotPositions[i] = new Vector2(personalSlotX, y - bottomOffset);
|
||||
SlotPositions[i] = new Vector2(personalSlotX, GameMain.GraphicsHeight - bottomOffset * 2 - extraOffset - spacing * 2);
|
||||
personalSlotX -= slots[i].Rect.Width + spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
SlotPositions[i] = new Vector2(x, y);
|
||||
SlotPositions[i] = new Vector2(x, GameMain.GraphicsHeight - bottomOffset - extraOffset);
|
||||
x += slots[i].Rect.Width + spacing;
|
||||
|
||||
if (i == SlotPositions.Length - 6)
|
||||
{
|
||||
x = lowerX + (slots[i].Rect.Width + spacing) * 2;
|
||||
y -= bottomOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,37 +346,28 @@ namespace Barotrauma
|
||||
{
|
||||
if (!HideSlot(i)) continue;
|
||||
x -= slots[i].Rect.Width + spacing;
|
||||
SlotPositions[i] = new Vector2(x, y);
|
||||
SlotPositions[i] = new Vector2(x, GameMain.GraphicsHeight - bottomOffset - extraOffset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Layout.Left:
|
||||
{
|
||||
int x = HUDLayoutSettings.InventoryAreaLower.Left;
|
||||
int y = GameMain.GraphicsHeight - bottomOffset;
|
||||
int x = HUDLayoutSettings.InventoryAreaLower.X;
|
||||
int personalSlotX = x;
|
||||
|
||||
for (int i = 0; i < SlotPositions.Length; i++)
|
||||
{
|
||||
if (HideSlot(i)) continue;
|
||||
if (PersonalSlots.HasFlag(SlotTypes[i]))
|
||||
{
|
||||
SlotPositions[i] = new Vector2(personalSlotX, y - bottomOffset);
|
||||
SlotPositions[i] = new Vector2(personalSlotX, GameMain.GraphicsHeight - bottomOffset * 2 - spacing * 2);
|
||||
personalSlotX += slots[i].Rect.Width + spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
SlotPositions[i] = new Vector2(x, y);
|
||||
SlotPositions[i] = new Vector2(x, GameMain.GraphicsHeight - bottomOffset);
|
||||
x += slots[i].Rect.Width + spacing;
|
||||
|
||||
if (i == SlotPositions.Length - 7)
|
||||
{
|
||||
x -= (slots[i].Rect.Width + spacing) * 6;
|
||||
y -= bottomOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < SlotPositions.Length; i++)
|
||||
{
|
||||
if (!HideSlot(i)) continue;
|
||||
@@ -483,11 +419,7 @@ namespace Barotrauma
|
||||
{
|
||||
HUDLayoutSettings.InventoryTopY = slots[0].EquipButtonRect.Y - (int)(15 * GUI.Scale);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsHandSlot(InvSlotType slotType)
|
||||
{
|
||||
return slotType == InvSlotType.LeftHand || slotType == InvSlotType.RightHand;
|
||||
|
||||
}
|
||||
|
||||
protected override void ControlInput(Camera cam)
|
||||
@@ -500,32 +432,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleInventory(bool automaticToggle = false)
|
||||
{
|
||||
if (Character.Controlled == null || !Character.Controlled.IsHuman || wasInventoryToggledAutomatically || inventoryOpen && automaticToggle) return;
|
||||
inventoryOpen = !inventoryOpen;
|
||||
if (inventoryOpen)
|
||||
{
|
||||
wasInventoryToggledAutomatically = automaticToggle;
|
||||
BackgroundFrame.Offset(0, -inventoryOpeningOffset);
|
||||
InventoryToggleArea.Offset(0, -inventoryOpeningOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
BackgroundFrame.Offset(0, inventoryOpeningOffset);
|
||||
InventoryToggleArea.Offset(0, inventoryOpeningOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleAutomaticInventoryState()
|
||||
{
|
||||
if (wasInventoryToggledAutomatically && inventoryOpen && Character.Controlled.SelectedConstruction == null && Character.Controlled.SelectedCharacter == null)
|
||||
{
|
||||
wasInventoryToggledAutomatically = false;
|
||||
ToggleInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam, bool isSubInventory = false)
|
||||
{
|
||||
if (!AccessibleWhenAlive && !character.IsDead)
|
||||
@@ -534,8 +440,6 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
HandleAutomaticInventoryState();
|
||||
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
bool hoverOnInventory = GUI.MouseOn == null &&
|
||||
@@ -564,12 +468,6 @@ namespace Barotrauma
|
||||
slots[i].DrawOffset = Vector2.Lerp(Vector2.Zero, new Vector2(personalSlotArea.Width, 0.0f), hidePersonalSlotsState);
|
||||
}
|
||||
}
|
||||
|
||||
InventoryToggleContains = InventoryToggleArea.Contains(PlayerInput.MousePosition);
|
||||
if (InventoryToggleContains && PlayerInput.PrimaryMouseButtonClicked())
|
||||
{
|
||||
ToggleInventory();
|
||||
}
|
||||
}
|
||||
|
||||
if (hoverOnInventory) { HideTimer = 0.5f; }
|
||||
@@ -726,10 +624,7 @@ namespace Barotrauma
|
||||
|
||||
private void HandleButtonEquipStates(Item item, InventorySlot slot, float deltaTime)
|
||||
{
|
||||
Rectangle modifiedRect = slot.EquipButtonRect;
|
||||
modifiedRect.Width = slot.InteractRect.Width;
|
||||
|
||||
slot.EquipButtonState = modifiedRect.Contains(PlayerInput.MousePosition) ?
|
||||
slot.EquipButtonState = slot.EquipButtonRect.Contains(PlayerInput.MousePosition) ?
|
||||
GUIComponent.ComponentState.Hover : GUIComponent.ComponentState.None;
|
||||
if (PlayerInput.LeftButtonHeld() && PlayerInput.RightButtonHeld())
|
||||
{
|
||||
@@ -803,8 +698,6 @@ namespace Barotrauma
|
||||
continue;
|
||||
}
|
||||
|
||||
if (num > hotkeyCount) break;
|
||||
|
||||
if (SlotTypes[i] == InvSlotType.Any)
|
||||
{
|
||||
slots[i].QuickUseKey = Keys.D0 + num % 10;
|
||||
@@ -950,7 +843,7 @@ namespace Barotrauma
|
||||
if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
|
||||
{
|
||||
//player has selected the inventory of another character -> attempt to move the item there
|
||||
success = character.SelectedCharacter.Inventory.TryPutItem(item, Character.Controlled, item.AllowedSlots, true, true);
|
||||
success = character.SelectedCharacter.Inventory.TryPutItem(item, Character.Controlled, item.AllowedSlots, true);
|
||||
}
|
||||
break;
|
||||
case QuickUseAction.PutToContainer:
|
||||
@@ -966,7 +859,7 @@ namespace Barotrauma
|
||||
character.SelectedBy.Inventory != null)
|
||||
{
|
||||
//item is in the inventory of another character -> attempt to get the item from there
|
||||
success = character.SelectedBy.Inventory.TryPutItemWithAutoEquipCheck(item, Character.Controlled, item.AllowedSlots, true, true);
|
||||
success = character.SelectedBy.Inventory.TryPutItemWithAutoEquipCheck(item, Character.Controlled, item.AllowedSlots, true);
|
||||
}
|
||||
break;
|
||||
case QuickUseAction.TakeFromContainer:
|
||||
@@ -985,7 +878,7 @@ namespace Barotrauma
|
||||
// No subinventory found or placing unsuccessful -> attempt to put in the character's inventory
|
||||
if (!success)
|
||||
{
|
||||
success = TryPutItemWithAutoEquipCheck(item, Character.Controlled, item.AllowedSlots, true, true);
|
||||
success = TryPutItemWithAutoEquipCheck(item, Character.Controlled, item.AllowedSlots, true);
|
||||
}
|
||||
break;
|
||||
case QuickUseAction.PutToEquippedItem:
|
||||
@@ -1017,86 +910,128 @@ namespace Barotrauma
|
||||
GUI.PlayUISound(success ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
}
|
||||
|
||||
public void DrawThis(SpriteBatch spriteBatch)
|
||||
public void DrawOwn(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!AccessibleWhenAlive && !character.IsDead) { return; }
|
||||
if (slots == null) { CreateSlots(); }
|
||||
|
||||
if (prevResolution.X != GameMain.GraphicsWidth || prevResolution.Y != GameMain.GraphicsHeight)
|
||||
if (!AccessibleWhenAlive && !character.IsDead) return;
|
||||
if (slots == null) CreateSlots();
|
||||
if (GameMain.GraphicsWidth != screenResolution.X ||
|
||||
GameMain.GraphicsHeight != screenResolution.Y ||
|
||||
prevUIScale != UIScale ||
|
||||
prevHUDScale != GUI.Scale)
|
||||
{
|
||||
SetSlotPositions();
|
||||
SetSlotPositions(layout);
|
||||
prevUIScale = UIScale;
|
||||
prevHUDScale = GUI.Scale;
|
||||
}
|
||||
|
||||
if (layout == Layout.Center)
|
||||
{
|
||||
CalculateBackgroundFrame();
|
||||
GUI.DrawRectangle(spriteBatch, BackgroundFrame, Color.Black * 0.8f, true);
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2((int)(BackgroundFrame.Center.X - GUI.Font.MeasureString(character.Name).X / 2), (int)BackgroundFrame.Y + 5),
|
||||
character.Name, Color.White * 0.9f);
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (HideSlot(i)) continue;
|
||||
|
||||
Rectangle interactRect = slots[i].InteractRect;
|
||||
interactRect.Location += slots[i].DrawOffset.ToPoint();
|
||||
|
||||
//don't draw the item if it's being dragged out of the slot
|
||||
bool drawItem = draggingItem == null || draggingItem != Items[i] || interactRect.Contains(PlayerInput.MousePosition);
|
||||
DrawSlot(spriteBatch, this, slots[i], Items[i], i, drawItem, SlotTypes[i]);
|
||||
}
|
||||
|
||||
if (hideButton != null && hideButton.Visible && !Locked)
|
||||
{
|
||||
hideButton.DrawManually(spriteBatch, alsoChildren: true);
|
||||
}
|
||||
|
||||
if (layout == Layout.Default)
|
||||
{
|
||||
inventoryBackgroundSprite.Draw(spriteBatch, BackgroundFrame.Location.ToVector2(), Color.White, Vector2.Zero, rotate: 0, scale: bgScale);
|
||||
|
||||
Vector2 backgroundFrameCenter = new Vector2(BackgroundFrame.Center.X, BackgroundFrame.Top);
|
||||
inventoryExtendButton.Draw(spriteBatch, backgroundFrameCenter - inventoryExtendButtonOffset, Color.White, scale: UIScale * 1.5f);
|
||||
|
||||
Vector2 arrowPosition = backgroundFrameCenter - inventoryArrowOffset;
|
||||
if (inventoryOpen)
|
||||
{
|
||||
inventoryExtendDownArrow.Draw(spriteBatch, arrowPosition, Color.White, scale: UIScale * 1.25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
inventoryExtendUpArrow.Draw(spriteBatch, arrowPosition, Color.White, scale: UIScale * 1.25f);
|
||||
}
|
||||
|
||||
GUI.DrawString(spriteBatch, arrowPosition + new Vector2(UIScale * 25, -3 * UIScale), GameMain.Config.KeyBindText(InputType.ToggleInventory), Color.White, font: GUI.HotkeyFont);
|
||||
}
|
||||
|
||||
InventorySlot highlightedQuickUseSlot = null;
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (HideSlot(i)) continue;
|
||||
if (IsSlotHiddenDueToToggleState(i)) continue;
|
||||
|
||||
InventorySlot slot = slots[i];
|
||||
|
||||
Item item = Items[i];
|
||||
InvSlotType slotType = SlotTypes[i];
|
||||
|
||||
Rectangle interactRect = slot.InteractRect;
|
||||
interactRect.Location += slot.DrawOffset.ToPoint();
|
||||
|
||||
//don't draw the item if it's being dragged out of the slot
|
||||
bool drawItem = draggingItem == null || draggingItem != item || interactRect.Contains(PlayerInput.MousePosition);
|
||||
DrawSlot(spriteBatch, this, slot, item, i, drawItem, slotType);
|
||||
|
||||
if (item == null || (draggingItem == item && !slot.InteractRect.Contains(PlayerInput.MousePosition)) || !item.AllowedSlots.Any(a => a != InvSlotType.Any))
|
||||
if (Items[i] == null ||
|
||||
(draggingItem == Items[i] && !slots[i].InteractRect.Contains(PlayerInput.MousePosition)) ||
|
||||
!Items[i].AllowedSlots.Any(a => a != InvSlotType.Any))
|
||||
{
|
||||
//draw limb icons on empty slots
|
||||
if (limbSlotIcons.ContainsKey(slotType))
|
||||
if (limbSlotIcons.ContainsKey(SlotTypes[i]))
|
||||
{
|
||||
var icon = limbSlotIcons[slotType];
|
||||
icon.Draw(spriteBatch, slot.Rect.Center.ToVector2() + slot.DrawOffset, GUIColorSettings.EquipmentSlotIconColor, origin: icon.size / 2, scale: slot.Rect.Width / icon.size.X);
|
||||
var icon = limbSlotIcons[SlotTypes[i]];
|
||||
icon.Draw(spriteBatch, slots[i].Rect.Center.ToVector2() + slots[i].DrawOffset, GUIColorSettings.EquipmentSlotIconColor, origin: icon.size / 2, scale: slots[i].Rect.Width / icon.size.X);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (draggingItem == Items[i] && !slots[i].IsHighlighted) continue;
|
||||
|
||||
//draw hand icons if the item is equipped in a hand slot
|
||||
if (IsInLimbSlot(Items[i], InvSlotType.LeftHand))
|
||||
{
|
||||
var icon = limbSlotIcons[InvSlotType.LeftHand];
|
||||
icon.Draw(spriteBatch, new Vector2(slots[i].Rect.X, slots[i].Rect.Bottom) + slots[i].DrawOffset, Color.White * 0.6f, origin: new Vector2(icon.size.X * 0.35f, icon.size.Y * 0.75f), scale: slots[i].Rect.Width / icon.size.X * 0.7f);
|
||||
}
|
||||
if (IsInLimbSlot(Items[i], InvSlotType.RightHand))
|
||||
{
|
||||
var icon = limbSlotIcons[InvSlotType.RightHand];
|
||||
icon.Draw(spriteBatch, new Vector2(slots[i].Rect.Right, slots[i].Rect.Bottom) + slots[i].DrawOffset, Color.White * 0.6f, origin: new Vector2(icon.size.X * 0.65f, icon.size.Y * 0.75f), scale: slots[i].Rect.Width / icon.size.X * 0.7f);
|
||||
}
|
||||
|
||||
// Draw always on hotkeys
|
||||
if (slot.QuickUseKey != Keys.None)
|
||||
{
|
||||
DrawIndicatorAndHotkey(spriteBatch, slot, slot.EquipButtonState == GUIComponent.ComponentState.Hover);
|
||||
}
|
||||
GUIComponent.ComponentState state = slots[i].EquipButtonState;
|
||||
if (state == GUIComponent.ComponentState.Hover)
|
||||
{
|
||||
highlightedQuickUseSlot = slots[i];
|
||||
}
|
||||
|
||||
if (!Items[i].AllowedSlots.Any(a => a == InvSlotType.Any))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (draggingItem == item && !slot.IsHighlighted) continue;
|
||||
|
||||
bool hover = slot.EquipButtonState == GUIComponent.ComponentState.Hover;
|
||||
if (hover) highlightedQuickUseSlot = slot;
|
||||
|
||||
if (!item.AllowedSlots.Any(a => a == InvSlotType.Any)) continue;
|
||||
|
||||
DrawIndicatorAndHotkey(spriteBatch, slot, hover);
|
||||
Color color = Color.White;
|
||||
if (Locked)
|
||||
{
|
||||
color *= 0.5f;
|
||||
}
|
||||
|
||||
if (character.HasEquippedItem(Items[i]))
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case GUIComponent.ComponentState.None:
|
||||
EquippedIndicator.Draw(spriteBatch, slots[i].EquipButtonRect.Center.ToVector2(), color, EquippedIndicator.Origin, 0, UIScale * IndicatorScaleAdjustment);
|
||||
break;
|
||||
case GUIComponent.ComponentState.Hover:
|
||||
EquippedHoverIndicator.Draw(spriteBatch, slots[i].EquipButtonRect.Center.ToVector2(), color, EquippedIndicator.Origin, 0, UIScale * IndicatorScaleAdjustment);
|
||||
break;
|
||||
case GUIComponent.ComponentState.Pressed:
|
||||
case GUIComponent.ComponentState.Selected:
|
||||
case GUIComponent.ComponentState.HoverSelected:
|
||||
EquippedClickedIndicator.Draw(spriteBatch, slots[i].EquipButtonRect.Center.ToVector2(), color, EquippedIndicator.Origin, 0, UIScale * IndicatorScaleAdjustment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case GUIComponent.ComponentState.None:
|
||||
UnequippedIndicator.Draw(spriteBatch, slots[i].EquipButtonRect.Center.ToVector2(), color, EquippedIndicator.Origin, 0, UIScale * IndicatorScaleAdjustment);
|
||||
break;
|
||||
case GUIComponent.ComponentState.Hover:
|
||||
UnequippedHoverIndicator.Draw(spriteBatch, slots[i].EquipButtonRect.Center.ToVector2(), color, EquippedIndicator.Origin, 0, UIScale * IndicatorScaleAdjustment);
|
||||
break;
|
||||
case GUIComponent.ComponentState.Pressed:
|
||||
case GUIComponent.ComponentState.Selected:
|
||||
case GUIComponent.ComponentState.HoverSelected:
|
||||
UnequippedClickedIndicator.Draw(spriteBatch, slots[i].EquipButtonRect.Center.ToVector2(), color, EquippedIndicator.Origin, 0, UIScale * IndicatorScaleAdjustment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (highlightedQuickUseSlot != null && !string.IsNullOrEmpty(highlightedQuickUseSlot.QuickUseButtonToolTip))
|
||||
@@ -1104,30 +1039,5 @@ namespace Barotrauma
|
||||
GUIComponent.DrawToolTip(spriteBatch, highlightedQuickUseSlot.QuickUseButtonToolTip, highlightedQuickUseSlot.EquipButtonRect);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawIndicatorAndHotkey(SpriteBatch spriteBatch, InventorySlot slot, bool hover)
|
||||
{
|
||||
|
||||
Color indicatorColor = (hover) ? Color.White : Color.White * 0.8f;
|
||||
|
||||
/*if (character.HasEquippedItem(item))
|
||||
{
|
||||
indicatorColor = hover ? GUIColorSettings.InventorySlotEquippedColor : GUIColorSettings.InventorySlotEquippedColor * 0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
indicatorColor = hover ? GUIColorSettings.InventorySlotColor : GUIColorSettings.InventorySlotColor * 0.8f;
|
||||
}*/
|
||||
|
||||
if (Locked) indicatorColor *= 0.3f;
|
||||
|
||||
Rectangle equipRect = slot.EquipButtonRect;
|
||||
EquipIndicator.Draw(spriteBatch, new Vector2(equipRect.Center.X, equipRect.Bottom), indicatorColor, EquipIndicator.Origin, 0, UIScale * 0.6f);
|
||||
|
||||
if (slot.QuickUseKey != Keys.None)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, new Vector2(slot.Rect.Center.X - 2, slot.Rect.Top), slot.QuickUseKey.ToString().Substring(1, 1), Color.Black, font: GUI.HotkeyFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,9 +334,9 @@ namespace Barotrauma.Items.Components
|
||||
//docking interface ----------------------------------------------------
|
||||
float dockingButtonSize = 1.1f;
|
||||
float elementScale = 0.6f;
|
||||
dockingContainer = new GUIFrame(new RectTransform(new Point(160).Multiply(GUI.Scale * dockingButtonSize), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
dockingContainer = new GUIFrame(new RectTransform(Sonar.controlBoxSize, GuiFrame.RectTransform, Anchor.BottomLeft, scaleBasis: ScaleBasis.Smallest)
|
||||
{
|
||||
RelativeOffset = new Vector2(Sonar.controlBoxOffset.X + 0.15f, -0.1f)
|
||||
RelativeOffset = Sonar.controlBoxOffset
|
||||
}, style: null);
|
||||
|
||||
dockText = TextManager.Get("label.navterminaldock", fallBackTag: "captain.dock");
|
||||
|
||||
@@ -156,6 +156,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
panel.DisconnectedWires.Add(DraggingConnected);
|
||||
}
|
||||
else if (DraggingConnected.Connections[0] == null && DraggingConnected.Connections[1] == null)
|
||||
{
|
||||
DraggingConnected.ClearConnections(user: Character.Controlled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +191,7 @@ namespace Barotrauma.Items.Components
|
||||
x = (int)(x + width / 2 - step * (panel.DisconnectedWires.Count() - 1) / 2);
|
||||
foreach (Wire wire in panel.DisconnectedWires)
|
||||
{
|
||||
if (wire == DraggingConnected) { continue; }
|
||||
if (wire == DraggingConnected && mouseInRect) { continue; }
|
||||
|
||||
Connection recipient = wire.OtherConnection(null);
|
||||
string label = recipient == null ? "" : recipient.item.Name + $" ({recipient.DisplayName})";
|
||||
|
||||
+14
-11
@@ -109,17 +109,20 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
base.CreateEditingHUD(editor);
|
||||
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(customInterfaceElementList[0]);
|
||||
PropertyDescriptor labelProperty = properties.Find("Label", false);
|
||||
PropertyDescriptor signalProperty = properties.Find("Signal", false);
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
editor.CreateStringField(customInterfaceElementList[i],
|
||||
new SerializableProperty(labelProperty),
|
||||
customInterfaceElementList[i].Label, "Label #" + (i + 1), "");
|
||||
editor.CreateStringField(customInterfaceElementList[i],
|
||||
new SerializableProperty(signalProperty),
|
||||
customInterfaceElementList[i].Signal, "Signal #" + (i + 1), "");
|
||||
if (customInterfaceElementList.Count > 0)
|
||||
{
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(customInterfaceElementList[0]);
|
||||
PropertyDescriptor labelProperty = properties.Find("Label", false);
|
||||
PropertyDescriptor signalProperty = properties.Find("Signal", false);
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
editor.CreateStringField(customInterfaceElementList[i],
|
||||
new SerializableProperty(labelProperty),
|
||||
customInterfaceElementList[i].Label, "Label #" + (i + 1), "");
|
||||
editor.CreateStringField(customInterfaceElementList[i],
|
||||
new SerializableProperty(signalProperty),
|
||||
customInterfaceElementList[i].Signal, "Signal #" + (i + 1), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -444,9 +444,10 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
powerIndicator.DrawManually(spriteBatch, true);
|
||||
|
||||
int requiredChargeIndicatorPos = (int)((powerConsumption / (batteryCapacity * 3600.0f)) * powerIndicator.Rect.Width);
|
||||
Rectangle sliderRect = powerIndicator.GetSliderRect(1.0f);
|
||||
int requiredChargeIndicatorPos = (int)(powerConsumption / (batteryCapacity * 3600.0f) * sliderRect.Width);
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Rectangle(powerIndicator.Rect.X + requiredChargeIndicatorPos, powerIndicator.Rect.Y, 3, powerIndicator.Rect.Height),
|
||||
new Rectangle(sliderRect.X + requiredChargeIndicatorPos, sliderRect.Y, 2, sliderRect.Height),
|
||||
Color.White * 0.5f, true);
|
||||
}
|
||||
|
||||
@@ -459,7 +460,7 @@ namespace Barotrauma.Items.Components
|
||||
Point invSlotPos = new Point(GameMain.GraphicsWidth / 2 - totalWidth / 2, (int)(60 * GUI.Scale));
|
||||
for (int i = 0; i < availableAmmo.Count; i++)
|
||||
{
|
||||
// TODO: Optimize? Creates multiple new classes per frame?
|
||||
// TODO: Optimize? Creates multiple new objects per frame?
|
||||
Inventory.DrawSlot(spriteBatch, null,
|
||||
new InventorySlot(new Rectangle(invSlotPos + new Point((i % slotsPerRow) * (slotSize.X + spacing), (int)Math.Floor(i / (float)slotsPerRow) * (slotSize.Y + spacing)), slotSize)),
|
||||
availableAmmo[i], -1, true);
|
||||
|
||||
@@ -53,10 +53,12 @@ namespace Barotrauma
|
||||
{
|
||||
int buttonDir = Math.Sign(SubInventoryDir);
|
||||
|
||||
Vector2 equipIndicatorPos = new Vector2(Rect.Left, Rect.Top);
|
||||
float sizeY = Inventory.UnequippedIndicator.size.Y * Inventory.UIScale * Inventory.IndicatorScaleAdjustment;
|
||||
|
||||
Vector2 equipIndicatorPos = new Vector2(Rect.Left, Rect.Center.Y + (Rect.Height / 2 + 25 * Inventory.UIScale) * buttonDir - sizeY / 2f);
|
||||
equipIndicatorPos += DrawOffset;
|
||||
|
||||
return new Rectangle((int)equipIndicatorPos.X, (int)equipIndicatorPos.Y, Rect.Width, (int)(Inventory.EquipIndicator.size.Y * Inventory.UIScale));
|
||||
return new Rectangle((int)equipIndicatorPos.X, (int)equipIndicatorPos.Y, (int)Rect.Width, (int)sizeY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,19 +138,27 @@ namespace Barotrauma
|
||||
{
|
||||
if (slotSpriteSmall == null)
|
||||
{
|
||||
//TODO: define these in xml
|
||||
slotSpriteSmall = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(12, 9, 115, 115), null, 0);
|
||||
slotSpriteSmall.size = new Vector2(SlotSpriteSmall.SourceRect.Width * 0.682f, SlotSpriteSmall.SourceRect.Height * 0.682f);
|
||||
//TODO: define this in xml
|
||||
slotSpriteSmall = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(10, 6, 119, 120), null, 0);
|
||||
// Adjustment to match the old size of 75,71
|
||||
SlotSpriteSmall.size = new Vector2(SlotSpriteSmall.SourceRect.Width * 0.625f, SlotSpriteSmall.SourceRect.Height * 0.625f);
|
||||
}
|
||||
return slotSpriteSmall;
|
||||
}
|
||||
}
|
||||
public static Sprite DraggableIndicator;
|
||||
public static Sprite EquipIndicator;
|
||||
|
||||
public static Sprite UnequippedIndicator, UnequippedHoverIndicator, UnequippedClickedIndicator, EquippedIndicator, EquippedHoverIndicator, EquippedClickedIndicator;
|
||||
public static float IndicatorScaleAdjustment
|
||||
{
|
||||
get
|
||||
{
|
||||
return !GUI.IsFourByThree() ? 0.85f : 0.75f;
|
||||
}
|
||||
}
|
||||
|
||||
public static Inventory DraggingInventory;
|
||||
|
||||
public Rectangle BackgroundFrame;
|
||||
public Rectangle BackgroundFrame { get; protected set; }
|
||||
|
||||
private ushort[] receivedItemIDs;
|
||||
private CoroutineHandle syncItemsCoroutine;
|
||||
@@ -305,7 +315,7 @@ namespace Barotrauma
|
||||
int columns = Math.Min(slotsPerRow, capacity);
|
||||
|
||||
Vector2 spacing = new Vector2(5.0f * UIScale);
|
||||
spacing.Y += (this is CharacterInventory) ? EquipIndicator.size.Y : ContainedIndicatorHeight;
|
||||
spacing.Y += (this is CharacterInventory) ? UnequippedIndicator.size.Y * UIScale : ContainedIndicatorHeight;
|
||||
Vector2 rectSize = new Vector2(60.0f * UIScale);
|
||||
|
||||
padding = new Vector4(spacing.X, spacing.Y, spacing.X, spacing.X);
|
||||
@@ -384,12 +394,7 @@ namespace Barotrauma
|
||||
|
||||
protected virtual bool HideSlot(int i)
|
||||
{
|
||||
return slots[i].Disabled;
|
||||
}
|
||||
|
||||
protected virtual bool IsSlotHiddenDueToToggleState(int i)
|
||||
{
|
||||
return false;
|
||||
return slots[i].Disabled || (hideEmptySlot[i] && Items[i] == null);
|
||||
}
|
||||
|
||||
public virtual void Update(float deltaTime, Camera cam, bool subInventory = false)
|
||||
@@ -405,7 +410,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (HideSlot(i) || IsSlotHiddenDueToToggleState(i)) { continue; }
|
||||
if (HideSlot(i)) { continue; }
|
||||
UpdateSlot(slots[i], i, Items[i], subInventory);
|
||||
}
|
||||
if (!isSubInventory)
|
||||
@@ -557,7 +562,16 @@ namespace Barotrauma
|
||||
var slot = slots[slotIndex];
|
||||
int dir = slot.SubInventoryDir;
|
||||
Rectangle subRect = slot.Rect;
|
||||
Vector2 spacing = new Vector2(10 * UIScale, (10 * UIScale + EquipIndicator.size.Y));
|
||||
Vector2 spacing;
|
||||
|
||||
if (GUI.IsFourByThree())
|
||||
{
|
||||
spacing = new Vector2(5 * UIScale, (5 + UnequippedIndicator.size.Y) * UIScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
spacing = new Vector2(10 * UIScale, (10 + UnequippedIndicator.size.Y) * UIScale);
|
||||
}
|
||||
|
||||
int columns = (int)Math.Max(Math.Floor(Math.Sqrt(itemCapacity)), 1);
|
||||
while (itemCapacity / columns * (subRect.Height + spacing.Y) > GameMain.GraphicsHeight * 0.5f)
|
||||
@@ -653,24 +667,18 @@ namespace Barotrauma
|
||||
/// Is the mouse on any inventory element (slot, equip button, subinventory...)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsMouseOnInventory(bool ignoreDrag = false)
|
||||
public static bool IsMouseOnInventory()
|
||||
{
|
||||
if (Character.Controlled == null) return false;
|
||||
|
||||
if (!ignoreDrag && draggingItem != null || DraggingInventory != null) return true;
|
||||
if (draggingItem != null || DraggingInventory != null) return true;
|
||||
|
||||
if (Character.Controlled.Inventory != null)
|
||||
{
|
||||
var inv = Character.Controlled.Inventory;
|
||||
|
||||
if (inv.BackgroundFrame.Contains(PlayerInput.MousePosition) || inv.InventoryToggleContains) return true;
|
||||
|
||||
for (var i = 0; i < inv.slots.Length; i++)
|
||||
{
|
||||
var slot = inv.slots[i];
|
||||
|
||||
if (inv.HideSlot(i) || inv.IsSlotHiddenDueToToggleState(i)) continue;
|
||||
|
||||
if (slot.InteractRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
return true;
|
||||
@@ -743,11 +751,6 @@ namespace Barotrauma
|
||||
|
||||
if (inv == null) { return CursorState.Default; }
|
||||
|
||||
if (inv.InventoryToggleContains)
|
||||
{
|
||||
return CursorState.Hand;
|
||||
}
|
||||
|
||||
foreach (var item in inv.Items)
|
||||
{
|
||||
var container = item?.GetComponent<ItemContainer>();
|
||||
@@ -798,12 +801,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < inv.slots.Length; i++)
|
||||
foreach (var slot in inv.slots)
|
||||
{
|
||||
InventorySlot slot = inv.slots[i];
|
||||
|
||||
if (inv.IsSlotHiddenDueToToggleState(i)) continue;
|
||||
|
||||
if (slot.EquipButtonRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
return CursorState.Hand;
|
||||
@@ -820,7 +819,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CursorState.Default;
|
||||
}
|
||||
|
||||
@@ -931,20 +929,17 @@ namespace Barotrauma
|
||||
|
||||
if (selectedSlot == null)
|
||||
{
|
||||
if (!IsMouseOnInventory(true))
|
||||
if (DraggingItemToWorld &&
|
||||
Character.Controlled.FocusedItem?.OwnInventory != null &&
|
||||
Character.Controlled.FocusedItem.OwnInventory.CanBePut(draggingItem) &&
|
||||
Character.Controlled.FocusedItem.OwnInventory.TryPutItem(draggingItem, Character.Controlled))
|
||||
{
|
||||
if (DraggingItemToWorld &&
|
||||
Character.Controlled.FocusedItem?.OwnInventory != null &&
|
||||
Character.Controlled.FocusedItem.OwnInventory.CanBePut(draggingItem) &&
|
||||
Character.Controlled.FocusedItem.OwnInventory.TryPutItem(draggingItem, Character.Controlled))
|
||||
{
|
||||
GUI.PlayUISound(GUISoundType.PickItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.PlayUISound(GUISoundType.DropItem);
|
||||
draggingItem.Drop(Character.Controlled);
|
||||
}
|
||||
GUI.PlayUISound(GUISoundType.PickItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.PlayUISound(GUISoundType.DropItem);
|
||||
draggingItem.Drop(Character.Controlled);
|
||||
}
|
||||
}
|
||||
else if (selectedSlot.ParentInventory.Items[selectedSlot.SlotIndex] != draggingItem)
|
||||
@@ -1076,7 +1071,7 @@ namespace Barotrauma
|
||||
|
||||
bool mouseOnHealthInterface = CharacterHealth.OpenHealthWindow != null && CharacterHealth.OpenHealthWindow.MouseOnElement;
|
||||
|
||||
if ((GUI.MouseOn == null || mouseOnHealthInterface) && selectedSlot == null && !IsMouseOnInventory(true))
|
||||
if ((GUI.MouseOn == null || mouseOnHealthInterface) && selectedSlot == null)
|
||||
{
|
||||
var shadowSprite = GUI.Style.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0];
|
||||
string toolTip = mouseOnHealthInterface ? TextManager.Get("QuickUseAction.UseTreatment") :
|
||||
@@ -1101,7 +1096,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedSlot != null && selectedSlot.Item != null && selectedSlot.Slot.EquipButtonState != GUIComponent.ComponentState.Hover)
|
||||
if (selectedSlot != null && selectedSlot.Item != null)
|
||||
{
|
||||
Rectangle slotRect = selectedSlot.Slot.Rect;
|
||||
slotRect.Location += selectedSlot.Slot.DrawOffset.ToPoint();
|
||||
@@ -1136,30 +1131,15 @@ namespace Barotrauma
|
||||
{
|
||||
Sprite slotSprite = slot.SlotSprite ?? SlotSpriteSmall;
|
||||
|
||||
if (inventory != null && (CharacterInventory.PersonalSlots.HasFlag(type) || (inventory.isSubInventory && (inventory.Owner as Item) != null
|
||||
/*if (inventory != null && (CharacterInventory.PersonalSlots.HasFlag(type) || (inventory.isSubInventory && (inventory.Owner as Item) != null
|
||||
&& (inventory.Owner as Item).AllowedSlots.Any(a => CharacterInventory.PersonalSlots.HasFlag(a)))))
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
slotColor = slot.IsHighlighted ? GUIColorSettings.EquipmentSlotEmptyColor : GUIColorSettings.EquipmentSlotEmptyColor * 0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
slotColor = slot.IsHighlighted ? GUIColorSettings.EquipmentSlotColor : GUIColorSettings.EquipmentSlotColor * 0.8f;
|
||||
}
|
||||
|
||||
slotColor = slot.IsHighlighted ? GUIColorSettings.EquipmentSlotColor : GUIColorSettings.EquipmentSlotColor * 0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item != null && Character.Controlled != null && Character.Controlled.HasEquippedItem(item))
|
||||
{
|
||||
slotColor = slot.IsHighlighted ? GUIColorSettings.InventorySlotEquippedColor : GUIColorSettings.InventorySlotEquippedColor * 0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
slotColor = slot.IsHighlighted ? GUIColorSettings.InventorySlotColor : GUIColorSettings.InventorySlotColor * 0.8f;
|
||||
}
|
||||
}
|
||||
slotColor = slot.IsHighlighted ? GUIColorSettings.InventorySlotColor : GUIColorSettings.InventorySlotColor * 0.8f;
|
||||
}*/
|
||||
|
||||
if (inventory != null && inventory.Locked) { slotColor = Color.Gray * 0.5f; }
|
||||
spriteBatch.Draw(slotSprite.Texture, rect, slotSprite.SourceRect, slotColor);
|
||||
@@ -1183,7 +1163,7 @@ namespace Barotrauma
|
||||
canBePut = true;
|
||||
}
|
||||
}
|
||||
if (slot.MouseOn() && canBePut)
|
||||
if (slot.MouseOn() && canBePut && selectedSlot?.Slot == slot)
|
||||
{
|
||||
GUI.UIGlow.Draw(spriteBatch, rect, GUI.Style.Green);
|
||||
}
|
||||
@@ -1273,7 +1253,7 @@ namespace Barotrauma
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, rect, Color.White, false, 0, 1);
|
||||
GUI.DrawRectangle(spriteBatch, slot.EquipButtonRect, Color.Red, false, 0, 1);
|
||||
GUI.DrawRectangle(spriteBatch, slot.EquipButtonRect, Color.White, false, 0, 1);
|
||||
}
|
||||
|
||||
if (slot.HighlightColor != Color.Transparent)
|
||||
@@ -1284,11 +1264,8 @@ namespace Barotrauma
|
||||
if (item != null && drawItem)
|
||||
{
|
||||
Sprite sprite = item.Prefab.InventoryIcon ?? item.Sprite;
|
||||
|
||||
float equipButtonHeightAdjustment = inventory == Character.Controlled?.Inventory ? slot.EquipButtonRect.Height : 0;
|
||||
|
||||
float scale = Math.Min(Math.Min((rect.Width - 10) / sprite.size.X, (rect.Height - 5 - equipButtonHeightAdjustment) / sprite.size.Y), 2.0f);
|
||||
Vector2 itemPos = rect.Center.ToVector2() + new Vector2(0, equipButtonHeightAdjustment / 2f);
|
||||
float scale = Math.Min(Math.Min((rect.Width - 10) / sprite.size.X, (rect.Height - 10) / sprite.size.Y), 2.0f);
|
||||
Vector2 itemPos = rect.Center.ToVector2();
|
||||
if (itemPos.Y > GameMain.GraphicsHeight)
|
||||
{
|
||||
itemPos.Y -= Math.Min(
|
||||
@@ -1314,6 +1291,15 @@ namespace Barotrauma
|
||||
}
|
||||
sprite.Draw(spriteBatch, itemPos, spriteColor, rotation, scale);
|
||||
}
|
||||
|
||||
if (inventory != null &&
|
||||
!inventory.Locked &&
|
||||
Character.Controlled?.Inventory == inventory &&
|
||||
slot.QuickUseKey != Keys.None)
|
||||
{
|
||||
spriteBatch.Draw(slotHotkeySprite.Texture, rect.ScaleSize(1.15f), slotHotkeySprite.SourceRect, slotColor);
|
||||
GUI.DrawString(spriteBatch, rect.Location.ToVector2() + new Vector2((int)(4 * UIScale), (int)(-1.25f * UIScale)), slot.QuickUseKey.ToString().Substring(1, 1), Color.Black, font: GUI.SmallFont);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
|
||||
|
||||
@@ -708,6 +708,8 @@ namespace Barotrauma
|
||||
foreach (ItemComponent ic in activeHUDs)
|
||||
{
|
||||
if (ic.GuiFrame == null || ic.AllowUIOverlap || ic.GetLinkUIToComponent() != null) { continue; }
|
||||
//if the frame covers nearly all of the screen, don't trying to prevent overlaps because it'd fail anyway
|
||||
if (ic.GuiFrame.Rect.Width >= GameMain.GraphicsWidth * 0.9f && ic.GuiFrame.Rect.Height >= GameMain.GraphicsHeight * 0.9f) { continue; }
|
||||
ic.GuiFrame.RectTransform.ScreenSpaceOffset = Point.Zero;
|
||||
elementsToMove.Add(ic.GuiFrame);
|
||||
debugInitialHudPositions.Add(ic.GuiFrame.Rect);
|
||||
@@ -779,10 +781,10 @@ namespace Barotrauma
|
||||
foreach (ItemComponent ic in activeComponents)
|
||||
{
|
||||
if (ic.HudPriority > 0 && ic.ShouldDrawHUD(character) &&
|
||||
(ic.CanBeSelected || character.HasEquippedItem(this)) &&
|
||||
(ic.CanBeSelected || (character.HasEquippedItem(this) && ic.DrawHudWhenEquipped)) &&
|
||||
(maxPriorityHUDs.Count == 0 || ic.HudPriority >= maxPriorityHUDs[0].HudPriority))
|
||||
{
|
||||
if (maxPriorityHUDs.Count > 0 && ic.HudPriority > maxPriorityHUDs[0].HudPriority) maxPriorityHUDs.Clear();
|
||||
if (maxPriorityHUDs.Count > 0 && ic.HudPriority > maxPriorityHUDs[0].HudPriority) { maxPriorityHUDs.Clear(); }
|
||||
maxPriorityHUDs.Add(ic);
|
||||
}
|
||||
}
|
||||
@@ -795,7 +797,8 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (ItemComponent ic in activeComponents)
|
||||
{
|
||||
if ((ic.CanBeSelected || character.HasEquippedItem(this)) && ic.ShouldDrawHUD(character))
|
||||
if (ic.ShouldDrawHUD(character) &&
|
||||
(ic.CanBeSelected || (character.HasEquippedItem(this) && ic.DrawHudWhenEquipped)))
|
||||
{
|
||||
activeHUDs.Add(ic);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,6 @@ namespace Barotrauma
|
||||
{
|
||||
base.ControlInput(cam);
|
||||
cam.OffsetAmount = 0;
|
||||
|
||||
if (Character.Controlled?.Inventory != null)
|
||||
{
|
||||
Character.Controlled.Inventory.ToggleInventory(true);
|
||||
}
|
||||
|
||||
//if this is used, we need to implement syncing this inventory with the server
|
||||
/*Character.DisableControls = true;
|
||||
if (Character.Controlled != null)
|
||||
@@ -25,7 +19,7 @@ namespace Barotrauma
|
||||
{
|
||||
Character.Controlled.SelectedConstruction = null;
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
|
||||
protected override void CalculateBackgroundFrame()
|
||||
|
||||
Reference in New Issue
Block a user