From e13be6f3f501f0bd3a242dc63a65e3185e91dc09 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 27 Dec 2021 22:20:09 +0100 Subject: [PATCH] Added a class and script property by default to the property inspector. --- .../resources/world_gen_base_resource.gd | 2 +- .../ui/ResourcePropertyList.gd | 12 +++++ .../ui/ResourcePropertyList.tscn | 46 +++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) 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 f268a5f9..496d14dd 100644 --- a/game/addons/world_generator/resources/world_gen_base_resource.gd +++ b/game/addons/world_generator/resources/world_gen_base_resource.gd @@ -106,7 +106,7 @@ func generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool) -> v _generate_terra_chunk_fallback(chunk, pseed, spawn_mobs) return - for i in range(stack.size() - 1, -1, -1): + for i in range(stack.size()): stack[i]._generate_terra_chunk(chunk, pseed, spawn_mobs, stack, i) func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool, stack : Array, stack_index : int) -> void: diff --git a/game/addons/world_generator/ui/ResourcePropertyList.gd b/game/addons/world_generator/ui/ResourcePropertyList.gd index 6ddbddad..6daa2dd2 100644 --- a/game/addons/world_generator/ui/ResourcePropertyList.gd +++ b/game/addons/world_generator/ui/ResourcePropertyList.gd @@ -348,9 +348,21 @@ func clear() -> void: func refresh() -> void: clear() + var cls_str : String = "[none]" + var script_str : String = "[none]" + if _edited_resource: + cls_str = _edited_resource.get_class() + + var scr = _edited_resource.get_script() + + if scr: + script_str = scr.resource_path + _edited_resource.setup_property_inspector(self) + $MainContainer/HBoxContainer/ClassLE.text = cls_str + $MainContainer/HBoxContainer2/ScriptLE.text = script_str func edit_resource(wgw) -> void: if _edited_resource: diff --git a/game/addons/world_generator/ui/ResourcePropertyList.tscn b/game/addons/world_generator/ui/ResourcePropertyList.tscn index e1c8fb1f..dfa929e0 100644 --- a/game/addons/world_generator/ui/ResourcePropertyList.tscn +++ b/game/addons/world_generator/ui/ResourcePropertyList.tscn @@ -14,7 +14,7 @@ __meta__ = { [node name="MainContainer" type="VBoxContainer" parent="."] margin_right = 1024.0 -margin_bottom = 18.0 +margin_bottom = 74.0 size_flags_horizontal = 3 [node name="Label" type="Label" parent="MainContainer"] @@ -24,8 +24,48 @@ text = "Properties" align = 1 valign = 1 -[node name="Content" type="VBoxContainer" parent="MainContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="MainContainer"] margin_top = 18.0 margin_right = 1024.0 -margin_bottom = 18.0 +margin_bottom = 42.0 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="MainContainer/HBoxContainer"] +margin_top = 5.0 +margin_right = 37.0 +margin_bottom = 19.0 +text = "Class " +valign = 1 + +[node name="ClassLE" type="LineEdit" parent="MainContainer/HBoxContainer"] +margin_left = 41.0 +margin_right = 1024.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +editable = false + +[node name="HBoxContainer2" type="HBoxContainer" parent="MainContainer"] +margin_top = 46.0 +margin_right = 1024.0 +margin_bottom = 70.0 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="MainContainer/HBoxContainer2"] +margin_top = 5.0 +margin_right = 36.0 +margin_bottom = 19.0 +text = "Script" +valign = 1 + +[node name="ScriptLE" type="LineEdit" parent="MainContainer/HBoxContainer2"] +margin_left = 40.0 +margin_right = 1024.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +editable = false + +[node name="Content" type="VBoxContainer" parent="MainContainer"] +margin_top = 74.0 +margin_right = 1024.0 +margin_bottom = 74.0 size_flags_horizontal = 3