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

@@ -30,6 +30,8 @@ namespace Content.Client.Administration
private DefaultWindow? _plainWindow; private DefaultWindow? _plainWindow;
private readonly Dictionary<NetUserId, BwoinkPanel> _activePanelMap = new(); private readonly Dictionary<NetUserId, BwoinkPanel> _activePanelMap = new();
public bool IsOpen => (_adminWindow?.IsOpen ?? false) || (_plainWindow?.IsOpen ?? false);
protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs) protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
{ {
base.OnBwoinkTextMessage(message, eventArgs); base.OnBwoinkTextMessage(message, eventArgs);
@@ -119,6 +121,12 @@ namespace Content.Client.Administration
EnsurePlain(channelId.Value); EnsurePlain(channelId.Value);
} }
public void Close()
{
_adminWindow?.Close();
_plainWindow?.Close();
}
private void SelectChannel(NetUserId uid) private void SelectChannel(NetUserId uid)
{ {
_adminWindow ??= new BwoinkWindow(this); _adminWindow ??= new BwoinkWindow(this);

View File

@@ -8,7 +8,7 @@
<changelog:ChangelogButton /> <changelog:ChangelogButton />
<ui:VoteCallMenuButton /> <ui:VoteCallMenuButton />
<Button Name="OptionsButton" Text="{Loc 'ui-escape-options'}" /> <Button Name="OptionsButton" Text="{Loc 'ui-escape-options'}" />
<Button Name="AHelpButton" Text="{Loc 'ui-escape-ahelp'}" /> <Button Name="RulesButton" Text="{Loc 'ui-escape-rules'}" />
<Button Name="DisconnectButton" Text="{Loc 'ui-escape-disconnect'}" /> <Button Name="DisconnectButton" Text="{Loc 'ui-escape-disconnect'}" />
<Button Name="QuitButton" Text="{Loc 'ui-escape-quit'}" /> <Button Name="QuitButton" Text="{Loc 'ui-escape-quit'}" />
</BoxContainer> </BoxContainer>

View File

@@ -1,3 +1,4 @@
using Content.Client.Info;
using Content.Client.Administration; using Content.Client.Administration;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.Console; using Robust.Client.Console;
@@ -25,7 +26,7 @@ namespace Content.Client.EscapeMenu.UI
OptionsButton.OnPressed += OnOptionsButtonClicked; OptionsButton.OnPressed += OnOptionsButtonClicked;
QuitButton.OnPressed += OnQuitButtonClicked; QuitButton.OnPressed += OnQuitButtonClicked;
AHelpButton.OnPressed += OnAHelpButtonClicked; RulesButton.OnPressed += _ => new RulesAndInfoWindow().Open();
DisconnectButton.OnPressed += OnDisconnectButtonClicked; DisconnectButton.OnPressed += OnDisconnectButtonClicked;
} }
@@ -35,13 +36,6 @@ namespace Content.Client.EscapeMenu.UI
Dispose(); Dispose();
} }
private void OnAHelpButtonClicked(BaseButton.ButtonEventArgs args)
{
_consoleHost.ExecuteCommand("openahelp");
// Doing Dispose() here causes issues because you can't un-dispose the escape menu.
// The other commands don't really suffer as much from it. Unsure if bug.
}
private void OnDisconnectButtonClicked(BaseButton.ButtonEventArgs args) private void OnDisconnectButtonClicked(BaseButton.ButtonEventArgs args)
{ {
_consoleHost.ExecuteCommand("disconnect"); _consoleHost.ExecuteCommand("disconnect");

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
ui-escape-title = Esc Menu ui-escape-title = Esc Menu
ui-escape-options = Options ui-escape-options = Options
ui-escape-ahelp = Admin Help ui-escape-rules = Rules
ui-escape-disconnect = Disconnect ui-escape-disconnect = Disconnect
ui-escape-quit = Quit ui-escape-quit = Quit

View File

@@ -110,7 +110,7 @@ ui-options-function-open-character-menu = Open character menu
ui-options-function-open-context-menu = Open context menu ui-options-function-open-context-menu = Open context menu
ui-options-function-open-crafting-menu = Open crafting menu ui-options-function-open-crafting-menu = Open crafting menu
ui-options-function-open-inventory-menu = Open inventory ui-options-function-open-inventory-menu = Open inventory
ui-options-function-open-info = Open server info ui-options-function-open-info = Open admin help
ui-options-function-open-abilities-menu = Open action menu ui-options-function-open-abilities-menu = Open action menu
ui-options-function-open-entity-spawn-window = Open entity spawn menu ui-options-function-open-entity-spawn-window = Open entity spawn menu
ui-options-function-open-sandbox-window = Open sandbox menu ui-options-function-open-sandbox-window = Open sandbox menu