Compare commits

..

2 commits

Author SHA1 Message Date
07aa3c846b Fixing Rebind, (With Saving) 2023-04-11 00:27:26 +02:00
4ad79253b2 Merge Brocken Saving of Rempaping 2023-04-10 23:55:55 +02:00
8 changed files with 30 additions and 47 deletions

View file

@ -41,7 +41,7 @@
[ext_resource type="StyleBox" uid="uid://0jfr1uwuog0s" path="res://Assets/UI/Slider/v/background.tres" id="39_dl1e4"] [ext_resource type="StyleBox" uid="uid://0jfr1uwuog0s" path="res://Assets/UI/Slider/v/background.tres" id="39_dl1e4"]
[ext_resource type="FontFile" uid="uid://dqdeftjkwxe64" path="res://Assets/Fonts/Dogica/dogicapixel.ttf" id="40_bmcvq"] [ext_resource type="FontFile" uid="uid://dqdeftjkwxe64" path="res://Assets/Fonts/Dogica/dogicapixel.ttf" id="40_bmcvq"]
[sub_resource type="Image" id="Image_kwuuq"] [sub_resource type="Image" id="Image_cw2pn"]
data = { data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0), "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0),
"format": "RGBA8", "format": "RGBA8",
@ -51,7 +51,7 @@ data = {
} }
[sub_resource type="ImageTexture" id="ImageTexture_g5bup"] [sub_resource type="ImageTexture" id="ImageTexture_g5bup"]
image = SubResource("Image_kwuuq") image = SubResource("Image_cw2pn")
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_sj7h5"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_sj7h5"]

View file

@ -195,7 +195,6 @@ vertical_alignment = 1
[node name="MoveUpRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")] [node name="MoveUpRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
layout_mode = 2 layout_mode = 2
toggle_mode = true
script = ExtResource("2_4asaa") script = ExtResource("2_4asaa")
input_action_name = "move_up" input_action_name = "move_up"
remap_controller = NodePath("../../../../../Remap Controller") remap_controller = NodePath("../../../../../Remap Controller")
@ -209,7 +208,6 @@ vertical_alignment = 1
[node name="MoveLeftRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")] [node name="MoveLeftRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
toggle_mode = true
script = ExtResource("2_4asaa") script = ExtResource("2_4asaa")
input_action_name = "move_left" input_action_name = "move_left"
remap_controller = NodePath("../../../../../Remap Controller") remap_controller = NodePath("../../../../../Remap Controller")
@ -223,7 +221,6 @@ vertical_alignment = 1
[node name="MoveDownRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")] [node name="MoveDownRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
toggle_mode = true
script = ExtResource("2_4asaa") script = ExtResource("2_4asaa")
input_action_name = "move_down" input_action_name = "move_down"
remap_controller = NodePath("../../../../../Remap Controller") remap_controller = NodePath("../../../../../Remap Controller")
@ -238,7 +235,6 @@ vertical_alignment = 1
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
focus_neighbor_bottom = NodePath("../../../../../Back Button") focus_neighbor_bottom = NodePath("../../../../../Back Button")
toggle_mode = true
script = ExtResource("2_4asaa") script = ExtResource("2_4asaa")
input_action_name = "move_right" input_action_name = "move_right"
remap_controller = NodePath("../../../../../Remap Controller") remap_controller = NodePath("../../../../../Remap Controller")

View file

@ -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,

View file

@ -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,19 @@ 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)
pass
func set_control_binding(action : String, keycode : int):
print(keycode)
pass

View file

@ -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)

View file

@ -1,38 +0,0 @@
extends TextureButton
@export var text : String = "Sample Text"
@export var pointer_margin_from_center : int = 100
@export var leftPointer : Sprite2D
@export var rightPointer : Sprite2D
@export var textBox : RichTextLabel
# Engine Callbacks
func _ready():
textBox.parse_bbcode("[center] %s [/center]" % [text])
pass
func _process(_delta):
handle_hover_and_focus()
handle_x_position()
func handle_hover_and_focus() -> void:
if has_focus():
leftPointer.visible = true
rightPointer.visible = true
elif is_hovered():
leftPointer.visible = true
leftPointer.modulate.a = 0.5
rightPointer.visible = true
rightPointer.modulate.a = 0.5
else:
leftPointer.visible = false
leftPointer.modulate.a = 1
rightPointer.visible = false
rightPointer.modulate.a = 1
pass
func handle_x_position() -> void:
var center_x = get_parent().position.x + (get_parent().size.x / 2.0)
leftPointer.global_position.x = center_x - pointer_margin_from_center
rightPointer.global_position.x = center_x + pointer_margin_from_center
pass

View file

@ -20,15 +20,16 @@ func start_remap(button : Button, action : String):
remap_action = action remap_action = action
remap_button.text = "..." remap_button.text = "..."
set_process_unhandled_key_input(true) set_process_unhandled_key_input(true)
button.release_focus()
pass pass
func remap_key(event): func remap_key(event):
print(event) set_process_unhandled_key_input(false)
# 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)
Save.game_data["%s" % [remap_action]] = event.keycode
remap_button.display_key() remap_button.display_key()
remap_button.grab_focus()
remap_button = null remap_button = null
set_process_unhandled_key_input(false)
pass pass

View file

@ -67,6 +67,7 @@ func add_resolution_items():
# Other Buttons # Other Buttons
func _on_back_pressed(): func _on_back_pressed():
Save.save_data()
on_back.call() on_back.call()
queue_free() queue_free()
pass pass