mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-22 02:17:18 +01:00
Basic RectView functionality. Renamed RectEditorNode to RectViewNode.
This commit is contained in:
parent
6b388b3c1b
commit
dd7024c0ed
@ -5,7 +5,7 @@
|
||||
|
||||
[sub_resource type="Resource" id=1]
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 0, 0, 1, 1 )
|
||||
rect = Rect2( 0, 0, 100, 100 )
|
||||
zones = [ ]
|
||||
|
||||
[sub_resource type="Resource" id=2]
|
||||
|
@ -15,8 +15,8 @@ __meta__ = {
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="ScrollContainer"]
|
||||
margin_right = 400.0
|
||||
|
@ -1,5 +0,0 @@
|
||||
tool
|
||||
extends MarginContainer
|
||||
|
||||
func _draw():
|
||||
draw_rect(Rect2(get_position(), get_size()), Color(1, 1, 1, 1))
|
@ -1,11 +0,0 @@
|
||||
[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,7 +1,7 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
#"res://addons/world_generator/ui/RectEditorNode.tscn"
|
||||
var rect_editor_node_scene : PackedScene = preload("res://addons/world_generator/ui/RectViewNode.tscn")
|
||||
|
||||
var edited_resource : WorldGenBaseResource = null
|
||||
|
||||
@ -24,21 +24,42 @@ func refresh() -> void:
|
||||
p.add_constant_override("margin_right", rect.size.x / 4.0)
|
||||
p.add_constant_override("margin_top", rect.size.y / 4.0)
|
||||
p.add_constant_override("margin_bottom", rect.size.y / 4.0)
|
||||
|
||||
|
||||
refresh_rects()
|
||||
|
||||
func clear() -> void:
|
||||
pass
|
||||
|
||||
func refresh_rects() -> void:
|
||||
clear_rects()
|
||||
|
||||
if !edited_resource:
|
||||
return
|
||||
|
||||
var cont : Array = edited_resource.get_content()
|
||||
|
||||
for c in cont:
|
||||
if c:
|
||||
var s : Node = rect_editor_node_scene.instance()
|
||||
|
||||
add_child(s)
|
||||
s.set_edited_resource(c)
|
||||
|
||||
func clear_rects():
|
||||
for c in get_children():
|
||||
c.queue_free()
|
||||
remove_child(c)
|
||||
|
||||
func set_edited_resource(res : WorldGenBaseResource):
|
||||
if edited_resource:
|
||||
edited_resource.disconnect("changed", self, "on_edited_resource_changed")
|
||||
# if edited_resource:
|
||||
# edited_resource.disconnect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
edited_resource = res
|
||||
|
||||
refresh()
|
||||
|
||||
if edited_resource:
|
||||
edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
# if edited_resource:
|
||||
# edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
|
||||
func on_edited_resource_changed() -> void:
|
||||
pass
|
||||
#refresh()
|
||||
#func on_edited_resource_changed() -> void:
|
||||
# pass
|
||||
|
24
game/addons/world_generator/ui/RectViewNode.gd
Normal file
24
game/addons/world_generator/ui/RectViewNode.gd
Normal file
@ -0,0 +1,24 @@
|
||||
tool
|
||||
extends MarginContainer
|
||||
|
||||
var edited_resource : WorldGenBaseResource = null
|
||||
|
||||
func _draw():
|
||||
draw_rect(Rect2(get_position(), get_size()), Color(1, 1, 1, 1))
|
||||
|
||||
func refresh() -> void:
|
||||
if !edited_resource:
|
||||
return
|
||||
|
||||
var rect : Rect2 = edited_resource.get_rect()
|
||||
|
||||
rect_position = rect.position
|
||||
rect_size = rect.size
|
||||
|
||||
update()
|
||||
|
||||
func set_edited_resource(res : WorldGenBaseResource):
|
||||
edited_resource = res
|
||||
|
||||
refresh()
|
||||
|
11
game/addons/world_generator/ui/RectViewNode.tscn
Normal file
11
game/addons/world_generator/ui/RectViewNode.tscn
Normal file
@ -0,0 +1,11 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/ui/RectViewNode.gd" type="Script" id=1]
|
||||
|
||||
[node name="RectViewNode" type="MarginContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
Loading…
Reference in New Issue
Block a user