From 0eb22020e380643ec5cd2c12f983403c2dd3b751 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Tue, 18 Jan 2022 18:04:34 +0100 Subject: load map gui & start doc balance --- scripts/gui_load_map.gd | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/gui_load_map.gd (limited to 'scripts/gui_load_map.gd') 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) -- cgit v1.2.3-54-g00ecf