forked from space-syndicate/space-station-14-next
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
614 changed files
with
6,250 additions
and
201 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
Content.Client/Nyanotrasen/ReverseEngineering/ReverseEngineeringMachineBoundUserInterface.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,80 @@ | ||
using Content.Shared.ReverseEngineering; | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Nyanotrasen.ReverseEngineering; | ||
|
||
public sealed class ReverseEngineeringMachineBoundUserInterface : BoundUserInterface | ||
{ | ||
[Dependency] private readonly IEntityManager _entMan = default!; | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
|
||
private ReverseEngineeringMachineMenu? _menu; | ||
|
||
public ReverseEngineeringMachineBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
if (_menu != null) | ||
return; | ||
|
||
_menu = new ReverseEngineeringMachineMenu(Owner, _entMan, _timing); | ||
|
||
_menu.OnClose += Close; | ||
_menu.OpenCentered(); | ||
|
||
_menu.OnScanButtonPressed += () => | ||
{ | ||
// every button flickering is bad so no prediction | ||
SendMessage(new ReverseEngineeringScanMessage()); | ||
}; | ||
|
||
_menu.OnSafetyButtonToggled += () => | ||
{ | ||
SendPredictedMessage(new ReverseEngineeringSafetyMessage()); | ||
}; | ||
|
||
_menu.OnAutoScanButtonToggled += () => | ||
{ | ||
SendPredictedMessage(new ReverseEngineeringAutoScanMessage()); | ||
}; | ||
|
||
_menu.OnStopButtonPressed += () => | ||
{ | ||
// see scan button | ||
SendMessage(new ReverseEngineeringStopMessage()); | ||
}; | ||
|
||
_menu.OnEjectButtonPressed += () => | ||
{ | ||
// doesn't sound nice when predicted | ||
SendMessage(new ReverseEngineeringEjectMessage()); | ||
}; | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (state is not ReverseEngineeringMachineState cast) | ||
return; | ||
|
||
_menu?.UpdateState(cast); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (!disposing) | ||
return; | ||
|
||
_menu?.Close(); | ||
_menu?.Dispose(); | ||
} | ||
} | ||
|
77 changes: 77 additions & 0 deletions
77
Content.Client/Nyanotrasen/ReverseEngineering/ReverseEngineeringMachineMenu.xaml
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,77 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Title="{Loc 'reverse-engineering-machine-menu-title'}" | ||
MinSize="620 280" | ||
SetSize="620 280"> | ||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True"> | ||
<BoxContainer Margin="10 10 10 10" MinWidth="150" Orientation="Vertical" VerticalExpand="True" SizeFlagsStretchRatio="1"> | ||
<BoxContainer Orientation="Vertical" VerticalExpand="True"> | ||
<Button Name="ScanButton" | ||
Text="{Loc 'reverse-engineering-machine-scan-button'}" | ||
ToolTip="{Loc 'reverse-engineering-machine-scan-tooltip-info'}"> | ||
</Button> | ||
<Button Name="SafetyButton" | ||
Text="{Loc 'reverse-engineering-machine-safety-button'}" | ||
ToolTip="{Loc 'reverse-engineering-machine-safety-tooltip-info'}" | ||
ToggleMode="True"> | ||
</Button> | ||
<Button Name="AutoScanButton" | ||
Text="{Loc 'reverse-engineering-machine-autoscan-button'}" | ||
ToolTip="{Loc 'reverse-engineering-machine-autoscan-tooltip-info'}" | ||
ToggleMode="True"> | ||
</Button> | ||
<Button Name="StopButton" | ||
Text="{Loc 'reverse-engineering-machine-stop-button'}" | ||
ToolTip="{Loc 'reverse-engineering-machine-stop-tooltip-info'}"> | ||
</Button> | ||
<Button Name="EjectButton" | ||
Text="{Loc 'reverse-engineering-machine-eject-button'}" | ||
ToolTip="{Loc 'reverse-engineering-machine-eject-tooltip-info'}"> | ||
</Button> | ||
<BoxContainer MinHeight="5"/> | ||
</BoxContainer> | ||
<BoxContainer Name="ProgressBox" Orientation="Vertical"> | ||
<Label Name="ProgressLabel"/> | ||
<ProgressBar | ||
Name="ProgressBar" | ||
MinValue="0" | ||
MaxValue="1" | ||
SetHeight="20"> | ||
</ProgressBar> | ||
<Label Name="TotalProgressLabel" Text="{Loc 'reverse-engineering-total-progress-label'}"/> | ||
<ProgressBar | ||
Name="TotalProgressBar" | ||
MinValue="0" | ||
MaxValue="100" | ||
SetHeight="20"> | ||
</ProgressBar> | ||
</BoxContainer> | ||
</BoxContainer> | ||
<customControls:VSeparator StyleClasses="LowDivider"/> | ||
<PanelContainer Margin="10 10 10 10" HorizontalExpand="True" SizeFlagsStretchRatio="3"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#000000FF" /> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Margin="10 10 10 10" Orientation="Horizontal"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" > | ||
<BoxContainer VerticalExpand="True"> | ||
<RichTextLabel Name="Information"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
<BoxContainer VerticalExpand="False" Orientation="Vertical" MaxSize="64 64"> | ||
<SpriteView | ||
Name="ItemDisplay" | ||
OverrideDirection="South" | ||
VerticalExpand="False" | ||
SetSize="64 64" | ||
MaxSize="64 64" | ||
Scale="2 2"> | ||
</SpriteView> | ||
</BoxContainer> | ||
<BoxContainer VerticalExpand="True"/> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
87 changes: 87 additions & 0 deletions
87
Content.Client/Nyanotrasen/ReverseEngineering/ReverseEngineeringMachineMenu.xaml.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,87 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.ReverseEngineering; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.State; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Nyanotrasen.ReverseEngineering; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class ReverseEngineeringMachineMenu : FancyWindow | ||
{ | ||
private readonly IEntityManager _entMan; | ||
private readonly IGameTiming _timing; | ||
private readonly SharedReverseEngineeringSystem _revEng; | ||
|
||
private readonly Entity<ReverseEngineeringMachineComponent> _owner; | ||
|
||
public event Action? OnScanButtonPressed; | ||
public event Action? OnSafetyButtonToggled; | ||
public event Action? OnAutoScanButtonToggled; | ||
public event Action? OnStopButtonPressed; | ||
public event Action? OnEjectButtonPressed; | ||
|
||
public ReverseEngineeringMachineMenu(EntityUid owner, IEntityManager entMan, IGameTiming timing) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
_entMan = entMan; | ||
_timing = timing; | ||
_revEng = entMan.System<SharedReverseEngineeringSystem>(); | ||
|
||
_owner = (owner, entMan.GetComponent<ReverseEngineeringMachineComponent>(owner)); | ||
|
||
ScanButton.OnPressed += _ => OnScanButtonPressed?.Invoke(); | ||
SafetyButton.OnToggled += _ => OnSafetyButtonToggled?.Invoke(); | ||
AutoScanButton.OnToggled += _ => OnAutoScanButtonToggled?.Invoke(); | ||
StopButton.OnPressed += _ => OnStopButtonPressed?.Invoke(); | ||
EjectButton.OnPressed += _ => OnEjectButtonPressed?.Invoke(); | ||
} | ||
|
||
private void UpdateArtifactIcon(EntityUid? uid) | ||
{ | ||
if (uid == null) | ||
{ | ||
ItemDisplay.Visible = false; | ||
return; | ||
} | ||
|
||
ItemDisplay.Visible = true; | ||
ItemDisplay.SetEntity(uid); | ||
} | ||
|
||
public void UpdateState(ReverseEngineeringMachineState state) | ||
{ | ||
Information.SetMessage(state.ScanMessage); | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
var scanning = _revEng.IsActive(_owner); | ||
var item = _revEng.GetItem(_owner); | ||
ScanButton.Disabled = scanning || item == null; | ||
StopButton.Disabled = !scanning; | ||
SafetyButton.Pressed = _owner.Comp.SafetyOn; | ||
AutoScanButton.Pressed = _owner.Comp.AutoScan; | ||
EjectButton.Disabled = ScanButton.Disabled; | ||
|
||
UpdateArtifactIcon(item); | ||
|
||
ProgressBox.Visible = scanning; | ||
|
||
if (!_entMan.TryGetComponent<ActiveReverseEngineeringMachineComponent>(_owner, out var active) | ||
|| !_entMan.TryGetComponent<ReverseEngineeringComponent>(item, out var rev)) | ||
return; | ||
|
||
TotalProgressBar.Value = (float) rev.Progress; | ||
|
||
var remaining = Math.Max(active.NextProbe.TotalSeconds - _timing.CurTime.TotalSeconds, 0.0); | ||
ProgressLabel.Text = Loc.GetString("analysis-console-progress-text", ("seconds", (int) remaining)); | ||
ProgressBar.Value = 1f - (float) (remaining / _owner.Comp.AnalysisDuration.TotalSeconds); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Content.Client/Nyanotrasen/ReverseEngineering/ReverseEngineeringSystem.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,5 @@ | ||
using Content.Shared.ReverseEngineering; | ||
|
||
namespace Content.Client.ReverseEngineering; | ||
|
||
public sealed class ReverseEngineeringSystem : SharedReverseEngineeringSystem; |
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,7 @@ | ||
// taken and adapted from https://github.com/RMC-14/RMC-14?ysclid=lzx00zxd6e53093995 | ||
|
||
using Content.Shared.ADT.NightVision; | ||
|
||
namespace Content.Server.ADT.NightVision; | ||
|
||
public sealed class NightVisionSystem : SharedNightVisionSystem; |
Oops, something went wrong.