···11+class_name RebindableActionButton
22+extends Button
33+44+const INPUT_CONFIG_SECTION = "Input"
55+66+# Set this string to the name of the action in the InputMap
77+@export var action: String
88+99+func _ready():
1010+ var action_events = InputMap.action_get_events(action)
1111+ if action_events.is_empty(): return
1212+ var default_input = action_events[0]
1313+ var config_value = Config.get_config(INPUT_CONFIG_SECTION, action, default_input)
1414+ _update_button_text(config_value)
1515+ if not toggled.is_connected(_on_toggled):
1616+ toggled.connect(_on_toggled)
1717+1818+func _input(input_event: InputEvent) -> void:
1919+ if button_pressed and not input_event is InputEventMouseMotion:
2020+ if not input_event.is_pressed():
2121+ set_pressed_no_signal(false)
2222+ release_focus()
2323+ InputMap.action_erase_events(action)
2424+ InputMap.action_add_event(action, input_event)
2525+ _update_button_text(input_event)
2626+ Config.set_config(INPUT_CONFIG_SECTION, action, input_event)
2727+ grab_focus()
2828+2929+func _update_button_text(input_event: InputEvent) -> void:
3030+ if input_event is InputEventMouseButton:
3131+ if input_event.button_index == MOUSE_BUTTON_LEFT:
3232+ text = "Mouse Left"
3333+ elif input_event.button_index == MOUSE_BUTTON_RIGHT:
3434+ text = "Mouse Right"
3535+ elif input_event.button_index == MOUSE_BUTTON_MIDDLE:
3636+ text = "Mouse Middle"
3737+ else:
3838+ text = input_event.as_text()
3939+4040+func _on_toggled(button_pressed_state):
4141+ if button_pressed_state:
4242+ text = "press a key..."
···11+class_name VolumeSlider
22+extends Slider
33+44+const AUDIO_CONFIG_SECTION = "Audio"
55+66+@export var bus_name: StringName = "Master"
77+# This path can link to an AudioStreamPlayer node to play after the volume has changed.
88+# For a music volume slider it should not be used (music should be playing while in the menu),
99+# but for a sounds volume slider it helps the user adjust to the right volume.
1010+@export var feedback_sound_path: NodePath
1111+1212+var _feedback_sound: AudioStreamPlayer = null
1313+var _original_bus_volume : float = 1.0
1414+1515+var _bus_index = 0
1616+1717+func _ready() -> void:
1818+ if not feedback_sound_path.is_empty():
1919+ _feedback_sound = get_node(feedback_sound_path)
2020+ _bus_index = AudioServer.get_bus_index(bus_name)
2121+ _original_bus_volume = db_to_linear(AudioServer.get_bus_volume_db(_bus_index))
2222+ var config_value = Config.get_config(AUDIO_CONFIG_SECTION, bus_name, 1.0)
2323+ set_value_no_signal(config_value)
2424+ _set_volume(config_value)
2525+ if not value_changed.is_connected(_on_value_changed):
2626+ value_changed.connect(_on_value_changed)
2727+2828+func _set_volume(volume_linear: float) -> void:
2929+ AudioServer.set_bus_volume_db(_bus_index, linear_to_db(volume_linear * _original_bus_volume))
3030+ Config.set_config(AUDIO_CONFIG_SECTION, bus_name, volume_linear)
3131+3232+func _on_value_changed(new_value: float) -> void:
3333+ _set_volume(new_value)
3434+ if _feedback_sound != null:
3535+ if not _feedback_sound.is_playing():
3636+ _feedback_sound.play()
···11+[plugin]
22+33+name="GWJ Accessibility Scripts"
44+description="Scripts for managing accessibility and persistent settings.
55+66+Created by the Godot Wild Jam community."
77+author="Godot Wild Jam"
88+version="0.1.0"
99+script="gwj_accessibility_scripts.gd"