connect missing options in menu

This commit is contained in:
2020-11-08 20:59:09 +01:00
parent d439d67813
commit 4565755868
4 changed files with 53 additions and 31 deletions

46
Menu.gd
View File

@@ -11,10 +11,10 @@ enum Actions {
PREV_TRACK,
# PREV_SKIN,
# NEXT_SKIN,
# PREV_INPUT_MODE,
# NEXT_INPUT_MODE,
# PREV_GAME_MODE,
# NEXT_GAME_MODE,
PREV_INPUT_MODE,
NEXT_INPUT_MODE,
PREV_GAME_MODE,
NEXT_GAME_MODE,
QUIT,
}
var actions = {} # Registered actions
@@ -29,6 +29,11 @@ func _ready():
_connect_action("Options/Return", Actions.EXIT_OPTIONS)
_connect_action("Options/TrackSelection/LeftArrow", Actions.PREV_TRACK)
_connect_action("Options/TrackSelection/RightArrow", Actions.NEXT_TRACK)
_connect_action("Options/GameMode/LeftArrow", Actions.PREV_GAME_MODE)
_connect_action("Options/GameMode/RightArrow", Actions.NEXT_GAME_MODE)
_connect_action("Options/InputMode/LeftArrow", Actions.PREV_INPUT_MODE)
_connect_action("Options/InputMode/RightArrow", Actions.NEXT_INPUT_MODE)
_update_options_values()
TrackSelection.connect("track_changed", self, "_on_track_changed")
_on_track_changed()
@@ -53,6 +58,20 @@ func _input(event):
TrackSelection.set_previous_track()
Actions.NEXT_TRACK:
TrackSelection.set_next_track()
Actions.NEXT_GAME_MODE,Actions.PREV_GAME_MODE:
if Global.settings.game_mode == Global.GameMode.TRAIN:
Global.settings.game_mode = Global.GameMode.EASY
else:
Global.settings.game_mode = Global.GameMode.TRAIN
_update_options_values()
Actions.NEXT_INPUT_MODE,Actions.PREV_INPUT_MODE:
if Global.settings.input_mode == Global.InputMode.MOUSE:
Global.settings.input_mode = Global.InputMode.KEYBOARD
else:
Global.settings.input_mode = Global.InputMode.MOUSE
_update_options_values()
func _on_track_changed():
@@ -64,8 +83,8 @@ func _connect_action(node_path, action):
node.connect("mouse_entered", self, "set_focus", [node])
node.connect("mouse_exited", self, "leave_focus", [node])
actions[node] = action
func set_focus(node):
_set_active(true, node)
_focus = node
@@ -79,4 +98,17 @@ func leave_focus(node):
func _set_active(is_active, node):
# Updates the focus effect for node
var color = Color.orange if is_active else Color.white
node.set("custom_colors/font_color", color)
node.set("custom_colors/font_color", color)
func _update_options_values():
var new_text
match Global.settings.game_mode:
Global.GameMode.EASY: new_text = "Facile"
Global.GameMode.TRAIN: new_text = "Entraînement"
get_node("Options/GameMode/Value").set_text(new_text)
match Global.settings.input_mode:
Global.InputMode.MOUSE: new_text = "Souris"
Global.InputMode.KEYBOARD: new_text = "Clavier"
get_node("Options/InputMode/Value").set_text(new_text)