mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-11 19:31:12 +03:00
* Predict Light Replacers * Public once more * Light changes * Introduce an OrderList. * Added Radial Menu * Fix missing Dirty() * Introduce EntityProvider * Migratiooon! * Adress Reviews * Forgot Comments * Test-Fail Fix * Fixes * Update buttons * Revert "Update buttons" This reverts commit f84d8f2502600905a2ab4bce5463af6f2b4b1c3e. * Introduce Dedicated Short String * review * Another review has hit the PR Co-Authored-By: Whatstone <166147148+whatston3@users.noreply.github.com> * Adressing reviews Co-Authored-By: Whatstone <166147148+whatston3@users.noreply.github.com> * Update LightReplacerMenuBoundUserInterface.cs * refactor: do not pass ref type by ref, try not to create impure methods where it is not required * refactor: random xml-doc changes * refactor: more xml-doc, and 1 call per line convention * Small fixes * Iterate through the container * updated xml docs * IReadOnlyfix * refactor: renaming, whitespaces, use deconstructor in foreach, use Enumerable instead of creating additional list when its possible that it will be empty and wont be modified * refactor: fix collction cloning to not throw during modificaiton * Replace popups with sounds. * Added singular sounds * refactor: fix error on moving items from one EntityProvider to another and back when they have some spawned entities in container * Replaced Popup with Sound --------- Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com> Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com> Co-authored-by: Fildrance <fildrance@gmail.com>
62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using Content.Client.Message;
|
|
using Content.Client.Stylesheets;
|
|
using Content.Shared.Light.Components;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.Light.Controls;
|
|
|
|
/// <summary>
|
|
/// Handles the label on the light replacer
|
|
/// </summary>
|
|
public sealed partial class LightReplacerStatusControl : Control
|
|
{
|
|
[Dependency] private IPrototypeManager _prototype = default!;
|
|
[Dependency] private IEntityManager _entity = default!;
|
|
|
|
private readonly Entity<LightReplacerComponent> _parent;
|
|
private readonly RichTextLabel _label;
|
|
|
|
private EntProtoId? _prevActiveLightTube;
|
|
private EntProtoId? _prevActiveLightBulb;
|
|
private string? _labelTube;
|
|
private string? _labelBulb;
|
|
|
|
public LightReplacerStatusControl(Entity<LightReplacerComponent> parent)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_parent = parent;
|
|
_label = new RichTextLabel { StyleClasses = { StyleClass.ItemStatus } };
|
|
AddChild(_label);
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
|
|
// only updates the UI if any of the details are different than they previously were
|
|
if (_prevActiveLightTube == _parent.Comp.ActiveLightTube
|
|
&& _prevActiveLightBulb == _parent.Comp.ActiveLightBulb)
|
|
return;
|
|
|
|
_prevActiveLightTube = _parent.Comp.ActiveLightTube;
|
|
_prevActiveLightBulb = _parent.Comp.ActiveLightBulb;
|
|
|
|
if (!_prototype.Resolve(_prevActiveLightTube, out var tube)
|
|
|| !tube.Components.TryGetComponent<LightBulbComponent>(_entity.ComponentFactory, out var lightTube)
|
|
|| !_prototype.Resolve(_prevActiveLightBulb, out var bulb)
|
|
|| !bulb.Components.TryGetComponent<LightBulbComponent>(_entity.ComponentFactory, out var lightBulb))
|
|
return;
|
|
|
|
_labelTube = lightTube.ShortName is { } tubeName ? Loc.GetString(tubeName) : tube.Name;
|
|
_labelBulb = lightBulb.ShortName is { } bulbName ? Loc.GetString(bulbName) : bulb.Name;
|
|
|
|
// Update current active lights
|
|
_label.SetMarkup(Loc.GetString("comp-light-replacer-label",
|
|
("tube", _labelTube),
|
|
("bulb", _labelBulb)));
|
|
}
|
|
}
|