mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 07:28:14 +00:00
you can now bind UI / Menu options to keys in the settings
This commit is contained in:
@@ -49,6 +49,7 @@ func update_direction_textures() -> void:
|
||||
i.frame = int(Track.DIRECTIONS[i.get_index()] == starting_direction)
|
||||
for i in [$Start, $Connect, $End]:
|
||||
i.texture = texture
|
||||
$DirectionArrow.global_rotation = Vector2(connecting_direction).angle()
|
||||
|
||||
func on_mouse_entered(area_idx := 0) -> void:
|
||||
mouse_in_areas |= (1 << area_idx)
|
||||
|
@@ -20,7 +20,7 @@ func update_visuals() -> void:
|
||||
func run_player_check(player: Player) -> void:
|
||||
if Global.player_action_pressed(get_input_direction(enter_direction), player.player_id) and can_enter:
|
||||
can_enter = false
|
||||
Checkpoint.passed = false
|
||||
Checkpoint.passed_checkpoints.clear()
|
||||
player.enter_pipe(self, false)
|
||||
await get_tree().create_timer(1, false).timeout
|
||||
$CanvasLayer.show()
|
||||
|
@@ -34,7 +34,9 @@ var file := {
|
||||
"move_left": "Left",
|
||||
"move_right": "Right",
|
||||
"move_up": "Up",
|
||||
"move_down": "Down"
|
||||
"move_down": "Down",
|
||||
"ui_accept": "Z",
|
||||
"ui_back": "X"
|
||||
},
|
||||
"controller":
|
||||
{
|
||||
@@ -44,7 +46,9 @@ var file := {
|
||||
"move_left": "0,-1",
|
||||
"move_right": "0,1",
|
||||
"move_up": "1,-1",
|
||||
"move_down": "1,1"
|
||||
"move_down": "1,1",
|
||||
"ui_accept": 0,
|
||||
"ui_back": 1
|
||||
},
|
||||
"visuals":
|
||||
{
|
||||
|
@@ -25,7 +25,7 @@ func _exit_tree() -> void:
|
||||
Global.get_node("GameHUD").show()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if Input.is_action_just_pressed("jump_0") and can_skip:
|
||||
if Input.is_action_just_pressed("ui_accept") and can_skip:
|
||||
go_to_menu()
|
||||
|
||||
func go_to_menu() -> void:
|
||||
|
@@ -2,6 +2,7 @@ class_name LevelEditorVisibleNode
|
||||
extends Node2D
|
||||
|
||||
func _ready() -> void:
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
update()
|
||||
if Global.level_editor != null:
|
||||
Global.level_editor.editor_start.connect(update)
|
||||
|
@@ -4,7 +4,7 @@ extends HBoxContainer
|
||||
@export var settings_category := "video"
|
||||
@export var selected := false
|
||||
|
||||
@export var action_name := ""
|
||||
@export var action_names := [""]
|
||||
@export var title := ""
|
||||
|
||||
@export_enum("Keyboard", "Controller") var type := 0
|
||||
@@ -42,10 +42,15 @@ const button_id_translation := [
|
||||
"DPad R"
|
||||
]
|
||||
|
||||
func _ready() -> void:
|
||||
update_value()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if selected:
|
||||
handle_inputs()
|
||||
$Cursor.modulate.a = int(selected)
|
||||
|
||||
func update_value() -> void:
|
||||
$Title.text = tr(title) + ":"
|
||||
$Value.text = get_event_string(input_event) if not awaiting_input else "Press Any..."
|
||||
|
||||
@@ -62,6 +67,7 @@ func begin_remap() -> void:
|
||||
get_parent().can_input = false
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
awaiting_input = true
|
||||
update_value()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if awaiting_input == false: return
|
||||
@@ -82,23 +88,28 @@ func _input(event: InputEvent) -> void:
|
||||
map_event_to_action(event)
|
||||
|
||||
func map_event_to_action(event) -> void:
|
||||
var action = action_name + "_" + str(player_idx)
|
||||
var events = InputMap.action_get_events(action).duplicate()
|
||||
events[type] = event
|
||||
InputMap.action_erase_events(action)
|
||||
for i in events:
|
||||
InputMap.action_add_event(action, i)
|
||||
input_changed.emit(action, event)
|
||||
input_event = event
|
||||
awaiting_input = false
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
rebinding_input = false
|
||||
get_parent().can_input = true
|
||||
can_remap = true
|
||||
for action_name in action_names:
|
||||
var action = action_name
|
||||
if action.contains("ui_") == false:
|
||||
action = action_name + "_" + str(player_idx)
|
||||
var events = InputMap.action_get_events(action).duplicate()
|
||||
events[type] = event
|
||||
InputMap.action_erase_events(action)
|
||||
for i in events:
|
||||
InputMap.action_add_event(action, i)
|
||||
input_changed.emit(action, event)
|
||||
input_event = event
|
||||
awaiting_input = false
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
rebinding_input = false
|
||||
get_parent().can_input = true
|
||||
can_remap = true
|
||||
update_value()
|
||||
|
||||
func get_event_string(event: InputEvent) -> String:
|
||||
var event_string := ""
|
||||
if event is InputEventKey:
|
||||
print(event.keycode)
|
||||
event_string = OS.get_keycode_string(event.keycode)
|
||||
elif event is InputEventJoypadButton:
|
||||
var translation = button_id_translation[event.button_index]
|
||||
@@ -126,6 +137,8 @@ func get_event_string(event: InputEvent) -> String:
|
||||
else:
|
||||
direction = "Down"
|
||||
event_string = stick + " " + direction
|
||||
else:
|
||||
pass
|
||||
return event_string
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
|
Reference in New Issue
Block a user