mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-20 21:07:17 +01:00
Added min and max size support for the world generator addon.
This commit is contained in:
parent
ffe566b0ac
commit
4bea9618b2
@ -3,13 +3,33 @@ extends Resource
|
||||
class_name WorldGenBaseResource
|
||||
|
||||
export(Rect2) var rect : Rect2 = Rect2(0, 0, 100, 100)
|
||||
export(Vector2i) var min_size : Vector2i = Vector2i(1, 1)
|
||||
export(Vector2i) var max_size : Vector2i = Vector2i(1000000, 1000000)
|
||||
export(bool) var locked : bool = false
|
||||
|
||||
func get_rect() -> Rect2:
|
||||
return rect
|
||||
|
||||
func set_rect(r : Rect2) -> void:
|
||||
rect = r
|
||||
rect.position = r.position
|
||||
rect.size.x = max(min_size.x, r.size.x)
|
||||
rect.size.y = max(min_size.y, r.size.y)
|
||||
rect.size.x = min(max_size.x, rect.size.x)
|
||||
rect.size.y = min(max_size.y, rect.size.y)
|
||||
emit_changed()
|
||||
|
||||
func get_min_size() -> Vector2i:
|
||||
return min_size
|
||||
|
||||
func set_min_size(r : Vector2i) -> void:
|
||||
min_size = r
|
||||
emit_changed()
|
||||
|
||||
func get_max_size() -> Vector2i:
|
||||
return max_size
|
||||
|
||||
func set_max_size(r : Vector2i) -> void:
|
||||
max_size = r
|
||||
emit_changed()
|
||||
|
||||
func get_locked() -> bool:
|
||||
@ -181,4 +201,7 @@ func get_editor_additional_text() -> String:
|
||||
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")
|
||||
|
||||
|
@ -198,7 +198,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()
|
||||
|
||||
@ -306,6 +306,39 @@ func add_slot_rect2(getter : String, setter : String, slot_name : String, step :
|
||||
|
||||
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
|
||||
|
||||
@ -403,6 +436,19 @@ func on_rect2_spinbox_value_changed(val : float, slot_idx, spinboxes) -> void:
|
||||
|
||||
_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)
|
||||
|
@ -16,6 +16,8 @@
|
||||
resource_name = "Spawner"
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 9.6719, 4.34375, 2.09375, 1.6875 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
trainer = ExtResource( 9 )
|
||||
vendor = ExtResource( 8 )
|
||||
@ -24,13 +26,17 @@ vendor = ExtResource( 8 )
|
||||
resource_name = "DungeonSpawner"
|
||||
script = ExtResource( 11 )
|
||||
rect = Rect2( 9.96875, 4.07812, 2.26562, 1.79688 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
dungeon_teleporter = ExtResource( 4 )
|
||||
|
||||
[sub_resource type="Resource" id=5]
|
||||
resource_name = "DungeonSpawner2"
|
||||
script = ExtResource( 11 )
|
||||
rect = Rect2( 13.439, 6.6259, 3.11573, 2.0916 )
|
||||
rect = Rect2( 11.4113, 7.34633, 6.9637, 3 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
dungeon_teleporter = ExtResource( 4 )
|
||||
|
||||
@ -38,6 +44,8 @@ dungeon_teleporter = ExtResource( 4 )
|
||||
resource_name = "TestForest"
|
||||
script = ExtResource( 7 )
|
||||
rect = Rect2( 8.75557, 6.875, 21.9944, 11.2839 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
subzones = [ SubResource( 2 ), SubResource( 4 ), SubResource( 5 ) ]
|
||||
zone_radius = 0.5
|
||||
@ -51,6 +59,8 @@ prop_tree2 = ExtResource( 5 )
|
||||
resource_name = "Continent"
|
||||
script = ExtResource( 3 )
|
||||
rect = Rect2( 241, 247, 40, 25 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
zones = [ SubResource( 3 ) ]
|
||||
continent_radius = 0.5
|
||||
@ -61,6 +71,8 @@ continent_base = 0.0
|
||||
resource_name = "TestWorld"
|
||||
script = ExtResource( 1 )
|
||||
rect = Rect2( -250, -250, 500, 500 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
continents = [ SubResource( 1 ) ]
|
||||
normal_surface_id = 2
|
||||
|
Loading…
Reference in New Issue
Block a user