mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
you can now bind UI / Menu options to keys in the settings
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://4gxhnql5bjk6"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://4gxhnql5bjk6"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://50hm4xgnw8ks" path="res://Assets/Sprites/Tilesets/Tracks.png" id="1_84p4k"]
|
||||
[ext_resource type="Script" uid="uid://chhr6kgvstkod" path="res://Scripts/Classes/Entities/Objects/TrackPiece.gd" id="1_t2c2l"]
|
||||
[ext_resource type="Texture2D" uid="uid://barofu3g8jf00" path="res://Assets/Sprites/Tilesets/InvisibleTracks.png" id="2_5cc87"]
|
||||
[ext_resource type="Script" uid="uid://cbal8ms2oe1ik" path="res://Scripts/Classes/Components/ResourceSetterNew.gd" id="3_4ie33"]
|
||||
[ext_resource type="JSON" path="res://Assets/Sprites/Tilesets/Track.json" id="4_5cc87"]
|
||||
[ext_resource type="Script" uid="uid://cpwloakvp672a" path="res://Scripts/Parts/EditorVisibleNode.gd" id="6_yu1nf"]
|
||||
[ext_resource type="Texture2D" uid="uid://dp4b0cpisp5cs" path="res://Assets/Sprites/UI/Arrow.png" id="7_br4q4"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4k6gi"]
|
||||
size = Vector2(12, 12)
|
||||
@@ -203,6 +205,16 @@ mode = 1
|
||||
resource_json = ExtResource("4_5cc87")
|
||||
metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
|
||||
|
||||
[node name="DirectionArrow" type="Node2D" parent="."]
|
||||
script = ExtResource("6_yu1nf")
|
||||
metadata/_custom_type_script = "uid://cpwloakvp672a"
|
||||
|
||||
[node name="Arrow" type="Sprite2D" parent="DirectionArrow"]
|
||||
modulate = Color(0, 1, 1, 1)
|
||||
rotation = -1.5707964
|
||||
texture = ExtResource("7_br4q4")
|
||||
hframes = 2
|
||||
|
||||
[connection signal="mouse_entered" from="PlacePreview/NW/MouseArea" to="." method="on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="PlacePreview/NW/MouseArea" to="." method="on_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="PlacePreview/N/MouseArea" to="." method="on_mouse_entered" binds= [1]]
|
||||
|
@@ -39,7 +39,7 @@ script/source = "extends Node
|
||||
|
||||
var input_nodes := []
|
||||
|
||||
var actions := [\"jump\", \"run\", \"action\", \"move_left\", \"move_right\", \"move_up\", \"move_down\"]
|
||||
var actions := [\"jump\", \"run\", \"action\", \"move_left\", \"move_right\", \"move_up\", \"move_down\", \"ui_accept\", \"ui_back\"]
|
||||
|
||||
@export_enum(\"Keyboard\", \"Controller\") var type := 0
|
||||
|
||||
@@ -53,33 +53,45 @@ func get_input_nodes() -> void:
|
||||
if i is SelectableInputOption:
|
||||
input_nodes.append(i)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if Input.is_action_just_pressed(\"ui_reset_keybindings\"):
|
||||
InputMap.load_from_project_settings()
|
||||
save_inputs()
|
||||
Settings.save_settings()
|
||||
load_inputs()
|
||||
|
||||
func load_inputs() -> void:
|
||||
for i in input_nodes:
|
||||
var action = i.action_name
|
||||
var value = Settings.file[[\"keyboard\", \"controller\"][type]].get(action, null)
|
||||
var event: InputEvent = null
|
||||
if value == null:
|
||||
continue
|
||||
if type == 0:
|
||||
event = InputEventKey.new()
|
||||
event.keycode = OS.find_keycode_from_string(value)
|
||||
elif type == 1:
|
||||
if value is String:
|
||||
var array = value.split(\",\")
|
||||
event = InputEventJoypadMotion.new()
|
||||
event.axis = int(array[0])
|
||||
event.axis_value = int(array[1])
|
||||
elif value is int:
|
||||
event = InputEventJoypadButton.new()
|
||||
event.button_index = value
|
||||
i.map_event_to_action(event)
|
||||
for action_name in i.action_names:
|
||||
var action = action_name
|
||||
var value = Settings.file[[\"keyboard\", \"controller\"][type]].get(action, null)
|
||||
var event: InputEvent = null
|
||||
if value == null:
|
||||
continue
|
||||
if type == 0:
|
||||
event = InputEventKey.new()
|
||||
event.keycode = OS.find_keycode_from_string(value)
|
||||
elif type == 1:
|
||||
if value is String:
|
||||
var array = value.split(\",\")
|
||||
event = InputEventJoypadMotion.new()
|
||||
event.axis = int(array[0])
|
||||
event.axis_value = int(array[1])
|
||||
elif value is int:
|
||||
event = InputEventJoypadButton.new()
|
||||
event.button_index = value
|
||||
i.map_event_to_action(event)
|
||||
|
||||
func update_starting_values() -> void:
|
||||
load_inputs()
|
||||
|
||||
|
||||
func save_inputs() -> void:
|
||||
for i in actions:
|
||||
var event = InputMap.action_get_events(i + \"_0\")[type]
|
||||
var event = null
|
||||
if i.contains(\"ui\"):
|
||||
event = InputMap.action_get_events(i)[type]
|
||||
else:
|
||||
event = InputMap.action_get_events(i + \"_0\")[type]
|
||||
var rep
|
||||
if event is InputEventKey:
|
||||
rep = OS.get_keycode_string(event.keycode)
|
||||
@@ -87,6 +99,8 @@ func save_inputs() -> void:
|
||||
rep = event.button_index
|
||||
elif event is InputEventJoypadMotion:
|
||||
rep = str(event.axis) + \",\" + str(event.axis_value)
|
||||
else:
|
||||
pass
|
||||
Settings.file[[\"keyboard\", \"controller\"][type]][i] = rep
|
||||
"
|
||||
|
||||
@@ -668,12 +682,12 @@ uppercase = true
|
||||
script = ExtResource("10_2qqpf")
|
||||
|
||||
[node name="KeyboardControls" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer" node_paths=PackedStringArray("options")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = -4
|
||||
script = ExtResource("4_avtty")
|
||||
category_name = "SETTINGS_KEYBOARD"
|
||||
options = [NodePath("Jump"), NodePath("Run"), NodePath("Action"), NodePath("Left"), NodePath("Right"), NodePath("Up"), NodePath("Down")]
|
||||
options = [NodePath("Jump"), NodePath("Run"), NodePath("Action"), NodePath("Left"), NodePath("Right"), NodePath("Up"), NodePath("Down"), NodePath("Accept"), NodePath("Back")]
|
||||
|
||||
[node name="Control" type="Control" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls"]
|
||||
custom_minimum_size = Vector2(0, 4)
|
||||
@@ -681,49 +695,67 @@ layout_mode = 2
|
||||
|
||||
[node name="Jump" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "jump"
|
||||
action_names = ["jump"]
|
||||
title = "ACTION_JUMP"
|
||||
|
||||
[node name="Run" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "run"
|
||||
action_names = ["run"]
|
||||
title = "ACTION_RUN"
|
||||
|
||||
[node name="Action" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "action"
|
||||
action_names = ["action"]
|
||||
title = "ACTION_ACTION"
|
||||
|
||||
[node name="Left" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "move_left"
|
||||
action_names = ["move_left", "ui_left"]
|
||||
title = "ACTION_LEFT"
|
||||
|
||||
[node name="Right" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "move_right"
|
||||
action_names = ["move_right", "ui_right"]
|
||||
title = "ACTION_RIGHT"
|
||||
|
||||
[node name="Up" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "move_up"
|
||||
action_names = ["move_up", "ui_up"]
|
||||
title = "ACTION_UP"
|
||||
|
||||
[node name="Down" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_name = "move_down"
|
||||
action_names = ["move_down", "ui_down"]
|
||||
title = "ACTION_DOWN"
|
||||
|
||||
[node name="Accept" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_names = ["ui_accept"]
|
||||
title = "ACCEPT"
|
||||
|
||||
[node name="Back" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
action_names = ["ui_back"]
|
||||
title = "BACK"
|
||||
|
||||
[node name="InputMapSaving" type="Node" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls" groups=["Options"]]
|
||||
process_mode = 3
|
||||
script = SubResource("GDScript_ksnto")
|
||||
|
||||
[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/KeyboardControls"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
text = "PRESS F5 TO RESET BINDINGS."
|
||||
uppercase = true
|
||||
|
||||
[node name="Controller" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer" node_paths=PackedStringArray("options")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = -4
|
||||
script = ExtResource("4_avtty")
|
||||
category_name = "SETTINGS_CONTROLLER"
|
||||
options = [NodePath("Jump"), NodePath("Run"), NodePath("Action"), NodePath("Left"), NodePath("Right"), NodePath("Up"), NodePath("Down")]
|
||||
options = [NodePath("Jump"), NodePath("Run"), NodePath("Action"), NodePath("Left"), NodePath("Right"), NodePath("Up"), NodePath("Down"), NodePath("Accept"), NodePath("Back")]
|
||||
|
||||
[node name="Control" type="Control" parent="PanelContainer/MarginContainer/VBoxContainer/Controller"]
|
||||
custom_minimum_size = Vector2(0, 4)
|
||||
@@ -732,57 +764,78 @@ layout_mode = 2
|
||||
[node name="Jump" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "jump"
|
||||
action_names = ["jump"]
|
||||
title = "ACTION_JUMP"
|
||||
type = 1
|
||||
|
||||
[node name="Run" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "run"
|
||||
action_names = ["run"]
|
||||
title = "ACTION_RUN"
|
||||
type = 1
|
||||
|
||||
[node name="Action" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "action"
|
||||
action_names = ["action"]
|
||||
title = "ACTION_ACTION"
|
||||
type = 1
|
||||
|
||||
[node name="Left" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "move_left"
|
||||
action_names = ["move_left", "ui_left"]
|
||||
title = "ACTION_LEFT"
|
||||
type = 1
|
||||
|
||||
[node name="Right" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "move_right"
|
||||
action_names = ["move_right", "ui_right"]
|
||||
title = "ACTION_RIGHT"
|
||||
type = 1
|
||||
|
||||
[node name="Up" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "move_up"
|
||||
action_names = ["move_up", "ui_up"]
|
||||
title = "ACTION_UP"
|
||||
type = 1
|
||||
|
||||
[node name="Down" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_name = "move_down"
|
||||
action_names = ["move_down", "ui_down"]
|
||||
title = "ACTION_DOWN"
|
||||
type = 1
|
||||
|
||||
[node name="Accept" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_names = ["ui_accept"]
|
||||
title = "ACCEPT"
|
||||
type = 1
|
||||
|
||||
[node name="Back" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"] instance=ExtResource("9_ksnto")]
|
||||
layout_mode = 2
|
||||
settings_category = "controller"
|
||||
action_names = ["ui_back"]
|
||||
title = "BACK"
|
||||
type = 1
|
||||
|
||||
[node name="InputMapSaving" type="Node" parent="PanelContainer/MarginContainer/VBoxContainer/Controller" groups=["Options"]]
|
||||
script = SubResource("GDScript_ksnto")
|
||||
type = 1
|
||||
|
||||
[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/Controller"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
text = "PRESS F5 TO RESET BINDINGS."
|
||||
uppercase = true
|
||||
|
||||
[node name="Data" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer" node_paths=PackedStringArray("options")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = -4
|
||||
script = ExtResource("4_avtty")
|
||||
|
Reference in New Issue
Block a user