2023-05-25 11:30:21 +00:00
|
|
|
extends VBoxContainer
|
|
|
|
|
|
|
|
const ITEM_SCENE := preload("res://UI/Components/ReleaseItem.tscn")
|
2023-05-25 20:13:07 +00:00
|
|
|
|
|
|
|
@onready var release_items_container: VBoxContainer = %ReleaseItemsContainer
|
|
|
|
@onready var fetch_button: Button = %FetchButton
|
|
|
|
@onready var status_label: Label = %StatusLabel
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
ReleasesManager.releases_fetched.connect(releases_updated)
|
|
|
|
ReleasesManager.releases_fetched.connect(func(_x):
|
|
|
|
await get_tree().process_frame
|
|
|
|
fetch_button.disabled = false
|
|
|
|
)
|
|
|
|
fetch_button.pressed.connect(func():
|
|
|
|
ReleasesManager.fetch_releases()
|
|
|
|
fetch_button.disabled = true
|
|
|
|
)
|
|
|
|
ReleasesManager.fetch_releases(true)
|
|
|
|
|
|
|
|
ReleasesManager.status_update.connect(status_label.set_text)
|
|
|
|
|
|
|
|
|
|
|
|
func releases_updated(releases: ReleasesManager.Releases) -> void:
|
|
|
|
clear_releases()
|
|
|
|
for version in releases.releases:
|
|
|
|
var item: ReleaseItem = ITEM_SCENE.instantiate()
|
|
|
|
release_items_container.add_child(item)
|
|
|
|
item.set_version(version)
|
|
|
|
item.set_install_button_disabled(ReleasesManager.is_version_installed(version))
|
|
|
|
item.set_templates_button_disabled(ReleasesManager.is_version_templates_installed(version))
|
|
|
|
|
|
|
|
item.install_button_pressed.connect(ReleasesManager.download_release)
|
|
|
|
item.install_templates_button_pressed.connect(ReleasesManager.download_release)
|
|
|
|
|
|
|
|
ReleasesManager.version_downloaded.connect(item._on_version_downloaded)
|
|
|
|
ReleasesManager.export_templates_downloaded.connect(item._on_export_templates_downloaded)
|
|
|
|
|
|
|
|
|
|
|
|
func clear_releases() -> void:
|
|
|
|
for i in release_items_container.get_children():
|
|
|
|
i.queue_free()
|