Move Escape Menu to Content.
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
<Compile Include="Chat\ChatManager.cs" />
|
||||
<Compile Include="Commands\DebugCommands.cs" />
|
||||
<Compile Include="EntryPoint.cs" />
|
||||
<Compile Include="EscapeMenuOwner.cs" />
|
||||
<Compile Include="GameObjects\Components\Actor\CharacterInterface.cs" />
|
||||
<Compile Include="GameObjects\Components\DamageableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Doors\AirlockVisualizer2D.cs" />
|
||||
@@ -120,6 +121,7 @@
|
||||
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />
|
||||
<Compile Include="Research\LatheMenu.cs" />
|
||||
<Compile Include="Research\LatheQueueMenu.cs" />
|
||||
<Compile Include="UserInterface\EscapeMenu.cs" />
|
||||
<Compile Include="UserInterface\HandsGui.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\PowerDebugTool.cs" />
|
||||
<Compile Include="UserInterface\LobbyGui.cs" />
|
||||
|
||||
@@ -12,14 +12,12 @@ using Content.Client.Interfaces;
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Content.Client.Interfaces.Parallax;
|
||||
using Content.Client.Parallax;
|
||||
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||
using Content.Shared.Interfaces;
|
||||
using Robust.Client;
|
||||
using Robust.Client.Interfaces;
|
||||
using Robust.Client.Interfaces.Graphics.Overlays;
|
||||
using Robust.Client.Interfaces.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -31,14 +29,14 @@ using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.GameObjects.Components.Research;
|
||||
using Content.Client.GameObjects.Components.Sound;
|
||||
using Content.Client.Interfaces.Chat;
|
||||
using Content.Client.Research;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.GameObjects.Components.Markers;
|
||||
using Content.Shared.GameObjects.Components.Materials;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Research;
|
||||
using Robust.Client.Interfaces.State;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Client.State.States;
|
||||
|
||||
namespace Content.Client
|
||||
{
|
||||
@@ -46,6 +44,7 @@ namespace Content.Client
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPlayerManager _playerManager;
|
||||
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override void Init()
|
||||
@@ -139,6 +138,7 @@ namespace Content.Client
|
||||
IoCManager.Register<IClientGameTicker, ClientGameTicker>();
|
||||
IoCManager.Register<IParallaxManager, ParallaxManager>();
|
||||
IoCManager.Register<IChatManager, ChatManager>();
|
||||
IoCManager.Register<IEscapeMenuOwner, EscapeMenuOwner>();
|
||||
IoCManager.BuildGraph();
|
||||
|
||||
IoCManager.Resolve<IParallaxManager>().LoadParallax();
|
||||
@@ -146,11 +146,13 @@ namespace Content.Client
|
||||
|
||||
var stylesheet = new NanoStyle();
|
||||
|
||||
IoCManager.Resolve<IUserInterfaceManager>().Stylesheet = stylesheet.Stylesheet;
|
||||
IoCManager.Resolve<IUserInterfaceManager>().Stylesheet = stylesheet.Stylesheet;
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
_escapeMenuOwner.Initialize();
|
||||
}
|
||||
/// <summary>
|
||||
/// Subscribe events to the player manager after the player manager is set up
|
||||
/// </summary>
|
||||
|
||||
88
Content.Client/EscapeMenuOwner.cs
Normal file
88
Content.Client/EscapeMenuOwner.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Content.Client.UserInterface;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.Input;
|
||||
using Robust.Client.Interfaces.Placement;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.Interfaces.State;
|
||||
using Robust.Client.State.States;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client
|
||||
{
|
||||
internal sealed class EscapeMenuOwner : IEscapeMenuOwner
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IStateManager _stateManager;
|
||||
[Dependency] private readonly IDisplayManager _displayManager;
|
||||
[Dependency] private readonly IClientConsole _clientConsole;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
||||
[Dependency] private readonly IPlacementManager _placementManager;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||
[Dependency] private readonly IResourceCache _resourceCache;
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager;
|
||||
[Dependency] private readonly IInputManager _inputManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
private EscapeMenu _escapeMenu;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_stateManager.OnStateChanged += StateManagerOnOnStateChanged;
|
||||
}
|
||||
|
||||
private void StateManagerOnOnStateChanged(StateChangedEventArgs obj)
|
||||
{
|
||||
if (obj.NewState is GameScreen)
|
||||
{
|
||||
// Switched TO GameScreen.
|
||||
_escapeMenu = new EscapeMenu(_displayManager, _clientConsole, _tileDefinitionManager, _placementManager,
|
||||
_prototypeManager, _resourceCache, _configurationManager)
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
|
||||
_escapeMenu.AddToScreen();
|
||||
|
||||
var escapeMenuCommand = InputCmdHandler.FromDelegate(session =>
|
||||
{
|
||||
if (_escapeMenu.Visible)
|
||||
{
|
||||
if (_escapeMenu.IsAtFront())
|
||||
{
|
||||
_escapeMenu.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_escapeMenu.MoveToFront();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_escapeMenu.OpenCentered();
|
||||
}
|
||||
});
|
||||
|
||||
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand);
|
||||
}
|
||||
else if (obj.OldState is GameScreen)
|
||||
{
|
||||
// Switched FROM GameScreen.
|
||||
_escapeMenu.Dispose();
|
||||
_escapeMenu = null;
|
||||
|
||||
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEscapeMenuOwner
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
121
Content.Client/UserInterface/EscapeMenu.cs
Normal file
121
Content.Client/UserInterface/EscapeMenu.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.Placement;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
internal sealed class EscapeMenu : SS14Window
|
||||
{
|
||||
private readonly IClientConsole _console;
|
||||
private readonly ITileDefinitionManager __tileDefinitionManager;
|
||||
private readonly IPlacementManager _placementManager;
|
||||
private readonly IPrototypeManager _prototypeManager;
|
||||
private readonly IResourceCache _resourceCache;
|
||||
private readonly IDisplayManager _displayManager;
|
||||
private readonly IConfigurationManager _configSystem;
|
||||
|
||||
private BaseButton QuitButton;
|
||||
private BaseButton OptionsButton;
|
||||
private BaseButton SpawnEntitiesButton;
|
||||
private BaseButton SpawnTilesButton;
|
||||
private OptionsMenu optionsMenu;
|
||||
|
||||
public EscapeMenu(IDisplayManager displayManager,
|
||||
IClientConsole console,
|
||||
ITileDefinitionManager tileDefinitionManager,
|
||||
IPlacementManager placementManager,
|
||||
IPrototypeManager prototypeManager,
|
||||
IResourceCache resourceCache,
|
||||
IConfigurationManager configSystem) : base(displayManager)
|
||||
{
|
||||
_configSystem = configSystem;
|
||||
_displayManager = displayManager;
|
||||
_console = console;
|
||||
__tileDefinitionManager = tileDefinitionManager;
|
||||
_placementManager = placementManager;
|
||||
_prototypeManager = prototypeManager;
|
||||
_resourceCache = resourceCache;
|
||||
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
private void PerformLayout()
|
||||
{
|
||||
optionsMenu = new OptionsMenu(_displayManager, _configSystem)
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
optionsMenu.AddToScreen();
|
||||
|
||||
Resizable = false;
|
||||
HideOnClose = true;
|
||||
|
||||
Title = "Menu";
|
||||
|
||||
var vBox = new VBoxContainer {SeparationOverride = 2};
|
||||
Contents.AddChild(vBox);
|
||||
|
||||
SpawnEntitiesButton = new Button {Text = "Spawn Entities"};
|
||||
SpawnEntitiesButton.OnPressed += OnSpawnEntitiesButtonClicked;
|
||||
vBox.AddChild(SpawnEntitiesButton);
|
||||
|
||||
SpawnTilesButton = new Button {Text = "Spawn Tiles"};
|
||||
SpawnTilesButton.OnPressed += OnSpawnTilesButtonClicked;
|
||||
vBox.AddChild(SpawnTilesButton);
|
||||
|
||||
// Add a spacer.
|
||||
vBox.AddChild(new Control { CustomMinimumSize = (0, 5)});
|
||||
|
||||
OptionsButton = new Button {Text = "Options"};
|
||||
OptionsButton.OnPressed += OnOptionsButtonClicked;
|
||||
vBox.AddChild(OptionsButton);
|
||||
|
||||
QuitButton = new Button {Text = "Quit"};
|
||||
QuitButton.OnPressed += OnQuitButtonClicked;
|
||||
vBox.AddChild(QuitButton);
|
||||
|
||||
Size = CombinedMinimumSize;
|
||||
}
|
||||
|
||||
private void OnQuitButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
_console.ProcessCommand("disconnect");
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void OnOptionsButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
optionsMenu.OpenCentered();
|
||||
}
|
||||
|
||||
private void OnSpawnEntitiesButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
var window = new EntitySpawnWindow(_displayManager, _placementManager, _prototypeManager, _resourceCache);
|
||||
window.AddToScreen();
|
||||
window.OpenToLeft();
|
||||
}
|
||||
|
||||
private void OnSpawnTilesButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
var window = new TileSpawnWindow(__tileDefinitionManager, _placementManager, _displayManager, _resourceCache);
|
||||
window.AddToScreen();
|
||||
window.OpenToLeft();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
optionsMenu.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Submodule RobustToolbox updated: bb7288d26a...3bad55a705
Reference in New Issue
Block a user