diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-08-27 00:39:58 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-08-27 00:39:58 -0400 |
commit | e4322bde34c2c8c864e3fd40bd254894d18fb15f (patch) | |
tree | fb07ac99416cbe258bb8415e39eeb1597b7be8d1 | |
parent | 260fa2214e298686678d43ca58bcbfd493d563b3 (diff) | |
download | Planner-e4322bde34c2c8c864e3fd40bd254894d18fb15f.tar.gz Planner-e4322bde34c2c8c864e3fd40bd254894d18fb15f.zip |
Add Main Schedule Screen Prototype
-rw-r--r-- | Main.gd | 2 | ||||
-rw-r--r-- | data_model/TimeSlot.gd | 9 | ||||
-rw-r--r-- | screens/Schedule/Body.gd | 13 | ||||
-rw-r--r-- | screens/Schedule/Body.tscn | 40 | ||||
-rw-r--r-- | screens/Schedule/Header.gd | 26 | ||||
-rw-r--r-- | screens/Schedule/Header.tscn | 40 | ||||
-rw-r--r-- | screens/Schedule/TimeSlotItem.gd | 12 | ||||
-rw-r--r-- | screens/Schedule/TimeSlotItem.tscn | 55 |
8 files changed, 196 insertions, 1 deletions
@@ -43,4 +43,4 @@ func swap_screen(screen): body_container.add_child(body) func _ready(): - nav_screen("TaskManager", DataHelpers, "dummy_data", [[]]) + nav_screen("Schedule", TimeSlot, "get_by_schedule_name", ["default"]) diff --git a/data_model/TimeSlot.gd b/data_model/TimeSlot.gd index f98cd62..80b7671 100644 --- a/data_model/TimeSlot.gd +++ b/data_model/TimeSlot.gd @@ -16,6 +16,15 @@ class TimeSlot_data: self.name = record['name']
self.date_completed = record['date_completed']
+static func get_by_id(id):
+ var record = DBMS.query("""
+ SELECT * FROM "TimeSlots"
+ WHERE id = ?
+ """,
+ [id])
+ record = record[0]
+ return TimeSlot_data.new(record)
+
static func get_by_schedule_name(schedule_name):
var records = DBMS.query("""
SELECT "TimeSlots".* FROM "TimeSlots"
diff --git a/screens/Schedule/Body.gd b/screens/Schedule/Body.gd new file mode 100644 index 0000000..7760a59 --- /dev/null +++ b/screens/Schedule/Body.gd @@ -0,0 +1,13 @@ +extends VBoxContainer + +func populate(data): + var TimeSlotItem = load("res://screens/Schedule/TimeSlotItem.tscn") + var timeslot_list = $"%TimeSlotList" + for timeslot in data: + var item = TimeSlotItem.instance() + item.populate(timeslot) + timeslot_list.add_child(item) + + +func _on_ManageTasks_button_up(): + $"/root/Main".nav_screen("TaskManager", DataHelpers, "dummy_data", [[]]) diff --git a/screens/Schedule/Body.tscn b/screens/Schedule/Body.tscn new file mode 100644 index 0000000..64747d9 --- /dev/null +++ b/screens/Schedule/Body.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://screens/Schedule/Body.gd" type="Script" id=1] +[ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=2] + +[sub_resource type="DynamicFont" id=3] +size = 72 +font_data = ExtResource( 2 ) + +[node name="ScheduleBody" type="VBoxContainer"] +margin_left = 20.0 +margin_top = 20.0 +margin_right = 1060.0 +margin_bottom = 1676.0 +script = ExtResource( 1 ) + +[node name="ScrollContainer" type="ScrollContainer" parent="."] +margin_right = 1040.0 +margin_bottom = 1502.0 +size_flags_vertical = 3 + +[node name="TimeSlotList" type="VBoxContainer" parent="ScrollContainer"] +unique_name_in_owner = true +margin_right = 1040.0 +size_flags_horizontal = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +margin_top = 1506.0 +margin_right = 1040.0 +margin_bottom = 1656.0 +rect_min_size = Vector2( 0, 150 ) + +[node name="ManageTasks" type="Button" parent="HBoxContainer"] +margin_right = 1040.0 +margin_bottom = 150.0 +size_flags_horizontal = 3 +custom_fonts/font = SubResource( 3 ) +text = "Manage Tasks" + +[connection signal="button_up" from="HBoxContainer/ManageTasks" to="." method="_on_ManageTasks_button_up"] diff --git a/screens/Schedule/Header.gd b/screens/Schedule/Header.gd new file mode 100644 index 0000000..3cf6e01 --- /dev/null +++ b/screens/Schedule/Header.gd @@ -0,0 +1,26 @@ +extends Button + +var timeslots = [] +var current_timeslot = null +var last_minute = -1 + +func populate(data): + timeslots = data + +func _process(_delta): + var time = Time.get_unix_time_from_system() + var time_dict = Time.get_time_dict_from_unix_time(time) + if time_dict.minute != last_minute: + last_minute = time_dict.minute + $"%Time".text = DataHelpers.timeofday(time) + time = Time.get_unix_time_from_datetime_dict(time_dict) + current_timeslot = null + for timeslot in timeslots: + if time >= timeslot.start_time && time <= timeslot.end_time: + current_timeslot = timeslot + break + $"%Name".text = "Free Time" if current_timeslot == null else current_timeslot.name + +func _on_ScheduleHeader_button_up(): + if current_timeslot != null: + $"/root/Main".nav_screen("TimeSlot", TimeSlot, "get_by_id", [current_timeslot.id]) diff --git a/screens/Schedule/Header.tscn b/screens/Schedule/Header.tscn new file mode 100644 index 0000000..c39877e --- /dev/null +++ b/screens/Schedule/Header.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://screens/Schedule/Header.gd" type="Script" id=1] +[ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=2] + +[sub_resource type="DynamicFont" id=2] +size = 100 +font_data = ExtResource( 2 ) + +[node name="ScheduleHeader" type="Button"] +margin_left = 20.0 +margin_top = 20.0 +margin_right = 1060.0 +margin_bottom = 200.0 +script = ExtResource( 1 ) + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Time" type="Label" parent="HBoxContainer"] +unique_name_in_owner = true +margin_top = 31.0 +margin_right = 421.0 +margin_bottom = 148.0 +custom_fonts/font = SubResource( 2 ) +text = "12:30 AM" + +[node name="Name" type="Label" parent="HBoxContainer"] +unique_name_in_owner = true +margin_left = 425.0 +margin_top = 31.0 +margin_right = 1040.0 +margin_bottom = 148.0 +size_flags_horizontal = 3 +custom_fonts/font = SubResource( 2 ) +text = "Chore Block" +align = 2 + +[connection signal="button_up" from="." to="." method="_on_ScheduleHeader_button_up"] diff --git a/screens/Schedule/TimeSlotItem.gd b/screens/Schedule/TimeSlotItem.gd new file mode 100644 index 0000000..d912284 --- /dev/null +++ b/screens/Schedule/TimeSlotItem.gd @@ -0,0 +1,12 @@ +extends MarginContainer + +var timeslot_id + +func populate(data): + timeslot_id = data.id + $"%Time".text = "%s ... " % DataHelpers.timeofday(data.start_time) + $"%Name".text = data.name + + +func _on_Button_button_up(): + $"/root/Main".nav_screen("TimeSlot", TimeSlot, "get_by_id", [timeslot_id]) diff --git a/screens/Schedule/TimeSlotItem.tscn b/screens/Schedule/TimeSlotItem.tscn new file mode 100644 index 0000000..95d9868 --- /dev/null +++ b/screens/Schedule/TimeSlotItem.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://fonts/DroidSans.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://screens/Schedule/TimeSlotItem.gd" type="Script" id=2] + +[sub_resource type="DynamicFont" id=1] +size = 60 +font_data = ExtResource( 1 ) + +[sub_resource type="DynamicFont" id=3] +size = 72 +font_data = ExtResource( 1 ) + +[node name="TimeSlotItem" type="MarginContainer"] +margin_right = 1040.0 +margin_bottom = 110.0 +custom_constants/margin_top = 5 +custom_constants/margin_bottom = 5 +script = ExtResource( 2 ) + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +margin_top = 5.0 +margin_right = 1040.0 +margin_bottom = 105.0 + +[node name="Time" type="Label" parent="HBoxContainer"] +unique_name_in_owner = true +margin_top = 14.0 +margin_right = 332.0 +margin_bottom = 85.0 +custom_fonts/font = SubResource( 1 ) +text = "12:30 AM ... " + +[node name="Button" type="Button" parent="HBoxContainer"] +margin_left = 336.0 +margin_right = 1040.0 +margin_bottom = 100.0 +rect_min_size = Vector2( 0, 100 ) +size_flags_horizontal = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/Button"] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Name" type="Label" parent="HBoxContainer/Button/HBoxContainer"] +unique_name_in_owner = true +margin_top = 8.0 +margin_right = 704.0 +margin_bottom = 92.0 +size_flags_horizontal = 3 +custom_fonts/font = SubResource( 3 ) +text = "Chore Block" +align = 1 + +[connection signal="button_up" from="HBoxContainer/Button" to="." method="_on_Button_button_up"] |