mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-02-08 14:50:05 +01:00
Implemented editing the names of resources in the DataList widget.
This commit is contained in:
parent
4cc9baf23b
commit
87e4318e06
@ -10,8 +10,12 @@ func get_content() -> Array:
|
|||||||
func set_content(arr : Array) -> void:
|
func set_content(arr : Array) -> void:
|
||||||
zones = arr
|
zones = arr
|
||||||
|
|
||||||
func add_content() -> void:
|
func add_content(item_name : String = "") -> void:
|
||||||
zones.append(Zone.new())
|
var zone : Zone = Zone.new()
|
||||||
|
zone.resource_name = item_name
|
||||||
|
|
||||||
|
zones.append(zone)
|
||||||
|
|
||||||
emit_changed()
|
emit_changed()
|
||||||
|
|
||||||
func setup_property_inspector(inspector) -> void:
|
func setup_property_inspector(inspector) -> void:
|
||||||
|
@ -18,7 +18,7 @@ func get_content() -> Array:
|
|||||||
func set_content(arr : Array) -> void:
|
func set_content(arr : Array) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func add_content() -> void:
|
func add_content(item_name : String = "") -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func setup_property_inspector(inspector) -> void:
|
func setup_property_inspector(inspector) -> void:
|
||||||
|
@ -10,8 +10,9 @@ func get_content() -> Array:
|
|||||||
func set_content(arr : Array) -> void:
|
func set_content(arr : Array) -> void:
|
||||||
continents = arr
|
continents = arr
|
||||||
|
|
||||||
func add_content() -> void:
|
func add_content(item_name : String = "") -> void:
|
||||||
var continent : Continent = Continent.new()
|
var continent : Continent = Continent.new()
|
||||||
|
continent.resource_name = item_name
|
||||||
|
|
||||||
var r : Rect2 = get_rect()
|
var r : Rect2 = get_rect()
|
||||||
r.size.x /= 10.0
|
r.size.x /= 10.0
|
||||||
|
@ -10,8 +10,11 @@ func get_content() -> Array:
|
|||||||
func set_content(arr : Array) -> void:
|
func set_content(arr : Array) -> void:
|
||||||
subzones = arr
|
subzones = arr
|
||||||
|
|
||||||
func add_content() -> void:
|
func add_content(item_name : String = "") -> void:
|
||||||
subzones.append(SubZone.new())
|
var subzone : SubZone = SubZone.new()
|
||||||
|
subzone.resource_name = item_name
|
||||||
|
|
||||||
|
subzones.append(subzone)
|
||||||
emit_changed()
|
emit_changed()
|
||||||
|
|
||||||
func setup_property_inspector(inspector) -> void:
|
func setup_property_inspector(inspector) -> void:
|
||||||
|
@ -1,35 +1,60 @@
|
|||||||
[gd_resource type="Resource" load_steps=7 format=2]
|
[gd_resource type="Resource" load_steps=10 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/world_generator/resources/world_gen_world.gd" type="Script" id=1]
|
[ext_resource path="res://addons/world_generator/resources/world_gen_world.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://addons/world_generator/resources/continent.gd" type="Script" id=2]
|
[ext_resource path="res://addons/world_generator/resources/continent.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=1]
|
[sub_resource type="Resource" id=1]
|
||||||
|
resource_name = "wwww"
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
rect = Rect2( 133, 63, 224, 158 )
|
rect = Rect2( 133, 63, 224, 158 )
|
||||||
locked = false
|
locked = false
|
||||||
zones = [ ]
|
zones = [ ]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=2]
|
[sub_resource type="Resource" id=2]
|
||||||
|
resource_name = "efefef"
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
rect = Rect2( 107, 271, 100, 49 )
|
rect = Rect2( 107, 271, 100, 49 )
|
||||||
locked = false
|
locked = false
|
||||||
zones = [ ]
|
zones = [ ]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=3]
|
[sub_resource type="Resource" id=3]
|
||||||
|
resource_name = "grgrg"
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
rect = Rect2( 498, 185, 100, 100 )
|
rect = Rect2( 498, 185, 100, 100 )
|
||||||
locked = false
|
locked = false
|
||||||
zones = [ ]
|
zones = [ ]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=4]
|
[sub_resource type="Resource" id=4]
|
||||||
|
resource_name = "qwdasd"
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
rect = Rect2( 522, 29, 63, 54 )
|
rect = Rect2( 522, 29, 63, 54 )
|
||||||
locked = false
|
locked = false
|
||||||
zones = [ ]
|
zones = [ ]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=5]
|
||||||
|
resource_name = "qwe"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
rect = Rect2( 473, 331, 100, 100 )
|
||||||
|
locked = false
|
||||||
|
zones = [ ]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=6]
|
||||||
|
resource_name = "asdasdq"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
rect = Rect2( 304, 280, 100, 100 )
|
||||||
|
locked = false
|
||||||
|
zones = [ ]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=7]
|
||||||
|
resource_name = "343"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
rect = Rect2( 14, 134, 100, 100 )
|
||||||
|
locked = false
|
||||||
|
zones = [ ]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
resource_name = "asdasdss"
|
resource_name = "asdasdss"
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
rect = Rect2( 0, 0, 1000, 1000 )
|
rect = Rect2( 0, 0, 1000, 1000 )
|
||||||
locked = false
|
locked = false
|
||||||
continents = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ]
|
continents = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ]
|
||||||
|
@ -3,11 +3,16 @@ extends Tree
|
|||||||
|
|
||||||
var edited_resource : WorldGenBaseResource = null
|
var edited_resource : WorldGenBaseResource = null
|
||||||
|
|
||||||
func add_item() -> void:
|
var name_edited_resource : WorldGenBaseResource = null
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
connect("item_activated", self, "on_item_activated")
|
||||||
|
|
||||||
|
func add_item(item_name : String = "") -> void:
|
||||||
if !edited_resource:
|
if !edited_resource:
|
||||||
return
|
return
|
||||||
|
|
||||||
edited_resource.add_content()
|
edited_resource.add_content(item_name)
|
||||||
|
|
||||||
func refresh() -> void:
|
func refresh() -> void:
|
||||||
clear()
|
clear()
|
||||||
@ -29,6 +34,7 @@ func refresh() -> void:
|
|||||||
var item : TreeItem = create_item(root)
|
var item : TreeItem = create_item(root)
|
||||||
|
|
||||||
item.set_text(0, n)
|
item.set_text(0, n)
|
||||||
|
item.set_meta("res", d)
|
||||||
|
|
||||||
func set_edited_resource(res : WorldGenBaseResource)-> void:
|
func set_edited_resource(res : WorldGenBaseResource)-> void:
|
||||||
if edited_resource:
|
if edited_resource:
|
||||||
@ -41,5 +47,31 @@ func set_edited_resource(res : WorldGenBaseResource)-> void:
|
|||||||
|
|
||||||
refresh()
|
refresh()
|
||||||
|
|
||||||
|
func add_button_pressed() -> void:
|
||||||
|
$NameDialog/TextEdit.text = ""
|
||||||
|
$NameDialog.popup_centered()
|
||||||
|
|
||||||
|
func name_dialog_ok_pressed() -> void:
|
||||||
|
if !name_edited_resource:
|
||||||
|
add_item($NameDialog/TextEdit.text)
|
||||||
|
else:
|
||||||
|
name_edited_resource.resource_name = $NameDialog/TextEdit.text
|
||||||
|
name_edited_resource = null
|
||||||
|
|
||||||
|
|
||||||
func on_resource_changed() -> void:
|
func on_resource_changed() -> void:
|
||||||
refresh()
|
refresh()
|
||||||
|
|
||||||
|
func on_item_activated() -> void:
|
||||||
|
var item : TreeItem = get_selected()
|
||||||
|
|
||||||
|
if !item:
|
||||||
|
return
|
||||||
|
|
||||||
|
name_edited_resource = item.get_meta("res")
|
||||||
|
|
||||||
|
if !name_edited_resource:
|
||||||
|
return
|
||||||
|
|
||||||
|
$NameDialog/TextEdit.text = name_edited_resource.resource_name
|
||||||
|
$NameDialog.popup_centered()
|
||||||
|
@ -12,3 +12,19 @@ script = ExtResource( 1 )
|
|||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="NameDialog" type="ConfirmationDialog" parent="."]
|
||||||
|
margin_right = 200.0
|
||||||
|
margin_bottom = 70.0
|
||||||
|
window_title = "Name"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="TextEdit" type="TextEdit" parent="NameDialog"]
|
||||||
|
margin_left = 8.0
|
||||||
|
margin_top = 8.0
|
||||||
|
margin_right = 192.0
|
||||||
|
margin_bottom = 34.0
|
||||||
|
|
||||||
|
[connection signal="confirmed" from="NameDialog" to="." method="name_dialog_ok_pressed"]
|
||||||
|
@ -173,4 +173,4 @@ margin_right = 96.0
|
|||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Delete"
|
text = "Delete"
|
||||||
|
|
||||||
[connection signal="pressed" from="TabContainer/World/VBoxContainer/HBoxContainer/AddButton" to="TabContainer/World/VBoxContainer/DataList" method="add_item"]
|
[connection signal="pressed" from="TabContainer/World/VBoxContainer/HBoxContainer/AddButton" to="TabContainer/World/VBoxContainer/DataList" method="add_button_pressed"]
|
||||||
|
Loading…
Reference in New Issue
Block a user