Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into HoS's-Shades
Browse files Browse the repository at this point in the history
  • Loading branch information
ps3moira committed Dec 31, 2023
2 parents 9d1d1c5 + 99448ce commit 38f79d9
Show file tree
Hide file tree
Showing 72 changed files with 42,757 additions and 37,253 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)!;
}
}
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();
}
}
20 changes: 13 additions & 7 deletions Content.Server/DeltaV/RoundEnd/RoundEndSystem.Pacified.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Server.Emp;
using Content.Server.Explosion.Components;
using Content.Server.Flash.Components;
using Content.Server.GameTicking;
using Content.Server.Popups;
using Content.Server.Store.Components;
Expand Down Expand Up @@ -38,19 +38,25 @@ private void OnRoundEnded(RoundEndTextAppendEvent ev)
var harmQuery = EntityQueryEnumerator<CombatModeComponent>();
while (harmQuery.MoveNext(out var uid, out var _))
{
_entityManager.EnsureComponent<PacifiedComponent>(uid);
EnsureComp<PacifiedComponent>(uid);
}

var grenadeQuery = EntityQueryEnumerator<ExplodeOnTriggerComponent>();
var explosiveQuery = EntityQueryEnumerator<ExplosiveComponent>();
while (explosiveQuery.MoveNext(out var uid, out var _))
{
RemComp<ExplosiveComponent>(uid);
}

var grenadeQuery = EntityQueryEnumerator<OnUseTimerTriggerComponent>();
while (grenadeQuery.MoveNext(out var uid, out var _))
{
_entityManager.RemoveComponent<ExplodeOnTriggerComponent>(uid);
RemComp<OnUseTimerTriggerComponent>(uid);
}

var empQuery = EntityQueryEnumerator<EmpOnTriggerComponent>();
while (empQuery.MoveNext(out var uid, out var _))
var flashQuery = EntityQueryEnumerator<FlashComponent>();
while (flashQuery.MoveNext(out var uid, out var _))
{
_entityManager.RemoveComponent<EmpOnTriggerComponent>(uid);
RemComp<FlashComponent>(uid);
}

var uplinkQuery = EntityQueryEnumerator<StoreComponent>();
Expand Down
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 Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs
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);
}
}
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 Content.Server/DeltaV/StationEvents/Events/PirateRadioSpawnRule.cs
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);
}
}
Loading

0 comments on commit 38f79d9

Please sign in to comment.