mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Added a rect2 property. And started working on the rect editor.
This commit is contained in:
parent
3f7f5c0e07
commit
c2e75ef147
@ -4,6 +4,13 @@ class_name WorldGenBaseResource
|
||||
|
||||
export(Rect2) var rect : Rect2 = Rect2(0, 0, 1, 1)
|
||||
|
||||
func get_rect() -> Rect2:
|
||||
return rect
|
||||
|
||||
func set_rect(r : Rect2) -> void:
|
||||
rect = r
|
||||
emit_changed()
|
||||
|
||||
func get_content() -> Array:
|
||||
return Array()
|
||||
|
||||
@ -15,3 +22,4 @@ func add_content() -> void:
|
||||
|
||||
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)
|
||||
|
@ -26,5 +26,5 @@ zones = [ ]
|
||||
[resource]
|
||||
resource_name = "asdasdss"
|
||||
script = ExtResource( 1 )
|
||||
rect = Rect2( 0, 0, 1, 1 )
|
||||
rect = Rect2( 0, 0, 1000, 1000 )
|
||||
continents = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ]
|
||||
|
5
game/addons/world_generator/ui/RectEditorNode.gd
Normal file
5
game/addons/world_generator/ui/RectEditorNode.gd
Normal file
@ -0,0 +1,5 @@
|
||||
tool
|
||||
extends MarginContainer
|
||||
|
||||
func _draw():
|
||||
draw_rect(Rect2(get_position(), get_size()), Color(1, 1, 1, 1))
|
11
game/addons/world_generator/ui/RectEditorNode.tscn
Normal file
11
game/addons/world_generator/ui/RectEditorNode.tscn
Normal file
@ -0,0 +1,11 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/ui/RectEditorNode.gd" type="Script" id=1]
|
||||
|
||||
[node name="RectEditorNode" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
#"res://addons/world_generator/ui/RectEditorNode.tscn"
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
|
@ -152,7 +152,7 @@ func add_slot_vector2(getter : String, setter : String, slot_name : String, step
|
||||
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()
|
||||
|
||||
@ -195,6 +195,64 @@ func add_slot_vector3(getter : String, setter : String, slot_name : String, step
|
||||
|
||||
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()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var hc1 : HBoxContainer = HBoxContainer.new()
|
||||
bc.add_child(hc1)
|
||||
|
||||
var sbx : SpinBox = SpinBox.new()
|
||||
hc1.add_child(sbx)
|
||||
|
||||
var sby : SpinBox = SpinBox.new()
|
||||
hc1.add_child(sby)
|
||||
|
||||
var hc2 : HBoxContainer = HBoxContainer.new()
|
||||
bc.add_child(hc2)
|
||||
|
||||
var sbw : SpinBox = SpinBox.new()
|
||||
hc2.add_child(sbw)
|
||||
|
||||
var sbh : SpinBox = SpinBox.new()
|
||||
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(getter : String, setter : String, control : Control) -> int:
|
||||
var content_node = $MainContainer/Content
|
||||
|
||||
@ -231,6 +289,11 @@ func on_vector3_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_
|
||||
|
||||
_edited_resource.call(properties[slot_idx][2], vv)
|
||||
|
||||
func on_rect2_spinbox_value_changed(val : float, slot_idx, spinboxes) -> void:
|
||||
var vv : Rect2 = Rect2(spinboxes[0].value, spinboxes[1].value, spinboxes[2].value, spinboxes[3].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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user