summaryrefslogtreecommitdiffstats
path: root/Main.gd
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-08-26 03:48:27 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-08-26 03:48:27 -0400
commitfebc05f628793d252066a173e8fce0826b2190fd (patch)
tree163b05a21767704b70a1add51d94abc2f64f3b97 /Main.gd
parent4dc99b2d0ac8cb741d1cd968d46026fae70d031e (diff)
downloadPlanner-febc05f628793d252066a173e8fce0826b2190fd.tar.gz
Planner-febc05f628793d252066a173e8fce0826b2190fd.zip
Flesh Out Navigation and Populate Screens with Data
Diffstat (limited to 'Main.gd')
-rw-r--r--Main.gd40
1 files changed, 35 insertions, 5 deletions
diff --git a/Main.gd b/Main.gd
index 0a80683..1037b1d 100644
--- a/Main.gd
+++ b/Main.gd
@@ -3,14 +3,44 @@ extends Control
onready var header_container = $"%HeaderContent"
onready var body_container = $"%BodyContent"
-func nav_screen(new_screen):
+var nav_history = []
+class nav_history_item:
+ var screen_name
+ var data_model_type
+ var lookup_method
+ var lookup_args
+ func _init(screen_name, data_model_type, lookup_method, lookup_args):
+ self.screen_name = screen_name
+ self.data_model_type = data_model_type
+ self.lookup_method = lookup_method
+ self.lookup_args = lookup_args
+
+func nav_screen(screen_name, data_model_type, lookup_method, lookup_args):
+ var screen = nav_history_item.new(screen_name, data_model_type, lookup_method, lookup_args)
+ nav_history.push_back(screen)
+ swap_screen(screen)
+
+func nav_back():
+ if nav_history.size() > 1:
+ nav_history.pop_back()
+ swap_screen(nav_history[-1])
+
+func swap_screen(screen):
+ #queue cleanup of old screen
if header_container.get_child_count() > 0:
header_container.get_child(0).queue_free()
- header_container.add_child(load("res://screens/"+new_screen+"/Header.tscn").instance())
if body_container.get_child_count() > 0:
body_container.get_child(0).queue_free()
- body_container.add_child(load("res://screens/"+new_screen+"/Body.tscn").instance())
+ #load new screen
+ var header = load("res://screens/"+screen.screen_name+"/Header.tscn").instance()
+ var body = load("res://screens/"+screen.screen_name+"/Body.tscn").instance()
+ #load data
+ var data = screen.data_model_type.callv(screen.lookup_method,screen.lookup_args)
+ header.populate(data)
+ body.populate(data)
+ #set new screen
+ header_container.add_child(header)
+ body_container.add_child(body)
func _ready():
- nav_screen("TimeSlot")
-
+ nav_screen("TimeSlot", TimeSlot, "get_by_id", [2])