-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Space-Wind-V4
- Loading branch information
Showing
271 changed files
with
48,098 additions
and
39,209 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Content.Client/Chemistry/EntitySystems/FillableOneTimeInjectorSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Content.Client.Chemistry.UI; | ||
using Content.Client.Items; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Client.Chemistry.EntitySystems; | ||
|
||
public sealed class FillableOneTimeInjectorSystem : SharedFillableOneTimeInjectorSystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
Subs.ItemStatus<FillableOneTimeInjectorComponent>(ent => new FillableOneTimeInjectorStatusControl(ent, SolutionContainers)); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
Content.Client/Chemistry/UI/FillableOneTimeInjectorStatusControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using Content.Client.Message; | ||
using Content.Client.Stylesheets; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Chemistry.UI; | ||
|
||
public sealed class FillableOneTimeInjectorStatusControl : Control | ||
{ | ||
private readonly Entity<FillableOneTimeInjectorComponent> _parent; | ||
private readonly SharedSolutionContainerSystem _solutionContainers; | ||
private readonly RichTextLabel _label; | ||
|
||
private FixedPoint2 PrevVolume; | ||
private FixedPoint2 PrevMaxVolume; | ||
private FixedPoint2 PrevTransferAmount; | ||
private FillableOneTimeInjectorToggleMode PrevToggleStateIndex; | ||
|
||
public FillableOneTimeInjectorStatusControl(Entity<FillableOneTimeInjectorComponent> parent, SharedSolutionContainerSystem solutionContainers) | ||
{ | ||
_parent = parent; | ||
_solutionContainers = solutionContainers; | ||
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } }; | ||
AddChild(_label); | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.SolutionName, out _, out var solution)) | ||
return; | ||
|
||
// only updates the UI if any of the details are different than they previously were | ||
if (PrevVolume == solution.Volume | ||
&& PrevMaxVolume == solution.MaxVolume | ||
&& PrevTransferAmount == _parent.Comp.TransferAmount) | ||
return; | ||
|
||
PrevVolume = solution.Volume; | ||
PrevMaxVolume = solution.MaxVolume; | ||
PrevTransferAmount = _parent.Comp.TransferAmount; | ||
var modeStringLocalized = ""; | ||
|
||
// only updates the UI if any of the details are different than they previously were | ||
if(PrevToggleStateIndex == _parent.Comp.ToggleState) | ||
return; | ||
|
||
PrevToggleStateIndex = _parent.Comp.ToggleState; | ||
|
||
// Update current volume and injector state | ||
modeStringLocalized = Loc.GetString( | ||
_parent.Comp.ToggleState switch | ||
{ | ||
FillableOneTimeInjectorToggleMode.Draw => "injector-draw-text", | ||
FillableOneTimeInjectorToggleMode.Inject => "injector-inject-text", | ||
FillableOneTimeInjectorToggleMode.Spent => "injector-spent-text", | ||
_ => "injector-invalid-injector-toggle-mode" | ||
}); | ||
|
||
if (_parent.Comp.ToggleState != FillableOneTimeInjectorToggleMode.Draw) | ||
{ | ||
_label.SetMarkup( | ||
Loc.GetString( | ||
"onetime-injector-simple-volume-label", | ||
("currentVolume", solution.Volume), | ||
("modeString", modeStringLocalized))); | ||
} | ||
else | ||
{ | ||
_label.SetMarkup( | ||
Loc.GetString( | ||
"injector-volume-label", | ||
("currentVolume", solution.Volume), | ||
("totalVolume", solution.MaxVolume), | ||
("modeString", modeStringLocalized), | ||
("transferVolume", _parent.Comp.TransferAmount))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,80 @@ | ||
using Content.Client.Storage.Systems; | ||
using Content.Client.UserInterface.Systems.Storage; | ||
using Content.Client.UserInterface.Systems.Storage.Controls; | ||
using Content.Shared.Storage; | ||
using JetBrains.Annotations; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.Storage; | ||
|
||
[UsedImplicitly] | ||
public sealed class StorageBoundUserInterface : BoundUserInterface | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
|
||
[Obsolete] public override bool DeferredClose => false; | ||
private readonly StorageSystem _storage; | ||
private StorageWindow? _window; | ||
|
||
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_storage = _entManager.System<StorageSystem>(); | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp)) | ||
_storage.OpenStorageWindow((Owner, comp)); | ||
_window = IoCManager.Resolve<IUserInterfaceManager>() | ||
.GetUIController<StorageUIController>() | ||
.CreateStorageWindow(Owner); | ||
|
||
if (EntMan.TryGetComponent(Owner, out StorageComponent? storage)) | ||
{ | ||
_window.UpdateContainer((Owner, storage)); | ||
} | ||
|
||
_window.OnClose += Close; | ||
_window.FlagDirty(); | ||
} | ||
|
||
public void Refresh() | ||
{ | ||
_window?.FlagDirty(); | ||
} | ||
|
||
public void Reclaim() | ||
{ | ||
if (_window == null) | ||
return; | ||
|
||
_window.OnClose -= Close; | ||
_window.Orphan(); | ||
_window = null; | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (!disposing) | ||
|
||
Reclaim(); | ||
} | ||
|
||
public void Hide() | ||
{ | ||
if (_window == null) | ||
return; | ||
|
||
_storage.CloseStorageWindow(Owner); | ||
_window.Visible = false; | ||
} | ||
|
||
public void Show() | ||
{ | ||
if (_window == null) | ||
return; | ||
|
||
_window.Visible = true; | ||
} | ||
|
||
public void ReOpen() | ||
{ | ||
_window?.Orphan(); | ||
_window = null; | ||
Open(); | ||
} | ||
} | ||
|
Oops, something went wrong.