Skip to content

Commit

Permalink
Separate inventory & character UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Jul 20, 2019
1 parent f5d319b commit c675886
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 7 deletions.
1 change: 1 addition & 0 deletions Content.Client/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public override void Init()
factory.RegisterIgnore("PlayerInputMover");

factory.Register<ExaminerComponent>();
factory.Register<CharacterInfoComponent>();

IoCManager.Register<IGameHud, GameHud>();
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public CharacterWindow(List<ICharacterUI> windowComponents)
public enum UIPriority
{
First = 0,
Info = 5,
Species = 100,
Inventory = 200,
Last = 99999
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public class ClientInventoryComponent : SharedInventoryComponent

private ISpriteComponent _sprite;

//Relevant interface implementation for the character UI controller
public Control Scene => _window;
public UIPriority Priority => UIPriority.Inventory;

public override void OnRemove()
{
base.OnRemove();
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/GameObjects/Components/Mobs/SpeciesUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ namespace Content.Client.GameObjects
/// <summary>
/// A character UI component which shows the current damage state of the mob (living/dead)
/// </summary>
public class SpeciesUI : SharedSpeciesComponent, ICharacterUI
public class SpeciesUI : SharedSpeciesComponent//, ICharacterUI
{
private StatusEffectsUI _ui;

/// <summary>
/// Holds the godot control for the species window
/// Holds the godot control for the species window
/// </summary>
private SpeciesWindow _window;

Expand Down
9 changes: 9 additions & 0 deletions Content.Client/UserInterface/NanoStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Content.Client.UserInterface
public sealed class NanoStyle
{
public const string StyleClassLabelHeading = "LabelHeading";
public const string StyleClassLabelSubText = "LabelSubText";
public const string StyleClassButtonBig = "ButtonBig";
private static readonly Color NanoGold = Color.FromHex("#A88B5E");

Expand All @@ -26,6 +27,7 @@ public sealed class NanoStyle
public NanoStyle()
{
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 notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
var notoSans16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16);
Expand Down Expand Up @@ -421,6 +423,13 @@ public NanoStyle()
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
new StyleRule(new SelectorElement(typeof(Button), new []{StyleClassButtonBig}, null, null), new []
{
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
- type: CombatMode
- type: Teleportable
- type: Examiner
- type: CharacterInfo

- type: entity
id: MobObserver
Expand Down

0 comments on commit c675886

Please sign in to comment.