Add gdlint and gdformat scripts
This commit is contained in:
@@ -14,27 +14,27 @@ signal back_to_main_menu
|
||||
# Progress reset confirmation dialog
|
||||
var confirmation_dialog: AcceptDialog
|
||||
|
||||
|
||||
# Navigation system variables
|
||||
var navigable_controls: Array[Control] = []
|
||||
var current_control_index: int = 0
|
||||
var original_control_scales: Array[Vector2] = []
|
||||
var original_control_modulates: Array[Color] = []
|
||||
|
||||
func _ready():
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("localizable")
|
||||
DebugManager.log_info("SettingsMenu ready", "Settings")
|
||||
# Language selector is initialized automatically
|
||||
|
||||
var master_callback = _on_volume_slider_changed.bind("master_volume")
|
||||
var master_callback: Callable = _on_volume_slider_changed.bind("master_volume")
|
||||
if not master_slider.value_changed.is_connected(master_callback):
|
||||
master_slider.value_changed.connect(master_callback)
|
||||
|
||||
var music_callback = _on_volume_slider_changed.bind("music_volume")
|
||||
var music_callback: Callable = _on_volume_slider_changed.bind("music_volume")
|
||||
if not music_slider.value_changed.is_connected(music_callback):
|
||||
music_slider.value_changed.connect(music_callback)
|
||||
|
||||
var sfx_callback = _on_volume_slider_changed.bind("sfx_volume")
|
||||
var sfx_callback: Callable = _on_volume_slider_changed.bind("sfx_volume")
|
||||
if not sfx_slider.value_changed.is_connected(sfx_callback):
|
||||
sfx_slider.value_changed.connect(sfx_callback)
|
||||
|
||||
@@ -45,37 +45,41 @@ func _ready():
|
||||
_setup_navigation_system()
|
||||
_setup_confirmation_dialog()
|
||||
|
||||
func _update_controls_from_settings():
|
||||
|
||||
func _update_controls_from_settings() -> void:
|
||||
master_slider.value = settings_manager.get_setting("master_volume")
|
||||
music_slider.value = settings_manager.get_setting("music_volume")
|
||||
sfx_slider.value = settings_manager.get_setting("sfx_volume")
|
||||
|
||||
# Language display is handled by the ValueStepper component
|
||||
|
||||
func _on_volume_slider_changed(value, setting_key):
|
||||
|
||||
func _on_volume_slider_changed(value: float, setting_key: String) -> void:
|
||||
# Input validation for volume settings
|
||||
if not setting_key in ["master_volume", "music_volume", "sfx_volume"]:
|
||||
DebugManager.log_error("Invalid volume setting key: " + str(setting_key), "Settings")
|
||||
return
|
||||
|
||||
if not (value is float or value is int):
|
||||
if typeof(value) != TYPE_FLOAT and typeof(value) != TYPE_INT:
|
||||
DebugManager.log_error("Invalid volume value type: " + str(typeof(value)), "Settings")
|
||||
return
|
||||
|
||||
# Clamp value to valid range
|
||||
var clamped_value = clamp(float(value), 0.0, 1.0)
|
||||
var clamped_value: float = clamp(float(value), 0.0, 1.0)
|
||||
if clamped_value != value:
|
||||
DebugManager.log_warn("Volume value %f clamped to %f" % [value, clamped_value], "Settings")
|
||||
|
||||
if not settings_manager.set_setting(setting_key, clamped_value):
|
||||
DebugManager.log_error("Failed to set volume setting: " + setting_key, "Settings")
|
||||
|
||||
func _exit_settings():
|
||||
|
||||
func _exit_settings() -> void:
|
||||
DebugManager.log_info("Exiting settings", "Settings")
|
||||
settings_manager.save_settings()
|
||||
back_to_main_menu.emit()
|
||||
|
||||
func _input(event):
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("action_east") or event.is_action_pressed("pause_menu"):
|
||||
DebugManager.log_debug("Cancel/back action pressed in settings", "Settings")
|
||||
_exit_settings()
|
||||
@@ -103,14 +107,14 @@ func _input(event):
|
||||
_activate_current_control()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _on_back_button_pressed():
|
||||
|
||||
func _on_back_button_pressed() -> void:
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Back button pressed", "Settings")
|
||||
_exit_settings()
|
||||
|
||||
|
||||
|
||||
func update_text():
|
||||
func update_text() -> void:
|
||||
$SettingsContainer/SettingsTitle.text = tr("settings_title")
|
||||
$SettingsContainer/MasterVolumeContainer/MasterVolume.text = tr("master_volume")
|
||||
$SettingsContainer/MusicVolumeContainer/MusicVolume.text = tr("music_volume")
|
||||
@@ -127,7 +131,8 @@ func _on_reset_setting_button_pressed() -> void:
|
||||
_update_controls_from_settings()
|
||||
localization_manager.change_language(settings_manager.get_setting("language"))
|
||||
|
||||
func _setup_navigation_system():
|
||||
|
||||
func _setup_navigation_system() -> void:
|
||||
navigable_controls.clear()
|
||||
original_control_scales.clear()
|
||||
original_control_modulates.clear()
|
||||
@@ -148,7 +153,8 @@ func _setup_navigation_system():
|
||||
|
||||
_update_visual_selection()
|
||||
|
||||
func _navigate_controls(direction: int):
|
||||
|
||||
func _navigate_controls(direction: int) -> void:
|
||||
AudioManager.play_ui_click()
|
||||
current_control_index = (current_control_index + direction) % navigable_controls.size()
|
||||
if current_control_index < 0:
|
||||
@@ -156,32 +162,36 @@ func _navigate_controls(direction: int):
|
||||
_update_visual_selection()
|
||||
DebugManager.log_info("Settings navigation: index " + str(current_control_index), "Settings")
|
||||
|
||||
func _adjust_current_control(direction: int):
|
||||
|
||||
func _adjust_current_control(direction: int) -> void:
|
||||
if current_control_index < 0 or current_control_index >= navigable_controls.size():
|
||||
return
|
||||
|
||||
var control = navigable_controls[current_control_index]
|
||||
var control: Control = navigable_controls[current_control_index]
|
||||
|
||||
# Handle sliders
|
||||
if control is HSlider:
|
||||
var slider = control as HSlider
|
||||
var step = slider.step if slider.step > 0 else 0.1
|
||||
var new_value = slider.value + (direction * step)
|
||||
var slider: HSlider = control as HSlider
|
||||
var step: float = slider.step if slider.step > 0 else 0.1
|
||||
var new_value: float = slider.value + (direction * step)
|
||||
new_value = clamp(new_value, slider.min_value, slider.max_value)
|
||||
slider.value = new_value
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Slider adjusted: %s = %f" % [_get_control_name(control), new_value], "Settings")
|
||||
DebugManager.log_info(
|
||||
"Slider adjusted: %s = %f" % [_get_control_name(control), new_value], "Settings"
|
||||
)
|
||||
|
||||
# Handle language stepper with left/right
|
||||
elif control == language_stepper:
|
||||
if language_stepper.handle_input_action("move_left" if direction == -1 else "move_right"):
|
||||
AudioManager.play_ui_click()
|
||||
|
||||
func _activate_current_control():
|
||||
|
||||
func _activate_current_control() -> void:
|
||||
if current_control_index < 0 or current_control_index >= navigable_controls.size():
|
||||
return
|
||||
|
||||
var control = navigable_controls[current_control_index]
|
||||
var control: Control = navigable_controls[current_control_index]
|
||||
|
||||
# Handle buttons
|
||||
if control is Button:
|
||||
@@ -193,7 +203,8 @@ func _activate_current_control():
|
||||
elif control == language_stepper:
|
||||
DebugManager.log_info("Language stepper selected - use left/right to change", "Settings")
|
||||
|
||||
func _update_visual_selection():
|
||||
|
||||
func _update_visual_selection() -> void:
|
||||
for i in range(navigable_controls.size()):
|
||||
var control = navigable_controls[i]
|
||||
if i == current_control_index:
|
||||
@@ -211,6 +222,7 @@ func _update_visual_selection():
|
||||
control.scale = original_control_scales[i]
|
||||
control.modulate = original_control_modulates[i]
|
||||
|
||||
|
||||
func _get_control_name(control: Control) -> String:
|
||||
if control == master_slider:
|
||||
return "master_volume"
|
||||
@@ -223,10 +235,15 @@ func _get_control_name(control: Control) -> String:
|
||||
else:
|
||||
return "button"
|
||||
|
||||
func _on_language_stepper_value_changed(new_value: String, new_index: int):
|
||||
DebugManager.log_info("Language changed via ValueStepper: " + new_value + " (index: " + str(new_index) + ")", "Settings")
|
||||
|
||||
func _setup_confirmation_dialog():
|
||||
func _on_language_stepper_value_changed(new_value: String, new_index: float) -> void:
|
||||
DebugManager.log_info(
|
||||
"Language changed via ValueStepper: " + new_value + " (index: " + str(int(new_index)) + ")",
|
||||
"Settings"
|
||||
)
|
||||
|
||||
|
||||
func _setup_confirmation_dialog() -> void:
|
||||
"""Create confirmation dialog for progress reset"""
|
||||
confirmation_dialog = AcceptDialog.new()
|
||||
confirmation_dialog.title = tr("confirm_reset_title")
|
||||
@@ -244,7 +261,8 @@ func _setup_confirmation_dialog():
|
||||
|
||||
add_child(confirmation_dialog)
|
||||
|
||||
func _on_reset_progress_button_pressed():
|
||||
|
||||
func _on_reset_progress_button_pressed() -> void:
|
||||
"""Handle reset progress button press with confirmation"""
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Reset progress button pressed", "Settings")
|
||||
@@ -257,7 +275,8 @@ func _on_reset_progress_button_pressed():
|
||||
# Show confirmation dialog
|
||||
confirmation_dialog.popup_centered()
|
||||
|
||||
func _on_reset_progress_confirmed():
|
||||
|
||||
func _on_reset_progress_confirmed() -> void:
|
||||
"""Actually reset the progress after confirmation"""
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Progress reset confirmed by user", "Settings")
|
||||
@@ -267,7 +286,7 @@ func _on_reset_progress_confirmed():
|
||||
DebugManager.log_info("All progress successfully reset", "Settings")
|
||||
|
||||
# Show success message
|
||||
var success_dialog = AcceptDialog.new()
|
||||
var success_dialog: AcceptDialog = AcceptDialog.new()
|
||||
success_dialog.title = tr("reset_success_title")
|
||||
success_dialog.dialog_text = tr("reset_success_message")
|
||||
success_dialog.ok_button_text = tr("ok")
|
||||
@@ -283,7 +302,7 @@ func _on_reset_progress_confirmed():
|
||||
DebugManager.log_error("Failed to reset progress", "Settings")
|
||||
|
||||
# Show error message
|
||||
var error_dialog = AcceptDialog.new()
|
||||
var error_dialog: AcceptDialog = AcceptDialog.new()
|
||||
error_dialog.title = tr("reset_error_title")
|
||||
error_dialog.dialog_text = tr("reset_error_message")
|
||||
error_dialog.ok_button_text = tr("ok")
|
||||
@@ -291,7 +310,8 @@ func _on_reset_progress_confirmed():
|
||||
error_dialog.popup_centered()
|
||||
error_dialog.confirmed.connect(func(): error_dialog.queue_free())
|
||||
|
||||
func _on_reset_progress_canceled():
|
||||
|
||||
func _on_reset_progress_canceled() -> void:
|
||||
"""Handle reset progress cancellation"""
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Progress reset canceled by user", "Settings")
|
||||
|
||||
Reference in New Issue
Block a user