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

Crime Assist pda program (DeltaV) #993

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b20eb07
Crime Assist pda program (#464)
Timfa2112 Dec 29, 2023
7ace640
Building up
dvir001 Dec 31, 2023
809263b
Fixing
dvir001 Dec 31, 2023
c666777
Fix Crime Assist incorrect entires and add a test (#624)
DebugOk Dec 31, 2023
286732a
Delete pda.yml
dvir001 Dec 31, 2023
2f2be1c
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Jan 14, 2024
04f1c9d
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 Jan 22, 2024
7134267
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 Jan 24, 2024
d813411
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 Jan 26, 2024
5e497c0
Merge branch '2023-12-31-CrimeApp' of https://github.com/dvir001/fron…
dvir001 Feb 9, 2024
8ccd4db
Edit ID and PDA
dvir001 Feb 9, 2024
58b4593
Update meta.json
dvir001 Feb 9, 2024
1ab04a2
Remove Unused
dvir001 Feb 9, 2024
561d847
Merge branch '2023-12-31-CrimeApp' of https://github.com/dvir001/fron…
dvir001 Feb 9, 2024
f22473d
Update pda.yml
dvir001 Feb 9, 2024
43083e3
yml
dvir001 Feb 9, 2024
959d798
icons
dvir001 Feb 9, 2024
b75df1d
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Mar 25, 2024
919b4e0
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 Mar 27, 2024
71c8eec
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Apr 4, 2024
2cf3b2f
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Apr 27, 2024
b1678fc
Merge branch 'master' of https://github.com/dvir001/frontier-station-…
dvir001 May 3, 2024
a30a1ad
Update pda.yml
dvir001 May 3, 2024
c6ae797
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 May 15, 2024
f25310c
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 May 17, 2024
7a4abb7
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 May 17, 2024
7df5306
Merge branch 'new-frontiers-14:master' into 2023-12-31-CrimeApp
dvir001 May 17, 2024
0e1b422
Update prisonguard.yml
dvir001 May 17, 2024
b607e02
Update job.yml
dvir001 May 17, 2024
7a1e1bf
Update job.yml
dvir001 May 17, 2024
9f005eb
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Jul 10, 2024
7004fa8
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 4, 2024
2916d9f
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 6, 2024
a0ecea0
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 10, 2024
d5e2353
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 12, 2024
c34b1f6
Update prisonguard.yml
dvir001 Aug 12, 2024
ed404f8
Update pda.yml
dvir001 Aug 12, 2024
1e7528c
Update cart.yml
dvir001 Aug 12, 2024
b2cb917
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 13, 2024
7985c3c
cartridges.ftl: updates from Salvantrix
whatston3 Aug 13, 2024
0b0e263
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 17, 2024
0affd3c
Merge branch 'master' of https://github.com/dvir001/frontier-station-…
dvir001 Aug 23, 2024
f1d9acc
Update cartridges.yml
dvir001 Aug 23, 2024
80182a9
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 23, 2024
9c0782e
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Aug 24, 2024
dccb5bc
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Oct 1, 2024
d75929c
Merge branch 'master' into 2023-12-31-CrimeApp
whatston3 Oct 6, 2024
218b772
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Oct 13, 2024
fb0d463
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Oct 21, 2024
3803f27
Merge branch 'master' into 2023-12-31-CrimeApp
dvir001 Nov 6, 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
35 changes: 35 additions & 0 deletions Content.Client/DeltaV/CartridgeLoader/Cartridges/CrimeAssistUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Robust.Client.UserInterface;
using Content.Client.UserInterface.Fragments;
using Content.Shared.DeltaV.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader;
using Robust.Shared.Prototypes;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

public sealed partial class CrimeAssistUi : UIFragment
{
private CrimeAssistUiFragment? _fragment;

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

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)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<cartridges:CrimeAssistUiFragment xmlns:cartridges="clr-namespace:Content.Client.DeltaV.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:CrimeAssistUiFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
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;
using static Content.Client.DeltaV.CartridgeLoader.Cartridges.CrimeAssistUi;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
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;

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

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

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

_currentPage = FindPageById("mainmenu");
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(CrimeAssistPage currentPage, bool yesPressed)
{
UpdateUI(yesPressed ? FindPageById(currentPage.OnYes!) : FindPageById(currentPage.OnNo!));
}

public void UpdateUI(CrimeAssistPage 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 CrimeAssistPage FindPageById(string id)
{
return _pages?.Find(o => o.ID == id)!;
}
}
79 changes: 79 additions & 0 deletions Content.IntegrationTests/Tests/DeltaV/CrimeassistTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Linq;
using Content.Shared.DeltaV.CartridgeLoader.Cartridges;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.DeltaV;

[TestFixture]
public sealed class CrimeAssistTest
{
[Test]
public async Task CrimeAssistValid()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
await server.WaitIdleAsync();

var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var allProtos = prototypeManager.EnumeratePrototypes<CrimeAssistPage>().ToArray();

await server.WaitAssertion(() =>
{
foreach (var proto in allProtos)
{
if (proto.LocKey != null)
{
Assert.That(Loc.TryGetString(proto.LocKey, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKey {proto.LocKey}!");
}

if (proto.LocKeyTitle != null)
{
Assert.That(Loc.TryGetString(proto.LocKeyTitle, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeyTitle {proto.LocKeyTitle}!");
}

if (proto.LocKeyDescription != null)
{
Assert.That(Loc.TryGetString(proto.LocKeyDescription, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeyDescription {proto.LocKeyDescription}!");
}

if (proto.LocKeySeverity != null)
{
Assert.That(Loc.TryGetString(proto.LocKeySeverity, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeySeverity {proto.LocKeySeverity}!");
}

if (proto.LocKeyPunishment != null)
{
Assert.That(Loc.TryGetString(proto.LocKeyPunishment, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeyPunishment {proto.LocKeyPunishment}!");
}

if (proto.OnStart != null)
{
Assert.That(allProtos.Any(p => p.ID == proto.OnStart),
$"CrimeAssistPage {proto.ID} has invalid OnStart {proto.OnStart}!");
}

if (proto.OnYes != null)
{
Assert.That(allProtos.Any(p => p.ID == proto.OnYes),
$"CrimeAssistPage {proto.ID} has invalid OnYes {proto.OnYes}!");
}

if (proto.OnNo != null)
{
Assert.That(allProtos.Any(p => p.ID == proto.OnNo),
$"CrimeAssistPage {proto.ID} has invalid OnNo {proto.OnNo}!");
}
}
});

await pair.CleanReturnAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Content.Server.DeltaV.CartridgeLoader.Cartridges;

[RegisterComponent]
public sealed partial class CrimeAssistCartridgeComponent : Component
{ }
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.CartridgeLoader;
using Content.Server.DeltaV.CartridgeLoader;
using Content.Server.CartridgeLoader.Cartridges;
using Content.Server.CartridgeLoader;

namespace Content.Server.DeltaV.CartridgeLoader.Cartridges;

public sealed class CrimeAssistCartridgeSystem : EntitySystem
{
[Dependency] private readonly CartridgeLoaderSystem? _cartridgeLoaderSystem = default!;

public override void Initialize()
{
base.Initialize();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Robust.Shared.Prototypes;

namespace Content.Shared.DeltaV.CartridgeLoader.Cartridges;

[Prototype("crimeAssistPage")]
public sealed partial class CrimeAssistPage : IPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = "";

[DataField("onStart")]
public string? OnStart { get; private set; }

[DataField("locKey")]
public string? LocKey { get; private set; }

[DataField("onYes")]
public string? OnYes { get; private set; }

[DataField("onNo")]
public string? OnNo { get; private set; }

[DataField("locKeyTitle")]
public string? LocKeyTitle { get; private set; }

[DataField("locKeyDescription")]
public string? LocKeyDescription { get; private set; }

[DataField("locKeySeverity")]
public string? LocKeySeverity { get; private set; }

[DataField("locKeyPunishment")]
public string? LocKeyPunishment { get; private set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Content.Shared.CartridgeLoader;
using Robust.Shared.Serialization;

namespace Content.Shared.DeltaV.CartridgeLoader.Cartridges;

[Serializable, NetSerializable]
public sealed class CrimeAssistUiState : BoundUserInterfaceState
{
public CrimeAssistUiState()
{ }
}

[Serializable, NetSerializable]
public sealed class CrimeAssistSyncMessageEvent : CartridgeMessageEvent
{
public CrimeAssistSyncMessageEvent()
{ }
}
Loading
Loading