2021-03-28 02:40:23 +00:00
|
|
|
using System.Collections.Generic;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.CharacterInfo.Components;
|
2019-07-17 21:37:58 +02:00
|
|
|
using Robust.Client.UserInterface.Controls;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-18 18:39:31 +02:00
|
|
|
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.CharacterInterface
|
2018-12-13 07:47:19 -06:00
|
|
|
{
|
|
|
|
|
/// <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>
|
2019-07-31 15:02:36 +02:00
|
|
|
[RegisterComponent]
|
2021-06-09 22:19:39 +02:00
|
|
|
public class CharacterInterfaceComponent : Component
|
2018-12-13 07:47:19 -06:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2019-07-19 11:15:33 +02:00
|
|
|
/// Window to hold each of the character interfaces
|
2018-12-13 07:47:19 -06:00
|
|
|
/// </summary>
|
2019-07-19 11:15:33 +02:00
|
|
|
/// <remarks>
|
|
|
|
|
/// Null if it would otherwise be empty.
|
|
|
|
|
/// </remarks>
|
2021-12-11 15:12:55 -08:00
|
|
|
public CharacterWindow? Window { get; set; }
|
2021-06-18 01:49:18 -07:00
|
|
|
|
2021-12-11 15:12:55 -08:00
|
|
|
public List<ICharacterUI>? UIComponents;
|
2019-07-17 21:37:58 +02:00
|
|
|
|
2018-12-13 07:47:19 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// A window that collects and shows all the individual character user interfaces
|
|
|
|
|
/// </summary>
|
2022-01-21 01:38:35 -08:00
|
|
|
public class CharacterWindow : DefaultWindow
|
2018-12-13 07:47:19 -06:00
|
|
|
{
|
2020-11-22 08:38:07 +01:00
|
|
|
private readonly List<ICharacterUI> _windowComponents;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
2019-07-19 11:15:33 +02:00
|
|
|
public CharacterWindow(List<ICharacterUI> windowComponents)
|
2018-12-13 07:47:19 -06:00
|
|
|
{
|
2019-05-05 23:14:40 +02:00
|
|
|
Title = "Character";
|
|
|
|
|
|
2021-12-11 15:12:55 -08:00
|
|
|
var contentsVBox = new BoxContainer
|
2021-07-18 18:39:31 +02:00
|
|
|
{
|
|
|
|
|
Orientation = LayoutOrientation.Vertical
|
|
|
|
|
};
|
2021-12-20 22:30:12 -03:00
|
|
|
|
|
|
|
|
var mainScrollContainer = new ScrollContainer { };
|
|
|
|
|
mainScrollContainer.AddChild(contentsVBox);
|
|
|
|
|
|
|
|
|
|
Contents.AddChild(mainScrollContainer);
|
2019-05-05 23:14:40 +02:00
|
|
|
|
2019-07-19 11:15:33 +02:00
|
|
|
windowComponents.Sort((a, b) => ((int) a.Priority).CompareTo((int) b.Priority));
|
|
|
|
|
foreach (var element in windowComponents)
|
2018-12-13 07:47:19 -06:00
|
|
|
{
|
2021-12-11 15:12:55 -08:00
|
|
|
contentsVBox.AddChild(element.Scene);
|
2018-12-13 07:47:19 -06:00
|
|
|
}
|
2020-11-22 08:38:07 +01:00
|
|
|
|
|
|
|
|
_windowComponents = windowComponents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Opened()
|
|
|
|
|
{
|
|
|
|
|
base.Opened();
|
|
|
|
|
foreach (var windowComponent in _windowComponents)
|
|
|
|
|
{
|
|
|
|
|
windowComponent.Opened();
|
|
|
|
|
}
|
2018-12-13 07:47:19 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines ordering of the character user interface, small values come sooner
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum UIPriority
|
|
|
|
|
{
|
|
|
|
|
First = 0,
|
2019-07-20 14:06:54 +02:00
|
|
|
Info = 5,
|
2018-12-13 07:47:19 -06:00
|
|
|
Species = 100,
|
|
|
|
|
Last = 99999
|
|
|
|
|
}
|
|
|
|
|
}
|