Skip to content

Commit

Permalink
Merge branch 'space-wizards:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
notquitehadouken authored Dec 27, 2023
2 parents c0514b4 + b1e2e4c commit 6e5b79a
Show file tree
Hide file tree
Showing 82 changed files with 3,033 additions and 554 deletions.
7 changes: 3 additions & 4 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Client.Rotation;
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
using Content.Shared.Rotation;
using Content.Shared.Vehicle.Components;
using Robust.Client.GameObjects;

Expand Down Expand Up @@ -56,17 +57,15 @@ private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref Ap
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals))
return;

if (!Appearance.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
if (!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
!buckled ||
args.Sprite == null)
{
_rotationVisualizerSystem.SetHorizontalAngle(uid, rotVisuals.DefaultRotation, rotVisuals);
_rotationVisualizerSystem.SetHorizontalAngle((uid, rotVisuals), rotVisuals.DefaultRotation);
return;
}

// Animate strapping yourself to something at a given angle
_rotationVisualizerSystem.SetHorizontalAngle(uid, Angle.FromDegrees(angle), rotVisuals);
// TODO: Dump this when buckle is better
_rotationVisualizerSystem.AnimateSpriteRotation(uid, args.Sprite, rotVisuals.HorizontalRotation, 0.125f);
}
Expand Down
28 changes: 28 additions & 0 deletions Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
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 Content.Client/CartridgeLoader/Cartridges/LogProbeUiEntry.xaml
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 Content.Client/CartridgeLoader/Cartridges/LogProbeUiEntry.xaml.cs
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 Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
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>
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Rounding;
using Robust.Client.GameObjects;
Expand Down
29 changes: 13 additions & 16 deletions Content.Client/Rotation/RotationVisualizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@

namespace Content.Client.Rotation;

public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsComponent>
public sealed class RotationVisualizerSystem : SharedRotationVisualsSystem
{
public void SetHorizontalAngle(EntityUid uid, Angle angle, RotationVisualsComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

if (component.HorizontalRotation.Equals(angle))
return;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly AnimationPlayerSystem _animation = default!;

component.HorizontalRotation = angle;
Dirty(component);
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RotationVisualsComponent, AppearanceChangeEvent>(OnAppearanceChange);
}

protected override void OnAppearanceChange(EntityUid uid, RotationVisualsComponent component, ref AppearanceChangeEvent args)
private void OnAppearanceChange(EntityUid uid, RotationVisualsComponent component, ref AppearanceChangeEvent args)
{
base.OnAppearanceChange(uid, component, ref args);

if (args.Sprite == null)
return;

// If not defined, defaults to standing.
AppearanceSystem.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component);
_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component);

switch (state)
{
Expand All @@ -53,9 +50,9 @@ public void AnimateSpriteRotation(EntityUid uid, SpriteComponent spriteComp, Ang
var animationComp = EnsureComp<AnimationPlayerComponent>(uid);
const string animationKey = "rotate";
// Stop the current rotate animation and then start a new one
if (AnimationSystem.HasRunningAnimation(animationComp, animationKey))
if (_animation.HasRunningAnimation(animationComp, animationKey))
{
AnimationSystem.Stop(animationComp, animationKey);
_animation.Stop(animationComp, animationKey);
}

var animation = new Animation
Expand All @@ -77,6 +74,6 @@ public void AnimateSpriteRotation(EntityUid uid, SpriteComponent spriteComp, Ang
}
};

AnimationSystem.Play((uid, animationComp), animation, animationKey);
_animation.Play((uid, animationComp), animation, animationKey);
}
}
19 changes: 0 additions & 19 deletions Content.Client/Rotation/RotationVisualsComponent.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override void Initialize()
_config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
_config.OnValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _timing.CurTime.ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;

SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
Expand Down Expand Up @@ -471,7 +471,7 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
{
str = str[..(DescriptionMax - _maxAdditionalChars - unameLength)];
}
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _timing.CurTime.ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, admins.Count == 0));
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, admins.Count == 0));
}

if (admins.Count != 0 || sendsWebhook)
Expand Down
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");
}
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);
}
}
8 changes: 5 additions & 3 deletions Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ private void OnBeforeBroadcast(EntityUid uid, DeviceListComponent component, Bef
//Don't filter anything if the device list is empty
if (component.Devices.Count == 0)
{
if (component.IsAllowList) args.Cancel();
if (component.IsAllowList)
args.Cancel();
return;
}

HashSet<DeviceNetworkComponent> filteredRecipients = new(args.Recipients.Count);

foreach (var recipient in args.Recipients)
{
if (component.Devices.Contains(recipient.Owner) == component.IsAllowList) filteredRecipients.Add(recipient);
if (component.Devices.Contains(recipient.Owner) == component.IsAllowList)
filteredRecipients.Add(recipient);
}

args.ModifiedRecipients = filteredRecipients;
Expand Down Expand Up @@ -162,7 +164,7 @@ private void OnMapSave(BeforeSaveEvent ev)
var old = device.Devices.ToList();
device.Devices.ExceptWith(toRemove);
RaiseLocalEvent(uid, new DeviceListUpdateEvent(old, device.Devices.ToList()));
Dirty(device);
Dirty(uid, device);
toRemove.Clear();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,13 @@ private void UpdateListUiState(EntityUid uid, NetworkConfiguratorComponent compo
/// </summary>
private void OnUiClosed(EntityUid uid, NetworkConfiguratorComponent component, BoundUIClosedEvent args)
{
component.ActiveDeviceList = null;
if (TryComp(component.ActiveDeviceList, out DeviceListComponent? list))
{
list.Configurators.Remove(uid);
}

component.ActiveDeviceList = null;

if (args.UiKey is NetworkConfiguratorUiKey.Link)
{
component.ActiveDeviceLink = null;
Expand Down
Loading

0 comments on commit 6e5b79a

Please sign in to comment.