Swap the positions of AHelp and Rules in the main interface (#7957)

suggested by Kaylie
This commit is contained in:
20kdc
2022-05-06 04:46:33 +01:00
committed by GitHub
parent d332c829e8
commit 330fb13b25
7 changed files with 26 additions and 62 deletions

View File

@@ -49,8 +49,7 @@ public interface IButtonBarView
event Action<bool> SandboxButtonToggled;
// Info top button
bool InfoButtonDown { get; set; }
event Action<bool> InfoButtonToggled;
event Action InfoButtonPressed;
}
internal sealed partial class GameHud
@@ -196,32 +195,18 @@ internal sealed partial class GameHud
{
ToolTip = Loc.GetString("ui-options-function-open-info"),
MinSize = topMinSize,
StyleClasses = { StyleBase.ButtonOpenLeft, TopButton.StyleClassRedTopButton },
StyleClasses = { StyleBase.ButtonOpenLeft },
ToggleMode = false
};
topButtonsContainer.AddChild(_buttonInfo);
_buttonInfo.OnToggled += args => InfoButtonToggled?.Invoke(args.Pressed);
_buttonInfo.OnToggled += ButtonInfoToggledHandler;
_buttonInfo.OnPressed += args => InfoButtonPressed?.Invoke();
}
return topButtonsContainer;
}
private void ButtonInfoToggledHandler(BaseButton.ButtonToggledEventArgs obj)
{
ButtonInfoToggled(obj.Pressed);
}
private void ButtonInfoToggled(bool pressed)
{
if(!pressed)
return;
_buttonInfo.StyleClasses.Remove(TopButton.StyleClassRedTopButton);
_buttonInfo.OnToggled -= ButtonInfoToggledHandler;
}
/// <inheritdoc />
public bool EscapeButtonDown
{
@@ -335,16 +320,5 @@ internal sealed partial class GameHud
public event Action<bool>? SandboxButtonToggled;
/// <inheritdoc />
public bool InfoButtonDown
{
get => _buttonInfo.Pressed;
set
{
_buttonInfo.Pressed = value;
ButtonInfoToggled(value);
}
}
/// <inheritdoc />
public event Action<bool>? InfoButtonToggled;
public event Action? InfoButtonPressed;
}

View File

@@ -2,6 +2,7 @@ using System;
using System.Linq;
using Content.Client.HUD.UI;
using Content.Client.Info;
using Content.Client.Administration;
using Content.Client.Resources;
using Content.Client.Targeting;
using Content.Shared.CCVar;
@@ -55,7 +56,6 @@ namespace Content.Client.HUD
internal sealed partial class GameHud : IGameHud
{
private RulesAndInfoWindow _rulesAndInfoWindow = default!;
private TargetingDoll _targetingDoll = default!;
private BoxContainer _combatPanelContainer = default!;
private BoxContainer _topNotificationContainer = default!;
@@ -129,13 +129,10 @@ namespace Content.Client.HUD
RootControl.AddChild(GenerateButtonBar(_resourceCache, _inputManager));
InventoryButtonToggled += down => TopInventoryQuickButtonContainer.Visible = down;
InfoButtonToggled += _ => ButtonInfoOnOnToggled();
_rulesAndInfoWindow = new RulesAndInfoWindow();
_rulesAndInfoWindow.OnClose += () => InfoButtonDown = false;
InfoButtonPressed += () => ButtonInfoOnPressed();
_inputManager.SetInputCommand(ContentKeyFunctions.OpenInfo,
InputCmdHandler.FromDelegate(s => ButtonInfoOnOnToggled()));
InputCmdHandler.FromDelegate(s => ButtonInfoOnPressed()));
_combatPanelContainer = new BoxContainer
{
@@ -256,25 +253,16 @@ namespace Content.Client.HUD
LC.SetGrowVertical(VoteContainer, LC.GrowDirection.End);
}
private void ButtonInfoOnOnToggled()
private void ButtonInfoOnPressed()
{
if (_rulesAndInfoWindow.IsOpen)
var bwoinkSystem = EntitySystem.Get<BwoinkSystem>();
if (bwoinkSystem.IsOpen)
{
if (!_rulesAndInfoWindow.IsAtFront())
{
_rulesAndInfoWindow.MoveToFront();
InfoButtonDown = true;
}
else
{
_rulesAndInfoWindow.Close();
InfoButtonDown = false;
}
bwoinkSystem.Close();
}
else
{
_rulesAndInfoWindow.OpenCentered();
InfoButtonDown = true;
bwoinkSystem.Open();
}
}