mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-04 17:14:06 +00:00
Compare commits
17 Commits
1590922bc5
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| aa1145f1dc | |||
| 13d6c3339b | |||
| 002b77d2d8 | |||
| 6ac2477803 | |||
| ff9fcc5b5f | |||
| 16742ea5fa | |||
| 073f5bebf9 | |||
| 57287de742 | |||
| 99dc27ced2 | |||
| de6bfb85f5 | |||
| 4bfb494abe | |||
| 3bc2b45823 | |||
| cb80364e68 | |||
| ec3b1fa068 | |||
| c0dedac4a4 | |||
| 13a782aabf | |||
| 92b2e34f25 |
@@ -57,7 +57,7 @@ GEM
|
|||||||
io-stream (0.14.0)
|
io-stream (0.14.0)
|
||||||
openssl (>= 3.3)
|
openssl (>= 3.3)
|
||||||
ircparser (1.0.0)
|
ircparser (1.0.0)
|
||||||
json (3.0.2)
|
json (3.1.0)
|
||||||
logger (1.7.0)
|
logger (1.7.0)
|
||||||
openssl (4.0.2)
|
openssl (4.0.2)
|
||||||
protocol-hpack (1.5.1)
|
protocol-hpack (1.5.1)
|
||||||
@@ -140,7 +140,7 @@ CHECKSUMS
|
|||||||
io-event (1.22.1) sha256=0dd054cefe4a29f1b8286604f332c14f3208d75f54902961e91e94d45e5e1600
|
io-event (1.22.1) sha256=0dd054cefe4a29f1b8286604f332c14f3208d75f54902961e91e94d45e5e1600
|
||||||
io-stream (0.14.0) sha256=07d9b13ea2066ccbbc761fff8d69ad5a31e47561d31e02cc271f3ed9c1a8f1cd
|
io-stream (0.14.0) sha256=07d9b13ea2066ccbbc761fff8d69ad5a31e47561d31e02cc271f3ed9c1a8f1cd
|
||||||
ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d
|
ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d
|
||||||
json (3.0.2) sha256=8e6d7e7b11384c21230430cef90b71f14849a34a1f4452796670f7c981bd19df
|
json (3.1.0) sha256=3ce7ccf8fde58960177a3a756c31f292a4c1e1dedee884547096a5b0604e3bd8
|
||||||
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
||||||
openssl (4.0.2) sha256=1037ad2868ae58df9ad917891c0c0f9815a1172f6846d4bcdd508e4c2ee747c2
|
openssl (4.0.2) sha256=1037ad2868ae58df9ad917891c0c0f9815a1172f6846d4bcdd508e4c2ee747c2
|
||||||
protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91
|
protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91
|
||||||
|
|||||||
@@ -6,4 +6,21 @@ module W3DHubLauncher
|
|||||||
"/etc/ssl/ca-bundle.pem" # Some other distros
|
"/etc/ssl/ca-bundle.pem" # Some other distros
|
||||||
].find { |path| File.exist?(path) }
|
].find { |path| File.exist?(path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.format_size(bytes)
|
||||||
|
case bytes
|
||||||
|
when 0..1023 # Bytes
|
||||||
|
"#{bytes} B"
|
||||||
|
when 1024..1_048_575 # KiloBytes
|
||||||
|
"#{format_size_number(bytes / 1024.0)} KB"
|
||||||
|
when 1_048_576..1_073_741_999 # MegaBytes
|
||||||
|
"#{format_size_number(bytes / 1_048_576.0)} MB"
|
||||||
|
else # GigaBytes
|
||||||
|
"#{format_size_number(bytes / 1_073_742_000.0)} GB"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.format_size_number(i)
|
||||||
|
format("%0.2f", i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,13 +10,70 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
stack(style_class: [:dialog_container]) do
|
stack(style_class: [:dialog_container]) do
|
||||||
button "Sign In", tip: "https://sso.w3d.cyberarm.dev" do
|
title "Sign in with your W3D Hub forum account", margin_bottom: PADDING
|
||||||
# use SSO service
|
|
||||||
pop_state
|
tagline "Username"
|
||||||
|
@username = edit_line "", width: 1.0
|
||||||
|
|
||||||
|
tagline "Password"
|
||||||
|
@password = edit_line "", type: :password, width: 1.0
|
||||||
|
|
||||||
|
flow(width: 1.0, margin_top: LARGE_PADDING, margin_bottom: LARGE_PADDING) do
|
||||||
|
flow(fill: true, height: 2, v_align: :center, background: 0xff_000000)
|
||||||
|
|
||||||
|
tagline "OR", margin_left: HALF_PADDING, margin_right: HALF_PADDING
|
||||||
|
|
||||||
|
flow(fill: true, height: 2, v_align: :center, background: 0xff_000000)
|
||||||
|
end
|
||||||
|
|
||||||
|
tagline "Sign in with access token"
|
||||||
|
flow(width: 1.0) do
|
||||||
|
edit_line "", fill: true, enabled: false
|
||||||
|
button "Get token", tip: "https://sso.w3d.cyberarm.dev/account/token", enabled: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
|
button "Cancel" do
|
||||||
|
pop_state
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(fill: true)
|
||||||
|
|
||||||
|
button "Register", tip: "https://w3dhub.com/forum/register/" do
|
||||||
|
SDL.OpenURL("https://w3dhub.com/forum/register/")
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(fill: true)
|
||||||
|
|
||||||
|
button "Sign In", **CTA_BUTTON_THEME do |btn|
|
||||||
|
# use SSO service, eventually. , tip: "https://sso.w3d.cyberarm.dev"
|
||||||
|
|
||||||
|
btn.enabled = false
|
||||||
|
|
||||||
|
Worker::Api.user_login(@username.value, @password.value) do |result|
|
||||||
|
if result.okay?
|
||||||
|
hash = JSON.parse(result.data)
|
||||||
|
|
||||||
|
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.new(hash)
|
||||||
|
|
||||||
|
Worker::Api.update_settings(MemCache[:settings]) do |settings_result|
|
||||||
|
if settings_result.okay?
|
||||||
|
on_main_thread(-> {
|
||||||
|
pop_state
|
||||||
|
window.current_state&.populate_account_information
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME: Retry? Show error? ???
|
||||||
|
pp settings_result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME: Show error message!
|
||||||
|
pp result
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
29
lib/dialogs/asterisk.rb
Normal file
29
lib/dialogs/asterisk.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
module W3DHubLauncher
|
||||||
|
class Dialog
|
||||||
|
class Asterisk < W3DHubLauncher::Dialog
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
|
||||||
|
stack(width: 1.0, max_width: 600, height: 1.0, max_height: 600, style_class: [:dialog]) do
|
||||||
|
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
|
banner "Direct Connect", width: 1.0, text_align: :center
|
||||||
|
end
|
||||||
|
|
||||||
|
stack(style_class: [:dialog_container]) do
|
||||||
|
banner "Coming soon!"
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
|
flow(fill: true)
|
||||||
|
|
||||||
|
button "Close", **CTA_BUTTON_THEME do
|
||||||
|
pop_state
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(fill: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
0
lib/dialogs/asterisk/.gitkeep
Normal file
0
lib/dialogs/asterisk/.gitkeep
Normal file
@@ -1,100 +1,31 @@
|
|||||||
module W3DHubLauncher
|
module W3DHubLauncher
|
||||||
class Dialog
|
class Dialog
|
||||||
class LauncherSettings < W3DHubLauncher::Dialog
|
class LauncherSettings < W3DHubLauncher::Dialog
|
||||||
|
include W3DHubLauncher::Form::SettingsForm
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
stack(width: 0.75, max_width: 1280, height: 0.75, max_height: 800, style_class: [:dialog]) do
|
stack(width: 0.75, max_width: 1280, height: 0.75, max_height: 800, style_class: [:dialog], padding_left: PADDING, padding_right: PADDING) do |e|
|
||||||
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
banner "Launcher Settings", width: 1.0, text_align: :center
|
banner "Launcher Settings", width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
item_height = 40 + PADDING
|
form_setup
|
||||||
settings = MemCache[:settings]
|
|
||||||
|
|
||||||
stack(width: 1.0, fill: true, scroll: true, margin_left: PADDING, margin_right: PADDING, padding: HALF_PADDING, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_BLACK) do
|
flow(width: 1.0, padding_top: PADDING, padding_bottom: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
flow(width: 1.0, height: item_height, margin_top: PADDING) do
|
|
||||||
tagline "Nickname", height: 1.0, text_v_align: :center
|
|
||||||
@nickname = edit_line settings&.preferences&.nickname || Etc.getlogin, fill: true
|
|
||||||
end
|
|
||||||
inscription "Nickname to use when joining servers.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Launcher package cache directory", height: 1.0, text_v_align: :center
|
|
||||||
@launcher_package_cache_directory = edit_line settings&.preferences&.launcher_package_cache_directory || DEFAULT_PACKAGE_CACHE_PATH, fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Location where the launcher will download application packages.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Application installation directory", height: 1.0, text_v_align: :center
|
|
||||||
@application_installation_directory = edit_line settings&.preferences&.application_installation_directory || DEFAULT_APPLICATIONS_PATH, fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Location where the launcher will install new applications.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Wine prefix path", height: 1.0, text_v_align: :center
|
|
||||||
@wine_prefix_path = edit_line settings&.preferences&.wine_prefix_path || "", fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Location of wine prefix to use. Leave blank to use default.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Wine command", height: 1.0, text_v_align: :center
|
|
||||||
@wine_command = edit_line settings&.preferences&.wine_command || "wine", fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Path to wine executable. Use <c=f80>wine</c> for system installed wine.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Winetricks command", height: 1.0, text_v_align: :center
|
|
||||||
@winetricks_command = edit_line settings&.preferences&.winetricks_command || "winetricks", fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Path to winetricks executable. Use <c=f80>winetricks</c> for system installed winetricks.", margin_left: PADDING
|
|
||||||
end
|
|
||||||
|
|
||||||
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
|
||||||
button "Close" do
|
button "Close" do
|
||||||
pop_state
|
pop_state
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(fill: true)
|
flow(fill: true)
|
||||||
|
|
||||||
button "Save", **CTA_BUTTON_THEME do |btn|
|
@accept_button = button "Save", **CTA_BUTTON_THEME do |btn|
|
||||||
btn.enabled = false
|
form_commit(btn)
|
||||||
|
|
||||||
settings = MemCache[:settings]
|
|
||||||
|
|
||||||
# update user preferences
|
|
||||||
settings.preferences.nickname = @nickname.value.strip
|
|
||||||
settings.preferences.launcher_package_cache_directory = @launcher_package_cache_directory.value.strip
|
|
||||||
settings.preferences.application_installation_directory = @application_installation_directory.value.strip
|
|
||||||
settings.preferences.wine_prefix_path = @wine_prefix_path.value.strip
|
|
||||||
settings.preferences.wine_command = @wine_command.value.strip
|
|
||||||
settings.preferences.winetricks_command = @winetricks_command.value.strip
|
|
||||||
|
|
||||||
Worker::Api.update_settings(settings) do |result|
|
|
||||||
if result.okay?
|
|
||||||
on_main_thread(proc {
|
|
||||||
MemCache[:settings] = settings
|
|
||||||
pop_state
|
|
||||||
})
|
|
||||||
else
|
|
||||||
# FIXME: Somehow something went wrong... show an error message.
|
|
||||||
btn.enabled = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: Check settings for validity before saving
|
|
||||||
def valid?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
116
lib/forms/settings_form.rb
Normal file
116
lib/forms/settings_form.rb
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
module W3DHubLauncher
|
||||||
|
module Form
|
||||||
|
module SettingsForm
|
||||||
|
include GuiExt
|
||||||
|
|
||||||
|
def form_setup(settings = MemCache[:settings])
|
||||||
|
item_height = 40 + PADDING - HALF_PADDING
|
||||||
|
|
||||||
|
stack(width: 1.0, fill: true, scroll: true, padding: HALF_PADDING, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_BLACK) do
|
||||||
|
flow(width: 1.0, height: item_height - HALF_PADDING) do
|
||||||
|
tagline "Nickname", height: 1.0, text_v_align: :center
|
||||||
|
@nickname = edit_line settings&.preferences&.nickname || Etc.getlogin, fill: true, filter: method(:form_filter_nickname)
|
||||||
|
end
|
||||||
|
inscription "Nickname to use when joining servers. Nickname must be a least 3 characters long and no more than 40. Only A-z, 0-9, _, -, and [] characters allowed.", margin_left: PADDING
|
||||||
|
|
||||||
|
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
||||||
|
tagline "Launcher package cache directory", height: 1.0, text_v_align: :center
|
||||||
|
@launcher_package_cache_directory = edit_line settings&.preferences&.launcher_package_cache_directory || DEFAULT_PACKAGE_CACHE_PATH, fill: true
|
||||||
|
button "Browse..." do
|
||||||
|
Gosu.choose_file do |result|
|
||||||
|
pp result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
inscription "Location where the launcher will download application packages.", margin_left: PADDING
|
||||||
|
|
||||||
|
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
||||||
|
tagline "Application installation directory", height: 1.0, text_v_align: :center
|
||||||
|
@application_installation_directory = edit_line settings&.preferences&.application_installation_directory || DEFAULT_APPLICATIONS_PATH, fill: true
|
||||||
|
button "Browse..." do
|
||||||
|
Gosu.choose_file do |result|
|
||||||
|
pp result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
inscription "Location where the launcher will install new applications.", margin_left: PADDING
|
||||||
|
|
||||||
|
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
||||||
|
tagline "Wine prefix path", height: 1.0, text_v_align: :center
|
||||||
|
@wine_prefix_path = edit_line settings&.preferences&.wine_prefix_path || "", fill: true
|
||||||
|
button "Browse..." do
|
||||||
|
Gosu.choose_file do |result|
|
||||||
|
pp result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
inscription "Location of wine prefix to use. Leave blank to use default.", margin_left: PADDING
|
||||||
|
|
||||||
|
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
||||||
|
tagline "Wine command", height: 1.0, text_v_align: :center
|
||||||
|
@wine_command = edit_line settings&.preferences&.wine_command || "wine", fill: true
|
||||||
|
button "Browse..." do
|
||||||
|
Gosu.choose_file do |result|
|
||||||
|
pp result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
inscription "Path to wine executable. Use <c=f80>wine</c> for system installed wine.", margin_left: PADDING
|
||||||
|
|
||||||
|
flow(width: 1.0, height: item_height, margin_top: HALF_PADDING) do
|
||||||
|
tagline "Winetricks command", height: 1.0, text_v_align: :center
|
||||||
|
@winetricks_command = edit_line settings&.preferences&.winetricks_command || "winetricks", fill: true
|
||||||
|
button "Browse..." do
|
||||||
|
Gosu.choose_file do |result|
|
||||||
|
pp result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
inscription "Path to winetricks executable. Use <c=f80>winetricks</c> for system installed winetricks.", margin_left: PADDING
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_commit(btn)
|
||||||
|
btn.enabled = false
|
||||||
|
|
||||||
|
@settings = MemCache[:settings]
|
||||||
|
|
||||||
|
# update user preferences
|
||||||
|
@settings.preferences.nickname = @nickname.value.strip
|
||||||
|
@settings.preferences.launcher_package_cache_directory = @launcher_package_cache_directory.value.strip
|
||||||
|
@settings.preferences.application_installation_directory = @application_installation_directory.value.strip
|
||||||
|
@settings.preferences.wine_prefix_path = @wine_prefix_path.value.strip
|
||||||
|
@settings.preferences.wine_command = @wine_command.value.strip
|
||||||
|
@settings.preferences.winetricks_command = @winetricks_command.value.strip
|
||||||
|
|
||||||
|
Worker::Api.update_settings(@settings) do |result|
|
||||||
|
if result.okay?
|
||||||
|
on_main_thread(proc {
|
||||||
|
MemCache[:settings] = @settings
|
||||||
|
pop_state
|
||||||
|
})
|
||||||
|
else
|
||||||
|
# FIXME: Somehow something went wrong... show an error message.
|
||||||
|
btn.enabled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_valid?
|
||||||
|
form_valid_nickname?(@nickname.value)
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_filter_nickname(entry)
|
||||||
|
if @nickname.value.length + 1 <= 40 && (entry =~ /^[a-z0-9_\-\[\]]+$/i)
|
||||||
|
entry
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_valid_nickname?(value)
|
||||||
|
value.length.between?(3, 40) && (value =~ /^[a-z0-9_\-\[\]]+$/i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3,87 +3,27 @@ module W3DHubLauncher
|
|||||||
module Boot
|
module Boot
|
||||||
class InitialSetup < CyberarmEngine::Page
|
class InitialSetup < CyberarmEngine::Page
|
||||||
include GuiExt
|
include GuiExt
|
||||||
|
include W3DHubLauncher::Form::SettingsForm
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
stack(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: 8, background_nine_slice_color: 0x11_ffffff, padding: HALF_PADDING) do
|
# initialize default settings
|
||||||
|
@settings = Worker::Api::Settings.new({})
|
||||||
|
|
||||||
|
stack(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: 8, background_nine_slice_color: 0x11_ffffff, padding: HALF_PADDING) do
|
||||||
banner "Welcome to #{NAME}", width: 1.0, text_align: :center
|
banner "Welcome to #{NAME}", width: 1.0, text_align: :center
|
||||||
tagline "Your gateway to the world of W3D Hub games.", width: 1.0, text_align: :center
|
tagline "Your gateway to the world of W3D Hub games.", width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
stack(width: 1.0, fill: true, padding: PADDING) do
|
stack(width: 1.0, fill: true, padding: PADDING) do |e|
|
||||||
stack(width: 1.0, fill: true, scroll: true) do
|
title "Initial Setup"
|
||||||
title "Initial Setup"
|
caption "Please confirm launcher's default settings and make any desired adjustments. These can be changed in the launcher settings later.", font: FONT_REGULAR, margin_left: PADDING
|
||||||
caption "Please confirm launcher's default settings and make any desired adjustments. These can be changed in the launcher settings later.", font: FONT_REGULAR, margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: PADDING) do
|
form_setup(nil)
|
||||||
tagline "Nickname", height: 1.0, text_v_align: :center
|
|
||||||
@nickname = edit_line Etc.getlogin, fill: true
|
|
||||||
end
|
|
||||||
inscription "Nickname to use when joining servers.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Launcher package cache directory", height: 1.0, text_v_align: :center
|
|
||||||
@launcher_package_cache_directory = edit_line DEFAULT_PACKAGE_CACHE_PATH, fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Location where the launcher will download application packages.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Application installation directory", height: 1.0, text_v_align: :center
|
|
||||||
@application_installation_directory = edit_line DEFAULT_APPLICATIONS_PATH, fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Location where the launcher will install new applications.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Wine prefix path", height: 1.0, text_v_align: :center
|
|
||||||
@wine_prefix_path = edit_line "", fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Location of wine prefix to use. Leave blank to use default.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Wine command", height: 1.0, text_v_align: :center
|
|
||||||
@wine_command = edit_line "wine", fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Path to wine executable. Use <c=f80>wine</c> for system installed wine.", margin_left: PADDING
|
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
|
||||||
tagline "Winetricks command", height: 1.0, text_v_align: :center
|
|
||||||
@winetricks_command = edit_line "winetricks", fill: true
|
|
||||||
button "Browse..."
|
|
||||||
end
|
|
||||||
inscription "Path to winetricks executable. Use <c=f80>winetricks</c> for system installed winetricks.", margin_left: PADDING
|
|
||||||
end
|
|
||||||
|
|
||||||
flow(width: 1.0, padding_top: PADDING) do
|
flow(width: 1.0, padding_top: PADDING) do
|
||||||
flow(fill: true)
|
flow(fill: true)
|
||||||
button "Accept", **CTA_BUTTON_THEME do |btn|
|
@accept_button = button "Accept", **CTA_BUTTON_THEME do |btn|
|
||||||
btn.enabled = false
|
form_commit(btn)
|
||||||
|
|
||||||
# initialize default settings
|
|
||||||
settings = Worker::Api::Settings.new({})
|
|
||||||
|
|
||||||
# update user preferences
|
|
||||||
settings.preferences.nickname = @nickname.value.strip
|
|
||||||
settings.preferences.launcher_package_cache_directory = @launcher_package_cache_directory.value.strip
|
|
||||||
settings.preferences.application_installation_directory = @application_installation_directory.value.strip
|
|
||||||
settings.preferences.wine_prefix_path = @wine_prefix_path.value.strip
|
|
||||||
settings.preferences.wine_command = @wine_command.value.strip
|
|
||||||
settings.preferences.winetricks_command = @winetricks_command.value.strip
|
|
||||||
|
|
||||||
Worker::Api.update_settings(settings) do |result|
|
|
||||||
if result.okay?
|
|
||||||
on_main_thread(proc {
|
|
||||||
MemCache[:settings] = settings
|
|
||||||
page(Page::Boot::StartUp)
|
|
||||||
})
|
|
||||||
else
|
|
||||||
# FIXME: Somehow something went wrong... show an error message.
|
|
||||||
btn.enabled = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module W3DHubLauncher
|
|||||||
@initialization_acceptable = false
|
@initialization_acceptable = false
|
||||||
@step_count = @steps.size
|
@step_count = @steps.size
|
||||||
|
|
||||||
stack(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: 8, background_nine_slice_color: 0x11_ffffff, padding: HALF_PADDING) do
|
stack(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: 8, background_nine_slice_color: 0x11_ffffff, padding: HALF_PADDING) do
|
||||||
banner "Establishing Battlefield Control", width: 1.0, text_align: :center
|
banner "Establishing Battlefield Control", width: 1.0, text_align: :center
|
||||||
tagline "Please stand by...", width: 1.0, text_align: :center
|
tagline "Please stand by...", width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module W3DHubLauncher
|
|||||||
TERMS
|
TERMS
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: 8, background_nine_slice_color: 0x11_ffffff, padding: HALF_PADDING) do
|
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: 8, background_nine_slice_color: 0x11_ffffff, padding: HALF_PADDING) do
|
||||||
banner "Terms and Conditions", width: 1.0, text_align: :center
|
banner "Terms and Conditions", width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ module W3DHubLauncher
|
|||||||
class Games < CyberarmEngine::Page
|
class Games < CyberarmEngine::Page
|
||||||
include GuiExt
|
include GuiExt
|
||||||
|
|
||||||
|
GAME_COVER_ASPECT_RATIO = 3 / 4.0
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@games = MemCache[:applications]&.select { |app| app.type.include?("game") } || []
|
@games = MemCache[:applications]&.select { |app| app.type.include?("game") } || []
|
||||||
|
|
||||||
@@ -78,15 +80,46 @@ module W3DHubLauncher
|
|||||||
def populate_all_games
|
def populate_all_games
|
||||||
@display_mode = :all_games
|
@display_mode = :all_games
|
||||||
|
|
||||||
|
img = safe_get_image("#{ROOT_PATH}/media/default_game_cover.png")
|
||||||
|
|
||||||
@game_content_container.clear do
|
@game_content_container.clear do
|
||||||
flow(fill: true, height: 1.0, scroll: true, tag: :hi_mom) do |e|
|
flow(fill: true, height: 1.0, scroll: true, tag: :hi_mom) do |e|
|
||||||
|
|
||||||
|
width = img.height * (GAME_COVER_ASPECT_RATIO * (1.0 / game_cover_width_ratio(e)))
|
||||||
|
height = img.width / (GAME_COVER_ASPECT_RATIO)
|
||||||
|
|
||||||
@games.each do |app|
|
@games.each do |app|
|
||||||
image safe_get_image("#{ROOT_PATH}/media/default_game_cover.png"), aspect_ratio: 3 / 4.0, width: 1.0 / game_cover_width_ratio(e), margin_left: HALF_PADDING, margin_right: HALF_PADDING, margin_bottom: PADDING, tip: app.name
|
w = widget(
|
||||||
|
background_image: img,
|
||||||
|
aspect_ratio: 3 / 4.0,
|
||||||
|
width: width.round,
|
||||||
|
height: height.round,
|
||||||
|
margin_left: HALF_PADDING,
|
||||||
|
margin_right: HALF_PADDING,
|
||||||
|
margin_bottom: PADDING,
|
||||||
|
tip: app.name
|
||||||
|
) do
|
||||||
|
image safe_get_image("#{CACHE_PATH}/logo_#{app.id}.png"), width: 1.0, padding: LARGE_PADDING
|
||||||
|
end
|
||||||
|
|
||||||
|
w.subscribe(:clicked_left_mouse_button) do
|
||||||
|
channel = app.channels.find { |c| c.name.downcase == "release" } ||
|
||||||
|
app.channels.find { |c| c.name.downcase == "testing" } ||
|
||||||
|
app.channels.first
|
||||||
|
|
||||||
|
populate_game(app, channel)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
e.subscribe(:size_changed) do |e|
|
e.subscribe(:size_changed) do |e|
|
||||||
e.children.each do |child|
|
e.children.each do |child|
|
||||||
child.style.width = 1.0 / game_cover_width_ratio(e)
|
img = child.background_image_canvas.image
|
||||||
|
|
||||||
|
width = e.width * (1.0 / game_cover_width_ratio(e))
|
||||||
|
height = (width / GAME_COVER_ASPECT_RATIO)
|
||||||
|
|
||||||
|
child.style.width = width
|
||||||
|
child.style.height = height
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -322,7 +355,9 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def game_cover_width_ratio(e)
|
def game_cover_width_ratio(e)
|
||||||
(e.width / 300.0).round.clamp(1..10)
|
return 1.0 if e.width.zero?
|
||||||
|
|
||||||
|
(e.width / 380.0).round.clamp(1..10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def news_item_width_ratio
|
def news_item_width_ratio
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button(safe_get_image("#{ROOT_PATH}/media/icons/target.png"), image_height: 1.0, tip: "Direct Connect", padding: HALF_PADDING, enabled: false, margin_left: PADDING) do
|
button(safe_get_image("#{ROOT_PATH}/media/icons/target.png"), image_height: 1.0, tip: "Direct Connect", padding: HALF_PADDING, margin_left: PADDING) do
|
||||||
dialog(Dialog::DirectConnect)
|
dialog(Dialog::Asterisk)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ module W3DHubLauncher
|
|||||||
# TODO: Sort servers?
|
# TODO: Sort servers?
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_game_server_list
|
def handle_game_server_list(payload)
|
||||||
after(1_000) do
|
after(1_000) do
|
||||||
populate_server_list
|
populate_server_list
|
||||||
end
|
end
|
||||||
@@ -191,7 +191,9 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
w.subscribe(:clicked_left_mouse_button) do
|
w.subscribe(:clicked_left_mouse_button) do
|
||||||
@parent.populate_server_information(server)
|
current_server = (MemCache[:servers] || []).find { |s| s.id == server.id }
|
||||||
|
|
||||||
|
@parent.populate_server_information(current_server)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,10 +38,11 @@ module W3DHubLauncher
|
|||||||
link("GAMES",height: 1.0, text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::Games) }
|
link("GAMES",height: 1.0, text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::Games) }
|
||||||
link("SERVERS",height: 1.0, text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::ServerBrowser) }
|
link("SERVERS",height: 1.0, text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::ServerBrowser) }
|
||||||
stack(fill: true)
|
stack(fill: true)
|
||||||
image safe_get_image("#{ROOT_PATH}/media/icons/import.png"), height: 40, color: 0xff_bbbbbb, tip: "Downloads" do |img|
|
stack(v_align: :center) do
|
||||||
dialog(Dialog::Downloads)
|
button safe_get_image("#{ROOT_PATH}/media/icons/import.png"), image_height: 40, color: 0xff_bbbbbb, padding_left: QUARTER_PADDING, padding_right: QUARTER_PADDING, tip: "Downloads" do |img|
|
||||||
|
dialog(Dialog::Downloads)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
image safe_get_image("#{ROOT_PATH}/media/icons/information.png"), height: 40, color: 0xff_bbbbbb, tip: "Notifications"
|
|
||||||
end
|
end
|
||||||
# application task status bar container
|
# application task status bar container
|
||||||
@application_task_status_bar_container = stack(width: 1.0, fill: true, margin_left: PADDING, visible: false) do
|
@application_task_status_bar_container = stack(width: 1.0, fill: true, margin_left: PADDING, visible: false) do
|
||||||
@@ -56,32 +57,8 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
# self account container
|
# self account container
|
||||||
@account_container = flow(width: 400, height: 80, margin_left: LARGE_PADDING) do
|
@account_container = flow(width: 400, height: 80, margin_left: LARGE_PADDING) do
|
||||||
# self avatar container
|
|
||||||
stack(width: 80, height: 1.0, background_image: rounded_avatar(safe_get_image("#{ROOT_PATH}/media/default.png")), tag: :account_avatar) do |i|
|
|
||||||
i.subscribe(:clicked_left_mouse_button) do
|
|
||||||
dialog(Dialog::Account)
|
|
||||||
end
|
|
||||||
# self online state container
|
|
||||||
stack(width: 20, height: 20, v_align: :bottom, h_align: :right, background_image: safe_get_image("#{ROOT_PATH}/media/ui/circle_small.png"), background_image_color: 0xff_26a269, tag: :account_online_state)
|
|
||||||
end
|
|
||||||
|
|
||||||
stack(fill: true, height: 1.0, margin_left: HALF_PADDING) do
|
|
||||||
flow(fill: true)
|
|
||||||
# self name
|
|
||||||
caption "cyberarm", font: FONT_BLACK, text_wrap: :none, width: 1.0, tag: :account_name
|
|
||||||
# self set online state
|
|
||||||
link "Online ▼", text_size: 18 do |l|
|
|
||||||
menu(parent: l) do
|
|
||||||
menu_item("Online")
|
|
||||||
menu_item("Do Not Disturb")
|
|
||||||
menu_item("Away")
|
|
||||||
menu_item("Invisible")
|
|
||||||
menu_item("Sign Out")
|
|
||||||
end.show
|
|
||||||
end
|
|
||||||
flow(fill: true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
populate_account_information
|
||||||
end
|
end
|
||||||
|
|
||||||
# layout container
|
# layout container
|
||||||
@@ -357,6 +334,65 @@ module W3DHubLauncher
|
|||||||
composite.save(path)
|
composite.save(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def populate_account_information
|
||||||
|
account = MemCache[:settings].account
|
||||||
|
avatar_path = account ? "#{CACHE_PATH}/avatar_#{account&.user_id}#{File.extname(account&.avatar_uri)}" : nil
|
||||||
|
|
||||||
|
@account_container.clear do
|
||||||
|
# self avatar container
|
||||||
|
stack(width: 80, height: 1.0, background_image: rounded_avatar(safe_get_image(avatar_path || "#{ROOT_PATH}/media/default.png")), tag: :account_avatar) do
|
||||||
|
# self online state container
|
||||||
|
stack(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
v_align: :bottom,
|
||||||
|
h_align: :right,
|
||||||
|
background_image: safe_get_image("#{ROOT_PATH}/media/ui/circle_small.png"),
|
||||||
|
background_image_color: 0xff_77767b,
|
||||||
|
tag: :account_online_state
|
||||||
|
) do
|
||||||
|
if account.signed_in?
|
||||||
|
image safe_get_image("#{ROOT_PATH}/media/ui/circle_small.png"), width: 1.0, height: 1.0, color: 0xff_26a269, padding: 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
stack(fill: true, height: 1.0, margin_left: HALF_PADDING) do
|
||||||
|
flow(fill: true)
|
||||||
|
# self name
|
||||||
|
caption account.signed_in? ? account.displayname : MemCache[:settings].preferences.nickname, font: FONT_BLACK, text_wrap: :none, width: 1.0, tag: :account_name
|
||||||
|
|
||||||
|
if account.signed_in?
|
||||||
|
# self set online state
|
||||||
|
link "Online ▼", text_size: 18 do |l|
|
||||||
|
menu(parent: l) do
|
||||||
|
menu_item("Online")
|
||||||
|
menu_item("Do Not Disturb")
|
||||||
|
menu_item("Away")
|
||||||
|
menu_item("Invisible")
|
||||||
|
menu_item("Sign Out") do
|
||||||
|
# sign out
|
||||||
|
end
|
||||||
|
end.show
|
||||||
|
end
|
||||||
|
else
|
||||||
|
button "Sign In", text_size: 18 do
|
||||||
|
dialog(Dialog::Account)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
flow(fill: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if account && !account.avatar_uri.empty?
|
||||||
|
img = find_element_by_tag(@account_container, :account_avatar)
|
||||||
|
|
||||||
|
remote_image(avatar_path, url: account.avatar_uri, element: img) do |e, path|
|
||||||
|
e&.background_image = rounded_avatar(safe_get_image(path))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def button_up(id)
|
def button_up(id)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ module W3DHubLauncher
|
|||||||
LARGE_PADDING = 40
|
LARGE_PADDING = 40
|
||||||
PADDING = 20
|
PADDING = 20
|
||||||
HALF_PADDING = 10
|
HALF_PADDING = 10
|
||||||
|
QUARTER_PADDING = 5
|
||||||
|
|
||||||
ALPHA_BLACK = 0x88_000000
|
ALPHA_BLACK = 0x88_000000
|
||||||
ALPHA_GRAY = 0x88_5e5c64
|
ALPHA_GRAY = 0x88_5e5c64
|
||||||
|
|||||||
@@ -81,11 +81,21 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
# Handle getting and updating game server data
|
# Handle getting and updating game server data
|
||||||
task.async do
|
task.async do
|
||||||
|
# Wait for "activation"
|
||||||
|
while (@settings.nil?)
|
||||||
|
sleep 0.25
|
||||||
|
end
|
||||||
|
|
||||||
game_server_hub_websocket
|
game_server_hub_websocket
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handle backend communication
|
# Handle backend communication
|
||||||
task.async do
|
task.async do
|
||||||
|
# Wait for "activation"
|
||||||
|
while (@settings.nil?)
|
||||||
|
sleep 0.25
|
||||||
|
end
|
||||||
|
|
||||||
backend_websocket
|
backend_websocket
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -190,6 +200,9 @@ module W3DHubLauncher
|
|||||||
msg = [8, 0, 0, 0, sequence_id].flatten.pack("C2n2A64")
|
msg = [8, 0, 0, 0, sequence_id].flatten.pack("C2n2A64")
|
||||||
echo_requests[sequence_id] = { send_time: Time.now, address: server_address, replied: false }
|
echo_requests[sequence_id] = { send_time: Time.now, address: server_address, replied: false }
|
||||||
socket.send(msg, 0, address)
|
socket.send(msg, 0, address)
|
||||||
|
rescue Errno::ENETUNREACH
|
||||||
|
# network was unreachable, cleanup
|
||||||
|
echo_requests.delete(sequence_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Receive replies until timeout
|
# Receive replies until timeout
|
||||||
@@ -362,7 +375,7 @@ module W3DHubLauncher
|
|||||||
content_length: content_length
|
content_length: content_length
|
||||||
})
|
})
|
||||||
|
|
||||||
message_requester(query.request_id, Request::STATUS_IN_PROGRESS, progress_result.data, progress_result.error)
|
message_requester(request_id: query.request_id, status: Request::STATUS_IN_PROGRESS, data: progress_result.data, error: progress_result.error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -506,6 +519,10 @@ module W3DHubLauncher
|
|||||||
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH)
|
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH)
|
||||||
File.write(W3DHubLauncher::SETTINGS_FILE_PATH, query.data)
|
File.write(W3DHubLauncher::SETTINGS_FILE_PATH, query.data)
|
||||||
|
|
||||||
|
if @settings&.account&.signed_in?
|
||||||
|
@w3dhub_api.access_token = @settings.account.access_token
|
||||||
|
end
|
||||||
|
|
||||||
result.data = query.data
|
result.data = query.data
|
||||||
rescue => e
|
rescue => e
|
||||||
result.error = e
|
result.error = e
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ module W3DHubLauncher
|
|||||||
def self.account
|
def self.account
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.user_login(username, password, &block)
|
||||||
|
W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :user_login, arguments: [username, password] }, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.refresh_user_login(refresh_token, &block)
|
||||||
|
W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :refresh_user_login, arguments: [refresh_token] }, &block)
|
||||||
|
end
|
||||||
|
|
||||||
# returns launcher settings
|
# returns launcher settings
|
||||||
def self.settings
|
def self.settings
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,10 +3,15 @@ module W3DHubLauncher
|
|||||||
# ignore *.meta and paths.ini files
|
# ignore *.meta and paths.ini files
|
||||||
IGNORED_FILES = [/\A.+\.meta\z/i, /\A.+\/paths\.ini\z/i].freeze
|
IGNORED_FILES = [/\A.+\.meta\z/i, /\A.+\/paths\.ini\z/i].freeze
|
||||||
|
|
||||||
|
STAGE_FETCH_MANIFEST = 1
|
||||||
|
STAGE_VERIFY_FILES = 2
|
||||||
|
STAGE_DOWNLOAD_FILES = 3
|
||||||
|
STAGE_INSTALL_FILES = 4
|
||||||
|
STAGE_MAX = STAGE_INSTALL_FILES
|
||||||
|
|
||||||
IndexedFile = Data.define(:type, :path)
|
IndexedFile = Data.define(:type, :path)
|
||||||
|
|
||||||
attr_reader :request_id, :application, :channel, :installed_version, :target_version
|
attr_reader :request_id, :application, :channel, :installed_version, :target_version, :status
|
||||||
attr_reader :status
|
|
||||||
|
|
||||||
def initialize(request_id:, application:, channel:, installed_version:, target_version:)
|
def initialize(request_id:, application:, channel:, installed_version:, target_version:)
|
||||||
@request_id = request_id
|
@request_id = request_id
|
||||||
@@ -38,6 +43,10 @@ module W3DHubLauncher
|
|||||||
# check file modification time and size
|
# check file modification time and size
|
||||||
@force_verification = false
|
@force_verification = false
|
||||||
|
|
||||||
|
# Status progress reporting stage
|
||||||
|
@stage = 0
|
||||||
|
@stage_count = STAGE_MAX # manifests and package list building, verifying, downloading, installing
|
||||||
|
|
||||||
setup
|
setup
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,7 +91,7 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_manifests(version = @target_version)
|
def fetch_manifests(version = @target_version)
|
||||||
update_status(label: "Fetching manifests...", fraction: 0.0)
|
update_stage_progress(label: "Fetching manifests...", fraction: 0.0)
|
||||||
|
|
||||||
while (manifest = fetch_manifest(version))
|
while (manifest = fetch_manifest(version))
|
||||||
@manifests[version] = manifest
|
@manifests[version] = manifest
|
||||||
@@ -94,7 +103,7 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_package_list
|
def build_package_list
|
||||||
update_status(label: "Building package list...", fraction: 0.0)
|
update_stage_progress(label: "Building package list...", fraction: 0.0)
|
||||||
|
|
||||||
channel_manifests = []
|
channel_manifests = []
|
||||||
version = @target_version
|
version = @target_version
|
||||||
@@ -109,7 +118,9 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
files = []
|
files = []
|
||||||
deleted_files = []
|
deleted_files = []
|
||||||
channel_manifests.reverse.each do |manifest|
|
channel_manifests.reverse.each_with_index do |manifest, i|
|
||||||
|
update_stage_progress(label: "Building package list...", fraction: (i.to_f + 1) / channel_manifests.size)
|
||||||
|
|
||||||
manifest.files.each do |file|
|
manifest.files.each do |file|
|
||||||
if file.removed?
|
if file.removed?
|
||||||
files.delete_if { |f| f.name.casecmp?(file.name) }
|
files.delete_if { |f| f.name.casecmp?(file.name) }
|
||||||
@@ -131,10 +142,13 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
@manifest_files = files
|
@manifest_files = files
|
||||||
@deleted_manifest_files = deleted_files
|
@deleted_manifest_files = deleted_files
|
||||||
|
|
||||||
|
update_stage_progress(label: "Building package list...", fraction: 1.0)
|
||||||
|
@stage += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_files
|
def verify_files
|
||||||
update_status(label: "Verifying files...", fraction: 0.0)
|
update_stage_progress(label: "Verifying files...", fraction: 0.0)
|
||||||
|
|
||||||
@required_manifest_files = @manifest_files.clone
|
@required_manifest_files = @manifest_files.clone
|
||||||
|
|
||||||
@@ -154,14 +168,22 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
puts "verifying #{file_path}..."
|
puts "verifying #{file_path}..."
|
||||||
key = @verification_data.key(file.name)
|
key = @verification_data.key(file.name)
|
||||||
pp [key, @force_verification]
|
|
||||||
verification_data = @force_verification ? nil : @verification_data.unchanged?(key, checksum: file.checksum, file_path: file_path)
|
verification_data = @force_verification ? nil : @verification_data.unchanged?(key, checksum: file.checksum, file_path: file_path)
|
||||||
|
|
||||||
# Use cached checksum if the file appears unchanged, otherwise recalculate it
|
# pp [key, @force_verification, verification_data, cached_checksums[file_path], file.checksum]
|
||||||
checksum = verification_data&.checksum || Digest::SHA256.file(file_path).hexdigest.upcase
|
# pp @verification_data.data(key)
|
||||||
|
|
||||||
# Set or update cached verification data if files don't match
|
checksum = verification_data&.checksum || cached_checksums[file_path]
|
||||||
@verification_data.set(key, checksum: checksum, file_path: file_path) unless verification_data
|
|
||||||
|
# File exists, verification data for an older version exists, skip generationing file checksum
|
||||||
|
if @force_verification || @verification_data.data(key).nil?
|
||||||
|
# Use cached checksum if the file appears unchanged, otherwise recalculate it
|
||||||
|
checksum = verification_data&.checksum || cached_checksums[file_path] || Digest::SHA256.file(file_path).hexdigest.upcase
|
||||||
|
|
||||||
|
# Set or update cached verification data if files don't match
|
||||||
|
@verification_data.set(key, checksum: checksum, file_path: file_path) unless verification_data
|
||||||
|
cached_checksums[file_path] = checksum
|
||||||
|
end
|
||||||
|
|
||||||
if checksum == file.checksum
|
if checksum == file.checksum
|
||||||
@required_manifest_files.delete(file)
|
@required_manifest_files.delete(file)
|
||||||
@@ -173,12 +195,16 @@ module W3DHubLauncher
|
|||||||
puts " failed verification:#{file.version}"
|
puts " failed verification:#{file.version}"
|
||||||
end
|
end
|
||||||
|
|
||||||
update_status(label: "Verifying files...", fraction: i.to_f / @manifest_files.size)
|
update_stage_progress(label: "Verifying files (#{i + 1} / #{@manifest_files.size})", fraction: (i.to_f + 1) / @manifest_files.size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
update_stage_progress(label: "Verified files.", fraction: 1.0)
|
||||||
|
|
||||||
|
@stage += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_packages
|
def fetch_packages
|
||||||
update_status(label: "Downloading packages...", fraction: 0.0)
|
update_stage_progress(label: "Downloading packages...", fraction: 0.0)
|
||||||
|
|
||||||
required_packages = {}
|
required_packages = {}
|
||||||
@required_manifest_files.each do |file|
|
@required_manifest_files.each do |file|
|
||||||
@@ -216,7 +242,12 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
@packages = manifest_packages
|
@packages = manifest_packages
|
||||||
|
|
||||||
manifest_packages.each do |pkg|
|
# FIXME: We should include packages in verification step so once we reach the downloading stage
|
||||||
|
# we don't halt everything to verify package files and have a stable download size report
|
||||||
|
total_data_to_download_bytes = manifest_packages.sum { |pkg| pkg.file_size }
|
||||||
|
total_data_downloaded_bytes = 0
|
||||||
|
|
||||||
|
manifest_packages.each_with_index do |pkg, i|
|
||||||
file_path = package_cache_path(pkg)
|
file_path = package_cache_path(pkg)
|
||||||
unless File.directory?(File.dirname(file_path))
|
unless File.directory?(File.dirname(file_path))
|
||||||
puts "creating directory: #{File.dirname(file_path)}"
|
puts "creating directory: #{File.dirname(file_path)}"
|
||||||
@@ -228,16 +259,34 @@ module W3DHubLauncher
|
|||||||
if state.is_a?(Integer)
|
if state.is_a?(Integer)
|
||||||
puts "partially valid at: #{state} bytes (#{file_path})" # 20971520
|
puts "partially valid at: #{state} bytes (#{file_path})" # 20971520
|
||||||
partially_valid_at = state
|
partially_valid_at = state
|
||||||
|
total_data_to_download_bytes -= partially_valid_at
|
||||||
else
|
else
|
||||||
if state == true # completely verified, skip download!
|
if state == true # completely verified, skip download!
|
||||||
puts "skipping #{file_path}"
|
puts "skipping #{file_path}"
|
||||||
|
total_data_to_download_bytes -= pkg.file_size
|
||||||
|
update_stage_progress(label: "Downloading packages...", fraction: (i.to_f + 1) / manifest_packages.size)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
last_sample_time_ms = -10_000
|
||||||
|
sample_downloaded_bytes = 0
|
||||||
|
|
||||||
result = if pkg.download_url
|
result = if pkg.download_url
|
||||||
puts "downloading #{pkg.download_url} to #{file_path}"
|
puts "downloading #{pkg.download_url} to #{file_path}"
|
||||||
@worker.w3dhub_api.download(pkg.download_url, path: file_path, headers: @worker.w3dhub_api.headers(range: partially_valid_at))
|
@worker.w3dhub_api.download(pkg.download_url, path: file_path, headers: @worker.w3dhub_api.headers(range: partially_valid_at)) do |downloaded_bytes, total_downloaded_bytes, content_length|
|
||||||
|
sample_downloaded_bytes += downloaded_bytes
|
||||||
|
total_data_downloaded_bytes += downloaded_bytes
|
||||||
|
|
||||||
|
if Gosu.milliseconds - last_sample_time_ms >= 1_000
|
||||||
|
last_sample_time_ms = Gosu.milliseconds
|
||||||
|
|
||||||
|
fraction = (total_downloaded_bytes + partially_valid_at) / pkg.file_size.to_f
|
||||||
|
|
||||||
|
update_stage_progress(label: "Downloading #{W3DHubLauncher.format_size(total_data_downloaded_bytes)} / #{W3DHubLauncher.format_size(total_data_to_download_bytes)} [#{W3DHubLauncher.format_size(sample_downloaded_bytes)}/s]", fraction: (i.to_f + fraction) / manifest_packages.size)
|
||||||
|
sample_downloaded_bytes = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
# TODO xD
|
# TODO xD
|
||||||
@worker.w3dhub_api.fetch_package("TODO")
|
@worker.w3dhub_api.fetch_package("TODO")
|
||||||
@@ -245,15 +294,19 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
abort_task!("Failed to download required package: #{pkg.name}:#{pkg.version} (#{result.error})") unless result.okay?
|
abort_task!("Failed to download required package: #{pkg.name}:#{pkg.version} (#{result.error})") unless result.okay?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
update_stage_progress(label: "Downloaded packages.", fraction: 1.0)
|
||||||
|
|
||||||
|
@stage += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_packages
|
def install_packages
|
||||||
update_status(label: "Installing...", fraction: 0.0)
|
update_stage_progress(label: "Installing...", fraction: 0.0)
|
||||||
|
|
||||||
create_directory(@installation_directory)
|
create_directory(@installation_directory)
|
||||||
|
|
||||||
processed_packages = {}
|
processed_packages = {}
|
||||||
@required_manifest_files.each do |manifest_file|
|
@required_manifest_files.each_with_index do |manifest_file, i|
|
||||||
package = @packages.find do |pkg|
|
package = @packages.find do |pkg|
|
||||||
pkg.name.casecmp?("#{manifest_file.package}.zip") && manifest_file.version == pkg.version
|
pkg.name.casecmp?("#{manifest_file.package}.zip") && manifest_file.version == pkg.version
|
||||||
end
|
end
|
||||||
@@ -268,11 +321,13 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
processed_packages[package_path] = manifest_file
|
processed_packages[package_path] = manifest_file
|
||||||
|
|
||||||
|
update_stage_progress(label: "Installing (#{i + 1} / #{@required_manifest_files.size})", fraction: (i.to_f + 1)/ @required_manifest_files.size)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_deleted_files
|
def remove_deleted_files
|
||||||
update_status(label: "Removing files...", fraction: 0.0)
|
update_stage_progress(label: "Removing files...", fraction: 1.0)
|
||||||
|
|
||||||
@deleted_manifest_files.each do |manifest_file|
|
@deleted_manifest_files.each do |manifest_file|
|
||||||
file_path = normalize_path(manifest_file.name)
|
file_path = normalize_path(manifest_file.name)
|
||||||
@@ -335,6 +390,12 @@ module W3DHubLauncher
|
|||||||
message_requester(data: { status: { title: "#{@task_verb} #{@application.name} (#{@channel.name})", label: label, fraction: fraction } } )
|
message_requester(data: { status: { title: "#{@task_verb} #{@application.name} (#{@channel.name})", label: label, fraction: fraction } } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_stage_progress(label:, fraction:)
|
||||||
|
fraction = (@stage / @stage_count.to_f) + ((1.0 / @stage_count) * fraction)
|
||||||
|
|
||||||
|
message_requester(data: { status: { title: "#{@task_verb} #{@application.name} (#{@channel.name})", label: label, fraction: fraction } } )
|
||||||
|
end
|
||||||
|
|
||||||
def application_target_installation_directory
|
def application_target_installation_directory
|
||||||
target_application = @worker.settings.applications.find { |app| app.id == @application.id && app.channel == @channel.id }
|
target_application = @worker.settings.applications.find { |app| app.id == @application.id && app.channel == @channel.id }
|
||||||
if target_application
|
if target_application
|
||||||
@@ -467,11 +528,11 @@ module W3DHubLauncher
|
|||||||
create_directory(File.dirname(file_path))
|
create_directory(File.dirname(file_path))
|
||||||
|
|
||||||
result = if manifest_package.download_url
|
result = if manifest_package.download_url
|
||||||
@worker.w3dhub_api.download(manifest_package.download_url, path: file_path)
|
@worker.w3dhub_api.download(manifest_package.download_url, path: file_path)
|
||||||
else
|
else
|
||||||
# TODO xD
|
# TODO xD
|
||||||
@worker.w3dhub_api.fetch_package("TODO")
|
@worker.w3dhub_api.fetch_package("TODO")
|
||||||
end
|
end
|
||||||
|
|
||||||
if result.okay?
|
if result.okay?
|
||||||
return Worker::Api::LegacyManifest.new(package_cache_path(manifest_package))
|
return Worker::Api::LegacyManifest.new(package_cache_path(manifest_package))
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
attr_reader :applications
|
attr_reader :applications
|
||||||
|
|
||||||
|
attr_writer :access_token
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@access_token = nil
|
@access_token = nil
|
||||||
|
|
||||||
@@ -38,7 +40,6 @@ module W3DHubLauncher
|
|||||||
Sync do |task|
|
Sync do |task|
|
||||||
task.with_timeout(API_TIMEOUT) do
|
task.with_timeout(API_TIMEOUT) do
|
||||||
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
||||||
pp [method, url, headers, body, response]
|
|
||||||
if response.success?
|
if response.success?
|
||||||
result.data = response.read
|
result.data = response.read
|
||||||
else
|
else
|
||||||
@@ -92,16 +93,71 @@ module W3DHubLauncher
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_login()
|
def user_login(username, password)
|
||||||
result = CyberarmEngine::Result.new
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
|
body = URI.encode_www_form("data": JSON.dump({username: username, password: password}))
|
||||||
|
response = fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/user-login", method: :post, body: body, headers: headers(form_encoded: true))
|
||||||
|
|
||||||
|
if response.okay?
|
||||||
|
hash = JSON.parse(response.data)
|
||||||
|
|
||||||
|
user_details_result = fetch_user_details(Integer(hash["userid"]))
|
||||||
|
user_details_hash = user_details_result.okay? ? JSON.parse(user_details_result.data) : {}
|
||||||
|
|
||||||
|
account = W3DHubLauncher::Worker::Api::Settings::Account.create(
|
||||||
|
user_id: hash["userid"],
|
||||||
|
username: hash["username"],
|
||||||
|
displayname: hash["displayname"],
|
||||||
|
avatar_uri: user_details_hash["avatar-uri"] || "",
|
||||||
|
access_token: hash["accessToken"],
|
||||||
|
refresh_token: hash["refreshToken"],
|
||||||
|
access_token_expiration_time: hash["accessTokenExpiry"]
|
||||||
|
)
|
||||||
|
|
||||||
|
result.data = account.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_user_login()
|
def refresh_user_login(refresh_token)
|
||||||
result = CyberarmEngine::Result.new
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
|
body = URI.encode_www_form("data": JSON.dump({refreshToken: refresh_token}))
|
||||||
|
response = fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/user-login", method: :post, body: body, headers: headers(form_encoded: true))
|
||||||
|
|
||||||
|
if response.okay?
|
||||||
|
hash = JSON.parse(response.data)
|
||||||
|
|
||||||
|
user_details_result = fetch_user_details(Integer(hash["userid"]))
|
||||||
|
user_details_hash = user_details_result.okay? ? JSON.parse(user_details_result.data) : {}
|
||||||
|
|
||||||
|
account = W3DHubLauncher::Worker::Api::Settings::Account.create(
|
||||||
|
user_id: hash["userid"],
|
||||||
|
username: hash["username"],
|
||||||
|
displayname: hash["displayname"],
|
||||||
|
avatar_uri: user_details_hash["avatar-uri"] || "",
|
||||||
|
access_token: hash["accessToken"],
|
||||||
|
refresh_token: hash["refreshToken"],
|
||||||
|
access_token_expiration_time: hash["accessTokenExpiry"]
|
||||||
|
)
|
||||||
|
|
||||||
|
result.data = account.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_user_details()
|
def fetch_user_details(user_id)
|
||||||
result = CyberarmEngine::Result.new
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
|
body = URI.encode_www_form("data": JSON.dump({id: user_id}))
|
||||||
|
response = fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/w3dhub/1/get-user-details", method: :post, body: body, headers: headers(form_encoded: true))
|
||||||
|
|
||||||
|
result.data = response.data if response.okay?
|
||||||
|
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_applications
|
def fetch_applications
|
||||||
@@ -146,7 +202,7 @@ module W3DHubLauncher
|
|||||||
fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/w3dhub/1/get-server-events", method: :post, body: "data={\"serverPath\":\"#{category}\"}", headers: headers(form_encoded: true))
|
fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/w3dhub/1/get-server-events", method: :post, body: "data={\"serverPath\":\"#{category}\"}", headers: headers(form_encoded: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_test_events(category)
|
def fetch_test_events
|
||||||
fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/w3dhub/1/get-testing-times")
|
fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/w3dhub/1/get-testing-times")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ require_relative "lib/gui_ext"
|
|||||||
require_relative "lib/state"
|
require_relative "lib/state"
|
||||||
require_relative "lib/dialog"
|
require_relative "lib/dialog"
|
||||||
require_relative "lib/theme"
|
require_relative "lib/theme"
|
||||||
|
require_relative "lib/forms/settings_form"
|
||||||
require_relative "lib/pages/games"
|
require_relative "lib/pages/games"
|
||||||
require_relative "lib/pages/server_browser"
|
require_relative "lib/pages/server_browser"
|
||||||
require_relative "lib/pages/boot/terms"
|
require_relative "lib/pages/boot/terms"
|
||||||
@@ -44,6 +45,7 @@ require_relative "lib/dialogs/account"
|
|||||||
require_relative "lib/dialogs/import_application"
|
require_relative "lib/dialogs/import_application"
|
||||||
require_relative "lib/dialogs/launcher_settings"
|
require_relative "lib/dialogs/launcher_settings"
|
||||||
require_relative "lib/dialogs/application_settings"
|
require_relative "lib/dialogs/application_settings"
|
||||||
|
require_relative "lib/dialogs/asterisk"
|
||||||
require_relative "lib/states/boot"
|
require_relative "lib/states/boot"
|
||||||
require_relative "lib/states/interface"
|
require_relative "lib/states/interface"
|
||||||
require_relative "lib/window"
|
require_relative "lib/window"
|
||||||
|
|||||||
Reference in New Issue
Block a user