fix: adding new done boxes works correctly
This commit is contained in:
parent
6ce640fce2
commit
32cdffd8ec
11 changed files with 111 additions and 48 deletions
|
|
@ -18,3 +18,6 @@ signal side_panel_color_changed(color: Color)
|
||||||
|
|
||||||
signal on_panel_created()
|
signal on_panel_created()
|
||||||
signal on_panel_requested(index)
|
signal on_panel_requested(index)
|
||||||
|
|
||||||
|
|
||||||
|
signal on_add_entry_button_pressed(day_container: DayContainer)
|
||||||
|
|
@ -133,12 +133,11 @@ text = "Whydt"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="UIManager" type="HBoxContainer" parent="Panel/VBoxContainer" node_paths=PackedStringArray("current_active_panel", "container_collection_box")]
|
[node name="UIManager" type="HBoxContainer" parent="Panel/VBoxContainer" node_paths=PackedStringArray("container_collection_box")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
script = ExtResource("5_05tj4")
|
script = ExtResource("5_05tj4")
|
||||||
current_active_panel = NodePath("")
|
|
||||||
main_panel_scene = ExtResource("9_cqoei")
|
main_panel_scene = ExtResource("9_cqoei")
|
||||||
container_collection_box = NodePath("Panel/MarginContainer/ScrollContainer/ContainerBox")
|
container_collection_box = NodePath("Panel/MarginContainer/ScrollContainer/ContainerBox")
|
||||||
container_button_scene = ExtResource("5_14o3q")
|
container_button_scene = ExtResource("5_14o3q")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ const uuid_util = preload('res://addons/uuid/uuid.gd')
|
||||||
@export var container_name_label: RichTextLabel
|
@export var container_name_label: RichTextLabel
|
||||||
@export var style_box: StyleBoxFlat
|
@export var style_box: StyleBoxFlat
|
||||||
@export var panel_main_color: Color
|
@export var panel_main_color: Color
|
||||||
@export var day_container: Container
|
|
||||||
|
@export var day_containers: Array[DayContainer] = []
|
||||||
|
|
||||||
@export_group("Entries")
|
@export_group("Entries")
|
||||||
@export var done_boxes: Array[DoneBox] = []
|
@export var done_boxes: Array[DoneBox] = []
|
||||||
|
|
@ -20,6 +21,11 @@ func _ready() -> void:
|
||||||
#SignalBus.edit_window_text_saved.connect(on_edit_window_text_save)
|
#SignalBus.edit_window_text_saved.connect(on_edit_window_text_save)
|
||||||
SignalBus.on_entry_deleted.connect(on_entry_deleted)
|
SignalBus.on_entry_deleted.connect(on_entry_deleted)
|
||||||
|
|
||||||
|
|
||||||
|
for child in get_children(true):
|
||||||
|
if is_instance_of(child, DayContainer):
|
||||||
|
day_containers.append(child)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
@ -34,13 +40,7 @@ func create_panel_name() -> void:
|
||||||
var panel_name: String = "Container %s" % id
|
var panel_name: String = "Container %s" % id
|
||||||
container_name_label.text = panel_name
|
container_name_label.text = panel_name
|
||||||
|
|
||||||
func _on_add_button_pressed() -> void:
|
|
||||||
var new_done_box: DoneBox = done_box_scene.instantiate()
|
|
||||||
done_boxes.append(new_done_box)
|
|
||||||
|
|
||||||
day_container.add_child(new_done_box)
|
|
||||||
day_container.move_child(new_done_box, -1)
|
|
||||||
print(done_boxes)
|
|
||||||
|
|
||||||
|
|
||||||
func on_entry_deleted(node: Node) -> void:
|
func on_entry_deleted(node: Node) -> void:
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
[ext_resource type="Script" uid="uid://bmsw85eprqln1" path="res://src/UI/main_panel.gd" id="2_5qsb6"]
|
[ext_resource type="Script" uid="uid://bmsw85eprqln1" path="res://src/UI/main_panel.gd" id="2_5qsb6"]
|
||||||
[ext_resource type="StyleBox" uid="uid://b7rqx5hwj7wff" path="res://src/UI/main_panel.tres" id="3_enj05"]
|
[ext_resource type="StyleBox" uid="uid://b7rqx5hwj7wff" path="res://src/UI/main_panel.tres" id="3_enj05"]
|
||||||
[ext_resource type="Script" uid="uid://b4q5pgorn5osd" path="res://src/UI/m_panel.gd" id="4_1citv"]
|
[ext_resource type="Script" uid="uid://b4q5pgorn5osd" path="res://src/UI/m_panel.gd" id="4_1citv"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dof65a47bfapk" path="res://src/assets/icons/library-plus.svg" id="5_1citv"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://d1b10b44uwo8y" path="res://src/UI/done_box.tscn" id="5_bb2jg"]
|
[ext_resource type="PackedScene" uid="uid://d1b10b44uwo8y" path="res://src/UI/done_box.tscn" id="5_bb2jg"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cxm7lqciow8sh" path="res://src/UI/main_panel/day_container.tscn" id="6_bb2jg"]
|
||||||
|
|
||||||
[node name="MainPanel" type="ScrollContainer" node_paths=PackedStringArray("container_name_label", "day_container")]
|
[node name="MainPanel" type="ScrollContainer" node_paths=PackedStringArray("container_name_label")]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
|
@ -19,7 +19,6 @@ horizontal_scroll_mode = 0
|
||||||
script = ExtResource("2_5qsb6")
|
script = ExtResource("2_5qsb6")
|
||||||
container_name_label = NodePath("Panel/VBoxContainer/RichTextLabel")
|
container_name_label = NodePath("Panel/VBoxContainer/RichTextLabel")
|
||||||
style_box = ExtResource("3_enj05")
|
style_box = ExtResource("3_enj05")
|
||||||
day_container = NodePath("Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer")
|
|
||||||
done_box_scene = ExtResource("5_bb2jg")
|
done_box_scene = ExtResource("5_bb2jg")
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="."]
|
[node name="Panel" type="Panel" parent="."]
|
||||||
|
|
@ -60,40 +59,5 @@ theme_override_constants/margin_bottom = 10
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/VBoxContainer/MarginContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/VBoxContainer/MarginContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="DayContainer" type="VBoxContainer" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer"]
|
[node name="DayContainer" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer" instance=ExtResource("6_bb2jg")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="DateMarker" type="HBoxContainer" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_vertical = 0
|
|
||||||
theme_override_constants/separation = -150
|
|
||||||
|
|
||||||
[node name="HSeparator" type="HSeparator" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/DateMarker"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
theme_override_constants/separation = 10
|
|
||||||
|
|
||||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/DateMarker"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
bbcode_enabled = true
|
|
||||||
text = "[b]DD.MM.YYYY[b]"
|
|
||||||
fit_content = true
|
|
||||||
horizontal_alignment = 1
|
|
||||||
vertical_alignment = 1
|
|
||||||
|
|
||||||
[node name="HSeparator2" type="HSeparator" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/DateMarker"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
theme_override_constants/separation = 10
|
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
theme = ExtResource("1_c0dr6")
|
|
||||||
text = "Add"
|
|
||||||
icon = ExtResource("5_1citv")
|
|
||||||
icon_alignment = 1
|
|
||||||
vertical_icon_alignment = 0
|
|
||||||
expand_icon = true
|
|
||||||
|
|
||||||
[connection signal="pressed" from="Panel/VBoxContainer/MarginContainer/VBoxContainer/Button" to="." method="_on_add_button_pressed"]
|
|
||||||
|
|
|
||||||
17
src/UI/main_panel/add_entry_button.gd
Normal file
17
src/UI/main_panel/add_entry_button.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
@export var container: DayContainer
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
func _on_pressed() -> void:
|
||||||
|
print(self)
|
||||||
|
SignalBus.on_add_entry_button_pressed.emit(container)
|
||||||
1
src/UI/main_panel/add_entry_button.gd.uid
Normal file
1
src/UI/main_panel/add_entry_button.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dv2i56x60tobl
|
||||||
24
src/UI/main_panel/date_marker.tscn
Normal file
24
src/UI/main_panel/date_marker.tscn
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
[gd_scene format=3 uid="uid://n1r3urir7tik"]
|
||||||
|
|
||||||
|
[node name="DateMarker" type="HBoxContainer"]
|
||||||
|
size_flags_vertical = 0
|
||||||
|
theme_override_constants/separation = -150
|
||||||
|
|
||||||
|
[node name="HSeparator" type="HSeparator" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_constants/separation = 10
|
||||||
|
|
||||||
|
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "[b]DD.MM.YYYY[b]"
|
||||||
|
fit_content = true
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="HSeparator2" type="HSeparator" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_constants/separation = 10
|
||||||
13
src/UI/main_panel/day_container.gd
Normal file
13
src/UI/main_panel/day_container.gd
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
class_name DayContainer extends VBoxContainer
|
||||||
|
const uuid_util = preload('res://addons/uuid/uuid.gd')
|
||||||
|
|
||||||
|
var uuid
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
uuid = uuid_util.v4()
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
1
src/UI/main_panel/day_container.gd.uid
Normal file
1
src/UI/main_panel/day_container.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b4nvd4riqb6lg
|
||||||
31
src/UI/main_panel/day_container.tscn
Normal file
31
src/UI/main_panel/day_container.tscn
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://cxm7lqciow8sh"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://n1r3urir7tik" path="res://src/UI/main_panel/date_marker.tscn" id="1_bor7d"]
|
||||||
|
[ext_resource type="Script" uid="uid://b4nvd4riqb6lg" path="res://src/UI/main_panel/day_container.gd" id="1_kpgep"]
|
||||||
|
[ext_resource type="Theme" uid="uid://bal6yp0a25hf2" path="res://src/theme/main_theme.tres" id="2_5bajb"]
|
||||||
|
[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"]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_kpgep")
|
||||||
|
|
||||||
|
[node name="DateMarker" parent="." instance=ExtResource("1_bor7d")]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="AddEntryButton" type="Button" parent="." node_paths=PackedStringArray("container")]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("2_5bajb")
|
||||||
|
text = "Add"
|
||||||
|
icon = ExtResource("3_kpgep")
|
||||||
|
icon_alignment = 1
|
||||||
|
vertical_icon_alignment = 0
|
||||||
|
expand_icon = true
|
||||||
|
script = ExtResource("4_5bajb")
|
||||||
|
container = NodePath("..")
|
||||||
|
|
||||||
|
[connection signal="pressed" from="AddEntryButton" to="AddEntryButton" method="_on_pressed"]
|
||||||
|
|
@ -25,6 +25,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
SignalBus.edit_window_text_saved.connect(_on_edit_window_text_saved)
|
SignalBus.edit_window_text_saved.connect(_on_edit_window_text_saved)
|
||||||
#SignalBus.on_entry_deleted.connect(on_entry_deleted)
|
#SignalBus.on_entry_deleted.connect(on_entry_deleted)
|
||||||
|
SignalBus.on_add_entry_button_pressed.connect(_on_add_button_pressed)
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
|
@ -78,4 +79,13 @@ func _on_edit_window_text_saved(window: Window, text: String, node: Node) -> voi
|
||||||
func rename_container_text_box_when_button_is_renamed(id) -> void:
|
func rename_container_text_box_when_button_is_renamed(id) -> void:
|
||||||
panel_array[id].container_name_label.text = container_selection_buttons[id].button.text
|
panel_array[id].container_name_label.text = container_selection_buttons[id].button.text
|
||||||
|
|
||||||
|
func _on_add_button_pressed(container: DayContainer) -> void:
|
||||||
|
print("pressed")
|
||||||
|
var new_done_box: DoneBox = current_active_panel.done_box_scene.instantiate()
|
||||||
|
current_active_panel.done_boxes.append(new_done_box)
|
||||||
|
|
||||||
|
container.add_child(new_done_box)
|
||||||
|
container.move_child(new_done_box, -2)
|
||||||
|
print(current_active_panel.done_boxes)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue