add full functionality to add and edit groups in group view
This commit is contained in:
parent
f0ce658518
commit
66f0585b3a
@ -61,6 +61,10 @@ func set_text(text: String) -> void:
|
||||
header_text_label.text = text
|
||||
|
||||
|
||||
func get_text() -> String:
|
||||
return header_text_label.text
|
||||
|
||||
|
||||
func set_description(text: String) -> void:
|
||||
if text == "":
|
||||
description_label.visible = false
|
||||
@ -84,6 +88,8 @@ func set_children_visible(p_visible: bool) -> void:
|
||||
add_install_button_container.visible = p_visible
|
||||
inner_separator.visible = p_visible
|
||||
|
||||
description_label.visible = p_visible && !description_label.text.is_empty()
|
||||
|
||||
|
||||
func add_custom(control: Control) -> void:
|
||||
header_custom_control_container.add_child(control)
|
||||
|
@ -33,3 +33,10 @@ func clear() -> void:
|
||||
func(c: OverrideEditorSettingsMenuItem):
|
||||
c.queue_free()
|
||||
)
|
||||
|
||||
|
||||
func fill_from_dictionary(overrides: Dictionary) -> void:
|
||||
for override in overrides:
|
||||
var item: OverrideEditorSettingsMenuItem = ITEM_SCENE.instantiate()
|
||||
add_item(item)
|
||||
item.fill(override, overrides[override])
|
||||
|
@ -19,6 +19,11 @@ func _ready() -> void:
|
||||
|
||||
func get_property() -> Dictionary:
|
||||
var prop_name = property_name_line_edit.text
|
||||
var value = str_to_var(prop_name)
|
||||
var value = str_to_var(property_value_line_edit.text)
|
||||
|
||||
return {prop_name: value}
|
||||
|
||||
|
||||
func fill(key: String, value: Variant) -> void:
|
||||
property_name_line_edit.text = key
|
||||
property_value_line_edit.text = var_to_str(value)
|
||||
|
@ -23,3 +23,18 @@ func get_group_metadata() -> GroupMetadata:
|
||||
group_metadata.settings_overrides = override_editor_settings_menu.get_overrides()
|
||||
|
||||
return group_metadata
|
||||
|
||||
|
||||
func fill_from_group_metadata(p_name: String) -> void:
|
||||
name_line_edit.text = p_name
|
||||
icon_path_line_edit.text = group_metadata.icon_path
|
||||
description_text_edit.text = group_metadata.description
|
||||
override_editor_settings_menu.fill_from_dictionary(group_metadata.settings_overrides)
|
||||
|
||||
|
||||
func clear_ok_button_connections() -> void:
|
||||
for connection in get_signal_connection_list("confirmed"):
|
||||
var callable := connection["callable"] as Callable
|
||||
var _signal := connection["signal"] as Signal
|
||||
|
||||
_signal.disconnect(callable)
|
||||
|
@ -6,14 +6,14 @@
|
||||
[node name="GroupEditDialog" type="ConfirmationDialog"]
|
||||
initial_position = 1
|
||||
title = "Edit Group"
|
||||
size = Vector2i(678, 411)
|
||||
size = Vector2i(678, 419)
|
||||
script = ExtResource("1_ic3yh")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 670.0
|
||||
offset_bottom = 362.0
|
||||
offset_left = 12.0
|
||||
offset_top = 12.0
|
||||
offset_right = 666.0
|
||||
offset_bottom = 366.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
@ -14,14 +14,16 @@ func _ready() -> void:
|
||||
|
||||
new_group_button.pressed.connect(add_new_group)
|
||||
|
||||
group_edit_dialog.canceled.connect(group_edit_dialog.clear_ok_button_connections)
|
||||
|
||||
func add_new_group():
|
||||
|
||||
func add_new_group() -> void:
|
||||
group_edit_dialog.clear()
|
||||
group_edit_dialog.ok_button_text = "Create"
|
||||
|
||||
group_edit_dialog.confirmed.connect(
|
||||
func():
|
||||
var gm := group_edit_dialog.group_metadata
|
||||
var gm := group_edit_dialog.get_group_metadata()
|
||||
|
||||
# TODO: hack, redo later
|
||||
var group_name := group_edit_dialog.name_line_edit.text
|
||||
@ -30,6 +32,24 @@ func add_new_group():
|
||||
group_menus_container.add_child(group_menu)
|
||||
group_menu.setup_from_metadata(group_name, gm)
|
||||
|
||||
)
|
||||
group_menu.edit_group_button_pressed.connect(edit_group.bind(group_menu))
|
||||
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
group_edit_dialog.show()
|
||||
|
||||
|
||||
func edit_group(group_menu: GroupMenu) -> void:
|
||||
group_edit_dialog.clear()
|
||||
group_edit_dialog.ok_button_text = "OK"
|
||||
|
||||
var group_name := group_menu.get_text()
|
||||
group_edit_dialog.group_metadata = group_menu.group_metadata
|
||||
group_edit_dialog.fill_from_group_metadata(group_name)
|
||||
|
||||
group_edit_dialog.confirmed.connect(
|
||||
func():
|
||||
group_menu.setup_from_metadata(group_name, group_edit_dialog.get_group_metadata())
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
group_edit_dialog.show()
|
||||
|
Loading…
Reference in New Issue
Block a user