feat: started work on save system
WIP - build doesn't work yet
This commit is contained in:
parent
32cdffd8ec
commit
8bff48784f
14 changed files with 112 additions and 10 deletions
19
src/Singletons/SaveScene.gd
Normal file
19
src/Singletons/SaveScene.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class_name SaveScene extends Resource
|
||||
|
||||
@export var nodes: Array[Control] = []
|
||||
|
||||
const SAVE_PATH: String = "user://save.tres"
|
||||
|
||||
func write_save() -> void:
|
||||
ResourceSaver.save(self, SAVE_PATH)
|
||||
|
||||
func load_save() -> Resource:
|
||||
if ResourceLoader.exists(SAVE_PATH):
|
||||
return load(SAVE_PATH)
|
||||
return null
|
||||
|
||||
func save_exists() -> bool:
|
||||
if ResourceLoader.exists(SAVE_PATH):
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
1
src/Singletons/SaveScene.gd.uid
Normal file
1
src/Singletons/SaveScene.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://duifkfe0647ly
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
extends Node
|
||||
|
||||
signal on_something_changed
|
||||
|
||||
signal on_window_closed(window: Window)
|
||||
signal on_new_container_requested
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ func _on_index_pressed(index:int) -> void:
|
|||
print("Node: ", node)
|
||||
if index == 1:
|
||||
queue_free()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func on_edit_window_closed(window: Window) -> void:
|
||||
if not is_instance_of(window, Editmenu):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,28 @@
|
|||
extends Control
|
||||
|
||||
|
||||
var _save: SaveScene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass
|
||||
load_or_create_save.call_deferred()
|
||||
#SaveScene.load_scene(self.get_tree(), "user://scene.tscn")
|
||||
SignalBus.on_something_changed.connect(_on_something_changed)
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func load_or_create_save() -> void:
|
||||
#if SaveScene.save_exists():
|
||||
# _save = SaveScene.load_save() as SaveScene
|
||||
# return
|
||||
|
||||
_save = SaveScene.new()
|
||||
for node in get_tree():
|
||||
pass
|
||||
#_save.main_scene = result
|
||||
|
||||
func _on_something_changed() -> void:
|
||||
#SaveScene.write_save()
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ const uuid_util = preload('res://addons/uuid/uuid.gd')
|
|||
@export_group("Entries")
|
||||
@export var done_boxes: Array[DoneBox] = []
|
||||
@export var done_box_scene: PackedScene
|
||||
@export var dates: Array[Date] = []
|
||||
|
||||
var id
|
||||
|
||||
|
|
@ -20,7 +21,11 @@ func _ready() -> void:
|
|||
SignalBus.main_panel_color_changed.connect(_on_main_panel_color_changed)
|
||||
#SignalBus.edit_window_text_saved.connect(on_edit_window_text_save)
|
||||
SignalBus.on_entry_deleted.connect(on_entry_deleted)
|
||||
|
||||
var d: Date = Date.new()
|
||||
d = d.get_current_date()
|
||||
print(d.day)
|
||||
print(d.month)
|
||||
print(d.year)
|
||||
|
||||
for child in get_children(true):
|
||||
if is_instance_of(child, DayContainer):
|
||||
|
|
|
|||
12
src/UI/main_panel/date_marker.gd
Normal file
12
src/UI/main_panel/date_marker.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
class_name DateMarker extends HBoxContainer
|
||||
|
||||
@export var date_text_label: RichTextLabel
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
1
src/UI/main_panel/date_marker.gd.uid
Normal file
1
src/UI/main_panel/date_marker.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://tq3r7qpunh34
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
[gd_scene format=3 uid="uid://n1r3urir7tik"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://n1r3urir7tik"]
|
||||
|
||||
[node name="DateMarker" type="HBoxContainer"]
|
||||
[ext_resource type="Script" uid="uid://tq3r7qpunh34" path="res://src/UI/main_panel/date_marker.gd" id="1_s6cos"]
|
||||
|
||||
[node name="DateMarker" type="HBoxContainer" node_paths=PackedStringArray("date_text_label")]
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/separation = -150
|
||||
script = ExtResource("1_s6cos")
|
||||
date_text_label = NodePath("RichTextLabel")
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="."]
|
||||
layout_mode = 2
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
class_name DayContainer extends VBoxContainer
|
||||
const uuid_util = preload('res://addons/uuid/uuid.gd')
|
||||
|
||||
@export var date_marker: DateMarker
|
||||
var uuid
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
uuid = uuid_util.v4()
|
||||
|
||||
var date: Date = Date.new()
|
||||
date = date.get_current_date()
|
||||
var _d: int = date.day
|
||||
var _m: int = date.month
|
||||
var _y: int = date.year
|
||||
var date_string: String = str(_d) + "." + str(_m) + "." + str(_y)
|
||||
date_marker.date_text_label.text = date_string
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@
|
|||
[ext_resource type="Texture2D" uid="uid://dof65a47bfapk" path="res://src/assets/icons/library-plus.svg" id="3_kpgep"]
|
||||
[ext_resource type="Script" uid="uid://dv2i56x60tobl" path="res://src/UI/main_panel/add_entry_button.gd" id="4_5bajb"]
|
||||
|
||||
[node name="DayContainer" type="VBoxContainer"]
|
||||
[node name="DayContainer" type="VBoxContainer" node_paths=PackedStringArray("date_marker")]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_kpgep")
|
||||
date_marker = NodePath("DateMarker")
|
||||
|
||||
[node name="DateMarker" parent="." instance=ExtResource("1_bor7d")]
|
||||
layout_mode = 2
|
||||
|
|
|
|||
|
|
@ -87,5 +87,6 @@ func _on_add_button_pressed(container: DayContainer) -> void:
|
|||
container.add_child(new_done_box)
|
||||
container.move_child(new_done_box, -2)
|
||||
print(current_active_panel.done_boxes)
|
||||
#SignalBus.on_something_changed.emit()
|
||||
|
||||
|
||||
|
|
|
|||
33
src/util/Date.gd
Normal file
33
src/util/Date.gd
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
class_name Date extends Node
|
||||
|
||||
var day: int
|
||||
var month: int
|
||||
var year: int
|
||||
|
||||
|
||||
func get_current_date() -> Date:
|
||||
var d: Date = Date.new()
|
||||
var time: Dictionary = Time.get_date_dict_from_system(false)
|
||||
d.day = get_day(time)
|
||||
d.month = get_month(time)
|
||||
d.year = get_year(time)
|
||||
|
||||
return d
|
||||
|
||||
func get_year(t: Dictionary) -> int:
|
||||
var _year: int = t.get("year")
|
||||
return _year
|
||||
|
||||
func get_month(t: Dictionary) -> int:
|
||||
var _year: int = t.get("month")
|
||||
return _year
|
||||
|
||||
func get_day(t: Dictionary) -> int:
|
||||
var _year: int = t.get("day")
|
||||
return _year
|
||||
|
||||
func is_equal_to(other_date: Date) -> bool:
|
||||
if self != other_date:
|
||||
return false
|
||||
else:
|
||||
return true
|
||||
1
src/util/Date.gd.uid
Normal file
1
src/util/Date.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://basprhhcje5ib
|
||||
Loading…
Add table
Add a link
Reference in a new issue