THE RETURN OF ITEM STATUS (#22986)

* 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>
This commit is contained in:
Pieter-Jan Briers
2024-04-21 15:16:23 +02:00
committed by GitHub
parent ee4ef4b96a
commit 58f025ba80
62 changed files with 582 additions and 585 deletions

View File

@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Client.Items;
using Content.Client.Resources;
using Content.Shared.Hands.Components;
@@ -5,6 +6,7 @@ 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;
@@ -14,12 +16,15 @@ using static Content.Client.IoC.StaticIoC;
namespace Content.Client.UserInterface.Systems.Inventory.Controls;
[GenerateTypedNameReferences]
public sealed partial class ItemStatusPanel : BoxContainer
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);
@@ -30,41 +35,65 @@ public sealed partial class ItemStatusPanel : BoxContainer
public void SetSide(HandLocation location)
{
string texture;
// 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;
Label.AlignMode textAlign;
Thickness contentMargin;
switch (location)
{
case HandLocation.Left:
texture = "/Textures/Interface/Nano/item_status_right.svg.96dpi.png";
cutOut = StyleBox.Margin.Left | StyleBox.Margin.Top;
flat = StyleBox.Margin.Right | StyleBox.Margin.Bottom;
textAlign = Label.AlignMode.Right;
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:
texture = "/Textures/Interface/Nano/item_status_middle.svg.96dpi.png";
cutOut = StyleBox.Margin.Right | StyleBox.Margin.Top;
flat = StyleBox.Margin.Left | StyleBox.Margin.Bottom;
textAlign = Label.AlignMode.Left;
break;
case HandLocation.Right:
texture = "/Textures/Interface/Nano/item_status_left.svg.96dpi.png";
cutOut = StyleBox.Margin.Right | StyleBox.Margin.Top;
flat = StyleBox.Margin.Left | StyleBox.Margin.Bottom;
textAlign = Label.AlignMode.Left;
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);
}
var panel = (StyleBoxTexture) Panel.PanelOverride!;
panel.Texture = ResC.GetTexture(texture);
panel.SetPatchMargin(flat, 2);
panel.SetPatchMargin(cutOut, 13);
Contents.Margin = contentMargin;
ItemNameLabel.Align = textAlign;
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)
@@ -79,7 +108,7 @@ public sealed partial class ItemStatusPanel : BoxContainer
{
ClearOldStatus();
_entity = null;
Panel.Visible = false;
VisWrapper.Visible = false;
return;
}
@@ -91,7 +120,12 @@ public sealed partial class ItemStatusPanel : BoxContainer
UpdateItemName();
}
Panel.Visible = true;
VisWrapper.Visible = true;
}
public void UpdateHighlight(bool highlight)
{
HighlightPanel.Visible = highlight;
}
private void UpdateItemName()