forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'space-wizards:master' into master
- Loading branch information
Showing
82 changed files
with
3,033 additions
and
554 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Content.Client.UserInterface.Fragments; | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.CartridgeLoader.Cartridges; | ||
|
||
public sealed partial class LogProbeUi : UIFragment | ||
{ | ||
private LogProbeUiFragment? _fragment; | ||
|
||
public override Control GetUIFragmentRoot() | ||
{ | ||
return _fragment!; | ||
} | ||
|
||
public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner) | ||
{ | ||
_fragment = new LogProbeUiFragment(); | ||
} | ||
|
||
public override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
if (state is not LogProbeUiState logProbeUiState) | ||
return; | ||
|
||
_fragment?.UpdateState(logProbeUiState.PulledLogs); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Content.Client/CartridgeLoader/Cartridges/LogProbeUiEntry.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,20 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Margin="4" | ||
Orientation="Vertical"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Name="NumberLabel" | ||
Align="Center" | ||
SetWidth="60" | ||
ClipText="True"/> | ||
<Label Name="TimeLabel" | ||
Align="Center" | ||
SetWidth="280" | ||
ClipText="True"/> | ||
<Label Name="AccessorLabel" | ||
Align="Center" | ||
SetWidth="110" | ||
ClipText="True"/> | ||
</BoxContainer> | ||
<customControls:HSeparator Margin="0 5 0 5"/> | ||
</BoxContainer> |
17 changes: 17 additions & 0 deletions
17
Content.Client/CartridgeLoader/Cartridges/LogProbeUiEntry.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,17 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LogProbeUiEntry : BoxContainer | ||
{ | ||
public LogProbeUiEntry(int numberLabel, string timeText, string accessorText) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
NumberLabel.Text = numberLabel.ToString(); | ||
TimeLabel.Text = timeText; | ||
AccessorLabel.Text = accessorText; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.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,21 @@ | ||
<cartridges:LogProbeUiFragment xmlns="https://spacestation14.io" | ||
xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
Orientation="Vertical" | ||
VerticalExpand="True"> | ||
<PanelContainer> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#000000FF" | ||
BorderColor="#5a5a5a" | ||
BorderThickness="0 0 0 1"/> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Orientation="Horizontal" Align="Center" Margin="8"> | ||
<Label HorizontalExpand="True" Text="{Loc 'log-probe-label-number'}"/> | ||
<Label HorizontalExpand="True" Text="{Loc 'log-probe-label-time'}"/> | ||
<Label HorizontalExpand="True" Text="{Loc 'log-probe-label-accessor'}"/> | ||
</BoxContainer> | ||
</PanelContainer> | ||
<ScrollContainer VerticalExpand="True" HScrollEnabled="True"> | ||
<BoxContainer Orientation="Vertical" Name="ProbedDeviceContainer"/> | ||
</ScrollContainer> | ||
</cartridges:LogProbeUiFragment> |
39 changes: 39 additions & 0 deletions
39
Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.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,39 @@ | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LogProbeUiFragment : BoxContainer | ||
{ | ||
public LogProbeUiFragment() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
} | ||
|
||
public void UpdateState(List<PulledAccessLog> logs) | ||
{ | ||
ProbedDeviceContainer.RemoveAllChildren(); | ||
|
||
//Reverse the list so the oldest entries appear at the bottom | ||
logs.Reverse(); | ||
|
||
var count = 1; | ||
foreach (var log in logs) | ||
{ | ||
AddAccessLog(log, count); | ||
count++; | ||
} | ||
} | ||
|
||
private void AddAccessLog(PulledAccessLog log, int numberLabelText) | ||
{ | ||
var timeLabelText = TimeSpan.FromSeconds(Math.Truncate(log.Time.TotalSeconds)).ToString(); | ||
var accessorLabelText = log.Accessor; | ||
var entry = new LogProbeUiEntry(numberLabelText, timeLabelText, accessorLabelText); | ||
|
||
ProbedDeviceContainer.AddChild(entry); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.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
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 was deleted.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeComponent.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,21 @@ | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Server.CartridgeLoader.Cartridges; | ||
|
||
[RegisterComponent] | ||
[Access(typeof(LogProbeCartridgeSystem))] | ||
public sealed partial class LogProbeCartridgeComponent : Component | ||
{ | ||
/// <summary> | ||
/// The list of pulled access logs | ||
/// </summary> | ||
[DataField, ViewVariables] | ||
public List<PulledAccessLog> PulledAccessLogs = new(); | ||
|
||
/// <summary> | ||
/// The sound to make when we scan something with access | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public SoundSpecifier SoundScan = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg"); | ||
} |
71 changes: 71 additions & 0 deletions
71
Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.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,71 @@ | ||
using Content.Shared.Access.Components; | ||
using Content.Shared.Audio; | ||
using Content.Shared.CartridgeLoader; | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Content.Shared.Popups; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.CartridgeLoader.Cartridges; | ||
|
||
public sealed class LogProbeCartridgeSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly CartridgeLoaderSystem? _cartridgeLoaderSystem = default!; | ||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; | ||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<LogProbeCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady); | ||
SubscribeLocalEvent<LogProbeCartridgeComponent, CartridgeAfterInteractEvent>(AfterInteract); | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="CartridgeAfterInteractEvent" /> gets relayed to this system if the cartridge loader is running | ||
/// the LogProbe program and someone clicks on something with it. <br/> | ||
/// <br/> | ||
/// Updates the program's list of logs with those from the device. | ||
/// </summary> | ||
private void AfterInteract(Entity<LogProbeCartridgeComponent> ent, ref CartridgeAfterInteractEvent args) | ||
{ | ||
if (args.InteractEvent.Handled || !args.InteractEvent.CanReach || args.InteractEvent.Target is not { } target) | ||
return; | ||
|
||
if (!TryComp(target, out AccessReaderComponent? accessReaderComponent)) | ||
return; | ||
|
||
//Play scanning sound with slightly randomized pitch | ||
_audioSystem.PlayEntity(ent.Comp.SoundScan, args.InteractEvent.User, target, AudioHelpers.WithVariation(0.25f, _random)); | ||
_popupSystem.PopupCursor(Loc.GetString("log-probe-scan", ("device", target)), args.InteractEvent.User); | ||
|
||
ent.Comp.PulledAccessLogs.Clear(); | ||
|
||
foreach (var accessRecord in accessReaderComponent.AccessLog) | ||
{ | ||
var log = new PulledAccessLog( | ||
accessRecord.AccessTime, | ||
accessRecord.Accessor | ||
); | ||
|
||
ent.Comp.PulledAccessLogs.Add(log); | ||
} | ||
|
||
UpdateUiState(ent, args.Loader); | ||
} | ||
|
||
/// <summary> | ||
/// This gets called when the ui fragment needs to be updated for the first time after activating | ||
/// </summary> | ||
private void OnUiReady(Entity<LogProbeCartridgeComponent> ent, ref CartridgeUiReadyEvent args) | ||
{ | ||
UpdateUiState(ent, args.Loader); | ||
} | ||
|
||
private void UpdateUiState(Entity<LogProbeCartridgeComponent> ent, EntityUid loaderUid) | ||
{ | ||
var state = new LogProbeUiState(ent.Comp.PulledAccessLogs); | ||
_cartridgeLoaderSystem?.UpdateCartridgeUiState(loaderUid, state); | ||
} | ||
} |
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
Oops, something went wrong.