Now the resource names are directly editable using the DataList tree in the world generator addon's ui.

This commit is contained in:
Relintai 2022-08-05 21:52:51 +02:00
parent ab2e4efaa6
commit 4f2a13f1d4
2 changed files with 27 additions and 1 deletions

View File

@ -12,7 +12,10 @@ var _plugin : EditorPlugin = null
var _undo_redo : UndoRedo = null
func _init():
connect("item_activated", self, "on_item_activated")
#connect("item_activated", self, "on_item_activated")
if !is_connected("item_edited", self, "on_item_edited"):
connect("item_edited", self, "on_item_edited")
func set_plugin(plugin : EditorPlugin) -> void:
_plugin = plugin
@ -100,6 +103,8 @@ func refresh() -> void:
item.set_text(0, n)
item.set_meta("res", d)
item.add_button(0, get_icon("Edit", "EditorIcons"), -1, false, "Edit")
item.set_editable(0, true)
func set_edited_resource(res : WorldGenBaseResource)-> void:
if edited_resource:
@ -187,3 +192,22 @@ func on_item_activated() -> void:
$NameEditDialog/VBoxContainer/LineEdit.text = name_edited_resource.resource_name
$NameEditDialog.popup_centered()
func on_item_edited() -> void:
var item : TreeItem = get_edited()
if !item:
return
name_edited_resource = item.get_meta("res")
if !name_edited_resource:
return
name_edited_resource.resource_name = item.get_text(0)
name_edited_resource.emit_changed()
name_edited_resource = null
on_resource_changed()

View File

@ -7,6 +7,8 @@ anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
allow_reselect = true
hide_folding = true
hide_root = true
script = ExtResource( 1 )