extends Control signal new_pressed( slot ) signal cancel_pressed signal select_pressed( creature_filename ) var slots_number = 0 var slots = {} func _ready(): var files = [] var directory = Directory.new() if directory.dir_exists( "user://creatures/" ): directory.open( "user://creatures/" ) directory.list_dir_begin() while true: var file = directory.get_next() if file == "": break elif not file.begins_with( "." ) and not directory.current_is_dir(): files.append( file ) directory.list_dir_end() for file in files: var creature_box = preload( "res://scenes/interfaces/creatures_menu/creature_box.tscn" ).instance() creature_box.get_node( "label" ).text = file creature_box.slot = self.slots_number creature_box.creature_filename = file creature_box.connect( "select_pressed", self, "_on_creature_box_select_pressed" ) creature_box.connect( "delete_pressed", self, "_on_creature_box_delete_pressed" ) $screen_box/scroll_container/v_box_container/creatures_box.add_child( creature_box ) self.slots[ self.slots_number ] = creature_box self.slots_number += 1 var creature = Creatures.Ra_old.new() creature.from_file( file ) creature_box.get_node( "label" ).text = creature.pseudonym func _on_new_pressed(): emit_signal( "new_pressed", self.slots_number ) func _on_cancel_pressed(): emit_signal( "cancel_pressed" ) func _on_creature_box_select_pressed( slot ): emit_signal( "select_pressed", self.slots[ slot ].creature_filename ) func _on_creature_box_delete_pressed( slot ): if self.slots[ slot ].creature_filename: var dir = Directory.new() dir.remove( "user://creatures/" + self.slots[ slot ].creature_filename ) self.slots[ slot ].queue_free()