mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
# Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Ports https://github.com/space-wizards/space-station-14/pull/32294 Ports https://github.com/ss14-harmony/ss14-harmony/pull/310 (and everything needed for it to function) Early-merges https://github.com/space-wizards/space-station-14/pull/34302 Adds the ability for multiple central command maps that get randomly selected. Tested and works. --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Several contributors - add: Added a new central command map that is randomly picked alongside the old one (thank you to Spanky from Harmony) - add: Added Advanced SMES for mappers. - add: Added the atmospheric network monitor for seeing what the temperature, moles, and pressure is on every pipe everywhere through a computer. - add: Nukie med bundle now contains a compact defibrillator. - add: Ported a better mapping editor. - add: Added the throngler plushie. - remove: Removed the Throngler as a possible loot spawn for gamble crates. --------- Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> (cherry picked from commit 9272f65b64392f66a7cd4fd7c84bb152dc93b65a)
224 lines
6.2 KiB
C#
224 lines
6.2 KiB
C#
using Content.Client.Gameplay;
|
|
using Content.Client.Mapping;
|
|
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>, IOnStateEntered<MappingState>, IOnStateExited<MappingState>
|
|
{
|
|
[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!;
|
|
|
|
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.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>();
|
|
}
|
|
|
|
public void OnStateEntered(MappingState state)
|
|
{
|
|
_escapeWindow = UIManager.CreateWindow<Options.UI.EscapeMenu>();
|
|
|
|
_escapeWindow.OnClose += DeactivateButton;
|
|
_escapeWindow.OnOpen += ActivateButton;
|
|
|
|
_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(MappingState 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;
|
|
}
|
|
}
|
|
}
|