Improved Inventory / Hand Slots UI (#2965)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Graphics.Shaders;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -26,11 +27,11 @@ namespace Content.Client.UserInterface
|
||||
|
||||
public bool EntityHover => HoverSpriteView.Sprite != null;
|
||||
public bool MouseIsHovering = false;
|
||||
private readonly ShaderInstance _highlightShader;
|
||||
|
||||
private readonly PanelContainer _highlightRect;
|
||||
|
||||
public ItemSlotButton(Texture texture, Texture storageTexture)
|
||||
{
|
||||
_highlightShader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>(HighlightShader).Instance();
|
||||
CustomMinimumSize = (64, 64);
|
||||
|
||||
AddChild(Button = new TextureRect
|
||||
@@ -40,6 +41,13 @@ namespace Content.Client.UserInterface
|
||||
MouseFilter = MouseFilterMode.Stop
|
||||
});
|
||||
|
||||
AddChild(_highlightRect = new PanelContainer
|
||||
{
|
||||
StyleClasses = { StyleNano.StyleClassHandSlotHighlight },
|
||||
CustomMinimumSize = (32, 32),
|
||||
Visible = false
|
||||
});
|
||||
|
||||
Button.OnKeyBindDown += OnButtonPressed;
|
||||
|
||||
AddChild(SpriteView = new SpriteView
|
||||
@@ -102,18 +110,16 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public void Highlight(bool on)
|
||||
public virtual void Highlight(bool highlight)
|
||||
{
|
||||
// I make no claim that this actually looks good but it's a start.
|
||||
if (on)
|
||||
if (highlight)
|
||||
{
|
||||
Button.ShaderOverride = _highlightShader;
|
||||
_highlightRect.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Button.ShaderOverride = null;
|
||||
_highlightRect.Visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnButtonPressed(GUIBoundKeyEventArgs args)
|
||||
|
||||
Reference in New Issue
Block a user