Download alt sprites

This commit is contained in:
infinitefusion
2023-05-07 15:29:50 -04:00
parent 51e5bb2450
commit f9c02bf8ab
5 changed files with 51 additions and 9 deletions

Binary file not shown.

View File

@@ -25,11 +25,12 @@ class StorageSystemPC
end end
def name def name
if $Trainer.seen_storage_creator return "Pokemon Storage"
return _INTL("{1}'s PC",pbGetStorageCreator) #if $Trainer.seen_storage_creator
else # return _INTL("{1}'s PC",pbGetStorageCreator)
return _INTL("Someone's PC") #else
end # return _INTL("Someone's PC")
#end
end end
def access def access

View File

@@ -35,11 +35,12 @@ end
def download_sprite(base_path, head_id, body_id, saveLocation = "Graphics/temp") def download_sprite(base_path, head_id, body_id, saveLocation = "Graphics/temp", alt_letter= "")
begin begin
downloaded_file_name = _INTL("{1}/{2}.{3}.png", saveLocation, head_id, body_id) downloaded_file_name = _INTL("{1}/{2}.{3}{4}.png", saveLocation, head_id, body_id,alt_letter)
return downloaded_file_name if pbResolveBitmap(downloaded_file_name) return downloaded_file_name if pbResolveBitmap(downloaded_file_name)
url = _INTL(base_path, head_id, body_id) url = _INTL(base_path, head_id, body_id)
echo "\nSending request to " + url
response = HTTPLite.get(url) response = HTTPLite.get(url)
if response[:status] == 200 if response[:status] == 200
File.open(downloaded_file_name, "wb") do |file| File.open(downloaded_file_name, "wb") do |file|
@@ -77,6 +78,22 @@ def download_custom_sprite(head_id, body_id)
return nil return nil
end end
def download_alt_sprites(head_id,body_id)
base_url = "https://raw.githubusercontent.com/infinitefusion/sprites/main/CustomBattlers/{1}.{2}"
extension = ".png"
destPath = _INTL("{1}{2}", Settings::CUSTOM_BATTLERS_FOLDER_INDEXED, head_id)
if !Dir.exist?(destPath)
Dir.mkdir(destPath)
end
alphabet = ('a'..'z').to_a
alphabet.each do |letter|
alt_url = base_url + letter + extension
sprite = download_sprite(alt_url, head_id, body_id, destPath, letter)
return if !sprite
end
end
#format: [1.1.png, 1.2.png, etc.] #format: [1.1.png, 1.2.png, etc.]
# https://api.github.com/repos/infinitefusion/contents/sprites/CustomBattlers # https://api.github.com/repos/infinitefusion/contents/sprites/CustomBattlers
# repo = "Aegide/custom-fusion-sprites" # repo = "Aegide/custom-fusion-sprites"

View File

@@ -96,9 +96,13 @@ class PokemonPokedexInfo_Scene
def pbGetAvailableForms def pbGetAvailableForms
body_id = getBodyID(@species)
head_id = getHeadID(@species,body_id)
download_custom_sprite(head_id,body_id)
download_autogen_sprite(head_id,body_id)
download_alt_sprites(head_id,body_id)
return PokedexUtils.new.pbGetAvailableAlts(@species) return PokedexUtils.new.pbGetAvailableAlts(@species)
end end
def hide_all_selected_windows def hide_all_selected_windows
@sprites["bgSelected_previous"].visible = false if @sprites["bgSelected_previous"] @sprites["bgSelected_previous"].visible = false if @sprites["bgSelected_previous"]
@sprites["bgSelected_center"].visible = false if @sprites["bgSelected_center"] @sprites["bgSelected_center"].visible = false if @sprites["bgSelected_center"]
@@ -251,4 +255,24 @@ class PokemonPokedexInfo_Scene
# return POSSIBLE_ALTS.include?(File.basename(old_main_sprite, ".png")[-1]) # return POSSIBLE_ALTS.include?(File.basename(old_main_sprite, ".png")[-1])
end end
end
end
class PokemonGlobalMetadata
attr_accessor :alt_sprite_substitutions
def initialize
@alt_sprite_substitutions = {}
end
end
def set_alt_sprite_substitution(original_sprite_name,selected_alt)
if ! $PokemonGlobal.alt_sprite_substitutions
$PokemonGlobal.alt_sprite_substitutions = {}
end
$PokemonGlobal.alt_sprite_substitutions[original_sprite_name] = selected_alt
p $PokemonGlobal.alt_sprite_substitutions
end

Binary file not shown.