format
Some checks failed
Continuous Integration / Code Formatting (push) Successful in 33s
Continuous Integration / Code Quality Check (push) Successful in 28s
Continuous Integration / Test Execution (push) Failing after 16s
Continuous Integration / CI Summary (push) Failing after 3s

This commit is contained in:
2025-10-01 15:35:34 +04:00
parent 1f1c394587
commit 35ee2f9a5e
28 changed files with 1962 additions and 663 deletions

View File

@@ -9,8 +9,10 @@ const YAML_SOURCES: Array[String] = [
# "res://assets/sprites/sprite-sources.yaml",
]
@onready var scroll_container: ScrollContainer = $MarginContainer/VBoxContainer/ScrollContainer
@onready var credits_text: RichTextLabel = $MarginContainer/VBoxContainer/ScrollContainer/CreditsText
@onready
var scroll_container: ScrollContainer = $MarginContainer/VBoxContainer/ScrollContainer
@onready
var credits_text: RichTextLabel = $MarginContainer/VBoxContainer/ScrollContainer/CreditsText
@onready var back_button: Button = $MarginContainer/VBoxContainer/BackButton
@@ -40,7 +42,9 @@ func _load_yaml_file(yaml_path: String) -> Dictionary:
var file := FileAccess.open(yaml_path, FileAccess.READ)
if not file:
DebugManager.log_warn("Could not open YAML file: %s" % yaml_path, "Credits")
DebugManager.log_warn(
"Could not open YAML file: %s" % yaml_path, "Credits"
)
return {}
var content: String = file.get_as_text()
@@ -67,10 +71,18 @@ func _parse_yaml_content(yaml_content: String) -> Dictionary:
continue
# Top-level section (audio, sprites, textures, etc.)
if not line.begins_with(" ") and not line.begins_with("\t") and trimmed.ends_with(":"):
if (
not line.begins_with(" ")
and not line.begins_with("\t")
and trimmed.ends_with(":")
):
if current_asset and not current_asset_data.is_empty():
_store_asset_data(
result, current_section, current_subsection, current_asset, current_asset_data
result,
current_section,
current_subsection,
current_asset,
current_asset_data
)
current_section = trimmed.trim_suffix(":")
current_subsection = ""
@@ -80,22 +92,37 @@ func _parse_yaml_content(yaml_content: String) -> Dictionary:
result[current_section] = {}
# Subsection (music, sfx, characters, etc.)
elif line.begins_with(" ") and not line.begins_with(" ") and trimmed.ends_with(":"):
elif (
line.begins_with(" ")
and not line.begins_with(" ")
and trimmed.ends_with(":")
):
if current_asset and not current_asset_data.is_empty():
_store_asset_data(
result, current_section, current_subsection, current_asset, current_asset_data
result,
current_section,
current_subsection,
current_asset,
current_asset_data
)
current_subsection = trimmed.trim_suffix(":")
current_asset = ""
current_asset_data = {}
if current_section and not result[current_section].has(current_subsection):
if (
current_section
and not result[current_section].has(current_subsection)
):
result[current_section][current_subsection] = {}
# Asset name
elif trimmed.begins_with('"') and trimmed.contains('":'):
if current_asset and not current_asset_data.is_empty():
_store_asset_data(
result, current_section, current_subsection, current_asset, current_asset_data
result,
current_section,
current_subsection,
current_asset,
current_asset_data
)
var parts: Array = trimmed.split('"')
current_asset = parts[1] if parts.size() > 1 else ""
@@ -106,21 +133,31 @@ func _parse_yaml_content(yaml_content: String) -> Dictionary:
var parts: Array = trimmed.split(":", false, 1)
if parts.size() == 2:
var key: String = parts[0].strip_edges()
var value: String = parts[1].strip_edges().trim_prefix('"').trim_suffix('"')
var value: String = (
parts[1].strip_edges().trim_prefix('"').trim_suffix('"')
)
if value and value != '""':
current_asset_data[key] = value
# Store last asset
if current_asset and not current_asset_data.is_empty():
_store_asset_data(
result, current_section, current_subsection, current_asset, current_asset_data
result,
current_section,
current_subsection,
current_asset,
current_asset_data
)
return result
func _store_asset_data(
result: Dictionary, section: String, subsection: String, asset: String, data: Dictionary
result: Dictionary,
section: String,
subsection: String,
asset: String,
data: Dictionary
) -> void:
"""Store parsed asset data into result dictionary"""
if not section or not asset:
@@ -150,7 +187,9 @@ func _merge_credits_data(target: Dictionary, source: Dictionary) -> void:
func _display_formatted_credits(credits_data: Dictionary) -> void:
"""Generate BBCode formatted credits from parsed data"""
if not credits_text:
DebugManager.log_error("Credits text node is null, cannot display credits", "Credits")
DebugManager.log_error(
"Credits text node is null, cannot display credits", "Credits"
)
return
var credits_bbcode: String = "[center][b][font_size=32]CREDITS[/font_size][/b][/center]\n\n"
@@ -227,11 +266,17 @@ func _on_back_button_pressed() -> void:
func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_back") or event.is_action_pressed("action_east"):
if (
event.is_action_pressed("ui_back")
or event.is_action_pressed("action_east")
):
_on_back_button_pressed()
elif event.is_action_pressed("move_up") or event.is_action_pressed("ui_up"):
_scroll_credits(-50.0)
elif event.is_action_pressed("move_down") or event.is_action_pressed("ui_down"):
elif (
event.is_action_pressed("move_down")
or event.is_action_pressed("ui_down")
):
_scroll_credits(50.0)
@@ -239,4 +284,6 @@ func _scroll_credits(amount: float) -> void:
"""Scroll the credits by the specified amount"""
var current_scroll: float = scroll_container.scroll_vertical
scroll_container.scroll_vertical = int(current_scroll + amount)
DebugManager.log_debug("Scrolled credits to: %d" % scroll_container.scroll_vertical, "Credits")
DebugManager.log_debug(
"Scrolled credits to: %d" % scroll_container.scroll_vertical, "Credits"
)

View File

@@ -17,12 +17,16 @@ func _find_target_scene():
# Fallback: search by common node names
if not match3_scene:
for possible_name in ["Match3", "match3", "Match3Game"]:
match3_scene = current_scene.find_child(possible_name, true, false)
match3_scene = current_scene.find_child(
possible_name, true, false
)
if match3_scene:
break
if match3_scene:
DebugManager.log_debug("Found match3 scene: " + match3_scene.name, log_category)
DebugManager.log_debug(
"Found match3 scene: " + match3_scene.name, log_category
)
_update_ui_from_scene()
_stop_search_timer()
else:

View File

@@ -8,7 +8,8 @@ const MIN_GRID_SIZE := 3
const MIN_TILE_TYPES := 3
const SCENE_SEARCH_COOLDOWN := 0.5
@export var target_script_path: String = "res://scenes/game/gameplays/Match3Gameplay.gd"
@export
var target_script_path: String = "res://scenes/game/gameplays/Match3Gameplay.gd"
@export var log_category: String = "DebugMenu"
var match3_scene: Node2D
@@ -16,8 +17,10 @@ var search_timer: Timer
var last_scene_search_time: float = 0.0
@onready var regenerate_button: Button = $VBoxContainer/RegenerateButton
@onready var gem_types_spinbox: SpinBox = $VBoxContainer/GemTypesContainer/GemTypesSpinBox
@onready var gem_types_label: Label = $VBoxContainer/GemTypesContainer/GemTypesLabel
@onready
var gem_types_spinbox: SpinBox = $VBoxContainer/GemTypesContainer/GemTypesSpinBox
@onready
var gem_types_label: Label = $VBoxContainer/GemTypesContainer/GemTypesLabel
@onready
var grid_width_spinbox: SpinBox = $VBoxContainer/GridSizeContainer/GridWidthContainer/GridWidthSpinBox
@onready
@@ -86,7 +89,9 @@ func _setup_scene_finding() -> void:
# Virtual method - override in derived classes for specific finding logic
func _find_target_scene() -> void:
DebugManager.log_error("_find_target_scene() not implemented in derived class", log_category)
DebugManager.log_error(
"_find_target_scene() not implemented in derived class", log_category
)
func _find_node_by_script(node: Node, script_path: String) -> Node:
@@ -114,10 +119,14 @@ func _update_ui_from_scene() -> void:
# Connect to grid state loaded signal if not already connected
if (
match3_scene.has_signal("grid_state_loaded")
and not match3_scene.grid_state_loaded.is_connected(_on_grid_state_loaded)
and not match3_scene.grid_state_loaded.is_connected(
_on_grid_state_loaded
)
):
match3_scene.grid_state_loaded.connect(_on_grid_state_loaded)
DebugManager.log_debug("Connected to grid_state_loaded signal", log_category)
DebugManager.log_debug(
"Connected to grid_state_loaded signal", log_category
)
# Update gem types display
if match3_scene.has_method("get") and "TILE_TYPES" in match3_scene:
@@ -135,7 +144,10 @@ func _update_ui_from_scene() -> void:
func _on_grid_state_loaded(grid_size: Vector2i, tile_types: int) -> void:
DebugManager.log_debug(
"Grid state loaded signal received: size=%s, types=%d" % [grid_size, tile_types],
(
"Grid state loaded signal received: size=%s, types=%d"
% [grid_size, tile_types]
),
log_category
)
@@ -155,7 +167,10 @@ func _stop_search_timer() -> void:
func _start_search_timer() -> void:
if search_timer and not search_timer.timeout.is_connected(_find_target_scene):
if (
search_timer
and not search_timer.timeout.is_connected(_find_target_scene)
):
search_timer.timeout.connect(_find_target_scene)
search_timer.start()
@@ -176,7 +191,8 @@ func _refresh_current_values() -> void:
# Refresh UI with current values from the scene
if match3_scene:
DebugManager.log_debug(
"Refreshing debug menu values from current scene state", log_category
"Refreshing debug menu values from current scene state",
log_category
)
_update_ui_from_scene()
@@ -186,14 +202,18 @@ func _on_regenerate_pressed() -> void:
_find_target_scene()
if not match3_scene:
DebugManager.log_error("Could not find target scene for regeneration", log_category)
DebugManager.log_error(
"Could not find target scene for regeneration", log_category
)
return
if match3_scene.has_method("regenerate_grid"):
DebugManager.log_debug("Calling regenerate_grid()", log_category)
await match3_scene.regenerate_grid()
else:
DebugManager.log_error("Target scene does not have regenerate_grid method", log_category)
DebugManager.log_error(
"Target scene does not have regenerate_grid method", log_category
)
func _on_gem_types_changed(value: float) -> void:
@@ -207,7 +227,9 @@ func _on_gem_types_changed(value: float) -> void:
last_scene_search_time = current_time
if not match3_scene:
DebugManager.log_error("Could not find target scene for gem types change", log_category)
DebugManager.log_error(
"Could not find target scene for gem types change", log_category
)
return
var new_value: int = int(value)
@@ -221,15 +243,21 @@ func _on_gem_types_changed(value: float) -> void:
log_category
)
# Reset to valid value
gem_types_spinbox.value = clamp(new_value, MIN_TILE_TYPES, MAX_TILE_TYPES)
gem_types_spinbox.value = clamp(
new_value, MIN_TILE_TYPES, MAX_TILE_TYPES
)
return
if match3_scene.has_method("set_tile_types"):
DebugManager.log_debug("Setting tile types to " + str(new_value), log_category)
DebugManager.log_debug(
"Setting tile types to " + str(new_value), log_category
)
await match3_scene.set_tile_types(new_value)
gem_types_label.text = "Gem Types: " + str(new_value)
else:
DebugManager.log_error("Target scene does not have set_tile_types method", log_category)
DebugManager.log_error(
"Target scene does not have set_tile_types method", log_category
)
# Fallback: try to set TILE_TYPES directly
if "TILE_TYPES" in match3_scene:
match3_scene.TILE_TYPES = new_value
@@ -247,7 +275,9 @@ func _on_grid_width_changed(value: float) -> void:
last_scene_search_time = current_time
if not match3_scene:
DebugManager.log_error("Could not find target scene for grid width change", log_category)
DebugManager.log_error(
"Could not find target scene for grid width change", log_category
)
return
var new_width: int = int(value)
@@ -261,7 +291,9 @@ func _on_grid_width_changed(value: float) -> void:
log_category
)
# Reset to valid value
grid_width_spinbox.value = clamp(new_width, MIN_GRID_SIZE, MAX_GRID_SIZE)
grid_width_spinbox.value = clamp(
new_width, MIN_GRID_SIZE, MAX_GRID_SIZE
)
return
grid_width_label.text = "Width: " + str(new_width)
@@ -271,11 +303,19 @@ func _on_grid_width_changed(value: float) -> void:
if match3_scene.has_method("set_grid_size"):
DebugManager.log_debug(
"Setting grid size to " + str(new_width) + "x" + str(current_height), log_category
(
"Setting grid size to "
+ str(new_width)
+ "x"
+ str(current_height)
),
log_category
)
await match3_scene.set_grid_size(Vector2i(new_width, current_height))
else:
DebugManager.log_error("Target scene does not have set_grid_size method", log_category)
DebugManager.log_error(
"Target scene does not have set_grid_size method", log_category
)
func _on_grid_height_changed(value: float) -> void:
@@ -289,7 +329,9 @@ func _on_grid_height_changed(value: float) -> void:
last_scene_search_time = current_time
if not match3_scene:
DebugManager.log_error("Could not find target scene for grid height change", log_category)
DebugManager.log_error(
"Could not find target scene for grid height change", log_category
)
return
var new_height: int = int(value)
@@ -303,7 +345,9 @@ func _on_grid_height_changed(value: float) -> void:
log_category
)
# Reset to valid value
grid_height_spinbox.value = clamp(new_height, MIN_GRID_SIZE, MAX_GRID_SIZE)
grid_height_spinbox.value = clamp(
new_height, MIN_GRID_SIZE, MAX_GRID_SIZE
)
return
grid_height_label.text = "Height: " + str(new_height)
@@ -313,8 +357,16 @@ func _on_grid_height_changed(value: float) -> void:
if match3_scene.has_method("set_grid_size"):
DebugManager.log_debug(
"Setting grid size to " + str(current_width) + "x" + str(new_height), log_category
(
"Setting grid size to "
+ str(current_width)
+ "x"
+ str(new_height)
),
log_category
)
await match3_scene.set_grid_size(Vector2i(current_width, new_height))
else:
DebugManager.log_error("Target scene does not have set_grid_size method", log_category)
DebugManager.log_error(
"Target scene does not have set_grid_size method", log_category
)

View File

@@ -81,13 +81,17 @@ func _navigate_menu(direction: int) -> void:
if current_menu_index < 0:
current_menu_index = menu_buttons.size() - 1
_update_visual_selection()
DebugManager.log_info("Menu navigation: index " + str(current_menu_index), "MainMenu")
DebugManager.log_info(
"Menu navigation: index " + str(current_menu_index), "MainMenu"
)
func _activate_current_button() -> void:
if current_menu_index >= 0 and current_menu_index < menu_buttons.size():
var button: Button = menu_buttons[current_menu_index]
DebugManager.log_info("Activating button via keyboard/gamepad: " + button.text, "MainMenu")
DebugManager.log_info(
"Activating button via keyboard/gamepad: " + button.text, "MainMenu"
)
button.pressed.emit()
@@ -95,7 +99,9 @@ func _update_visual_selection() -> void:
for i in range(menu_buttons.size()):
var button: Button = menu_buttons[i]
if i == current_menu_index:
button.scale = (original_button_scales[i] * UIConstants.BUTTON_HOVER_SCALE)
button.scale = (
original_button_scales[i] * UIConstants.BUTTON_HOVER_SCALE
)
button.modulate = Color(1.2, 1.2, 1.0)
else:
button.scale = original_button_scales[i]

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:
@@ -213,7 +260,8 @@ func _update_visual_selection() -> void:
language_stepper.set_highlighted(true)
else:
control.scale = (
original_control_scales[i] * UIConstants.UI_CONTROL_HIGHLIGHT_SCALE
original_control_scales[i]
* UIConstants.UI_CONTROL_HIGHLIGHT_SCALE
)
control.modulate = Color(1.1, 1.1, 0.9)
else:
@@ -237,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"
)

View File

@@ -30,17 +30,25 @@ var is_highlighted: bool = false
func _ready() -> void:
DebugManager.log_info("ValueStepper ready for: " + data_source, "ValueStepper")
DebugManager.log_info(
"ValueStepper ready for: " + data_source, "ValueStepper"
)
# Store original visual properties
original_scale = scale
original_modulate = modulate
# Connect button signals
if left_button and not left_button.pressed.is_connected(_on_left_button_pressed):
if (
left_button
and not left_button.pressed.is_connected(_on_left_button_pressed)
):
left_button.pressed.connect(_on_left_button_pressed)
if right_button and not right_button.pressed.is_connected(_on_right_button_pressed):
if (
right_button
and not right_button.pressed.is_connected(_on_right_button_pressed)
):
right_button.pressed.connect(_on_right_button_pressed)
# Initialize data
@@ -58,7 +66,9 @@ func _load_data() -> void:
"difficulty":
_load_difficulty_data()
_:
DebugManager.log_warn("Unknown data_source: " + data_source, "ValueStepper")
DebugManager.log_warn(
"Unknown data_source: " + data_source, "ValueStepper"
)
func _load_language_data() -> void:
@@ -68,22 +78,30 @@ func _load_language_data() -> void:
display_names.clear()
for lang_code in languages_data.languages.keys():
values.append(lang_code)
display_names.append(languages_data.languages[lang_code]["display_name"])
display_names.append(
languages_data.languages[lang_code]["display_name"]
)
# Set current index based on current language
var current_lang: String = SettingsManager.get_setting("language")
var index: int = values.find(current_lang)
current_index = max(0, index)
DebugManager.log_info("Loaded %d languages" % values.size(), "ValueStepper")
DebugManager.log_info(
"Loaded %d languages" % values.size(), "ValueStepper"
)
func _load_resolution_data() -> void:
# Example resolution data - customize as needed
values = ["1920x1080", "1366x768", "1280x720", "1024x768"]
display_names = ["1920×1080 (Full HD)", "1366×768", "1280×720 (HD)", "1024×768"]
display_names = [
"1920×1080 (Full HD)", "1366×768", "1280×720 (HD)", "1024×768"
]
current_index = 0
DebugManager.log_info("Loaded %d resolutions" % values.size(), "ValueStepper")
DebugManager.log_info(
"Loaded %d resolutions" % values.size(), "ValueStepper"
)
func _load_difficulty_data() -> void:
@@ -91,12 +109,18 @@ func _load_difficulty_data() -> void:
values = ["easy", "normal", "hard", "nightmare"]
display_names = ["Easy", "Normal", "Hard", "Nightmare"]
current_index = 1 # Default to "normal"
DebugManager.log_info("Loaded %d difficulty levels" % values.size(), "ValueStepper")
DebugManager.log_info(
"Loaded %d difficulty levels" % values.size(), "ValueStepper"
)
## Updates the display text based on current selection
func _update_display() -> void:
if values.size() == 0 or current_index < 0 or current_index >= values.size():
if (
values.size() == 0
or current_index < 0
or current_index >= values.size()
):
value_display.text = "N/A"
return
@@ -109,7 +133,9 @@ func _update_display() -> void:
## Changes the current value by the specified direction (-1 for previous, +1 for next)
func change_value(direction: int) -> void:
if values.size() == 0:
DebugManager.log_warn("No values available for: " + data_source, "ValueStepper")
DebugManager.log_warn(
"No values available for: " + data_source, "ValueStepper"
)
return
var new_index: int = (current_index + direction) % values.size()
@@ -123,7 +149,14 @@ func change_value(direction: int) -> void:
_apply_value_change(new_value, current_index)
value_changed.emit(new_value, current_index)
DebugManager.log_info(
"Value changed to: " + new_value + " (index: " + str(current_index) + ")", "ValueStepper"
(
"Value changed to: "
+ new_value
+ " (index: "
+ str(current_index)
+ ")"
),
"ValueStepper"
)
@@ -136,10 +169,14 @@ func _apply_value_change(new_value: String, _index: int) -> void:
LocalizationManager.change_language(new_value)
"resolution":
# Apply resolution change logic here
DebugManager.log_info("Resolution would change to: " + new_value, "ValueStepper")
DebugManager.log_info(
"Resolution would change to: " + new_value, "ValueStepper"
)
"difficulty":
# Apply difficulty change logic here
DebugManager.log_info("Difficulty would change to: " + new_value, "ValueStepper")
DebugManager.log_info(
"Difficulty would change to: " + new_value, "ValueStepper"
)
## Sets up custom values for the stepper
@@ -148,16 +185,24 @@ func setup_custom_values(
) -> void:
values = custom_values.duplicate()
display_names = (
custom_display_names.duplicate() if custom_display_names.size() > 0 else values.duplicate()
custom_display_names.duplicate()
if custom_display_names.size() > 0
else values.duplicate()
)
current_index = 0
_update_display()
DebugManager.log_info("Setup custom values: " + str(values.size()) + " items", "ValueStepper")
DebugManager.log_info(
"Setup custom values: " + str(values.size()) + " items", "ValueStepper"
)
## Gets the current value
func get_current_value() -> String:
if values.size() > 0 and current_index >= 0 and current_index < values.size():
if (
values.size() > 0
and current_index >= 0
and current_index < values.size()
):
return values[current_index]
return ""