Skip to content

Commit

Permalink
make CrimeAssistPage use LocId and ProtoId instead of a test (#2100)
Browse files Browse the repository at this point in the history
* make CrimeAssistPage use LocId and ProtoId instead of a test

* use an enum instead of le funny

* use enums in the prototypes

* rust

Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com>

* fix

* untroll engine

* actually fix spelling

* lovely language

---------

Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
  • Loading branch information
deltanedas authored Jan 2, 2025
1 parent 81fc3a9 commit a23928c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void UpdateUI(CrimeAssistPage page)
HomeButton.Visible = page.OnStart == null;
Explanation.Visible = page.OnStart == null;

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

if (!isResult)
Expand All @@ -72,19 +72,21 @@ public void UpdateUI(CrimeAssistPage page)
}
else
{
string color = page.LocKeySeverity! switch
var severity = page.CrimeSeverity!.Value;
var color = severity switch
{
"crime-assist-crimetype-innocent" => "#39a300",
"crime-assist-crimetype-misdemeanour" => "#7b7b30",
"crime-assist-crimetype-felony" => "#7b5430",
"crime-assist-crimetype-capital" => "#7b2e30",
CrimeSeverity.Innocent => "#39a300",
CrimeSeverity.Misdemeanour => "#7b7b30",
CrimeSeverity.Felony => "#7b5430",
CrimeSeverity.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]");
var severityName = Loc.GetString("crime-assist-crimetype-" + severity.ToString().ToLower());
Title.SetMarkup($"\n[bold][font size=23][color=#a4885c]{Loc.GetString(page.LocKeyTitle!)}[/color][/font][/bold]");
Subtitle.SetMarkup($"\n[font size=19][color={color}]{severityName}[/color][/font]");
Explanation.SetMarkup($"\n[title]{Loc.GetString(page.LocKeyDescription!)}[/title]\n");
Punishment.SetMarkup($"[bold][font size=15]{Loc.GetString(page.LocKeyPunishment!)}[/font][/bold]");
}
}

Expand Down
43 changes: 27 additions & 16 deletions Content.Shared/_DV/CartridgeLoader/Cartridges/CrimeAssistPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,38 @@ public sealed partial class CrimeAssistPage : IPrototype
[IdDataField]
public string ID { get; private set; } = "";

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

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

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

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

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

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

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

[DataField("locKeyPunishment")]
public string? LocKeyPunishment { get; private set; }
[DataField]
public LocId? LocKeyPunishment;
}

/// <summary>
/// The severity a crime is in, used for page results.
/// </summary>
public enum CrimeSeverity : byte
{
Innocent,
Misdemeanour,
Felony,
Capital
}
54 changes: 27 additions & 27 deletions Resources/Prototypes/_DV/Cartridges/crimeassistflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,187 +163,187 @@
id: "resultInnocent"
locKeyTitle: "crime-assist-crime-innocent"
locKeyDescription: "crime-assist-crimedetail-innocent"
locKeySeverity: "crime-assist-crimetype-innocent"
crimeSeverity: Innocent
locKeyPunishment: "crime-assist-crimepunishment-innocent"

- type: crimeAssistPage
id: "resultAnimalCruelty"
locKeyTitle: "crime-assist-crime-animalcruelty"
locKeyDescription: "crime-assist-crimedetail-animalcruelty"
locKeySeverity: "crime-assist-crimetype-misdemeanour"
crimeSeverity: Misdemeanour
locKeyPunishment: "crime-assist-crimepunishment-animalcruelty"

- type: crimeAssistPage
id: "resultTheft"
locKeyTitle: "crime-assist-crime-theft"
locKeyDescription: "crime-assist-crimedetail-theft"
locKeySeverity: "crime-assist-crimetype-misdemeanour"
crimeSeverity: Misdemeanour
locKeyPunishment: "crime-assist-crimepunishment-theft"

- type: crimeAssistPage
id: "resultTrespass"
locKeyTitle: "crime-assist-crime-trespass"
locKeyDescription: "crime-assist-crimedetail-trespass"
locKeySeverity: "crime-assist-crimetype-misdemeanour"
crimeSeverity: Misdemeanour
locKeyPunishment: "crime-assist-crimepunishment-trespass"

- type: crimeAssistPage
id: "resultVandalism"
locKeyTitle: "crime-assist-crime-vandalism"
locKeyDescription: "crime-assist-crimedetail-vandalism"
locKeySeverity: "crime-assist-crimetype-misdemeanour"
crimeSeverity: Misdemeanour
locKeyPunishment: "crime-assist-crimepunishment-vandalism"

- type: crimeAssistPage
id: "resultHooliganism"
locKeyTitle: "crime-assist-crime-hooliganism"
locKeyDescription: "crime-assist-crimedetail-hooliganism"
locKeySeverity: "crime-assist-crimetype-misdemeanour"
crimeSeverity: Misdemeanour
locKeyPunishment: "crime-assist-crimepunishment-hooliganism"

- type: crimeAssistPage
id: "resultManslaughter"
locKeyTitle: "crime-assist-crime-manslaughter"
locKeyDescription: "crime-assist-crimedetail-manslaughter"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-manslaughter"

- type: crimeAssistPage
id: "resultGrandTheft"
locKeyTitle: "crime-assist-crime-grandtheft"
locKeyDescription: "crime-assist-crimedetail-grandtheft"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-grandtheft"

- type: crimeAssistPage
id: "resultSabotage"
locKeyTitle: "crime-assist-crime-sabotage"
locKeyDescription: "crime-assist-crimedetail-sabotage"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-sabotage"

- type: crimeAssistPage
id: "resultMindbreaking"
locKeyTitle: "crime-assist-crime-mindbreaking"
locKeyDescription: "crime-assist-crimedetail-mindbreaking"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-mindbreaking"

- type: crimeAssistPage
id: "resultAssault"
locKeyTitle: "crime-assist-crime-assault"
locKeyDescription: "crime-assist-crimedetail-assault"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-assault"

- type: crimeAssistPage
id: "resultAbuseOfPower"
locKeyTitle: "crime-assist-crime-abuseofpower"
locKeyDescription: "crime-assist-crimedetail-abuseofpower"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-abuseofpower"

- type: crimeAssistPage
id: "resultPossession"
locKeyTitle: "crime-assist-crime-possession"
locKeyDescription: "crime-assist-crimedetail-possession"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-possession"

- type: crimeAssistPage
id: "resultEndangerment"
locKeyTitle: "crime-assist-crime-endangerment"
locKeyDescription: "crime-assist-crimedetail-endangerment"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-endangerment"

- type: crimeAssistPage
id: "resultBreakingAndEntering"
locKeyTitle: "crime-assist-crime-breakingandentering"
locKeyDescription: "crime-assist-crimedetail-breakingandentering"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-breakingandentering"

- type: crimeAssistPage
id: "resultRioting"
locKeyTitle: "crime-assist-crime-rioting"
locKeyDescription: "crime-assist-crimedetail-rioting"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-rioting"

- type: crimeAssistPage
id: "resultContemptOfCourt"
locKeyTitle: "crime-assist-crime-contemptofcourt"
locKeyDescription: "crime-assist-crimedetail-contemptofcourt"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-contemptofcourt"

- type: crimeAssistPage
id: "resultBlackMarketeering"
locKeyTitle: "crime-assist-crime-blackmarketeering"
locKeyDescription: "crime-assist-crimedetail-blackmarketeering"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-blackmarketeering"

- type: crimeAssistPage
id: "resultPerjuryOrFalseReport"
locKeyTitle: "crime-assist-crime-perjuryfalsereport"
locKeyDescription: "crime-assist-crimedetail-perjuryfalsereport"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-perjuryfalsereport"

- type: crimeAssistPage
id: "resultObstructionOfJustice"
locKeyTitle: "crime-assist-crime-obstructionofjustice"
locKeyDescription: "crime-assist-crimedetail-obstructionofjustice"
locKeySeverity: "crime-assist-crimetype-felony"
crimeSeverity: Felony
locKeyPunishment: "crime-assist-crimepunishment-obstructionofjustice"

- type: crimeAssistPage
id: "resultMurder"
locKeyTitle: "crime-assist-crime-murder"
locKeyDescription: "crime-assist-crimedetail-murder"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-murder"

- type: crimeAssistPage
id: "resultTerrorism"
locKeyTitle: "crime-assist-crime-terrorism"
locKeyDescription: "crime-assist-crimedetail-terrorism"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-terrorism"

- type: crimeAssistPage
id: "resultGrandSabotage"
locKeyTitle: "crime-assist-crime-grandsabotage"
locKeyDescription: "crime-assist-crimedetail-grandsabotage"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-grandsabotage"

- type: crimeAssistPage
id: "resultDecorporealisation"
locKeyTitle: "crime-assist-crime-decorporealisation"
locKeyDescription: "crime-assist-crimedetail-decorporealisation"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-decorporealisation"

- type: crimeAssistPage
id: "resultKidnapping"
locKeyTitle: "crime-assist-crime-kidnapping"
locKeyDescription: "crime-assist-crimedetail-kidnapping"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-kidnapping"

- type: crimeAssistPage
id: "resultSedition"
locKeyTitle: "crime-assist-crime-sedition"
locKeyDescription: "crime-assist-crimedetail-sedition"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-sedition"

- type: crimeAssistPage
id: "resultSexualHarassment"
locKeyTitle: "crime-assist-crime-sexualharassment"
locKeyDescription: "crime-assist-crimedetail-sexualharassment"
locKeySeverity: "crime-assist-crimetype-capital"
crimeSeverity: Capital
locKeyPunishment: "crime-assist-crimepunishment-sexualharassment"

0 comments on commit a23928c

Please sign in to comment.