Adds a UI element to act as placeholder.

This commit is contained in:
Pieter-Jan Briers
2019-05-14 01:19:25 +02:00
parent 88c29abe5e
commit 96fbde3413
4 changed files with 51 additions and 0 deletions

View File

@@ -124,6 +124,7 @@
<Compile Include="GameObjects\Components\Power\PowerDebugTool.cs" /> <Compile Include="GameObjects\Components\Power\PowerDebugTool.cs" />
<Compile Include="UserInterface\LobbyGui.cs" /> <Compile Include="UserInterface\LobbyGui.cs" />
<Compile Include="UserInterface\NanoStyle.cs" /> <Compile Include="UserInterface\NanoStyle.cs" />
<Compile Include="UserInterface\Placeholder.cs" />
<Compile Include="Utility\ResourceCacheExtensions.cs" /> <Compile Include="Utility\ResourceCacheExtensions.cs" />
<Compile Include="GameObjects\Components\Mobs\SpeciesVisualizer2D.cs" /> <Compile Include="GameObjects\Components\Mobs\SpeciesVisualizer2D.cs" />
</ItemGroup> </ItemGroup>

View File

@@ -20,6 +20,7 @@ namespace Content.Client.UserInterface
{ {
var resCache = IoCManager.Resolve<IResourceCache>(); var resCache = IoCManager.Resolve<IResourceCache>();
var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12); 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 notoSansBold16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 16);
var textureCloseButton = resCache.GetTexture("/Nano/cross.svg.png"); var textureCloseButton = resCache.GetTexture("/Nano/cross.svg.png");
var windowHeaderTex = resCache.GetTexture("/Nano/window_header.png"); var windowHeaderTex = resCache.GetTexture("/Nano/window_header.png");
@@ -140,6 +141,12 @@ namespace Content.Client.UserInterface
tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2); tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5); 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[] Stylesheet = new Stylesheet(new[]
{ {
// Default font. // Default font.
@@ -376,6 +383,18 @@ namespace Content.Client.UserInterface
ContentMarginLeftOverride = 4 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)),
}),
}); });
} }
} }

View File

@@ -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);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B