diff --git a/game/addons/world_generator/ui/MainScreen.gd b/game/addons/world_generator/ui/MainScreen.gd index 14929974..5bc3d654 100644 --- a/game/addons/world_generator/ui/MainScreen.gd +++ b/game/addons/world_generator/ui/MainScreen.gd @@ -3,6 +3,11 @@ extends PanelContainer var edited_world +func _ready(): + var world : Control = get_node("TabContainer/World") + if !world.is_connected("request_item_edit", self, "on_world_request_item_edit"): + world.connect("request_item_edit", self, "on_world_request_item_edit") + func set_plugin(plugin : EditorPlugin) -> void: $TabContainer/World.set_plugin(plugin) $TabContainer/Continent.set_plugin(plugin) @@ -21,3 +26,11 @@ func set_wgworld(wgw : WorldGenWorld) -> void: edited_world = wgw refresh() + +func on_world_request_item_edit(resource : WorldGenBaseResource) -> void: + var cont : Control = get_node("TabContainer/Continent") + + var tc : TabContainer = get_node("TabContainer") + tc.current_tab = cont.get_position_in_parent() + + cont.switch_to(resource) diff --git a/game/addons/world_generator/ui/MainScreen.tscn b/game/addons/world_generator/ui/MainScreen.tscn index b735abf0..0f86dc87 100644 --- a/game/addons/world_generator/ui/MainScreen.tscn +++ b/game/addons/world_generator/ui/MainScreen.tscn @@ -13,9 +13,6 @@ anchor_bottom = 1.0 rect_min_size = Vector2( 0, 200 ) size_flags_vertical = 3 script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="TabContainer" type="TabContainer" parent="."] margin_left = 7.0 diff --git a/game/addons/world_generator/ui/WorldTab.gd b/game/addons/world_generator/ui/WorldTab.gd index 0198b78c..1dea5b68 100644 --- a/game/addons/world_generator/ui/WorldTab.gd +++ b/game/addons/world_generator/ui/WorldTab.gd @@ -7,7 +7,6 @@ signal request_item_edit(world_gen_base_resource) func _ready(): var dl : Control = get_node("VBoxContainer/DataList") - if !dl.is_connected("request_item_edit", self, "on_request_item_edit"): dl.connect("request_item_edit", self, "on_request_item_edit") diff --git a/game/addons/world_generator/ui/tabs/Continent.gd b/game/addons/world_generator/ui/tabs/Continent.gd index f8750d66..2fff8e27 100644 --- a/game/addons/world_generator/ui/tabs/Continent.gd +++ b/game/addons/world_generator/ui/tabs/Continent.gd @@ -52,6 +52,17 @@ func set_wgworld(wgw : WorldGenWorld) -> void: refresh() +func switch_to(resource : WorldGenBaseResource) -> void: + var option_button : OptionButton = $HSplitContainer/VBoxContainer/OptionButton + + for i in range(option_button.get_item_count()): + var continent : Continent = option_button.get_item_metadata(i) + + if (continent == resource): + option_button.select(i) + on_item_selected(i) + return + func set_continent(continent : Continent) -> void: edited_continent = continent