Merge branch 'master' into new-netcode
Conflicts: Subsurface/Source/Items/CharacterInventory.cs Subsurface/Source/Items/Inventory.cs Subsurface/Source/Items/Item.cs
This commit is contained in:
Binary file not shown.
@@ -264,10 +264,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.Draw(t, new Rectangle(rect.X, rect.Y, rect.Width, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
sb.Draw(t, new Rectangle(rect.X + thickness, rect.Y, rect.Width - thickness * 2, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
||||||
sb.Draw(t, new Rectangle(rect.X, rect.Y+rect.Height- thickness, rect.Width, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
sb.Draw(t, new Rectangle(rect.X + thickness, rect.Y + rect.Height - thickness, rect.Width - thickness * 2, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
||||||
|
|
||||||
sb.Draw(t, new Rectangle(rect.X, rect.Y, thickness, rect.Height), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
sb.Draw(t, new Rectangle(rect.X, rect.Y, thickness, rect.Height), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
||||||
sb.Draw(t, new Rectangle(rect.X+rect.Width- thickness, rect.Y, thickness, rect.Height), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
sb.Draw(t, new Rectangle(rect.X + rect.Width - thickness, rect.Y, thickness, rect.Height), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ namespace Barotrauma
|
|||||||
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i]!=null && Items[i]!=item)
|
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i]!=null && Items[i]!=item)
|
||||||
{
|
{
|
||||||
free = false;
|
free = false;
|
||||||
break;
|
if (slots != null) slots[i].ShowBorderHighlight(Color.Red, 0.1f, 0.9f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +238,6 @@ namespace Barotrauma
|
|||||||
TryPutItem(item, currentIndex, false);
|
TryPutItem(item, currentIndex, false);
|
||||||
TryPutItem(existingItem, index, false);
|
TryPutItem(existingItem, index, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return combined;
|
return combined;
|
||||||
@@ -292,17 +291,21 @@ namespace Barotrauma
|
|||||||
|
|
||||||
protected override void CreateSlots()
|
protected override void CreateSlots()
|
||||||
{
|
{
|
||||||
slots = new InventorySlot[capacity];
|
if (slots == null) slots = new InventorySlot[capacity];
|
||||||
|
|
||||||
int rectWidth = 40, rectHeight = 40;
|
int rectWidth = 40, rectHeight = 40;
|
||||||
|
|
||||||
Rectangle slotRect = new Rectangle(0, 0, rectWidth, rectHeight);
|
Rectangle slotRect = new Rectangle(0, 0, rectWidth, rectHeight);
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
|
if (slots[i] == null) slots[i] = new InventorySlot(slotRect);
|
||||||
|
|
||||||
|
slots[i].Disabled = false;
|
||||||
|
|
||||||
slotRect.X = (int)(SlotPositions[i].X + DrawOffset.X);
|
slotRect.X = (int)(SlotPositions[i].X + DrawOffset.X);
|
||||||
slotRect.Y = (int)(SlotPositions[i].Y + DrawOffset.Y);
|
slotRect.Y = (int)(SlotPositions[i].Y + DrawOffset.Y);
|
||||||
|
|
||||||
slots[i] = new InventorySlot(slotRect);
|
slots[i].Rect = slotRect;
|
||||||
|
|
||||||
slots[i].Color = limbSlots[i] == InvSlotType.Any ? Color.White * 0.2f : Color.White * 0.4f;
|
slots[i].Color = limbSlots[i] == InvSlotType.Any ? Color.White * 0.2f : Color.White * 0.4f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,7 +378,12 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
base.RemoveComponentSpecific();
|
base.RemoveComponentSpecific();
|
||||||
|
|
||||||
GameMain.World.RemoveBody(body.FarseerBody);
|
if (body != null)
|
||||||
|
{
|
||||||
|
body.Remove();
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (linkedGap!=null) linkedGap.Remove();
|
if (linkedGap!=null) linkedGap.Remove();
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Color Color;
|
public Color Color;
|
||||||
|
|
||||||
|
public Color BorderHighlightColor;
|
||||||
|
private CoroutineHandle BorderHighlightCoroutine;
|
||||||
|
|
||||||
public InventorySlot(Rectangle rect)
|
public InventorySlot(Rectangle rect)
|
||||||
{
|
{
|
||||||
Rect = rect;
|
Rect = rect;
|
||||||
@@ -36,6 +39,33 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Color = Color.White * 0.4f;
|
Color = Color.White * 0.4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowBorderHighlight(Color color, float fadeInDuration, float fadeOutDuration)
|
||||||
|
{
|
||||||
|
if (BorderHighlightCoroutine != null)
|
||||||
|
{
|
||||||
|
BorderHighlightCoroutine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
BorderHighlightCoroutine = CoroutineManager.StartCoroutine(UpdateBorderHighlight(color, fadeInDuration, fadeOutDuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<object> UpdateBorderHighlight(Color color, float fadeInDuration, float fadeOutDuration)
|
||||||
|
{
|
||||||
|
float t = 0.0f;
|
||||||
|
while (t < fadeInDuration + fadeOutDuration)
|
||||||
|
{
|
||||||
|
BorderHighlightColor = (t < fadeInDuration) ?
|
||||||
|
Color.Lerp(Color.Transparent, color, t / fadeInDuration) :
|
||||||
|
Color.Lerp(color, Color.Transparent, (t - fadeInDuration) / fadeOutDuration);
|
||||||
|
|
||||||
|
t += CoroutineManager.DeltaTime;
|
||||||
|
|
||||||
|
yield return CoroutineStatus.Running;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return CoroutineStatus.Success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Inventory
|
class Inventory
|
||||||
@@ -163,6 +193,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (slots != null) slots[i].ShowBorderHighlight(Color.Red, 0.1f, 0.9f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,6 +210,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Items[i] = item;
|
Items[i] = item;
|
||||||
item.ParentInventory = this;
|
item.ParentInventory = this;
|
||||||
|
|
||||||
|
if (slots != null) slots[i].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
|
||||||
|
|
||||||
if (item.body != null)
|
if (item.body != null)
|
||||||
{
|
{
|
||||||
item.body.Enabled = false;
|
item.body.Enabled = false;
|
||||||
@@ -321,7 +355,7 @@ namespace Barotrauma
|
|||||||
Vector2 rectSize = textSize * 1.2f;
|
Vector2 rectSize = textSize * 1.2f;
|
||||||
|
|
||||||
Vector2 pos = new Vector2(highlightedSlot.Right, highlightedSlot.Y-rectSize.Y);
|
Vector2 pos = new Vector2(highlightedSlot.Right, highlightedSlot.Y-rectSize.Y);
|
||||||
pos.X = (int)pos.X;
|
pos.X = (int)(pos.X + 3);
|
||||||
pos.Y = (int)pos.Y;
|
pos.Y = (int)pos.Y;
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, pos, rectSize, Color.Black * 0.8f, true);
|
GUI.DrawRectangle(spriteBatch, pos, rectSize, Color.Black * 0.8f, true);
|
||||||
@@ -368,10 +402,20 @@ namespace Barotrauma
|
|||||||
doubleClickedItem = item;
|
doubleClickedItem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//selectedSlot = slotIndex;
|
if (draggingItem != Items[slotIndex])
|
||||||
TryPutItem(draggingItem, slotIndex, true);
|
{
|
||||||
draggingItem = null;
|
//selectedSlot = slotIndex;
|
||||||
draggingSlot = null;
|
if (TryPutItem(draggingItem, slotIndex, true))
|
||||||
|
{
|
||||||
|
if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.Red, 0.1f, 0.9f);
|
||||||
|
}
|
||||||
|
draggingItem = null;
|
||||||
|
draggingSlot = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,6 +513,14 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, rect, (slot.IsHighlighted ? Color.Red * 0.4f : slot.Color), false);
|
GUI.DrawRectangle(spriteBatch, rect, (slot.IsHighlighted ? Color.Red * 0.4f : slot.Color), false);
|
||||||
|
|
||||||
|
if (slot.BorderHighlightColor != Color.Transparent)
|
||||||
|
{
|
||||||
|
Rectangle highlightRect = slot.Rect;
|
||||||
|
highlightRect.Inflate(3,3);
|
||||||
|
|
||||||
|
GUI.DrawRectangle(spriteBatch, highlightRect, slot.BorderHighlightColor, false, 0, 5);
|
||||||
|
}
|
||||||
|
|
||||||
if (item == null || !drawItem) return;
|
if (item == null || !drawItem) return;
|
||||||
|
|
||||||
item.Sprite.Draw(spriteBatch, new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), item.Color);
|
item.Sprite.Draw(spriteBatch, new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), item.Color);
|
||||||
|
|||||||
@@ -1770,14 +1770,17 @@ namespace Barotrauma
|
|||||||
int index = components.IndexOf(ic);
|
int index = components.IndexOf(ic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Remove()
|
public override void Remove()
|
||||||
{
|
{
|
||||||
base.Remove();
|
base.Remove();
|
||||||
|
|
||||||
Removed = true;
|
Removed = true;
|
||||||
|
|
||||||
//sprite.Remove();
|
if (parentInventory != null)
|
||||||
//if (body != null) body.Remove();
|
{
|
||||||
|
parentInventory.RemoveItem(this);
|
||||||
|
parentInventory = null;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (ItemComponent ic in components)
|
foreach (ItemComponent ic in components)
|
||||||
{
|
{
|
||||||
@@ -1785,6 +1788,12 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
ItemList.Remove(this);
|
ItemList.Remove(this);
|
||||||
|
|
||||||
|
if (body != null)
|
||||||
|
{
|
||||||
|
body.Remove();
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Item it in ItemList)
|
foreach (Item it in ItemList)
|
||||||
{
|
{
|
||||||
if (it.linkedTo.Contains(this))
|
if (it.linkedTo.Contains(this))
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user