Added ApplicationManager::Status, DownloadManager now displays data from Status, added improved progress information to DownloadManager via Task updating its Status object

This commit is contained in:
2021-11-26 12:17:26 -06:00
parent 935aed1a7a
commit 6c18e16357
10 changed files with 220 additions and 81 deletions

View File

@@ -1,13 +1,13 @@
class W3DHub
class Pages
class DownloadManager < Page
attr_reader :download_package_info
attr_reader :operation_info
def setup
@download_package_info ||= {}
@task = Store.application_manager.current_task
@operation_info ||= {}
task = Store.application_manager.current_task
unless @task
unless task
body.clear do
tagline "No operations pending.", width: 1.0, text_align: :center, margin: 128
end
@@ -15,50 +15,61 @@ class W3DHub
return
end
regenerate(task)
end
def regenerate(task)
@operation_info[:___step] = task.status.step
body.clear do
stack(width: 1.0, height: 1.0) do
# TODO: Show correct application details here
flow(width: 1.0, height: 0.1, padding: 8) do
background @task.application.color
background task.application.color
flow(width: 0.70, height: 1.0) do
@application_image = image "#{GAME_ROOT_PATH}/media/icons/#{@task.app_id}.png", height: 1.0
@application_image = image "#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png", height: 1.0
stack(margin_left: 8) do
@application_name_label = tagline "#{@task.application.name}"
@application_version_label = inscription "Version: #{@task.channel.current_version} (#{@task.channel.id})"
@application_name_label = tagline "#{task.application.name}"
@application_version_label = inscription "Version: #{task.channel.current_version} (#{task.channel.id})"
end
end
puts "OKAY"
flow(width: 0.30, height: 1.0) do
stack(width: 0.499, height: 1.0) do
para "Download Speed", width: 1.0, text_align: :center
@download_speed_label = inscription "0 b/s", width: 1.0, text_align: :center
@download_speed_label = inscription "- b/s", width: 1.0, text_align: :center
end
stack(width: 0.5, height: 1.0) do
para "Downloaded", width: 1.0, text_align: :center
inscription "325.8 MB / 1.39 GB", width: 1.0, text_align: :center
inscription "---- b / ---- b", width: 1.0, text_align: :center
end
end
end
# Operations
@downloads_container = stack(width: 1.0, height: 0.9, padding: 8, scroll: true) do
@operations_container = stack(width: 1.0, height: 0.9, padding: 8, scroll: true) do
# TODO: Show actual list of downloads
@task&.packages_to_download&.each_with_index do |pkg, i|
p ["DOWNLOAD MANAGER", task.status.operations.size]
i = -1
task.status.operations.each do |key, operation|
i += 1
p [key, operation.label]
stack(width: 1.0, height: 24, padding: 8) do
background 0xff_333333 if i.odd?
flow(width: 1.0, height: 22) do
@download_package_info["#{pkg.checksum}_name"] = inscription pkg.name, width: 0.7, text_wrap: :none, tag: "#{pkg.checksum}_name"
@download_package_info["#{pkg.checksum}_status"] = inscription "Pending...", width: 0.3, text_align: :right, text_wrap: :none, tag: "#{pkg.checksum}_status"
@operation_info["#{key}_name"] = inscription operation.label, width: 0.7, text_wrap: :none, tag: "#{key}_name"
@operation_info["#{key}_status"] = inscription operation.value, width: 0.3, text_align: :right, text_wrap: :none, tag: "#{key}_status"
end
@download_package_info["#{pkg.checksum}_progress"] = progress fraction: 0.0, height: 2, width: 1.0, tag: "#{pkg.checksum}_progress"
@operation_info["#{key}_progress"] = progress fraction: operation.progress, height: 2, width: 1.0, tag: "#{key}_progress"
end
end
end