mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Login to W3D Hub is now possible
This commit is contained in:
@@ -35,12 +35,12 @@ class W3DHub
|
||||
|
||||
# Available to download
|
||||
stack(width: 1.0, height: 0.8, padding: 8, scroll: true) do
|
||||
[W3DHub::Game.games + W3DHub::Game.games].flatten.each_with_index do |game, i|
|
||||
@host.applications.games.reject { |g| g.id == "ren" }.each_with_index do |game, i|
|
||||
flow(width: 1.0, height: 64, padding: 8) do
|
||||
background 0xff_333333 if i.odd?
|
||||
|
||||
flow(width: 0.7, height: 1.0) do
|
||||
image game.icon, width: 0.1, margin_right: 8
|
||||
image "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png", width: 0.1, margin_right: 8
|
||||
|
||||
stack(width: 0.9, height: 1.0) do
|
||||
title game.name
|
||||
@@ -49,9 +49,21 @@ class W3DHub
|
||||
end
|
||||
|
||||
flow(width: 0.3, height: 1.0) do
|
||||
list_box items: ["Release", "1.7 Beta"]
|
||||
version_selector = list_box items: game.channels.map { |c| c.name }, width: 0.499, enabled: game.channels.count > 1
|
||||
version_selector.subscribe(:changed) do |item|
|
||||
p item.value
|
||||
end
|
||||
|
||||
button "Install"
|
||||
button "Install", width: 0.5 do
|
||||
# Download/verify game-channel manifest
|
||||
# Download broken/missing files
|
||||
# Unpack
|
||||
# Configure
|
||||
# Disable install
|
||||
# Enable Uninstall
|
||||
|
||||
get
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -172,8 +172,10 @@ class W3DHub
|
||||
|
||||
stack(width: 0.6, height: 1.0) do
|
||||
stack(width: 1.0, height: 112) do
|
||||
para "<b>#{item.title}</b>"
|
||||
inscription "#{item.blurb.strip[0..180]}"
|
||||
link "<b>#{item.title}</b>", text_size: 18 do
|
||||
Launchy.open(item.uri)
|
||||
end
|
||||
inscription item.blurb.gsub(/\n+/, "\n").strip[0..180]
|
||||
end
|
||||
|
||||
flow(width: 1.0) do
|
||||
|
||||
@@ -37,11 +37,41 @@ class W3DHub
|
||||
# Do network stuff
|
||||
|
||||
Thread.new do
|
||||
sleep 0.2
|
||||
account = Api.user_login(@username.value, @password.value)
|
||||
|
||||
main_thread_queue << proc { populate_account_info; page(W3DHub::Pages::Games) }
|
||||
if account
|
||||
@host.account = account
|
||||
|
||||
ext = File.basename(account.avatar_uri).split(".").last
|
||||
path = "#{CACHE_PATH}/#{Digest::SHA2.hexdigest(account.avatar_uri)}.#{ext}"
|
||||
|
||||
unless File.exist?(path)
|
||||
response = Excon.get(account.avatar_uri)
|
||||
|
||||
if response.status == 200
|
||||
File.open(path, "wb") do |f|
|
||||
f.write(response.body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
main_thread_queue << proc { populate_account_info; page(W3DHub::Pages::Games) }
|
||||
else
|
||||
# An error occurred, enable account entry
|
||||
# FIXME: Show an error message
|
||||
# NOTE: Too many incorrect entries causes lock out (Unknown duration)
|
||||
main_thread_queue << proc do
|
||||
@username.enabled = true
|
||||
@password.enabled = true
|
||||
btn.enabled = true
|
||||
|
||||
@error_label.value = "Incorrect username or password.\nOr too many failed login attempts."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@error_label = caption "", width: 1.0, text_align: :center, color: 0xff_800000
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -52,15 +82,19 @@ class W3DHub
|
||||
@host.instance_variable_get(:"@account_container").clear do
|
||||
stack(width: 0.7, height: 1.0) do
|
||||
# background 0xff_222222
|
||||
tagline "<b>#{@username.value}</b>"
|
||||
tagline "<b>#{@host.account.username}</b>"
|
||||
|
||||
flow(width: 1.0) do
|
||||
link("Logout", text_size: 16) { depopulate_account_info }
|
||||
link "Profile", text_size: 16
|
||||
link "Profile", text_size: 16 do
|
||||
Launchy.open("https://secure.w3dhub.com/forum/index.php?showuser=#{@host.account.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/singleplayer.png", height: 1.0
|
||||
ext = File.basename(@host.account.avatar_uri).split(".").last
|
||||
path = "#{CACHE_PATH}/#{Digest::SHA2.hexdigest(@host.account.avatar_uri)}.#{ext}"
|
||||
image path, height: 1.0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,7 +106,9 @@ class W3DHub
|
||||
|
||||
flow(width: 1.0) do
|
||||
link("Log in", text_size: 16) { page(W3DHub::Pages::Login) }
|
||||
link "Register", text_size: 16
|
||||
link "Register", text_size: 16 do
|
||||
Launchy.open("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user