Added a new get_editor_class to the WoirldGeneratorBaseResource, and now the RectViewNode will also render it if it's not an empty string.

This commit is contained in:
Relintai 2021-12-26 18:50:09 +01:00
parent f739cca1f4
commit 9cac983ff5
2 changed files with 14 additions and 3 deletions

View File

@ -2,7 +2,7 @@ tool
extends Resource
class_name WorldGenBaseResource
export(Rect2) var rect : Rect2 = Rect2(0, 0, 1, 1)
export(Rect2) var rect : Rect2 = Rect2(0, 0, 100, 100)
export(bool) var locked : bool = false
func get_rect() -> Rect2:
@ -36,7 +36,7 @@ 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)
return Color(1, 1, 1, 0.9)
func get_editor_rect_border_size() -> int:
return 2
@ -44,6 +44,9 @@ func get_editor_rect_border_size() -> int:
func get_editor_font_color() -> Color:
return Color(0, 0, 0, 1)
func get_editor_class() -> String:
return "WorldGenBaseResource"
func get_editor_additional_text() -> String:
return "WorldGenBaseResource"

View File

@ -33,9 +33,17 @@ func _draw():
if edited_resource:
res_name = edited_resource.resource_name
var res_cls : String = ""
if edited_resource:
res_cls = edited_resource.get_editor_class()
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)
if res_cls != "":
draw_string(font, Vector2(_editor_rect_border_size, font.get_height() * 3), res_cls, _edited_resource_font_color, get_rect().size.x)
func refresh() -> void:
if !edited_resource:
return