mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Fixes right click menu stopping input Removed a flag change when the modal stack was showing, which preventing the click from getting passed to the next function. * Added parsing for mod2 and mod3 from Keybind YAML * Fixes a crash on context change when a keybind is not defined in keybinds.yml * Implemented ShowDebugConsole Hotkey * Refactored input system Refactored input system to run Key and Mouse input through the InputManager before doing stuff. * Upgraded LineEdit and classes that use it. Fixed input while KeyboardFocused. Upgraded LineEdit to use Keybinds. Upgraded DebugConsole to use Keybinds. Replaced all references to MouseDown, MouseUp, KeyDown, and KeyUp with KeyBindUp and KeyBindDown. Moved UserInterfaceManager call from GameController.Input to InputManager event. Stopped input going to simulation while a control has focus in UserInterfaceManager. * Some fixes for input system Fixed keybinds getting stuck when selecting a LineEdit. Changed MenuBar to not error. Fixed a few cases where LineEdit would eat input if you hovered over it and where mouse input got eaten when clicking in the world while a LineEdit was selected. * Removed extra dependencies * Added GUIBoundKeyEventArgs to ButtonEventArgs * Fixes for input with LineEdit selected Fixed multiple keybinds mapped to the same key not triggering. Fixed keybind input not getting to LineEdit when hovering over a control. * Implemented Key Repeat for LineEdit * Fix for input on Robust.Lite Launcher * Renames NonFocusKeybinds to EnableAllKeybinds Renamed NonFocusKeybinds to EnableAllKeybinds and added comment to clarify usage * Adds repeating keybinds Used for TextBackspace, TextCursorLeft, and TextCursorRight Reverts a change to LineEdit that implemented repeating keys Adds some documentation comments
204 lines
6.0 KiB
C#
204 lines
6.0 KiB
C#
using Robust.Client.Input;
|
|
using Robust.Client.Utility;
|
|
using Robust.Shared.Input;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using System;
|
|
|
|
namespace Robust.Client.UserInterface
|
|
{
|
|
public partial class Control
|
|
{
|
|
protected internal virtual void MouseEntered()
|
|
{
|
|
}
|
|
|
|
protected internal virtual void MouseExited()
|
|
{
|
|
}
|
|
|
|
protected internal virtual void MouseWheel(GUIMouseWheelEventArgs args)
|
|
{
|
|
}
|
|
|
|
public event Action<GUIBoundKeyEventArgs> OnKeyBindDown;
|
|
|
|
protected internal virtual void KeyBindDown(GUIBoundKeyEventArgs args)
|
|
{
|
|
OnKeyBindDown?.Invoke(args);
|
|
}
|
|
|
|
protected internal virtual void KeyBindUp(GUIBoundKeyEventArgs args)
|
|
{
|
|
}
|
|
|
|
protected internal virtual void MouseMove(GUIMouseMoveEventArgs args)
|
|
{
|
|
}
|
|
|
|
protected internal virtual void KeyHeld(GUIKeyEventArgs args)
|
|
{
|
|
}
|
|
|
|
protected internal virtual void TextEntered(GUITextEventArgs args)
|
|
{
|
|
}
|
|
}
|
|
|
|
public class GUIBoundKeyEventArgs : BoundKeyEventArgs
|
|
{
|
|
/// <summary>
|
|
/// Position of the mouse, relative to the current control.
|
|
/// </summary>
|
|
public Vector2 RelativePosition { get; internal set; }
|
|
|
|
public Vector2 RelativePixelPosition { get; internal set; }
|
|
|
|
public GUIBoundKeyEventArgs(BoundKeyFunction function, BoundKeyState state, ScreenCoordinates pointerLocation,
|
|
bool canFocus, Vector2 relativePosition, Vector2 relativePixelPosition)
|
|
: base(function, state, pointerLocation, canFocus)
|
|
{
|
|
RelativePosition = relativePosition;
|
|
RelativePixelPosition = relativePixelPosition;
|
|
}
|
|
}
|
|
|
|
public class GUIKeyEventArgs : KeyEventArgs
|
|
{
|
|
/// <summary>
|
|
/// The control spawning this event.
|
|
/// </summary>
|
|
public Control SourceControl { get; }
|
|
|
|
public GUIKeyEventArgs(Control sourceControl,
|
|
Keyboard.Key key,
|
|
bool repeat,
|
|
bool alt,
|
|
bool control,
|
|
bool shift,
|
|
bool system)
|
|
: base(key, repeat, alt, control, shift, system)
|
|
{
|
|
SourceControl = sourceControl;
|
|
}
|
|
}
|
|
|
|
public class GUITextEventArgs : TextEventArgs
|
|
{
|
|
/// <summary>
|
|
/// The control spawning this event.
|
|
/// </summary>
|
|
public Control SourceControl { get; }
|
|
|
|
public GUITextEventArgs(Control sourceControl,
|
|
uint codePoint)
|
|
: base(codePoint)
|
|
{
|
|
SourceControl = sourceControl;
|
|
}
|
|
}
|
|
|
|
public abstract class GUIMouseEventArgs : ModifierInputEventArgs
|
|
{
|
|
/// <summary>
|
|
/// The control spawning this event.
|
|
/// </summary>
|
|
public Control SourceControl { get; internal set; }
|
|
|
|
/// <summary>
|
|
/// <c>InputEventMouse.button_mask</c> in Godot.
|
|
/// Which mouse buttons are currently held maybe?
|
|
/// </summary>
|
|
public Mouse.ButtonMask ButtonMask { get; }
|
|
|
|
/// <summary>
|
|
/// Position of the mouse, relative to the screen.
|
|
/// </summary>
|
|
public Vector2 GlobalPosition { get; }
|
|
|
|
public Vector2 GlobalPixelPosition { get; }
|
|
|
|
/// <summary>
|
|
/// Position of the mouse, relative to the current control.
|
|
/// </summary>
|
|
public Vector2 RelativePosition { get; internal set; }
|
|
|
|
public Vector2 RelativePixelPosition { get; internal set; }
|
|
|
|
protected GUIMouseEventArgs(Control sourceControl,
|
|
Mouse.ButtonMask buttonMask,
|
|
Vector2 globalPosition,
|
|
Vector2 globalPixelPosition,
|
|
Vector2 relativePosition,
|
|
Vector2 relativePixelPosition,
|
|
bool alt,
|
|
bool control,
|
|
bool shift,
|
|
bool system)
|
|
: base(alt, control, shift, system)
|
|
{
|
|
SourceControl = sourceControl;
|
|
ButtonMask = buttonMask;
|
|
GlobalPosition = globalPosition;
|
|
RelativePosition = relativePosition;
|
|
RelativePixelPosition = relativePixelPosition;
|
|
GlobalPixelPosition = globalPixelPosition;
|
|
}
|
|
}
|
|
|
|
public class GUIMouseMoveEventArgs : GUIMouseEventArgs
|
|
{
|
|
/// <summary>
|
|
/// The new position relative to the previous position.
|
|
/// </summary>
|
|
public Vector2 Relative { get; }
|
|
|
|
// TODO: Godot's docs aren't exactly clear on what this is.
|
|
// Speed how?
|
|
/// <summary>
|
|
/// The speed of the movement.
|
|
/// </summary>
|
|
public Vector2 Speed { get; }
|
|
|
|
// ALL the parameters!
|
|
public GUIMouseMoveEventArgs(Vector2 relative,
|
|
Vector2 speed,
|
|
Control sourceControl,
|
|
Mouse.ButtonMask buttonMask,
|
|
Vector2 globalPosition,
|
|
Vector2 globalPixelPosition,
|
|
Vector2 relativePosition,
|
|
Vector2 relativePixelPosition,
|
|
bool alt,
|
|
bool control,
|
|
bool shift,
|
|
bool system)
|
|
: base(sourceControl, buttonMask, globalPosition, globalPixelPosition, relativePosition, relativePixelPosition, alt, control, shift, system)
|
|
{
|
|
Relative = relative;
|
|
Speed = speed;
|
|
}
|
|
}
|
|
|
|
public class GUIMouseWheelEventArgs : GUIMouseEventArgs
|
|
{
|
|
public Vector2 Delta { get; }
|
|
|
|
public GUIMouseWheelEventArgs(Vector2 delta,
|
|
Control sourceControl,
|
|
Mouse.ButtonMask buttonMask,
|
|
Vector2 globalPosition,
|
|
Vector2 globalPixelPosition,
|
|
Vector2 relativePosition,
|
|
Vector2 relativePixelPosition,
|
|
bool alt,
|
|
bool control,
|
|
bool shift,
|
|
bool system)
|
|
: base(sourceControl, buttonMask, globalPosition, globalPixelPosition, relativePosition, relativePixelPosition, alt, control, shift, system)
|
|
{
|
|
Delta = delta;
|
|
}
|
|
}
|
|
}
|