Files
DungeonCrawlerWorld/scripts/game/input_bindings.gd
T

96 lines
2.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class_name InputBindings
extends RefCounted
# The Input Map owns physical bindings; this catalog gives every rebindable action
# its stable identifier, player command and user-facing French help name.
const ACTIONS: Array[StringName] = [
# Modifier shortcuts must be checked before their unmodified key (Ctrl+S
# before south), otherwise Godot also considers the physical S match.
&"save",
&"interact",
&"move_north",
&"move_south",
&"move_west",
&"move_east",
&"move_northwest",
&"move_northeast",
&"move_southwest",
&"move_southeast",
&"wait",
&"ranged",
&"cast",
&"talk",
&"rest",
&"inventory",
&"crafting",
&"character",
&"quest",
&"companion",
&"party",
&"achievements",
&"audience",
&"recap",
&"factions",
&"moderation",
&"map",
&"options",
&"help",
&"toggle_log",
]
const HELP_NAMES := {
&"move_north": "Déplacer vers le nord",
&"move_south": "Déplacer vers le sud",
&"move_west": "Déplacer vers l’ouest",
&"move_east": "Déplacer vers l’est",
&"move_northwest": "Déplacer vers le nord-ouest",
&"move_northeast": "Déplacer vers le nord-est",
&"move_southwest": "Déplacer vers le sud-ouest",
&"move_southeast": "Déplacer vers le sud-est",
&"wait": "Attendre",
&"interact": "Interagir",
&"ranged": "Attaque à distance / choisir une cible",
&"save": "Sauvegarder manuellement (V ou Ctrl+S)",
&"cast": "Lancer un sort",
&"talk": "Parler",
&"rest": "Se reposer",
&"inventory": "Inventaire",
&"crafting": "Artisanat",
&"character": "Personnage",
&"quest": "Quêtes",
&"companion": "Compagnon",
&"party": "Groupe",
&"achievements": "Succès",
&"audience": "Audience",
&"recap": "Récapitulatif",
&"factions": "Factions",
&"moderation": "Modération",
&"map": "Carte",
&"options": "Options",
&"help": "Aide",
&"toggle_log": "Afficher le journal",
}
const MOVE_DIRECTIONS := {
&"move_north": Vector2i.UP,
&"move_south": Vector2i.DOWN,
&"move_west": Vector2i.LEFT,
&"move_east": Vector2i.RIGHT,
&"move_northwest": Vector2i(-1, -1),
&"move_northeast": Vector2i(1, -1),
&"move_southwest": Vector2i(-1, 1),
&"move_southeast": Vector2i(1, 1),
}
static func input_actions() -> Array[StringName]:
return ACTIONS.duplicate()
static func help_name_for(input_action: StringName) -> String:
return HELP_NAMES.get(input_action, "")
static func direction_for(input_action: StringName) -> Vector2i:
return MOVE_DIRECTIONS.get(input_action, Vector2i.ZERO)
static func player_action_for(input_action: StringName) -> StringName:
return &"move" if MOVE_DIRECTIONS.has(input_action) else input_action