-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into HoS's-Shades
- Loading branch information
Showing
72 changed files
with
42,757 additions
and
37,253 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)!; | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Content.Server/DeltaV/StationEvents/Components/PirateRadioSpawnRuleComponent.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,15 @@ | ||
using Content.Server.StationEvents.Events; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
[RegisterComponent, Access(typeof(PirateRadioSpawnRule))] | ||
public sealed partial class PirateRadioSpawnRuleComponent : Component | ||
{ | ||
[DataField("PirateRadioShuttlePath")] | ||
public string PirateRadioShuttlePath = "Maps/Shuttles/pirateradio.yml"; | ||
|
||
[DataField("additionalRule")] | ||
public EntityUid? AdditionalRule; | ||
} |
39 changes: 39 additions & 0 deletions
39
Content.Server/DeltaV/StationEvents/Events/PirateRadioSpawnRule.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,39 @@ | ||
using Robust.Server.GameObjects; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Map; | ||
using Content.Server.GameTicking; | ||
using Content.Server.GameTicking.Rules; | ||
using Content.Server.GameTicking.Rules.Components; | ||
using Content.Server.StationEvents.Components; | ||
using Content.Server.RoundEnd; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
public sealed class PirateRadioSpawnRule : StationEventSystem<PirateRadioSpawnRuleComponent> | ||
{ | ||
[Dependency] private readonly IMapManager _mapManager = default!; | ||
[Dependency] private readonly MapLoaderSystem _map = default!; | ||
[Dependency] private readonly GameTicker _gameTicker = default!; | ||
[Dependency] private readonly TraitorRuleSystem _TraitorRuleSystem = default!; | ||
|
||
protected override void Started(EntityUid uid, PirateRadioSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
{ | ||
base.Started(uid, component, gameRule, args); | ||
|
||
var shuttleMap = _mapManager.CreateMap(); | ||
var options = new MapLoadOptions | ||
{ | ||
LoadMap = true, | ||
}; | ||
|
||
_map.TryLoad(shuttleMap, component.PirateRadioShuttlePath, out _, options); | ||
} | ||
|
||
protected override void Ended(EntityUid uid, PirateRadioSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args) | ||
{ | ||
base.Ended(uid, component, gameRule, args); | ||
|
||
if (component.AdditionalRule != null) | ||
GameTicker.EndGameRule(component.AdditionalRule.Value); | ||
} | ||
} |
Oops, something went wrong.