mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-08 02:54:10 +00:00
Compare commits
5 Commits
4bfb494abe
...
16742ea5fa
| Author | SHA1 | Date | |
|---|---|---|---|
| 16742ea5fa | |||
| 073f5bebf9 | |||
| 57287de742 | |||
| 99dc27ced2 | |||
| de6bfb85f5 |
@@ -55,15 +55,7 @@ module W3DHubLauncher
|
|||||||
if result.okay?
|
if result.okay?
|
||||||
hash = JSON.parse(result.data)
|
hash = JSON.parse(result.data)
|
||||||
|
|
||||||
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.create(
|
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.new(hash)
|
||||||
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"]
|
|
||||||
)
|
|
||||||
|
|
||||||
Worker::Api.update_settings(MemCache[:settings]) do |settings_result|
|
Worker::Api.update_settings(MemCache[:settings]) do |settings_result|
|
||||||
if settings_result.okay?
|
if settings_result.okay?
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -335,10 +336,11 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
def populate_account_information
|
def populate_account_information
|
||||||
account = MemCache[:settings].account
|
account = MemCache[:settings].account
|
||||||
|
avatar_path = account ? "#{CACHE_PATH}/avatar_#{account&.user_id}#{File.extname(account&.avatar_uri)}" : nil
|
||||||
|
|
||||||
@account_container.clear do
|
@account_container.clear do
|
||||||
# self avatar container
|
# 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
|
# self online state container
|
||||||
stack(
|
stack(
|
||||||
width: 20,
|
width: 20,
|
||||||
@@ -346,9 +348,13 @@ module W3DHubLauncher
|
|||||||
v_align: :bottom,
|
v_align: :bottom,
|
||||||
h_align: :right,
|
h_align: :right,
|
||||||
background_image: safe_get_image("#{ROOT_PATH}/media/ui/circle_small.png"),
|
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
|
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
|
end
|
||||||
|
|
||||||
stack(fill: true, height: 1.0, margin_left: HALF_PADDING) do
|
stack(fill: true, height: 1.0, margin_left: HALF_PADDING) do
|
||||||
@@ -377,6 +383,14 @@ module W3DHubLauncher
|
|||||||
flow(fill: true)
|
flow(fill: true)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def button_up(id)
|
def button_up(id)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -372,7 +372,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
|
||||||
|
|
||||||
|
|||||||
@@ -93,21 +93,71 @@ module W3DHubLauncher
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_login(username, password, &block)
|
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}))
|
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))
|
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
|
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
|
||||||
@@ -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))
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user