diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-08-26 03:48:27 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-08-26 03:48:27 -0400 |
commit | febc05f628793d252066a173e8fce0826b2190fd (patch) | |
tree | 163b05a21767704b70a1add51d94abc2f64f3b97 | |
parent | 4dc99b2d0ac8cb741d1cd968d46026fae70d031e (diff) | |
download | Planner-febc05f628793d252066a173e8fce0826b2190fd.tar.gz Planner-febc05f628793d252066a173e8fce0826b2190fd.zip |
Flesh Out Navigation and Populate Screens with Data
-rw-r--r-- | Main.gd | 40 | ||||
-rw-r--r-- | data.db | bin | 36864 -> 0 bytes | |||
-rw-r--r-- | project.godot | 40 | ||||
-rw-r--r-- | screens/Task/Body.gd | 12 | ||||
-rw-r--r-- | screens/Task/Body.tscn | 10 | ||||
-rw-r--r-- | screens/Task/Header.gd | 5 | ||||
-rw-r--r-- | screens/Task/Header.tscn | 1 | ||||
-rw-r--r-- | screens/Task/SubtaskItem.gd | 4 | ||||
-rw-r--r-- | screens/Task/SubtaskItem.tscn | 6 | ||||
-rw-r--r-- | screens/TimeSlot/Body.gd | 13 | ||||
-rw-r--r-- | screens/TimeSlot/Body.tscn | 6 | ||||
-rw-r--r-- | screens/TimeSlot/Header.gd | 5 | ||||
-rw-r--r-- | screens/TimeSlot/Header.tscn | 1 | ||||
-rw-r--r-- | screens/TimeSlot/TaskItem.gd | 17 | ||||
-rw-r--r-- | screens/TimeSlot/TaskItem.tscn | 15 |
15 files changed, 155 insertions, 20 deletions
@@ -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]) diff --git a/data.db b/data.db Binary files differdeleted file mode 100644 index d39056b..0000000 --- a/data.db +++ /dev/null diff --git a/project.godot b/project.godot index 8df89ec..864ccc1 100644 --- a/project.godot +++ b/project.godot @@ -8,12 +8,48 @@ config_version=4 +_global_script_classes=[ { +"base": "Reference", +"class": "DataHelpers", +"language": "GDScript", +"path": "res://data_model/DataHelpers.gd" +}, { +"base": "Reference", +"class": "SubTask", +"language": "GDScript", +"path": "res://data_model/SubTask.gd" +}, { +"base": "Reference", +"class": "Task", +"language": "GDScript", +"path": "res://data_model/Task.gd" +}, { +"base": "Reference", +"class": "TimeSlot", +"language": "GDScript", +"path": "res://data_model/TimeSlot.gd" +} ] +_global_script_class_icons={ +"DataHelpers": "", +"SubTask": "", +"Task": "", +"TimeSlot": "" +} + [application] config/name="Planner" run/main_scene="res://Main.tscn" config/icon="res://icon.png" +[autoload] + +DBMS="*res://data_model/dbms.gd" + +[debug] + +gdscript/warnings/shadowed_variable=false + [display] window/size/width=1080 @@ -28,6 +64,10 @@ window/stretch/aspect="keep" enabled=PoolStringArray( "res://addons/godot-sqlite/plugin.cfg" ) +[global] + +shadow=false + [gui] common/drop_mouse_on_gui_input_disabled=true diff --git a/screens/Task/Body.gd b/screens/Task/Body.gd new file mode 100644 index 0000000..05c9e9e --- /dev/null +++ b/screens/Task/Body.gd @@ -0,0 +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 diff --git a/screens/Task/Body.tscn b/screens/Task/Body.tscn index 9185ad4..7f57ab2 100644 --- a/screens/Task/Body.tscn +++ b/screens/Task/Body.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=2] [ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://screens/Task/SubtaskItem.tscn" type="PackedScene" id=2] +[ext_resource path="res://screens/Task/Body.gd" type="Script" id=3] [sub_resource type="DynamicFont" id=2] size = 100 @@ -16,12 +16,14 @@ margin_left = 20.0 margin_top = 20.0 margin_right = 1046.0 margin_bottom = 1664.0 +script = ExtResource( 3 ) [node name="HBoxContainer" type="HBoxContainer" parent="."] margin_right = 1026.0 margin_bottom = 300.0 [node name="Length" type="Label" parent="HBoxContainer"] +unique_name_in_owner = true margin_right = 511.0 margin_bottom = 300.0 rect_min_size = Vector2( 0, 300 ) @@ -32,6 +34,7 @@ valign = 1 clip_text = true [node name="Description" type="TextEdit" parent="HBoxContainer"] +unique_name_in_owner = true margin_left = 515.0 margin_right = 1026.0 margin_bottom = 300.0 @@ -48,10 +51,7 @@ margin_right = 1026.0 margin_bottom = 1644.0 size_flags_vertical = 3 -[node name="SubtaskList" type="VBoxContainer" parent="ScrollContainer"] +[node name="SubTaskList" type="VBoxContainer" parent="ScrollContainer"] unique_name_in_owner = true margin_right = 1026.0 -margin_bottom = 110.0 size_flags_horizontal = 3 - -[node name="TaskItem" parent="ScrollContainer/SubtaskList" instance=ExtResource( 2 )] diff --git a/screens/Task/Header.gd b/screens/Task/Header.gd index ed2fe98..8f6c3f7 100644 --- a/screens/Task/Header.gd +++ b/screens/Task/Header.gd @@ -1,4 +1,7 @@ extends HBoxContainer +func populate(data): + $"%Name".text = data.name + func _on_Back_button_up(): - $"/root/Main".nav_screen("TimeSlot") + $"/root/Main".nav_back() diff --git a/screens/Task/Header.tscn b/screens/Task/Header.tscn index 89e488c..66cb874 100644 --- a/screens/Task/Header.tscn +++ b/screens/Task/Header.tscn @@ -15,6 +15,7 @@ margin_bottom = 198.0 script = ExtResource( 2 ) [node name="Name" type="Label" parent="."] +unique_name_in_owner = true margin_top = 30.0 margin_right = 799.0 margin_bottom = 147.0 diff --git a/screens/Task/SubtaskItem.gd b/screens/Task/SubtaskItem.gd new file mode 100644 index 0000000..157ed5c --- /dev/null +++ b/screens/Task/SubtaskItem.gd @@ -0,0 +1,4 @@ +extends MarginContainer + +func populate(data): + $"Button".text = data.name
\ No newline at end of file diff --git a/screens/Task/SubtaskItem.tscn b/screens/Task/SubtaskItem.tscn index 48fc590..11bcd0b 100644 --- a/screens/Task/SubtaskItem.tscn +++ b/screens/Task/SubtaskItem.tscn @@ -1,16 +1,18 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://screens/Task/SubtaskItem.gd" type="Script" id=2] [sub_resource type="DynamicFont" id=1] size = 72 font_data = ExtResource( 1 ) -[node name="TaskItem" type="MarginContainer"] +[node name="SubTaskItem" type="MarginContainer"] margin_right = 1026.0 margin_bottom = 110.0 custom_constants/margin_top = 5 custom_constants/margin_bottom = 5 +script = ExtResource( 2 ) [node name="Button" type="Button" parent="."] margin_top = 5.0 diff --git a/screens/TimeSlot/Body.gd b/screens/TimeSlot/Body.gd new file mode 100644 index 0000000..aa1f352 --- /dev/null +++ b/screens/TimeSlot/Body.gd @@ -0,0 +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) diff --git a/screens/TimeSlot/Body.tscn b/screens/TimeSlot/Body.tscn index 2e6460a..0456acb 100644 --- a/screens/TimeSlot/Body.tscn +++ b/screens/TimeSlot/Body.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://screens/TimeSlot/TaskItem.tscn" type="PackedScene" id=2] +[ext_resource path="res://screens/TimeSlot/Body.gd" type="Script" id=3] [sub_resource type="DynamicFont" id=2] size = 100 @@ -12,6 +12,7 @@ margin_left = 20.0 margin_top = 20.0 margin_right = 1046.0 margin_bottom = 1664.0 +script = ExtResource( 3 ) [node name="TimeRange" type="Label" parent="."] unique_name_in_owner = true @@ -31,7 +32,4 @@ size_flags_vertical = 3 [node name="TaskList" type="VBoxContainer" parent="ScrollContainer"] unique_name_in_owner = true margin_right = 1026.0 -margin_bottom = 110.0 size_flags_horizontal = 3 - -[node name="TaskItem" parent="ScrollContainer/TaskList" instance=ExtResource( 2 )] diff --git a/screens/TimeSlot/Header.gd b/screens/TimeSlot/Header.gd index 009a9b4..8f6c3f7 100644 --- a/screens/TimeSlot/Header.gd +++ b/screens/TimeSlot/Header.gd @@ -1,4 +1,7 @@ extends HBoxContainer +func populate(data): + $"%Name".text = data.name + func _on_Back_button_up(): - $"/root/Main".nav_screen("Task") + $"/root/Main".nav_back() diff --git a/screens/TimeSlot/Header.tscn b/screens/TimeSlot/Header.tscn index 2823e6a..eec311c 100644 --- a/screens/TimeSlot/Header.tscn +++ b/screens/TimeSlot/Header.tscn @@ -15,6 +15,7 @@ margin_bottom = 198.0 script = ExtResource( 2 ) [node name="Name" type="Label" parent="."] +unique_name_in_owner = true margin_top = 30.0 margin_right = 799.0 margin_bottom = 147.0 diff --git a/screens/TimeSlot/TaskItem.gd b/screens/TimeSlot/TaskItem.gd new file mode 100644 index 0000000..c2ab487 --- /dev/null +++ b/screens/TimeSlot/TaskItem.gd @@ -0,0 +1,17 @@ +extends MarginContainer + +var task_id + +func populate(data): + task_id = data.id + $"%Name".text = data.name + $"%Length".text = "%d min" % data.estimated_length + var freq = $"%Frequency" + freq.text = DataHelpers.frequency(data.frequency) + if freq.text.length() > 10: + freq["custom_fonts/font"] = freq["custom_fonts/font"].duplicate() + freq["custom_fonts/font"].size /= 2 + + +func _on_Button_button_up(): + $"/root/Main".nav_screen("Task", Task, "get_by_id", [task_id]) diff --git a/screens/TimeSlot/TaskItem.tscn b/screens/TimeSlot/TaskItem.tscn index 75ef95d..1a9948d 100644 --- a/screens/TimeSlot/TaskItem.tscn +++ b/screens/TimeSlot/TaskItem.tscn @@ -1,16 +1,22 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://screens/TimeSlot/TaskItem.gd" type="Script" id=2] [sub_resource type="DynamicFont" id=1] size = 72 font_data = ExtResource( 1 ) +[sub_resource type="DynamicFont" id=2] +size = 72 +font_data = ExtResource( 1 ) + [node name="TaskItem" type="MarginContainer"] margin_right = 1026.0 margin_bottom = 110.0 custom_constants/margin_top = 5 custom_constants/margin_bottom = 5 +script = ExtResource( 2 ) [node name="Button" type="Button" parent="."] margin_top = 5.0 @@ -24,6 +30,7 @@ margin_bottom = 100.0 alignment = 2 [node name="Name" type="Label" parent="Button/HBoxContainer"] +unique_name_in_owner = true margin_top = 8.0 margin_right = 493.0 margin_bottom = 92.0 @@ -33,6 +40,7 @@ text = "Stretching" clip_text = true [node name="Length" type="Label" parent="Button/HBoxContainer"] +unique_name_in_owner = true margin_left = 497.0 margin_top = 8.0 margin_right = 722.0 @@ -42,12 +50,15 @@ text = "10 min" align = 2 [node name="Frequency" type="Label" parent="Button/HBoxContainer"] +unique_name_in_owner = true margin_left = 726.0 margin_top = 8.0 margin_right = 1026.0 margin_bottom = 92.0 rect_min_size = Vector2( 300, 0 ) -custom_fonts/font = SubResource( 1 ) +custom_fonts/font = SubResource( 2 ) text = "Daily" align = 2 clip_text = true + +[connection signal="button_up" from="Button" to="." method="_on_Button_button_up"] |