feat: point primitive editor
This commit is contained in:
parent
cd730ac8d4
commit
18ecb79957
|
|
@ -161,13 +161,14 @@ offset_right = 258.0
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme = ExtResource("3_ba0ut")
|
theme = ExtResource("3_ba0ut")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="LeftPanel" unique_id=1723457232]
|
[node name="VBoxContainer" type="VSplitContainer" parent="LeftPanel" unique_id=2133978581]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
drag_area_highlight_in_editor = true
|
||||||
|
|
||||||
[node name="Layers" type="TabContainer" parent="LeftPanel/VBoxContainer" unique_id=2095156888]
|
[node name="Layers" type="TabContainer" parent="LeftPanel/VBoxContainer" unique_id=2095156888]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,52 @@
|
||||||
[gd_scene format=3 uid="uid://cwby0in0f2wi2"]
|
[gd_scene format=3 uid="uid://cwby0in0f2wi2"]
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_aclmm"]
|
||||||
|
script/source = "extends HBoxContainer
|
||||||
|
|
||||||
|
@export var changes_value : String = \"height\"
|
||||||
|
@onready var terrain : TerrainMeshEditor = $\"../../..\".terrain
|
||||||
|
@onready var primitive : TerrainPrimitive = terrain.current_selected
|
||||||
|
var value_before : float = 0.0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
$HSlider.connect(\"drag_ended\", _drag_ended)
|
||||||
|
$HSlider.connect(\"drag_started\", _drag_started)
|
||||||
|
$HSlider.connect(\"value_changed\", _slider_value_changed)
|
||||||
|
$SpinBox.connect(\"value_changed\", _spin_value_changed)
|
||||||
|
primitive.changed.connect(_primitive_changed)
|
||||||
|
_primitive_changed();
|
||||||
|
|
||||||
|
func _primitive_changed():
|
||||||
|
var value = primitive.get(changes_value)
|
||||||
|
$HSlider.value = value
|
||||||
|
$SpinBox.value = value
|
||||||
|
|
||||||
|
func _spin_value_changed(value : float):
|
||||||
|
EditHistory.push_action(primitive.set.bind(changes_value, $SpinBox.value), primitive.set.bind(changes_value, primitive.get(changes_value)))
|
||||||
|
|
||||||
|
func _drag_started():
|
||||||
|
value_before = primitive.get(changes_value)
|
||||||
|
|
||||||
|
func _slider_value_changed(value : float):
|
||||||
|
primitive.set(changes_value, value)
|
||||||
|
$SpinBox.value = value
|
||||||
|
|
||||||
|
func _drag_ended(changed : bool):
|
||||||
|
if changed:
|
||||||
|
EditHistory.push_action(primitive.set.bind(changes_value, $HSlider.value), primitive.set.bind(changes_value, value_before))
|
||||||
|
"
|
||||||
|
|
||||||
[node name="FloatEditor" type="HBoxContainer" unique_id=1730998858]
|
[node name="FloatEditor" type="HBoxContainer" unique_id=1730998858]
|
||||||
offset_right = 318.0
|
offset_right = 318.0
|
||||||
offset_bottom = 31.0
|
offset_bottom = 31.0
|
||||||
|
script = SubResource("GDScript_aclmm")
|
||||||
|
|
||||||
|
[node name="SpinBox" type="SpinBox" parent="." unique_id=580598896]
|
||||||
|
layout_mode = 2
|
||||||
|
min_value = -10000.0
|
||||||
|
max_value = 100000.0
|
||||||
|
value = 10.0
|
||||||
|
allow_greater = true
|
||||||
|
|
||||||
[node name="HSlider" type="HSlider" parent="." unique_id=163542019]
|
[node name="HSlider" type="HSlider" parent="." unique_id=163542019]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
@ -11,11 +55,3 @@ size_flags_vertical = 1
|
||||||
max_value = 300.0
|
max_value = 300.0
|
||||||
step = 0.01
|
step = 0.01
|
||||||
value = 200.0
|
value = 200.0
|
||||||
|
|
||||||
[node name="SpinBox" type="SpinBox" parent="." unique_id=580598896]
|
|
||||||
layout_mode = 2
|
|
||||||
min_value = -10000.0
|
|
||||||
max_value = 100000.0
|
|
||||||
step = 0.01
|
|
||||||
value = 10.0
|
|
||||||
allow_greater = true
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,31 @@
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cwby0in0f2wi2" path="res://ui/editor_elements/float_editor.tscn" id="1_qb00w"]
|
[ext_resource type="PackedScene" uid="uid://cwby0in0f2wi2" path="res://ui/editor_elements/float_editor.tscn" id="1_qb00w"]
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_qb00w"]
|
||||||
|
script/source = "extends HBoxContainer
|
||||||
|
|
||||||
|
@onready var terrain : TerrainMeshEditor = $\"../../..\".terrain
|
||||||
|
@onready var primitive : PointPrimitive = terrain.current_selected
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
primitive.changed.connect(_primitive_changed)
|
||||||
|
$XBox.connect(\"value_changed\", _x_changed)
|
||||||
|
$YBox.connect(\"value_changed\", _y_changed)
|
||||||
|
|
||||||
|
func _primitive_changed():
|
||||||
|
var new_position : Vector2 = primitive.center
|
||||||
|
$XBox.value = new_position.x
|
||||||
|
$YBox.value = new_position.y
|
||||||
|
|
||||||
|
func _x_changed(value : float):
|
||||||
|
var old : Vector2 = primitive.center
|
||||||
|
EditHistory.push_action(primitive.set.bind(\"center\", Vector2(value, old.y)), primitive.set.bind(\"center\", old))
|
||||||
|
|
||||||
|
func _y_changed(value : float):
|
||||||
|
var old : Vector2 = primitive.center
|
||||||
|
EditHistory.push_action(primitive.set.bind(\"center\", Vector2(old.x, value)), primitive.set.bind(\"center\", old))
|
||||||
|
"
|
||||||
|
|
||||||
[node name="PointPrimitive" type="MarginContainer" unique_id=905749607]
|
[node name="PointPrimitive" type="MarginContainer" unique_id=905749607]
|
||||||
offset_right = 302.0
|
offset_right = 302.0
|
||||||
offset_bottom = 230.0
|
offset_bottom = 230.0
|
||||||
|
|
@ -21,3 +46,45 @@ text = "Height"
|
||||||
|
|
||||||
[node name="FloatEditor" parent="VBoxContainer" unique_id=1730998858 instance=ExtResource("1_qb00w")]
|
[node name="FloatEditor" parent="VBoxContainer" unique_id=1730998858 instance=ExtResource("1_qb00w")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Slope" type="Label" parent="VBoxContainer" unique_id=303736827]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Slope"
|
||||||
|
|
||||||
|
[node name="FloatEditor2" parent="VBoxContainer" unique_id=1151227800 instance=ExtResource("1_qb00w")]
|
||||||
|
layout_mode = 2
|
||||||
|
changes_value = "slope"
|
||||||
|
|
||||||
|
[node name="HSlider" parent="VBoxContainer/FloatEditor2" index="0" unique_id=163542019]
|
||||||
|
min_value = -2.0
|
||||||
|
max_value = 2.0
|
||||||
|
value = -0.5
|
||||||
|
tick_count = 5
|
||||||
|
ticks_on_borders = true
|
||||||
|
|
||||||
|
[node name="SpinBox" parent="VBoxContainer/FloatEditor2" index="1" unique_id=580598896]
|
||||||
|
step = 0.1
|
||||||
|
|
||||||
|
[node name="Position" type="Label" parent="VBoxContainer" unique_id=200995882]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Position"
|
||||||
|
|
||||||
|
[node name="HSplitContainer" type="HBoxContainer" parent="VBoxContainer" unique_id=1958091184]
|
||||||
|
layout_mode = 2
|
||||||
|
script = SubResource("GDScript_qb00w")
|
||||||
|
|
||||||
|
[node name="XBox" type="SpinBox" parent="VBoxContainer/HSplitContainer" unique_id=2044129298]
|
||||||
|
layout_mode = 2
|
||||||
|
min_value = -10000.0
|
||||||
|
max_value = 10000.0
|
||||||
|
prefix = "x"
|
||||||
|
|
||||||
|
[node name="YBox" type="SpinBox" parent="VBoxContainer/HSplitContainer" unique_id=1865142111]
|
||||||
|
layout_mode = 2
|
||||||
|
min_value = -10000.0
|
||||||
|
max_value = 10000.0
|
||||||
|
prefix = "y"
|
||||||
|
|
||||||
|
[editable path="VBoxContainer/FloatEditor2"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue