mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 01:02:34 +00:00
Initial work launcher (self) updater
This commit is contained in:
@@ -51,7 +51,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
stack(width: 128, height: 48, h_align: :center, margin_top: 16) do
|
stack(width: 128, max_height: 256, h_align: :center, margin_top: 16, fill: true) do
|
||||||
button "Save", width: 1.0 do
|
button "Save", width: 1.0 do
|
||||||
save_settings!
|
save_settings!
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class W3DHub
|
|||||||
@w3dhub_logo = get_image("#{GAME_ROOT_PATH}/media/icons/app.png")
|
@w3dhub_logo = get_image("#{GAME_ROOT_PATH}/media/icons/app.png")
|
||||||
@tasks = {
|
@tasks = {
|
||||||
# connectivity_check: { started: false, complete: false }, # HEAD connectivity-check.ubuntu.com or HEAD secure.w3dhub.com?
|
# connectivity_check: { started: false, complete: false }, # HEAD connectivity-check.ubuntu.com or HEAD secure.w3dhub.com?
|
||||||
|
# launcher_updater: { started: false, complete: false },
|
||||||
server_list: { started: false, complete: false },
|
server_list: { started: false, complete: false },
|
||||||
refresh_user_token: { started: false, complete: false },
|
refresh_user_token: { started: false, complete: false },
|
||||||
service_status: { started: false, complete: false },
|
service_status: { started: false, complete: false },
|
||||||
@@ -159,6 +160,32 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def launcher_updater
|
||||||
|
@status_label.value = "Checking for Launcher updates..." # I18n.t(:"boot.checking_for_updates")
|
||||||
|
|
||||||
|
Api.on_thread(:fetch, "https://api.github.com/repos/Inq8/CAmod/releases/latest") do |response|
|
||||||
|
if response.status == 200
|
||||||
|
hash = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
available_version = hash[:tag_name].downcase.sub("v", "")
|
||||||
|
|
||||||
|
pp Gem::Version.new(available_version) > Gem::Version.new(W3DHub::VERSION)
|
||||||
|
pp [Gem::Version.new(available_version), Gem::Version.new(W3DHub::VERSION)]
|
||||||
|
|
||||||
|
push_state(
|
||||||
|
LauncherUpdaterDialog,
|
||||||
|
release_data: hash,
|
||||||
|
available_version: available_version,
|
||||||
|
cancel_callback: -> { @tasks[:launcher_updater][:complete] = true },
|
||||||
|
accept_callback: -> { @tasks[:launcher_updater][:complete] = true }
|
||||||
|
)
|
||||||
|
else
|
||||||
|
# Failed to retrieve release data from github
|
||||||
|
log "Failed to retrieve release data from Github"
|
||||||
|
@tasks[:launcher_updater][:complete] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def applications
|
def applications
|
||||||
@status_label.value = I18n.t(:"boot.checking_for_updates")
|
@status_label.value = I18n.t(:"boot.checking_for_updates")
|
||||||
|
|
||||||
|
|||||||
62
lib/states/dialogs/launcher_updater_dialog.rb
Normal file
62
lib/states/dialogs/launcher_updater_dialog.rb
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
class W3DHub
|
||||||
|
class States
|
||||||
|
class LauncherUpdaterDialog < Dialog
|
||||||
|
BUTTON_STYLE = { text_size: 18, padding_top: 3, padding_bottom: 3, padding_left: 3, padding_right: 3, height: 18 }
|
||||||
|
LIST_ITEM_THEME = Marshal.load(Marshal.dump(THEME))
|
||||||
|
BUTTON_STYLE.each do |key, value|
|
||||||
|
LIST_ITEM_THEME[:Button][key] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup
|
||||||
|
window.show_cursor = true
|
||||||
|
|
||||||
|
theme(THEME)
|
||||||
|
|
||||||
|
background 0xaa_525252
|
||||||
|
|
||||||
|
stack(width: 1.0, max_width: 760, height: 1.0, max_height: 640, v_align: :center, h_align: :center, background: 0xee_222222, border_thickness: 2, border_color: 0xee_222222, padding: 16) do
|
||||||
|
flow(width: 1.0, height: 36, padding: 8) do
|
||||||
|
background 0xff_0052c0
|
||||||
|
|
||||||
|
title @options[:title] || "Launcher Update Available", fill: true, text_align: :center, font: BOLD_FONT
|
||||||
|
end
|
||||||
|
|
||||||
|
stack(width: 1.0, fill: true, margin_top: 14) do
|
||||||
|
subtitle "Release Notes - #{@options[:available_version]}"
|
||||||
|
|
||||||
|
# case launcher_release_type
|
||||||
|
# when :git
|
||||||
|
# when :tebako
|
||||||
|
# end
|
||||||
|
|
||||||
|
pp @options[:release_data]
|
||||||
|
|
||||||
|
stack(width: 1.0, fill: true, scroll: true, padding: 8, border_thickness: 1, border_color: 0x44_ffffff) do
|
||||||
|
# para @options[:release_data][:body], width: 1.0
|
||||||
|
# FIXME: Finish this bit
|
||||||
|
@options[:release_data][:body].lines.each do |line|
|
||||||
|
line.strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(width: 1.0, height: 46, margin_top: 16) do
|
||||||
|
background 0xff_ffffff
|
||||||
|
|
||||||
|
button "Cancel", width: 0.25 do
|
||||||
|
pop_state
|
||||||
|
@options[:cancel_callback]&.call
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(fill: true)
|
||||||
|
|
||||||
|
button "Update", width: 0.25 do
|
||||||
|
pop_state
|
||||||
|
@options[:accept_callback]&.call
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -121,6 +121,7 @@ require_relative "lib/states/dialogs/confirm_dialog"
|
|||||||
require_relative "lib/states/dialogs/direct_connect_dialog"
|
require_relative "lib/states/dialogs/direct_connect_dialog"
|
||||||
require_relative "lib/states/dialogs/game_settings_dialog"
|
require_relative "lib/states/dialogs/game_settings_dialog"
|
||||||
require_relative "lib/states/dialogs/import_game_dialog"
|
require_relative "lib/states/dialogs/import_game_dialog"
|
||||||
|
require_relative "lib/states/dialogs/launcher_updater_dialog"
|
||||||
|
|
||||||
require_relative "lib/api"
|
require_relative "lib/api"
|
||||||
require_relative "lib/api/service_status"
|
require_relative "lib/api/service_status"
|
||||||
|
|||||||
Reference in New Issue
Block a user