Cleaned up the methods in the Zone editor. Also fixed a few smaller usability issues.

This commit is contained in:
Relintai 2021-12-25 23:09:56 +01:00
parent 900f402370
commit 1fa6903106
2 changed files with 41 additions and 36 deletions

View File

@ -8,13 +8,13 @@
[sub_resource type="Resource" id=14]
resource_name = "qwe"
script = ExtResource( 4 )
rect = Rect2( 12, 17, 159.14, 87.78 )
rect = Rect2( 21, 25, 150, 79 )
locked = false
[sub_resource type="Resource" id=15]
resource_name = "we"
script = ExtResource( 4 )
rect = Rect2( 0, 0, 19.14, 12.78 )
rect = Rect2( 3, -1, 54.14, 32.78 )
locked = false
[sub_resource type="Resource" id=8]

View File

@ -12,31 +12,11 @@ func _ready():
var zoption_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
zoption_button.connect("item_selected", self, "on_zone_item_selected")
func refresh_continent() -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
option_button.clear()
if !edited_continent:
return
var content : Array = edited_continent.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_zone:
edited_zone = c
func refresh_zone() -> void:
$HSplitContainer/VBoxContainer/HBoxContainer2/ResourcePropertyList.edit_resource(edited_zone)
$HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList.set_edited_resource(edited_zone)
$HSplitContainer/RectEditor.set_edited_resource(edited_zone)
func refresh() -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
option_button.clear()
edited_continent = null
edited_zone = null
if !edited_world:
return
@ -51,8 +31,44 @@ func refresh() -> void:
if !edited_continent:
edited_continent = c
refresh_continent()
continent_changed()
func continent_changed() -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
option_button.clear()
edited_zone = null
if !edited_continent:
return
var content : Array = edited_continent.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_zone:
edited_zone = c
zone_changed()
func zone_changed() -> void:
$HSplitContainer/VBoxContainer/HBoxContainer2/ResourcePropertyList.edit_resource(edited_zone)
$HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList.set_edited_resource(edited_zone)
$HSplitContainer/RectEditor.set_edited_resource(edited_zone)
func set_continent(continent : Continent) -> void:
edited_continent = continent
edited_zone = null
continent_changed()
func set_zone(zone : Zone) -> void:
edited_zone = zone
zone_changed()
func set_wgworld(wgw : WorldGenWorld) -> void:
edited_world = wgw
edited_continent = null
@ -60,17 +76,6 @@ func set_wgworld(wgw : WorldGenWorld) -> void:
refresh()
func set_continent(continent : Continent) -> void:
edited_continent = continent
edited_zone = null
refresh_continent()
func set_zone(zone : Zone) -> void:
edited_zone = zone
refresh_zone()
func on_continent_item_selected(idx : int) -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton