diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-18 18:04:34 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-18 18:04:34 +0100 |
commit | 0eb22020e380643ec5cd2c12f983403c2dd3b751 (patch) | |
tree | ff23a3e26611c04e3ba72c8c1504b9ae86dfdeb8 /scripts/gui_load_map.gd | |
parent | f75ee64e21f67b4f27404147aedaa63750058d5a (diff) |
load map gui & start doc balance
Diffstat (limited to 'scripts/gui_load_map.gd')
-rw-r--r-- | scripts/gui_load_map.gd | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/gui_load_map.gd b/scripts/gui_load_map.gd new file mode 100644 index 0000000..288f937 --- /dev/null +++ b/scripts/gui_load_map.gd @@ -0,0 +1,51 @@ +extends PanelContainer + +var vbox_items +var _gui_item : Resource = load("res://scenes/gui/gui_map_item.tscn") +var saveload_map : Node + +var control : Node +var gui : Control + +var selected_delete = "" + +func _fetch (): + if gui == null: gui = get_parent() + if saveload_map != null: return; + + vbox_items = $"vbox/vbox_items" + + var root = get_tree().root.get_node("world") + control = root.get_node("player").get_node("control") + saveload_map = root.get_node("saveload").get_node("saveload_map") + +func build (): + _fetch() + + var txt = "load map from " + saveload_map.mappath + get_node("vbox").get_node("title").text = txt + + var mapnames = saveload_map.get_mapnames() + for child in vbox_items.get_children(): child.queue_free() + + for mapname in mapnames: + var item = _gui_item.instance() + item.get_node("name").text = mapname + vbox_items.add_child(item) + + var button_load = item.get_node("hbox").get_node("load") + button_load.connect("pressed", self, "_load_pressed", [mapname]) + + var button_delete = item.get_node("hbox").get_node("delete") + button_delete.connect("pressed", self, "_delete_pressed", [mapname]) + +func refresh (): + _fetch() + +func _delete_pressed (mapname : String): + gui.delete_confirm.popup() + gui.delete_confirm.dialog_text = "You are about to delete this map:\n"+mapname + selected_delete = mapname + +func _load_pressed (mapname : String): + control.gui_change_map_event(mapname) |