diff options
-rw-r--r-- | Main.gd | 62 | ||||
-rw-r--r-- | screens/Task/Body.gd | 18 | ||||
-rw-r--r-- | screens/Task/Header.gd | 4 | ||||
-rw-r--r-- | screens/TimeSlot/Body.gd | 20 | ||||
-rw-r--r-- | screens/TimeSlot/Header.gd | 4 | ||||
-rw-r--r-- | screens/TimeSlot/TaskItem.gd | 2 |
6 files changed, 55 insertions, 55 deletions
@@ -5,42 +5,42 @@ onready var body_container = $"%BodyContent" 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 + 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) + 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]) + 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() - if body_container.get_child_count() > 0: - body_container.get_child(0).queue_free() - #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) + #queue cleanup of old screen + if header_container.get_child_count() > 0: + header_container.get_child(0).queue_free() + if body_container.get_child_count() > 0: + body_container.get_child(0).queue_free() + #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", TimeSlot, "get_by_id", [2]) + nav_screen("TimeSlot", TimeSlot, "get_by_id", [2]) diff --git a/screens/Task/Body.gd b/screens/Task/Body.gd index 05c9e9e..0831524 100644 --- a/screens/Task/Body.gd +++ b/screens/Task/Body.gd @@ -1,12 +1,12 @@ extends VBoxContainer func populate(data): - $"%Length".text = "%d min" % data.estimated_length - $"%Description".text = data.description if data.description != null else "" - var tasks = SubTask.get_by_task(data.id) - var SubTaskItem = load("res://screens/Task/SubTaskItem.tscn") - var task_list = $"%SubTaskList" - for task in tasks: - var item = SubTaskItem.instance() - item.populate(task) - task_list.add_child(item)
\ No newline at end of file + $"%Length".text = "%d min" % data.estimated_length + $"%Description".text = data.description if data.description != null else "" + var tasks = SubTask.get_by_task(data.id) + var SubTaskItem = load("res://screens/Task/SubTaskItem.tscn") + var task_list = $"%SubTaskList" + for task in tasks: + var item = SubTaskItem.instance() + item.populate(task) + task_list.add_child(item) diff --git a/screens/Task/Header.gd b/screens/Task/Header.gd index 8f6c3f7..7653b6a 100644 --- a/screens/Task/Header.gd +++ b/screens/Task/Header.gd @@ -1,7 +1,7 @@ extends HBoxContainer func populate(data): - $"%Name".text = data.name + $"%Name".text = data.name func _on_Back_button_up(): - $"/root/Main".nav_back() + $"/root/Main".nav_back() diff --git a/screens/TimeSlot/Body.gd b/screens/TimeSlot/Body.gd index aa1f352..5bca112 100644 --- a/screens/TimeSlot/Body.gd +++ b/screens/TimeSlot/Body.gd @@ -1,13 +1,13 @@ extends VBoxContainer func populate(data): - var start_time = DataHelpers.timeofday(data.start_time) - var end_time = DataHelpers.timeofday(data.end_time) - $"%TimeRange".text = "%s - %s" % [start_time, end_time] - var tasks = Task.get_by_timeslot(data.id) - var TaskItem = load("res://screens/TimeSlot/TaskItem.tscn") - var task_list = $"%TaskList" - for task in tasks: - var item = TaskItem.instance() - item.populate(task) - task_list.add_child(item) + var start_time = DataHelpers.timeofday(data.start_time) + var end_time = DataHelpers.timeofday(data.end_time) + $"%TimeRange".text = "%s - %s" % [start_time, end_time] + var tasks = Task.get_by_timeslot(data.id) + var TaskItem = load("res://screens/TimeSlot/TaskItem.tscn") + var task_list = $"%TaskList" + for task in tasks: + var item = TaskItem.instance() + item.populate(task) + task_list.add_child(item) diff --git a/screens/TimeSlot/Header.gd b/screens/TimeSlot/Header.gd index 8f6c3f7..7653b6a 100644 --- a/screens/TimeSlot/Header.gd +++ b/screens/TimeSlot/Header.gd @@ -1,7 +1,7 @@ extends HBoxContainer func populate(data): - $"%Name".text = data.name + $"%Name".text = data.name func _on_Back_button_up(): - $"/root/Main".nav_back() + $"/root/Main".nav_back() diff --git a/screens/TimeSlot/TaskItem.gd b/screens/TimeSlot/TaskItem.gd index c2ab487..aa7c9bd 100644 --- a/screens/TimeSlot/TaskItem.gd +++ b/screens/TimeSlot/TaskItem.gd @@ -14,4 +14,4 @@ func populate(data): func _on_Button_button_up(): - $"/root/Main".nav_screen("Task", Task, "get_by_id", [task_id]) + $"/root/Main".nav_screen("Task", Task, "get_by_id", [task_id]) |