Skip to content

Commit

Permalink
Merge branch 'master' into quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 authored Aug 10, 2024
2 parents 5d04224 + a39ad34 commit 637fd39
Show file tree
Hide file tree
Showing 152 changed files with 11,512 additions and 578 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
<LineEdit Name="MinOverallMinutes" MinWidth="50" Margin="0 0 5 0" />
<Label Text="{Loc generic-minutes}" />
</BoxContainer>
<!-- Corvax-VPNGuard-Start -->
<BoxContainer Orientation="Horizontal" Margin="2" Visible="False" Name="VPNContainer">
<CheckBox Name="DenyVPN" Text="{Loc admin-ui-panic-bunker-deny-vpn}" />
</BoxContainer>
<!-- Corvax-VPNGuard-End -->
</BoxContainer>
</BoxContainer>
</controls:PanicBunkerTab>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Corvax.Interfaces.Shared;
using Content.Shared.Administration.Events;
using Content.Shared.Administration.Events;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
Expand Down Expand Up @@ -29,14 +28,6 @@ public PanicBunkerTab()
MinOverallMinutes.OnTextEntered += args => SendMinOverallMinutes(args.Text);
MinOverallMinutes.OnFocusExit += args => SendMinOverallMinutes(args.Text);
_minOverallMinutes = MinOverallMinutes.Text;
// Corvax-VPNGuard-Start
var haveSecrets = IoCManager.Instance!.TryResolveType<ISharedSponsorsManager>(out _); // TODO: Probably need better way to detect Secrets module
if (haveSecrets)
{
VPNContainer.Visible = true;
DenyVPN.OnPressed += _ => SendDenyVpn(DenyVPN.Pressed);
}
// Corvax-VPNGuard-End
}

private void SendMinAccountAge(string text)
Expand All @@ -63,13 +54,6 @@ private void SendMinOverallMinutes(string text)
_console.ExecuteCommand($"panicbunker_min_overall_minutes {minutes}");
}

// Corvax-VPNGuard-Start
private void SendDenyVpn(bool deny)
{
_console.ExecuteCommand($"panicbunker_deny_vpn {deny}");
}
// Corvax-VPNGuard-End

public void UpdateStatus(PanicBunkerStatus status)
{
EnabledButton.Pressed = status.Enabled;
Expand All @@ -89,6 +73,5 @@ public void UpdateStatus(PanicBunkerStatus status)

MinOverallMinutes.Text = status.MinOverallMinutes.ToString();
_minOverallMinutes = MinOverallMinutes.Text;
DenyVPN.Pressed = status.DenyVpn; // Corvax-VPNGuard
}
}
2 changes: 0 additions & 2 deletions Content.Client/Content.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<ProjectReference Include="..\RobustToolbox\Robust.Shared\Robust.Shared.csproj" />
<ProjectReference Include="..\RobustToolbox\Robust.Client\Robust.Client.csproj" />
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj" />
<ProjectReference Include="..\Corvax\Content.Corvax.Interfaces.Shared\Content.Corvax.Interfaces.Shared.csproj" />
<ProjectReference Include="..\Corvax\Content.Corvax.Interfaces.Client\Content.Corvax.Interfaces.Client.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Spawners\" />
Expand Down
28 changes: 28 additions & 0 deletions Content.Client/Corvax/DiscordAuth/DiscordAuthGui.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:parallax="clr-namespace:Content.Client.Parallax"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
<parallax:ParallaxControl />
<Control HorizontalAlignment="Center" VerticalAlignment="Center">
<PanelContainer StyleClasses="AngleRect" />
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Margin="8 0 0 0" Text="{Loc 'discord-auth-title'}"
StyleClasses="LabelHeading" VAlign="Center" />
<Button Name="QuitButton" Text="{Loc 'discord-auth-quit-btn'}"
HorizontalAlignment="Right" HorizontalExpand="True" />
</BoxContainer>
<controls:HighDivider />
<BoxContainer Orientation="Vertical" Margin="50 20 50 20">
<Label Text="{Loc 'discord-auth-info'}" Align="Center" />
<Label Text="{Loc 'discord-auth-warn'}" Margin="0 5 0 0" Align="Center" StyleClasses="LabelSubText" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" VerticalAlignment="Bottom" Margin="10 0 0 0">
<Label Text="{Loc 'discord-auth-link'}" Align="Center" />
<Label Text=" " />
<LineEdit Name="UrlEdit" HorizontalExpand="True" Editable="False"></LineEdit>
</BoxContainer>
<Button Name="OpenUrlButton" Text="{Loc 'discord-auth-browser-btn'}" HorizontalExpand="True" StyleClasses="OpenRight" />
</BoxContainer>
</Control>
</Control>
35 changes: 35 additions & 0 deletions Content.Client/Corvax/DiscordAuth/DiscordAuthGui.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Corvax.DiscordAuth;

[GenerateTypedNameReferences]
public sealed partial class DiscordAuthGui : Control
{
[Dependency] private readonly DiscordAuthManager _discordAuthManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;

public DiscordAuthGui()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

QuitButton.OnPressed += (_) =>
{
_consoleHost.ExecuteCommand("quit");
};

UrlEdit.Text = _discordAuthManager.AuthUrl;
OpenUrlButton.OnPressed += (_) =>
{
if (_discordAuthManager.AuthUrl != string.Empty)
{
IoCManager.Resolve<IUriOpener>().OpenUri(_discordAuthManager.AuthUrl);
}
};
}
}
30 changes: 30 additions & 0 deletions Content.Client/Corvax/DiscordAuth/DiscordAuthManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Threading;
using Content.Shared.Corvax.DiscordAuth;
using Robust.Client.State;
using Robust.Shared.Network;
using Timer = Robust.Shared.Timing.Timer;

namespace Content.Client.Corvax.DiscordAuth;

public sealed class DiscordAuthManager
{
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;

public string AuthUrl { get; private set; } = string.Empty;

public void Initialize()
{
_netManager.RegisterNetMessage<MsgDiscordAuthCheck>();
_netManager.RegisterNetMessage<MsgDiscordAuthRequired>(OnDiscordAuthRequired);
}

private void OnDiscordAuthRequired(MsgDiscordAuthRequired message)
{
if (_stateManager.CurrentState is not DiscordAuthState)
{
AuthUrl = message.AuthUrl;
_stateManager.RequestStateChange<DiscordAuthState>();
}
}
}
34 changes: 34 additions & 0 deletions Content.Client/Corvax/DiscordAuth/DiscordAuthState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Threading;
using Content.Shared.Corvax.DiscordAuth;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Shared.Network;
using Timer = Robust.Shared.Timing.Timer;

namespace Content.Client.Corvax.DiscordAuth;

public sealed class DiscordAuthState : State
{
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;

private DiscordAuthGui? _gui;
private readonly CancellationTokenSource _checkTimerCancel = new();

protected override void Startup()
{
_gui = new DiscordAuthGui();
_userInterfaceManager.StateRoot.AddChild(_gui);

Timer.SpawnRepeating(TimeSpan.FromSeconds(5), () =>
{
_netManager.ClientSendMessage(new MsgDiscordAuthCheck());
}, _checkTimerCancel.Token);
}

protected override void Shutdown()
{
_checkTimerCancel.Cancel();
_gui!.Dispose();
}
}
26 changes: 26 additions & 0 deletions Content.Client/Corvax/JoinQueue/JoinQueueManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.Corvax.JoinQueue;
using Robust.Client.State;
using Robust.Shared.Network;

namespace Content.Client.Corvax.JoinQueue;

public sealed class JoinQueueManager
{
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;

public void Initialize()
{
_netManager.RegisterNetMessage<MsgQueueUpdate>(OnQueueUpdate);
}

private void OnQueueUpdate(MsgQueueUpdate msg)
{
if (_stateManager.CurrentState is not QueueState)
{
_stateManager.RequestStateChange<QueueState>();
}

((QueueState) _stateManager.CurrentState).OnQueueUpdate(msg);
}
}
34 changes: 34 additions & 0 deletions Content.Client/Corvax/JoinQueue/QueueGui.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:parallax="clr-namespace:Content.Client.Parallax"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
<parallax:ParallaxControl />
<Control HorizontalAlignment="Center" VerticalAlignment="Center">
<PanelContainer StyleClasses="AngleRect" />
<BoxContainer Orientation="Vertical" MinSize="200 200">
<BoxContainer Orientation="Horizontal">
<Label Margin="8 0 0 0" Text="{Loc 'queue-title'}"
StyleClasses="LabelHeading" VAlign="Center" />
<Button Name="QuitButton" Text="{Loc 'queue-quit'}"
HorizontalAlignment="Right" HorizontalExpand="True" />
</BoxContainer>
<controls:HighDivider />
<BoxContainer Orientation="Vertical" VerticalExpand="True" Margin="0 20 0 0">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Vertical" VerticalExpand="True">
<Label Text="{Loc 'queue-position'}" Align="Center" />
<Label Name="QueuePosition" StyleClasses="LabelHeading" Align="Center" />
</BoxContainer>
<BoxContainer Orientation="Vertical" VerticalExpand="True" Margin="0 10 0 0">
<Label Text="{Loc 'queue-total'}" Align="Center" />
<Label Name="QueueTotal" StyleClasses="LabelHeading" Align="Center" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0 20 0 0">
<Button Name="PriorityJoinButton" Text="{Loc 'queue-priority-join'}" HorizontalExpand="True" StyleClasses="OpenRight" />
</BoxContainer>
</BoxContainer>
</Control>
</Control>
41 changes: 41 additions & 0 deletions Content.Client/Corvax/JoinQueue/QueueGui.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Content.Shared.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;

namespace Content.Client.Corvax.JoinQueue;

[GenerateTypedNameReferences]
public sealed partial class QueueGui : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;

public event Action? QuitPressed;

public QueueGui()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

QuitButton.OnPressed += (_) => QuitPressed?.Invoke();

// Disable "priority join" button on Steam builds
// since it violates Valve's rules about alternative storefronts.
PriorityJoinButton.Visible = !_cfg.GetCVar(CCVars.BrandingSteam);

PriorityJoinButton.OnPressed += (_) =>
{
var linkPatreon = _cfg.GetCVar(CCVars.InfoLinksPatreon);
IoCManager.Resolve<IUriOpener>().OpenUri(linkPatreon);
};
}

public void UpdateInfo(int total, int position)
{
QueueTotal.Text = total.ToString();
QueuePosition.Text = position.ToString();
}
}
51 changes: 51 additions & 0 deletions Content.Client/Corvax/JoinQueue/QueueState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Shared.Corvax.JoinQueue;
using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;

namespace Content.Client.Corvax.JoinQueue;

public sealed class QueueState : State
{
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;

private const string JoinSoundPath = "/Audio/Effects/voteding.ogg";

private QueueGui? _gui;

protected override void Startup()
{
_gui = new QueueGui();
_userInterfaceManager.StateRoot.AddChild(_gui);

_gui.QuitPressed += OnQuitPressed;
}

protected override void Shutdown()
{
_gui!.QuitPressed -= OnQuitPressed;
_gui.Dispose();

Ding();
}

private void Ding()
{
_audio.PlayGlobal(JoinSoundPath, Filter.Local(), false);
}

public void OnQueueUpdate(MsgQueueUpdate msg)
{
_gui?.UpdateInfo(msg.Total, msg.Position);
}

private void OnQuitPressed()
{
_consoleHost.ExecuteCommand("quit");
}
}
38 changes: 38 additions & 0 deletions Content.Client/Corvax/Sponsors/CheckSponsorClientSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Linq;
using Content.Shared.Corvax.Sponsors;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Player;

namespace Content.Client.Corvax.Sponsors
{
public sealed class CheckSponsorClientSystem : EntitySystem
{
public bool IsSponsor = false;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CheckedUserSponsor>(SetSponsorStatus);
}

private void SetSponsorStatus(CheckedUserSponsor ev)
{
IsSponsor = ev.IsSponsor;
}

public void TryCheckSponsor(string? player)
{
if (player != null)
{
var ev = new CheckUserSponsor(player);
RaiseNetworkEvent(ev);
}
}

public bool GetSponsorStatus()
{
return IsSponsor;
}

}
}
Loading

0 comments on commit 637fd39

Please sign in to comment.