feat: rename container name
(remaining issue: renames every instance of the container_selection_button)
This commit is contained in:
parent
a47a818f8b
commit
15b56ef048
13 changed files with 164 additions and 20 deletions
|
|
@ -1,9 +1,11 @@
|
|||
extends Node
|
||||
|
||||
signal on_window_closed(window: Window)
|
||||
|
||||
signal settings_window_closed
|
||||
signal edit_window_closed
|
||||
signal edit_window_requested(text: String)
|
||||
signal edit_window_text_saved(text: String)
|
||||
signal edit_window_requested(window: Window, text: String)
|
||||
signal edit_window_text_saved(window: Window, text: String)
|
||||
|
||||
signal main_panel_color_changed(color: Color)
|
||||
signal main_window_color_changed(color: Color)
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@ class_name ContainerSelectionButton extends MarginContainer
|
|||
@export var button: Button
|
||||
@export var container_box: ContainerBox
|
||||
@export var popup_menu: PopupMenu
|
||||
@export var edit_collection_name_window: PackedScene
|
||||
|
||||
var button_index: int
|
||||
var instantiated_menu
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass
|
||||
SignalBus.edit_window_text_saved.connect(_on_edit_window_text_saved)
|
||||
SignalBus.on_window_closed.connect(_on_window_closed)
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
|
|
@ -32,3 +35,23 @@ func _input(event: InputEvent) -> void:
|
|||
button.get_global_rect().size.x,
|
||||
button.get_global_rect().size.y)
|
||||
)
|
||||
|
||||
|
||||
func _on_popup_menu_index_pressed(index: int) -> void:
|
||||
if instantiated_menu != null:
|
||||
return
|
||||
if index == 0:
|
||||
instantiated_menu = edit_collection_name_window.instantiate()
|
||||
add_child(instantiated_menu)
|
||||
SignalBus.edit_window_requested.emit(instantiated_menu, button.text)
|
||||
|
||||
func _on_edit_window_text_saved(window: Window, text: String) -> void:
|
||||
if not is_instance_of(window, EditCollectionNameWindow):
|
||||
return
|
||||
button.text = text
|
||||
|
||||
func _on_window_closed(window: Window) -> void:
|
||||
if not is_instance_of(window, EditCollectionNameWindow):
|
||||
return
|
||||
if instantiated_menu != null:
|
||||
instantiated_menu.queue_free()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://csre4kogd8afg"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://csre4kogd8afg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://osei0aimuya2" path="res://src/UI/buttons/container_selection_button.gd" id="1_g121j"]
|
||||
[ext_resource type="Theme" uid="uid://bal6yp0a25hf2" path="res://src/theme/main_theme.tres" id="1_ru1ls"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgqshc2r7sdmx" path="res://src/UI/windows/edit_collection_name_window.tscn" id="2_4ff2x"]
|
||||
[ext_resource type="Texture2D" uid="uid://ne4o3drvj5vw" path="res://src/assets/icons/color-picker.svg" id="3_wvlx0"]
|
||||
[ext_resource type="Texture2D" uid="uid://s3vf3vhl8y3e" path="res://src/assets/icons/trash.svg" id="4_4ff2x"]
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ theme_override_constants/margin_bottom = 5
|
|||
script = ExtResource("1_g121j")
|
||||
button = NodePath("Button")
|
||||
popup_menu = NodePath("PopupMenu")
|
||||
edit_collection_name_window = ExtResource("2_4ff2x")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
|
|
@ -43,3 +45,4 @@ item_1/icon = ExtResource("4_4ff2x")
|
|||
item_1/id = 1
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
[connection signal="index_pressed" from="PopupMenu" to="." method="_on_popup_menu_index_pressed"]
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@ func _on_index_pressed(index:int) -> void:
|
|||
if index == 0:
|
||||
instantiated_menu = edit_menu.instantiate()
|
||||
add_child(instantiated_menu)
|
||||
SignalBus.edit_window_requested.emit(entry_text_box.text)
|
||||
SignalBus.edit_window_requested.emit(instantiated_menu, entry_text_box.text)
|
||||
if index == 1:
|
||||
queue_free()
|
||||
|
||||
|
||||
func on_edit_window_text_save(text: String) -> void:
|
||||
func on_edit_window_text_save(window: Window, text: String) -> void:
|
||||
if not is_instance_of(window, Editmenu):
|
||||
return
|
||||
entry_text_box.text = text
|
||||
|
||||
func on_edit_window_closed() -> void:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://d1b10b44uwo8y"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://buvowannsky2u" path="res://src/UI/done_box.gd" id="1_kikfe"]
|
||||
[ext_resource type="PackedScene" uid="uid://dcifyvgobrvp5" path="res://src/UI/editmenu.tscn" id="2_qm8q0"]
|
||||
[ext_resource type="PackedScene" uid="uid://dcifyvgobrvp5" path="res://src/UI/windows/editmenu.tscn" id="2_qm8q0"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1ccasyx80msg" path="res://src/assets/icons/dots-vertical.svg" id="3_leupd"]
|
||||
[ext_resource type="Texture2D" uid="uid://ne4o3drvj5vw" path="res://src/assets/icons/color-picker.svg" id="4_qqlum"]
|
||||
[ext_resource type="Texture2D" uid="uid://s3vf3vhl8y3e" path="res://src/assets/icons/trash.svg" id="5_k527k"]
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
extends Control
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
|
@ -170,10 +170,6 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
script = ExtResource("5_cqoei")
|
||||
|
||||
[node name="ContainerSelectionButton" parent="Panel/VBoxContainer/UIManager/Panel/MarginContainer/ScrollContainer/ContainerBox" node_paths=PackedStringArray("container_box") instance=ExtResource("5_14o3q")]
|
||||
layout_mode = 2
|
||||
container_box = NodePath("..")
|
||||
|
||||
[node name="ContainerAddButton" type="Button" parent="Panel/VBoxContainer/UIManager/Panel/MarginContainer/ScrollContainer/ContainerBox" node_paths=PackedStringArray("container_box")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Add a new collection"
|
||||
|
|
|
|||
35
src/UI/windows/edit_collection_name_window.gd
Normal file
35
src/UI/windows/edit_collection_name_window.gd
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
class_name EditCollectionNameWindow extends Window
|
||||
|
||||
@export var text_edit: LineEdit
|
||||
|
||||
# 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 cancel() -> void:
|
||||
SignalBus.edit_window_closed.emit()
|
||||
|
||||
|
||||
func save() -> void:
|
||||
SignalBus.edit_window_text_saved.emit(self, text_edit.text)
|
||||
SignalBus.on_window_closed.emit(self)
|
||||
|
||||
|
||||
func on_edit_window_requested(window: Window, text: String) -> void:
|
||||
if not is_instance_of(window, EditCollectionNameWindow):
|
||||
return
|
||||
text_edit.text = text
|
||||
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
cancel()
|
||||
|
||||
func _on_save_button_pressed() -> void:
|
||||
save()
|
||||
1
src/UI/windows/edit_collection_name_window.gd.uid
Normal file
1
src/UI/windows/edit_collection_name_window.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cs8uqq3avmeon
|
||||
78
src/UI/windows/edit_collection_name_window.tscn
Normal file
78
src/UI/windows/edit_collection_name_window.tscn
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://bgqshc2r7sdmx"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bpvgbghct7ayv" path="res://src/assets/icons/x.svg" id="1_4qw31"]
|
||||
[ext_resource type="Script" uid="uid://cs8uqq3avmeon" path="res://src/UI/windows/edit_collection_name_window.gd" id="1_xruei"]
|
||||
[ext_resource type="Texture2D" uid="uid://cbj48abbpldb" path="res://src/assets/icons/device-floppy.svg" id="2_xruei"]
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_i6crh"]
|
||||
device = -1
|
||||
keycode = 4194305
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_06rc3"]
|
||||
events = [SubResource("InputEventKey_i6crh")]
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_lut1q"]
|
||||
device = -1
|
||||
ctrl_pressed = true
|
||||
keycode = 83
|
||||
unicode = 115
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_esnbn"]
|
||||
events = [SubResource("InputEventKey_lut1q")]
|
||||
|
||||
[node name="EditCollectionNameWindow" type="Window" node_paths=PackedStringArray("text_edit")]
|
||||
title = "Edit Collection Name"
|
||||
initial_position = 4
|
||||
size = Vector2i(300, 100)
|
||||
script = ExtResource("1_xruei")
|
||||
text_edit = NodePath("Panel/MarginContainer/VBoxContainer/LineEdit")
|
||||
|
||||
[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 = 40
|
||||
theme_override_constants/margin_top = 40
|
||||
theme_override_constants/margin_right = 40
|
||||
theme_override_constants/margin_bottom = 40
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
fit_content = true
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
|
||||
[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
|
||||
shortcut = SubResource("Shortcut_06rc3")
|
||||
text = "Cancel"
|
||||
icon = ExtResource("1_4qw31")
|
||||
|
||||
[node name="SaveButton" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
shortcut = SubResource("Shortcut_esnbn")
|
||||
text = "Save"
|
||||
icon = ExtResource("2_xruei")
|
||||
|
||||
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/SaveButton" to="." method="_on_save_button_pressed"]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
extends Window
|
||||
class_name Editmenu extends Window
|
||||
|
||||
@export var text_edit: TextEdit
|
||||
|
||||
|
|
@ -16,7 +16,9 @@ func _process(delta: float) -> void:
|
|||
func _on_close_requested() -> void:
|
||||
cancel()
|
||||
|
||||
func on_edit_window_requested(text: String) -> void:
|
||||
func on_edit_window_requested(window: Window, text: String) -> void:
|
||||
if not is_instance_of(window, Editmenu):
|
||||
return
|
||||
text_edit.text = text
|
||||
|
||||
func _on_cancel_button_button_down() -> void:
|
||||
|
|
@ -38,6 +40,7 @@ func cancel() -> void:
|
|||
func save() -> void:
|
||||
SignalBus.edit_window_text_saved.emit(text_edit.text)
|
||||
SignalBus.edit_window_closed.emit()
|
||||
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
cancel()
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
[gd_scene load_steps=8 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"]
|
||||
[ext_resource type="Script" uid="uid://cdkqu7he8lkb6" path="res://src/UI/windows/editmenu.gd" id="1_v1pdc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpvgbghct7ayv" path="res://src/assets/icons/x.svg" id="2_a7lul"]
|
||||
[ext_resource type="Texture2D" uid="uid://cbj48abbpldb" path="res://src/assets/icons/device-floppy.svg" id="3_pi283"]
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_i6crh"]
|
||||
device = -1
|
||||
|
|
@ -25,7 +25,7 @@ title = "Edit Entry"
|
|||
initial_position = 1
|
||||
size = Vector2i(600, 300)
|
||||
exclusive = true
|
||||
script = ExtResource("1_qmobg")
|
||||
script = ExtResource("1_v1pdc")
|
||||
text_edit = NodePath("Panel/MarginContainer/VBoxContainer/TextEdit")
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
|
|
@ -63,13 +63,13 @@ size_flags_horizontal = 4
|
|||
layout_mode = 2
|
||||
shortcut = SubResource("Shortcut_hou23")
|
||||
text = "Cancel"
|
||||
icon = ExtResource("2_lut1q")
|
||||
icon = ExtResource("2_a7lul")
|
||||
|
||||
[node name="SaveButton" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
shortcut = SubResource("Shortcut_i6crh")
|
||||
text = "Save"
|
||||
icon = ExtResource("3_i6crh")
|
||||
icon = ExtResource("3_pi283")
|
||||
|
||||
[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"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue