Files
Dunkanoid/BackgroundSelector.gd
Matt Jenkins 81d8e14746 Added pause and mute.
Improved fonts and font scaling
Added level editor
2024-05-05 22:36:32 +01:00

30 lines
763 B
GDScript

extends OptionButton
func _ready() -> void:
update_background_list()
func update_background_list() -> void:
clear()
var i : int = 0
for file in DirAccess.get_files_at("res://Backgrounds"):
if file.ends_with(".png"):
add_item(file.left(-4), i)
set_item_metadata(i, "res://Backgrounds/%s" % file)
i += 1
for file in DirAccess.get_files_at("user://Backgrounds"):
if file.ends_with(".png"):
add_item(file.left(-4), i)
set_item_metadata(i, "user://Backgrounds/%s" % file)
i += 1
func select_by_name(name : String) -> void:
for i in item_count:
if get_item_text(i) == name:
selected = i
func get_selected_filename() -> String:
return get_item_metadata(selected)
func get_selected_text() -> String:
return get_item_text(selected)