Remove usages of obsolete SpriteView.Sprite.set() (#19500)

This commit is contained in:
Visne
2023-08-25 03:16:46 +02:00
committed by GitHub
parent 3c667b6f7e
commit 11a57be230
20 changed files with 72 additions and 95 deletions

View File

@@ -195,7 +195,7 @@ namespace Content.Client.UserInterface.Controls
IoCManager.Resolve<IEntityManager>().DeleteEntity(tempQualifier.Owner);
}
HoverSpriteView.Sprite = null;
HoverSpriteView.SetEntity(null);
}
private void OnButtonPressed(GUIBoundKeyEventArgs args)

View File

@@ -203,13 +203,12 @@ public sealed class ActionButton : Control
return;
}
if (Action?.EntityIcon == null ||
!entityManager.TryGetComponent(Action.EntityIcon.Value, out SpriteComponent? sprite))
if (Action?.EntityIcon is not { } entity || !entityManager.HasComponent<SpriteComponent>(entity))
{
_bigItemSpriteView.Visible = false;
_bigItemSpriteView.Sprite = null;
_bigItemSpriteView.SetEntity(null);
_smallItemSpriteView.Visible = false;
_smallItemSpriteView.Sprite = null;
_smallItemSpriteView.SetEntity(null);
}
else
{
@@ -217,24 +216,21 @@ public sealed class ActionButton : Control
{
case ItemActionIconStyle.BigItem:
_bigItemSpriteView.Visible = true;
_bigItemSpriteView.Sprite = sprite;
_bigItemSpriteView.SetEntity(entity);
_smallItemSpriteView.Visible = false;
_smallItemSpriteView.Sprite = null;
_smallItemSpriteView.SetEntity(null);
break;
case ItemActionIconStyle.BigAction:
_bigItemSpriteView.Visible = false;
_bigItemSpriteView.Sprite = null;
_bigItemSpriteView.SetEntity(null);
_smallItemSpriteView.Visible = true;
_smallItemSpriteView.Sprite = sprite;
_smallItemSpriteView.SetEntity(entity);
break;
case ItemActionIconStyle.NoItem:
_bigItemSpriteView.Visible = false;
_bigItemSpriteView.Sprite = null;
_bigItemSpriteView.SetEntity(null);
_smallItemSpriteView.Visible = false;
_smallItemSpriteView.Sprite = null;
_smallItemSpriteView.SetEntity(null);
break;
}
}

View File

@@ -101,7 +101,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
return;
}
var (job, objectives, briefing, sprite, entityName) = data;
var (entity, job, objectives, briefing, entityName) = data;
_window.SubText.Text = job;
_window.Objectives.RemoveAllChildren();
@@ -143,7 +143,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
_window.Objectives.AddChild(objectiveControl);
}
_window.SpriteView.Sprite = sprite;
_window.SpriteView.SetEntity(entity);
_window.NameLabel.Text = entityName;
}

View File

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

View File

@@ -125,9 +125,8 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
container.AddButton(button);
}
var sprite = _entities.GetComponentOrNull<SpriteComponent>(data.HeldEntity);
var showStorage = _entities.HasComponent<ClientStorageComponent>(data.HeldEntity);
var update = new SlotSpriteUpdate(data.SlotGroup, data.SlotName, sprite, showStorage);
var update = new SlotSpriteUpdate(data.HeldEntity, data.SlotGroup, data.SlotName, showStorage);
SpriteUpdated(update);
}
}
@@ -151,9 +150,8 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
_strippingWindow!.InventoryButtons.AddButton(button, data.ButtonOffset);
}
var sprite = _entities.GetComponentOrNull<SpriteComponent>(data.HeldEntity);
var showStorage = _entities.HasComponent<ClientStorageComponent>(data.HeldEntity);
var update = new SlotSpriteUpdate(data.SlotGroup, data.SlotName, sprite, showStorage);
var update = new SlotSpriteUpdate(data.HeldEntity, data.SlotGroup, data.SlotName, showStorage);
SpriteUpdated(update);
}
}
@@ -288,7 +286,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
hoverSprite.CopyFrom(sprite);
hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127);
control.HoverSpriteView.Sprite = hoverSprite;
control.HoverSpriteView.SetEntity(hoverEntity);
}
private void AddSlot(SlotData data)
@@ -338,18 +336,18 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
private void SpriteUpdated(SlotSpriteUpdate update)
{
var (group, name, sprite, showStorage) = update;
var (entity, group, name, showStorage) = update;
if (_strippingWindow?.InventoryButtons.GetButton(update.Name) is { } inventoryButton)
{
inventoryButton.SpriteView.Sprite = sprite;
inventoryButton.SpriteView.SetEntity(entity);
inventoryButton.StorageButton.Visible = showStorage;
}
if (_slotGroups.GetValueOrDefault(group)?.GetButton(name) is not { } button)
return;
button.SpriteView.Sprite = sprite;
button.SpriteView.SetEntity(entity);
button.StorageButton.Visible = showStorage;
}