format
Some checks failed
Some checks failed
This commit is contained in:
@@ -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 ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user