Merge Brocken Saving of Rempaping
This commit is contained in:
parent
87508f9170
commit
4ad79253b2
4 changed files with 21 additions and 1 deletions
|
@ -13,6 +13,10 @@ func load_data():
|
||||||
"display_mode": 0,
|
"display_mode": 0,
|
||||||
"vsync_on": false,
|
"vsync_on": false,
|
||||||
"current_resolution_index": 0,
|
"current_resolution_index": 0,
|
||||||
|
"move_up": KEY_W,
|
||||||
|
"move_down": KEY_S,
|
||||||
|
"move_left": KEY_A,
|
||||||
|
"move_right": KEY_D,
|
||||||
"master_volume": 0,
|
"master_volume": 0,
|
||||||
"music_volume": 0,
|
"music_volume": 0,
|
||||||
"sfx_volume": 0,
|
"sfx_volume": 0,
|
||||||
|
|
|
@ -4,6 +4,8 @@ extends Node
|
||||||
@export var music_bus_index : int = 1
|
@export var music_bus_index : int = 1
|
||||||
@export var sfx_bus_index : int = 2
|
@export var sfx_bus_index : int = 2
|
||||||
|
|
||||||
|
@export var remappable_input_actions = ["move_up", "move_down", "move_left", "move_right"]
|
||||||
|
|
||||||
const resolutions_dictionary : Dictionary = {
|
const resolutions_dictionary : Dictionary = {
|
||||||
"800x600" : Vector2(800, 600),
|
"800x600" : Vector2(800, 600),
|
||||||
"1024x546" : Vector2(1024, 546),
|
"1024x546" : Vector2(1024, 546),
|
||||||
|
@ -59,3 +61,14 @@ func update_sfx_volume(vol : int) -> void:
|
||||||
Save.save_data()
|
Save.save_data()
|
||||||
AudioServer.set_bus_volume_db(sfx_bus_index, vol)
|
AudioServer.set_bus_volume_db(sfx_bus_index, vol)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Controls
|
||||||
|
func set_controls_from_save_file() -> void:
|
||||||
|
for remappable_input_action in remappable_input_actions:
|
||||||
|
for i in Save.game_data.keys().size():
|
||||||
|
if Save.game_data.keys()[i] == remappable_input_action:
|
||||||
|
for key in InputMap.action_get_events(remappable_input_action):
|
||||||
|
InputMap.action_erase_event(remappable_input_action, key)
|
||||||
|
var control_key = InputEventKey.new()
|
||||||
|
control_key.set_keycode(Save.game_data.values()[i])
|
||||||
|
InputMap.action_add_event(remappable_input_action, control_key)
|
||||||
|
|
|
@ -6,6 +6,7 @@ extends Node
|
||||||
|
|
||||||
# Engine Callbackss
|
# Engine Callbackss
|
||||||
func _ready():
|
func _ready():
|
||||||
|
GlobalSettings.set_controls_from_save_file()
|
||||||
GlobalSettings.set_display_mode(Save.game_data.display_mode)
|
GlobalSettings.set_display_mode(Save.game_data.display_mode)
|
||||||
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
|
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
|
||||||
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
|
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
|
||||||
|
|
|
@ -26,8 +26,10 @@ func remap_key(event):
|
||||||
print(event)
|
print(event)
|
||||||
# Do Actual Rebinding
|
# Do Actual Rebinding
|
||||||
for key in InputMap.action_get_events(remap_action):
|
for key in InputMap.action_get_events(remap_action):
|
||||||
InputMap.action_erase_event(remap_action, key)
|
InputMap.action_erase_event(remap_action, key)
|
||||||
InputMap.action_add_event(remap_action, event)
|
InputMap.action_add_event(remap_action, event)
|
||||||
|
print(event.as_text_keycode())
|
||||||
|
#Save.game_data["%s" % [remap_action]] = event.get_text_keycode()
|
||||||
remap_button.display_key()
|
remap_button.display_key()
|
||||||
remap_button = null
|
remap_button = null
|
||||||
set_process_unhandled_key_input(false)
|
set_process_unhandled_key_input(false)
|
||||||
|
|
Reference in a new issue