14 Commits

Author SHA1 Message Date
aa1145f1dc Split off launcher settings into a 'form' parent module to share the implementation between initial setup and settings dialog 2026-11-04 00:01:43 -06:00
13d6c3339b Fixed header using rounded instead of rounded_top 2026-11-04 00:00:42 -06:00
002b77d2d8 Improved game card sizing 2026-11-04 00:00:07 -06:00
6ac2477803 Prevent game server pinger from dying if there's a network interruption; like computer going to sleep 2026-10-29 18:13:25 -05:00
ff9fcc5b5f Fix error when handling payload from GSH websocket reconnect 2026-10-27 11:37:21 -05:00
16742ea5fa Add a 1 pixel 'border' around online state indicator so it stands out against the user's avatar 2026-10-25 23:16:11 -05:00
073f5bebf9 Show signed in user's avatar 2026-10-25 22:51:57 -05:00
57287de742 Implement W3D Hub API sign in and user details 2026-10-25 22:51:10 -05:00
99dc27ced2 Fixed crash when using remote_image image downloader 2026-10-25 22:50:19 -05:00
de6bfb85f5 Tweaks downloads button styling and position 2026-10-25 21:45:13 -05:00
4bfb494abe Stub asterisk direct connect 2026-10-18 11:41:03 -05:00
3bc2b45823 Add prototype UI for support direct access token based sign in when you have a non-ascii username/password 2026-10-17 20:13:12 -05:00
cb80364e68 Initial work towards authentication 2026-10-17 19:37:31 -05:00
ec3b1fa068 Fixed click server would populate server info with stale data 2026-10-17 19:37:03 -05:00
16 changed files with 413 additions and 192 deletions

View File

@@ -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
View 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

View File

View 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
View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -372,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
@@ -516,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

View File

@@ -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

View File

@@ -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
@@ -91,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
@@ -145,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

View File

@@ -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"