Ajout de la possibilite de supprimer un personnage.
This commit is contained in:
parent
c7f0b0aa16
commit
e212bf143b
1 changed files with 15 additions and 0 deletions
|
@ -32,6 +32,12 @@ func _ready():
|
||||||
slot_box.add_child( choose_button )
|
slot_box.add_child( choose_button )
|
||||||
choose_button.set_owner( slot_box )
|
choose_button.set_owner( slot_box )
|
||||||
choose_button.connect( "pressed", self, "_on_choose_pressed", [int(section)] )
|
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()
|
var create_new_characer_button = Button.new()
|
||||||
|
@ -46,7 +52,16 @@ func _on_return_button_pressed():
|
||||||
|
|
||||||
func _on_choose_pressed( slot ):
|
func _on_choose_pressed( slot ):
|
||||||
emit_signal( "character_selected", 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():
|
func _on_slot0_character_button_pressed():
|
||||||
emit_signal( "character_selected", 0 )
|
emit_signal( "character_selected", 0 )
|
||||||
|
|
Loading…
Reference in a new issue