Some random tasks (#1763)

* Update venicialis.yml

* Update CP14CurrencySystem.Converter.cs

* fix #1759

* fix #1605

* fix #1604
This commit is contained in:
Red
2025-09-11 00:22:21 +03:00
committed by GitHub
parent 1831dcc75b
commit 38f1a765d7
6 changed files with 122 additions and 5 deletions

View File

@@ -0,0 +1,50 @@
using System.Text;
using Content.Client.Items;
using Content.Client.Stylesheets;
using Content.Shared._CP14.LockKey.Components;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
namespace Content.Client._CP14.LockKey;
public sealed class CP14ClientLockKeySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
Subs.ItemStatus<CP14KeyComponent>(ent => new CP14KeyStatusControl(ent));
}
}
public sealed class CP14KeyStatusControl : Control
{
private readonly Entity<CP14KeyComponent> _parent;
private readonly RichTextLabel _label;
public CP14KeyStatusControl(Entity<CP14KeyComponent> parent)
{
_parent = parent;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (_parent.Comp.LockShape is null)
return;
var sb = new StringBuilder("(");
foreach (var item in _parent.Comp.LockShape)
{
sb.Append($"{item} ");
}
sb.Append(")");
_label.Text = sb.ToString();
}
}

View File

@@ -0,0 +1,55 @@
using Content.Client.Stylesheets;
using Content.Shared._CP14.MagicEnergy.Components;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
namespace Content.Client._CP14.MagicEnergy;
public sealed class CP14MagicEnergyStatusControl : Control
{
private readonly Entity<CP14MagicEnergyContainerComponent> _parent;
private readonly IEntityManager _entMan;
private readonly RichTextLabel _label;
private readonly ProgressBar _progress;
public CP14MagicEnergyStatusControl(Entity<CP14MagicEnergyExaminableComponent> parent)
{
_entMan = IoCManager.Resolve<IEntityManager>();
_progress = new ProgressBar
{
MaxValue = 1,
Value = 0
};
_progress.SetHeight = 8f;
_progress.ForegroundStyleBoxOverride = new StyleBoxFlat(Color.FromHex("#3fc488"));
_progress.BackgroundStyleBoxOverride = new StyleBoxFlat(Color.FromHex("#0f2d42"));
_progress.Margin = new Thickness(0, 4);
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
if (!_entMan.TryGetComponent<CP14MagicEnergyContainerComponent>(parent, out var container))
return;
_parent = (parent.Owner, container);
var boxContainer = new BoxContainer();
boxContainer.Orientation = BoxContainer.LayoutOrientation.Vertical;
boxContainer.AddChild(_label);
boxContainer.AddChild(_progress);
AddChild(boxContainer);
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
_progress.Value = (float)(_parent.Comp.Energy / _parent.Comp.MaxEnergy);
var power = (int) (_parent.Comp.Energy / _parent.Comp.MaxEnergy * 100);
_label.Text = $"{power}%";
}
}

View File

@@ -1,5 +1,15 @@
using Content.Client.Items;
using Content.Shared._CP14.MagicEnergy;
using Content.Shared._CP14.MagicEnergy.Components;
namespace Content.Client._CP14.MagicEnergy;
public sealed class CP14MagicEnergySystem : CP14SharedMagicEnergySystem;
public sealed class CP14MagicEnergySystem : CP14SharedMagicEnergySystem
{
public override void Initialize()
{
base.Initialize();
Subs.ItemStatus<CP14MagicEnergyExaminableComponent>( ent => new CP14MagicEnergyStatusControl(ent));
}
}