alexguirre / RAGENativeUI

MIT License
115 stars 38 forks source link

Implement token parser for arbitrary key icons #92

Closed alexguirre closed 4 years ago

alexguirre commented 4 years ago

Add support for parsing ~ tokens for arbitrary key icons in help text (and other scaleforms where SET_FORMATTED_TEXT_WITH_ICONS is used).

Game.DisplayHelp($"Press ~{Keys.LControlKey.GetInstructionalId()}~ ~+~ ~{Keys.E.GetInstructionalId()}~");

Instructional Keys Example

The token format is similar to the strings returned by GET_CONTROL_INSTRUCTIONAL_BUTTON and GET_CONTROL_GROUP_INSTRUCTIONAL_BUTTON. Supported tokens:

Added InstructionalKey enum containing values for keys, mouse buttons, controller buttons and other icons, with GetId() extension method that returns the correct token.

Added GetInstructionalId() and GetInstructionalKey() extensions methods for System.Windows.Forms.Keys and Rage.ControllerButtons enums, to convert them to the correct string token or InstructionalKey value.

Added a constructor to InstructionalButtonId that takes a InstructionalKey.