Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label Rendering For Vending Machines and Item Preferences Menus #1538

Merged
merged 19 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.Customization.Systems;
using Content.Shared.Labels.Components;
using Content.Shared.Paint;
using Content.Shared.Preferences;
using Content.Shared.Roles;
Expand Down Expand Up @@ -140,6 +141,15 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob,
Loc.GetString($"loadout-name-{loadout.ID}") == $"loadout-name-{loadout.ID}"
? entityManager.GetComponent<MetaDataComponent>(dummyLoadoutItem).EntityName
: Loc.GetString($"loadout-name-{loadout.ID}");

// Display the item's label if it's present
if (entityManager.TryGetComponent(dummyLoadoutItem, out LabelComponent? labelComponent))
{
var itemLabel = labelComponent.CurrentLabel;
if (!string.IsNullOrEmpty(itemLabel))
loadoutName += $" ({Loc.GetString(itemLabel)})";
}

var loadoutDesc =
!Loc.TryGetString($"loadout-description-{loadout.ID}", out var description)
? entityManager.GetComponent<MetaDataComponent>(dummyLoadoutItem).EntityDescription
Expand Down
15 changes: 15 additions & 0 deletions Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow;
using Content.Shared.Labels.Components;
using Content.Shared.Prototypes;
using System.Reflection.Emit;
using Content.Client.Labels;

namespace Content.Client.VendingMachines.UI
{
Expand Down Expand Up @@ -73,11 +77,21 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int>
vendingItem.Icon = null;

var itemName = entry.ID;

Texture? icon = null;
if (_prototypeManager.TryIndex<EntityPrototype>(entry.ID, out var prototype))
{
itemName = prototype.Name;
icon = spriteSystem.GetPrototypeIcon(prototype).Default;

const string labelCompName = "Label";
if (prototype.Components.TryGetValue(labelCompName, out var labelCompData)
&& labelCompData.Component is LabelComponent labelComponent)
{
var itemLabel = labelComponent.CurrentLabel;
if (!string.IsNullOrEmpty(itemLabel))
itemName += $" ({Loc.GetString(itemLabel)})";
}
}

// search filter
Expand All @@ -93,6 +107,7 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int>
longestEntry = itemName;

vendingItem.Text = $"{itemName} [{entry.Amount}]";

vendingItem.Icon = icon;
filteredInventory.Add(i);
}
Expand Down
55 changes: 25 additions & 30 deletions Resources/Prototypes/Entities/Objects/Specific/Medical/healing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@

# Pills
- type: entity
name: pill (dexalin 10u)
suffix: Dexalin 10u
parent: Pill
id: PillDexalin
components:
Expand All @@ -367,7 +367,6 @@


- type: entity
name: pill canister (dexalin 10u)
parent: PillCanister
id: PillCanisterDexalin
suffix: Dexalin, 7
Expand All @@ -380,7 +379,7 @@
amount: 7

- type: entity
name: pill (dylovene 10u)
suffix: Dylovene 10u
parent: Pill
id: PillDylovene
components:
Expand All @@ -399,7 +398,6 @@
Quantity: 10

- type: entity
name: pill canister (dylovene 10u)
parent: PillCanister
id: PillCanisterDylovene
suffix: Dylovene, 5
Expand All @@ -412,7 +410,7 @@
amount: 5

- type: entity
name: pill (hyronalin 10u)
suffix: Hyronalin 10u
parent: Pill
id: PillHyronalin
components:
Expand All @@ -431,7 +429,6 @@
Quantity: 10

- type: entity
name: pill canister (hyronalin 10u)
parent: PillCanister
id: PillCanisterHyronalin
suffix: Hyronalin, 5
Expand All @@ -444,7 +441,6 @@
amount: 5

- type: entity
name: pill
suffix: Potassium iodide 10u
parent: Pill
id: PillPotassiumIodide
Expand All @@ -464,10 +460,9 @@
Quantity: 10

- type: entity
name: pill canister
parent: PillCanister
id: PillCanisterPotassiumIodide
suffix: Potassium iodide 10u, 5
suffix: Potassium iodide, 5
components:
- type: Label
currentLabel: potassium iodide 10u
Expand All @@ -477,7 +472,6 @@
amount: 5

- type: entity
name: pill
suffix: Iron 10u
parent: Pill
id: PillIron
Expand All @@ -497,7 +491,7 @@
Quantity: 10

- type: entity
name: pill (copper 10u)
suffix: Copper 10u
parent: Pill
id: PillCopper
components:
Expand All @@ -516,7 +510,6 @@
Quantity: 10

- type: entity
name: pill canister (iron 10u)
parent: PillCanister
id: PillCanisterIron
suffix: Iron, 5
Expand All @@ -529,7 +522,6 @@
amount: 5

- type: entity
name: pill canister (copper 10u)
parent: PillCanister
id: PillCanisterCopper
suffix: Copper, 5
Expand All @@ -542,7 +534,7 @@
amount: 5

- type: entity
name: pill (kelotane 10u)
suffix: Kelotane 10u
parent: Pill
id: PillKelotane
components:
Expand All @@ -561,7 +553,6 @@
Quantity: 10

- type: entity
name: pill canister (kelotane 10u)
parent: PillCanister
id: PillCanisterKelotane
suffix: Kelotane, 5
Expand All @@ -574,7 +565,7 @@
amount: 5

- type: entity
name: pill (dermaline 10u)
suffix: Dermaline 10u
parent: Pill
id: PillDermaline
components:
Expand All @@ -593,7 +584,6 @@
Quantity: 10

- type: entity
name: pill canister (dermaline 10u)
parent: PillCanister
id: PillCanisterDermaline
suffix: Dermaline, 5
Expand All @@ -606,10 +596,12 @@
amount: 5

- type: entity
name: space drugs
suffix: Space drugs 15u
parent: Pill
id: PillSpaceDrugs
components:
- type: Label
currentLabel: space drugs 15u
- type: SolutionContainerManager
solutions:
food:
Expand All @@ -619,7 +611,6 @@
Quantity: 15

- type: entity
name: pill canister (LSD 15u)
parent: PillCanister
id: PillCanisterSpaceDrugs
suffix: Space Drugs, 5
Expand All @@ -632,10 +623,12 @@
amount: 5

- type: entity
name: pax
suffix: Pax 10u
parent: Pill
id: PillPax
components:
- type: Label
currentLabel: pax 10u
- type: SolutionContainerManager
solutions:
food:
Expand All @@ -645,7 +638,6 @@
Quantity: 10

- type: entity
name: pill canister (Pax 10u)
parent: PillCanister
id: PillCanisterPax
suffix: Pax, 5
Expand All @@ -659,7 +651,7 @@


- type: entity
name: pill (tricordrazine 10u)
suffix: Tricordrazine 10u
parent: Pill
id: PillTricordrazine
components:
Expand All @@ -678,7 +670,6 @@
Quantity: 10

- type: entity
name: pill canister (tricordrazine 10u)
parent: PillCanister
id: PillCanisterTricordrazine
suffix: Tricordrazine, 5
Expand All @@ -691,7 +682,7 @@
amount: 5

- type: entity
name: pill (bicaridine 10u)
suffix: Bicaridine 10u
parent: Pill
id: PillBicaridine
components:
Expand All @@ -710,7 +701,6 @@
Quantity: 10

- type: entity
name: pill canister (bicaridine 10u)
parent: PillCanister
id: PillCanisterBicaridine
suffix: Bicaridine, 5
Expand All @@ -723,7 +713,7 @@
amount: 5

- type: entity
name: pill (charcoal 10u)
suffix: Charcoal 10u
parent: Pill
id: PillCharcoal
components:
Expand All @@ -742,7 +732,6 @@
Quantity: 10

- type: entity
name: pill canister (charcoal 10u)
parent: PillCanister
id: PillCanisterCharcoal
suffix: Charcoal, 3
Expand All @@ -755,10 +744,12 @@
amount: 3

- type: entity
name: romerol pill
suffix: Romerol 10u
parent: Pill
id: PillRomerol
components:
- type: Label
currentLabel: romerol 10u
- type: SolutionContainerManager
solutions:
food:
Expand All @@ -768,10 +759,12 @@
Quantity: 10

- type: entity
name: ambuzol pill
suffix: Ambuzol 10u
parent: Pill
id: PillAmbuzol
components:
- type: Label
currentLabel: ambuzol 10u
- type: SolutionContainerManager
solutions:
food:
Expand All @@ -781,14 +774,16 @@
Quantity: 10

- type: entity
name: ambuzol plus pill
suffix: Ambuzol plus 5u
parent: Pill
id: PillAmbuzolPlus
components:
- type: Pill
pillType: 2
- type: Sprite
state: pill3
- type: Label
currentLabel: ambuzol plus 5u
- type: SolutionContainerManager
solutions:
food:
Expand Down
Loading
Loading