mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-08 01:49:35 +01:00
Implemented delete and duplicate buttons in world. Also made sure that the inspectors update properly after the edited resources change.
This commit is contained in:
parent
829b01b72f
commit
cc6669bb12
@ -10,7 +10,7 @@ func get_content() -> Array:
|
||||
func set_content(arr : Array) -> void:
|
||||
zones = arr
|
||||
|
||||
func add_content(item_name : String = "") -> void:
|
||||
func create_content(item_name : String = "") -> void:
|
||||
var zone : Zone = Zone.new()
|
||||
zone.resource_name = item_name
|
||||
|
||||
@ -21,9 +21,18 @@ func add_content(item_name : String = "") -> void:
|
||||
|
||||
zone.set_rect(r)
|
||||
|
||||
zones.append(zone)
|
||||
add_content(zone)
|
||||
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
zones.append(entry)
|
||||
emit_changed()
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
for i in range(zones.size()):
|
||||
if zones[i] == entry:
|
||||
zones.remove(i)
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
@ -18,9 +18,20 @@ func get_content() -> Array:
|
||||
func set_content(arr : Array) -> void:
|
||||
pass
|
||||
|
||||
func add_content(item_name : String = "") -> void:
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
pass
|
||||
|
||||
func create_content(item_name : String = "") -> void:
|
||||
pass
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
pass
|
||||
|
||||
func duplicate_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
var de : WorldGenBaseResource = entry.duplicate(true)
|
||||
de.resource_name += " (Duplicate)"
|
||||
add_content(de)
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
|
@ -10,7 +10,7 @@ func get_content() -> Array:
|
||||
func set_content(arr : Array) -> void:
|
||||
continents = arr
|
||||
|
||||
func add_content(item_name : String = "") -> void:
|
||||
func create_content(item_name : String = "") -> void:
|
||||
var continent : Continent = Continent.new()
|
||||
continent.resource_name = item_name
|
||||
|
||||
@ -21,9 +21,19 @@ func add_content(item_name : String = "") -> void:
|
||||
|
||||
continent.set_rect(r)
|
||||
|
||||
continents.append(continent)
|
||||
add_content(continent)
|
||||
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
continents.append(entry)
|
||||
emit_changed()
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
for i in range(continents.size()):
|
||||
if continents[i] == entry:
|
||||
continents.remove(i)
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
|
@ -10,7 +10,7 @@ func get_content() -> Array:
|
||||
func set_content(arr : Array) -> void:
|
||||
subzones = arr
|
||||
|
||||
func add_content(item_name : String = "") -> void:
|
||||
func create_content(item_name : String = "") -> void:
|
||||
var subzone : SubZone = SubZone.new()
|
||||
subzone.resource_name = item_name
|
||||
|
||||
@ -21,8 +21,18 @@ func add_content(item_name : String = "") -> void:
|
||||
|
||||
subzone.set_rect(r)
|
||||
|
||||
subzones.append(subzone)
|
||||
add_content(subzone)
|
||||
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
subzones.append(entry)
|
||||
emit_changed()
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
for i in range(subzones.size()):
|
||||
if subzones[i] == entry:
|
||||
subzones.remove(i)
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" load_steps=20 format=2]
|
||||
[gd_resource type="Resource" load_steps=25 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/continent.gd" type="Script" id=2]
|
||||
@ -14,27 +14,27 @@ locked = false
|
||||
[sub_resource type="Resource" id=15]
|
||||
resource_name = "we"
|
||||
script = ExtResource( 4 )
|
||||
rect = Rect2( 3, -1, 54.14, 32.78 )
|
||||
rect = Rect2( 7, 9, 54.14, 32.78 )
|
||||
locked = false
|
||||
|
||||
[sub_resource type="Resource" id=8]
|
||||
resource_name = "asdasr"
|
||||
script = ExtResource( 3 )
|
||||
rect = Rect2( 25, 19, 191.4, 127.8 )
|
||||
rect = Rect2( 35, 21, 191.4, 127.8 )
|
||||
locked = false
|
||||
subzones = [ SubResource( 14 ), SubResource( 15 ) ]
|
||||
|
||||
[sub_resource type="Resource" id=13]
|
||||
resource_name = "qqq"
|
||||
script = ExtResource( 3 )
|
||||
rect = Rect2( 14, 9, 200.4, 61.8 )
|
||||
rect = Rect2( 8, 13, 200.4, 61.8 )
|
||||
locked = false
|
||||
subzones = [ ]
|
||||
|
||||
[sub_resource type="Resource" id=1]
|
||||
resource_name = "wwww"
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 161, 40, 241, 158 )
|
||||
rect = Rect2( 163, 35, 241, 158 )
|
||||
locked = false
|
||||
zones = [ SubResource( 8 ), SubResource( 13 ) ]
|
||||
|
||||
@ -87,30 +87,167 @@ rect = Rect2( 473, 331, 100, 100 )
|
||||
locked = false
|
||||
zones = [ SubResource( 11 ) ]
|
||||
|
||||
[sub_resource type="Resource" id=6]
|
||||
resource_name = "asdasdq"
|
||||
[sub_resource type="GDScript" id=16]
|
||||
script/source = "tool
|
||||
extends \"res://addons/world_generator/resources/world_gen_base_resource.gd\"
|
||||
class_name Continent
|
||||
|
||||
export(Array) var zones : Array
|
||||
|
||||
func get_content() -> Array:
|
||||
return zones
|
||||
|
||||
func set_content(arr : Array) -> void:
|
||||
zones = arr
|
||||
|
||||
func create_content(item_name : String = \"\") -> void:
|
||||
var zone : Zone = Zone.new()
|
||||
zone.resource_name = item_name
|
||||
|
||||
var r : Rect2 = get_rect()
|
||||
r.position = Vector2()
|
||||
r.size.x /= 10.0
|
||||
r.size.y /= 10.0
|
||||
|
||||
zone.set_rect(r)
|
||||
|
||||
add_content(zone)
|
||||
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
zones.append(entry)
|
||||
emit_changed()
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
for i in range(zones.size()):
|
||||
if zones[i] == entry:
|
||||
zones.remove(i)
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
"
|
||||
|
||||
[sub_resource type="Resource" id=17]
|
||||
resource_name = "qwet"
|
||||
script = SubResource( 16 )
|
||||
rect = Rect2( 473, 331, 100, 100 )
|
||||
locked = false
|
||||
zones = [ SubResource( 11 ) ]
|
||||
|
||||
[sub_resource type="GDScript" id=18]
|
||||
script/source = "tool
|
||||
extends \"res://addons/world_generator/resources/world_gen_base_resource.gd\"
|
||||
class_name Continent
|
||||
|
||||
export(Array) var zones : Array
|
||||
|
||||
func get_content() -> Array:
|
||||
return zones
|
||||
|
||||
func set_content(arr : Array) -> void:
|
||||
zones = arr
|
||||
|
||||
func create_content(item_name : String = \"\") -> void:
|
||||
var zone : Zone = Zone.new()
|
||||
zone.resource_name = item_name
|
||||
|
||||
var r : Rect2 = get_rect()
|
||||
r.position = Vector2()
|
||||
r.size.x /= 10.0
|
||||
r.size.y /= 10.0
|
||||
|
||||
zone.set_rect(r)
|
||||
|
||||
add_content(zone)
|
||||
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
zones.append(entry)
|
||||
emit_changed()
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
for i in range(zones.size()):
|
||||
if zones[i] == entry:
|
||||
zones.remove(i)
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
"
|
||||
|
||||
[sub_resource type="Resource" id=19]
|
||||
resource_name = "qwesa"
|
||||
script = SubResource( 18 )
|
||||
rect = Rect2( 613, 346, 100, 100 )
|
||||
locked = false
|
||||
zones = [ SubResource( 11 ) ]
|
||||
|
||||
[sub_resource type="Resource" id=20]
|
||||
resource_name = "ggg"
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 304, 280, 100, 100 )
|
||||
rect = Rect2( 26, 51, 100, 100 )
|
||||
locked = false
|
||||
zones = [ ]
|
||||
|
||||
[sub_resource type="Resource" id=12]
|
||||
resource_name = "e"
|
||||
script = ExtResource( 3 )
|
||||
rect = Rect2( 24, 144, 0, 0 )
|
||||
locked = false
|
||||
subzones = [ ]
|
||||
[sub_resource type="GDScript" id=21]
|
||||
script/source = "tool
|
||||
extends \"res://addons/world_generator/resources/world_gen_base_resource.gd\"
|
||||
class_name Continent
|
||||
|
||||
[sub_resource type="Resource" id=7]
|
||||
resource_name = "343"
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 26, 21, 154, 114 )
|
||||
export(Array) var zones : Array
|
||||
|
||||
func get_content() -> Array:
|
||||
return zones
|
||||
|
||||
func set_content(arr : Array) -> void:
|
||||
zones = arr
|
||||
|
||||
func create_content(item_name : String = \"\") -> void:
|
||||
var zone : Zone = Zone.new()
|
||||
zone.resource_name = item_name
|
||||
|
||||
var r : Rect2 = get_rect()
|
||||
r.position = Vector2()
|
||||
r.size.x /= 10.0
|
||||
r.size.y /= 10.0
|
||||
|
||||
zone.set_rect(r)
|
||||
|
||||
add_content(zone)
|
||||
|
||||
func add_content(entry : WorldGenBaseResource) -> void:
|
||||
zones.append(entry)
|
||||
emit_changed()
|
||||
|
||||
func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
for i in range(zones.size()):
|
||||
if zones[i] == entry:
|
||||
zones.remove(i)
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
"
|
||||
|
||||
[sub_resource type="Resource" id=22]
|
||||
resource_name = "ggg (Duplicate)"
|
||||
script = SubResource( 21 )
|
||||
rect = Rect2( 33, 181, 100, 100 )
|
||||
locked = false
|
||||
zones = [ SubResource( 12 ) ]
|
||||
zones = [ ]
|
||||
|
||||
[sub_resource type="Resource" id=23]
|
||||
resource_name = "eeqqq"
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 256, 365, 100, 100 )
|
||||
locked = false
|
||||
zones = [ ]
|
||||
|
||||
[resource]
|
||||
resource_name = "asdasdss"
|
||||
resource_name = "asdasdsse"
|
||||
script = ExtResource( 1 )
|
||||
rect = Rect2( 0, 0, 1000, 1000 )
|
||||
locked = false
|
||||
continents = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ]
|
||||
continents = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 17 ), SubResource( 19 ), SubResource( 20 ), SubResource( 22 ), SubResource( 23 ) ]
|
||||
|
@ -12,7 +12,7 @@ func add_item(item_name : String = "") -> void:
|
||||
if !edited_resource:
|
||||
return
|
||||
|
||||
edited_resource.add_content(item_name)
|
||||
edited_resource.create_content(item_name)
|
||||
|
||||
func refresh() -> void:
|
||||
clear()
|
||||
@ -58,9 +58,34 @@ func name_dialog_ok_pressed() -> void:
|
||||
name_edited_resource.resource_name = $NameDialog/TextEdit.text
|
||||
name_edited_resource = null
|
||||
|
||||
func delete_button_pressed() -> void:
|
||||
var item : TreeItem = get_selected()
|
||||
|
||||
if !item:
|
||||
return
|
||||
|
||||
var item_resource = item.get_meta("res")
|
||||
|
||||
if !item_resource:
|
||||
return
|
||||
|
||||
edited_resource.remove_content_entry(item_resource)
|
||||
|
||||
func duplicate_button_pressed() -> void:
|
||||
var item : TreeItem = get_selected()
|
||||
|
||||
if !item:
|
||||
return
|
||||
|
||||
var item_resource = item.get_meta("res")
|
||||
|
||||
if !item_resource:
|
||||
return
|
||||
|
||||
edited_resource.duplicate_content_entry(item_resource)
|
||||
|
||||
func on_resource_changed() -> void:
|
||||
refresh()
|
||||
call_deferred("refresh")
|
||||
|
||||
func on_item_activated() -> void:
|
||||
var item : TreeItem = get_selected()
|
||||
|
@ -74,15 +74,15 @@ func clear_rects():
|
||||
remove_child(c)
|
||||
|
||||
func set_edited_resource(res : WorldGenBaseResource):
|
||||
# if edited_resource:
|
||||
# edited_resource.disconnect("changed", self, "on_edited_resource_changed")
|
||||
if edited_resource:
|
||||
edited_resource.disconnect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
edited_resource = res
|
||||
|
||||
refresh()
|
||||
|
||||
# if edited_resource:
|
||||
# edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
if edited_resource:
|
||||
edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
#func on_edited_resource_changed() -> void:
|
||||
# pass
|
||||
func on_edited_resource_changed() -> void:
|
||||
call_deferred("refresh")
|
||||
|
@ -325,8 +325,6 @@ func refresh() -> void:
|
||||
if _edited_resource:
|
||||
_edited_resource.setup_property_inspector(self)
|
||||
|
||||
if !_edited_resource.is_connected("changed", self, "on_edited_resource_changed"):
|
||||
_edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
func edit_resource(wgw) -> void:
|
||||
if _edited_resource:
|
||||
@ -334,7 +332,11 @@ func edit_resource(wgw) -> void:
|
||||
|
||||
_edited_resource = wgw
|
||||
|
||||
#if !_edited_resource.is_connected("changed", self, "on_edited_resource_changed"):
|
||||
if _edited_resource:
|
||||
_edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
refresh()
|
||||
|
||||
func on_edited_resource_changed() -> void:
|
||||
refresh()
|
||||
call_deferred("refresh")
|
||||
|
@ -78,3 +78,5 @@ margin_right = 173.0
|
||||
margin_bottom = 564.0
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/AddButton" to="VBoxContainer/DataList" method="add_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/DeleteButton" to="VBoxContainer/DataList" method="delete_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Duplicate" to="VBoxContainer/DataList" method="duplicate_button_pressed"]
|
||||
|
Loading…
Reference in New Issue
Block a user