Show rules on first connection (#5715)

* Implement showing rules on first connection

* Clean up RulesManager

* Change changelog and rules unread to use CVars

* Fix missing change

* Rename InfoWindow to RulesAndInfoWindow

* Change default server.id to unknown

* Fix invalid file contents and getting CVar
This commit is contained in:
ShadowCommander
2021-12-09 14:22:49 -08:00
committed by GitHub
parent ceca68236c
commit b3a4e3f557
9 changed files with 102 additions and 17 deletions

View File

@@ -104,7 +104,7 @@ namespace Content.Client.HUD
private TopButton _buttonActionsMenu = default!;
private TopButton _buttonAdminMenu = default!;
private TopButton _buttonSandboxMenu = default!;
private InfoWindow _infoWindow = default!;
private RulesAndInfoWindow _rulesAndInfoWindow = default!;
private TargetingDoll _targetingDoll = default!;
private BoxContainer _combatPanelContainer = default!;
private BoxContainer _topNotificationContainer = default!;
@@ -301,9 +301,11 @@ namespace Content.Client.HUD
_buttonInfo.OnToggled += a => ButtonInfoOnOnToggled();
_infoWindow = new InfoWindow();
_rulesAndInfoWindow = new RulesAndInfoWindow();
_infoWindow.OnClose += () => _buttonInfo.Pressed = false;
IoCManager.Resolve<RulesManager>().OpenRulesAndInfoWindow += OpenRulesAndInfoWindow;
_rulesAndInfoWindow.OnClose += () => _buttonInfo.Pressed = false;
_inputManager.SetInputCommand(ContentKeyFunctions.OpenInfo,
InputCmdHandler.FromDelegate(s => ButtonInfoOnOnToggled()));
@@ -428,25 +430,31 @@ namespace Content.Client.HUD
LC.SetGrowVertical(VoteContainer, LC.GrowDirection.End);
}
private void OpenRulesAndInfoWindow()
{
_rulesAndInfoWindow.OpenCentered();
_buttonInfo.Pressed = true;
}
private void ButtonInfoOnOnToggled()
{
_buttonInfo.StyleClasses.Remove(TopButton.StyleClassRedTopButton);
if (_infoWindow.IsOpen)
if (_rulesAndInfoWindow.IsOpen)
{
if (!_infoWindow.IsAtFront())
if (!_rulesAndInfoWindow.IsAtFront())
{
_infoWindow.MoveToFront();
_rulesAndInfoWindow.MoveToFront();
_buttonInfo.Pressed = true;
}
else
{
_infoWindow.Close();
_rulesAndInfoWindow.Close();
_buttonInfo.Pressed = false;
}
}
else
{
_infoWindow.OpenCentered();
_rulesAndInfoWindow.OpenCentered();
_buttonInfo.Pressed = true;
}
}