mirror of
https://port.numenaute.org/aleajactaest/khanat-client.git
synced 2024-12-30 13:00:54 +00:00
41 lines
1,012 B
GDScript
41 lines
1,012 B
GDScript
extends WindowDialog
|
|
|
|
func _ready():
|
|
var directory = Directory.new()
|
|
|
|
if not directory.dir_exists( "user://musics/" ):
|
|
directory.make_dir_recursive( "user://musics/" )
|
|
directory.open( "user://musics/" )
|
|
directory.list_dir_begin()
|
|
var files = []
|
|
while true:
|
|
var file = directory.get_next()
|
|
if file == "":
|
|
break
|
|
elif not file.begins_with(".") and not directory.current_is_dir() and not file.ends_with( ".import" ):
|
|
files.append(file)
|
|
directory.list_dir_end()
|
|
|
|
for file in files:
|
|
var button = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance()
|
|
button.music_filename = file
|
|
button.text = file
|
|
button.connect( "music_selected", self, "_on_music_pressed" )
|
|
$window_box/scroll_box/musics_box.add_child( button )
|
|
|
|
func open():
|
|
self.popup()
|
|
|
|
func close():
|
|
self.hide()
|
|
|
|
func toggle():
|
|
if self.visible:
|
|
self.close()
|
|
else:
|
|
self.open()
|
|
|
|
|
|
func _on_music_pressed( p_filename ):
|
|
$music.stream = load( "res://assets/musics/" + p_filename )
|
|
$music.play()
|