Adds character menu, crafting menu and tutorial to the top left.

This commit is contained in:
Pieter-Jan Briers
2019-07-17 21:37:58 +02:00
parent 69f9da944d
commit 4b9c4022b8
21 changed files with 508 additions and 213 deletions

View File

@@ -1,15 +1,16 @@
using Content.Client.GameObjects.Components.Mobs;
using System.Collections.Generic;
using System.Linq;
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.UserInterface;
using Content.Shared.Input;
using Robust.Client.GameObjects;
using Robust.Client.Interfaces.Input;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
using System.Collections.Generic;
using System.Linq;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.GameObjects.Components.Actor
{
@@ -21,15 +22,15 @@ namespace Content.Client.GameObjects.Components.Actor
{
public override string Name => "Character Interface Component";
/// <summary>
/// Stored keybind to open the menu on keypress
/// </summary>
private InputCmdHandler _openMenuCmdHandler;
[Dependency]
#pragma warning disable 649
private readonly IGameHud _gameHud;
#pragma warning restore 649
/// <summary>
/// Window to hold each of the character interfaces
/// </summary>
private SS14Window _window;
public SS14Window Window { get; private set; }
/// <summary>
/// Create the window with all character UIs and bind it to a keypress
@@ -39,26 +40,11 @@ namespace Content.Client.GameObjects.Components.Actor
base.Initialize();
//Use all the character ui interfaced components to create the character window
var UIcomponents = Owner.GetAllComponents<ICharacterUI>();
_window = new CharacterWindow(UIcomponents);
var uiComponents = Owner.GetAllComponents<ICharacterUI>();
Window = new CharacterWindow(uiComponents);
Window.OnClose += () => _gameHud.CharacterButtonDown = false;
_window.AddToScreen();
//Toggle window visible/invisible on keypress
_openMenuCmdHandler = InputCmdHandler.FromDelegate(session => {
if (_window.Visible)
{
_window.Close();
}
else
{
_window.Open();
}
});
//Set keybind to open character menu
var inputMgr = IoCManager.Resolve<IInputManager>();
inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, _openMenuCmdHandler);
Window.AddToScreen();
}
/// <summary>
@@ -68,13 +54,40 @@ namespace Content.Client.GameObjects.Components.Actor
{
base.OnRemove();
_window.Dispose();
_window = null;
Window.Dispose();
Window = null;
var inputMgr = IoCManager.Resolve<IInputManager>();
inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, null);
}
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
{
base.HandleMessage(message, netChannel, component);
switch (message)
{
case PlayerAttachedMsg playerAttachedMsg:
_gameHud.CharacterButtonVisible = true;
_gameHud.CharacterButtonToggled = b =>
{
if (b)
{
Window.Open();
}
else
{
Window.Close();
}
};
break;
case PlayerDetachedMsg playerDetachedMsg:
_gameHud.CharacterButtonVisible = false;
break;
}
}
/// <summary>
/// A window that collects and shows all the individual character user interfaces
/// </summary>

View File

@@ -1,16 +1,15 @@
using System.Collections.Generic;
using Content.Client.Construction;
using Content.Client.UserInterface;
using Content.Shared.Construction;
using Content.Shared.GameObjects.Components.Construction;
using Robust.Client.GameObjects;
using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.Graphics;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -18,17 +17,19 @@ namespace Content.Client.GameObjects.Components.Construction
{
public class ConstructorComponent : SharedConstructorComponent
{
int nextId;
readonly Dictionary<int, ConstructionGhostComponent> Ghosts = new Dictionary<int, ConstructionGhostComponent>();
ConstructionButton Button;
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
#pragma warning restore 649
ITransformComponent Transform;
private int nextId;
private readonly Dictionary<int, ConstructionGhostComponent> Ghosts = new Dictionary<int, ConstructionGhostComponent>();
public ConstructionMenu ConstructionMenu { get; private set; }
public override void Initialize()
{
base.Initialize();
Transform = Owner.GetComponent<ITransformComponent>();
Owner.GetComponent<ITransformComponent>();
}
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
@@ -38,15 +39,30 @@ namespace Content.Client.GameObjects.Components.Construction
switch (message)
{
case PlayerAttachedMsg _:
if (Button == null)
if (ConstructionMenu == null)
{
Button = new ConstructionButton {Owner = this};
ConstructionMenu = new ConstructionMenu {Owner = this};
ConstructionMenu.OnClose += () => _gameHud.CraftingButtonDown = false;
}
Button.AddToScreen();
ConstructionMenu.AddToScreen();
_gameHud.CraftingButtonVisible = true;
_gameHud.CraftingButtonToggled = b =>
{
if (b)
{
ConstructionMenu.Open();
}
else
{
ConstructionMenu.Close();
}
};
break;
case PlayerDetachedMsg _:
Button.RemoveFromScreen();
ConstructionMenu.Parent.RemoveChild(ConstructionMenu);
_gameHud.CraftingButtonVisible = false;
break;
case AckStructureConstructionMessage ackMsg:
@@ -57,7 +73,7 @@ namespace Content.Client.GameObjects.Components.Construction
public override void OnRemove()
{
Button?.Dispose();
ConstructionMenu?.Dispose();
}
public void SpawnGhost(ConstructionPrototype prototype, GridCoordinates loc, Direction dir)