mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Task now ask Interface to update task status instead of just doing it themselves whenever they want, stubbed apply_patch method, moved unpacking into its own method
This commit is contained in:
@@ -123,7 +123,7 @@ class W3DHub
|
|||||||
def update_interface_task_status
|
def update_interface_task_status
|
||||||
run_on_main_thread(
|
run_on_main_thread(
|
||||||
proc do
|
proc do
|
||||||
window.current_state.update_interface_task_status(self)
|
window.current_state.interface_task_update_pending = self
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -237,7 +237,7 @@ class W3DHub
|
|||||||
|
|
||||||
@status.step = :prefetch_verifying_packages
|
@status.step = :prefetch_verifying_packages
|
||||||
|
|
||||||
package_details.each do |pkg|
|
package_details.each_with_index.each do |pkg, i|
|
||||||
operation = @status.operations[:"#{pkg.checksum}"]
|
operation = @status.operations[:"#{pkg.checksum}"]
|
||||||
|
|
||||||
if verify_package(pkg)
|
if verify_package(pkg)
|
||||||
@@ -250,6 +250,8 @@ class W3DHub
|
|||||||
operation.progress = pkg.custom_partially_valid_at_bytes.to_f / pkg.size
|
operation.progress = pkg.custom_partially_valid_at_bytes.to_f / pkg.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@status.progress = i.to_f / package_details.count
|
||||||
|
|
||||||
update_interface_task_status
|
update_interface_task_status
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -300,24 +302,29 @@ class W3DHub
|
|||||||
packages.each do |pkg|
|
packages.each do |pkg|
|
||||||
@status.operations[:"#{pkg.checksum}"] = Status::Operation.new(
|
@status.operations[:"#{pkg.checksum}"] = Status::Operation.new(
|
||||||
label: pkg.name,
|
label: pkg.name,
|
||||||
value: "Pending",
|
value: "Pending...",
|
||||||
progress: 0.0
|
progress: 0.0
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@status.step = :unpacking
|
@status.step = :unpacking
|
||||||
|
|
||||||
# TODO: Add support for patches
|
|
||||||
packages.each do |package|
|
packages.each do |package|
|
||||||
puts " #{package.name}:#{package.version}"
|
status = if package.custom_is_patch
|
||||||
package_path = Cache.package_path(package.category, package.subcategory, "#{package.name}.zip", package.version)
|
@status.operations[:"#{package.checksum}"].value = "Patching..."
|
||||||
|
update_interface_task_status
|
||||||
|
|
||||||
puts " Running #{W3DHub.tar_command} command: #{"#{W3DHub.tar_command} -xf #{package_path} -C #{path}"}"
|
apply_patch(package)
|
||||||
status = system("#{W3DHub.tar_command} -xf #{package_path} -C #{path}")
|
else
|
||||||
|
@status.operations[:"#{package.checksum}"].value = "Unpacking..."
|
||||||
|
update_interface_task_status
|
||||||
|
|
||||||
|
unpack_package(package)
|
||||||
|
end
|
||||||
|
|
||||||
if status
|
if status
|
||||||
@status.operations[:"#{pkg.checksum}"].value = "Unpacked"
|
@status.operations[:"#{package.checksum}"].value = "Unpacked"
|
||||||
@status.operations[:"#{pkg.checksum}"].progress = 1.0
|
@status.operations[:"#{package.checksum}"].progress = 1.0
|
||||||
|
|
||||||
update_interface_task_status
|
update_interface_task_status
|
||||||
else
|
else
|
||||||
@@ -440,6 +447,7 @@ class W3DHub
|
|||||||
package.checksum_chunks.each do |chunk_start, checksum|
|
package.checksum_chunks.each do |chunk_start, checksum|
|
||||||
i += 1
|
i += 1
|
||||||
operation&.progress = i.to_f / chunks
|
operation&.progress = i.to_f / chunks
|
||||||
|
update_interface_task_status
|
||||||
|
|
||||||
chunk_start = Integer(chunk_start.to_s)
|
chunk_start = Integer(chunk_start.to_s)
|
||||||
|
|
||||||
@@ -471,6 +479,24 @@ class W3DHub
|
|||||||
def load_manifest(category, subcategory, name, version)
|
def load_manifest(category, subcategory, name, version)
|
||||||
Manifest.new(category, subcategory, name, version)
|
Manifest.new(category, subcategory, name, version)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unpack_package(package)
|
||||||
|
puts " #{package.name}:#{package.version}"
|
||||||
|
package_path = Cache.package_path(package.category, package.subcategory, "#{package.name}.zip", package.version)
|
||||||
|
|
||||||
|
puts " Running #{W3DHub.tar_command} command: #{"#{W3DHub.tar_command} -xf #{package_path} -C #{path}"}"
|
||||||
|
return system("#{W3DHub.tar_command} -xf #{package_path} -C #{path}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def apply_patch(package)
|
||||||
|
# Unpack patch to a known directory
|
||||||
|
# Load MIX1 file
|
||||||
|
# Read and Parse .w3dhub.patch json file
|
||||||
|
# Load target MIX1 (.mix and .dat)
|
||||||
|
# Update and remove files
|
||||||
|
# Overwrite updated file
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -53,14 +53,10 @@ class W3DHub
|
|||||||
@operations_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
|
# TODO: Show actual list of downloads
|
||||||
|
|
||||||
p ["DOWNLOAD MANAGER", task.status.operations.size]
|
|
||||||
|
|
||||||
i = -1
|
i = -1
|
||||||
task.status.operations.each do |key, operation|
|
task.status.operations.each do |key, operation|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
p [key, operation.label]
|
|
||||||
|
|
||||||
stack(width: 1.0, height: 24, padding: 8) do
|
stack(width: 1.0, height: 24, padding: 8) do
|
||||||
background 0xff_333333 if i.odd?
|
background 0xff_333333 if i.odd?
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class W3DHub
|
|||||||
class States
|
class States
|
||||||
class Interface < CyberarmEngine::GuiState
|
class Interface < CyberarmEngine::GuiState
|
||||||
attr_reader :main_thread_queue
|
attr_reader :main_thread_queue
|
||||||
|
attr_accessor :interface_task_update_pending
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
window.show_cursor = true
|
window.show_cursor = true
|
||||||
@@ -10,6 +11,8 @@ class W3DHub
|
|||||||
@service_status = @options[:service_status]
|
@service_status = @options[:service_status]
|
||||||
@applications = @options[:applications]
|
@applications = @options[:applications]
|
||||||
|
|
||||||
|
@interface_task_update_pending = nil
|
||||||
|
|
||||||
@page = nil
|
@page = nil
|
||||||
@pages = {}
|
@pages = {}
|
||||||
|
|
||||||
@@ -141,6 +144,8 @@ class W3DHub
|
|||||||
while(block = @main_thread_queue.shift)
|
while(block = @main_thread_queue.shift)
|
||||||
block&.call
|
block&.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
update_interface_task_status(@interface_task_update_pending) if @interface_task_update_pending
|
||||||
end
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user