-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Revert-New-Shotgun-Sprites
- Loading branch information
Showing
46 changed files
with
2,632 additions
and
319 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
Content.Client/DeltaV/CartridgeLoader/Cartridges/CrimeAssistUi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Content.Client/DeltaV/CartridgeLoader/Cartridges/CrimeAssistUiFragment.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
98 changes: 98 additions & 0 deletions
98
Content.Client/DeltaV/CartridgeLoader/Cartridges/CrimeAssistUiFragment.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)!; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Content.Server/DeltaV/CartridgeLoader/CrimeAssistCartridgeComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ } |
16 changes: 16 additions & 0 deletions
16
Content.Server/DeltaV/CartridgeLoader/CrimeAssistCartridgeSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Content.Server/DeltaV/Speech/Components/ScottishAccentComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Content.Server.DeltaV.Speech.EntitySystems; | ||
|
||
namespace Content.Server.DeltaV.Speech.Components; | ||
|
||
[RegisterComponent] | ||
[Access(typeof(ScottishAccentSystem))] | ||
public sealed partial class ScottishAccentComponent : Component | ||
{ } |
33 changes: 33 additions & 0 deletions
33
Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Content.Server.DeltaV.Speech.Components; | ||
using Content.Server.Speech; | ||
using Content.Server.Speech.EntitySystems; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Content.Server.DeltaV.Speech.EntitySystems; | ||
|
||
public sealed class ScottishAccentSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ReplacementAccentSystem _replacement = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ScottishAccentComponent, AccentGetEvent>(OnAccentGet); | ||
} | ||
|
||
// converts left word when typed into the right word. For example typing you becomes ye. | ||
public string Accentuate(string message, ScottishAccentComponent component) | ||
{ | ||
var msg = message; | ||
|
||
msg = _replacement.ApplyReplacements(msg, "scottish"); | ||
|
||
return msg; | ||
} | ||
|
||
private void OnAccentGet(EntityUid uid, ScottishAccentComponent component, AccentGetEvent args) | ||
{ | ||
args.Message = Accentuate(args.Message, component); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Content.Shared/DeltaV/CartridgeLoader/Cartridges/CrimeAssistPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
Oops, something went wrong.