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