Skip to content

Commit

Permalink
Кнопка в правилах
Browse files Browse the repository at this point in the history
Ссылка на правила по кнопке
  • Loading branch information
Cooderer committed Aug 9, 2023
1 parent 31fd0b9 commit 6efe88a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 201 deletions.
7 changes: 7 additions & 0 deletions Content.Client/Info/RulesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public sealed class RulesManager : SharedRulesManager
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly IUriOpener _uri = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private InfoSection rulesSection = new InfoSection("", "", false);
private bool _shouldShowRules = false;
Expand Down Expand Up @@ -73,6 +75,7 @@ private void ShowRules(float time)

_activePopup.OnQuitPressed += OnQuitPressed;
_activePopup.OnAcceptPressed += OnAcceptPressed;
_activePopup.OnToWikiSend += OnToWikiSendPressed;
_userInterfaceManager.WindowRoot.AddChild(_activePopup);
LayoutContainer.SetAnchorPreset(_activePopup, LayoutContainer.LayoutPreset.Wide);
}
Expand All @@ -89,6 +92,10 @@ private void OnAcceptPressed()
_activePopup?.Orphan();
_activePopup = null;
}
private void OnToWikiSendPressed()
{
_uri.OpenUri(_cfg.GetCVar(CCVars.InfoLinksWikiRules));
}

public void UpdateRules()
{
Expand Down
4 changes: 3 additions & 1 deletion Content.Client/Info/RulesPopup.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Control xmlns="https://spacestation14.io"
<Control xmlns="https://spacestation14.io"
xmlns:parallax="clr-namespace:Content.Client.Parallax"
xmlns:info="clr-namespace:Content.Client.Info"
VerticalExpand="True" HorizontalExpand="True"
Expand All @@ -13,6 +13,8 @@
<info:RulesControl />
<Label Name="WaitLabel" />
<BoxContainer Orientation="Horizontal">
<Button Name ="ToWikiSend"
Text="{Loc 'ui-rules-wikirules'}" />
<Button Name="AcceptButton"
Text="{Loc 'ui-rules-accept'}"
Disabled="True" />
Expand Down
28 changes: 19 additions & 9 deletions Content.Client/Info/RulesPopup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Content.Client.Info;
public sealed partial class RulesPopup : Control
{
private float _timer;
private bool _wikiPressed = false ;

public float Timer
{
Expand All @@ -25,13 +26,15 @@ public float Timer

public event Action? OnQuitPressed;
public event Action? OnAcceptPressed;
public event Action? OnToWikiSend;

public RulesPopup()
{
RobustXamlLoader.Load(this);

AcceptButton.OnPressed += OnAcceptButtonPressed;
QuitButton.OnPressed += OnQuitButtonPressed;
ToWikiSend.OnPressed += OnToWikiSendPressed;
}

private void OnQuitButtonPressed(BaseButton.ButtonEventArgs obj)
Expand All @@ -43,24 +46,31 @@ private void OnAcceptButtonPressed(BaseButton.ButtonEventArgs obj)
{
OnAcceptPressed?.Invoke();
}
private void OnToWikiSendPressed(BaseButton.ButtonEventArgs obj)
{
_wikiPressed = true;
OnToWikiSend?.Invoke();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

if (!AcceptButton.Disabled)
return;

if (Timer > 0.0)
if (_wikiPressed)
{
if (Timer - args.DeltaSeconds < 0)
Timer = 0;
if (Timer > 0.0)
{
if (Timer - args.DeltaSeconds < 0)
Timer = 0;
else
Timer -= args.DeltaSeconds;
}
else
Timer -= args.DeltaSeconds;
}
else
{
AcceptButton.Disabled = false;
{
AcceptButton.Disabled = false;
}
}
}
}
6 changes: 6 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,12 @@ public static readonly CVarDef<float>
public static readonly CVarDef<string> InfoLinksWiki =
CVarDef.Create("infolinks.wiki", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Link to wiki rules to show in the launcher.
/// </summary>
public static readonly CVarDef<string> InfoLinksWikiRules =
CVarDef.Create("infolinks.wikirules", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Link to Patreon. Not shown in the launcher currently.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/info/rules.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ui-rules-header-links = Links
ui-rules-roles = Roles wiki
ui-rules-discord = Discord
ui-rules-laws = Space Law
ui-rules-wikirules = Switch to rules
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/info/rules.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ui-rules-header-links = Ссылки
ui-rules-roles = Вики ролей
ui-rules-discord = Discord
ui-rules-laws = Космический Закон
ui-rules-wikirules = Открыть правила
Loading

0 comments on commit 6efe88a

Please sign in to comment.