From 9e4bd47103ac8c605e20095455dd0c7451efff7c Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 5 Aug 2022 22:46:15 +0200 Subject: [PATCH] Implemented edit buttons for the SubZone editor tab. --- game/addons/world_generator/ui/MainScreen.gd | 12 +++++ .../addons/world_generator/ui/tabs/SubZone.gd | 4 +- .../world_generator/ui/tabs/SubZoneProp.gd | 44 ++++++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/game/addons/world_generator/ui/MainScreen.gd b/game/addons/world_generator/ui/MainScreen.gd index 89379fc2..9809efb8 100644 --- a/game/addons/world_generator/ui/MainScreen.gd +++ b/game/addons/world_generator/ui/MainScreen.gd @@ -15,6 +15,11 @@ func _ready(): var zone : Control = get_node("TabContainer/Zone") if !zone.is_connected("request_item_edit", self, "on_zone_request_item_edit"): zone.connect("request_item_edit", self, "on_zone_request_item_edit") + + var subzone : Control = get_node("TabContainer/SubZone") + if !subzone.is_connected("request_item_edit", self, "on_subzone_request_item_edit"): + subzone.connect("request_item_edit", self, "on_subzone_request_item_edit") + func set_plugin(plugin : EditorPlugin) -> void: $TabContainer/World.set_plugin(plugin) @@ -59,3 +64,10 @@ func on_zone_request_item_edit(continent : WorldGenBaseResource, zone : WorldGen sz.switch_to(continent, zone, subzone) +func on_subzone_request_item_edit(continent : WorldGenBaseResource, zone : WorldGenBaseResource, subzone : WorldGenBaseResource, subzone_prop : WorldGenBaseResource) -> void: + var sz : Control = get_node("TabContainer/SubZoneProp") + + var tc : TabContainer = get_node("TabContainer") + tc.current_tab = sz.get_position_in_parent() + + sz.switch_to(continent, zone, subzone, subzone_prop) diff --git a/game/addons/world_generator/ui/tabs/SubZone.gd b/game/addons/world_generator/ui/tabs/SubZone.gd index c1d30aca..a3887f9c 100644 --- a/game/addons/world_generator/ui/tabs/SubZone.gd +++ b/game/addons/world_generator/ui/tabs/SubZone.gd @@ -6,7 +6,7 @@ var edited_continent : Continent = null var edited_zone : Zone = null var edited_sub_zone : SubZone = null -signal request_item_edit(world_gen_base_resource) +signal request_item_edit(continent, zone, subzone, subzone_prop) func _ready(): var coption_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton @@ -164,5 +164,5 @@ func on_sub_zone_item_selected(idx : int) -> void: set_sub_zone(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, edited_zone, edited_sub_zone, resource) diff --git a/game/addons/world_generator/ui/tabs/SubZoneProp.gd b/game/addons/world_generator/ui/tabs/SubZoneProp.gd index 4bba0253..0cf4190a 100644 --- a/game/addons/world_generator/ui/tabs/SubZoneProp.gd +++ b/game/addons/world_generator/ui/tabs/SubZoneProp.gd @@ -135,12 +135,54 @@ func set_sub_zone(sub_zone : SubZone) -> void: edited_sub_zone_prop = null sub_zone_changed() - + func set_sub_zone_prop(sub_zone_prop : SubZoneProp) -> void: edited_sub_zone_prop = sub_zone_prop sub_zone_prop_changed() +func switch_to(continent : WorldGenBaseResource, zone : WorldGenBaseResource, subzone : WorldGenBaseResource, subzone_prop : WorldGenBaseResource) -> void: + var contob : OptionButton = $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 = $VBoxContainer/ZoneOptionButton + + for i in range(zoneob.get_item_count()): + var czone : Zone = zoneob.get_item_metadata(i) + + if (czone == zone): + zoneob.select(i) + on_zone_item_selected(i) + break + + var subzoneob : OptionButton = $VBoxContainer/SubZoneOptionButton + + for i in range(subzoneob.get_item_count()): + var cszone : SubZone = subzoneob.get_item_metadata(i) + + if (cszone == subzone): + subzoneob.select(i) + set_sub_zone(subzone) + break + + var subzonepropob : OptionButton = $VBoxContainer/SubZonePropOptionButton + + for i in range(subzonepropob.get_item_count()): + var cszoneprop : SubZoneProp = subzonepropob.get_item_metadata(i) + + if (cszoneprop == subzone_prop): + subzonepropob.select(i) + set_sub_zone_prop(subzone_prop) + return + + func on_continent_item_selected(idx : int) -> void: var option_button : OptionButton = $VBoxContainer/ContinentOptionButton