mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Work on the world editor. Also added a property editor similar to mat_maker_gd's nodes.
This commit is contained in:
parent
e44d367c0e
commit
afc929350b
3
game/addons/world_generator/ui/DataList.gd
Normal file
3
game/addons/world_generator/ui/DataList.gd
Normal file
@ -0,0 +1,3 @@
|
||||
tool
|
||||
extends Tree
|
||||
|
14
game/addons/world_generator/ui/DataList.tscn
Normal file
14
game/addons/world_generator/ui/DataList.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/ui/DataList.gd" type="Script" id=1]
|
||||
|
||||
[node name="DataList" type="Tree"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
hide_root = true
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
@ -4,7 +4,7 @@ extends PanelContainer
|
||||
var edited_world
|
||||
|
||||
func refresh() -> void:
|
||||
pass
|
||||
$TabContainer/World/HSplitContainer/ResourcePropertyList.edit_resource(edited_world)
|
||||
|
||||
func set_wgworld(wgw : WorldGenWorld) -> void:
|
||||
edited_world = wgw
|
||||
|
@ -1,6 +1,10 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/ui/MainScreen.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/world_generator/ui/RectEditor.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/world_generator/ui/DataList.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://addons/world_generator/ui/WorldTab.gd" type="Script" id=4]
|
||||
[ext_resource path="res://addons/world_generator/ui/ResourcePropertyList.tscn" type="PackedScene" id=5]
|
||||
|
||||
[node name="WorldGenerator" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
@ -19,16 +23,66 @@ margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
tab_align = 0
|
||||
|
||||
[node name="World" type="VBoxContainer" parent="TabContainer"]
|
||||
[node name="World" type="HBoxContainer" parent="TabContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_top = 32.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="TabContainer/World"]
|
||||
margin_right = 825.0
|
||||
margin_bottom = 550.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="RectEditor" parent="TabContainer/World/HSplitContainer" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 713.0
|
||||
margin_bottom = 550.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ResourcePropertyList" parent="TabContainer/World/HSplitContainer" instance=ExtResource( 5 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 725.0
|
||||
margin_right = 825.0
|
||||
margin_bottom = 550.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/World"]
|
||||
margin_left = 829.0
|
||||
margin_right = 1002.0
|
||||
margin_bottom = 550.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/World/VBoxContainer"]
|
||||
margin_right = 173.0
|
||||
margin_bottom = 20.0
|
||||
|
||||
[node name="AddButton" type="Button" parent="TabContainer/World/VBoxContainer/HBoxContainer"]
|
||||
margin_right = 37.0
|
||||
margin_bottom = 20.0
|
||||
text = "Add"
|
||||
|
||||
[node name="DeleteButton" type="Button" parent="TabContainer/World/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 41.0
|
||||
margin_right = 96.0
|
||||
margin_bottom = 20.0
|
||||
text = "Delete"
|
||||
|
||||
[node name="Duplicate" type="Button" parent="TabContainer/World/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 100.0
|
||||
margin_right = 173.0
|
||||
margin_bottom = 20.0
|
||||
text = "Duplicate"
|
||||
|
||||
[node name="DataList" parent="TabContainer/World/VBoxContainer" instance=ExtResource( 3 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 24.0
|
||||
margin_right = 173.0
|
||||
margin_bottom = 550.0
|
||||
|
||||
[node name="Continent" type="VBoxContainer" parent="TabContainer"]
|
||||
visible = false
|
||||
|
6
game/addons/world_generator/ui/RectEditor.gd
Normal file
6
game/addons/world_generator/ui/RectEditor.gd
Normal file
@ -0,0 +1,6 @@
|
||||
tool
|
||||
extends PanelContainer
|
||||
|
||||
func _init():
|
||||
# Control/EditorZoomWidget
|
||||
pass
|
44
game/addons/world_generator/ui/RectEditor.tscn
Normal file
44
game/addons/world_generator/ui/RectEditor.tscn
Normal file
@ -0,0 +1,44 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/ui/RectEditor.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/world_generator/widgets/EditorZoomWidget.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/world_generator/ui/RectView.gd" type="Script" id=3]
|
||||
|
||||
[node name="RectEditor" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
|
||||
[node name="RectView" type="Control" parent="ScrollContainer"]
|
||||
margin_right = 1010.0
|
||||
margin_bottom = 586.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="EditorZoomWidget" parent="Control" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 115.0
|
||||
margin_bottom = 22.0
|
||||
custom_constants/separation = -8
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
17
game/addons/world_generator/ui/RectView.gd
Normal file
17
game/addons/world_generator/ui/RectView.gd
Normal file
@ -0,0 +1,17 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
265
game/addons/world_generator/ui/ResourcePropertyList.gd
Normal file
265
game/addons/world_generator/ui/ResourcePropertyList.gd
Normal file
@ -0,0 +1,265 @@
|
||||
tool
|
||||
extends ScrollContainer
|
||||
|
||||
var _edited_resource : WorldGenWorld = null
|
||||
var properties : Array = Array()
|
||||
|
||||
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_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 : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sb : SpinBox = SpinBox.new()
|
||||
sb.rounded = true
|
||||
sb.min_value = prange.x
|
||||
sb.max_value = prange.y
|
||||
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", _edited_resource, setter)
|
||||
|
||||
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 : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
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.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(getter : String, setter : String, control : Control) -> int:
|
||||
var content_node = $MainContainer/Content
|
||||
|
||||
content_node.add_child(control)
|
||||
var slot_idx : int = content_node.get_child_count() - 1
|
||||
|
||||
var arr : Array = Array()
|
||||
|
||||
arr.append(slot_idx)
|
||||
arr.append(getter)
|
||||
arr.append(setter)
|
||||
arr.append(control)
|
||||
|
||||
properties.append(arr)
|
||||
|
||||
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:
|
||||
_edited_resource.call(properties[slot_idx][2], int(val))
|
||||
|
||||
func on_float_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
_edited_resource.call(properties[slot_idx][2], val)
|
||||
|
||||
func on_vector2_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y) -> void:
|
||||
var vv : Vector2 = Vector2(spinbox_x.value, spinbox_y.value)
|
||||
|
||||
_edited_resource.call(properties[slot_idx][2], vv)
|
||||
|
||||
func on_vector3_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y, spinbox_z) -> void:
|
||||
var vv : Vector3 = Vector3(spinbox_x.value, spinbox_y.value, spinbox_z.value)
|
||||
|
||||
_edited_resource.call(properties[slot_idx][2], vv)
|
||||
|
||||
func on_slot_enum_item_selected(val : int, slot_idx : int) -> void:
|
||||
_edited_resource.call(properties[slot_idx][2], val)
|
||||
|
||||
func on_slot_line_edit_text_entered(text : String, slot_idx : int) -> void:
|
||||
_edited_resource.call(properties[slot_idx][2], text)
|
||||
|
||||
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 _edited_resource:
|
||||
_edited_resource.setup_property_inspector(self)
|
||||
_edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
func edit_resource(wgw) -> void:
|
||||
if _edited_resource:
|
||||
_edited_resource.disconnect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
_edited_resource = wgw
|
||||
|
||||
refresh()
|
31
game/addons/world_generator/ui/ResourcePropertyList.tscn
Normal file
31
game/addons/world_generator/ui/ResourcePropertyList.tscn
Normal file
@ -0,0 +1,31 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/ui/ResourcePropertyList.gd" type="Script" id=1]
|
||||
|
||||
[node name="ResourcePropertyList" type="ScrollContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 100, 0 )
|
||||
scroll_horizontal_enabled = false
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MainContainer" type="VBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="MainContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 14.0
|
||||
text = "Properties"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="MainContainer"]
|
||||
margin_top = 18.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_horizontal = 3
|
3
game/addons/world_generator/ui/WorldTab.gd
Normal file
3
game/addons/world_generator/ui/WorldTab.gd
Normal file
@ -0,0 +1,3 @@
|
||||
tool
|
||||
extends HBoxContainer
|
||||
|
@ -245,6 +245,11 @@ _global_script_classes=[ {
|
||||
"path": "res://scripts/game_modules/ui_window_module.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "WorldGenBaseResource",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/world_generator/resources/world_gen_base_resource.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "WorldGenWorld",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/world_generator/resources/world_gen_world.gd"
|
||||
@ -302,6 +307,7 @@ _global_script_class_icons={
|
||||
"SubZone": "",
|
||||
"UIGuiChildModule": "",
|
||||
"UIWindowModule": "",
|
||||
"WorldGenBaseResource": "",
|
||||
"WorldGenWorld": "",
|
||||
"Zone": ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user