mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-04 09:04:04 +00:00
Compare commits
11 Commits
3bc2b45823
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| aa1145f1dc | |||
| 13d6c3339b | |||
| 002b77d2d8 | |||
| 6ac2477803 | |||
| ff9fcc5b5f | |||
| 16742ea5fa | |||
| 073f5bebf9 | |||
| 57287de742 | |||
| 99dc27ced2 | |||
| de6bfb85f5 | |||
| 4bfb494abe |
@@ -55,15 +55,7 @@ module W3DHubLauncher
|
||||
if result.okay?
|
||||
hash = JSON.parse(result.data)
|
||||
|
||||
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.create(
|
||||
user_id: hash["userid"],
|
||||
username: hash["username"],
|
||||
displayname: hash["displayname"],
|
||||
avatar_uri: "",
|
||||
access_token: hash["accessToken"],
|
||||
refresh_token: hash["refreshToken"],
|
||||
access_token_expiration_time: hash["accessTokenExpiry"]
|
||||
)
|
||||
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.new(hash)
|
||||
|
||||
Worker::Api.update_settings(MemCache[:settings]) do |settings_result|
|
||||
if settings_result.okay?
|
||||
|
||||
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
|
||||
class Dialog
|
||||
class LauncherSettings < W3DHubLauncher::Dialog
|
||||
include W3DHubLauncher::Form::SettingsForm
|
||||
|
||||
def setup
|
||||
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
|
||||
banner "Launcher Settings", width: 1.0, text_align: :center
|
||||
end
|
||||
|
||||
item_height = 40 + PADDING
|
||||
settings = MemCache[:settings]
|
||||
form_setup
|
||||
|
||||
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, 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
|
||||
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
|
||||
button "Close" do
|
||||
pop_state
|
||||
end
|
||||
|
||||
flow(fill: true)
|
||||
|
||||
button "Save", **CTA_BUTTON_THEME do |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
|
||||
@accept_button = button "Save", **CTA_BUTTON_THEME do |btn|
|
||||
form_commit(btn)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# FIXME: Check settings for validity before saving
|
||||
def valid?
|
||||
true
|
||||
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
|
||||
class InitialSetup < CyberarmEngine::Page
|
||||
include GuiExt
|
||||
include W3DHubLauncher::Form::SettingsForm
|
||||
|
||||
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
|
||||
tagline "Your gateway to the world of W3D Hub games.", width: 1.0, text_align: :center
|
||||
end
|
||||
|
||||
stack(width: 1.0, fill: true, padding: PADDING) do
|
||||
stack(width: 1.0, fill: true, scroll: true) do
|
||||
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
|
||||
stack(width: 1.0, fill: true, padding: PADDING) do |e|
|
||||
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
|
||||
|
||||
flow(width: 1.0, height: 40, margin_top: PADDING) do
|
||||
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
|
||||
form_setup(nil)
|
||||
|
||||
flow(width: 1.0, padding_top: PADDING) do
|
||||
flow(fill: true)
|
||||
button "Accept", **CTA_BUTTON_THEME do |btn|
|
||||
btn.enabled = false
|
||||
|
||||
# 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
|
||||
@accept_button = button "Accept", **CTA_BUTTON_THEME do |btn|
|
||||
form_commit(btn)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ module W3DHubLauncher
|
||||
@initialization_acceptable = false
|
||||
@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
|
||||
tagline "Please stand by...", width: 1.0, text_align: :center
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module W3DHubLauncher
|
||||
TERMS
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ module W3DHubLauncher
|
||||
class Games < CyberarmEngine::Page
|
||||
include GuiExt
|
||||
|
||||
GAME_COVER_ASPECT_RATIO = 3 / 4.0
|
||||
|
||||
def setup
|
||||
@games = MemCache[:applications]&.select { |app| app.type.include?("game") } || []
|
||||
|
||||
@@ -78,15 +80,46 @@ module W3DHubLauncher
|
||||
def populate_all_games
|
||||
@display_mode = :all_games
|
||||
|
||||
img = safe_get_image("#{ROOT_PATH}/media/default_game_cover.png")
|
||||
|
||||
@game_content_container.clear do
|
||||
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|
|
||||
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
|
||||
|
||||
e.subscribe(:size_changed) do |e|
|
||||
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
|
||||
@@ -322,7 +355,9 @@ module W3DHubLauncher
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def news_item_width_ratio
|
||||
|
||||
@@ -45,8 +45,8 @@ module W3DHubLauncher
|
||||
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
|
||||
dialog(Dialog::DirectConnect)
|
||||
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::Asterisk)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ module W3DHubLauncher
|
||||
# TODO: Sort servers?
|
||||
end
|
||||
|
||||
def handle_game_server_list
|
||||
def handle_game_server_list(payload)
|
||||
after(1_000) do
|
||||
populate_server_list
|
||||
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("SERVERS",height: 1.0, text_v_align: :center, font: FONT_BLACK, margin_left: PADDING) { page(Page::ServerBrowser) }
|
||||
stack(fill: true)
|
||||
image safe_get_image("#{ROOT_PATH}/media/icons/import.png"), height: 40, color: 0xff_bbbbbb, tip: "Downloads" do |img|
|
||||
dialog(Dialog::Downloads)
|
||||
stack(v_align: :center) do
|
||||
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
|
||||
image safe_get_image("#{ROOT_PATH}/media/icons/information.png"), height: 40, color: 0xff_bbbbbb, tip: "Notifications"
|
||||
end
|
||||
# application task status bar container
|
||||
@application_task_status_bar_container = stack(width: 1.0, fill: true, margin_left: PADDING, visible: false) do
|
||||
@@ -335,10 +336,11 @@ module W3DHubLauncher
|
||||
|
||||
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("#{ROOT_PATH}/media/default.png")), tag: :account_avatar) do
|
||||
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,
|
||||
@@ -346,9 +348,13 @@ module W3DHubLauncher
|
||||
v_align: :bottom,
|
||||
h_align: :right,
|
||||
background_image: safe_get_image("#{ROOT_PATH}/media/ui/circle_small.png"),
|
||||
background_image_color: account.signed_in? ? 0xff_26a269 : 0xff_77767b,
|
||||
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
|
||||
@@ -377,6 +383,14 @@ module W3DHubLauncher
|
||||
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)
|
||||
|
||||
@@ -2,6 +2,7 @@ module W3DHubLauncher
|
||||
LARGE_PADDING = 40
|
||||
PADDING = 20
|
||||
HALF_PADDING = 10
|
||||
QUARTER_PADDING = 5
|
||||
|
||||
ALPHA_BLACK = 0x88_000000
|
||||
ALPHA_GRAY = 0x88_5e5c64
|
||||
|
||||
@@ -200,6 +200,9 @@ module W3DHubLauncher
|
||||
msg = [8, 0, 0, 0, sequence_id].flatten.pack("C2n2A64")
|
||||
echo_requests[sequence_id] = { send_time: Time.now, address: server_address, replied: false }
|
||||
socket.send(msg, 0, address)
|
||||
rescue Errno::ENETUNREACH
|
||||
# network was unreachable, cleanup
|
||||
echo_requests.delete(sequence_id)
|
||||
end
|
||||
|
||||
# Receive replies until timeout
|
||||
@@ -372,7 +375,7 @@ module W3DHubLauncher
|
||||
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
|
||||
|
||||
|
||||
@@ -93,21 +93,71 @@ module W3DHubLauncher
|
||||
result
|
||||
end
|
||||
|
||||
def user_login(username, password, &block)
|
||||
def user_login(username, password)
|
||||
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))
|
||||
|
||||
pp response
|
||||
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
|
||||
|
||||
def refresh_user_login()
|
||||
def refresh_user_login(refresh_token)
|
||||
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
|
||||
|
||||
def fetch_user_details()
|
||||
def fetch_user_details(user_id)
|
||||
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
|
||||
|
||||
def fetch_applications
|
||||
@@ -152,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))
|
||||
end
|
||||
|
||||
def fetch_test_events(category)
|
||||
def fetch_test_events
|
||||
fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/w3dhub/1/get-testing-times")
|
||||
end
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ require_relative "lib/gui_ext"
|
||||
require_relative "lib/state"
|
||||
require_relative "lib/dialog"
|
||||
require_relative "lib/theme"
|
||||
require_relative "lib/forms/settings_form"
|
||||
require_relative "lib/pages/games"
|
||||
require_relative "lib/pages/server_browser"
|
||||
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/launcher_settings"
|
||||
require_relative "lib/dialogs/application_settings"
|
||||
require_relative "lib/dialogs/asterisk"
|
||||
require_relative "lib/states/boot"
|
||||
require_relative "lib/states/interface"
|
||||
require_relative "lib/window"
|
||||
|
||||
Reference in New Issue
Block a user