Fixes crash when can't copy file when generating fusion icon

This commit is contained in:
infinitefusion
2023-07-11 19:53:55 -04:00
parent e663541a88
commit e7778b72b9
17 changed files with 72 additions and 79 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -116,8 +116,8 @@ class PokeRadar_UI
bitmapFileName = sprintf("Graphics/Pokemon/FusionIcons/icon%03d", dexNum)
headPokeFileName = GameData::Species.icon_filename(headPoke)
bitmapPath = sprintf("%s.png", bitmapFileName)
IO.copy_stream(headPokeFileName, bitmapPath)
result_bitmap = AnimatedBitmap.new(bitmapPath)
generated_new_icon = generateFusionIcon(headPokeFileName,bitmapPath)
result_bitmap = generated_new_icon ? AnimatedBitmap.new(bitmapPath) : bitmap1
for i in 0..bitmap1.width-1
for j in ((bitmap1.height / 2) + Settings::FUSION_ICON_SPRITE_OFFSET)..bitmap1.height-1

View File

@@ -191,8 +191,8 @@ class PokemonIconSprite < SpriteWrapper
bitmapFileName = sprintf("Graphics/Pokemon/FusionIcons/icon%03d", dexNum)
headPokeFileName = GameData::Species.icon_filename(headPoke)
bitmapPath = sprintf("%s.png", bitmapFileName)
IO.copy_stream(headPokeFileName, bitmapPath)
result_icon = AnimatedBitmap.new(bitmapPath)
generated_new_icon = generateFusionIcon(headPokeFileName,bitmapPath)
result_icon = generated_new_icon ? AnimatedBitmap.new(bitmapPath) : icon1
for i in 0..icon1.width-1
for j in ((icon1.height / 2) + Settings::FUSION_ICON_SPRITE_OFFSET)..icon1.height-1

View File

@@ -38,8 +38,8 @@ class PokemonBoxIcon < IconSprite
bitmapFileName = sprintf("Graphics/Pokemon/FusionIcons/icon%03d", dexNum)
headPokeFileName = GameData::Species.icon_filename(headPoke)
bitmapPath = sprintf("%s.png", bitmapFileName)
IO.copy_stream(headPokeFileName, bitmapPath)
result_icon = AnimatedBitmap.new(bitmapPath)
generated_new_icon = generateFusionIcon(headPokeFileName,bitmapPath)
result_icon = generated_new_icon ? AnimatedBitmap.new(bitmapPath) : icon1
for i in 0..icon1.width - 1
for j in ((icon1.height / 2) + Settings::FUSION_ICON_SPRITE_OFFSET)..icon1.height - 1

View File

@@ -47,6 +47,14 @@ def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = fals
return true
end
def generateFusionIcon(dexNum, path)
begin
IO.copy_stream(dexNum, path)
return true
rescue
return false
end
end
def ensureFusionIconExists
directory_name = "Graphics/Pokemon/FusionIcons"
@@ -85,7 +93,6 @@ def pbHasSpecies?(species)
return false
end
#ancienne methode qui est encore callée un peu partout dans les vieux scripts
def getID(pbspecies_unused, species)
if species.is_a?(String)
@@ -96,6 +103,7 @@ def getID(pbspecies_unused,species)
id = species.dexNum
end
end
#Check if the Pokemon can learn a TM
def CanLearnMove(pokemon, move)
species = getID(PBSpecies, pokemon)
@@ -138,8 +146,6 @@ def getDexNumberForSpecies(species)
return dexNum
end
def getPokemon(dexNum)
return GameData::Species.get(dexNum)
end
@@ -152,7 +158,6 @@ def getSpeciesIdForFusion(head_id, body_id)
return (body_id) * Settings::NB_POKEMON + head_id
end
#shortcut for using in game events because of script characters limit
def dexNum(species)
return getDexNumberForSpecies(species)
@@ -162,7 +167,6 @@ def isTripleFusion?(num)
return num >= Settings::ZAPMOLCUNO_NB
end
def getRandomCustomFusionForIntro(returnRandomPokemonIfNoneFound = true, customPokeList = [], maxPoke = -1, recursionLimit = 3)
if customPokeList.length == 0
customPokeList = getCustomSpeciesList(false)
@@ -191,7 +195,6 @@ def getRandomCustomFusionForIntro(returnRandomPokemonIfNoneFound = true, customP
return randPoke
end
def addShinyStarsToGraphicsArray(imageArray, xPos, yPos, shinyBody, shinyHead, debugShiny, srcx = nil, srcy = nil, width = nil, height = nil,
showSecondStarUnder = false, showSecondStarAbove = false)
color = debugShiny ? Color.new(0, 0, 0, 255) : nil
@@ -235,7 +238,6 @@ def getRandomCustomFusion(returnRandomPokemonIfNoneFound = true, customPokeList
return randPoke
end
def getBodyID(species)
dexNum = getDexNumberForSpecies(species)
if dexNum % NB_POKEMON == 0
@@ -409,10 +411,6 @@ def obtainPokemonSpritePath(id, includeCustoms = true)
return obtainPokemonSpritePath(body, head, includeCustoms)
end
def obtainPokemonSpritePath(bodyId, headId, include_customs = true)
download_pokemon_sprite_if_missing(bodyId, headId)
picturePath = _INTL("Graphics/Battlers/{1}/{1}.{2}.png", headId, bodyId)
@@ -443,7 +441,6 @@ def checkIfCustomSpriteExistsByPath(path)
return true if pbResolveBitmap(path) != nil
end
def customSpriteExistsBodyHead(body, head)
pathCustom = getCustomSpritePath(body, head)
@@ -562,8 +559,6 @@ def Kernel.getItemNamesAsString(list)
return strList
end
def Kernel.getPlateType(item)
return :FIGHTING if item == PBItems::FISTPLATE
return :FLYING if item == PBItems::SKYPLATE
@@ -584,6 +579,7 @@ def Kernel.getPlateType(item)
return :FAIRY if item == PBItems::PIXIEPLATE
return -1
end
def get_default_moves_at_level(species, level)
moveset = GameData::Species.get(species).moves
knowable_moves = []
@@ -604,7 +600,6 @@ def get_default_moves_at_level(species,level)
return moves
end
def find_newer_available_version
latest_Version = fetch_latest_game_version
return nil if !latest_Version
@@ -644,13 +639,11 @@ def change_game_difficulty(down_only=false)
message = "The game is currently on " + get_difficulty_text() + " difficulty."
pbMessage(message)
choice_easy = "Easy"
choice_normal = "Normal"
choice_hard = "Hard"
choice_cancel = "Cancel"
available_difficulties = []
currentDifficulty = get_current_game_difficulty
if down_only

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1815,7 +1815,7 @@ Pokemon = B109H33,26 #Nidofing,
[TEAMROCKET_M,Joffrey]
Pokemon = KOFFING,21 #Tentata,
Ball = ROCKETBALL
Pokemon = B20H73,23 #Tentaicate,
Pokemon = B42H20,23 #RATICATE/GOLBAT,
Ball = ROCKETBALL
########################
@@ -1843,7 +1843,7 @@ Pokemon = B100H132,26 #Ditorb,
Moves = TRANSFORM,CHARGEBEAM,LIGHTSCREEN,SONICBOOM
AbilityIndex = 0
Ball = ROCKETBALL
Pokemon = B147H88,25 #Gritini,
Pokemon = B89h42,25 #muk / golbat,
Ball = ROCKETBALL
#######################