Job icons are stored on ID cards (#18233)
This commit is contained in:
@@ -3,7 +3,9 @@ using System.Numerics;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.CrewManifest;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.StatusIcon;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
@@ -100,8 +102,15 @@ public sealed partial class CrewManifestUi : DefaultWindow
|
||||
|
||||
private sealed class CrewManifestSection : BoxContainer
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||
private readonly SpriteSystem _spriteSystem = default!;
|
||||
|
||||
public CrewManifestSection(string sectionTitle, List<CrewManifestEntry> entries, IResourceCache cache, CrewManifestSystem crewManifestSystem)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_spriteSystem = _entitySystem.GetEntitySystem<SpriteSystem>();
|
||||
|
||||
Orientation = LayoutOrientation.Vertical;
|
||||
HorizontalExpand = true;
|
||||
|
||||
@@ -122,9 +131,6 @@ public sealed partial class CrewManifestUi : DefaultWindow
|
||||
|
||||
AddChild(gridContainer);
|
||||
|
||||
var path = new ResPath("/Textures/Interface/Misc/job_icons.rsi");
|
||||
cache.TryGetResource(path, out RSIResource? rsi);
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var name = new RichTextLabel()
|
||||
@@ -143,25 +149,15 @@ public sealed partial class CrewManifestUi : DefaultWindow
|
||||
title.SetMessage(entry.JobTitle);
|
||||
|
||||
|
||||
if (rsi != null)
|
||||
if (_prototypeManager.TryIndex<StatusIconPrototype>(entry.JobIcon, out var jobIcon))
|
||||
{
|
||||
var icon = new TextureRect()
|
||||
{
|
||||
TextureScale = new Vector2(2, 2),
|
||||
Stretch = TextureRect.StretchMode.KeepCentered
|
||||
Stretch = TextureRect.StretchMode.KeepCentered,
|
||||
Texture = _spriteSystem.Frame0(jobIcon.Icon),
|
||||
};
|
||||
|
||||
if (rsi.RSI.TryGetState(entry.JobIcon, out _))
|
||||
{
|
||||
var specifier = new SpriteSpecifier.Rsi(path, entry.JobIcon);
|
||||
icon.Texture = specifier.Frame0();
|
||||
}
|
||||
else if (rsi.RSI.TryGetState("Unknown", out _))
|
||||
{
|
||||
var specifier = new SpriteSpecifier.Rsi(path, "Unknown");
|
||||
icon.Texture = specifier.Frame0();
|
||||
}
|
||||
|
||||
titleContainer.AddChild(icon);
|
||||
titleContainer.AddChild(title);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user