Add new image sizes

* 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.
This commit is contained in:
Justin Edmund 2025-03-01 05:42:40 -08:00
parent 5955ef2650
commit 0d997d6ad5
3 changed files with 24 additions and 8 deletions

View file

@ -77,8 +77,13 @@ module Granblue
# @return [String] Complete URL for downloading the image # @return [String] Complete URL for downloading the image
def build_variant_url(variant_id, size) def build_variant_url(variant_id, size)
directory = directory_for_size(size) directory = directory_for_size(size)
if size == 'detail'
"#{@base_url}/#{directory}/#{variant_id}.png"
else
"#{@base_url}/#{directory}/#{variant_id}.jpg" "#{@base_url}/#{directory}/#{variant_id}.jpg"
end end
end
# Gets object type for file paths and storage keys # Gets object type for file paths and storage keys
# @return [String] Returns "character" # @return [String] Returns "character"
@ -102,6 +107,7 @@ module Granblue
when 'main' then 'f' when 'main' then 'f'
when 'grid' then 'm' when 'grid' then 'm'
when 'square' then 's' when 'square' then 's'
when 'detail' then 'detail'
end end
end end
end end

View file

@ -79,8 +79,12 @@ module Granblue
# @return [String] Complete URL for downloading the image # @return [String] Complete URL for downloading the image
def build_variant_url(variant_id, size) def build_variant_url(variant_id, size)
directory = directory_for_size(size) directory = directory_for_size(size)
if size == 'detail'
"#{@base_url}/#{directory}/#{variant_id}.png"
else
"#{@base_url}/#{directory}/#{variant_id}.jpg" "#{@base_url}/#{directory}/#{variant_id}.jpg"
end end
end
# Gets object type for file paths and storage keys # Gets object type for file paths and storage keys
# @return [String] Returns "summon" # @return [String] Returns "summon"
@ -95,14 +99,16 @@ module Granblue
end end
# Gets directory name for a size variant # Gets directory name for a size variant
#
# @param size [String] Image size variant # @param size [String] Image size variant
# @return [String] Directory name in game asset URL structure # @return [String] Directory name in game asset URL structure
# @note Maps "main" -> "party_main", "grid" -> "party_sub", "square" -> "s" # @note Maps "main" -> "party_main", "grid" -> "party_sub", "square" -> "s"
def directory_for_size(size) def directory_for_size(size)
case size.to_s case size.to_s
when 'main' then 'party_main' when 'main' then 'ls'
when 'grid' then 'party_sub' when 'grid' then 'm'
when 'square' then 's' when 'square' then 's'
when 'detail' then 'detail'
end end
end end
end end

View file

@ -42,9 +42,7 @@ module Granblue
variants = [@id] variants = [@id]
# Add transcendence variants if available # Add transcendence variants if available
if weapon.transcendence variants.push("#{@id}_02", "#{@id}_03") if weapon.transcendence
variants.push("#{@id}_02", "#{@id}_03")
end
log_info "Downloading weapon variants: #{variants.join(', ')}" if @verbose log_info "Downloading weapon variants: #{variants.join(', ')}" if @verbose
@ -79,8 +77,12 @@ module Granblue
# @return [String] Complete URL for downloading the image # @return [String] Complete URL for downloading the image
def build_variant_url(variant_id, size) def build_variant_url(variant_id, size)
directory = directory_for_size(size) directory = directory_for_size(size)
if size == 'raw'
"#{@base_url}/#{directory}/#{variant_id}.png"
else
"#{@base_url}/#{directory}/#{variant_id}.jpg" "#{@base_url}/#{directory}/#{variant_id}.jpg"
end end
end
# Gets object type for file paths and storage keys # Gets object type for file paths and storage keys
# @return [String] Returns "weapon" # @return [String] Returns "weapon"
@ -95,6 +97,7 @@ module Granblue
end end
# Gets directory name for a size variant # Gets directory name for a size variant
#
# @param size [String] Image size variant # @param size [String] Image size variant
# @return [String] Directory name in game asset URL structure # @return [String] Directory name in game asset URL structure
# @note Maps "main" -> "ls", "grid" -> "m", "square" -> "s" # @note Maps "main" -> "ls", "grid" -> "m", "square" -> "s"
@ -103,6 +106,7 @@ module Granblue
when 'main' then 'ls' when 'main' then 'ls'
when 'grid' then 'm' when 'grid' then 'm'
when 'square' then 's' when 'square' then 's'
when 'raw' then 'b'
end end
end end
end end