From 0d997d6ad5daa5934d94f3cbfff615beb3ab7efd Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 1 Mar 2025 05:42:40 -0800 Subject: [PATCH] Add new image sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Weapons can now download the “raw”image size, which is the weapon art without a background * Characters now download the “detail” image size, which is a horizontal crop of the character’s art * Summons now download the “detail” image size, which is a horizontal crop of the summon’s art * Summons also download “ls” and “m” instead of “party_main” and “party_sub”, as they match the aspect ratio of weapon sizes better, which should make our lives a lot easier. --- lib/granblue/downloaders/character_downloader.rb | 8 +++++++- lib/granblue/downloaders/summon_downloader.rb | 12 +++++++++--- lib/granblue/downloaders/weapon_downloader.rb | 12 ++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/granblue/downloaders/character_downloader.rb b/lib/granblue/downloaders/character_downloader.rb index c5028d5..feed390 100644 --- a/lib/granblue/downloaders/character_downloader.rb +++ b/lib/granblue/downloaders/character_downloader.rb @@ -77,7 +77,12 @@ module Granblue # @return [String] Complete URL for downloading the image def build_variant_url(variant_id, size) directory = directory_for_size(size) - "#{@base_url}/#{directory}/#{variant_id}.jpg" + + if size == 'detail' + "#{@base_url}/#{directory}/#{variant_id}.png" + else + "#{@base_url}/#{directory}/#{variant_id}.jpg" + end end # Gets object type for file paths and storage keys @@ -102,6 +107,7 @@ module Granblue when 'main' then 'f' when 'grid' then 'm' when 'square' then 's' + when 'detail' then 'detail' end end end diff --git a/lib/granblue/downloaders/summon_downloader.rb b/lib/granblue/downloaders/summon_downloader.rb index 540b9e1..39a19a4 100644 --- a/lib/granblue/downloaders/summon_downloader.rb +++ b/lib/granblue/downloaders/summon_downloader.rb @@ -79,7 +79,11 @@ module Granblue # @return [String] Complete URL for downloading the image def build_variant_url(variant_id, size) directory = directory_for_size(size) - "#{@base_url}/#{directory}/#{variant_id}.jpg" + if size == 'detail' + "#{@base_url}/#{directory}/#{variant_id}.png" + else + "#{@base_url}/#{directory}/#{variant_id}.jpg" + end end # Gets object type for file paths and storage keys @@ -95,14 +99,16 @@ module Granblue end # Gets directory name for a size variant + # # @param size [String] Image size variant # @return [String] Directory name in game asset URL structure # @note Maps "main" -> "party_main", "grid" -> "party_sub", "square" -> "s" def directory_for_size(size) case size.to_s - when 'main' then 'party_main' - when 'grid' then 'party_sub' + when 'main' then 'ls' + when 'grid' then 'm' when 'square' then 's' + when 'detail' then 'detail' end end end diff --git a/lib/granblue/downloaders/weapon_downloader.rb b/lib/granblue/downloaders/weapon_downloader.rb index 834b824..5207f97 100644 --- a/lib/granblue/downloaders/weapon_downloader.rb +++ b/lib/granblue/downloaders/weapon_downloader.rb @@ -42,9 +42,7 @@ module Granblue variants = [@id] # Add transcendence variants if available - if weapon.transcendence - variants.push("#{@id}_02", "#{@id}_03") - end + variants.push("#{@id}_02", "#{@id}_03") if weapon.transcendence log_info "Downloading weapon variants: #{variants.join(', ')}" if @verbose @@ -79,7 +77,11 @@ module Granblue # @return [String] Complete URL for downloading the image def build_variant_url(variant_id, size) directory = directory_for_size(size) - "#{@base_url}/#{directory}/#{variant_id}.jpg" + if size == 'raw' + "#{@base_url}/#{directory}/#{variant_id}.png" + else + "#{@base_url}/#{directory}/#{variant_id}.jpg" + end end # Gets object type for file paths and storage keys @@ -95,6 +97,7 @@ module Granblue end # Gets directory name for a size variant + # # @param size [String] Image size variant # @return [String] Directory name in game asset URL structure # @note Maps "main" -> "ls", "grid" -> "m", "square" -> "s" @@ -103,6 +106,7 @@ module Granblue when 'main' then 'ls' when 'grid' then 'm' when 'square' then 's' + when 'raw' then 'b' end end end