* THE RETURN OF ITEM STATUS Item status is now inline with the hands again. You can now see item status for both hands at once. If you have more than 2 hands, the last active hand of that side is displayed in the respective item status. The item status for the active hand is also highlighted. Item status has been given a new look so it looks unique and matches every UI theme. * Shrink item status to 125px This is going to require fixing the existing controls. Do that later. * New bullet item status rendering sex * Make gun item status look just a little bit nicer. Avoid only one or two bullets ending up on a single row of an item status. * Delete Eris theme files * More improvements Fixed the fact that left/right were flipped around when assigning status panel locations. Involved renaming all the UI textures. Redid how content margins are set from the theme. Less complex and cleaner now. Made the item name always left-aligned, just looks better since other UI elements don't adapt anyways. * Compact down item status text Now it fits 3 lines of text on one line. Yay. This is achieved by compacting RichTextLabels by reducing their line height and giving them a negative bottom margin. * Add item status sprites for Ashen theme. * Add status control to show beaker/bucket/jug solution/transfer volumes Also PollingItemStatusControl I'll be using that more. * Fix welder item status, clean up welder code The item status control implementation was ancient and bad. That's why it was buggy. Removed all the complex dated networking stuff for welders, we just sync the solution contents now anyways so none of that is needed anymore. This moves a buncha stuff to shared and just removes code. Cleanup. The code was doing some really dumb stuff. * Spray bottles show contents in item status. * cowtools * Fix plasmafire and clockwork themes. Actual git gaslighting wtf. --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
174 lines
5.2 KiB
C#
174 lines
5.2 KiB
C#
using System.Numerics;
|
|
using Content.Client.Items;
|
|
using Content.Client.Resources;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Inventory.VirtualItem;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
using static Content.Client.IoC.StaticIoC;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Inventory.Controls;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class ItemStatusPanel : Control
|
|
{
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
[ViewVariables] private EntityUid? _entity;
|
|
|
|
// Tracked so we can re-run SetSide() if the theme changes.
|
|
private HandLocation _side;
|
|
|
|
public ItemStatusPanel()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
SetSide(HandLocation.Middle);
|
|
}
|
|
|
|
public void SetSide(HandLocation location)
|
|
{
|
|
// AN IMPORTANT REMINDER ABOUT THIS CODE:
|
|
// In the UI, the RIGHT hand is on the LEFT on the screen.
|
|
// So that a character facing DOWN matches the hand positions.
|
|
|
|
Texture? texture;
|
|
Texture? textureHighlight;
|
|
StyleBox.Margin cutOut;
|
|
StyleBox.Margin flat;
|
|
Thickness contentMargin;
|
|
|
|
switch (location)
|
|
{
|
|
case HandLocation.Right:
|
|
texture = Theme.ResolveTexture("item_status_right");
|
|
textureHighlight = Theme.ResolveTexture("item_status_right_highlight");
|
|
cutOut = StyleBox.Margin.Left;
|
|
flat = StyleBox.Margin.Right;
|
|
contentMargin = MarginFromThemeColor("_itemstatus_content_margin_right");
|
|
break;
|
|
case HandLocation.Middle:
|
|
case HandLocation.Left:
|
|
texture = Theme.ResolveTexture("item_status_left");
|
|
textureHighlight = Theme.ResolveTexture("item_status_left_highlight");
|
|
cutOut = StyleBox.Margin.Right;
|
|
flat = StyleBox.Margin.Left;
|
|
contentMargin = MarginFromThemeColor("_itemstatus_content_margin_left");
|
|
break;
|
|
default:
|
|
throw new ArgumentOutOfRangeException(nameof(location), location, null);
|
|
}
|
|
|
|
Contents.Margin = contentMargin;
|
|
|
|
var panel = (StyleBoxTexture) Panel.PanelOverride!;
|
|
panel.Texture = texture;
|
|
panel.SetPatchMargin(flat, 4);
|
|
panel.SetPatchMargin(cutOut, 7);
|
|
|
|
var panelHighlight = (StyleBoxTexture) HighlightPanel.PanelOverride!;
|
|
panelHighlight.Texture = textureHighlight;
|
|
panelHighlight.SetPatchMargin(flat, 4);
|
|
panelHighlight.SetPatchMargin(cutOut, 7);
|
|
|
|
_side = location;
|
|
}
|
|
|
|
private Thickness MarginFromThemeColor(string itemName)
|
|
{
|
|
// This is the worst thing I've ever programmed
|
|
// (can you tell I'm a graphics programmer?)
|
|
// (the margin needs to change depending on the UI theme, so we use a fake color entry to store the value)
|
|
|
|
var color = Theme.ResolveColorOrSpecified(itemName);
|
|
return new Thickness(color.RByte, color.GByte, color.BByte, color.AByte);
|
|
}
|
|
|
|
protected override void OnThemeUpdated()
|
|
{
|
|
SetSide(_side);
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
UpdateItemName();
|
|
}
|
|
|
|
public void Update(EntityUid? entity)
|
|
{
|
|
if (entity == null)
|
|
{
|
|
ClearOldStatus();
|
|
_entity = null;
|
|
VisWrapper.Visible = false;
|
|
return;
|
|
}
|
|
|
|
if (entity != _entity)
|
|
{
|
|
_entity = entity.Value;
|
|
BuildNewEntityStatus();
|
|
|
|
UpdateItemName();
|
|
}
|
|
|
|
VisWrapper.Visible = true;
|
|
}
|
|
|
|
public void UpdateHighlight(bool highlight)
|
|
{
|
|
HighlightPanel.Visible = highlight;
|
|
}
|
|
|
|
private void UpdateItemName()
|
|
{
|
|
if (_entity == null)
|
|
return;
|
|
|
|
if (!_entityManager.TryGetComponent<MetaDataComponent>(_entity, out var meta) || meta.Deleted)
|
|
{
|
|
Update(null);
|
|
return;
|
|
}
|
|
|
|
if (_entityManager.TryGetComponent(_entity, out VirtualItemComponent? virtualItem)
|
|
&& _entityManager.EntityExists(virtualItem.BlockingEntity))
|
|
{
|
|
// Uses identity because we can be blocked by pulling someone
|
|
ItemNameLabel.Text = Identity.Name(virtualItem.BlockingEntity, _entityManager);
|
|
}
|
|
else
|
|
{
|
|
ItemNameLabel.Text = Identity.Name(_entity.Value, _entityManager);
|
|
}
|
|
}
|
|
|
|
private void ClearOldStatus()
|
|
{
|
|
StatusContents.RemoveAllChildren();
|
|
}
|
|
|
|
private void BuildNewEntityStatus()
|
|
{
|
|
DebugTools.AssertNotNull(_entity);
|
|
|
|
ClearOldStatus();
|
|
|
|
var collectMsg = new ItemStatusCollectMessage();
|
|
_entityManager.EventBus.RaiseLocalEvent(_entity!.Value, collectMsg, true);
|
|
|
|
foreach (var control in collectMsg.Controls)
|
|
{
|
|
StatusContents.AddChild(control);
|
|
}
|
|
}
|
|
}
|