From e212bf143b950af46e79909c18c8d973dcbfeafd Mon Sep 17 00:00:00 2001 From: osquallo Date: Wed, 8 Aug 2018 14:55:50 +0200 Subject: [PATCH] Ajout de la possibilite de supprimer un personnage. --- .../character_selection_menu.gd | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scenes/GUI/character_selection/character_selection_menu.gd b/scenes/GUI/character_selection/character_selection_menu.gd index f17c365..b02847f 100644 --- a/scenes/GUI/character_selection/character_selection_menu.gd +++ b/scenes/GUI/character_selection/character_selection_menu.gd @@ -32,6 +32,12 @@ func _ready(): slot_box.add_child( choose_button ) choose_button.set_owner( slot_box ) choose_button.connect( "pressed", self, "_on_choose_pressed", [int(section)] ) + + var delete_button = Button.new() + delete_button.text = "delete" + slot_box.add_child( delete_button ) + delete_button.set_owner( slot_box ) + delete_button.connect( "pressed", self, "_on_delete_pressed", [int(section), slot_box] ) var create_new_characer_button = Button.new() @@ -46,7 +52,16 @@ func _on_return_button_pressed(): func _on_choose_pressed( slot ): emit_signal( "character_selected", slot ) +func _on_delete_pressed( slot, node_to_delete ): + var config_file = ConfigFile.new() + var err = config_file.load( "user://player.cfg" ) + if err: + print("Error code when loading player config file: ", err) + config_file.erase_section( str(slot) ) + config_file.save( "user://player.cfg" ) + var parent = node_to_delete.get_parent() + parent.remove_child( node_to_delete ) func _on_slot0_character_button_pressed(): emit_signal( "character_selected", 0 )