Update submodule, UI fixes.

This commit is contained in:
Pieter-Jan Briers
2020-05-05 23:59:31 +02:00
parent b9e59fc8d4
commit cf9edddf2f
6 changed files with 44 additions and 33 deletions

View File

@@ -114,13 +114,13 @@ namespace Content.Client.GameObjects
} }
} }
protected override void HandleInventoryKeybind(BaseButton.ButtonEventArgs args, Slots slot) protected override void HandleInventoryKeybind(GUIBoundKeyEventArgs args, Slots slot)
{ {
if (!_inventoryButtons.TryGetValue(slot, out var buttons)) if (!_inventoryButtons.TryGetValue(slot, out var buttons))
return; return;
if (!Owner.TryGetSlot(slot, out var item)) if (!Owner.TryGetSlot(slot, out var item))
return; return;
if (_itemSlotManager.OnButtonPressed(args.Event, item)) if (_itemSlotManager.OnButtonPressed(args, item))
return; return;
base.HandleInventoryKeybind(args, slot); base.HandleInventoryKeybind(args, slot);

View File

@@ -2,8 +2,9 @@
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Input; using Content.Shared.Input;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -62,39 +63,35 @@ namespace Content.Client.GameObjects
{ {
} }
protected virtual void HandleInventoryKeybind(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) protected virtual void HandleInventoryKeybind(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot)
{ {
if (args.Event.CanFocus) if (args.Function == EngineKeyFunctions.UIClick)
{ {
UseItemOnInventory(args, slot); UseItemOnInventory(slot);
} }
} }
protected void AddToInventory(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) protected void AddToInventory(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot)
{ {
if (!args.Event.CanFocus) if (args.Function != EngineKeyFunctions.UIClick)
{ {
return; return;
} }
args.Button.Pressed = false;
Owner.SendEquipMessage(slot); Owner.SendEquipMessage(slot);
} }
protected void UseItemOnInventory(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) protected void UseItemOnInventory(EquipmentSlotDefines.Slots slot)
{ {
args.Button.Pressed = false;
Owner.SendUseMessage(slot); Owner.SendUseMessage(slot);
} }
protected void OpenStorage(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) protected void OpenStorage(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot)
{ {
if (!args.Event.CanFocus && args.Event.Function != ContentKeyFunctions.ActivateItemInWorld) if (args.Function != EngineKeyFunctions.UIClick && args.Function != ContentKeyFunctions.ActivateItemInWorld)
{ {
return; return;
} }
args.Button.Pressed = false;
Owner.SendOpenStorageUIMessage(slot); Owner.SendOpenStorageUIMessage(slot);
} }

View File

@@ -57,10 +57,10 @@ namespace Content.Client.UserInterface
AddChild(hBox); AddChild(hBox);
_leftButton.OnPressed += args => HandKeyBindDown(args.Event, HandNameLeft); _leftButton.OnPressed += args => HandKeyBindDown(args, HandNameLeft);
_leftButton.OnStoragePressed += args => _OnStoragePressed(args.Event, HandNameLeft); _leftButton.OnStoragePressed += args => _OnStoragePressed(args, HandNameLeft);
_rightButton.OnPressed += args => HandKeyBindDown(args.Event, HandNameRight); _rightButton.OnPressed += args => HandKeyBindDown(args, HandNameRight);
_rightButton.OnStoragePressed += args => _OnStoragePressed(args.Event, HandNameRight); _rightButton.OnStoragePressed += args => _OnStoragePressed(args, HandNameRight);
// Active hand // Active hand
_leftButton.AddChild(ActiveHandRect = new TextureRect _leftButton.AddChild(ActiveHandRect = new TextureRect

View File

@@ -1,5 +1,7 @@
using System; using System;
using Content.Shared.Input;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Maths; using Robust.Shared.Maths;
@@ -8,26 +10,26 @@ namespace Content.Client.GameObjects
{ {
public sealed class ItemSlotButton : MarginContainer public sealed class ItemSlotButton : MarginContainer
{ {
public BaseButton Button { get; } public TextureRect Button { get; }
public SpriteView SpriteView { get; } public SpriteView SpriteView { get; }
public BaseButton StorageButton { get; } public BaseButton StorageButton { get; }
public TextureRect CooldownCircle { get; } public TextureRect CooldownCircle { get; }
public Action<BaseButton.ButtonEventArgs> OnPressed { get; set; } public Action<GUIBoundKeyEventArgs> OnPressed { get; set; }
public Action<BaseButton.ButtonEventArgs> OnStoragePressed { get; set; } public Action<GUIBoundKeyEventArgs> OnStoragePressed { get; set; }
public ItemSlotButton(Texture texture, Texture storageTexture) public ItemSlotButton(Texture texture, Texture storageTexture)
{ {
CustomMinimumSize = (64, 64); CustomMinimumSize = (64, 64);
AddChild(Button = new TextureButton AddChild(Button = new TextureRect
{ {
TextureNormal = texture, Texture = texture,
Scale = (2, 2), TextureScale = (2, 2),
EnableAllKeybinds = true MouseFilter = MouseFilterMode.Stop
}); });
Button.OnPressed += OnButtonPressed; Button.OnKeyBindDown += OnButtonPressed;
AddChild(SpriteView = new SpriteView AddChild(SpriteView = new SpriteView
{ {
@@ -42,9 +44,16 @@ namespace Content.Client.GameObjects
SizeFlagsHorizontal = SizeFlags.ShrinkEnd, SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
SizeFlagsVertical = SizeFlags.ShrinkEnd, SizeFlagsVertical = SizeFlags.ShrinkEnd,
Visible = false, Visible = false,
EnableAllKeybinds = true
}); });
StorageButton.OnKeyBindDown += args =>
{
if (args.Function != EngineKeyFunctions.UIClick)
{
OnButtonPressed(args);
}
};
StorageButton.OnPressed += OnStorageButtonPressed; StorageButton.OnPressed += OnStorageButtonPressed;
AddChild(CooldownCircle = new TextureRect AddChild(CooldownCircle = new TextureRect
@@ -57,20 +66,20 @@ namespace Content.Client.GameObjects
}); });
} }
private void OnButtonPressed(BaseButton.ButtonEventArgs args) private void OnButtonPressed(GUIBoundKeyEventArgs args)
{ {
OnPressed?.Invoke(args); OnPressed?.Invoke(args);
} }
private void OnStorageButtonPressed(BaseButton.ButtonEventArgs args) private void OnStorageButtonPressed(BaseButton.ButtonEventArgs args)
{ {
if (args.Event.Function == EngineKeyFunctions.Use) if (args.Event.Function == EngineKeyFunctions.UIClick)
{ {
OnStoragePressed?.Invoke(args); OnStoragePressed?.Invoke(args.Event);
} }
else else
{ {
OnPressed?.Invoke(args); OnPressed?.Invoke(args.Event);
} }
} }
} }

View File

@@ -1,5 +1,9 @@
version: 1 # Not used right now, whatever. version: 1 # Not used right now, whatever.
binds: binds:
- function: UIClick
type: state
key: MouseLeft
canFocus: true
- function: Use - function: Use
type: state type: state
key: MouseLeft key: MouseLeft
@@ -84,6 +88,7 @@ binds:
- function: ActivateItemInWorld - function: ActivateItemInWorld
type: state type: state
key: E key: E
canFocus: true
- function: ThrowItemInHand - function: ThrowItemInHand
type: state type: state
key: MouseLeft key: MouseLeft