Refactored input system
This commit is contained in:
@@ -121,9 +121,14 @@ namespace Content.Client.Chat
|
|||||||
AddChild(outerVBox);
|
AddChild(outerVBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
protected override void KeyBindDown(GUIBoundKeyEventArgs args)
|
||||||
{
|
{
|
||||||
base.MouseDown(e);
|
base.KeyBindDown(args);
|
||||||
|
|
||||||
|
if (!args.CanFocus)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Input.GrabKeyboardFocus();
|
Input.GrabKeyboardFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Client.GameObjects.Components.Weapons.Ranged;
|
using Content.Client.GameObjects.Components.Weapons.Ranged;
|
||||||
using Content.Client.Interfaces.GameObjects;
|
using Content.Client.Interfaces.GameObjects;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.GameObjects.EntitySystems;
|
using Robust.Client.GameObjects.EntitySystems;
|
||||||
@@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
var canFireSemi = _isFirstShot;
|
var canFireSemi = _isFirstShot;
|
||||||
var state = _inputSystem.CmdStates.GetState(ContentKeyFunctions.UseItemInHand);
|
var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use);
|
||||||
if (state != BoundKeyState.Down)
|
if (state != BoundKeyState.Down)
|
||||||
{
|
{
|
||||||
_isFirstShot = true;
|
_isFirstShot = true;
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ namespace Content.Client.Input
|
|||||||
human.AddFunction(ContentKeyFunctions.Drop);
|
human.AddFunction(ContentKeyFunctions.Drop);
|
||||||
human.AddFunction(ContentKeyFunctions.ActivateItemInHand);
|
human.AddFunction(ContentKeyFunctions.ActivateItemInHand);
|
||||||
human.AddFunction(ContentKeyFunctions.OpenCharacterMenu);
|
human.AddFunction(ContentKeyFunctions.OpenCharacterMenu);
|
||||||
human.AddFunction(ContentKeyFunctions.UseItemInHand);
|
|
||||||
human.AddFunction(ContentKeyFunctions.ActivateItemInWorld);
|
human.AddFunction(ContentKeyFunctions.ActivateItemInWorld);
|
||||||
human.AddFunction(ContentKeyFunctions.ThrowItemInHand);
|
human.AddFunction(ContentKeyFunctions.ThrowItemInHand);
|
||||||
human.AddFunction(ContentKeyFunctions.OpenContextMenu);
|
human.AddFunction(ContentKeyFunctions.OpenContextMenu);
|
||||||
human.AddFunction(ContentKeyFunctions.OpenCraftingMenu);
|
human.AddFunction(ContentKeyFunctions.OpenCraftingMenu);
|
||||||
human.AddFunction(ContentKeyFunctions.OpenInventoryMenu);
|
human.AddFunction(ContentKeyFunctions.OpenInventoryMenu);
|
||||||
|
human.AddFunction(ContentKeyFunctions.MouseMiddle);
|
||||||
// Disabled until there is feedback, so hitting tab doesn't suddenly break interaction.
|
// Disabled until there is feedback, so hitting tab doesn't suddenly break interaction.
|
||||||
// human.AddFunction(ContentKeyFunctions.ToggleCombatMode);
|
// human.AddFunction(ContentKeyFunctions.ToggleCombatMode);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Content.Client.GameObjects.EntitySystems;
|
using Content.Client.GameObjects.EntitySystems;
|
||||||
using Content.Client.Interfaces.GameObjects;
|
using Content.Client.Interfaces.GameObjects;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
|
using Content.Shared.Input;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
using Robust.Client.Interfaces.GameObjects.Components;
|
using Robust.Client.Interfaces.GameObjects.Components;
|
||||||
@@ -9,6 +10,7 @@ using Robust.Client.Interfaces.ResourceManagement;
|
|||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
@@ -201,9 +203,14 @@ namespace Content.Client.UserInterface
|
|||||||
return _handL.Contains((Vector2i) point) || _handR.Contains((Vector2i) point);
|
return _handL.Contains((Vector2i) point) || _handR.Contains((Vector2i) point);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MouseDown(GUIMouseButtonEventArgs args)
|
protected override void KeyBindDown(GUIBoundKeyEventArgs args)
|
||||||
{
|
{
|
||||||
base.MouseDown(args);
|
base.KeyBindDown(args);
|
||||||
|
|
||||||
|
if (!args.CanFocus)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var leftHandContains = _handL.Contains((Vector2i)args.RelativePosition);
|
var leftHandContains = _handL.Contains((Vector2i)args.RelativePosition);
|
||||||
var rightHandContains = _handR.Contains((Vector2i)args.RelativePosition);
|
var rightHandContains = _handR.Contains((Vector2i)args.RelativePosition);
|
||||||
@@ -222,7 +229,7 @@ namespace Content.Client.UserInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Button == Mouse.Button.Left)
|
if (args.Function == EngineKeyFunctions.Use)
|
||||||
{
|
{
|
||||||
if (!TryGetHands(out var hands))
|
if (!TryGetHands(out var hands))
|
||||||
return;
|
return;
|
||||||
@@ -238,12 +245,12 @@ namespace Content.Client.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (args.Button == Mouse.Button.Middle)
|
else if (args.Function == ContentKeyFunctions.MouseMiddle)
|
||||||
{
|
{
|
||||||
SendSwitchHandTo(handIndex);
|
SendSwitchHandTo(handIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (args.Button == Mouse.Button.Right)
|
else if (args.Function == ContentKeyFunctions.OpenContextMenu)
|
||||||
{
|
{
|
||||||
if (!TryGetHands(out var hands))
|
if (!TryGetHands(out var hands))
|
||||||
{
|
{
|
||||||
@@ -257,7 +264,7 @@ namespace Content.Client.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
var esm = IoCManager.Resolve<IEntitySystemManager>();
|
var esm = IoCManager.Resolve<IEntitySystemManager>();
|
||||||
esm.GetEntitySystem<VerbSystem>().OpenContextMenu(entity, new ScreenCoordinates(args.GlobalPosition));
|
esm.GetEntitySystem<VerbSystem>().OpenContextMenu(entity, new ScreenCoordinates(args.PointerLocation.Position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>();
|
var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>();
|
||||||
inputSys.BindMap.BindFunction(ContentKeyFunctions.UseItemInHand,
|
inputSys.BindMap.BindFunction(EngineKeyFunctions.Use,
|
||||||
new PointerInputCmdHandler(HandleUseItemInHand));
|
new PointerInputCmdHandler(HandleUseItemInHand));
|
||||||
inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld,
|
inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld,
|
||||||
new PointerInputCmdHandler(HandleActivateItemInWorld));
|
new PointerInputCmdHandler(HandleActivateItemInWorld));
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ namespace Content.Shared.Input
|
|||||||
public static readonly BoundKeyFunction SwapHands = "SwapHands";
|
public static readonly BoundKeyFunction SwapHands = "SwapHands";
|
||||||
public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand";
|
public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand";
|
||||||
public static readonly BoundKeyFunction ToggleCombatMode = "ToggleCombatMode";
|
public static readonly BoundKeyFunction ToggleCombatMode = "ToggleCombatMode";
|
||||||
public static readonly BoundKeyFunction UseItemInHand = "UseItemInHand"; // use hand item on world entity
|
public static readonly BoundKeyFunction MouseMiddle = "MouseMiddle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,78 +1,86 @@
|
|||||||
version: 1 # Not used right now, whatever.
|
version: 1 # Not used right now, whatever.
|
||||||
binds:
|
binds:
|
||||||
|
- function: Use
|
||||||
|
type: state
|
||||||
|
key: MouseLeft
|
||||||
|
canFocus: true
|
||||||
- function: ShowDebugMonitors
|
- function: ShowDebugMonitors
|
||||||
|
type: Toggle
|
||||||
key: F3
|
key: F3
|
||||||
type: Toggle
|
|
||||||
- function: HideUI
|
- function: HideUI
|
||||||
key: F4
|
|
||||||
type: Toggle
|
type: Toggle
|
||||||
|
key: F4
|
||||||
- function: MoveUp
|
- function: MoveUp
|
||||||
|
type: State
|
||||||
key: W
|
key: W
|
||||||
type: State
|
|
||||||
- function: MoveLeft
|
- function: MoveLeft
|
||||||
|
type: State
|
||||||
key: A
|
key: A
|
||||||
type: State
|
|
||||||
- function: MoveRight
|
- function: MoveRight
|
||||||
|
type: State
|
||||||
key: D
|
key: D
|
||||||
type: State
|
|
||||||
- function: MoveDown
|
- function: MoveDown
|
||||||
|
type: State
|
||||||
key: S
|
key: S
|
||||||
type: State
|
|
||||||
- function: Run
|
- function: Run
|
||||||
|
type: State
|
||||||
key: Shift
|
key: Shift
|
||||||
type: State
|
|
||||||
- function: ShowEscapeMenu
|
- function: ShowEscapeMenu
|
||||||
|
type: State
|
||||||
key: Escape
|
key: Escape
|
||||||
type: State
|
|
||||||
- function: FocusChatWindow
|
- function: FocusChatWindow
|
||||||
|
type: State
|
||||||
key: T
|
key: T
|
||||||
type: State
|
|
||||||
- function: EditorLinePlace
|
- function: EditorLinePlace
|
||||||
key: MouseLeft
|
|
||||||
mod1: Shift
|
|
||||||
type: State
|
type: State
|
||||||
|
key: MouseLeft
|
||||||
|
canFocus: true
|
||||||
|
mod1: Shift
|
||||||
- function: EditorGridPlace
|
- function: EditorGridPlace
|
||||||
key: MouseLeft
|
|
||||||
mod1: Control
|
|
||||||
type: State
|
type: State
|
||||||
|
key: MouseLeft
|
||||||
|
canFocus: true
|
||||||
|
mod1: Control
|
||||||
- function: EditorPlaceObject
|
- function: EditorPlaceObject
|
||||||
key: MouseLeft
|
|
||||||
type: State
|
type: State
|
||||||
|
key: MouseLeft
|
||||||
|
canFocus: true
|
||||||
- function: EditorCancelPlace
|
- function: EditorCancelPlace
|
||||||
key: MouseRight
|
|
||||||
type: State
|
type: State
|
||||||
|
key: MouseRight
|
||||||
|
canFocus: true
|
||||||
- function: EditorRotateObject
|
- function: EditorRotateObject
|
||||||
|
type: State
|
||||||
key: MouseMiddle
|
key: MouseMiddle
|
||||||
type: State
|
|
||||||
- function: SwapHands
|
- function: SwapHands
|
||||||
|
type: State
|
||||||
key: X
|
key: X
|
||||||
type: State
|
|
||||||
- function: Drop
|
- function: Drop
|
||||||
|
type: State
|
||||||
key: Q
|
key: Q
|
||||||
type: State
|
|
||||||
- function: ActivateItemInHand
|
- function: ActivateItemInHand
|
||||||
|
type: State
|
||||||
key: Z
|
key: Z
|
||||||
type: State
|
|
||||||
- function: OpenCharacterMenu
|
- function: OpenCharacterMenu
|
||||||
|
type: State
|
||||||
key: C
|
key: C
|
||||||
type: State
|
|
||||||
- function: ExamineEntity
|
- function: ExamineEntity
|
||||||
key: MouseLeft
|
|
||||||
mod1: Shift
|
|
||||||
type: State
|
type: State
|
||||||
- function: UseItemInHand
|
|
||||||
key: MouseLeft
|
key: MouseLeft
|
||||||
type: state
|
canFocus: true
|
||||||
|
mod1: Shift
|
||||||
- function: ActivateItemInWorld
|
- function: ActivateItemInWorld
|
||||||
|
type: state
|
||||||
key: E
|
key: E
|
||||||
type: state
|
|
||||||
- function: ThrowItemInHand
|
- function: ThrowItemInHand
|
||||||
|
type: state
|
||||||
key: MouseLeft
|
key: MouseLeft
|
||||||
|
canFocus: true
|
||||||
mod1: Control
|
mod1: Control
|
||||||
type: state
|
|
||||||
- function: OpenContextMenu
|
- function: OpenContextMenu
|
||||||
key: MouseRight
|
|
||||||
type: state
|
type: state
|
||||||
|
key: MouseRight
|
||||||
|
canFocus: true
|
||||||
- function: ToggleCombatMode
|
- function: ToggleCombatMode
|
||||||
type: Toggle
|
type: Toggle
|
||||||
key: Tab
|
key: Tab
|
||||||
@@ -85,3 +93,10 @@ binds:
|
|||||||
- function: OpenInventoryMenu
|
- function: OpenInventoryMenu
|
||||||
type: state
|
type: state
|
||||||
key: I
|
key: I
|
||||||
|
- function: ShowDebugConsole
|
||||||
|
type: state
|
||||||
|
key: Tilde
|
||||||
|
- function: MouseMiddle
|
||||||
|
type: state
|
||||||
|
key: MouseMiddle
|
||||||
|
canFocus: true
|
||||||
Submodule RobustToolbox updated: 3f7cd1f1b2...a9d8044105
Reference in New Issue
Block a user