mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Initial pass at lazily loading app icons
This commit is contained in:
@@ -71,9 +71,14 @@ module W3DHubLauncher
|
|||||||
def populate_games_list
|
def populate_games_list
|
||||||
@games_list_container.clear do
|
@games_list_container.clear do
|
||||||
@games.each_with_index do |game, i|
|
@games.each_with_index do |game, i|
|
||||||
button(safe_get_image("#{ROOT_PATH}/data/cache/#{game.id}.png"), tag: :"image_icon_#{game.id}", style_class: [:app_icon_button], enabled: @current_app.id != game.id, tip: game.name) do |btn|
|
btn = button(safe_get_image("#{CACHE_PATH}/icon_#{game.id}.png"), tag: :"image_icon_#{game.id}", style_class: [:app_icon_button], enabled: @current_app.id != game.id, tip: game.name) do |btn|
|
||||||
populate_game(game, game&.channels&.first)
|
populate_game(game, game&.channels&.first)
|
||||||
end
|
end
|
||||||
|
remote_image("#{CACHE_PATH}/icon_#{game.id}.ico", url: "https://s3.w3d.cyberarm.dev/games/#{game.id}/#{game.id}.ico", element: btn) do |e, path|
|
||||||
|
Worker::Api.ico_to_png(ico_path: path, png_path: path.sub(".ico", ".png")) do |result|
|
||||||
|
e&.value = safe_get_image(result.data["path"]) if result.okay?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts
|
puts
|
||||||
@@ -87,8 +92,8 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
@game_info_container.clear do
|
@game_info_container.clear do
|
||||||
# logo
|
# logo
|
||||||
img = image safe_get_image("#{ROOT_PATH}/data/cache/logo_#{@current_app.id}.png"), tag: :"image_logo_#{@current_app.id}", width: 1.0, max_height: 124
|
img = image safe_get_image("#{CACHE_PATH}/logo_#{@current_app.id}.png"), tag: :"image_logo_#{@current_app.id}", width: 1.0, max_height: 124
|
||||||
remote_image("#{ROOT_PATH}/data/cache/logo_#{@current_app.id}.png", url: "https://s3.w3d.cyberarm.dev/games/#{@current_app.id}/logo.png", element: img) do |e, path|
|
remote_image("#{CACHE_PATH}/logo_#{@current_app.id}.png", url: "https://s3.w3d.cyberarm.dev/games/#{@current_app.id}/logo.png", element: img) do |e, path|
|
||||||
e&.value = safe_get_image(path)
|
e&.value = safe_get_image(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module W3DHubLauncher
|
|||||||
MemCache[:applications].each do |app|
|
MemCache[:applications].each do |app|
|
||||||
next unless app.game?
|
next unless app.game?
|
||||||
|
|
||||||
button(safe_get_image("#{ROOT_PATH}/data/cache/#{app.id}.png"), style_class: [:app_icon_button], tip: app.name) do |btn|
|
button(safe_get_image("#{CACHE_PATH}/icon_#{app.id}.png"), style_class: [:app_icon_button], tip: app.name) do |btn|
|
||||||
if shift_down?
|
if shift_down?
|
||||||
@games_filter << app.id
|
@games_filter << app.id
|
||||||
@games_filter.uniq!
|
@games_filter.uniq!
|
||||||
@@ -56,7 +56,7 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
widget(width: 1.0, height: 48, padding_top: HALF_PADDING, padding_bottom: HALF_PADDING, margin_bottom: HALF_PADDING, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: server.channel == "release" ? ALPHA_GRAY : 0xaa_c64600, hover: { background_nine_slice_color: 0xff_5e5c64 } , active: { background_nine_slice_color: 0xaa_5e5c64 }) do
|
widget(width: 1.0, height: 48, padding_top: HALF_PADDING, padding_bottom: HALF_PADDING, margin_bottom: HALF_PADDING, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: server.channel == "release" ? ALPHA_GRAY : 0xaa_c64600, hover: { background_nine_slice_color: 0xff_5e5c64 } , active: { background_nine_slice_color: 0xaa_5e5c64 }) do
|
||||||
# app icon container
|
# app icon container
|
||||||
image(safe_get_image("#{ROOT_PATH}/data/cache/#{app.id}.png"), tip: app.name, width: 48, height: 1.0, margin_left: HALF_PADDING)
|
image(safe_get_image("#{CACHE_PATH}/icon_#{app.id}.png"), tip: app.name, width: 48, height: 1.0, margin_left: HALF_PADDING)
|
||||||
|
|
||||||
# server name, region, and times container
|
# server name, region, and times container
|
||||||
stack(fill: true, height: 1.0, margin_left: HALF_PADDING) do
|
stack(fill: true, height: 1.0, margin_left: HALF_PADDING) do
|
||||||
|
|||||||
@@ -147,6 +147,9 @@ module W3DHubLauncher
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
rescue JSON::ParserError => e
|
||||||
|
puts "This should never happen!?!?!"
|
||||||
|
|
||||||
rescue Errno::EWOULDBLOCK
|
rescue Errno::EWOULDBLOCK
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -157,6 +160,14 @@ module W3DHubLauncher
|
|||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_directory(path)
|
||||||
|
pathname = Pathname.new(path)
|
||||||
|
|
||||||
|
unless Dir.exist?(pathname.dirname)
|
||||||
|
FileUtils.mkdir_p(pathname.dirname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# ------------ query / request handlers ------------
|
# ------------ query / request handlers ------------
|
||||||
#
|
#
|
||||||
@@ -194,6 +205,8 @@ module W3DHubLauncher
|
|||||||
headers = query.data["headers"] || DEFAULT_HEADERS
|
headers = query.data["headers"] || DEFAULT_HEADERS
|
||||||
body = query.data["body"]
|
body = query.data["body"]
|
||||||
|
|
||||||
|
create_directory(path)
|
||||||
|
|
||||||
Sync do |task|
|
Sync do |task|
|
||||||
task.with_timeout(DEFAULT_NETWORK_TIMEOUT) do
|
task.with_timeout(DEFAULT_NETWORK_TIMEOUT) do
|
||||||
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
||||||
@@ -230,6 +243,20 @@ module W3DHubLauncher
|
|||||||
deliver_response(result, query)
|
deliver_response(result, query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ico_to_png(query)
|
||||||
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
|
begin
|
||||||
|
ico = ICO.new(file: query.data["ico_path"])
|
||||||
|
ico.save(ico.images.max_by(&:width), query.data["png_path"])
|
||||||
|
result.data = { path: query.data["png_path"] }
|
||||||
|
rescue => e
|
||||||
|
result.error = e
|
||||||
|
end
|
||||||
|
|
||||||
|
deliver_response(result, query)
|
||||||
|
end
|
||||||
|
|
||||||
def dns_resolution(query)
|
def dns_resolution(query)
|
||||||
result = CyberarmEngine::Result.new
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ module W3DHubLauncher
|
|||||||
Worker::Request.new(:download_url, { url: url, path: path, method: method, headers: headers, body: body }, &block)
|
Worker::Request.new(:download_url, { url: url, path: path, method: method, headers: headers, body: body }, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.ico_to_png(ico_path:, png_path:, &block)
|
||||||
|
Worker::Request.new(:ico_to_png, { ico_path: ico_path, png_path: png_path }, &block)
|
||||||
|
end
|
||||||
|
|
||||||
def self.dns_resolution(&block)
|
def self.dns_resolution(&block)
|
||||||
Worker::Request.new(:dns_resolution, "", &block)
|
Worker::Request.new(:dns_resolution, "", &block)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ require "rexml"
|
|||||||
require "base64"
|
require "base64"
|
||||||
require "logger"
|
require "logger"
|
||||||
require "digest"
|
require "digest"
|
||||||
|
require "pathname"
|
||||||
|
require "fileutils"
|
||||||
|
|
||||||
require "async"
|
require "async"
|
||||||
require "async/http/internet/instance"
|
require "async/http/internet/instance"
|
||||||
@@ -37,6 +39,9 @@ require_relative "lib/states/boot"
|
|||||||
require_relative "lib/states/interface"
|
require_relative "lib/states/interface"
|
||||||
require_relative "lib/window"
|
require_relative "lib/window"
|
||||||
|
|
||||||
|
require_relative "lib/ico"
|
||||||
|
require_relative "lib/ww_mix"
|
||||||
|
|
||||||
require_relative "lib/worker"
|
require_relative "lib/worker"
|
||||||
require_relative "lib/worker/api"
|
require_relative "lib/worker/api"
|
||||||
require_relative "lib/worker/api/application"
|
require_relative "lib/worker/api/application"
|
||||||
|
|||||||
Reference in New Issue
Block a user