From ad2e6e728cf405dbf6e92a3acfa19eb4deb73cae Mon Sep 17 00:00:00 2001 From: chardub Date: Thu, 2 Feb 2023 21:43:05 -0500 Subject: [PATCH] Makes it possible to download sprites at runtime --- Data/Scripts/001_Settings.rb | 2 +- .../randomizer gym leader edit.rb | 12 ++++++++- .../Scripts/048_Fusion/DoublePreviewScreen.rb | 11 +++----- Data/Scripts/050_AddOns/GeneralUtils.rb | 13 +++++++-- Data/Scripts/050_AddOns/IntroScreen.rb | 25 ++++++++---------- Data/Scripts/999_Main/999_Main.rb | 8 ++++-- Data/System.rxdata | Bin 27858 -> 27858 bytes 7 files changed, 43 insertions(+), 28 deletions(-) diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index b073a78ec..1797c45b9 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -25,7 +25,7 @@ module Settings CUSTOM_BATTLERS_FOLDER_INDEXED = "Graphics/CustomBattlers/indexed" BATTLERS_FOLDER = "Graphics/Battlers/" DOWNLOADED_SPRITES_FOLDER = "Graphics/temp/" - + DEFAULT_SPRITE_PATH = "Graphics/Battlers/Special/000.png" FRONTSPRITE_POSITION_OFFSET = 20 FRONTSPRITE_SCALE = 0.6666666666 BACKRPSPRITE_SCALE = 1 diff --git a/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb b/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb index b5e9cf5f0..ea06207a7 100644 --- a/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb +++ b/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb @@ -408,7 +408,7 @@ end #end -def getCustomSpeciesList() +def getCustomSpeciesList(allowOnline=true) speciesList = [] for num in 1..NB_POKEMON @@ -429,6 +429,16 @@ def getCustomSpeciesList() end end + + + if speciesList.length <= 200 && allowOnline + #try to get list from github + print "let's try it online bruh" + online_list = list_online_custom_sprites + return online_list if online_list !=nil + end + + return speciesList end # def getCustomSpeciesList() diff --git a/Data/Scripts/048_Fusion/DoublePreviewScreen.rb b/Data/Scripts/048_Fusion/DoublePreviewScreen.rb index da79b4adb..7e67e9d0a 100644 --- a/Data/Scripts/048_Fusion/DoublePreviewScreen.rb +++ b/Data/Scripts/048_Fusion/DoublePreviewScreen.rb @@ -110,7 +110,8 @@ class DoublePreviewScreen bitmap = AnimatedBitmap.new(picturePath) bitmap.scale_bitmap(Settings::FRONTSPRITE_SCALE) - hasCustom = picturePath.include?("CustomBattlers") + #hasCustom = picturePath.include?("CustomBattlers") + hasCustom = customSpriteExistsBase(body_pokemon,head_pokemon) previewwindow = PictureWindow.new(bitmap) previewwindow.x = x @@ -131,13 +132,7 @@ class DoublePreviewScreen def getPicturePath(head_pokemon, body_pokemon) - pathCustom = _INTL("Graphics/CustomBattlers/indexed/{1}/{1}.{2}.png", head_pokemon, body_pokemon) - if (pbResolveBitmap(pathCustom)) - picturePath = pathCustom - else - picturePath = _INTL("Graphics/Battlers/{1}/{1}.{2}.png",head_pokemon , body_pokemon) - end - return picturePath + return get_fusion_sprite_path(head_pokemon,body_pokemon) end def drawFusionInformation(fusedDexNum, level, x = 0) diff --git a/Data/Scripts/050_AddOns/GeneralUtils.rb b/Data/Scripts/050_AddOns/GeneralUtils.rb index 6eee24867..f17b30b5d 100644 --- a/Data/Scripts/050_AddOns/GeneralUtils.rb +++ b/Data/Scripts/050_AddOns/GeneralUtils.rb @@ -132,7 +132,7 @@ end def getRandomCustomFusionForIntro(returnRandomPokemonIfNoneFound = true, customPokeList = [], maxPoke = -1, recursionLimit = 3) if customPokeList.length == 0 - customPokeList = getCustomSpeciesList() + customPokeList = getCustomSpeciesList(false ) end randPoke = [] if customPokeList.length >= 5000 @@ -401,9 +401,18 @@ def customSpriteExists(species) head = getBasePokemonID(species, false) body = getBasePokemonID(species, true) pathCustom = getCustomSpritePath(body,head) - return pbResolveBitmap(pathCustom) != nil + + return true if pbResolveBitmap(pathCustom) != nil + return download_custom_sprite(head, body) != nil end +def customSpriteExistsBase(head,body) + pathCustom = getCustomSpritePath(body,head) + return true if pbResolveBitmap(pathCustom) != nil + return download_custom_sprite(head, body) != nil +end + + def getArceusPlateType(heldItem) return :NORMAL if heldItem == nil case heldItem diff --git a/Data/Scripts/050_AddOns/IntroScreen.rb b/Data/Scripts/050_AddOns/IntroScreen.rb index b7c6a3d61..e8ff1c443 100644 --- a/Data/Scripts/050_AddOns/IntroScreen.rb +++ b/Data/Scripts/050_AddOns/IntroScreen.rb @@ -70,6 +70,7 @@ class Scene_Intro pbBGMStop(1.0) # disposes current title screen disposeTitle + clearTempFolder # initializes load screen sscene = PokemonLoad_Scene.new sscreen = PokemonLoadScreen.new(sscene) @@ -129,19 +130,18 @@ class GenOneStyle Kernel.pbDisplayText("Version " + Settings::GAME_VERSION_NUMBER, 254, 308, 99999) @maxPoke = 140 #1st gen, pas de legend la premiere fois, graduellement plus de poke - @customPokeList = getCustomSpeciesList() + @customPokeList = getCustomSpeciesList(false) #Get random Pokemon (1st gen orandPokenly, pas de legend la prmeiere fois) randPoke = getRandomCustomFusionForIntro(true, @customPokeList, @maxPoke) randpoke1 = randPoke[0] #rand(@maxPoke)+1 randpoke2 = randPoke[1] #rand(@maxPoke)+1 - randpoke1s = randpoke1.to_s randpoke2s = randpoke2.to_s - path_s1 = "Graphics/Battlers/" + randpoke1s + "/" + randpoke1s + ".png" - path_s2 = "Graphics/Battlers/" + randpoke2s + "/" + randpoke2s + ".png" - path_f = getFusedPath(randpoke1, randpoke2) + path_s1 = get_unfused_sprite_path(randpoke1) + path_s2 = get_unfused_sprite_path(randpoke2) + path_f = get_fusion_sprite_path(randpoke1, randpoke2) @prevPoke1 = randpoke1 @prevPoke2 = randpoke2 @@ -219,7 +219,7 @@ class GenOneStyle @sprites["poke"].tone = Tone.new(0, 0, 0, 255) @sprites["poke"].opacity = 0 @sprites["poke2"] = Sprite.new(@viewport) - @sprites["poke2"].bitmap = pbBitmap("Graphics/Battlers/21364") + # @sprites["poke2"].bitmap = pbBitmap("Graphics/Battlers/21364") @sprites["poke2"].tone = Tone.new(255, 255, 255, 255) @sprites["poke2"].src_rect.set(0, Graphics.height, Graphics.width, 48) @sprites["poke2"].y = Graphics.height @@ -372,11 +372,8 @@ class GenOneStyle randpoke1 = randPoke[0] #rand(@maxPoke)+1 randpoke2 = randPoke[1] #rand(@maxPoke)+1 - randpoke1s = randpoke1.to_s - randpoke2s = randpoke2.to_s - - path_s1 = "Graphics/Battlers/" + randpoke1s + "/" + randpoke1s + ".png" - path_s2 = "Graphics/Battlers/" + randpoke2s + "/" + randpoke2s + ".png" + path_s1 = get_unfused_sprite_path(randpoke1) + path_s2 = get_unfused_sprite_path(randpoke2) path_f = getFusedPath(randpoke1, randpoke2) path_fMod = getFusedPath(@prevPoke1, @prevPoke2) @@ -408,11 +405,11 @@ class GenOneStyle #new version def getFusedPath(randpoke1, randpoke2) - path = rand(2) == 0 ? GetSpritePathForced(randpoke1, randpoke2, true) : GetSpritePathForced(randpoke2, randpoke1, true) + path = rand(2) == 0 ? get_fusion_sprite_path(randpoke1, randpoke2) : get_fusion_sprite_path(randpoke2, randpoke1) if Input.press?(Input::RIGHT) - path = GetSpritePathForced(randpoke1, randpoke2, true) + path = get_fusion_sprite_path(randpoke2, randpoke1) elsif Input.press?(Input::LEFT) - path = GetSpritePathForced(randpoke2, randpoke1, true) + path = get_fusion_sprite_path(randpoke1, randpoke2) end return path end diff --git a/Data/Scripts/999_Main/999_Main.rb b/Data/Scripts/999_Main/999_Main.rb index 90b470233..62fb0edc3 100644 --- a/Data/Scripts/999_Main/999_Main.rb +++ b/Data/Scripts/999_Main/999_Main.rb @@ -44,7 +44,7 @@ def handleReplaceExistingSprites() end def pbCallTitle - return Scene_DebugIntro.new if $DEBUG + #return Scene_DebugIntro.new if $DEBUG return Scene_Intro.new end @@ -144,7 +144,11 @@ def mainFunctionDebug Graphics.update Graphics.freeze clearTempFolder() - sortCustomBattlers() + begin + sortCustomBattlers() + rescue + echo "failed to sort custom battlers" + end $scene = pbCallTitle $scene.main until $scene.nil? Graphics.transition(20) diff --git a/Data/System.rxdata b/Data/System.rxdata index 5af2c610019e1f9897b44c04e956195786019b79..6664efc1b5bb2ed31c24796558cea5b50a109f74 100644 GIT binary patch delta 18 acmca~lkw6`#tk_V%=$+cZqAoT4gmmEwFnjf delta 18 acmca~lkw6`#tk_V%o!VRZqAoT4gmmHK?rjI