mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Changed how account data is stored, authorization header is now sent when logged in, adjusted spacing game filters for server list, fixed crashing when trying to load icon for game whos icon is not present, a bit of code cleanup to Api to use Async::HTTP::Client over Async::Internet directly (for everything except get requests), probably a few misc. changes
This commit is contained in:
@@ -63,18 +63,18 @@ class W3DHub
|
||||
Async do
|
||||
internet = Async::HTTP::Internet.instance
|
||||
|
||||
fetch_w3dhub_news(internet)
|
||||
fetch_w3dhub_news
|
||||
populate_w3dhub_news
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_w3dhub_news(internet)
|
||||
news = Api.news(internet, "launcher-home")
|
||||
def fetch_w3dhub_news
|
||||
news = Api.news("launcher-home")
|
||||
|
||||
if news
|
||||
news.items[0..9].each do |item|
|
||||
Cache.fetch(internet, item.image)
|
||||
Cache.fetch(item.image)
|
||||
end
|
||||
|
||||
@w3dhub_news = news
|
||||
|
||||
@@ -28,7 +28,8 @@ class W3DHub
|
||||
background task.application.color
|
||||
|
||||
flow(width: 0.70, height: 1.0) do
|
||||
@application_image = image "#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png", height: 1.0
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
@application_image = image image_path, height: 1.0
|
||||
|
||||
stack(margin_left: 8, width: 0.75) do
|
||||
@application_name_label = tagline "#{task.application.name}"
|
||||
|
||||
@@ -4,7 +4,9 @@ class W3DHub
|
||||
def setup
|
||||
@game_news ||= {}
|
||||
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
||||
@focused_game ||= Store.applications.games.find { |g| g.id == "ren" }
|
||||
@focused_channel ||= @focused_game.channels.find { |c| c.id == Store.settings[:last_selected_channel] }
|
||||
@focused_channel ||= @focused_game.channels.first
|
||||
|
||||
body.clear do
|
||||
# Games List
|
||||
@@ -38,7 +40,9 @@ class W3DHub
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/return.png", width: 1.0, color: Gosu::Color::GRAY if Store.application_manager.updateable?(game.id, game.channels.first.id)
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/import.png", width: 0.5, color: 0x88_ffffff unless Store.application_manager.installed?(game.id, game.channels.first.id)
|
||||
end
|
||||
image "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png", height: 48, color: Store.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0x88_ffffff
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{game.id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
|
||||
image image_path, height: 48, color: Store.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0x88_ffffff
|
||||
end
|
||||
inscription game.name, width: 1.0, text_align: :center
|
||||
end
|
||||
@@ -168,20 +172,18 @@ class W3DHub
|
||||
end
|
||||
|
||||
Async do
|
||||
internet = Async::HTTP::Internet.instance
|
||||
|
||||
fetch_game_news(internet, game)
|
||||
fetch_game_news(game)
|
||||
populate_game_news(game)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_game_news(internet, game)
|
||||
news = Api.news(internet, game.id)
|
||||
def fetch_game_news(game)
|
||||
news = Api.news(game.id)
|
||||
|
||||
if news
|
||||
news.items[0..9].each do |item|
|
||||
Cache.fetch(internet, item.image)
|
||||
Cache.fetch(item.image)
|
||||
end
|
||||
|
||||
@game_news[game.id] = news
|
||||
|
||||
@@ -37,18 +37,20 @@ class W3DHub
|
||||
# Do network stuff
|
||||
|
||||
Async do
|
||||
internet = Async::HTTP::Internet.instance
|
||||
|
||||
account = Api.user_login(internet, @username.value, @password.value)
|
||||
account = Api.user_login(@username.value, @password.value)
|
||||
|
||||
if account
|
||||
Store.account = account
|
||||
Store.settings[:account][:refresh_token] = account.refresh_token
|
||||
Store.settings[:account][:data] = account
|
||||
Store.settings.save_settings
|
||||
|
||||
Cache.fetch(internet, account.avatar_uri, true)
|
||||
internet = Async::HTTP::Internet.instance
|
||||
Cache.fetch(account.avatar_uri, true)
|
||||
|
||||
populate_account_info
|
||||
applications = Api.applications
|
||||
Store.applications = applications if applications
|
||||
|
||||
page(W3DHub::Pages::Games)
|
||||
else
|
||||
# An error occurred, enable account entry
|
||||
@@ -70,8 +72,7 @@ class W3DHub
|
||||
|
||||
if Store.account
|
||||
Async do
|
||||
internet = Async::HTTP::Internet.instance
|
||||
Cache.fetch(internet, Store.account.avatar_uri)
|
||||
Cache.fetch(Store.account.avatar_uri)
|
||||
|
||||
populate_account_info
|
||||
page(W3DHub::Pages::Games)
|
||||
@@ -98,10 +99,13 @@ class W3DHub
|
||||
end
|
||||
|
||||
def depopulate_account_info
|
||||
Store.settings[:account][:refresh_token] = nil
|
||||
Store.settings[:account] = {}
|
||||
Store.settings.save_settings
|
||||
Store.account = nil
|
||||
|
||||
applications = Api.applications
|
||||
Store.applications if applications
|
||||
|
||||
@host.instance_variable_get(:"@account_container").clear do
|
||||
stack(width: 0.7, height: 1.0) do
|
||||
# background 0xff_222222
|
||||
|
||||
@@ -26,9 +26,11 @@ class W3DHub
|
||||
@filters.each do |app_id, enabled|
|
||||
app = Store.applications.games.find { |a| a.id == app_id.to_s }
|
||||
|
||||
image "#{GAME_ROOT_PATH}/media/icons/#{app_id}.png", tip: "#{app.name}", height: 1.0,
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{app_id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{app_id}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
|
||||
image image_path, tip: "#{app.name}", height: 1.0,
|
||||
border_thickness_bottom: 1, border_color_bottom: 0x00_000000,
|
||||
color: enabled ? 0xff_ffffff : 0xff_444444, hover: { border_color_bottom: 0xff_aaaaaa }, margin_right: 32 do |img|
|
||||
color: enabled ? 0xff_ffffff : 0xff_444444, hover: { border_color_bottom: 0xff_aaaaaa }, margin_right: 16 do |img|
|
||||
@filters[app_id] = !@filters[app_id]
|
||||
Store.settings[:server_list_filters] = @filters
|
||||
Store.settings.save_settings
|
||||
@@ -359,9 +361,11 @@ class W3DHub
|
||||
end
|
||||
|
||||
def game_icon(server)
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
|
||||
if server.status.password
|
||||
@server_locked_icons[server.game] ||= Gosu.render(96, 96) do
|
||||
i = get_image("#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png")
|
||||
i = get_image(image_path)
|
||||
lock = get_image("#{GAME_ROOT_PATH}/media/ui_icons/locked.png")
|
||||
scale = [96.0 / i.width, 96.0 / i.height].min
|
||||
|
||||
@@ -369,7 +373,7 @@ class W3DHub
|
||||
lock.draw(96 - lock.width * 0.5, 96 - lock.height * 0.5, 0, 0.5, 0.5, 0xff_ff8800)
|
||||
end
|
||||
else
|
||||
"#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png"
|
||||
image_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user