mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-06-09 15:06:34 +02:00
bcd3612730
* Commit * add the form post * dv * fixes * Change wording * Address review * wording change * Added some stuff * New format * bruh * thanks perry! * yes * More fixes! * typo * Add a command to show the list, improve the UI slightly, split up command names * Fix UI controller * Add better comment * Get rid of weird recursive thing * Cleanup * Work on moving feedback popups out of simulation * Move round end screen subscription to feedback ui controller * Finish moving feedback popups out of simulation * Fix _ as parameter * Clean up FeedbackPopupUIController * Clean up commands * Fix prototype yaml * Fix openfeedbackpopup command description * Update Resources/Locale/en-US/feedbackpopup/feedbackpopup.ftl Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> * Address reviews * Address reviews * Fix FeedbackPopupPrototype.cs using empty string instead of string.empty * Address some more of the reviews, style nano is still trolling sadly * Fix feedback popup styling * Fix PopupPrototype ID field not having a setter * Address reviews * Add label when no feedback entries are present Change link button to not show when no link is set --------- Co-authored-by: beck-thompson <beck314159@hotmail.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com> Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com>
164 lines
4.6 KiB
C#
164 lines
4.6 KiB
C#
using Content.Client.FeedbackPopup;
|
|
using Content.Client.Gameplay;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Client.UserInterface.Systems.Guidebook;
|
|
using Content.Client.UserInterface.Systems.Info;
|
|
using Content.Shared.CCVar;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Console;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Input;
|
|
using Robust.Shared.Input.Binding;
|
|
using Robust.Shared.Utility;
|
|
using static Robust.Client.UserInterface.Controls.BaseButton;
|
|
|
|
namespace Content.Client.UserInterface.Systems.EscapeMenu;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class EscapeUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>
|
|
{
|
|
[Dependency] private readonly IClientConsoleHost _console = default!;
|
|
[Dependency] private readonly IUriOpener _uri = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly ChangelogUIController _changelog = default!;
|
|
[Dependency] private readonly InfoUIController _info = default!;
|
|
[Dependency] private readonly OptionsUIController _options = default!;
|
|
[Dependency] private readonly GuidebookUIController _guidebook = default!;
|
|
[Dependency] private readonly FeedbackPopupUIController _feedback = null!;
|
|
|
|
private Options.UI.EscapeMenu? _escapeWindow;
|
|
|
|
private MenuButton? EscapeButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.EscapeButton;
|
|
|
|
public void UnloadButton()
|
|
{
|
|
if (EscapeButton == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
EscapeButton.Pressed = false;
|
|
EscapeButton.OnPressed -= EscapeButtonOnOnPressed;
|
|
}
|
|
|
|
public void LoadButton()
|
|
{
|
|
if (EscapeButton == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
EscapeButton.OnPressed += EscapeButtonOnOnPressed;
|
|
}
|
|
|
|
private void ActivateButton() => EscapeButton!.SetClickPressed(true);
|
|
private void DeactivateButton() => EscapeButton!.SetClickPressed(false);
|
|
|
|
public void OnStateEntered(GameplayState state)
|
|
{
|
|
DebugTools.Assert(_escapeWindow == null);
|
|
|
|
_escapeWindow = UIManager.CreateWindow<Options.UI.EscapeMenu>();
|
|
|
|
_escapeWindow.OnClose += DeactivateButton;
|
|
_escapeWindow.OnOpen += ActivateButton;
|
|
|
|
_escapeWindow.FeedbackButton.OnPressed += _ =>
|
|
{
|
|
CloseEscapeWindow();
|
|
_feedback.ToggleWindow();
|
|
};
|
|
|
|
_escapeWindow.ChangelogButton.OnPressed += _ =>
|
|
{
|
|
CloseEscapeWindow();
|
|
_changelog.ToggleWindow();
|
|
};
|
|
|
|
_escapeWindow.RulesButton.OnPressed += _ =>
|
|
{
|
|
CloseEscapeWindow();
|
|
_info.OpenWindow();
|
|
};
|
|
|
|
_escapeWindow.DisconnectButton.OnPressed += _ =>
|
|
{
|
|
CloseEscapeWindow();
|
|
_console.ExecuteCommand("disconnect");
|
|
};
|
|
|
|
_escapeWindow.OptionsButton.OnPressed += _ =>
|
|
{
|
|
CloseEscapeWindow();
|
|
_options.OpenWindow();
|
|
};
|
|
|
|
_escapeWindow.QuitButton.OnPressed += _ =>
|
|
{
|
|
CloseEscapeWindow();
|
|
_console.ExecuteCommand("quit");
|
|
};
|
|
|
|
_escapeWindow.WikiButton.OnPressed += _ =>
|
|
{
|
|
_uri.OpenUri(_cfg.GetCVar(CCVars.InfoLinksWiki));
|
|
};
|
|
|
|
_escapeWindow.GuidebookButton.OnPressed += _ =>
|
|
{
|
|
_guidebook.ToggleGuidebook();
|
|
};
|
|
|
|
// Hide wiki button if we don't have a link for it.
|
|
_escapeWindow.WikiButton.Visible = _cfg.GetCVar(CCVars.InfoLinksWiki) != "";
|
|
|
|
CommandBinds.Builder
|
|
.Bind(EngineKeyFunctions.EscapeMenu,
|
|
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
|
.Register<EscapeUIController>();
|
|
}
|
|
|
|
public void OnStateExited(GameplayState state)
|
|
{
|
|
if (_escapeWindow != null)
|
|
{
|
|
_escapeWindow.Dispose();
|
|
_escapeWindow = null;
|
|
}
|
|
|
|
CommandBinds.Unregister<EscapeUIController>();
|
|
}
|
|
|
|
private void EscapeButtonOnOnPressed(ButtonEventArgs obj)
|
|
{
|
|
ToggleWindow();
|
|
}
|
|
|
|
private void CloseEscapeWindow()
|
|
{
|
|
_escapeWindow?.Close();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Toggles the game menu.
|
|
/// </summary>
|
|
public void ToggleWindow()
|
|
{
|
|
if (_escapeWindow == null)
|
|
return;
|
|
|
|
if (_escapeWindow.IsOpen)
|
|
{
|
|
CloseEscapeWindow();
|
|
EscapeButton!.Pressed = false;
|
|
}
|
|
else
|
|
{
|
|
_escapeWindow.OpenCentered();
|
|
EscapeButton!.Pressed = true;
|
|
}
|
|
}
|
|
}
|