Actions System + UI (#2710)

Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
chairbender
2020-12-13 14:28:20 -08:00
committed by GitHub
parent fd0df9a00a
commit 7a3c281f60
150 changed files with 7283 additions and 854 deletions

View File

@@ -1,14 +1,19 @@
using System;
using Robust.Client.Graphics;
using Robust.Client.Graphics.Shaders;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.UserInterface
{
public class ItemSlotButton : MarginContainer
{
private const string HighlightShader = "SelectionOutlineInrange";
public TextureRect Button { get; }
public SpriteView SpriteView { get; }
public SpriteView HoverSpriteView { get; }
@@ -21,9 +26,11 @@ namespace Content.Client.UserInterface
public bool EntityHover => HoverSpriteView.Sprite != null;
public bool MouseIsHovering = false;
private readonly ShaderInstance _highlightShader;
public ItemSlotButton(Texture texture, Texture storageTexture)
{
_highlightShader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>(HighlightShader).Instance();
CustomMinimumSize = (64, 64);
AddChild(Button = new TextureRect
@@ -95,6 +102,20 @@ namespace Content.Client.UserInterface
}
}
public void Highlight(bool on)
{
// I make no claim that this actually looks good but it's a start.
if (on)
{
Button.ShaderOverride = _highlightShader;
}
else
{
Button.ShaderOverride = null;
}
}
private void OnButtonPressed(GUIBoundKeyEventArgs args)
{
OnPressed?.Invoke(args);