From 96fbde341326aa656c4c898cbcff9edd99fa8234 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 14 May 2019 01:19:25 +0200 Subject: [PATCH] Adds a UI element to act as placeholder. --- Content.Client/Content.Client.csproj | 1 + Content.Client/UserInterface/NanoStyle.cs | 19 ++++++++++++ Content.Client/UserInterface/Placeholder.cs | 31 ++++++++++++++++++++ Resources/Nano/placeholder.png | Bin 0 -> 271 bytes 4 files changed, 51 insertions(+) create mode 100644 Content.Client/UserInterface/Placeholder.cs create mode 100644 Resources/Nano/placeholder.png diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index 9740c1c11e..0eaf694e59 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -124,6 +124,7 @@ + diff --git a/Content.Client/UserInterface/NanoStyle.cs b/Content.Client/UserInterface/NanoStyle.cs index c173895609..ab7e904bdd 100644 --- a/Content.Client/UserInterface/NanoStyle.cs +++ b/Content.Client/UserInterface/NanoStyle.cs @@ -20,6 +20,7 @@ namespace Content.Client.UserInterface { var resCache = IoCManager.Resolve(); var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12); + var notoSans16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16); var notoSansBold16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 16); var textureCloseButton = resCache.GetTexture("/Nano/cross.svg.png"); var windowHeaderTex = resCache.GetTexture("/Nano/window_header.png"); @@ -140,6 +141,12 @@ namespace Content.Client.UserInterface tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2); tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5); + // Placeholder + var placeholderTexture = resCache.GetTexture("/Nano/placeholder.png"); + var placeholder = new StyleBoxTexture { Texture = placeholderTexture }; + placeholder.SetPatchMargin(StyleBox.Margin.All, 24); + placeholder.SetExpandMargin(StyleBox.Margin.All, -5); + Stylesheet = new Stylesheet(new[] { // Default font. @@ -376,6 +383,18 @@ namespace Content.Client.UserInterface ContentMarginLeftOverride = 4 }) }), + + // Placeholder + new StyleRule(new SelectorElement(typeof(Placeholder), null, null, null), new [] + { + new StyleProperty(PanelContainer.StylePropertyPanel, placeholder), + }), + + new StyleRule(new SelectorElement(typeof(Label), new []{Placeholder.StyleClassPlaceholderText}, null, null), new [] + { + new StyleProperty(Label.StylePropertyFont, notoSans16), + new StyleProperty(Label.StylePropertyFontColor, new Color(103, 103, 103, 128)), + }), }); } } diff --git a/Content.Client/UserInterface/Placeholder.cs b/Content.Client/UserInterface/Placeholder.cs new file mode 100644 index 0000000000..d6a196d6c1 --- /dev/null +++ b/Content.Client/UserInterface/Placeholder.cs @@ -0,0 +1,31 @@ +using Robust.Client.Interfaces.ResourceManagement; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.UserInterface +{ + public sealed class Placeholder : PanelContainer + { + public const string StyleClassPlaceholderText = "PlaceholderText"; + + private readonly Label _label; + + public string PlaceholderText + { + get => _label.Text; + set => _label.Text = value; + } + + public Placeholder(IResourceCache _resourceCache) + { + _label = new Label + { + SizeFlagsHorizontal = SizeFlags.Fill, + SizeFlagsVertical = SizeFlags.Fill, + Align = Label.AlignMode.Center, + VAlign = Label.VAlignMode.Center + }; + _label.AddStyleClass(StyleClassPlaceholderText); + AddChild(_label); + } + } +} diff --git a/Resources/Nano/placeholder.png b/Resources/Nano/placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..bdae339c2aab400c239fb499382fd3dc39d5d19d GIT binary patch literal 271 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nC-&H|6fVg?31We{epSZZGe6g=qZ z;uw-~@9nHat_B4jH{V^Wk57<2d^>D{;vzRT!?(5eEe_Y^ZfDKxES5w}~XVNQKITY&avSzX$w-S+ArMUG<(+L)tq|1L~MIT9+ZJ(uEsyemD Q9_SecPgg&ebxsLQ097+%tpET3 literal 0 HcmV?d00001