feature/saves-and-score (#8)
Reviewed-on: #8 Co-authored-by: Vladimir nett00n Budylnikov <git@nett00n.org> Co-committed-by: Vladimir nett00n Budylnikov <git@nett00n.org>
This commit is contained in:
@@ -6,10 +6,14 @@ signal back_to_main_menu
|
||||
@onready var music_slider = $SettingsContainer/MusicVolumeContainer/MusicVolumeSlider
|
||||
@onready var sfx_slider = $SettingsContainer/SFXVolumeContainer/SFXVolumeSlider
|
||||
@onready var language_stepper = $SettingsContainer/LanguageContainer/LanguageStepper
|
||||
@onready var reset_progress_button = $ResetSettingsContainer/ResetProgressButton
|
||||
|
||||
@export var settings_manager: Node = SettingsManager
|
||||
@export var localization_manager: Node = LocalizationManager
|
||||
|
||||
# Progress reset confirmation dialog
|
||||
var confirmation_dialog: AcceptDialog
|
||||
|
||||
|
||||
# Navigation system variables
|
||||
var navigable_controls: Array[Control] = []
|
||||
@@ -39,6 +43,7 @@ func _ready():
|
||||
_update_controls_from_settings()
|
||||
update_text()
|
||||
_setup_navigation_system()
|
||||
_setup_confirmation_dialog()
|
||||
|
||||
func _update_controls_from_settings():
|
||||
master_slider.value = settings_manager.get_setting("master_volume")
|
||||
@@ -112,6 +117,7 @@ func update_text():
|
||||
$SettingsContainer/SFXVolumeContainer/SFXVolume.text = tr("sfx_volume")
|
||||
$SettingsContainer/LanguageContainer/LanguageLabel.text = tr("language")
|
||||
$BackButtonContainer/BackButton.text = tr("back")
|
||||
reset_progress_button.text = tr("reset_progress")
|
||||
|
||||
|
||||
func _on_reset_setting_button_pressed() -> void:
|
||||
@@ -133,6 +139,7 @@ func _setup_navigation_system():
|
||||
navigable_controls.append(language_stepper) # Use the ValueStepper component
|
||||
navigable_controls.append($BackButtonContainer/BackButton)
|
||||
navigable_controls.append($ResetSettingsContainer/ResetSettingButton)
|
||||
navigable_controls.append(reset_progress_button)
|
||||
|
||||
# Store original visual properties
|
||||
for control in navigable_controls:
|
||||
@@ -218,3 +225,73 @@ func _get_control_name(control: Control) -> String:
|
||||
|
||||
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():
|
||||
"""Create confirmation dialog for progress reset"""
|
||||
confirmation_dialog = AcceptDialog.new()
|
||||
confirmation_dialog.title = tr("confirm_reset_title")
|
||||
confirmation_dialog.dialog_text = tr("confirm_reset_message")
|
||||
confirmation_dialog.ok_button_text = tr("reset_confirm")
|
||||
confirmation_dialog.add_cancel_button(tr("cancel"))
|
||||
|
||||
# Make dialog modal and centered
|
||||
confirmation_dialog.set_flag(Window.FLAG_POPUP, true)
|
||||
confirmation_dialog.popup_window = true
|
||||
|
||||
# Connect signals
|
||||
confirmation_dialog.confirmed.connect(_on_reset_progress_confirmed)
|
||||
confirmation_dialog.canceled.connect(_on_reset_progress_canceled)
|
||||
|
||||
add_child(confirmation_dialog)
|
||||
|
||||
func _on_reset_progress_button_pressed():
|
||||
"""Handle reset progress button press with confirmation"""
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Reset progress button pressed", "Settings")
|
||||
|
||||
# Update dialog text with current translations
|
||||
confirmation_dialog.title = tr("confirm_reset_title")
|
||||
confirmation_dialog.dialog_text = tr("confirm_reset_message")
|
||||
confirmation_dialog.ok_button_text = tr("reset_confirm")
|
||||
|
||||
# Show confirmation dialog
|
||||
confirmation_dialog.popup_centered()
|
||||
|
||||
func _on_reset_progress_confirmed():
|
||||
"""Actually reset the progress after confirmation"""
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Progress reset confirmed by user", "Settings")
|
||||
|
||||
# Call SaveManager to reset all progress
|
||||
if SaveManager.reset_all_progress():
|
||||
DebugManager.log_info("All progress successfully reset", "Settings")
|
||||
|
||||
# Show success message
|
||||
var success_dialog = AcceptDialog.new()
|
||||
success_dialog.title = tr("reset_success_title")
|
||||
success_dialog.dialog_text = tr("reset_success_message")
|
||||
success_dialog.ok_button_text = tr("ok")
|
||||
add_child(success_dialog)
|
||||
success_dialog.popup_centered()
|
||||
|
||||
# Auto-close success dialog and remove it after 3 seconds
|
||||
success_dialog.confirmed.connect(func(): success_dialog.queue_free())
|
||||
await get_tree().create_timer(3.0).timeout
|
||||
if is_instance_valid(success_dialog):
|
||||
success_dialog.queue_free()
|
||||
else:
|
||||
DebugManager.log_error("Failed to reset progress", "Settings")
|
||||
|
||||
# Show error message
|
||||
var error_dialog = AcceptDialog.new()
|
||||
error_dialog.title = tr("reset_error_title")
|
||||
error_dialog.dialog_text = tr("reset_error_message")
|
||||
error_dialog.ok_button_text = tr("ok")
|
||||
add_child(error_dialog)
|
||||
error_dialog.popup_centered()
|
||||
error_dialog.confirmed.connect(func(): error_dialog.queue_free())
|
||||
|
||||
func _on_reset_progress_canceled():
|
||||
"""Handle reset progress cancellation"""
|
||||
AudioManager.play_ui_click()
|
||||
DebugManager.log_info("Progress reset canceled by user", "Settings")
|
||||
|
||||
Reference in New Issue
Block a user