Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFSD Criminal Records Fix + Shipyard Fax Records System #1578

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dcc6418
Criminal Records initial WIP
Qulibly Apr 26, 2024
32c844f
Criminal Records and job icon fixup
Qulibly Apr 26, 2024
7d0b1fe
Shipyard record added extra info to papers
Qulibly May 4, 2024
79aa222
Merge branch 'nfsd-criminal-records' of https://github.com/Qulibly/fr…
Qulibly Jun 29, 2024
6935ef9
Merge branch 'new-frontiers-14:master' into nfsd-criminal-records
Qulibly Jun 29, 2024
8a35e77
Merge branch 'nfsd-criminal-records' of https://github.com/Qulibly/fr…
Qulibly Jun 29, 2024
26b2d48
Criminal and Shipyard records minor fixes
Qulibly Jun 29, 2024
28d683b
Merge branch 'master' into nfsd-criminal-records
dvir001 Jul 1, 2024
4575b92
Criminal and Shipyard records fax error fix
Qulibly Jul 13, 2024
ea5f81b
Merge branch 'master' into nfsd-criminal-records
Qulibly Jul 13, 2024
0e405ee
Merge branch 'nfsd-criminal-records' of https://github.com/Qulibly/fr…
Qulibly Jul 13, 2024
f90ef86
Criminal and Shipyard records fax vessel class integration
Qulibly Jul 13, 2024
5ddb0e4
Criminal and Shipyard records fax record paper and illegal informatio…
Qulibly Jul 14, 2024
c7eab94
Criminal and Shipyard records fax paper and antag record cleanup
Qulibly Jul 16, 2024
723c064
Criminal and Shipyard records fax implementing sector records to NFSD…
Qulibly Jul 16, 2024
e465e45
Update prospector.yml
Qulibly Jul 16, 2024
cb0cce2
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Jul 25, 2024
0fa617a
Merge branch 'master' into nfsd-criminal-records
dvir001 Aug 4, 2024
9260aab
Merge branch 'master' into nfsd-criminal-records
dvir001 Aug 6, 2024
f72e196
Merge branch 'master' into nfsd-criminal-records
Qulibly Aug 12, 2024
a5b1456
Shipyard Record ShipConnect PDA APP WIP
Qulibly Oct 1, 2024
7c3f280
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Oct 1, 2024
354d0b1
Merge branch 'master' into nfsd-criminal-records
whatston3 Oct 6, 2024
3183dd0
Merge branch 'master' into nfsd-criminal-records
dvir001 Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Content.Client/CartridgeLoader/Cartridges/NF_ShipConnectUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Robust.Client.UserInterface;
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader;
using Robust.Shared.Prototypes;

namespace Content.Client.CartridgeLoader.Cartridges;

public sealed partial class NF_ShipConnectUi : UIFragment
{
private NF_ShipConnectUiFragment? _fragment;

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

public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new NF_ShipConnectUiFragment();

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

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

public override void UpdateState(BoundUserInterfaceState state)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<cartridges:NF_ShipConnectUiFragment xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
xmlns="https://spacestation14.io" Margin="1 0 2 0">
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Name="ExplanationBox" Orientation="Vertical" MaxWidth="400" VerticalExpand="True" Margin="5">
<RichTextLabel Name ="Title" />
<RichTextLabel Name ="Subtitle"/>
<RichTextLabel Name ="Explanation"/>
<RichTextLabel Name ="Punishment" Margin="0,20"/>
</BoxContainer>
<BoxContainer Name="QuestionBox" Orientation="Horizontal" HorizontalAlignment="Center" HorizontalExpand="True" VerticalExpand="False">
<Button Name="StartButton" Access="Public" Text="Start"/>
<Button Name="HomeButton" Access="Public" Text="Home" Visible="False"/>
<Button Name="YesButton" Access="Public" Text="Yes" Visible="False"/>
<Button Name="NoButton" Access="Public" Text="No" Visible="False"/>
</BoxContainer>
</cartridges:NF_ShipConnectUiFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using Content.Client.Message;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using static Content.Client.CartridgeLoader.Cartridges.NF_ShipConnectUi;

namespace Content.Client.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class NF_ShipConnectUiFragment : BoxContainer
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;

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

public NF_ShipConnectUiFragment()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

Orientation = LayoutOrientation.Vertical;
HorizontalExpand = true;
VerticalExpand = true;

_pages = new List<NF_ShipConnectPage>(_prototypeManager.EnumeratePrototypes<NF_ShipConnectPage>());

_currentPage = FindPageById("mainmenu");//ISSUE SOMEWHERE HERE
UpdateUI(_currentPage);

StartButton.OnPressed += _ => UpdateUI(FindPageById(FindPageById("mainmenu").OnStart!));
HomeButton.OnPressed += _ => UpdateUI(FindPageById("mainmenu"));
YesButton.OnPressed += _ => AdvanceState(_currentPage!, true);
NoButton.OnPressed += _ => AdvanceState(_currentPage!, false);
}

public void AdvanceState(NF_ShipConnectPage currentPage, bool yesPressed)
{
UpdateUI(yesPressed ? FindPageById(currentPage.OnYes!) : FindPageById(currentPage.OnNo!));
}

public void UpdateUI(NF_ShipConnectPage page)
{
_currentPage = page;
bool isResult = page.LocKeyPunishment != null;

StartButton.Visible = page.OnStart != null;
YesButton.Visible = page.OnYes != null;
NoButton.Visible = page.OnNo != null;
HomeButton.Visible = page.OnStart == null;
Explanation.Visible = page.OnStart == null;

Subtitle.Visible = page.LocKeySeverity != null;
Punishment.Visible = page.LocKeyPunishment != null;

if (!isResult)
{
string question = $"\n[font size=15]{Loc.GetString(page.LocKey!)}[/font]";

if (question.ToLower().Contains("sophont"))
{
string sophontExplanation = Loc.GetString("crime-assist-sophont-explanation");
question += $"\n[font size=8][color=#999999]{sophontExplanation}[/color][/font]";
}

Title.SetMarkup(question);
Subtitle.SetMarkup(string.Empty);
Explanation.SetMarkup(string.Empty);
Punishment.SetMarkup(string.Empty);
}
else
{
string color = page.LocKeySeverity! switch
{
"crime-assist-crimetype-innocent" => "#39a300",
"crime-assist-crimetype-misdemeanour" => "#7b7b30",
"crime-assist-crimetype-felony" => "#7b5430",
"crime-assist-crimetype-capital" => "#7b2e30",
_ => "#ff00ff"
};

Title.SetMarkup("\n[bold][font size=23][color=#a4885c]" + Loc.GetString(page.LocKeyTitle!) + "[/color][/font][/bold]");
Subtitle.SetMarkup($"\n[font size=19][color={color}]" + Loc.GetString(page.LocKeySeverity!) + "[/color][/font]");
Explanation.SetMarkup("\n[title]" + Loc.GetString(page.LocKeyDescription!) + "[/title]\n");
Punishment.SetMarkup("[bold][font size=15]" + Loc.GetString(page.LocKeyPunishment!) + "[/font][/bold]");
}
}

private NF_ShipConnectPage FindPageById(string id)
{
return _pages?.Find(o => o.ID == id)!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Server.CartridgeLoader.Cartridges;

[RegisterComponent, Access(typeof(NF_ShipConnectCartridgeSystem))]
public sealed partial class NF_ShipConnectCartridgeComponent : Component
{
/// <summary>
/// Station entity keeping track of logistics stats
/// </summary>
[DataField]
public EntityUid? Station;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using Content.Server.Station.Systems;
using Content.Server.CartridgeLoader;
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;

namespace Content.Server.CartridgeLoader.Cartridges;

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

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

SubscribeLocalEvent<NF_ShipConnectCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady);
SubscribeLocalEvent<NF_ShipConnectCartridgeComponent, CartridgeMessageEvent>(OnUiMessage);
//SubscribeLocalEvent<LogisticStatsUpdatedEvent>(OnLogisticsStatsUpdated);
//SubscribeLocalEvent<MailComponent, ComponentInit>(OnComponentInit);
}

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

/*private void OnLogisticsStatsUpdated(LogisticStatsUpdatedEvent args)
{
UpdateAllCartridges(args.Station);
}*/

/*private void OnComponentInit(EntityUid uid, MailComponent mail, ComponentInit args)
{
var stationUid = _station.GetOwningStation(uid);
if (stationUid != null)
UpdateAllCartridges((EntityUid) stationUid);
}*/

private void UpdateAllCartridges(EntityUid station)
{
var query = EntityQueryEnumerator<NF_ShipConnectCartridgeComponent, CartridgeComponent>();
while (query.MoveNext(out var uid, out var comp, out var cartridge))
{
if (cartridge.LoaderUid is not { } loader || comp.Station != station)
continue;
UpdateUI((uid, comp), loader);
}
}

private void UpdateUI(Entity<NF_ShipConnectCartridgeComponent> ent, EntityUid loader)
{
if (_station.GetOwningStation(loader) is { } station)
ent.Comp.Station = station;
//Use this to get info from server
//if (!TryComp<StationLogisticStatsComponent>(ent.Comp.Station, out var logiStats))
// return;

// Get station's logistic stats
/*var mailEarnings = logiStats.MailEarnings;
var damagedMailLosses = logiStats.DamagedMailLosses;
var expiredMailLosses = logiStats.ExpiredMailLosses;
var tamperedMailLosses = logiStats.TamperedMailLosses;
var openedMailCount = logiStats.OpenedMailCount;
var damagedMailCount = logiStats.DamagedMailCount;
var expiredMailCount = logiStats.ExpiredMailCount;
var tamperedMailCount = logiStats.TamperedMailCount;
var unopenedMailCount = GetUnopenedMailCount();*/

// Send logistic stats to cartridge client/NF_ShipConnectUiState
/*var state = new MailMetricUiState(mailEarnings,
damagedMailLosses,
expiredMailLosses,
tamperedMailLosses,
openedMailCount,
damagedMailCount,
expiredMailCount,
tamperedMailCount,
unopenedMailCount);
_cartridgeLoader.UpdateCartridgeUiState(loader, state);*/
}

private void OnUiMessage(EntityUid uid, NF_ShipConnectCartridgeComponent component, CartridgeMessageEvent args)
{
UpdateUiState(uid, GetEntity(args.LoaderUid), component);
}

private void UpdateUiState(EntityUid uid, EntityUid loaderUid, NF_ShipConnectCartridgeComponent? component)
{
if (!Resolve(uid, ref component))
return;

/* var owningStation = _stationSystem.GetOwningStation(uid);

if (owningStation is null)
return;

var (stationName, entries) = _crewManifest.GetCrewManifest(owningStation.Value);

var state = new CrewManifestUiState(stationName, entries);
_cartridgeLoader.UpdateCartridgeUiState(loaderUid, state); ///IMPORTANT UPDATE*/
}
}
28 changes: 27 additions & 1 deletion Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
using Content.Server.Station.Components;
using System.Text.RegularExpressions;
using Content.Shared.UserInterface;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Content.Shared.Access;
using Content.Server.Fax;
using Content.Shared.Tiles;
using Content.Server._NF.Smuggling.Components;

Expand Down Expand Up @@ -259,6 +259,32 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component
_records.Synchronize(shuttleStation!.Value);
_records.Synchronize(station);

//Sends vessel details to all dedicated faxes
if (_mind.TryGetMind(args.Actor, out var _mindUid, out var _mindComp)
&& _prefManager.GetPreferences(_mind.GetSession(_mindComp)!.UserId).SelectedCharacter is HumanoidCharacterProfile _profile)
{
var metaData = MetaData((EntityUid) shuttleStation);
name = metaData.EntityName;

TryComp<FingerprintComponent>(player, out var _fingerprintComponent);
TryComp<DnaComponent>(player, out var _dnaComponent);

var faxQuery = EntityQueryEnumerator<ShipyardRecordPaperComponent>();

string vesselClass = "Undetermined";
if (vessel.Classes.Count > 0)
vesselClass = vessel.Classes[0].ToString();

while (faxQuery.MoveNext(out var faxUid, out var recordPaperComp))
{
var ev = new ShipyardRecordPaperTransmitEvent(name, _profile.Name, _profile.Species, _profile.Gender, _profile.Age, _fingerprintComponent!.Fingerprint!, _dnaComponent!.DNA!, vessel.Category.ToString(), vesselClass, vessel.Group.ToString(), vessel.Price, vessel.Description);
RaiseLocalEvent(faxUid, ref ev);
}
}

//if (ShipyardConsoleUiKey.Security == (ShipyardConsoleUiKey) args.UiKey) Enable in the case we force this on every security ship
// EnsureComp<StationEmpImmuneComponent>(shuttle.Owner); Enable in the case we force this on every security ship

// Shuttle setup: add protected grid status if needed.
if (vessel.GridProtection != GridProtectionFlags.None)
{
Expand Down
Loading
Loading