Event refactor (#9589)

* Station event refactor

* Remove clientside `IStationEventManager`

we can just use prototypes

* Basic API idea

* Cruft

* first attempt at epicness

* okay yeah this shit is really clean

* sort out minor stuff

* Convert `BreakerFlip`

* `BureaucraticError` + general cleanup

* `DiseaseOutbreak`

* `FalseAlarm`

* `GasLeak`

* `KudzuGrowth`

* `MeteorSwarm`

* `MouseMigration`

* misc errors

* `PowerGridCheck`

* `RandomSentience`

* `VentClog`

* `VentCritters`

* `ZombieOutbreak`

* Rewrite basic event scheduler

* Minor fixes and logging

* ooooops

* errors + fix

* linter

* completions, `RuleStarted` property, update loop fixes

* Tweaks

* Fix #9462

* Basic scheduler update fix, and fixes #8174

* Add test

* UI cleanup

* really this was just for testing
This commit is contained in:
Kara
2022-07-10 18:48:41 -07:00
committed by GitHub
parent f28cdaaa7c
commit b9a0894d7c
55 changed files with 1095 additions and 1582 deletions

View File

@@ -12,6 +12,5 @@
<Button Name="LoadGamePrototypeButton" Text="{Loc 'load-game-prototype'}"/>
<cc:UICommandButton Name="LoadBlueprintsButton" Command="loadbp" Text="{Loc 'load-blueprints'}" WindowType="{x:Type abt:LoadBlueprintsWindow}"/>
<cc:CommandButton Command="deleteewc Singularity" Name="DeleteSingulos" Text="{Loc 'delete-singularities'}"/>
<cc:UICommandButton Command="events" Text="{Loc 'open-station-events'}" WindowType="{x:Type abt:StationEventsWindow}" />
</GridContainer>
</Control>

View File

@@ -1,13 +0,0 @@
<DefaultWindow
xmlns="https://spacestation14.io" Title="{Loc Events}">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc Event}" MinSize="100 0" />
<Control MinSize="50 0" />
<OptionButton Name="EventsOptions" MinSize="100 0" HorizontalExpand="True" Disabled="True" />
</BoxContainer>
<Button Name="PauseButton" Text="{Loc Pause}" Disabled="True" />
<Button Name="ResumeButton" Text="{Loc Resume}" Disabled="True" />
<Button Name="SubmitButton" Text="{Loc Run}" Disabled="True" />
</BoxContainer>
</DefaultWindow>

View File

@@ -1,86 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Content.Client.StationEvents.Managers;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Client.Administration.UI.Tabs.AdminbusTab
{
[GenerateTypedNameReferences]
[UsedImplicitly]
public sealed partial class StationEventsWindow : DefaultWindow
{
private List<string>? _data;
[Dependency]
private readonly IStationEventManager _eventManager = default!;
public StationEventsWindow()
{
IoCManager.InjectDependencies(this);
MinSize = SetSize = (300, 200);
RobustXamlLoader.Load(this);
}
protected override void EnteredTree()
{
_eventManager.OnStationEventsReceived += OnStationEventsReceived;
_eventManager.RequestEvents();
EventsOptions.AddItem(Loc.GetString("station-events-window-not-loaded-text"));
}
private void OnStationEventsReceived()
{
// fill events dropdown
_data = _eventManager.StationEvents.ToList();
EventsOptions.Clear();
foreach (var stationEvent in _data)
{
EventsOptions.AddItem(stationEvent);
}
EventsOptions.AddItem(Loc.GetString("station-events-window-random-text"));
// Enable all UI elements
EventsOptions.Disabled = false;
PauseButton.Disabled = false;
ResumeButton.Disabled = false;
SubmitButton.Disabled = false;
// Subscribe to UI events
EventsOptions.OnItemSelected += eventArgs => EventsOptions.SelectId(eventArgs.Id);
PauseButton.OnPressed += PauseButtonOnOnPressed;
ResumeButton.OnPressed += ResumeButtonOnOnPressed;
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
}
private static void PauseButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events pause");
}
private static void ResumeButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events resume");
}
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
if (_data == null)
return;
// random is always last option
var id = EventsOptions.SelectedId;
var selectedEvent = id < _data.Count ? _data[id] : "random";
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"events run \"{selectedEvent}\"");
}
}
}