Fixed ICO implementation having a top and left offset for bitmap images, icons are now fetched at start up instead of statically being included (More work needed to fetch them after logging), fixed importer incorrectly storing executable basename instead of dirname
6
.gitignore
vendored
@@ -2,4 +2,8 @@
|
||||
data/cache/*
|
||||
!data/cache/.gitkeep
|
||||
_*.*
|
||||
*.log
|
||||
*.log
|
||||
media/icons/*
|
||||
!media/icons/app.*
|
||||
!media/icons/default_icon.png
|
||||
!media/icons/w3dhub.png
|
||||
@@ -148,6 +148,7 @@ class W3DHub
|
||||
hash = JSON.parse(response.read, symbolize_names: true)
|
||||
hash[:packages].map { |pkg| Package.new(pkg) }
|
||||
else
|
||||
pp response
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -247,7 +247,7 @@ class W3DHub
|
||||
|
||||
def imported!(task, exe_path)
|
||||
application_data = {
|
||||
install_directory: File.basename(exe_path),
|
||||
install_directory: File.dirname(exe_path),
|
||||
installed_version: task.channel.current_version,
|
||||
install_path: exe_path,
|
||||
wine_prefix: task.wine_prefix
|
||||
|
||||
@@ -36,7 +36,11 @@ class W3DHub
|
||||
def self.package_path(category, subcategory, name, version)
|
||||
package_cache_dir = Store.settings[:package_cache_dir]
|
||||
|
||||
"#{package_cache_dir}/#{category}/#{subcategory}/#{version}/#{name}.package"
|
||||
if version.to_s.length.zero?
|
||||
"#{package_cache_dir}/#{category}/#{subcategory}/#{name}.package"
|
||||
else
|
||||
"#{package_cache_dir}/#{category}/#{subcategory}/#{version}/#{name}.package"
|
||||
end
|
||||
end
|
||||
|
||||
def self.install_path(application, channel)
|
||||
|
||||
20
lib/ico.rb
@@ -85,7 +85,7 @@ class W3DHub
|
||||
|
||||
def select_bmps
|
||||
@images.select do |image|
|
||||
image_bmp?(image)
|
||||
image_bmp?(image) && image.palette_size == 0 && image.bit_depth == 32
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,9 +103,12 @@ class W3DHub
|
||||
|
||||
blob = "".force_encoding("ASCII-8BIT")
|
||||
|
||||
width = image.width
|
||||
height = image.height - 1
|
||||
|
||||
image.height.times do |y|
|
||||
image.width.times do |x|
|
||||
buf.pos = ((image.height - y) * image.width + x) * 4
|
||||
buf.pos = ((height - y) * width + x + 10) * 4
|
||||
|
||||
blue = buf.read(1)
|
||||
green = buf.read(1)
|
||||
@@ -121,5 +124,18 @@ class W3DHub
|
||||
|
||||
Gosu::Image.from_blob(image.width, image.height, blob)
|
||||
end
|
||||
|
||||
def image_data(image)
|
||||
@file.pos = image.image_offset
|
||||
StringIO.new(@file.read(image.image_size)).string
|
||||
end
|
||||
|
||||
def save(image, filename)
|
||||
if image_bmp?(image)
|
||||
to_rgba32_blob(image).save(filename)
|
||||
else
|
||||
File.write(filename, image_data(image))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,6 +14,7 @@ class W3DHub
|
||||
refresh_user_token: { started: false, complete: false },
|
||||
service_status: { started: false, complete: false },
|
||||
applications: { started: false, complete: false },
|
||||
app_icons: { started: false, complete: false },
|
||||
server_list: { started: false, complete: false }
|
||||
}
|
||||
|
||||
@@ -118,6 +119,41 @@ class W3DHub
|
||||
end
|
||||
end
|
||||
|
||||
def app_icons
|
||||
return unless Store.applications
|
||||
|
||||
packages = []
|
||||
Store.applications.games.each do |app|
|
||||
packages << { category: app.category, subcategory: app.id, name: "#{app.id}.ico", version: "" }
|
||||
end
|
||||
|
||||
if (package_details = Api.package_details(packages))
|
||||
package_details.each do |package|
|
||||
path = Cache.package_path(package.category, package.subcategory, package.name, package.version)
|
||||
generated_icon_path = "#{GAME_ROOT_PATH}/media/icons/#{package.subcategory}.png"
|
||||
|
||||
regenerate = false
|
||||
|
||||
if File.exist?(path)
|
||||
regenerate = Digest::SHA256.new.hexdigest(File.binread(path)).upcase != package.checksum.upcase
|
||||
regenerate ||= !File.exist?(generated_icon_path)
|
||||
else
|
||||
Cache.fetch_package(package, proc {})
|
||||
regenerate = true
|
||||
end
|
||||
|
||||
if regenerate
|
||||
ico = ICO.new(file: path)
|
||||
image = ico.images.sort_by(&:width).last
|
||||
|
||||
ico.save(image, generated_icon_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@tasks[:app_icons][:complete] = true
|
||||
end
|
||||
|
||||
def server_list
|
||||
@status_label.value = I18n.t(:"server_browser.fetching_server_list")
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 28 KiB |