Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
Crime Assist pda program (space-wizards#464)
Browse files Browse the repository at this point in the history
* Completely untested first commit

* Get basic program flow working

* Add Innocent

* Add Fancy Rich Text

* Icon

Thanks, IcedQuinn!

* Add Cartridge icons

* New image from IcedQuinn

* Add explanation on what a Sophont is, to be automatically appended to any text referencing a Sophont later on

* Convert tabs to spaces

* remove [bold] tags from loc

* Make text bold again

* Alter formatting, reduce text length for sophont explanation to fit it on the screen

* Update Resources/Locale/en-US/deltav/cartridge-loader/cartridges.ftl

Co-authored-by: Colin-Tel <[email protected]>
Signed-off-by: Tim Falken <[email protected]>

* Add program to more PDA's

* Add a tip about the app

* Recreate flow in yaml

todo: actually load and use this yaml

* Remove the old state machine, and add configurable yaml prototypes to define pages

* Move page to its own file

---------

Signed-off-by: Tim Falken <[email protected]>
Co-authored-by: Colin-Tel <[email protected]>
(cherry picked from commit b20eb07253b9c185d7928e96483304c36cb057a6)
  • Loading branch information
Peptide90 committed Feb 16, 2024
1 parent 652148b commit faca628
Show file tree
Hide file tree
Showing 16 changed files with 777 additions and 0 deletions.
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)!;
}
}
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()
{ }
}
120 changes: 120 additions & 0 deletions Resources/Locale/en-US/deltav/cartridge-loader/cartridges.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
crime-assist-program-name = Crime Assist
crime-assist-yes-button = Yes
crime-assist-no-button = No
crime-assist-crimetype-innocent = Innocent
crime-assist-crimetype-misdemeanour = Misdemeanour
crime-assist-crimetype-felony = Felony
crime-assist-crimetype-capital = Capital
crime-assist-crime-innocent = No crime was committed
crime-assist-crime-animalcruelty = Code 101: Animal Cruelty
crime-assist-crime-theft = Code 102: Theft
crime-assist-crime-trespass = Code 110: Trespass
crime-assist-crime-vandalism = Code 111: Vandalism
crime-assist-crime-hooliganism = Code 112: Hooliganism
crime-assist-crime-manslaughter = Code 201: Manslaughter
crime-assist-crime-grandtheft = Code 202: Grand Theft
crime-assist-crime-blackmarketeering = Code 203: Black Marketeering
crime-assist-crime-sabotage = Code 204: Sabotage
crime-assist-crime-mindbreaking = Code 205: Mindbreaking
crime-assist-crime-assault = Code 206: Assault
crime-assist-crime-abuseofpower = Code 207: Abuse of Power
crime-assist-crime-possession = Code 208: Possession
crime-assist-crime-endangerment = Code 209: Endangerment
crime-assist-crime-breakingandentering = Code 210: Breaking and Entering
crime-assist-crime-rioting = Code 211: Rioting
crime-assist-crime-contemptofcourt = Code 212: Contempt of Court
crime-assist-crime-perjuryfalsereport = Code 213: Perjury or False Report
crime-assist-crime-obstructionofjustice = Code 214: Obstruction of Justice
crime-assist-crime-murder = Code 301: Murder
crime-assist-crime-terrorism = Code 303: Terrorism
crime-assist-crime-grandsabotage = Code 304: Grand Sabotage
crime-assist-crime-decorporealisation = Code 305: Decorporealisation
crime-assist-crime-kidnapping = Code 309: Kidnapping
crime-assist-crime-sedition = Code 311: Sedition
crime-assist-crime-sexualharassment = Code 314: Sexual Harassment
crime-assist-mainmenu = Welcome to Crime Assist!
crime-assist-question-isitterrorism = Did the suspect hold hostages, cause many deaths or major destruction to force compliance from the crew?
crime-assist-question-wassomeoneattacked = Was an entity attacked?
crime-assist-question-wasitsophont = Was the victim in question a sophont?
crime-assist-question-didvictimdie = Did the victim die as a result to the attack?
crime-assist-question-isvictimremovedfrombody = Is the victim alive, but intentionally and permanently removed from the body?
crime-assist-question-wasdeathintentional = Did the suspect attack the victim with intent to kill?
crime-assist-question-forcedmindbreakertoxin = Was the victim forced to take Mindbreaker Toxin?
crime-assist-question-hadillicititem = Did the suspect have an illicit or controlled item, substance or entity?
crime-assist-question-wasitaperson = Did the suspect hold another sophont against its will?
crime-assist-question-wassuspectselling = Was the suspect selling or distributing the illicit items?
crime-assist-question-wassuspectseentaking = Can it be proven that the suspect took the item knowing that it was illegal for the suspect to possess the item?
crime-assist-question-isitemextremelydangerous = Is the item in question dangerous to other sophonts or the station as a whole?
crime-assist-question-wassuspectinarestrictedlocation = Was the suspect in a restricted location, or anywhere the suspect did not have legal access to?
crime-assist-question-wasentrancelocked = Did the suspect force through a locked access point to get to the location?
crime-assist-question-didsuspectbreaksomething = Did the suspect break something?
crime-assist-question-weretheremanysuspects = Were there many suspects in a group causing a disturbance?
crime-assist-question-wasdamagesmall = Was the damage minor, or easily undone?
crime-assist-question-wasdestroyeditemimportanttostation = Was the damaged or destroyed item important to the functioning of the station?
crime-assist-question-islargepartofstationdestroyed = Was a large part of the station destroyed or made uninhabitable?
crime-assist-question-wascrimesexualinnature = Was the crime sexual in nature?
crime-assist-question-wassuspectanuisance = Was the suspect being a nuisance to other sophonts?
crime-assist-question-falselyreportingtosecurity = Has the suspect made a report, in person or through radio channels, to security that was proven to be intentionally false?
crime-assist-question-happenincourt = Was the suspect a nuisance in court?
crime-assist-question-duringactiveinvestigation = Was the suspect a nuisance during an active investigation, and hindered the investigation as a result?
crime-assist-question-tocommandstaff = Did the suspect overthrow or compromise a lawfully established Chain of Command, or attempt to do so?
crime-assist-question-wasitcommanditself = Was a command staff or department head abusing authority over another sophont?
crime-assist-crimedetail-innocent = Crime could not be determined. Use your best judgement to resolve the situation.
crime-assist-crimedetail-animalcruelty = To inflict unnecessary suffering on a sapient being with malicious intent.
crime-assist-crimedetail-theft = To unlawfully take property or items without consent.
crime-assist-crimedetail-trespass = To enter into an area where one is not authorised nor invited.
crime-assist-crimedetail-vandalism = To deface or superficially damage public property, or property belonging to another person.
crime-assist-crimedetail-hooliganism = To intentionally and maliciously engage in disruptive conduct, where one refuses to cease.
crime-assist-crimedetail-manslaughter = To effect violence upon a sophont, resulting in their death, without the apparent intent to kill them.
crime-assist-crimedetail-grandtheft = To unlawfully take highly restricted, dangerous, valuable, or highly sensitive property or items without consent.
crime-assist-crimedetail-blackmarketeering = To sell, distribute, or otherwise circulate restricted items or substances to unauthorised sophonts or entities.
crime-assist-crimedetail-sabotage = To engage in malicious actions that directly or indirectly hinder the operation of a vessel or its part, modify and/or damage technology one is not authorised to access, or endanger multiple sophonts.
crime-assist-crimedetail-mindbreaking = To unlawfully and maliciously rid a psionic sophont of their powers.
crime-assist-crimedetail-assault = To cause physical harm or to effect unwanted physical contact on a sophont, without the apparent intent to kill them, or to threaten such actions with both capability and intent to do so.
crime-assist-crimedetail-abuseofpower = To intentionally misuse or wrongfully exercise one’s own authority, influence, or control, resulting in harm, unjust treatment, or demonstrable loss to a separate party due to violation of ethical and professional standards.
crime-assist-crimedetail-possession = To be in unauthorised possession of restricted items or items of particular danger.
crime-assist-crimedetail-endangerment = To recklessly abandon obligations involving the continued wellbeing and/or protection of life and property, through malpractice, action, or inaction.
crime-assist-crimedetail-breakingandentering = To break and enter into a high security area where one is not authorised nor invited, with intent to commit a crime within.
crime-assist-crimedetail-rioting = To partake in an unauthorised riotous, tumultuous, and disruptive public assembly that refuses to disperse after warning.
crime-assist-crimedetail-contemptofcourt = To conduct oneself disruptively and disrespectfully before the court.
crime-assist-crimedetail-perjuryfalsereport = To wilfully and maliciously tell an untruth either in court or in the process of making an actionable report to law enforcement.
crime-assist-crimedetail-obstructionofjustice = To wilfully disobey, interfere with, or refuse a decree of the court, warrant, or arrest.
crime-assist-crimedetail-murder = To kill a sophont with malicious intent and premeditation.
crime-assist-crimedetail-terrorism = To commit an act with the intent to cause injury or death, or to take hostages, in order to provoke a state of terror in, intimidate, or compel a group of sophonts to do or to abstain from doing any act.
crime-assist-crimedetail-grandsabotage = To engage in malicious actions that directly or indirectly make uninhabitable or inoperable a vessel or its part, or irreversibly modify and/or damage technology one is not authorised to access, causing severe bodily harm or death to multiple sophonts.
crime-assist-crimedetail-decorporealisation = To unlawfully, maliciously, and permanently strip a sophont’s mind from their body.
crime-assist-crimedetail-kidnapping = To unlawfully confine or restrict the free movement of a sophont against their will.
crime-assist-crimedetail-sedition = To act to overthrow a lawfully established Chain of Command or governing body without lawful or legitimate cause.
crime-assist-crimedetail-sexualharassment = To sexually harass, attempt to coerce into sexual relations, or effect unwanted sexual contact with an unwilling sophont.
crime-assist-crimepunishment-innocent = No punishment may be necessary
crime-assist-crimepunishment-animalcruelty = Punishment: 3 minutes
crime-assist-crimepunishment-theft = Punishment: 2 minutes
crime-assist-crimepunishment-trespass = Punishment: 2 minutes
crime-assist-crimepunishment-vandalism = Punishment: 2 minutes
crime-assist-crimepunishment-hooliganism = Punishment: As necessary
crime-assist-crimepunishment-manslaughter = Punishment: 8 minutes
crime-assist-crimepunishment-grandtheft = Punishment: 8 minutes
crime-assist-crimepunishment-blackmarketeering = Punishment: 6 minutes
crime-assist-crimepunishment-sabotage = Punishment: 6 minutes
crime-assist-crimepunishment-mindbreaking = Punishment: 5 minutes
crime-assist-crimepunishment-assault = Punishment: 5 minutes
crime-assist-crimepunishment-abuseofpower = Punishment: 5 minutes
crime-assist-crimepunishment-possession = Punishment: Up to 5 minutes
crime-assist-crimepunishment-endangerment = Punishment: 4 minutes
crime-assist-crimepunishment-breakingandentering = Punishment: 4 minutes
crime-assist-crimepunishment-rioting = Punishment: 4 minutes
crime-assist-crimepunishment-contemptofcourt = Punishment: 4 minutes
crime-assist-crimepunishment-perjuryfalsereport = Punishment: 3 minutes
crime-assist-crimepunishment-obstructionofjustice = Punishment: 2 minutes
crime-assist-crimepunishment-murder = Punishment: Capital
crime-assist-crimepunishment-terrorism = Punishment: Capital
crime-assist-crimepunishment-grandsabotage = Punishment: Capital
crime-assist-crimepunishment-decorporealisation = Punishment: Capital
crime-assist-crimepunishment-kidnapping = Punishment: Capital
crime-assist-crimepunishment-sedition = Punishment: Capital
crime-assist-crimepunishment-sexualharassment = Punishment: Capital
crime-assist-sophont-explanation = A sophont is described as any entity with the capacity to display the following attributes:
• [bold]Sapience[/bold]: the entity possesses basic logic and problem-solving skills, or at a minimum some level of significant intelligence.
• [bold]Sentience[/bold]: the entity has the capacity to process an emotion or lack thereof, or at a minimum the ability to recognise its own pain.
• [bold]Self-awareness[/bold]: the entity is capable of altering its behaviour in a reasonable fashion as a result of stimuli, or at a minimum is capable of recognising its own sapience and sentience.
Any sophont is considered a legal person, regardless of origin or prior cognitive status. Much like any other intelligent organic, a sophont may press charges against crew and be tried for crimes.
Loading

0 comments on commit faca628

Please sign in to comment.