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

View File

@@ -8,7 +8,7 @@
<changelog:ChangelogButton />
<ui:VoteCallMenuButton />
<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="QuitButton" Text="{Loc 'ui-escape-quit'}" />
</BoxContainer>

View File

@@ -1,3 +1,4 @@
using Content.Client.Info;
using Content.Client.Administration;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
@@ -25,7 +26,7 @@ namespace Content.Client.EscapeMenu.UI
OptionsButton.OnPressed += OnOptionsButtonClicked;
QuitButton.OnPressed += OnQuitButtonClicked;
AHelpButton.OnPressed += OnAHelpButtonClicked;
RulesButton.OnPressed += _ => new RulesAndInfoWindow().Open();
DisconnectButton.OnPressed += OnDisconnectButtonClicked;
}
@@ -35,13 +36,6 @@ namespace Content.Client.EscapeMenu.UI
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)
{
_consoleHost.ExecuteCommand("disconnect");

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();
}
}

View File

@@ -2,7 +2,7 @@
ui-escape-title = Esc Menu
ui-escape-options = Options
ui-escape-ahelp = Admin Help
ui-escape-rules = Rules
ui-escape-disconnect = Disconnect
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-crafting-menu = Open crafting menu
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-entity-spawn-window = Open entity spawn menu
ui-options-function-open-sandbox-window = Open sandbox menu