mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* more-item-status * update 1 * update 2 * Update pistol.yml * update 3 * yml * oops * BatteryItemStatus * fix ChargeItemStatus * Update item-status.ftl * review update 1 * review fix 1 * Update BatteryInfoSystem.cs * Update TimerTriggerItemStatus * merge fix * merge fix * review update 2 * review update 3 * fix marge * StyleNano * review update 4 * review update 5 * BatteryItemStatus * BatteryItemStatus Client * code cleanup * merge * merge and GasTank fix * Merge * unnecessary components * review * oops * GasTank * wawa
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using Content.Client.Items.UI;
|
|
using Content.Client.Message;
|
|
using Content.Client.Stylesheets;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
namespace Content.Client.Weapons.Ranged.UI;
|
|
|
|
/// <summary>
|
|
/// Displays magazine ammunition information for <see cref="BallisticAmmoProviderComponent"/>.
|
|
/// </summary>
|
|
/// <seealso cref="GunSystem"/>
|
|
public sealed partial class MagazineStatusControl : PollingItemStatusControl<MagazineStatusControl.Data>
|
|
{
|
|
private readonly Entity<BallisticAmmoProviderComponent> _parent;
|
|
private readonly RichTextLabel _label;
|
|
|
|
public MagazineStatusControl(Entity<BallisticAmmoProviderComponent> parent)
|
|
{
|
|
_parent = parent;
|
|
_label = new RichTextLabel { StyleClasses = { StyleClass.ItemStatus } };
|
|
AddChild(_label);
|
|
}
|
|
|
|
protected override Data PollData()
|
|
{
|
|
var ammoProvider = _parent.Comp;
|
|
var currentRounds = ammoProvider.Count;
|
|
var maxRounds = ammoProvider.Capacity;
|
|
|
|
return new Data(currentRounds, maxRounds);
|
|
}
|
|
|
|
protected override void Update(in Data data)
|
|
{
|
|
var markup = Loc.GetString("magazine-status-rounds",
|
|
("current", data.CurrentRounds),
|
|
("max", data.MaxRounds));
|
|
|
|
_label.SetMarkup(markup);
|
|
}
|
|
|
|
public readonly record struct Data(int CurrentRounds, int MaxRounds);
|
|
}
|