Class KeyDefinition

java.lang.Object
net.regsirius06.engine.control.KeyDefinition
All Implemented Interfaces:
Serializable

@Deprecated public class KeyDefinition extends Object implements Serializable
Deprecated.
This class is deprecated. Consider using alternative key-binding management systems.
This class represents a mapping between actions and key codes for keyboard inputs. It allows defining, retrieving, and saving key bindings for various actions such as movement, rotation, and minimap toggling.

The class provides default key bindings for common actions like movement (W, A, S, D) and minimap (M). It also allows saving and loading the key bindings to and from a file.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Deprecated.
    Enumeration of possible actions that can be mapped to keys.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
    Deprecated.
    Logger instance for logging errors and warnings related to key bindings.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Constructs a new KeyDefinition instance with no initial key bindings.
  • Method Summary

    Modifier and Type
    Method
    Description
    final @Nullable Integer
    Deprecated.
    Retrieves the key code associated with a specific action.
    Deprecated.
    Loads the key bindings from a file named "Settings.ser".
    final void
    Deprecated.
    Saves the current key bindings to a file named "Settings.ser".
    final void
    setKey(KeyDefinition.Action action, int keyCode)
    Deprecated.
    Sets a key code for a specific action.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      public static final org.slf4j.Logger log
      Deprecated.
      Logger instance for logging errors and warnings related to key bindings.

      This logger is used to report issues when saving or loading key bindings, ensuring that errors are recorded without interrupting program execution.

  • Constructor Details

    • KeyDefinition

      public KeyDefinition()
      Deprecated.
      Constructs a new KeyDefinition instance with no initial key bindings. This constructor initializes an empty set of key bindings that can later be configured by the user.
  • Method Details

    • getKey

      @Nullable public final @Nullable Integer getKey(KeyDefinition.Action action)
      Deprecated.
      Retrieves the key code associated with a specific action.
      Parameters:
      action - the action whose key code is to be retrieved
      Returns:
      the key code for the given action, or null if no key is assigned
    • setKey

      public final void setKey(KeyDefinition.Action action, int keyCode)
      Deprecated.
      Sets a key code for a specific action.
      Parameters:
      action - the action to associate with the key code
      keyCode - the key code to bind to the action (e.g., KeyEvent.VK_W for 'W' key)
    • save

      public final void save()
      Deprecated.
      Saves the current key bindings to a file named "Settings.ser".

      The key bindings are serialized and written to the file for persistent storage. If an error occurs during the saving process, a log entry is created instead of throwing an exception.

    • load

      public static KeyDefinition load()
      Deprecated.
      Loads the key bindings from a file named "Settings.ser".

      If the file is found and successfully read, the stored key bindings are loaded. If the file is missing, corrupted, or cannot be read, the default key bindings are returned. Errors are logged but do not interrupt execution.

      Returns:
      the loaded KeyDefinition instance with key bindings, or the default key bindings if loading fails