diff --git a/game/addons/world_generator/resources/world_gen_base_resource.gd b/game/addons/world_generator/resources/world_gen_base_resource.gd index a4f7b492..c9195cde 100644 --- a/game/addons/world_generator/resources/world_gen_base_resource.gd +++ b/game/addons/world_generator/resources/world_gen_base_resource.gd @@ -21,6 +21,21 @@ func set_content(arr : Array) -> void: func add_content(item_name : String = "") -> void: pass +func get_editor_rect_border_color() -> Color: + return Color(1, 1, 1, 1) + +func get_editor_rect_color() -> Color: + return Color(0.8, 0.8, 0.8, 0.9) + +func get_editor_rect_border_size() -> int: + return 2 + +func get_editor_font_color() -> Color: + return Color(0, 0, 0, 1) + +func get_editor_additional_text() -> String: + return "WorldGenBaseResource" + 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) diff --git a/game/addons/world_generator/test/test_world.tres b/game/addons/world_generator/test/test_world.tres index ab70f0dd..4faec61b 100644 --- a/game/addons/world_generator/test/test_world.tres +++ b/game/addons/world_generator/test/test_world.tres @@ -27,14 +27,14 @@ subzones = [ SubResource( 14 ), SubResource( 15 ) ] [sub_resource type="Resource" id=13] resource_name = "qqq" script = ExtResource( 3 ) -rect = Rect2( 0, 0, 200.4, 61.8 ) +rect = Rect2( 14, 9, 200.4, 61.8 ) locked = false subzones = [ ] [sub_resource type="Resource" id=1] resource_name = "wwww" script = ExtResource( 2 ) -rect = Rect2( 133, 63, 224, 158 ) +rect = Rect2( 161, 40, 241, 158 ) locked = false zones = [ SubResource( 8 ), SubResource( 13 ) ] @@ -104,7 +104,7 @@ subzones = [ ] [sub_resource type="Resource" id=7] resource_name = "343" script = ExtResource( 2 ) -rect = Rect2( 14, 134, 157, 152 ) +rect = Rect2( 26, 21, 154, 114 ) locked = false zones = [ SubResource( 12 ) ] diff --git a/game/addons/world_generator/ui/RectViewNode.gd b/game/addons/world_generator/ui/RectViewNode.gd index 41eab557..038959eb 100644 --- a/game/addons/world_generator/ui/RectViewNode.gd +++ b/game/addons/world_generator/ui/RectViewNode.gd @@ -12,12 +12,29 @@ enum DragType { var edited_resource : WorldGenBaseResource = null +var _edited_resource_rect_border_color : Color = Color(1, 1, 1, 1) +var _edited_resource_rect_color : Color = Color(0.8, 0.8, 0.8, 0.9) +var _editor_rect_border_size : int = 2 +var _edited_resource_font_color : Color = Color(0, 0, 0, 1) +var _editor_additional_text : String = "" + var drag_type : int var drag_offset : Vector2 var drag_offset_far : Vector2 func _draw(): - draw_rect(Rect2(Vector2(), get_size()), Color(1, 1, 1, 1)) + draw_rect(Rect2(Vector2(), get_size()), _edited_resource_rect_color) + draw_rect(Rect2(Vector2(), get_size()), _edited_resource_rect_border_color, false, _editor_rect_border_size) + + var font : Font = get_font("font") + + var res_name : String = "NULL" + + if edited_resource: + res_name = edited_resource.resource_name + + draw_string(font, Vector2(_editor_rect_border_size, font.get_height()), res_name, _edited_resource_font_color) + draw_string(font, Vector2(_editor_rect_border_size, font.get_height() * 2), _editor_additional_text, _edited_resource_font_color, get_rect().size.x) func refresh() -> void: if !edited_resource: @@ -33,8 +50,15 @@ func refresh() -> void: func set_edited_resource(res : WorldGenBaseResource): edited_resource = res + if edited_resource: + _edited_resource_rect_border_color = edited_resource.get_editor_rect_border_color() + _edited_resource_rect_color = edited_resource.get_editor_rect_color() + _editor_rect_border_size = edited_resource.get_editor_rect_border_size() + _edited_resource_font_color = edited_resource.get_editor_font_color() + _editor_additional_text = edited_resource.get_editor_additional_text() + refresh() - + #based on / ported from engine/scene/gui/dialogs.h and .cpp func _notification(p_what : int) -> void: if (p_what == NOTIFICATION_MOUSE_EXIT):