more lint and formatting
Some checks failed
Continuous Integration / Code Formatting (push) Successful in 33s
Continuous Integration / Code Quality Check (push) Successful in 29s
Continuous Integration / Test Execution (push) Failing after 16s
Continuous Integration / CI Summary (push) Failing after 4s

This commit is contained in:
2025-10-01 15:04:40 +04:00
parent 538459f323
commit 3b8da89ad5
31 changed files with 2112 additions and 691 deletions

View File

@@ -14,10 +14,13 @@ var current_control_index: int = 0
var original_control_scales: Array[Vector2] = []
var original_control_modulates: Array[Color] = []
@onready var master_slider = $SettingsContainer/MasterVolumeContainer/MasterVolumeSlider
@onready var music_slider = $SettingsContainer/MusicVolumeContainer/MusicVolumeSlider
@onready
var master_slider = $SettingsContainer/MasterVolumeContainer/MasterVolumeSlider
@onready
var music_slider = $SettingsContainer/MusicVolumeContainer/MusicVolumeSlider
@onready var sfx_slider = $SettingsContainer/SFXVolumeContainer/SFXVolumeSlider
@onready var language_stepper = $SettingsContainer/LanguageContainer/LanguageStepper
@onready
var language_stepper = $SettingsContainer/LanguageContainer/LanguageStepper
@onready var reset_progress_button = $ResetSettingsContainer/ResetProgressButton
@@ -26,11 +29,15 @@ func _ready() -> void:
DebugManager.log_info("SettingsMenu ready", "Settings")
# Language selector is initialized automatically
var master_callback: Callable = _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: Callable = _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)
@@ -57,20 +64,28 @@ func _update_controls_from_settings() -> void:
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")
DebugManager.log_error(
"Invalid volume setting key: " + str(setting_key), "Settings"
)
return
if typeof(value) != TYPE_FLOAT and typeof(value) != TYPE_INT:
DebugManager.log_error("Invalid volume value type: " + str(typeof(value)), "Settings")
DebugManager.log_error(
"Invalid volume value type: " + str(typeof(value)), "Settings"
)
return
# Clamp value to valid range
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")
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")
DebugManager.log_error(
"Failed to set volume setting: " + setting_key, "Settings"
)
func _exit_settings() -> void:
@@ -80,8 +95,13 @@ func _exit_settings() -> void:
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")
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()
get_viewport().set_input_as_handled()
return
@@ -116,8 +136,12 @@ func _on_back_button_pressed() -> void:
func update_text() -> void:
$SettingsContainer/SettingsTitle.text = tr("settings_title")
$SettingsContainer/MasterVolumeContainer/MasterVolume.text = tr("master_volume")
$SettingsContainer/MusicVolumeContainer/MusicVolume.text = tr("music_volume")
$SettingsContainer/MasterVolumeContainer/MasterVolume.text = tr(
"master_volume"
)
$SettingsContainer/MusicVolumeContainer/MusicVolume.text = tr(
"music_volume"
)
$SettingsContainer/SFXVolumeContainer/SFXVolume.text = tr("sfx_volume")
$SettingsContainer/LanguageContainer/LanguageLabel.text = tr("language")
$BackButtonContainer/BackButton.text = tr("back")
@@ -129,7 +153,9 @@ func _on_reset_setting_button_pressed() -> void:
DebugManager.log_info("Resetting settings", "Settings")
settings_manager.reset_settings_to_defaults()
_update_controls_from_settings()
localization_manager.change_language(settings_manager.get_setting("language"))
localization_manager.change_language(
settings_manager.get_setting("language")
)
func _setup_navigation_system() -> void:
@@ -156,15 +182,22 @@ func _setup_navigation_system() -> void:
func _navigate_controls(direction: int) -> void:
AudioManager.play_ui_click()
current_control_index = (current_control_index + direction) % navigable_controls.size()
current_control_index = (
(current_control_index + direction) % navigable_controls.size()
)
if current_control_index < 0:
current_control_index = navigable_controls.size() - 1
_update_visual_selection()
DebugManager.log_info("Settings navigation: index " + str(current_control_index), "Settings")
DebugManager.log_info(
"Settings navigation: index " + str(current_control_index), "Settings"
)
func _adjust_current_control(direction: int) -> void:
if current_control_index < 0 or current_control_index >= navigable_controls.size():
if (
current_control_index < 0
or current_control_index >= navigable_controls.size()
):
return
var control: Control = navigable_controls[current_control_index]
@@ -178,17 +211,26 @@ func _adjust_current_control(direction: int) -> void:
slider.value = new_value
AudioManager.play_ui_click()
DebugManager.log_info(
"Slider adjusted: %s = %f" % [_get_control_name(control), new_value], "Settings"
(
"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"):
if language_stepper.handle_input_action(
"move_left" if direction == -1 else "move_right"
):
AudioManager.play_ui_click()
func _activate_current_control() -> void:
if current_control_index < 0 or current_control_index >= navigable_controls.size():
if (
current_control_index < 0
or current_control_index >= navigable_controls.size()
):
return
var control: Control = navigable_controls[current_control_index]
@@ -196,12 +238,17 @@ func _activate_current_control() -> void:
# Handle buttons
if control is Button:
AudioManager.play_ui_click()
DebugManager.log_info("Activating button via keyboard/gamepad: " + control.text, "Settings")
DebugManager.log_info(
"Activating button via keyboard/gamepad: " + control.text,
"Settings"
)
control.pressed.emit()
# Handle language stepper (no action needed on activation, left/right handles it)
elif control == language_stepper:
DebugManager.log_info("Language stepper selected - use left/right to change", "Settings")
DebugManager.log_info(
"Language stepper selected - use left/right to change", "Settings"
)
func _update_visual_selection() -> void:
@@ -212,7 +259,10 @@ func _update_visual_selection() -> void:
if control == language_stepper:
language_stepper.set_highlighted(true)
else:
control.scale = original_control_scales[i] * UIConstants.UI_CONTROL_HIGHLIGHT_SCALE
control.scale = (
original_control_scales[i]
* UIConstants.UI_CONTROL_HIGHLIGHT_SCALE
)
control.modulate = Color(1.1, 1.1, 0.9)
else:
# Reset highlighting
@@ -235,9 +285,17 @@ func _get_control_name(control: Control) -> String:
return "button"
func _on_language_stepper_value_changed(new_value: String, new_index: float) -> void:
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)) + ")",
(
"Language changed via ValueStepper: "
+ new_value
+ " (index: "
+ str(int(new_index))
+ ")"
),
"Settings"
)