From 8a3ac51e8619386ed605ef5f9d8be55738fcc988 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 5 Aug 2022 22:32:04 +0200 Subject: [PATCH] The edit buttons now work in Continent aswell. --- game/addons/world_generator/ui/MainScreen.gd | 12 +++++++++++ .../world_generator/ui/tabs/Continent.gd | 4 ++-- game/addons/world_generator/ui/tabs/Zone.gd | 21 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/game/addons/world_generator/ui/MainScreen.gd b/game/addons/world_generator/ui/MainScreen.gd index 5bc3d654..197a752a 100644 --- a/game/addons/world_generator/ui/MainScreen.gd +++ b/game/addons/world_generator/ui/MainScreen.gd @@ -7,6 +7,10 @@ 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") + + var continent : Control = get_node("TabContainer/Continent") + if !continent.is_connected("request_item_edit", self, "on_continent_request_item_edit"): + continent.connect("request_item_edit", self, "on_continent_request_item_edit") func set_plugin(plugin : EditorPlugin) -> void: $TabContainer/World.set_plugin(plugin) @@ -34,3 +38,11 @@ func on_world_request_item_edit(resource : WorldGenBaseResource) -> void: tc.current_tab = cont.get_position_in_parent() cont.switch_to(resource) + +func on_continent_request_item_edit(continent : WorldGenBaseResource, resource : WorldGenBaseResource) -> void: + var zone : Control = get_node("TabContainer/Zone") + + var tc : TabContainer = get_node("TabContainer") + tc.current_tab = zone.get_position_in_parent() + + zone.switch_to(continent, resource) diff --git a/game/addons/world_generator/ui/tabs/Continent.gd b/game/addons/world_generator/ui/tabs/Continent.gd index 2fff8e27..be2409f2 100644 --- a/game/addons/world_generator/ui/tabs/Continent.gd +++ b/game/addons/world_generator/ui/tabs/Continent.gd @@ -4,7 +4,7 @@ extends HBoxContainer var edited_world : WorldGenWorld = null var edited_continent : Continent = null -signal request_item_edit(world_gen_base_resource) +signal request_item_edit(continent, world_gen_base_resource) func _ready(): var option_button : OptionButton = $HSplitContainer/VBoxContainer/OptionButton @@ -74,5 +74,5 @@ func on_item_selected(idx : int) -> void: set_continent(option_button.get_item_metadata(idx)) func on_request_item_edit(resource : WorldGenBaseResource) -> void: - emit_signal("request_item_edit", resource) + emit_signal("request_item_edit", edited_continent, resource) diff --git a/game/addons/world_generator/ui/tabs/Zone.gd b/game/addons/world_generator/ui/tabs/Zone.gd index 18bb028e..a316be67 100644 --- a/game/addons/world_generator/ui/tabs/Zone.gd +++ b/game/addons/world_generator/ui/tabs/Zone.gd @@ -86,6 +86,27 @@ func set_wgworld(wgw : WorldGenWorld) -> void: edited_zone = null refresh() + +func switch_to(continent : WorldGenBaseResource, resource : WorldGenBaseResource) -> void: + var contob : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton + + for i in range(contob.get_item_count()): + var ccont : Continent = contob.get_item_metadata(i) + + if (ccont == continent): + contob.select(i) + on_continent_item_selected(i) + break + + var zoneob : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton + + for i in range(zoneob.get_item_count()): + var czone : Zone = zoneob.get_item_metadata(i) + + if (czone == resource): + zoneob.select(i) + on_zone_item_selected(i) + return func on_continent_item_selected(idx : int) -> void: var option_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton