fix: renaming a collection only renames selected one
This commit is contained in:
parent
15b56ef048
commit
cf7669fadc
9 changed files with 51 additions and 30 deletions
|
|
@ -1,15 +1,16 @@
|
|||
extends Node
|
||||
|
||||
signal on_window_closed(window: Window)
|
||||
signal on_new_container_requested
|
||||
|
||||
signal settings_window_closed
|
||||
signal edit_window_closed
|
||||
signal edit_window_requested(window: Window, text: String)
|
||||
signal edit_window_text_saved(window: Window, text: String)
|
||||
signal edit_window_requested(window: Window, text: String, edit_id: int)
|
||||
signal edit_window_text_saved(window: Window, text: String, edit_id: int)
|
||||
|
||||
signal main_panel_color_changed(color: Color)
|
||||
signal main_window_color_changed(color: Color)
|
||||
signal side_panel_color_changed(color: Color)
|
||||
|
||||
signal on_panel_created()
|
||||
signal on_panel_requested(index: int)
|
||||
signal on_panel_requested(index: int)
|
||||
|
|
|
|||
|
|
@ -10,19 +10,17 @@ var instantiated_menu
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
SignalBus.edit_window_text_saved.connect(_on_edit_window_text_saved)
|
||||
SignalBus.on_window_closed.connect(_on_window_closed)
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
var text: String = "Collection %d" % container_box.container_id
|
||||
button_index = container_box.container_id
|
||||
var text: String = "Collection %d" % button_index
|
||||
button.text = text
|
||||
|
||||
|
||||
## Request to change to a panel with the ID - 1 of the button. [br]
|
||||
## Buttons are 1-indexed, while [member UIManager.panel_array] is 0-index
|
||||
func _on_button_pressed() -> void:
|
||||
SignalBus.on_panel_requested.emit(button_index-1)
|
||||
SignalBus.on_panel_requested.emit(button_index)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
|
|
@ -43,12 +41,8 @@ func _on_popup_menu_index_pressed(index: int) -> void:
|
|||
if index == 0:
|
||||
instantiated_menu = edit_collection_name_window.instantiate()
|
||||
add_child(instantiated_menu)
|
||||
SignalBus.edit_window_requested.emit(instantiated_menu, button.text)
|
||||
SignalBus.edit_window_requested.emit(instantiated_menu, button.text, button_index)
|
||||
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ func _ready() -> void:
|
|||
pass
|
||||
|
||||
func _on_pressed() -> void:
|
||||
container_box.container_id = container_box.container_id +1
|
||||
var new_button: ContainerSelectionButton = container_button_scene.instantiate()
|
||||
new_button.container_box = container_box
|
||||
container_box.add_child(new_button)
|
||||
container_box.move_child(new_button, -2)
|
||||
SignalBus.on_new_container_requested.emit()
|
||||
SignalBus.on_panel_created.emit()
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ class_name DoneBox extends HBoxContainer
|
|||
@export var entry_text_box: RichTextLabel
|
||||
|
||||
var instantiated_menu
|
||||
|
||||
var id: int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
@ -32,9 +32,10 @@ func _on_index_pressed(index:int) -> void:
|
|||
queue_free()
|
||||
|
||||
|
||||
func on_edit_window_text_save(window: Window, text: String) -> void:
|
||||
func on_edit_window_text_save(window: Window, text: String, edit_id: int) -> void:
|
||||
if not is_instance_of(window, Editmenu):
|
||||
return
|
||||
id = edit_id
|
||||
entry_text_box.text = text
|
||||
|
||||
func on_edit_window_closed() -> void:
|
||||
|
|
|
|||
|
|
@ -134,12 +134,14 @@ horizontal_alignment = 1
|
|||
vertical_alignment = 1
|
||||
|
||||
[node name="UIManager" type="HBoxContainer" parent="Panel/VBoxContainer" node_paths=PackedStringArray("current_active_panel", "container_collection_box")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
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")
|
||||
container_collection_box = NodePath("Panel/MarginContainer/ScrollContainer/ContainerBox")
|
||||
container_button_scene = ExtResource("5_14o3q")
|
||||
|
||||
[node name="Panel" type="Panel" parent="Panel/VBoxContainer/UIManager"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class_name MainPanel extends ScrollContainer
|
|||
@export var style_box: StyleBoxFlat
|
||||
@export var panel_main_color: Color
|
||||
|
||||
var id: int = 1
|
||||
var id: int = 0
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,27 @@
|
|||
class_name UIManager extends HBoxContainer
|
||||
|
||||
@export_category("Main Panel")
|
||||
@export var current_active_panel: MainPanel
|
||||
@export var panel_array: Array[MainPanel] = []
|
||||
@export var container_collection_box: ContainerBox
|
||||
|
||||
@export var main_panel_scene: PackedScene
|
||||
|
||||
@export_category("Container Selection")
|
||||
@export var container_collection_box: ContainerBox
|
||||
@export var container_selection_buttons: Array[ContainerSelectionButton] = []
|
||||
@export var container_button_scene: PackedScene
|
||||
|
||||
var instantiated_window: Window
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
current_active_panel.id = 1
|
||||
current_active_panel.id = 0
|
||||
panel_array.append(current_active_panel)
|
||||
|
||||
SignalBus.on_panel_created.connect(_on_panel_created)
|
||||
SignalBus.on_panel_requested.connect(_on_panel_requested)
|
||||
SignalBus.on_new_container_requested.connect(_on_new_container_requested)
|
||||
|
||||
SignalBus.edit_window_text_saved.connect(_on_edit_window_text_saved)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
@ -22,7 +31,7 @@ func _process(delta: float) -> void:
|
|||
|
||||
func _on_panel_created() -> void:
|
||||
var new_panel: MainPanel = main_panel_scene.instantiate()
|
||||
new_panel.id = panel_array.size() + 1
|
||||
new_panel.id = panel_array.size()
|
||||
panel_array.append(new_panel)
|
||||
|
||||
func _on_panel_requested(index: int) -> void:
|
||||
|
|
@ -38,3 +47,16 @@ func _on_panel_requested(index: int) -> void:
|
|||
current_active_panel.show()
|
||||
|
||||
|
||||
func _on_new_container_requested() -> void:
|
||||
var new_button: ContainerSelectionButton = container_button_scene.instantiate()
|
||||
new_button.container_box = container_collection_box
|
||||
container_selection_buttons.append(new_button)
|
||||
new_button.button_index = container_selection_buttons.find(new_button)
|
||||
container_collection_box.add_child(new_button)
|
||||
container_collection_box.move_child(new_button, -2)
|
||||
|
||||
func _on_edit_window_text_saved(window: Window, text: String, edit_id: int) -> void:
|
||||
if not is_instance_of(window, EditCollectionNameWindow):
|
||||
return
|
||||
container_selection_buttons[edit_id].button.text = text
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ class_name EditCollectionNameWindow extends Window
|
|||
|
||||
@export var text_edit: LineEdit
|
||||
|
||||
var id: int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
SignalBus.edit_window_requested.connect(on_edit_window_requested)
|
||||
|
|
@ -18,14 +20,15 @@ func cancel() -> void:
|
|||
|
||||
|
||||
func save() -> void:
|
||||
SignalBus.edit_window_text_saved.emit(self, text_edit.text)
|
||||
SignalBus.edit_window_text_saved.emit(self, text_edit.text, id)
|
||||
SignalBus.on_window_closed.emit(self)
|
||||
|
||||
|
||||
func on_edit_window_requested(window: Window, text: String) -> void:
|
||||
func on_edit_window_requested(window: Window, text: String, edit_id: int) -> void:
|
||||
if not is_instance_of(window, EditCollectionNameWindow):
|
||||
return
|
||||
text_edit.text = text
|
||||
id = edit_id
|
||||
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ class_name Editmenu extends Window
|
|||
|
||||
@export var text_edit: TextEdit
|
||||
|
||||
var id: int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
@ -16,9 +17,10 @@ func _process(delta: float) -> void:
|
|||
func _on_close_requested() -> void:
|
||||
cancel()
|
||||
|
||||
func on_edit_window_requested(window: Window, text: String) -> void:
|
||||
func on_edit_window_requested(window: Window, text: String, edit_id: int) -> void:
|
||||
if not is_instance_of(window, Editmenu):
|
||||
return
|
||||
id = edit_id
|
||||
text_edit.text = text
|
||||
|
||||
func _on_cancel_button_button_down() -> void:
|
||||
|
|
@ -38,7 +40,7 @@ func cancel() -> void:
|
|||
|
||||
|
||||
func save() -> void:
|
||||
SignalBus.edit_window_text_saved.emit(text_edit.text)
|
||||
SignalBus.edit_window_text_saved.emit(self, text_edit.text, id)
|
||||
SignalBus.edit_window_closed.emit()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue