Package net.regsirius06.engine.control
Class KeyDefinition
java.lang.Object
net.regsirius06.engine.control.KeyDefinition
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionstatic enumDeprecated.Enumeration of possible actions that can be mapped to keys. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.LoggerDeprecated.Logger instance for logging errors and warnings related to key bindings. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Constructs a newKeyDefinitioninstance with no initial key bindings. -
Method Summary
Modifier and TypeMethodDescriptionfinal @Nullable IntegergetKey(KeyDefinition.Action action) Deprecated.Retrieves the key code associated with a specific action.static KeyDefinitionload()Deprecated.Loads the key bindings from a file named "Settings.ser".final voidsave()Deprecated.Saves the current key bindings to a file named "Settings.ser".final voidsetKey(KeyDefinition.Action action, int keyCode) Deprecated.Sets a key code for a specific action.
-
Field Details
-
log
public static final org.slf4j.Logger logDeprecated.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 newKeyDefinitioninstance 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
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
nullif no key is assigned
-
setKey
Deprecated.Sets a key code for a specific action.- Parameters:
action- the action to associate with the key codekeyCode- the key code to bind to the action (e.g.,KeyEvent.VK_Wfor '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
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
KeyDefinitioninstance with key bindings, or the default key bindings if loading fails
-