Skip to content

Commit b0e6a05

Browse files
committed
im the best
1 parent a0a1814 commit b0e6a05

File tree

5 files changed

+189
-0
lines changed

5 files changed

+189
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<controls:FancyWindow xmlns="https://spacestation14.io"
2+
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
3+
Title="{Loc 'no-eorg-popup-title'}"
4+
MinSize="520 450"
5+
MaxSize="520 450">
6+
<BoxContainer Orientation="Vertical" Margin="20">
7+
<Label Name="TitleLabel"
8+
StyleClasses="LabelBig"
9+
HorizontalAlignment="Center"
10+
Margin="0 0 0 5" />
11+
<PanelContainer StyleClasses="BackgroundDark" Margin="0 0 0 10">
12+
<BoxContainer Orientation="Vertical" Margin="10">
13+
<RichTextLabel Name="MessageLabel" HorizontalAlignment="Center" />
14+
<Control MinSize="0 5" />
15+
<RichTextLabel Name="RuleLabel" HorizontalAlignment="Center" />
16+
<RichTextLabel Name="RuleTextLabel" HorizontalAlignment="Center" Margin="0 5 0 0" />
17+
</BoxContainer>
18+
</PanelContainer>
19+
<BoxContainer Orientation="Vertical" VerticalAlignment="Bottom" Margin="0 10 0 0">
20+
<CheckBox Name="SkipCheckBox"
21+
Text="{Loc 'no-eorg-popup-skip-checkbox'}"
22+
HorizontalAlignment="Center"
23+
Margin="0 0 0 10" />
24+
<Button Name="NoEorgCloseButton"
25+
HorizontalAlignment="Center"
26+
MinWidth="150" />
27+
</BoxContainer>
28+
</BoxContainer>
29+
</controls:FancyWindow>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using Content.Client.UserInterface.Controls;
2+
using Content.Shared._Emberfall.CCVar;
3+
using Robust.Client.AutoGenerated;
4+
using Robust.Client.UserInterface.Controls;
5+
using Robust.Client.UserInterface.XAML;
6+
using Robust.Shared.Configuration;
7+
using Robust.Shared.Timing;
8+
using Robust.Shared.Utility;
9+
10+
namespace Content.Client._Emberfall.RoundEnd;
11+
12+
[GenerateTypedNameReferences]
13+
public sealed partial class NoEorgPopup : FancyWindow
14+
{
15+
[Dependency] private readonly IConfigurationManager _cfg = default!;
16+
17+
private float _remainingTime;
18+
private bool _initialSkipState;
19+
20+
public NoEorgPopup()
21+
{
22+
IoCManager.InjectDependencies(this);
23+
RobustXamlLoader.Load(this);
24+
25+
InitializeUI();
26+
InitializeEvents();
27+
ResetTimer();
28+
}
29+
30+
private void InitializeUI()
31+
{
32+
TitleLabel.Text = Loc.GetString("no-eorg-popup-label");
33+
MessageLabel.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("no-eorg-popup-message")));
34+
RuleLabel.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("no-eorg-popup-rule")));
35+
RuleTextLabel.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("no-eorg-popup-rule-text")));
36+
37+
_initialSkipState =
38+
_cfg.GetCVar(ECCVars.SkipRoundEndNoEorgPopup); // Store the initial CVar value to compare against
39+
SkipCheckBox.Pressed = _initialSkipState;
40+
NoEorgCloseButton.Disabled = true;
41+
42+
UpdateCloseButtonText();
43+
}
44+
45+
private void InitializeEvents()
46+
{
47+
OnClose += SaveSkipState; // Only change the CVar once the close button is pressed
48+
NoEorgCloseButton.OnPressed += OnClosePressed;
49+
}
50+
51+
private void ResetTimer()
52+
{
53+
_remainingTime = _cfg.GetCVar(ECCVars.RoundEndNoEorgPopupTime); // Set how long to show the popup for
54+
UpdateCloseButtonText();
55+
}
56+
57+
private void SaveSkipState()
58+
{
59+
if (SkipCheckBox.Pressed == _initialSkipState)
60+
return;
61+
62+
_cfg.SetCVar(ECCVars.SkipRoundEndNoEorgPopup, SkipCheckBox.Pressed);
63+
_cfg.SaveToFile();
64+
}
65+
66+
private void OnClosePressed(BaseButton.ButtonEventArgs args)
67+
{
68+
Close();
69+
}
70+
71+
private void UpdateCloseButtonText()
72+
{
73+
var isWaiting = _remainingTime > 0f;
74+
NoEorgCloseButton.Text = isWaiting
75+
? Loc.GetString("no-eorg-popup-close-button-wait", ("time", (int)MathF.Ceiling(_remainingTime)))
76+
: Loc.GetString("no-eorg-popup-close-button");
77+
NoEorgCloseButton.Disabled = isWaiting;
78+
}
79+
80+
protected override void FrameUpdate(FrameEventArgs args)
81+
{
82+
base.FrameUpdate(args);
83+
84+
if (!NoEorgCloseButton.Disabled)
85+
return;
86+
87+
_remainingTime = MathF.Max(0f, _remainingTime - args.DeltaSeconds);
88+
UpdateCloseButtonText();
89+
}
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Content.Shared._Emberfall.CCVar;
2+
using Content.Shared.GameTicking;
3+
using Robust.Shared.Configuration;
4+
5+
namespace Content.Client._Emberfall.RoundEnd;
6+
7+
public sealed class NoEorgPopupSystem : EntitySystem
8+
{
9+
[Dependency] private readonly IConfigurationManager _cfg = default!;
10+
11+
private NoEorgPopup? _window;
12+
13+
public override void Initialize()
14+
{
15+
base.Initialize();
16+
SubscribeNetworkEvent<RoundEndMessageEvent>(OnRoundEnd);
17+
}
18+
19+
private void OnRoundEnd(RoundEndMessageEvent ev)
20+
{
21+
if (_cfg.GetCVar(ECCVars.SkipRoundEndNoEorgPopup) || _cfg.GetCVar(ECCVars.RoundEndNoEorgPopup) == false)
22+
return;
23+
24+
OpenNoEorgPopup();
25+
}
26+
27+
private void OpenNoEorgPopup()
28+
{
29+
if (_window != null)
30+
return;
31+
32+
_window = new NoEorgPopup();
33+
_window.OpenCentered();
34+
_window.OnClose += () => _window = null;
35+
}
36+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Robust.Shared.Configuration;
2+
3+
namespace Content.Shared._Emberfall.CCVar;
4+
5+
[CVarDefs]
6+
public sealed partial class ECCVars
7+
{
8+
/// <summary>
9+
/// Whether the no EORG popup is enabled.
10+
/// </summary>
11+
public static readonly CVarDef<bool> RoundEndNoEorgPopup =
12+
CVarDef.Create("game.round_end_eorg_popup_enabled", true, CVar.SERVER | CVar.REPLICATED);
13+
14+
/// <summary>
15+
/// Skip the no EORG popup.
16+
/// </summary>
17+
public static readonly CVarDef<bool> SkipRoundEndNoEorgPopup =
18+
CVarDef.Create("game.skip_round_end_eorg_popup", false, CVar.CLIENTONLY | CVar.ARCHIVE);
19+
20+
/// <summary>
21+
/// How long to display the EORG popup for.
22+
/// </summary>
23+
public static readonly CVarDef<float> RoundEndNoEorgPopupTime =
24+
CVarDef.Create("game.round_end_eorg_popup_time", 15f, CVar.SERVER | CVar.REPLICATED);
25+
}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
no-eorg-popup-title = Emberfall
2+
no-eorg-popup-label = Welcome to the End of Round!
3+
no-eorg-popup-message = [bold]End-of-round grief (EORG)[/bold] is not allowed at Emberfall. Please stay in character until the lobby screen appears to maintain an immersive environment for everyone. Thank you for respecting the community rules!
4+
no-eorg-popup-rule = [bold][color=#a4885c]Significant end-of-round grief (EORG) is not allowed.[/color][/bold]
5+
no-eorg-popup-rule-text = This includes attacking, destroying, polluting, and severely injuring without reason both at and on the way to Central Command. Remember that you are playing a character throughout the round.
6+
no-eorg-popup-close-button = Sounds good!
7+
no-eorg-popup-close-button-wait = The close button will be enabled after {$time} seconds.
8+
no-eorg-popup-skip-checkbox = Don't show this again.

0 commit comments

Comments
 (0)