Class KeybindingsManager

java.lang.Object
com.realtime.crossfire.jxclient.gui.keybindings.KeybindingsManager

public class KeybindingsManager extends Object
Manages key bindings.
  • Field Details

    • DEFAULT

      @NotNull public static final @NotNull String DEFAULT
      The source identification string for default key bindings.
      See Also:
    • GLOBAL

      @NotNull public static final @NotNull String GLOBAL
      The source identification string for global key bindings.
      See Also:
    • CHARACTER

      @NotNull public static final @NotNull String CHARACTER
      The source identification string for per-character key bindings.
      See Also:
  • Constructor Details

    • KeybindingsManager

      public KeybindingsManager(@NotNull @NotNull Path keybindingsFileVersion2, @NotNull @NotNull Path keybindingsFileVersion1, @NotNull @NotNull GUICommandFactory guiCommandFactory)
      Creates a new instance.
      Parameters:
      keybindingsFileVersion2 - the global keybindings file
      keybindingsFileVersion1 - the global fallback keybindings file
      guiCommandFactory - the gui command factory for creating commands
  • Method Details

    • setDefaultKeyBindings

      public void setDefaultKeyBindings(@NotNull @NotNull KeyBindings defaultKeyBindings)
      Sets the default KeyBindings of the currently active skin.
      Parameters:
      defaultKeyBindings - the default key bindings
    • removeKeyBinding

      public boolean removeKeyBinding(boolean perCharacter)
      Starts to remove a key binding.
      Parameters:
      perCharacter - whether a per-character key binding should be removed
      Returns:
      whether the key bindings dialog should be opened
    • windowClosing

      public boolean windowClosing()
      Should be called when the main window is closing.
      Returns:
      whether the key bindings dialog should be closed
    • createKeyBinding

      public boolean createKeyBinding(boolean perCharacter, @NotNull @NotNull CommandList cmdList)
      Starts creating a new key binding.
      Parameters:
      perCharacter - whether a per-character key bindings should be created
      cmdList - the commands for the key binding
      Returns:
      whether the key bindings dialog should be opened
    • loadPerCharacterBindings

      public void loadPerCharacterBindings(@NotNull @NotNull CharSequence hostname, @NotNull @NotNull CharSequence character)
      Loads the per-character key bindings. This function should be called when a character logs in.
      Parameters:
      hostname - the character's hostname
      character - the character's name
    • unloadPerCharacterBindings

      public void unloadPerCharacterBindings()
      Unloads (clears and saves) the per-character key bindings. This function should be called when a character logs out.
    • saveGlobalKeybindings

      public void saveGlobalKeybindings()
      Saves the global key bindings to the backing file.
    • loadGlobalKeybindings

      public void loadGlobalKeybindings()
      Loads the global key bindings from the backing file.
    • keyReleased

      public boolean keyReleased()
      Processes a key released event.
      Returns:
      whether the event has been consumed
    • keyPressed

      public boolean keyPressed(@NotNull @NotNull KeyEvent2 keyEvent)
      Processes a key pressed event.
      Parameters:
      keyEvent - the key event
      Returns:
      whether the event has been consumed
    • escPressed

      public boolean escPressed()
      Processes a pressed ESC key.
      Returns:
      whether the event has been consumed and the key bindings dialog should be closed
    • handleKeyPress

      public boolean handleKeyPress(@NotNull @NotNull KeyEvent2 e)
      Processes a key pressed event.
      Parameters:
      e - the key event
      Returns:
      whether the event has been consumed
    • getBindings

      @NotNull public @NotNull Map<KeyBinding,String> getBindings(@NotNull @NotNull Predicate<KeyBinding> predicate)
      Searches bindings having a command text starting with the specified value.
      Parameters:
      predicate - the predicate for selecting keybindings
      Returns:
      the matching bindings; maps key bindings to the source that defines the key binding