mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-05 17:44:16 +00:00
Compare commits
9 Commits
16742ea5fa
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| f5e8055bf5 | |||
| 27b0d92ccf | |||
| 3a15789a29 | |||
| 4b95fcdf15 | |||
| aa1145f1dc | |||
| 13d6c3339b | |||
| 002b77d2d8 | |||
| 6ac2477803 | |||
| ff9fcc5b5f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.*/
|
||||||
pkg/
|
pkg/
|
||||||
*.json
|
*.json
|
||||||
*.xml
|
*.xml
|
||||||
|
|||||||
@@ -68,10 +68,14 @@ module W3DHubLauncher
|
|||||||
# FIXME: Retry? Show error? ???
|
# FIXME: Retry? Show error? ???
|
||||||
pp settings_result
|
pp settings_result
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
dialog(
|
||||||
|
Dialog::Alert,
|
||||||
|
title: "Failed to sign in",
|
||||||
|
message: "If you have failed 3 or more times in a row, wait about 15 minutes and try again."
|
||||||
|
)
|
||||||
|
btn.enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: Show error message!
|
|
||||||
pp result
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
29
lib/dialogs/alert.rb
Normal file
29
lib/dialogs/alert.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
module W3DHubLauncher
|
||||||
|
class Dialog
|
||||||
|
class Alert < W3DHubLauncher::Dialog
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
|
||||||
|
stack(width: 1.0, max_width: 800, height: 1.0, max_height: 480, 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 @options[:title] || "", width: 1.0, text_align: :center
|
||||||
|
end
|
||||||
|
|
||||||
|
stack(style_class: [:dialog_container]) do
|
||||||
|
tagline @options[:message] || ""
|
||||||
|
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
|
||||||
@@ -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
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: Check settings for validity before saving
|
|
||||||
def valid?
|
|
||||||
true
|
|
||||||
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
|
||||||
@@ -75,10 +75,25 @@ module W3DHubLauncher
|
|||||||
def step_launcher_update
|
def step_launcher_update
|
||||||
@initialization_container.append do
|
@initialization_container.append do
|
||||||
tagline "Checking for updates..."
|
tagline "Checking for updates..."
|
||||||
caption "Launcher version <c=0f0>OK</c>", margin_left: LARGE_PADDING
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after(1000) do
|
Worker::Api.fetch_url("https://api.github.com/repos/cyberarm/w3d_hub_linux_launcher/releases/latest") do |result|
|
||||||
|
if result.okay?
|
||||||
|
hash = JSON.parse(result.data)
|
||||||
|
|
||||||
|
@initialization_container.append do
|
||||||
|
if hash["name"] && Gem::Version.new(hash["name"].sub("v", "")) > Gem::Version.new(W3DHubLauncher::VERSION)
|
||||||
|
caption "Launcher update available <c=0f0>#{hash["version"]}</c> (#{W3DHubLauncher::VERSION} running)", margin_left: LARGE_PADDING
|
||||||
|
else
|
||||||
|
caption "Launcher version <c=0f0>OK</c>", margin_left: LARGE_PADDING
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@initialization_container.append do
|
||||||
|
caption "Fetch latest launcher version <c=f80>FAILED</c>", margin_left: LARGE_PADDING
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
next_step
|
next_step
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -89,7 +104,7 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
every(1000) do
|
every(1000) do |timer|
|
||||||
if !MemCache[:servers].nil? || counter >= 5
|
if !MemCache[:servers].nil? || counter >= 5
|
||||||
@initialization_container.append do
|
@initialization_container.append do
|
||||||
if MemCache[:servers]
|
if MemCache[:servers]
|
||||||
@@ -98,6 +113,7 @@ module W3DHubLauncher
|
|||||||
caption "Failed to retrieve server listing.", color: 0xff_ff8800, margin_left: LARGE_PADDING
|
caption "Failed to retrieve server listing.", color: 0xff_ff8800, margin_left: LARGE_PADDING
|
||||||
end
|
end
|
||||||
|
|
||||||
|
timer.cancel
|
||||||
next_step
|
next_step
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -107,13 +123,53 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def step_refresh_account_data
|
def step_refresh_account_data
|
||||||
@initialization_container.append do
|
account = MemCache[:settings]&.account
|
||||||
tagline "Updating account information..."
|
|
||||||
caption "Refresh session <c=0f0>OK</c>", margin_left: LARGE_PADDING
|
# user isn't signed in, skip step
|
||||||
caption "Profile data <c=0f0>OK</c>", margin_left: LARGE_PADDING
|
if account&.refresh_token.empty?
|
||||||
|
next_step
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
after(1000) do
|
# Expired or expiring session refresh immediately
|
||||||
|
if account.access_token_expiration_time < Time.now || (account.access_token_expiration_time - Time.now) < 60 * 60 * 6 # expiring in 6 hours
|
||||||
|
@initialization_container.append do
|
||||||
|
tagline "Updating account information..."
|
||||||
|
end
|
||||||
|
|
||||||
|
Worker::Api.refresh_user_login(account.refresh_token) 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?
|
||||||
|
@initialization_container.append do
|
||||||
|
caption "Refresh session <c=0f0>OK</c>", margin_left: LARGE_PADDING
|
||||||
|
end
|
||||||
|
|
||||||
|
next_step
|
||||||
|
else
|
||||||
|
@initialization_container.append do
|
||||||
|
caption "Refresh session <c=f80>FAILED</c>", margin_left: LARGE_PADDING
|
||||||
|
end
|
||||||
|
MemCache[:account_session_expired] = true
|
||||||
|
|
||||||
|
next_step
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@initialization_container.append do
|
||||||
|
caption "Refresh session <c=f80>FAILED</c>", margin_left: LARGE_PADDING
|
||||||
|
end
|
||||||
|
MemCache[:account_session_expired] = true
|
||||||
|
|
||||||
|
next_step
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
next_step
|
next_step
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ module W3DHubLauncher
|
|||||||
MemCache[:servers].delete(game_server) if game_server
|
MemCache[:servers].delete(game_server) if game_server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CyberarmEngine::EventBus.subscribe("application_changed") do |payload|
|
||||||
|
# pp payload
|
||||||
|
# SDL 3.6 required
|
||||||
|
# SDL.ShowNotification(NAME, "Application Changed Event", nil, nil, 0) #(payload["application"]["name"], payload["state"])
|
||||||
|
end
|
||||||
|
|
||||||
push_state(States::Boot)
|
push_state(States::Boot)
|
||||||
# push_state(States::Interface)
|
# push_state(States::Interface)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module W3DHubLauncher
|
|||||||
@game_servers = []
|
@game_servers = []
|
||||||
@host_pings = {}
|
@host_pings = {}
|
||||||
|
|
||||||
@w3dhub_api = W3DHubLauncher::W3DHubApi.new
|
@w3dhub_api = W3DHubLauncher::W3DHubApi.new(self)
|
||||||
|
|
||||||
Async do |task|
|
Async do |task|
|
||||||
task.async do |subtask|
|
task.async do |subtask|
|
||||||
@@ -200,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
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ module W3DHubLauncher
|
|||||||
class Worker
|
class Worker
|
||||||
class Api
|
class Api
|
||||||
# downloads requested resource, returns raw string
|
# downloads requested resource, returns raw string
|
||||||
def self.fetch_url
|
def self.fetch_url(url, method = :get, headers = nil, body = nil, &block)
|
||||||
|
Worker::Request.new(:fetch_url, { url: url, method: method, headers: headers, body: body }, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# downloads requested resource, periodically reporting progress until completion, returning path for file on disk
|
# downloads requested resource, periodically reporting progress until completion, returning path for file on disk
|
||||||
|
|||||||
@@ -288,8 +288,19 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# TODO xD
|
@worker.w3dhub_api.fetch_package(pkg, path: file_path, range: partially_valid_at) do |downloaded_bytes, total_downloaded_bytes, content_length|
|
||||||
@worker.w3dhub_api.fetch_package("TODO")
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
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?
|
||||||
@@ -530,8 +541,7 @@ module W3DHubLauncher
|
|||||||
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
|
@worker.w3dhub_api.fetch_package(manifest_package, path: file_path)
|
||||||
@worker.w3dhub_api.fetch_package("TODO")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if result.okay?
|
if result.okay?
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
attr_writer :access_token
|
attr_writer :access_token
|
||||||
|
|
||||||
def initialize
|
def initialize(worker)
|
||||||
|
@worker = worker
|
||||||
|
|
||||||
@access_token = nil
|
@access_token = nil
|
||||||
|
|
||||||
@applications = []
|
@applications = []
|
||||||
@@ -82,6 +84,8 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
result.data = true
|
result.data = true
|
||||||
|
else
|
||||||
|
result.error = response.read
|
||||||
end
|
end
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
result.error = e
|
result.error = e
|
||||||
@@ -102,6 +106,11 @@ module W3DHubLauncher
|
|||||||
if response.okay?
|
if response.okay?
|
||||||
hash = JSON.parse(response.data)
|
hash = JSON.parse(response.data)
|
||||||
|
|
||||||
|
if hash["error"]
|
||||||
|
result.error = hash["error"]
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
user_details_result = fetch_user_details(Integer(hash["userid"]))
|
user_details_result = fetch_user_details(Integer(hash["userid"]))
|
||||||
user_details_hash = user_details_result.okay? ? JSON.parse(user_details_result.data) : {}
|
user_details_hash = user_details_result.okay? ? JSON.parse(user_details_result.data) : {}
|
||||||
|
|
||||||
@@ -130,6 +139,11 @@ module W3DHubLauncher
|
|||||||
if response.okay?
|
if response.okay?
|
||||||
hash = JSON.parse(response.data)
|
hash = JSON.parse(response.data)
|
||||||
|
|
||||||
|
if hash["error"]
|
||||||
|
result.error = hash["error"]
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
user_details_result = fetch_user_details(Integer(hash["userid"]))
|
user_details_result = fetch_user_details(Integer(hash["userid"]))
|
||||||
user_details_hash = user_details_result.okay? ? JSON.parse(user_details_result.data) : {}
|
user_details_hash = user_details_result.okay? ? JSON.parse(user_details_result.data) : {}
|
||||||
|
|
||||||
@@ -181,17 +195,67 @@ module W3DHubLauncher
|
|||||||
single_source = true
|
single_source = true
|
||||||
end
|
end
|
||||||
|
|
||||||
unless single_source
|
if single_source
|
||||||
puts "FIXME: merge applications source"
|
|
||||||
# We've gotten data back from both backends, merge them.
|
|
||||||
# pp [primary_result, alternate_result]
|
|
||||||
|
|
||||||
# FIXME: Merge primary and alternate results
|
|
||||||
end
|
|
||||||
|
|
||||||
@applications = JSON.parse(result.data)["applications"]&.map { |app| W3DHubLauncher::Worker::Api::Application.new(app) } || []
|
@applications = JSON.parse(result.data)["applications"]&.map { |app| W3DHubLauncher::Worker::Api::Application.new(app) } || []
|
||||||
|
|
||||||
result
|
result
|
||||||
|
else # We've gotten data back from both backends, merge them.
|
||||||
|
primary = JSON.parse(primary_result.data)["applications"]&.map { |app| W3DHubLauncher::Worker::Api::Application.new(app) } || []
|
||||||
|
alternate = JSON.parse(alternate_result.data)["applications"]&.map { |app| W3DHubLauncher::Worker::Api::Application.new(app) } || []
|
||||||
|
|
||||||
|
primary.each do |app|
|
||||||
|
application = alternate.find { |a| a.id == app.id }
|
||||||
|
unless application
|
||||||
|
alternate << app
|
||||||
|
|
||||||
|
# App doesn't exist in alternate list
|
||||||
|
# comparing channels isn't useful
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
app.channels.each do |chan|
|
||||||
|
channel = application.channels.find { |c| c.id == chan.id }
|
||||||
|
|
||||||
|
unless channel
|
||||||
|
application.channels << chan
|
||||||
|
|
||||||
|
# App doesn't have channel in alternate list
|
||||||
|
# comparing channels isn't useful
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
# If channel versions and access levels match then all is well
|
||||||
|
if chan.version == channel.version &&
|
||||||
|
chan.user_level == channel.user_level
|
||||||
|
|
||||||
|
# All is well!
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
# If the access levels don't match then overwrite alternate's channel with primary's channel
|
||||||
|
if chan.user_level != channel.user_level
|
||||||
|
# Replace alternate's channel with primary's channel
|
||||||
|
application.channels[application.channels.index(channel)] = chan
|
||||||
|
|
||||||
|
# Replaced, continue.
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
# If versions don't match then pick whichever one is higher
|
||||||
|
if Gem::Version.new(chan.current_version) > Gem::Version.new(channel.current_version)
|
||||||
|
# Replace alternate's channel with primary's channel
|
||||||
|
application.channels[application.channels.index(channel)] = chan
|
||||||
|
else
|
||||||
|
# Do nothing, alternate backend version is greater.
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@applications = alternate # alternate is merged with primary
|
||||||
|
result.data = { applications: alternate }.to_json
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_news(category)
|
def fetch_news(category)
|
||||||
@@ -215,8 +279,23 @@ module W3DHubLauncher
|
|||||||
fetch("#{@access_token ? PRIMARY_W3DHUB_API_ENDPOINT : ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package-details", method: :post, body: body, headers: headers(form_encoded: true))
|
fetch("#{@access_token ? PRIMARY_W3DHUB_API_ENDPOINT : ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package-details", method: :post, body: body, headers: headers(form_encoded: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_package()
|
def fetch_package(manifest_package, path:, range: 0)
|
||||||
download()
|
body = URI.encode_www_form(
|
||||||
|
"data": JSON.dump({
|
||||||
|
category: manifest_package.category,
|
||||||
|
subcategory: manifest_package.subcategory,
|
||||||
|
name: manifest_package.name,
|
||||||
|
version: manifest_package.version
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
download(
|
||||||
|
"#{W3DHubApi::PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package",
|
||||||
|
path: path,
|
||||||
|
method: :post,
|
||||||
|
body: body,
|
||||||
|
headers: headers(form_encoded: true, range: range <= 0 ? nil : range)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,11 +32,13 @@ 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"
|
||||||
require_relative "lib/pages/boot/initial_setup"
|
require_relative "lib/pages/boot/initial_setup"
|
||||||
require_relative "lib/pages/boot/start_up"
|
require_relative "lib/pages/boot/start_up"
|
||||||
|
require_relative "lib/dialogs/alert"
|
||||||
require_relative "lib/dialogs/about"
|
require_relative "lib/dialogs/about"
|
||||||
require_relative "lib/dialogs/downloads"
|
require_relative "lib/dialogs/downloads"
|
||||||
require_relative "lib/dialogs/server"
|
require_relative "lib/dialogs/server"
|
||||||
|
|||||||
Reference in New Issue
Block a user