make filled inventory slots blank (#27150)

* blank filled slots

* Update InventoryTemplatePrototype.cs
This commit is contained in:
Nemanja
2024-04-19 23:17:29 -04:00
committed by GitHub
parent ef7f0b8322
commit e5a5196b1f
18 changed files with 73 additions and 13 deletions

View File

@@ -251,6 +251,7 @@ namespace Content.Client.Inventory
public string SlotGroup => SlotDef.SlotGroup;
public string SlotDisplayName => SlotDef.DisplayName;
public string TextureName => "Slots/" + SlotDef.TextureName;
public string FullTextureName => SlotDef.FullTextureName;
public SlotData(SlotDefinition slotDef, ContainerSlot? container = null, bool highlighted = false,
bool blocked = false)

View File

@@ -219,7 +219,7 @@ namespace Content.Client.Inventory
if (entity == null)
{
button.SpriteView.SetEntity(null);
button.SetEntity(null);
return;
}
@@ -231,7 +231,7 @@ namespace Content.Client.Inventory
else
return;
button.SpriteView.SetEntity(viewEnt);
button.SetEntity(viewEnt);
}
}
}

View File

@@ -9,6 +9,7 @@ namespace Content.Client.UserInterface.Controls
public SlotButton(SlotData slotData)
{
ButtonTexturePath = slotData.TextureName;
FullButtonTexturePath = slotData.FullTextureName;
Blocked = slotData.Blocked;
Highlight = slotData.Highlighted;
StorageTexturePath = "Slots/back";

View File

@@ -15,11 +15,12 @@ namespace Content.Client.UserInterface.Controls
public TextureRect ButtonRect { get; }
public TextureRect BlockedRect { get; }
public TextureRect HighlightRect { get; }
public SpriteView SpriteView { get; }
public SpriteView HoverSpriteView { get; }
public TextureButton StorageButton { get; }
public CooldownGraphic CooldownDisplay { get; }
private SpriteView SpriteView { get; }
public EntityUid? Entity => SpriteView.Entity;
private bool _slotNameSet;
@@ -68,7 +69,18 @@ namespace Content.Client.UserInterface.Controls
set
{
_buttonTexturePath = value;
ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
UpdateButtonTexture();
}
}
private string? _fullButtonTexturePath;
public string? FullButtonTexturePath
{
get => _fullButtonTexturePath;
set
{
_fullButtonTexturePath = value;
UpdateButtonTexture();
}
}
@@ -197,6 +209,21 @@ namespace Content.Client.UserInterface.Controls
HoverSpriteView.SetEntity(null);
}
public void SetEntity(EntityUid? ent)
{
SpriteView.SetEntity(ent);
UpdateButtonTexture();
}
private void UpdateButtonTexture()
{
var fullTexture = Theme.ResolveTextureOrNull(_fullButtonTexturePath);
var texture = Entity.HasValue && fullTexture != null
? fullTexture.Texture
: Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
ButtonRect.Texture = texture;
}
private void OnButtonPressed(GUIBoundKeyEventArgs args)
{
Pressed?.Invoke(args, this);
@@ -229,8 +256,8 @@ namespace Content.Client.UserInterface.Controls
base.OnThemeUpdated();
StorageButton.TextureNormal = Theme.ResolveTextureOrNull(_storageTexturePath)?.Texture;
ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
HighlightRect.Texture = Theme.ResolveTextureOrNull(_highlightTexturePath)?.Texture;
UpdateButtonTexture();
}
EntityUid? IEntityControl.UiEntity => Entity;

View File

@@ -120,12 +120,12 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
if (_entities.TryGetComponent(hand.HeldEntity, out VirtualItemComponent? virt))
{
handButton.SpriteView.SetEntity(virt.BlockingEntity);
handButton.SetEntity(virt.BlockingEntity);
handButton.Blocked = true;
}
else
{
handButton.SpriteView.SetEntity(hand.HeldEntity);
handButton.SetEntity(hand.HeldEntity);
handButton.Blocked = false;
}
}
@@ -171,12 +171,12 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
if (_entities.TryGetComponent(entity, out VirtualItemComponent? virt))
{
hand.SpriteView.SetEntity(virt.BlockingEntity);
hand.SetEntity(virt.BlockingEntity);
hand.Blocked = true;
}
else
{
hand.SpriteView.SetEntity(entity);
hand.SetEntity(entity);
hand.Blocked = false;
}
@@ -190,7 +190,7 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
if (hand == null)
return;
hand.SpriteView.SetEntity(null);
hand.SetEntity(null);
if (_playerHandsComponent?.ActiveHand?.Name == name)
HandsGui?.UpdatePanelEntity(null);
}

View File

@@ -417,7 +417,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
if (_strippingWindow?.InventoryButtons.GetButton(update.Name) is { } inventoryButton)
{
inventoryButton.SpriteView.SetEntity(entity);
inventoryButton.SetEntity(entity);
inventoryButton.StorageButton.Visible = showStorage;
}
@@ -426,12 +426,12 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
if (_entities.TryGetComponent(entity, out VirtualItemComponent? virtb))
{
button.SpriteView.SetEntity(virtb.BlockingEntity);
button.SetEntity(virtb.BlockingEntity);
button.Blocked = true;
}
else
{
button.SpriteView.SetEntity(entity);
button.SetEntity(entity);
button.Blocked = false;
button.StorageButton.Visible = showStorage;
}

View File

@@ -17,6 +17,10 @@ public sealed partial class SlotDefinition
{
[DataField("name", required: true)] public string Name { get; private set; } = string.Empty;
[DataField("slotTexture")] public string TextureName { get; private set; } = "pocket";
/// <summary>
/// The texture displayed in a slot when it has an item inside of it.
/// </summary>
[DataField] public string FullTextureName { get; private set; } = "SlotBackground";
[DataField("slotFlags")] public SlotFlags SlotFlags { get; private set; } = SlotFlags.PREVENTEQUIP;
[DataField("showInWindow")] public bool ShowInWindow { get; private set; } = true;
[DataField("slotGroup")] public string SlotGroup { get; private set; } = "Default";

View File

@@ -11,6 +11,7 @@
displayName: ID
- name: id
slotTexture: id
fullTextureName: template_small
slotFlags: IDCARD
slotGroup: SecondHotbar
stripTime: 6

View File

@@ -55,6 +55,7 @@
displayName: Head
- name: id
slotTexture: id
fullTextureName: template_small
slotFlags: IDCARD
slotGroup: SecondHotbar
stripTime: 6
@@ -64,6 +65,7 @@
displayName: ID
- name: belt
slotTexture: belt
fullTextureName: template_small
slotFlags: BELT
slotGroup: SecondHotbar
stripTime: 6
@@ -72,6 +74,7 @@
displayName: Belt
- name: back
slotTexture: back
fullTextureName: template_small
slotFlags: BACK
slotGroup: SecondHotbar
stripTime: 6
@@ -81,6 +84,7 @@
- name: pocket4
slotTexture: web
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -89,6 +93,7 @@
displayName: Pocket 4
- name: pocket3
slotTexture: web
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -104,6 +109,7 @@
displayName: Suit
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -114,6 +120,7 @@
stripHidden: true
- name: pocket2
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3

View File

@@ -55,6 +55,7 @@
displayName: Head
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -65,6 +66,7 @@
stripHidden: true
- name: pocket2
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -84,6 +86,7 @@
displayName: Suit Storage
- name: belt
slotTexture: belt
fullTextureName: template_small
slotFlags: BELT
slotGroup: SecondHotbar
stripTime: 6

View File

@@ -56,6 +56,7 @@
displayName: Head
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -66,6 +67,7 @@
stripHidden: true
- name: pocket2
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -85,6 +87,7 @@
displayName: Suit Storage
- name: id
slotTexture: id
fullTextureName: template_small
slotFlags: IDCARD
slotGroup: SecondHotbar
stripTime: 6
@@ -94,6 +97,7 @@
displayName: ID
- name: belt
slotTexture: belt
fullTextureName: template_small
slotFlags: BELT
slotGroup: SecondHotbar
stripTime: 6
@@ -102,6 +106,7 @@
displayName: Belt
- name: back
slotTexture: back
fullTextureName: template_small
slotFlags: BACK
slotGroup: SecondHotbar
stripTime: 6

View File

@@ -3,6 +3,7 @@
slots:
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -12,6 +13,7 @@
stripHidden: true
- name: pocket2
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3

View File

@@ -62,6 +62,7 @@
displayName: Head
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -72,6 +73,7 @@
stripHidden: true
- name: pocket2
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -91,6 +93,7 @@
displayName: Suit Storage
- name: id
slotTexture: id
fullTextureName: template_small
slotFlags: IDCARD
slotGroup: SecondHotbar
stripTime: 6
@@ -100,6 +103,7 @@
displayName: ID
- name: belt
slotTexture: belt
fullTextureName: template_small
slotFlags: BELT
slotGroup: SecondHotbar
stripTime: 6
@@ -108,6 +112,7 @@
displayName: Belt
- name: back
slotTexture: back
fullTextureName: template_small
slotFlags: BACK
slotGroup: SecondHotbar
stripTime: 6

View File

@@ -35,6 +35,7 @@
- name: belt
slotTexture: belt
fullTextureName: template_small
slotFlags: BELT
slotGroup: SecondHotbar
stripTime: 6
@@ -47,6 +48,7 @@
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3
@@ -60,6 +62,7 @@
slots:
- name: pocket1
slotTexture: pocket
fullTextureName: template_small
slotFlags: POCKET
slotGroup: MainHotbar
stripTime: 3

View File

@@ -29,6 +29,7 @@
displayName: Jumpsuit
- name: id
slotTexture: id
fullTextureName: template_small
slotFlags: IDCARD
slotGroup: SecondHotbar
stripTime: 6

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B