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

@@ -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;
}