aboutsummaryrefslogtreecommitdiff
path: root/scripts/gui.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gui.gd')
-rw-r--r--scripts/gui.gd38
1 files changed, 34 insertions, 4 deletions
diff --git a/scripts/gui.gd b/scripts/gui.gd
index 3ad47aa..2e63483 100644
--- a/scripts/gui.gd
+++ b/scripts/gui.gd
@@ -6,17 +6,30 @@ var wave : Node
var bottom_bar : Control
var top_bar : Control
-var _wave_ongoing : Panel
+var wave_ongoing : Panel
+var load_map : PanelContainer
+var save_as : AcceptDialog
+var delete_confirm : AcceptDialog
+var saveload : Node
+var saveload_map : Node
func _fetch ():
var root = get_tree().root.get_node("world")
player = root.get_node("player")
control = player.get_node("control")
wave = root.get_node("wave")
+ saveload = root.get_node("saveload")
+ saveload_map = saveload.get_node("saveload_map")
if bottom_bar == null: bottom_bar = get_node("bottom_bar")
if top_bar == null: top_bar = get_node("top_bar")
- if _wave_ongoing == null: _wave_ongoing = $wave_ongoing_indicator
+ if wave_ongoing == null: wave_ongoing = $wave_ongoing_indicator
+ if load_map == null: load_map = $gui_load_map
+ if save_as == null:
+ save_as = $save_as
+ save_as.register_text_enter(save_as.get_node("line_edit"))
+ if delete_confirm == null:
+ delete_confirm = $delete_confirm
func _ready():
_fetch()
@@ -27,5 +40,22 @@ func refresh ():
bottom_bar.refresh(control.ineditor)
top_bar.refresh(control.ineditor)
- if wave.ongoing: _wave_ongoing.visible = true
- else: _wave_ongoing.visible = false
+ if wave.ongoing: wave_ongoing.visible = true
+ else: wave_ongoing.visible = false
+
+func save_as_mapname():
+ var mapname = save_as.get_node("line_edit").text
+ if !mapname.ends_with(".json"): mapname += ".json"
+ control.gui_save_as_map_event(mapname)
+ save_as.visible = false
+ load_map.build()
+
+func _on_save_as_confirmed():
+ save_as_mapname()
+
+func _on_delete_confirmed():
+ control.gui_delete_map_event(load_map.selected_delete)
+ load_map.build()
+
+func _on_close_load_map():
+ load_map.visible = false