Skip to content

Commit

Permalink
More Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PursuitInAshes committed Jan 1, 2025
1 parent 6ef4237 commit 5eb9a94
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Content.Shared._CD.TapeRecorder.Components;
using Content.Shared._CD.TapeRecorder.Events;
using JetBrains.Annotations;
using Robust.Shared.Timing;

namespace Content.Client._CD.TapeRecorder.Ui;

[UsedImplicitly]
public sealed class TapeRecorderBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
[Dependency] private readonly IEntityManager _entMan = default!;
Expand Down
12 changes: 6 additions & 6 deletions Content.Client/_CD/TapeRecorder/Ui/TapeRecorderWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
SetSize="440 220"
Title="{Loc 'tape-recorder-menu-title'}"
Resizable="False">
<BoxContainer Margin = "10 5" Orientation="Vertical" SeparationOverride="5">
<BoxContainer Margin="10 5" Orientation="Vertical" SeparationOverride="5">
<BoxContainer Orientation="Vertical">
<Label Margin = "5 0" Name="CassetteLabel" Text="{Loc 'tape-recorder-menu-no-cassette-label'}" Align="Left" StyleClasses="StatusFieldTitle" />
<Label Margin="5 0" Name="CassetteLabel" Text="{Loc 'tape-recorder-menu-no-cassette-label'}" Align="Left" StyleClasses="StatusFieldTitle" />
<Slider Name="PlaybackSlider" HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name ="Test" Margin = "0 5 0 0" Orientation="Horizontal" VerticalExpand = "True">
<BoxContainer Orientation="Vertical" HorizontalExpand = "True">
<BoxContainer Name="Test" Margin="0 5 0 0" Orientation="Horizontal" VerticalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<Label Text="{Loc 'tape-recorder-menu-controls-label'}" Align="Center" />
<BoxContainer Name="Buttons" Orientation="Horizontal" VerticalExpand="True" Align="Center"/> <!-- Populated in constructor -->
</BoxContainer>
</BoxContainer>
<BoxContainer Margin = "0 2 0 0" Orientation="Horizontal">
<Button Name="PrintButton" Text="{Loc 'tape-recorder-menu-print-button'}" TextAlign="Center" HorizontalExpand ="True"/>
<BoxContainer Margin="0 2 0 0" Orientation="Horizontal">
<Button Name="PrintButton" Text="{Loc 'tape-recorder-menu-print-button'}" TextAlign="Center" HorizontalExpand="True"/>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ public sealed partial class TapeRecorderWindow : FancyWindow
private readonly IEntityManager _entMan;

private readonly EntityUid _owner;
private bool _onCooldown;
private bool _hasCassette;
private TapeRecorderMode _mode = TapeRecorderMode.Stopped;

private RadioOptions<TapeRecorderMode> _options = default!;
private RadioOptions<TapeRecorderMode> _options;
private bool _updating;

public Action<TapeRecorderMode>? OnModeChanged;
Expand Down
5 changes: 2 additions & 3 deletions Content.Server/_CD/TapeRecorder/TapeRecorderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Content.Shared._CD.TapeRecorder.Components;
using Content.Shared._CD.TapeRecorder.Events;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Server._CD.TapeRecorder;

Expand Down Expand Up @@ -71,11 +70,11 @@ private void OnListen(Entity<TapeRecorderComponent> ent, ref ListenEvent args)

// TODO: Handle "Someone" when whispering from far away, needs chat refactor

//Handle someone using a voice changer
// Handle someone using a voice changer
var nameEv = new TransformSpeakerNameEvent(args.Source, Name(args.Source));
RaiseLocalEvent(args.Source, nameEv);

//Add a new entry to the tape
// Add a new entry to the tape
var verb = _chat.GetSpeechVerb(args.Source, args.Message);
var name = nameEv.VoiceName;
cassette.Comp.Buffer.Add(new TapeCassetteRecordedMessage(cassette.Comp.CurrentPosition, name, verb, args.Message));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Robust.Shared.GameStates;

namespace Content.Shared._CD.TapeRecorder.Components;

/// <summary>
/// Removed from the cassette when damaged to prevent it being played until repaired
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed partial class TapeCassetteComponent : Component
/// Only dirtied when the tape recorder is stopped
/// </summary>
[DataField, AutoNetworkedField]
public float CurrentPosition = 0f;
public float CurrentPosition;

/// <summary>
/// Maximum capacity of this tape
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class PrintTapeRecorderMessage : BoundUserInterfaceMessage;
[Serializable, NetSerializable]
public sealed class TapeRecorderState : BoundUserInterfaceState
{
// TODO: check the itemslot on client instead of putting easy casette stuff in the state
// TODO: check the itemslot on client instead of putting easy cassette stuff in the state
public bool HasCassette;
public bool HasData;
public float CurrentTime;
Expand Down
37 changes: 19 additions & 18 deletions Content.Shared/_CD/TapeRecorder/SharedTapeRecorderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Labels.Components;
using Content.Shared.Popups;
using Content.Shared._CD.TapeRecorder.Components;
using Content.Shared._CD.TapeRecorder.Events;
using Content.Shared.Toggleable;
Expand All @@ -30,7 +29,7 @@ public abstract class SharedTapeRecorderSystem : EntitySystem
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;

protected const string SlotName = "cassette_tape";
private protected const string SlotName = "cassette_tape";

public override void Initialize()
{
Expand Down Expand Up @@ -108,18 +107,18 @@ private bool ProcessRecordingTapeRecorder(Entity<TapeRecorderComponent> ent, flo

var currentTime = tape.Comp.CurrentPosition + frameTime;

//'Flushed' in this context is a mark indicating the message was not added between the last update and this update
//Remove any flushed messages in the segment we just recorded over (ie old messages)
// 'Flushed' in this context is a mark indicating the message was not added between the last update and this update
// Remove any flushed messages in the segment we just recorded over (ie old messages)
tape.Comp.RecordedData.RemoveAll(x => x.Timestamp > tape.Comp.CurrentPosition && x.Timestamp <= currentTime);

tape.Comp.RecordedData.AddRange(tape.Comp.Buffer);

tape.Comp.Buffer.Clear();

//Update the tape's current time
// Update the tape's current time
tape.Comp.CurrentPosition = (float) Math.Min(currentTime, tape.Comp.MaxCapacity.TotalSeconds);

//If we have reached the end of the tape - stop
// If we have reached the end of the tape - stop
return tape.Comp.CurrentPosition < tape.Comp.MaxCapacity.TotalSeconds;
}

Expand All @@ -134,16 +133,16 @@ private bool ProcessPlayingTapeRecorder(Entity<TapeRecorderComponent> ent, float
if (!TryGetTapeCassette(ent, out var tape))
return false;

//Get the segment of the tape to be played
//And any messages within that time period
// Get the segment of the tape to be played
// And any messages within that time period
var currentTime = tape.Comp.CurrentPosition + frameTime;

ReplayMessagesInSegment(ent, tape.Comp, tape.Comp.CurrentPosition, currentTime);

//Update the tape's position
// Update the tape's position
tape.Comp.CurrentPosition = (float) Math.Min(currentTime, tape.Comp.MaxCapacity.TotalSeconds);

//Stop when we reach the end of the tape
// Stop when we reach the end of the tape
return tape.Comp.CurrentPosition < tape.Comp.MaxCapacity.TotalSeconds;
}

Expand All @@ -158,12 +157,12 @@ private bool ProcessRewindingTapeRecorder(Entity<TapeRecorderComponent> ent, flo
if (!TryGetTapeCassette(ent, out var tape))
return false;

//Calculate how far we have rewound
// Calculate how far we have rewound
var rewindTime = frameTime * ent.Comp.RewindSpeed;
//Update the current time, clamp to 0
// Update the current time, clamp to 0
tape.Comp.CurrentPosition = Math.Max(0, tape.Comp.CurrentPosition - rewindTime);

//If we have reached the beginning of the tape, stop
// If we have reached the beginning of the tape, stop
return tape.Comp.CurrentPosition >= float.Epsilon;
}

Expand All @@ -180,11 +179,11 @@ protected virtual void ReplayMessagesInSegment(Entity<TapeRecorderComponent> ent
/// </summary>
protected void OnInteractingWithCassette(Entity<TapeCassetteComponent> ent, ref InteractUsingEvent args)
{
//Is the tape damaged?
// Is the tape damaged?
if (HasComp<FitsInTapeRecorderComponent>(ent))
return;

//Are we using a valid repair tool?
// Are we using a valid repair tool?
if (_whitelist.IsWhitelistFail(ent.Comp.RepairWhitelist, args.Used))
return;

Expand All @@ -203,7 +202,7 @@ protected void OnTapeCassetteRepair(Entity<TapeCassetteComponent> ent, ref TapeC
if (args.Handled || args.Cancelled || args.Args.Target == null)
return;

//Cant repair if not damaged
// Cant repair if not damaged
if (HasComp<FitsInTapeRecorderComponent>(ent))
return;

Expand Down Expand Up @@ -247,7 +246,7 @@ protected void OnRecorderExamined(Entity<TapeRecorderComponent> ent, ref Examine
if (!args.IsInDetailsRange)
return;

//Check if we have a tape cassette inserted
// Check if we have a tape cassette inserted
if (!TryGetTapeCassette(ent, out var tape))
{
args.PushMarkup(Loc.GetString(ent.Comp.TextModeEmpty));
Expand Down Expand Up @@ -363,7 +362,7 @@ private void SetMode(Entity<TapeRecorderComponent> ent, TapeRecorderMode mode)
UpdateUI(ent);
}

protected bool TryGetTapeCassette(EntityUid ent, [NotNullWhen(true)] out Entity<TapeCassetteComponent> tape)
protected bool TryGetTapeCassette(EntityUid ent, out Entity<TapeCassetteComponent> tape)
{
if (_slots.GetItemOrNull(ent, SlotName) is not {} cassette)
{
Expand Down Expand Up @@ -401,8 +400,10 @@ private void UpdateUI(Entity<TapeRecorderComponent> ent)
maxTime = (float) tape.Comp.MaxCapacity.TotalSeconds;

if (TryComp<LabelComponent>(tape, out var labelComp))
{
if (labelComp.CurrentLabel != null)
cassetteName = labelComp.CurrentLabel;
}
}

var state = new TapeRecorderState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace Content.Shared._CD.TapeRecorder;
/// <summary>
/// Every chat event recorded on a tape is saved in this format
/// </summary>
[ImplicitDataDefinitionForInheritors]
[DataField]

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

Check failure on line 9 in Content.Shared/_CD/TapeRecorder/TapeCassetteRecordedMessage.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Attribute 'DataField' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.
public sealed partial class TapeCassetteRecordedMessage : IComparable<TapeCassetteRecordedMessage>
{
/// <summary>
/// Number of seconds since the start of the tape that this event was recorded at
/// </summary>
[DataField(required: true)]
public float Timestamp = 0;
public float Timestamp;

/// <summary>
/// The name of the entity that spoke
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@
- ForensicPad
- ForensicPad
- LogProbeCartridge
- TapeRecorder # CD Change
- CassetteTape # CD Change
- CassetteTape # CD Change
- BoxTapeRecorder

0 comments on commit 5eb9a94

Please sign in to comment.