- Use EditorInspectors instead of custom properties.

- Make the properties a bit smaller by default in the world view.
- Now only the properties will grow on the right side in the Continent, SubZone, and Zone editors.
- Update world generator tab values when they become visible.
- The addon now needs engine version at least 4cc096a002 .
This commit is contained in:
Relintai 2023-10-16 13:26:41 +02:00
parent a9344fb743
commit e1135e8b84
18 changed files with 67 additions and 717 deletions

View File

@ -33,6 +33,3 @@ func remove_content_entry(entry : WorldGenBaseResource) -> void:
zones.remove(i)
emit_changed()
return
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)

View File

@ -2,6 +2,3 @@ tool
extends "res://addons/world_generator/resources/world_gen_base_resource.gd"
class_name SubZoneProp
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)

View File

@ -34,5 +34,3 @@ func remove_content_entry(entry : WorldGenBaseResource) -> void:
emit_changed()
return
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)

View File

@ -209,11 +209,3 @@ func editor_draw_additional_background(control : Control) -> void:
func _editor_draw_additional_background(control : Control) -> void:
pass
func setup_property_inspector(inspector) -> void:
inspector.add_slot_line_edit("get_name", "set_name", "Name")
inspector.add_slot_rect2("get_rect", "set_rect", "Rect", 1)
inspector.add_slot_vector2i("get_min_size", "set_min_size", "Min Size", 1)
inspector.add_slot_vector2i("get_max_size", "set_max_size", "Max Size", 1)
inspector.add_slot_bool("get_locked", "set_locked", "Locked")

View File

@ -34,9 +34,6 @@ func remove_content_entry(entry : WorldGenBaseResource) -> void:
emit_changed()
return
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)
func generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())

View File

@ -33,6 +33,3 @@ func remove_content_entry(entry : WorldGenBaseResource) -> void:
subzones.remove(i)
emit_changed()
return
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)

View File

@ -1,540 +1,30 @@
tool
extends ScrollContainer
var EditorResourceWidget : PackedScene = preload("res://addons/world_generator/widgets/EditorResourceWidget.tscn")
extends Container
var _edited_resource : WorldGenBaseResource = null
var properties : Array = Array()
var _ignore_changed_evend : bool = false
var _refresh_queued : bool = false
var _plugin : EditorPlugin = null
var _undo_redo : UndoRedo = null
var _inspector : EditorInspector = null
func set_plugin(plugin : EditorPlugin) -> void:
_plugin = plugin
_undo_redo = _plugin.get_undo_redo()
func add_h_separator() -> int:
var hsep : HSeparator = HSeparator.new()
var content_node = $MainContainer/Content
content_node.add_child(hsep)
var slot_idx : int = content_node.get_child_count() - 1
return slot_idx
func add_slot_color(getter : String, setter : String) -> int:
var cp : ColorPickerButton = ColorPickerButton.new()
var slot_idx : int = add_slot(getter, setter, cp)
cp.color = _edited_resource.call(getter)
cp.connect("color_changed", _edited_resource, setter)
return slot_idx
func add_slot_label(getter : String, setter : String, slot_name : String) -> int:
var l : Label = Label.new()
l.text = slot_name
return add_slot(getter, setter, l)
func add_slot_resource(getter : String, setter : String, slot_name : String, resource_type : String = "Resource") -> int:
var bc : HBoxContainer = HBoxContainer.new()
bc.set_h_size_flags(SIZE_EXPAND_FILL)
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var r : Control = EditorResourceWidget.instance()
r.set_plugin(_plugin)
r.set_resource_type(resource_type)
r.set_resource(_edited_resource.call(getter))
r.set_h_size_flags(SIZE_EXPAND_FILL)
bc.add_child(r)
var slot_idx : int = add_slot(getter, setter, bc)
r.connect("on_resource_changed", self, "on_widget_resource_changed", [ slot_idx ])
return slot_idx
func add_slot_line_edit(getter : String, setter : String, slot_name : String, placeholder : String = "") -> int:
var bc : HBoxContainer = HBoxContainer.new()
bc.set_h_size_flags(SIZE_EXPAND_FILL)
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var le : LineEdit = LineEdit.new()
le.placeholder_text = placeholder
le.set_h_size_flags(SIZE_EXPAND_FILL)
bc.add_child(le)
var slot_idx : int = add_slot(getter, setter, bc)
le.text = _edited_resource.call(getter)
le.connect("text_entered", self, "on_slot_line_edit_text_entered", [ slot_idx ])
return slot_idx
func add_slot_enum(getter : String, setter : String, slot_name : String, values : Array) -> int:
var bc : VBoxContainer = VBoxContainer.new()
if slot_name:
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var mb : OptionButton = OptionButton.new()
for v in values:
mb.add_item(v)
bc.add_child(mb)
var slot_idx : int = add_slot(getter, setter, bc)
mb.selected = _edited_resource.call(getter)
mb.connect("item_selected", self, "on_slot_enum_item_selected", [ slot_idx ])
return slot_idx
func add_slot_int(getter : String, setter : String, slot_name : String, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : HBoxContainer = HBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
# l.size_flags_horizontal = SIZE_EXPAND_FILL
bc.add_child(l)
var sb : SpinBox = SpinBox.new()
sb.rounded = true
sb.min_value = prange.x
sb.max_value = prange.y
sb.set_h_size_flags(SIZE_EXPAND_FILL)
bc.add_child(sb)
var slot_idx : int = add_slot(getter, setter, bc)
sb.value = _edited_resource.call(getter)
sb.connect("value_changed", self, "on_int_spinbox_value_changed", [ slot_idx ])
return slot_idx
func add_slot_bool(getter : String, setter : String, slot_name : String) -> int:
var cb : CheckBox = CheckBox.new()
cb.text = slot_name
var slot_idx : int = add_slot(getter, setter, cb)
cb.pressed = _edited_resource.call(getter)
cb.connect("toggled", self, "on_checkbox_value_changed", [ slot_idx ])
return slot_idx
func add_slot_float(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : HBoxContainer = HBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
# l.size_flags_horizontal = SIZE_EXPAND_FILL
bc.add_child(l)
var sb : SpinBox = SpinBox.new()
bc.add_child(sb)
var slot_idx : int = add_slot(getter, setter, bc)
sb.rounded = false
sb.step = step
sb.min_value = prange.x
sb.max_value = prange.y
sb.value = _edited_resource.call(getter)
sb.set_h_size_flags(SIZE_EXPAND_FILL)
sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ])
return slot_idx
func add_slot_vector2(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var sbx : SpinBox = SpinBox.new()
bc.add_child(sbx)
var sby : SpinBox = SpinBox.new()
bc.add_child(sby)
var slot_idx : int = add_slot(getter, setter, bc)
sbx.rounded = false
sby.rounded = false
sbx.step = step
sby.step = step
sbx.min_value = prange.x
sbx.max_value = prange.y
sby.min_value = prange.x
sby.max_value = prange.y
var val : Vector2 = _edited_resource.call(getter)
sbx.value = val.x
sby.value = val.y
sbx.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ])
sby.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ])
return slot_idx
func add_slot_vector3(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var sbx : SpinBox = SpinBox.new()
bc.add_child(sbx)
var sby : SpinBox = SpinBox.new()
bc.add_child(sby)
var sbz : SpinBox = SpinBox.new()
bc.add_child(sbz)
var slot_idx : int = add_slot(getter, setter, bc)
sbx.rounded = false
sby.rounded = false
sbz.rounded = false
sbx.step = step
sby.step = step
sbz.step = step
sbx.min_value = prange.x
sbx.max_value = prange.y
sby.min_value = prange.x
sby.max_value = prange.y
sbz.min_value = prange.x
sbz.max_value = prange.y
var val : Vector3 = _edited_resource.call(getter)
sbx.value = val.x
sby.value = val.y
sbz.value = val.z
sbx.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ])
sby.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ])
sbz.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ])
return slot_idx
func add_slot_rect2(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-10000, 10000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
bc.size_flags_horizontal = SIZE_EXPAND_FILL
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var hc1 : HBoxContainer = HBoxContainer.new()
hc1.size_flags_horizontal = SIZE_EXPAND_FILL
bc.add_child(hc1)
var sbx : SpinBox = SpinBox.new()
sbx.size_flags_horizontal = SIZE_EXPAND_FILL
hc1.add_child(sbx)
var sby : SpinBox = SpinBox.new()
sby.size_flags_horizontal = SIZE_EXPAND_FILL
hc1.add_child(sby)
var hc2 : HBoxContainer = HBoxContainer.new()
hc2.size_flags_horizontal = SIZE_EXPAND_FILL
bc.add_child(hc2)
var sbw : SpinBox = SpinBox.new()
sbw.size_flags_horizontal = SIZE_EXPAND_FILL
hc2.add_child(sbw)
var sbh : SpinBox = SpinBox.new()
sbh.size_flags_horizontal = SIZE_EXPAND_FILL
hc2.add_child(sbh)
var slot_idx : int = add_slot(getter, setter, bc)
sbx.rounded = false
sby.rounded = false
sbw.rounded = false
sbh.rounded = false
sbx.step = step
sby.step = step
sbw.step = step
sbh.step = step
sbx.min_value = prange.x
sbx.max_value = prange.y
sby.min_value = prange.x
sby.max_value = prange.y
sbw.min_value = prange.x
sbw.max_value = prange.y
sbh.min_value = prange.x
sbh.max_value = prange.y
var val : Rect2 = _edited_resource.call(getter)
sbx.value = val.position.x
sby.value = val.position.y
sbw.value = val.size.x
sbh.value = val.size.y
sbx.connect("value_changed", self, "on_rect2_spinbox_value_changed", [ slot_idx, [ sbx, sby, sbw, sbh ] ])
sby.connect("value_changed", self, "on_rect2_spinbox_value_changed", [ slot_idx, [ sbx, sby, sbw, sbh ] ])
sbw.connect("value_changed", self, "on_rect2_spinbox_value_changed", [ slot_idx, [ sbx, sby, sbw, sbh ] ])
sbh.connect("value_changed", self, "on_rect2_spinbox_value_changed", [ slot_idx, [ sbx, sby, sbw, sbh ] ])
return slot_idx
func add_slot_vector2i(getter : String, setter : String, slot_name : String, step : int = 1, prange : Vector2i = Vector2i(-1000000, 1000000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var sbx : SpinBox = SpinBox.new()
bc.add_child(sbx)
var sby : SpinBox = SpinBox.new()
bc.add_child(sby)
var slot_idx : int = add_slot(getter, setter, bc)
sbx.rounded = true
sby.rounded = true
sbx.step = step
sby.step = step
sbx.min_value = prange.x
sbx.max_value = prange.y
sby.min_value = prange.x
sby.max_value = prange.y
var val : Vector2 = _edited_resource.call(getter)
sbx.value = val.x
sby.value = val.y
sbx.connect("value_changed", self, "on_vector2i_spinbox_value_changed", [ slot_idx, sbx, sby ])
sby.connect("value_changed", self, "on_vector2i_spinbox_value_changed", [ slot_idx, sbx, sby ])
return slot_idx
func add_slot(getter : String, setter : String, control : Control) -> int:
var content_node = $MainContainer/Content
content_node.add_child(control)
var child_idx : int = content_node.get_child_count() - 1
var arr : Array = Array()
arr.append(child_idx)
arr.append(getter)
arr.append(setter)
arr.append(control)
properties.append(arr)
var slot_idx : int = properties.size() - 1
return slot_idx
func get_property_control(slot_idx : int) -> Node:
return properties[slot_idx][3]
func on_int_spinbox_value_changed(val : float, slot_idx) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], int(val))
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], int(val))
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_checkbox_value_changed(val : bool, slot_idx) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], val)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], val)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_float_spinbox_value_changed(val : float, slot_idx) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], val)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], val)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_vector2_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y) -> void:
_ignore_changed_evend = true
var vv : Vector2 = Vector2(spinbox_x.value, spinbox_y.value)
#_edited_resource.call(properties[slot_idx][2], vv)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], vv)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_vector3_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y, spinbox_z) -> void:
_ignore_changed_evend = true
var vv : Vector3 = Vector3(spinbox_x.value, spinbox_y.value, spinbox_z.value)
#_edited_resource.call(properties[slot_idx][2], vv)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], vv)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_rect2_spinbox_value_changed(val : float, slot_idx, spinboxes) -> void:
_ignore_changed_evend = true
var vv : Rect2 = Rect2(spinboxes[0].value, spinboxes[1].value, spinboxes[2].value, spinboxes[3].value)
#_edited_resource.call(properties[slot_idx][2], vv)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], vv)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_vector2i_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y) -> void:
_ignore_changed_evend = true
var vv : Vector2i = Vector2i(spinbox_x.value, spinbox_y.value)
#_edited_resource.call(properties[slot_idx][2], vv)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], vv)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_slot_enum_item_selected(val : int, slot_idx : int) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], val)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], val)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_slot_line_edit_text_entered(text : String, slot_idx : int) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], text)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], text)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_widget_resource_changed(res : Resource, slot_idx : int) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], res)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], res)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func clear() -> void:
properties.clear()
var content_node = $MainContainer/Content
if !content_node:
return
for c in content_node.get_children():
c.queue_free()
content_node.remove_child(c)
func refresh() -> void:
clear()
if !_inspector:
_inspector = EditorInspector.new()
$MainContainer.add_child(_inspector)
_inspector.set_h_size_flags(SIZE_EXPAND_FILL)
_inspector.set_v_size_flags(SIZE_EXPAND_FILL)
_inspector.set_hide_script(false)
var cls_str : String = "[none]"
var script_str : String = "[none]"
if _edited_resource:
cls_str = _edited_resource.get_class()
var scr = _edited_resource.get_script()
if scr:
script_str = scr.resource_path
_edited_resource.setup_property_inspector(self)
$MainContainer/HBoxContainer/ClassLE.text = cls_str
$MainContainer/HBoxContainer2/ScriptLE.text = script_str
_refresh_queued = false
if _inspector.get_edited_object() != _edited_resource:
_inspector.edit(_edited_resource)
else:
_inspector.refresh()
func edit_resource(wgw) -> void:
if _edited_resource:
_edited_resource.disconnect("changed", self, "on_edited_resource_changed")
_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:
if _ignore_changed_evend:
return
if _refresh_queued:
return
_refresh_queued = true
call_deferred("refresh")

View File

@ -2,19 +2,17 @@
[ext_resource path="res://addons/world_generator/ui/ResourcePropertyList.gd" type="Script" id=1]
[node name="ResourcePropertyList" type="ScrollContainer"]
[node name="ResourcePropertyList" type="MarginContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 100, 0 )
scroll_horizontal_enabled = false
rect_min_size = Vector2( 250, 0 )
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MainContainer" type="VBoxContainer" parent="."]
margin_right = 1024.0
margin_bottom = 90.0
margin_bottom = 600.0
size_flags_horizontal = 3
[node name="Label" type="Label" parent="MainContainer"]
@ -28,54 +26,3 @@ valign = 1
margin_top = 18.0
margin_right = 1024.0
margin_bottom = 22.0
[node name="Content" type="VBoxContainer" parent="MainContainer"]
margin_top = 26.0
margin_right = 1024.0
margin_bottom = 26.0
size_flags_horizontal = 3
[node name="HSeparator2" type="HSeparator" parent="MainContainer"]
margin_top = 30.0
margin_right = 1024.0
margin_bottom = 34.0
[node name="HBoxContainer" type="HBoxContainer" parent="MainContainer"]
margin_top = 38.0
margin_right = 1024.0
margin_bottom = 62.0
size_flags_horizontal = 3
[node name="Label" type="Label" parent="MainContainer/HBoxContainer"]
margin_top = 5.0
margin_right = 37.0
margin_bottom = 19.0
text = "Class "
valign = 1
[node name="ClassLE" type="LineEdit" parent="MainContainer/HBoxContainer"]
margin_left = 41.0
margin_right = 1024.0
margin_bottom = 24.0
size_flags_horizontal = 3
editable = false
[node name="HBoxContainer2" type="HBoxContainer" parent="MainContainer"]
margin_top = 66.0
margin_right = 1024.0
margin_bottom = 90.0
size_flags_horizontal = 3
[node name="Label" type="Label" parent="MainContainer/HBoxContainer2"]
margin_top = 5.0
margin_right = 36.0
margin_bottom = 19.0
text = "Script"
valign = 1
[node name="ScriptLE" type="LineEdit" parent="MainContainer/HBoxContainer2"]
margin_left = 40.0
margin_right = 1024.0
margin_bottom = 24.0
size_flags_horizontal = 3
editable = false

View File

@ -27,3 +27,8 @@ func set_wgworld(wgw : WorldGenWorld) -> void:
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", resource)
func _on_World_visibility_changed() -> void:
if visible:
refresh()

View File

@ -76,3 +76,7 @@ func on_item_selected(idx : int) -> void:
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", edited_continent, resource)
func _on_Continent_visibility_changed() -> void:
if visible:
refresh()

View File

@ -11,9 +11,6 @@ anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HSplitContainer" type="HSplitContainer" parent="."]
margin_right = 1024.0
@ -23,22 +20,22 @@ size_flags_horizontal = 3
[node name="RectEditor" parent="HSplitContainer" instance=ExtResource( 4 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 735.0
margin_right = 585.0
margin_bottom = 600.0
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer"]
margin_left = 747.0
margin_left = 597.0
margin_right = 1024.0
margin_bottom = 600.0
[node name="OptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_right = 277.0
margin_right = 427.0
margin_bottom = 20.0
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer"]
margin_top = 24.0
margin_right = 277.0
margin_right = 427.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
@ -46,16 +43,13 @@ size_flags_vertical = 3
[node name="ResourcePropertyList" parent="HSplitContainer/VBoxContainer/HBoxContainer2" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 100.0
margin_right = 250.0
margin_bottom = 576.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/HBoxContainer2"]
margin_left = 104.0
margin_right = 277.0
margin_left = 254.0
margin_right = 427.0
margin_bottom = 576.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
@ -95,6 +89,7 @@ margin_right = 173.0
margin_bottom = 576.0
class_types = 1
[connection signal="visibility_changed" from="." to="." method="_on_Continent_visibility_changed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/AddButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="add_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/DeleteButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="delete_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/Duplicate" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="duplicate_button_pressed"]

View File

@ -166,3 +166,7 @@ func on_sub_zone_item_selected(idx : int) -> void:
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", edited_continent, edited_zone, edited_sub_zone, resource)
func _on_SubZone_visibility_changed() -> void:
if visible:
refresh()

View File

@ -20,32 +20,32 @@ size_flags_horizontal = 3
[node name="RectEditor" parent="HSplitContainer" instance=ExtResource( 4 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 735.0
margin_right = 585.0
margin_bottom = 600.0
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer"]
margin_left = 747.0
margin_left = 597.0
margin_right = 1024.0
margin_bottom = 600.0
[node name="ContinentOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_right = 277.0
margin_right = 427.0
margin_bottom = 20.0
[node name="ZoneOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_top = 24.0
margin_right = 277.0
margin_right = 427.0
margin_bottom = 44.0
[node name="SubZoneOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_top = 48.0
margin_right = 277.0
margin_right = 427.0
margin_bottom = 68.0
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer"]
margin_top = 72.0
margin_right = 277.0
margin_right = 427.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
@ -53,16 +53,13 @@ size_flags_vertical = 3
[node name="ResourcePropertyList" parent="HSplitContainer/VBoxContainer/HBoxContainer2" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 100.0
margin_right = 250.0
margin_bottom = 528.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/HBoxContainer2"]
margin_left = 104.0
margin_right = 277.0
margin_left = 254.0
margin_right = 427.0
margin_bottom = 528.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
@ -102,6 +99,7 @@ margin_right = 173.0
margin_bottom = 528.0
class_types = 3
[connection signal="visibility_changed" from="." to="." method="_on_SubZone_visibility_changed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/AddButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="add_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/DeleteButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="delete_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/Duplicate" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="duplicate_button_pressed"]

View File

@ -18,18 +18,19 @@ script = ExtResource( 5 )
margin_right = 839.0
margin_bottom = 564.0
size_flags_horizontal = 3
split_offset = 180
[node name="RectEditor" parent="HSplitContainer" instance=ExtResource( 7 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 727.0
margin_right = 577.0
margin_bottom = 564.0
size_flags_horizontal = 3
[node name="ResourcePropertyList" parent="HSplitContainer" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 739.0
margin_left = 589.0
margin_right = 839.0
margin_bottom = 564.0
@ -74,6 +75,7 @@ margin_top = 42.0
margin_right = 173.0
margin_bottom = 564.0
[connection signal="visibility_changed" from="." to="." method="_on_World_visibility_changed"]
[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"]

View File

@ -120,3 +120,8 @@ func on_zone_item_selected(idx : int) -> void:
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", edited_continent, edited_zone, resource)
func _on_Zone_visibility_changed() -> void:
if visible:
refresh()

View File

@ -23,27 +23,27 @@ size_flags_horizontal = 3
[node name="RectEditor" parent="HSplitContainer" instance=ExtResource( 4 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 735.0
margin_right = 585.0
margin_bottom = 600.0
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer"]
margin_left = 747.0
margin_left = 597.0
margin_right = 1024.0
margin_bottom = 600.0
[node name="ContinentOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_right = 277.0
margin_right = 427.0
margin_bottom = 20.0
[node name="ZoneOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_top = 24.0
margin_right = 277.0
margin_right = 427.0
margin_bottom = 44.0
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer"]
margin_top = 48.0
margin_right = 277.0
margin_right = 427.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
@ -51,16 +51,13 @@ size_flags_vertical = 3
[node name="ResourcePropertyList" parent="HSplitContainer/VBoxContainer/HBoxContainer2" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 100.0
margin_right = 250.0
margin_bottom = 552.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/HBoxContainer2"]
margin_left = 104.0
margin_right = 277.0
margin_left = 254.0
margin_right = 427.0
margin_bottom = 552.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
@ -100,6 +97,7 @@ margin_right = 173.0
margin_bottom = 552.0
class_types = 2
[connection signal="visibility_changed" from="." to="." method="_on_Zone_visibility_changed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/AddButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="add_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/DeleteButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="delete_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/Duplicate" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="duplicate_button_pressed"]

View File

@ -1,68 +0,0 @@
tool
extends HBoxContainer
var _resource_type : String = "Resource"
var _resource : Resource = null
var _plugin : EditorPlugin = null
var _picker : EditorResourcePicker = null
signal on_resource_changed(new_res)
func set_resource_type(type : String) -> void:
_resource_type = type
if _picker:
_picker.base_type = _resource_type
func set_resource(res : Resource) -> void:
if res && !res.is_class(_resource_type):
return
var emit : bool = res != _resource
_resource = res
if _picker:
_picker.edited_resource = _resource
if emit:
emit_signal("on_resource_changed", _resource)
func set_plugin(plugin : EditorPlugin) -> void:
_plugin = plugin
func _enter_tree():
if Engine.is_editor_hint():
_picker = EditorResourcePicker.new()
_picker.set_h_size_flags(SIZE_EXPAND_FILL)
_picker.set_v_size_flags(SIZE_EXPAND_FILL)
add_child(_picker)
if _resource:
_picker.edited_resource = _resource
_picker.base_type = _resource_type
_picker.connect(@"resource_changed", self, "_on_resource_changed")
_picker.connect(@"resource_selected", self, "_on_resource_selected")
func _on_resource_changed(resource: Resource) -> void:
var emit : bool = resource != _resource
_resource = resource
if emit:
emit_signal("on_resource_changed", _resource)
func _on_resource_selected(resource: Resource, edit: bool) -> void:
_plugin.edit_resource(resource)
func on_clear_button_pressed() -> void:
if _resource:
set_resource(null)
func on_resource_button_pressed() -> void:
if _resource && _plugin:
_plugin.get_editor_interface().inspect_object(_resource)

View File

@ -1,8 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/world_generator/widgets/EditorResourceWidget.gd" type="Script" id=1]
[node name="EditorResourceWidget" type="HBoxContainer"]
margin_right = 376.0
margin_bottom = 40.0
script = ExtResource( 1 )