Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor discord link #449

Merged
merged 12 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Robust.Client.AutoGenerated;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/EscapeMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Button Access="Public" Name="RulesButton" Text="{Loc 'ui-escape-rules'}" />
<Button Access="Public" Name="GuidebookButton" Text="{Loc 'ui-escape-guidebook'}" />
<Button Access="Public" Name="WikiButton" Text="{Loc 'ui-escape-wiki'}" />
<Button Access="Public" Name="DiscordLinkButton" Text="Привязать"/>
<Button Access="Public" Name="DisconnectButton" Text="{Loc 'ui-escape-disconnect'}" />
<Button Access="Public" Name="QuitButton" Text="{Loc 'ui-escape-quit'}" />
</BoxContainer>
Expand Down
46 changes: 46 additions & 0 deletions Content.Client/SS220/UserInterface/DiscordLink/DiscordLinkEui.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Client.Eui;
using Content.Shared.Eui;
using Content.Shared.SS220.DiscordLink;
using JetBrains.Annotations;

namespace Content.Client.SS220.UserInterface.DiscordLink;

[UsedImplicitly]
public sealed class DiscordLinkEui : BaseEui
{
private DiscordLinkWindow DiscordWindow { get; }

public DiscordLinkEui()
{
DiscordWindow = new DiscordLinkWindow();
DiscordWindow.OnClose += DiscordWindow_OnClose;
}

private void DiscordWindow_OnClose()
{
SendMessage(new CloseEuiMessage());
}

public override void Closed()
{
base.Closed();
DiscordWindow.Close();
}

public override void Opened()
{
DiscordWindow.OpenCentered();
}

public override void HandleState(EuiStateBase state)
{
if (state is not DiscordLinkEuiState discordLink)
{
return;
}

DiscordWindow.SetLink(discordLink.LinkKey);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt -->
<ui:FancyWindow
xmlns="https://spacestation14.io"
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
Title="Привязка аккаунта"
Resizable="False"
MinWidth="400"
MinHeight="150">
<BoxContainer Name="LinkPanel" Visible="True" Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2" StyleClasses="BackgroundDark" Margin="8">
<Label Text="Ваша командя для привязки аккаунта Discrod:" />
<LineEdit Name="LinkText" Editable="False" />
</BoxContainer>
<BoxContainer Name="LinkAlreadyExistPanel" Visible="False" Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2" StyleClasses="BackgroundDark" Margin="8">
<Label Text="Ваш аккаунт уже привяза к учётной записи Discord" />
</BoxContainer>
</ui:FancyWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.SS220.UserInterface.DiscordLink;

[GenerateTypedNameReferences]
public sealed partial class DiscordLinkWindow : FancyWindow
{
public DiscordLinkWindow()
{
RobustXamlLoader.Load(this);
}

public void SetLink(string? link)
{
if (string.IsNullOrWhiteSpace(link))
{
LinkPanel.Visible = false;
LinkAlreadyExistPanel.Visible = true;
}
else
{
LinkText.Text = $"/привязка14 {link}";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.Gameplay;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Guidebook;
using Content.Client.UserInterface.Systems.Info;
Expand Down Expand Up @@ -103,6 +103,12 @@ public void OnStateEntered(GameplayState state)
_guidebook.ToggleGuidebook();
};

_escapeWindow.DiscordLinkButton.OnPressed += _ =>
{
CloseEscapeWindow();
_console.ExecuteCommand("discordlink");
};

// Hide wiki button if we don't have a link for it.
_escapeWindow.WikiButton.Visible = _cfg.GetCVar(CCVars.InfoLinksWiki) != "";

Expand Down
Loading
Loading