Skip to content

Commit

Permalink
Merge branch 'master' into CPR-Remake
Browse files Browse the repository at this point in the history
Signed-off-by: VMSolidus <[email protected]>
  • Loading branch information
VMSolidus authored Jul 5, 2024
2 parents eb4ecaf + d971e7c commit 5528e7b
Show file tree
Hide file tree
Showing 68 changed files with 983 additions and 295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ public override Control GetUIFragmentRoot()
public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new CrimeAssistUiFragment();

_fragment.OnSync += _ => SendSyncMessage(userInterface);
}

private void SendSyncMessage(BoundUserInterface userInterface)
{
var syncMessage = new CrimeAssistSyncMessageEvent();
var message = new CartridgeUiMessage(syncMessage);
userInterface.SendMessage(message);
}

public override void UpdateState(BoundUserInterfaceState state)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Client.Message;
using Content.Shared.DeltaV.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
Expand All @@ -13,9 +12,7 @@ namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;
public sealed partial class CrimeAssistUiFragment : BoxContainer
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;

public event Action<bool>? OnSync;
private CrimeAssistPage _currentPage;
private List<CrimeAssistPage>? _pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:cartridges="clr-namespace:Content.Client.DeltaV.CartridgeLoader.Cartridges"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
HorizontalExpand="True"
VerticalExpand="True"
Margin="5">
<!-- All labels populated in constructor -->
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left">
<BoxContainer Orientation="Vertical">
<Label Name="Status"/>
<Label Text="{Loc 'criminal-records-console-reason'}"/>
</BoxContainer>
<customControls:VSeparator StyleClasses="LowDivider" Margin="8 0"/>
<BoxContainer Orientation="Vertical">
<Label Name="Title"/>
<Label Name="Reason"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class SecWatchEntryControl : BoxContainer
{
public SecWatchEntryControl(SecWatchEntry entry)
{
RobustXamlLoader.Load(this);

Status.Text = Loc.GetString($"criminal-records-status-{entry.Status.ToString().ToLower()}");
Title.Text = Loc.GetString("sec-watch-entry", ("name", entry.Name), ("job", entry.Job));

Reason.Text = entry.Reason ?? Loc.GetString("sec-watch-no-reason");
}
}
27 changes: 27 additions & 0 deletions Content.Client/DeltaV/CartridgeLoader/Cartridges/SecWatchUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

public sealed partial class SecWatchUi : UIFragment
{
private SecWatchUiFragment? _fragment;

public override Control GetUIFragmentRoot()
{
return _fragment!;
}

public override void Setup(BoundUserInterface ui, EntityUid? owner)
{
_fragment = new SecWatchUiFragment();
}

public override void UpdateState(BoundUserInterfaceState state)
{
if (state is SecWatchUiState cast)
_fragment?.UpdateState(cast);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<cartridges:SecWatchUiFragment xmlns="https://spacestation14.io"
xmlns:cartridges="clr-namespace:Content.Client.DeltaV.CartridgeLoader.Cartridges"
Margin="5"
VerticalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<Label Text="{Loc 'sec-watch-title'}" HorizontalExpand="True" HorizontalAlignment="Center"/>
<Label Name="NoEntries" Text="{Loc 'sec-watch-no-entries'}" HorizontalExpand="True" HorizontalAlignment="Center" Visible="False"/>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
<!-- Populated when state received -->
<BoxContainer Name="Entries" Orientation="Vertical" VerticalAlignment="Top"/>
</ScrollContainer>
</BoxContainer>
</cartridges:SecWatchUiFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class SecWatchUiFragment : BoxContainer
{
public SecWatchUiFragment()
{
RobustXamlLoader.Load(this);
}

public void UpdateState(SecWatchUiState state)
{
NoEntries.Visible = state.Entries.Count == 0;
Entries.RemoveAllChildren();
foreach (var entry in state.Entries)
{
Entries.AddChild(new SecWatchEntryControl(entry));
}
}
}
5 changes: 4 additions & 1 deletion Content.Client/Inventory/StrippableBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Player;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
Expand All @@ -31,6 +32,7 @@ namespace Content.Client.Inventory
public sealed class StrippableBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IUserInterfaceManager _ui = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly ExamineSystem _examine;
private readonly InventorySystem _inv;
private readonly SharedCuffableSystem _cuffable;
Expand Down Expand Up @@ -198,7 +200,8 @@ private void AddInventoryButton(EntityUid invUid, string slotId, InventoryCompon
var entity = container.ContainedEntity;

// If this is a full pocket, obscure the real entity
if (entity != null && slotDef.StripHidden)
if (entity != null && slotDef.StripHidden
&& !(EntMan.TryGetComponent<ThievingComponent>(_playerManager.LocalEntity, out var thiefcomponent) && thiefcomponent.IgnoreStripHidden))
entity = _virtualHiddenEntity;

var button = new SlotButton(new SlotData(slotDef, container));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ void AddSelector(LoadoutPreferenceSelector selector, int points, string id)
selector.PreferenceChanged += preference =>
{
// Make sure they have enough loadout points
preference = preference ? CheckPoints(points, preference) : CheckPoints(-points, preference);
preference = preference ? CheckPoints(-points, preference) : CheckPoints(points, preference);
// Update Preferences
Profile = Profile?.WithLoadoutPreference(id, preference);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.Security;

namespace Content.Server.CartridgeLoader.Cartridges;

[RegisterComponent, Access(typeof(SecWatchCartridgeSystem))]
public sealed partial class SecWatchCartridgeComponent : Component
{
/// <summary>
/// Only show people with these statuses.
/// </summary>
[DataField]
public List<SecurityStatus> Statuses = new()
{
SecurityStatus.Suspected,
SecurityStatus.Wanted
};

/// <summary>
/// Station entity thats getting its records checked.
/// </summary>
[DataField]
public EntityUid? Station;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Content.Server.Station.Systems;
using Content.Server.StationRecords;
using Content.Server.StationRecords.Systems;
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.CriminalRecords;
using Content.Shared.StationRecords;

namespace Content.Server.CartridgeLoader.Cartridges;

public sealed class SecWatchCartridgeSystem : EntitySystem
{
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoader = default!;
[Dependency] private readonly StationRecordsSystem _records = default!;
[Dependency] private readonly StationSystem _station = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RecordModifiedEvent>(OnRecordModified);

SubscribeLocalEvent<SecWatchCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady);
}

private void OnRecordModified(RecordModifiedEvent args)
{
// when a record is modified update the ui of every loaded cartridge tuned to the same station
var query = EntityQueryEnumerator<SecWatchCartridgeComponent, CartridgeComponent>();
while (query.MoveNext(out var uid, out var comp, out var cartridge))
{
if (cartridge.LoaderUid is not {} loader || comp.Station != args.Station)
continue;

UpdateUI((uid, comp), loader);
}
}

private void OnUiReady(Entity<SecWatchCartridgeComponent> ent, ref CartridgeUiReadyEvent args)
{
UpdateUI(ent, args.Loader);
}

private void UpdateUI(Entity<SecWatchCartridgeComponent> ent, EntityUid loader)
{
// if the loader is on a grid, update the station
// if it is off grid use the cached station
if (_station.GetOwningStation(loader) is {} station)
ent.Comp.Station = station;

if (!TryComp<StationRecordsComponent>(ent.Comp.Station, out var records))
return;

station = ent.Comp.Station.Value;

var entries = new List<SecWatchEntry>();
foreach (var (id, criminal) in _records.GetRecordsOfType<CriminalRecord>(station, records))
{
if (!ent.Comp.Statuses.Contains(criminal.Status))
continue;

var key = new StationRecordKey(id, station);
if (!_records.TryGetRecord<GeneralStationRecord>(key, out var general, records))
continue;

var status = criminal.Status;
entries.Add(new SecWatchEntry(general.Name, general.JobTitle, criminal.Status, criminal.Reason));
}

var state = new SecWatchUiState(entries);
_cartridgeLoader.UpdateCartridgeUiState(loader, state);
}
}

This file was deleted.

This file was deleted.

8 changes: 8 additions & 0 deletions Content.Server/DeltaV/Paper/SignAttemptEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server.DeltaV.Paper;

/// <summary>
/// Raised on the pen when trying to sign a paper.
/// If it's cancelled the signature wasn't made.
/// </summary>
[ByRefEvent]
public record struct SignAttemptEvent(EntityUid Paper, EntityUid User, bool Cancelled = false);
Loading

0 comments on commit 5528e7b

Please sign in to comment.