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
112 lines
4.0 KiB
C#
112 lines
4.0 KiB
C#
using System;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Robust.Shared.Input
|
|
{
|
|
public enum BoundKeyState : byte
|
|
{
|
|
Up = 0,
|
|
Down = 1
|
|
}
|
|
|
|
[KeyFunctions]
|
|
public static class EngineKeyFunctions
|
|
{
|
|
public static readonly BoundKeyFunction MoveUp = "MoveUp";
|
|
public static readonly BoundKeyFunction MoveDown = "MoveDown";
|
|
public static readonly BoundKeyFunction MoveLeft = "MoveLeft";
|
|
public static readonly BoundKeyFunction MoveRight = "MoveRight";
|
|
public static readonly BoundKeyFunction Run = "Run";
|
|
|
|
public static readonly BoundKeyFunction Use = "Use";
|
|
|
|
public static readonly BoundKeyFunction ShowDebugConsole = "ShowDebugConsole";
|
|
public static readonly BoundKeyFunction ShowDebugMonitors = "ShowDebugMonitors";
|
|
public static readonly BoundKeyFunction HideUI = "HideUI";
|
|
public static readonly BoundKeyFunction EscapeMenu = "ShowEscapeMenu";
|
|
|
|
public static readonly BoundKeyFunction EditorLinePlace = "EditorLinePlace";
|
|
public static readonly BoundKeyFunction EditorGridPlace = "EditorGridPlace";
|
|
public static readonly BoundKeyFunction EditorPlaceObject = "EditorPlaceObject";
|
|
public static readonly BoundKeyFunction EditorCancelPlace = "EditorCancelPlace";
|
|
public static readonly BoundKeyFunction EditorRotateObject = "EditorRotateObject";
|
|
|
|
public static readonly BoundKeyFunction TextCursorLeft = "TextCursorLeft";
|
|
public static readonly BoundKeyFunction TextCursorRight = "TextCursorRight";
|
|
public static readonly BoundKeyFunction TextBackspace = "TextBackspace";
|
|
public static readonly BoundKeyFunction TextSubmit = "TextSubmit";
|
|
public static readonly BoundKeyFunction TextPaste = "TextPaste";
|
|
public static readonly BoundKeyFunction TextHistoryPrev = "TextHistoryPrev";
|
|
public static readonly BoundKeyFunction TextHistoryNext = "TextHistoryNext";
|
|
public static readonly BoundKeyFunction TextReleaseFocus = "TextReleaseFocus";
|
|
public static readonly BoundKeyFunction TextScrollToBottom = "TextScrollToBottom";
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public struct BoundKeyFunction : IComparable, IComparable<BoundKeyFunction>, IEquatable<BoundKeyFunction>
|
|
{
|
|
public readonly string FunctionName;
|
|
|
|
public BoundKeyFunction(string name)
|
|
{
|
|
FunctionName = name;
|
|
}
|
|
|
|
public static implicit operator BoundKeyFunction(string name)
|
|
{
|
|
return new BoundKeyFunction(name);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"KeyFunction({FunctionName})";
|
|
}
|
|
|
|
#region Code for easy equality and sorting.
|
|
|
|
public int CompareTo(object obj)
|
|
{
|
|
return CompareTo((BoundKeyFunction) obj);
|
|
}
|
|
|
|
public int CompareTo(BoundKeyFunction other)
|
|
{
|
|
return string.Compare(FunctionName, other.FunctionName, StringComparison.InvariantCultureIgnoreCase);
|
|
}
|
|
|
|
// Could maybe go dirty and optimize these on the assumption that they're singletons.
|
|
public override bool Equals(object obj)
|
|
{
|
|
return Equals((BoundKeyFunction) obj);
|
|
}
|
|
|
|
public bool Equals(BoundKeyFunction other)
|
|
{
|
|
return other.FunctionName == FunctionName;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return FunctionName.GetHashCode();
|
|
}
|
|
|
|
public static bool operator ==(BoundKeyFunction a, BoundKeyFunction b)
|
|
{
|
|
return a.FunctionName == b.FunctionName;
|
|
}
|
|
|
|
public static bool operator !=(BoundKeyFunction a, BoundKeyFunction b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// Makes all constant strings on this static class be added as input functions.
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class KeyFunctionsAttribute : Attribute { }
|
|
}
|