* Fix this fug oksure Creates the initial species component, damage states, and threshold templates and hooks them into the damageable component * More rebase fixes * test * Pre future rebase * Please * Lol * Lol2 * SHADERS * Update Engine * yml file * Fix an initialization issue, injects dependencies * Fix error in loading shaders * Makes a master character ui controller component added upon client attachment to entity and remove upon client detachment from entity * Fixes just about everytrhing * Address PJB's comments * geeze * Make overlays work in worldspace instead of screen space and not cover user interfaces * update submodule
109 lines
3.4 KiB
C#
109 lines
3.4 KiB
C#
using Content.Client.GameObjects.Components.Mobs;
|
|
using Content.Shared.Input;
|
|
using SS14.Client.Interfaces.Input;
|
|
using SS14.Client.UserInterface.CustomControls;
|
|
using SS14.Shared.GameObjects;
|
|
using SS14.Shared.Input;
|
|
using SS14.Shared.IoC;
|
|
using SS14.Shared.Utility;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Content.Client.GameObjects.Components.Actor
|
|
{
|
|
/// <summary>
|
|
/// A semi-abstract component which gets added to entities upon attachment and collects all character
|
|
/// user interfaces into a single window and keybind for the user
|
|
/// </summary>
|
|
public class CharacterInterface : Component
|
|
{
|
|
public override string Name => "Character Interface Component";
|
|
|
|
/// <summary>
|
|
/// Stored keybind to open the menu on keypress
|
|
/// </summary>
|
|
private InputCmdHandler _openMenuCmdHandler;
|
|
|
|
/// <summary>
|
|
/// Window to hold each of the character interfaces
|
|
/// </summary>
|
|
private SS14Window _window;
|
|
|
|
/// <summary>
|
|
/// Create the window with all character UIs and bind it to a keypress
|
|
/// </summary>
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
//Use all the character ui interfaced components to create the character window
|
|
var UIcomponents = Owner.GetAllComponents<ICharacterUI>();
|
|
_window = new CharacterWindow(UIcomponents);
|
|
|
|
//Add to screen the window and hide it
|
|
_window.AddToScreen();
|
|
_window.Close();
|
|
|
|
//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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dispose of window and the keypress binding
|
|
/// </summary>
|
|
public override void OnRemove()
|
|
{
|
|
base.OnRemove();
|
|
|
|
_window.Dispose();
|
|
_window = null;
|
|
|
|
var inputMgr = IoCManager.Resolve<IInputManager>();
|
|
inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A window that collects and shows all the individual character user interfaces
|
|
/// </summary>
|
|
public class CharacterWindow : SS14Window
|
|
{
|
|
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Mobs/CharacterWindow.tscn");
|
|
|
|
public CharacterWindow(IEnumerable<ICharacterUI> windowcomponents)
|
|
{
|
|
//TODO: sort window components by priority of window component
|
|
foreach(var element in windowcomponents.OrderByDescending(x => x.Priority))
|
|
{
|
|
Contents.AddChild(element.Scene);
|
|
}
|
|
|
|
HideOnClose = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines ordering of the character user interface, small values come sooner
|
|
/// </summary>
|
|
public enum UIPriority
|
|
{
|
|
First = 0,
|
|
Species = 100,
|
|
Inventory = 200,
|
|
Last = 99999
|
|
}
|
|
}
|