feat: edit entries
This commit is contained in:
parent
8e215a6962
commit
3d87fd8fcb
30 changed files with 519 additions and 6 deletions
38
src/UI/done_box.gd
Normal file
38
src/UI/done_box.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
extends HBoxContainer
|
||||
|
||||
@export var edit_menu: PackedScene
|
||||
@export var options_menu: MenuButton
|
||||
|
||||
@export var entry_text_box: RichTextLabel
|
||||
|
||||
var instantiated_menu
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
options_menu.get_popup().id_pressed.connect(_on_index_pressed)
|
||||
|
||||
SignalBus.edit_window_text_saved.connect(on_edit_window_text_save)
|
||||
SignalBus.edit_window_closed.connect(on_edit_window_closed)
|
||||
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _on_index_pressed(index:int) -> void:
|
||||
print(index)
|
||||
if index == 0:
|
||||
instantiated_menu = edit_menu.instantiate()
|
||||
add_child(instantiated_menu)
|
||||
SignalBus.edit_window_requested.emit(entry_text_box.text)
|
||||
if index == 1:
|
||||
queue_free()
|
||||
|
||||
|
||||
func on_edit_window_text_save(text: String) -> void:
|
||||
entry_text_box.text = text
|
||||
|
||||
func on_edit_window_closed() -> void:
|
||||
instantiated_menu.queue_free()
|
||||
1
src/UI/done_box.gd.uid
Normal file
1
src/UI/done_box.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://buvowannsky2u
|
||||
12
src/UI/done_options_menu.gd
Normal file
12
src/UI/done_options_menu.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
extends MenuButton
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
1
src/UI/done_options_menu.gd.uid
Normal file
1
src/UI/done_options_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://hx7vjovdnudk
|
||||
29
src/UI/editmenu.gd
Normal file
29
src/UI/editmenu.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
extends Window
|
||||
|
||||
@export var text_edit: TextEdit
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
SignalBus.edit_window_requested.connect(on_edit_window_requested)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_close_requested() -> void:
|
||||
SignalBus.edit_window_closed.emit()
|
||||
|
||||
|
||||
func on_edit_window_requested(text: String) -> void:
|
||||
text_edit.text = text
|
||||
|
||||
func _on_cancel_button_button_down() -> void:
|
||||
SignalBus.edit_window_closed.emit()
|
||||
|
||||
|
||||
func _on_save_button_button_down() -> void:
|
||||
SignalBus.edit_window_text_saved.emit(text_edit.text)
|
||||
SignalBus.edit_window_closed.emit()
|
||||
1
src/UI/editmenu.gd.uid
Normal file
1
src/UI/editmenu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cdkqu7he8lkb6
|
||||
58
src/UI/editmenu.tscn
Normal file
58
src/UI/editmenu.tscn
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dcifyvgobrvp5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cdkqu7he8lkb6" path="res://src/UI/editmenu.gd" id="1_qmobg"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpvgbghct7ayv" path="res://src/assets/icons/x.svg" id="2_lut1q"]
|
||||
[ext_resource type="Texture2D" uid="uid://cbj48abbpldb" path="res://src/assets/icons/device-floppy.svg" id="3_i6crh"]
|
||||
|
||||
[node name="Control" type="Window" node_paths=PackedStringArray("text_edit")]
|
||||
title = "Edit Entry"
|
||||
initial_position = 1
|
||||
size = Vector2i(600, 300)
|
||||
exclusive = true
|
||||
script = ExtResource("1_qmobg")
|
||||
text_edit = NodePath("Panel/MarginContainer/VBoxContainer/TextEdit")
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextEdit" type="TextEdit" parent="Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
wrap_mode = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="CancelButton" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
||||
icon = ExtResource("2_lut1q")
|
||||
|
||||
[node name="SaveButton" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Save"
|
||||
icon = ExtResource("3_i6crh")
|
||||
|
||||
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
||||
[connection signal="button_down" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/CancelButton" to="." method="_on_cancel_button_button_down"]
|
||||
[connection signal="button_down" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/SaveButton" to="." method="_on_save_button_button_down"]
|
||||
|
|
@ -139,6 +139,7 @@ size_flags_vertical = 3
|
|||
script = ExtResource("5_05tj4")
|
||||
current_active_panel = NodePath("MainPanel")
|
||||
container_collection_box = NodePath("Panel/MarginContainer/ScrollContainer/ContainerBox")
|
||||
main_panel_scene = ExtResource("9_cqoei")
|
||||
|
||||
[node name="Panel" type="Panel" parent="Panel/VBoxContainer/UIManager"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@ class_name MainPanel extends ScrollContainer
|
|||
@export var style_box: StyleBoxFlat
|
||||
@export var panel_main_color: Color
|
||||
|
||||
var id: int = 1
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
panel_main_color = style_box.bg_color
|
||||
|
||||
create_panel_name()
|
||||
SignalBus.main_panel_color_changed.connect(_on_main_panel_color_changed)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
@ -18,3 +22,9 @@ func _process(delta: float) -> void:
|
|||
|
||||
func _on_main_panel_color_changed(color: Color):
|
||||
style_box.bg_color = color
|
||||
|
||||
|
||||
func create_panel_name() -> void:
|
||||
var panel_name: String = "Container %d" % id
|
||||
container_name_label.text = panel_name
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://cirolvhfd455u"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cirolvhfd455u"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bal6yp0a25hf2" path="res://src/theme/main_theme.tres" id="1_c0dr6"]
|
||||
[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="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="Texture2D" uid="uid://c1ccasyx80msg" path="res://src/assets/icons/dots-vertical.svg" id="5_bb2jg"]
|
||||
[ext_resource type="Script" uid="uid://buvowannsky2u" path="res://src/UI/done_box.gd" id="5_w3kqg"]
|
||||
[ext_resource type="PackedScene" uid="uid://dcifyvgobrvp5" path="res://src/UI/editmenu.tscn" id="6_qxra8"]
|
||||
[ext_resource type="Texture2D" uid="uid://s3vf3vhl8y3e" path="res://src/assets/icons/trash.svg" id="7_8bhwf"]
|
||||
[ext_resource type="Texture2D" uid="uid://ne4o3drvj5vw" path="res://src/assets/icons/color-picker.svg" id="8_8bhwf"]
|
||||
|
||||
[node name="MainPanel" type="ScrollContainer" node_paths=PackedStringArray("container_name_label")]
|
||||
anchors_preset = 15
|
||||
|
|
@ -40,3 +46,83 @@ text = "Container"
|
|||
fit_content = true
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DayContainer" type="VBoxContainer" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" 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/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "[b]MM.DD.YYYY[b]"
|
||||
fit_content = true
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="DoneBox" type="HBoxContainer" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer" node_paths=PackedStringArray("options_menu", "entry_text_box")]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
script = ExtResource("5_w3kqg")
|
||||
edit_menu = ExtResource("6_qxra8")
|
||||
options_menu = NodePath("MenuButton")
|
||||
entry_text_box = NodePath("RichTextLabel")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/DoneBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
focus_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "Haaaalooo"
|
||||
fit_content = true
|
||||
context_menu_enabled = true
|
||||
selection_enabled = true
|
||||
|
||||
[node name="MenuButton" type="MenuButton" parent="Panel/VBoxContainer/MarginContainer/VBoxContainer/DayContainer/DoneBox"]
|
||||
layout_mode = 2
|
||||
icon = ExtResource("5_bb2jg")
|
||||
item_count = 2
|
||||
popup/item_0/text = "Edit"
|
||||
popup/item_0/icon = ExtResource("8_8bhwf")
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "Delete"
|
||||
popup/item_1/icon = ExtResource("7_8bhwf")
|
||||
popup/item_1/id = 1
|
||||
|
||||
[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
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ class_name UIManager extends HBoxContainer
|
|||
@export var panel_array: Array[MainPanel] = []
|
||||
@export var container_collection_box: ContainerBox
|
||||
|
||||
@export var main_panel_scene: PackedScene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var text: String = "Container %d" % container_collection_box.container_id
|
||||
current_active_panel.container_name_label.text = text
|
||||
current_active_panel.id = 1
|
||||
panel_array.append(current_active_panel)
|
||||
|
||||
SignalBus.on_panel_created.connect(_on_panel_created)
|
||||
|
|
@ -20,11 +21,20 @@ func _process(delta: float) -> void:
|
|||
|
||||
|
||||
func _on_panel_created() -> void:
|
||||
var new_panel: MainPanel = MainPanel.new()
|
||||
var new_panel: MainPanel = main_panel_scene.instantiate()
|
||||
new_panel.id = panel_array.size() + 1
|
||||
panel_array.append(new_panel)
|
||||
|
||||
func _on_panel_requested(index: int) -> void:
|
||||
if current_active_panel == panel_array[index]:
|
||||
print("Already active")
|
||||
return
|
||||
print("Panel: %d requested" % index)
|
||||
current_active_panel.hide()
|
||||
current_active_panel = panel_array[index]
|
||||
add_child(current_active_panel)
|
||||
if not current_active_panel.is_inside_tree():
|
||||
add_child(current_active_panel)
|
||||
else:
|
||||
current_active_panel.show()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue