Separate inventory & character UI.

This commit is contained in:
Pieter-Jan Briers
2019-07-20 14:06:54 +02:00
parent f5d319bc3a
commit c675886713
7 changed files with 109 additions and 7 deletions

View File

@@ -138,6 +138,7 @@ namespace Content.Client
factory.RegisterIgnore("PlayerInputMover"); factory.RegisterIgnore("PlayerInputMover");
factory.Register<ExaminerComponent>(); factory.Register<ExaminerComponent>();
factory.Register<CharacterInfoComponent>();
IoCManager.Register<IGameHud, GameHud>(); IoCManager.Register<IGameHud, GameHud>();
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>(); IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();

View File

@@ -0,0 +1,95 @@
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.UserInterface;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Actor
{
public sealed class CharacterInfoComponent : Component, ICharacterUI
{
private CharacterInfoControl _control;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IResourceCache _resourceCache;
#pragma warning restore 649
public override string Name => "CharacterInfo";
public Control Scene { get; private set; }
public UIPriority Priority => UIPriority.Info;
public override void OnAdd()
{
base.OnAdd();
Scene = _control = new CharacterInfoControl(_resourceCache, _loc);
}
public override void Initialize()
{
base.Initialize();
if (Owner.TryGetComponent(out ISpriteComponent spriteComponent))
{
_control.SpriteView.Sprite = spriteComponent;
}
_control.NameLabel.Text = Owner.Name;
// ReSharper disable once StringLiteralTypo
_control.SubText.Text = _loc.GetString("Professional Greyshirt");
}
private sealed class CharacterInfoControl : VBoxContainer
{
public SpriteView SpriteView { get; }
public Label NameLabel { get; }
public Label SubText { get; }
public CharacterInfoControl(IResourceCache resourceCache, ILocalizationManager loc)
{
AddChild(new HBoxContainer
{
Children =
{
(SpriteView = new SpriteView()),
new VBoxContainer
{
SizeFlagsVertical = SizeFlags.None,
Children =
{
(NameLabel = new Label()),
(SubText = new Label
{
SizeFlagsVertical = SizeFlags.None,
StyleClasses = {NanoStyle.StyleClassLabelSubText}
})
}
}
}
});
AddChild(new Placeholder(resourceCache)
{
PlaceholderText = loc.GetString("Health & status effects")
});
AddChild(new Placeholder(resourceCache)
{
PlaceholderText = loc.GetString("Objectives")
});
AddChild(new Placeholder(resourceCache)
{
PlaceholderText = loc.GetString("Antagonist Roles")
});
}
}
}
}

View File

@@ -135,8 +135,8 @@ namespace Content.Client.GameObjects.Components.Actor
public enum UIPriority public enum UIPriority
{ {
First = 0, First = 0,
Info = 5,
Species = 100, Species = 100,
Inventory = 200,
Last = 99999 Last = 99999
} }
} }

View File

@@ -51,10 +51,6 @@ namespace Content.Client.GameObjects
private ISpriteComponent _sprite; private ISpriteComponent _sprite;
//Relevant interface implementation for the character UI controller
public Control Scene => _window;
public UIPriority Priority => UIPriority.Inventory;
public override void OnRemove() public override void OnRemove()
{ {
base.OnRemove(); base.OnRemove();

View File

@@ -26,7 +26,7 @@ namespace Content.Client.GameObjects
/// <summary> /// <summary>
/// A character UI component which shows the current damage state of the mob (living/dead) /// A character UI component which shows the current damage state of the mob (living/dead)
/// </summary> /// </summary>
public class SpeciesUI : SharedSpeciesComponent, ICharacterUI public class SpeciesUI : SharedSpeciesComponent//, ICharacterUI
{ {
private StatusEffectsUI _ui; private StatusEffectsUI _ui;

View File

@@ -13,6 +13,7 @@ namespace Content.Client.UserInterface
public sealed class NanoStyle public sealed class NanoStyle
{ {
public const string StyleClassLabelHeading = "LabelHeading"; public const string StyleClassLabelHeading = "LabelHeading";
public const string StyleClassLabelSubText = "LabelSubText";
public const string StyleClassButtonBig = "ButtonBig"; public const string StyleClassButtonBig = "ButtonBig";
private static readonly Color NanoGold = Color.FromHex("#A88B5E"); private static readonly Color NanoGold = Color.FromHex("#A88B5E");
@@ -26,6 +27,7 @@ namespace Content.Client.UserInterface
public NanoStyle() public NanoStyle()
{ {
var resCache = IoCManager.Resolve<IResourceCache>(); var resCache = IoCManager.Resolve<IResourceCache>();
var notoSans10 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 10);
var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12); var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12);
var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14); var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
var notoSans16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16); var notoSans16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16);
@@ -421,6 +423,13 @@ namespace Content.Client.UserInterface
new StyleProperty(Label.StylePropertyFontColor, NanoGold), new StyleProperty(Label.StylePropertyFontColor, NanoGold),
} ), } ),
// Small Label
new StyleRule(new SelectorElement(typeof(Label), new []{StyleClassLabelSubText}, null, null), new []
{
new StyleProperty(Label.StylePropertyFont, notoSans10),
new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
} ),
// Big Button // Big Button
new StyleRule(new SelectorElement(typeof(Button), new []{StyleClassButtonBig}, null, null), new [] new StyleRule(new SelectorElement(typeof(Button), new []{StyleClassButtonBig}, null, null), new []
{ {

View File

@@ -67,6 +67,7 @@
- type: CombatMode - type: CombatMode
- type: Teleportable - type: Teleportable
- type: Examiner - type: Examiner
- type: CharacterInfo
- type: entity - type: entity
id: MobObserver id: MobObserver