mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Fixes sprite importing
This commit is contained in:
@@ -22,7 +22,7 @@ module Settings
|
|||||||
|
|
||||||
#Infinite fusion settings
|
#Infinite fusion settings
|
||||||
NB_POKEMON = 501
|
NB_POKEMON = 501
|
||||||
CUSTOM_BASE_SPRITES_FOLDER = "Graphics/CustomBattlers/local_spritesBaseSprites/"
|
CUSTOM_BASE_SPRITES_FOLDER = "Graphics/CustomBattlers/local_sprites/BaseSprites/"
|
||||||
CUSTOM_BATTLERS_FOLDER = "Graphics/CustomBattlers/"
|
CUSTOM_BATTLERS_FOLDER = "Graphics/CustomBattlers/"
|
||||||
CUSTOM_SPRITES_TO_IMPORT_FOLDER = "Graphics/CustomBattlers/Sprites to import/"
|
CUSTOM_SPRITES_TO_IMPORT_FOLDER = "Graphics/CustomBattlers/Sprites to import/"
|
||||||
CUSTOM_BATTLERS_FOLDER_INDEXED = "Graphics/CustomBattlers/local_sprites/indexed/"
|
CUSTOM_BATTLERS_FOLDER_INDEXED = "Graphics/CustomBattlers/local_sprites/indexed/"
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class DoublePreviewScreen
|
|||||||
spriteLoader = BattleSpriteLoader.new
|
spriteLoader = BattleSpriteLoader.new
|
||||||
bitmap = spriteLoader.load_fusion_sprite(head_pokemon,body_pokemon)
|
bitmap = spriteLoader.load_fusion_sprite(head_pokemon,body_pokemon)
|
||||||
bitmap.scale_bitmap(Settings::FRONTSPRITE_SCALE)
|
bitmap.scale_bitmap(Settings::FRONTSPRITE_SCALE)
|
||||||
|
pif_sprite = spriteLoader.obtain_fusion_pif_sprite(head_pokemon,body_pokemon)
|
||||||
#hasCustom = picturePath.include?("CustomBattlers")
|
#hasCustom = picturePath.include?("CustomBattlers")
|
||||||
#hasCustom = customSpriteExistsBase(body_pokemon,head_pokemon)
|
#hasCustom = customSpriteExistsBase(body_pokemon,head_pokemon)
|
||||||
hasCustom = customSpriteExists(body_pokemon,head_pokemon)
|
hasCustom = customSpriteExists(body_pokemon,head_pokemon)
|
||||||
@@ -123,10 +123,12 @@ class DoublePreviewScreen
|
|||||||
drawFusionInformation(dexNumber, level, x)
|
drawFusionInformation(dexNumber, level, x)
|
||||||
|
|
||||||
if !$Trainer.seen?(dexNumber)
|
if !$Trainer.seen?(dexNumber)
|
||||||
if hasCustom
|
if pif_sprite.local_path()
|
||||||
previewwindow.picture.pbSetColor(150, 255, 150, 200)
|
previewwindow.picture.pbSetColor(170, 200, 250, 200) #blue
|
||||||
|
elsif hasCustom
|
||||||
|
previewwindow.picture.pbSetColor(150, 255, 150, 200) #green
|
||||||
else
|
else
|
||||||
previewwindow.picture.pbSetColor(255, 255, 255, 200)
|
previewwindow.picture.pbSetColor(255, 255, 255, 200) #white
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return previewwindow
|
return previewwindow
|
||||||
|
|||||||
@@ -954,6 +954,7 @@ end
|
|||||||
def drawSpriteCredits(pif_sprite, viewport)
|
def drawSpriteCredits(pif_sprite, viewport)
|
||||||
overlay = BitmapSprite.new(Graphics.width, Graphics.height, @viewport).bitmap
|
overlay = BitmapSprite.new(Graphics.width, Graphics.height, @viewport).bitmap
|
||||||
return if pif_sprite.type == :AUTOGEN
|
return if pif_sprite.type == :AUTOGEN
|
||||||
|
return if pif_sprite.local_path
|
||||||
x = Graphics.width / 2
|
x = Graphics.width / 2
|
||||||
y = 240
|
y = 240
|
||||||
spritename = pif_sprite.to_filename()
|
spritename = pif_sprite.to_filename()
|
||||||
|
|||||||
@@ -96,36 +96,3 @@ class PIFSpriteExtracter
|
|||||||
class PokemonGlobalMetadata
|
class PokemonGlobalMetadata
|
||||||
attr_accessor :current_spritepack_date
|
attr_accessor :current_spritepack_date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# class SpritesBitmapCache
|
|
||||||
# @@cache = {} # Cache storage for spritesheets
|
|
||||||
# @@usage_order = [] # Tracks usage order for LRU eviction
|
|
||||||
#
|
|
||||||
# def self.fetch(key)
|
|
||||||
# if @@cache.key?(key)
|
|
||||||
# # Move key to the end to mark it as recently used
|
|
||||||
# @@usage_order.delete(key)
|
|
||||||
# @@usage_order << key
|
|
||||||
# return @@cache[key]
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Load spritesheet via block if not found in cache
|
|
||||||
# spritesheet = yield
|
|
||||||
#
|
|
||||||
# if @@cache.size >= Settings::SPRITE_CACHE_MAX_NB
|
|
||||||
# # Evict least recently used (first in order)
|
|
||||||
# oldest_key = @@usage_order.shift
|
|
||||||
# @@cache.delete(oldest_key)
|
|
||||||
# echoln "Evicted: #{oldest_key} from spritesheet cache"
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Add new spritesheet to cache and track its usage
|
|
||||||
# @@cache[key] = spritesheet
|
|
||||||
# @@usage_order << key
|
|
||||||
# spritesheet
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
@@ -4,6 +4,9 @@ class BattleSpriteLoader
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_pif_sprite_directly(pif_sprite)
|
def load_pif_sprite_directly(pif_sprite)
|
||||||
|
if pif_sprite.local_path && pbResolveBitmap(pif_sprite.local_path)
|
||||||
|
return AnimatedBitmap.new(pif_sprite.local_path)
|
||||||
|
end
|
||||||
extractor = get_sprite_extractor_instance(pif_sprite.type)
|
extractor = get_sprite_extractor_instance(pif_sprite.type)
|
||||||
return extractor.load_sprite(pif_sprite)
|
return extractor.load_sprite(pif_sprite)
|
||||||
end
|
end
|
||||||
@@ -22,8 +25,8 @@ class BattleSpriteLoader
|
|||||||
def preload_sprite_from_pokemon(pokemon)
|
def preload_sprite_from_pokemon(pokemon)
|
||||||
return if !pokemon
|
return if !pokemon
|
||||||
substitution_id = get_sprite_substitution_id_from_dex_number(pokemon.species)
|
substitution_id = get_sprite_substitution_id_from_dex_number(pokemon.species)
|
||||||
echoln substitution_id
|
# echoln substitution_id
|
||||||
echoln $PokemonGlobal.alt_sprite_substitutions
|
# echoln $PokemonGlobal.alt_sprite_substitutions
|
||||||
pif_sprite = $PokemonGlobal.alt_sprite_substitutions[substitution_id] if $PokemonGlobal
|
pif_sprite = $PokemonGlobal.alt_sprite_substitutions[substitution_id] if $PokemonGlobal
|
||||||
if !pif_sprite
|
if !pif_sprite
|
||||||
pif_sprite = get_pif_sprite_from_species(pokemon.species)
|
pif_sprite = get_pif_sprite_from_species(pokemon.species)
|
||||||
@@ -65,19 +68,25 @@ class BattleSpriteLoader
|
|||||||
def obtain_fusion_pif_sprite(head_id,body_id)
|
def obtain_fusion_pif_sprite(head_id,body_id)
|
||||||
substitution_id = get_sprite_substitution_id_for_fusion(head_id, body_id)
|
substitution_id = get_sprite_substitution_id_for_fusion(head_id, body_id)
|
||||||
pif_sprite = $PokemonGlobal.alt_sprite_substitutions[substitution_id] if $PokemonGlobal
|
pif_sprite = $PokemonGlobal.alt_sprite_substitutions[substitution_id] if $PokemonGlobal
|
||||||
|
pif_sprite.dump_info if pif_sprite
|
||||||
if !pif_sprite
|
if !pif_sprite
|
||||||
pif_sprite = select_new_pif_fusion_sprite(head_id, body_id)
|
pif_sprite = select_new_pif_fusion_sprite(head_id, body_id)
|
||||||
|
local_path = check_for_local_sprite(pif_sprite)
|
||||||
|
if local_path
|
||||||
|
pif_sprite.local_path = local_path
|
||||||
|
pif_sprite.type = :CUSTOM
|
||||||
|
end
|
||||||
substitution_id = get_sprite_substitution_id_for_fusion(head_id, body_id)
|
substitution_id = get_sprite_substitution_id_for_fusion(head_id, body_id)
|
||||||
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = pif_sprite if $PokemonGlobal
|
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = pif_sprite if $PokemonGlobal
|
||||||
end
|
end
|
||||||
return pif_sprite
|
return pif_sprite
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def load_fusion_sprite(head_id, body_id)
|
def load_fusion_sprite(head_id, body_id)
|
||||||
pif_sprite = obtain_fusion_pif_sprite(head_id,body_id)
|
pif_sprite = obtain_fusion_pif_sprite(head_id,body_id)
|
||||||
local_path = check_for_local_sprite(pif_sprite)
|
if pif_sprite.local_path
|
||||||
if local_path
|
return AnimatedBitmap.new(pif_sprite.local_path)
|
||||||
return AnimatedBitmap.new(local_path)
|
|
||||||
end
|
end
|
||||||
extractor = get_sprite_extractor_instance(pif_sprite.type)
|
extractor = get_sprite_extractor_instance(pif_sprite.type)
|
||||||
loaded_sprite = extractor.load_sprite(pif_sprite, @download_allowed)
|
loaded_sprite = extractor.load_sprite(pif_sprite, @download_allowed)
|
||||||
@@ -94,9 +103,8 @@ class BattleSpriteLoader
|
|||||||
pif_sprite = select_new_pif_base_sprite(dex_number)
|
pif_sprite = select_new_pif_base_sprite(dex_number)
|
||||||
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = pif_sprite if $PokemonGlobal
|
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = pif_sprite if $PokemonGlobal
|
||||||
end
|
end
|
||||||
local_path = check_for_local_sprite(pif_sprite)
|
if pif_sprite.local_path
|
||||||
if local_path
|
return AnimatedBitmap.new(pif_sprite.local_path)
|
||||||
return AnimatedBitmap.new(local_path)
|
|
||||||
end
|
end
|
||||||
extractor = get_sprite_extractor_instance(pif_sprite.type)
|
extractor = get_sprite_extractor_instance(pif_sprite.type)
|
||||||
loaded_sprite = extractor.load_sprite(pif_sprite)
|
loaded_sprite = extractor.load_sprite(pif_sprite)
|
||||||
@@ -137,6 +145,7 @@ class BattleSpriteLoader
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_for_local_sprite(pif_sprite)
|
def check_for_local_sprite(pif_sprite)
|
||||||
|
return pif_sprite.local_path if pif_sprite.local_path
|
||||||
if pif_sprite.type == :BASE
|
if pif_sprite.type == :BASE
|
||||||
sprite_path = "#{Settings::CUSTOM_BASE_SPRITES_FOLDER}#{pif_sprite.head_id}#{pif_sprite.alt_letter}.png"
|
sprite_path = "#{Settings::CUSTOM_BASE_SPRITES_FOLDER}#{pif_sprite.head_id}#{pif_sprite.alt_letter}.png"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class PIFSprite
|
|||||||
attr_accessor :head_id
|
attr_accessor :head_id
|
||||||
attr_accessor :body_id
|
attr_accessor :body_id
|
||||||
attr_accessor :alt_letter
|
attr_accessor :alt_letter
|
||||||
|
attr_accessor :local_path
|
||||||
|
|
||||||
#types:
|
#types:
|
||||||
# :AUTOGEN, :CUSTOM, :BASE
|
# :AUTOGEN, :CUSTOM, :BASE
|
||||||
@@ -12,8 +13,24 @@ class PIFSprite
|
|||||||
@head_id = head_id
|
@head_id = head_id
|
||||||
@body_id = body_id
|
@body_id = body_id
|
||||||
@alt_letter = alt_letter
|
@alt_letter = alt_letter
|
||||||
|
@local_path = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dump_info()
|
||||||
|
echoln "Type: #{@type}"
|
||||||
|
echoln "Head: #{@head_id}"
|
||||||
|
echoln "Body: #{@body_id}"
|
||||||
|
echoln "Alt letter: #{@alt_letter}"
|
||||||
|
echoln "Local path: #{@local_path}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def equals(other_pif_sprite)
|
||||||
|
return @type == other_pif_sprite.type &&
|
||||||
|
@head_id == other_pif_sprite.head_id &&
|
||||||
|
@body_id == other_pif_sprite.body_id &&
|
||||||
|
@alt_letter == other_pif_sprite.alt_letter &&
|
||||||
|
@local_path == other_pif_sprite.local_path
|
||||||
|
end
|
||||||
|
|
||||||
#little hack for old methods that expect a filename for a sprite
|
#little hack for old methods that expect a filename for a sprite
|
||||||
def to_filename()
|
def to_filename()
|
||||||
@@ -46,7 +63,6 @@ class PIFSprite
|
|||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_pif_sprite_from_dex_num(type, dexNum, alt_letter)
|
def new_pif_sprite_from_dex_num(type, dexNum, alt_letter)
|
||||||
@@ -55,8 +71,6 @@ def new_pif_sprite_from_dex_num(type, dexNum,alt_letter)
|
|||||||
return PIFSprite.new(type, head_id, body_id, alt_letter)
|
return PIFSprite.new(type, head_id, body_id, alt_letter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pif_sprite_from_spritename(spritename, autogen = false)
|
def pif_sprite_from_spritename(spritename, autogen = false)
|
||||||
spritename = spritename.split(".png")[0] #remove the extension
|
spritename = spritename.split(".png")[0] #remove the extension
|
||||||
if spritename =~ /^(\d+)\.(\d+)([a-zA-Z]*)$/ # Two numbers with optional letters
|
if spritename =~ /^(\d+)\.(\d+)([a-zA-Z]*)$/ # Two numbers with optional letters
|
||||||
|
|||||||
@@ -378,9 +378,7 @@ class PokemonLoadScreen
|
|||||||
|
|
||||||
def check_for_spritepack_update()
|
def check_for_spritepack_update()
|
||||||
$updated_spritesheets = [] if !$updated_spritesheets
|
$updated_spritesheets = [] if !$updated_spritesheets
|
||||||
echoln "wawawa"
|
|
||||||
if new_spritepack_was_released()
|
if new_spritepack_was_released()
|
||||||
echoln "waaaah!"
|
|
||||||
reset_updated_spritesheets_cache()
|
reset_updated_spritesheets_cache()
|
||||||
$updated_spritesheets = []
|
$updated_spritesheets = []
|
||||||
end
|
end
|
||||||
@@ -443,8 +441,6 @@ class PokemonLoadScreen
|
|||||||
handleReplaceExistingSprites()
|
handleReplaceExistingSprites()
|
||||||
end
|
end
|
||||||
if ($game_temp.nb_imported_sprites && $game_temp.nb_imported_sprites > 0)
|
if ($game_temp.nb_imported_sprites && $game_temp.nb_imported_sprites > 0)
|
||||||
echoln $game_temp.nb_imported_sprites
|
|
||||||
echoln $game_temp.nb_imported_sprites.to_s
|
|
||||||
pbMessage(_INTL("{1} new custom sprites were imported into the game", $game_temp.nb_imported_sprites.to_s))
|
pbMessage(_INTL("{1} new custom sprites were imported into the game", $game_temp.nb_imported_sprites.to_s))
|
||||||
end
|
end
|
||||||
checkEnableSpritesDownload
|
checkEnableSpritesDownload
|
||||||
|
|||||||
@@ -12,16 +12,43 @@ class PokedexUtils
|
|||||||
return $game_temp.base_sprites_list[dex_number]
|
return $game_temp.base_sprites_list[dex_number]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def getLocalBaseSpriteAlts(dex_number)
|
||||||
|
local_sprite_alts = []
|
||||||
|
baseFilename = "#{dex_number}"
|
||||||
|
possible_alt_letters = getAltLettersList()
|
||||||
|
possible_alt_letters << ""
|
||||||
|
possible_alt_letters.each { |alt_letter|
|
||||||
|
spritename = "#{baseFilename}#{alt_letter}"
|
||||||
|
local_path = "#{Settings::CUSTOM_BASE_SPRITES_FOLDER}/#{spritename}.png"
|
||||||
|
if pbResolveBitmap(local_path)
|
||||||
|
local_sprite_alts << getLocalSpriteID(local_path)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
return local_sprite_alts
|
||||||
|
end
|
||||||
|
|
||||||
|
def getLocalFusionSpriteAlts(head_id,body_id)
|
||||||
|
local_sprite_alts = []
|
||||||
|
baseFilename = "#{head_id}.#{body_id}"
|
||||||
|
possible_alt_letters = getAltLettersList()
|
||||||
|
possible_alt_letters << ""
|
||||||
|
possible_alt_letters.each { |alt_letter|
|
||||||
|
spritename = "#{baseFilename}#{alt_letter}"
|
||||||
|
local_path = "#{Settings::CUSTOM_BATTLERS_FOLDER_INDEXED}/#{head_id.to_s}/#{spritename}.png"
|
||||||
|
if pbResolveBitmap(local_path)
|
||||||
|
local_sprite_alts << getLocalSpriteID(local_path)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
return local_sprite_alts
|
||||||
|
end
|
||||||
|
|
||||||
|
def getLocalSpriteID(sprite_path)
|
||||||
|
return "local_#{sprite_path}"
|
||||||
|
end
|
||||||
|
|
||||||
def getFusionSpriteAlts(head_id, body_id)
|
def getFusionSpriteAlts(head_id, body_id)
|
||||||
sprite_id = get_fusion_symbol(head_id,body_id)
|
sprite_id = get_fusion_symbol(head_id,body_id)
|
||||||
return $game_temp.custom_sprites_list[sprite_id]
|
return $game_temp.custom_sprites_list[sprite_id]
|
||||||
# available_alts = []
|
|
||||||
# species_id = get_fusion_id(head_id,body_id).to_s
|
|
||||||
# for pokemon_id in $game_temp.custom_sprites_list
|
|
||||||
# available_alts << pokemon_id if pokemon_id.to_s.start_with?(species_id)
|
|
||||||
# end
|
|
||||||
# echoln available_alts
|
|
||||||
# return available_alts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbGetAvailableAlts(species, includeAutogens=false)
|
def pbGetAvailableAlts(species, includeAutogens=false)
|
||||||
@@ -30,49 +57,19 @@ class PokedexUtils
|
|||||||
body_id = getBodyID(dex_number)
|
body_id = getBodyID(dex_number)
|
||||||
head_id = getHeadID(dex_number,body_id)
|
head_id = getHeadID(dex_number,body_id)
|
||||||
available_alts = getFusionSpriteAlts(head_id,body_id)
|
available_alts = getFusionSpriteAlts(head_id,body_id)
|
||||||
|
available_alts = [] if !available_alts
|
||||||
|
local_alts = getLocalFusionSpriteAlts(head_id,body_id)
|
||||||
else
|
else
|
||||||
available_alts= getBaseSpritesAlts(dex_number)
|
available_alts= getBaseSpritesAlts(dex_number)
|
||||||
end
|
|
||||||
available_alts = [] if !available_alts
|
available_alts = [] if !available_alts
|
||||||
|
local_alts = getLocalBaseSpriteAlts(dex_number)
|
||||||
|
end
|
||||||
|
available_alts += local_alts if local_alts
|
||||||
available_alts << "autogen" if includeAutogens
|
available_alts << "autogen" if includeAutogens
|
||||||
return available_alts
|
return available_alts
|
||||||
|
|
||||||
|
|
||||||
# ret = []
|
|
||||||
# return ret if !species
|
|
||||||
# dexNum = getDexNumberForSpecies(species)
|
|
||||||
# isFusion = dexNum > NB_POKEMON
|
|
||||||
# if !isFusion
|
|
||||||
# altLetters = getAltLettersList()
|
|
||||||
# altLetters << ""
|
|
||||||
# altLetters.each { |alt_letter|
|
|
||||||
# altFilePath = Settings::CUSTOM_BASE_SPRITES_FOLDER + dexNum.to_s + alt_letter + ".png"
|
|
||||||
# if pbResolveBitmap(altFilePath)
|
|
||||||
# ret << altFilePath
|
|
||||||
# end
|
|
||||||
# }
|
|
||||||
# return ret
|
|
||||||
# end
|
|
||||||
# body_id = getBodyID(species)
|
|
||||||
# head_id = getHeadID(species, body_id)
|
|
||||||
#
|
|
||||||
# baseFilename = head_id.to_s + "." + body_id.to_s
|
|
||||||
# baseFilePath = Settings::CUSTOM_BATTLERS_FOLDER_INDEXED + head_id.to_s + "/" + baseFilename + ".png"
|
|
||||||
# if pbResolveBitmap(baseFilePath)
|
|
||||||
# ret << baseFilePath
|
|
||||||
# end
|
|
||||||
# getAltLettersList().each { |alt_letter|
|
|
||||||
# if alt_letter != "" #empty is included in alt letters because unfused sprites can be alts and not have a letter
|
|
||||||
# altFilePath = Settings::CUSTOM_BATTLERS_FOLDER_INDEXED + head_id.to_s + "/" + baseFilename + alt_letter + ".png"
|
|
||||||
# if pbResolveBitmap(altFilePath)
|
|
||||||
# ret << altFilePath
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# }
|
|
||||||
# ret << Settings::BATTLERS_FOLDER + head_id.to_s + "/" + baseFilename + ".png"
|
|
||||||
# return ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#todo: return array for split evolution lines that have multiple final evos
|
#todo: return array for split evolution lines that have multiple final evos
|
||||||
def getFinalEvolution(species)
|
def getFinalEvolution(species)
|
||||||
#ex: [[B3H4,Level 32],[B2H5, Level 35]]
|
#ex: [[B3H4,Level 32],[B2H5, Level 35]]
|
||||||
|
|||||||
@@ -110,13 +110,6 @@ class PokemonPokedexInfo_Scene
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# def get_currently_selected_sprite()
|
|
||||||
# species_dex = getDexNumberForSpecies(@species).to_s
|
|
||||||
# initialize_alt_sprite_substitutions()
|
|
||||||
# substitution_id = getSpritesSubstutionFromSpecies(species_dex)
|
|
||||||
# return $PokemonGlobal.alt_sprite_substitutions[substitution_id]
|
|
||||||
# end
|
|
||||||
|
|
||||||
def get_substitution_id(dex_number)
|
def get_substitution_id(dex_number)
|
||||||
if isFusion(dex_number)
|
if isFusion(dex_number)
|
||||||
body_id = getBodyID(dex_number)
|
body_id = getBodyID(dex_number)
|
||||||
@@ -164,6 +157,9 @@ class PokemonPokedexInfo_Scene
|
|||||||
previous_index = @selected_index == 0 ? @available.size - 1 : @selected_index - 1
|
previous_index = @selected_index == 0 ? @available.size - 1 : @selected_index - 1
|
||||||
next_index = @selected_index == @available.size - 1 ? 0 : @selected_index + 1
|
next_index = @selected_index == @available.size - 1 ? 0 : @selected_index + 1
|
||||||
|
|
||||||
|
echoln "selected sprite:"
|
||||||
|
get_pif_sprite(@available[@selected_index]).dump_info()
|
||||||
|
|
||||||
@sprites["bgSelected_previous"].visible = true if is_main_sprite(previous_index) && @available.size > 2
|
@sprites["bgSelected_previous"].visible = true if is_main_sprite(previous_index) && @available.size > 2
|
||||||
@sprites["bgSelected_center"].visible = true if is_main_sprite(@selected_index)
|
@sprites["bgSelected_center"].visible = true if is_main_sprite(@selected_index)
|
||||||
@sprites["bgSelected_next"].visible = true if is_main_sprite(next_index) && @available.size > 1
|
@sprites["bgSelected_next"].visible = true if is_main_sprite(next_index) && @available.size > 1
|
||||||
@@ -174,17 +170,29 @@ class PokemonPokedexInfo_Scene
|
|||||||
if isFusion(dex_number)
|
if isFusion(dex_number)
|
||||||
body_id = getBodyID(dex_number)
|
body_id = getBodyID(dex_number)
|
||||||
head_id = getHeadID(dex_number, body_id)
|
head_id = getHeadID(dex_number, body_id)
|
||||||
|
#Autogen sprite
|
||||||
if alt_letter == "autogen"
|
if alt_letter == "autogen"
|
||||||
pif_sprite = PIFSprite.new(:AUTOGEN, head_id, body_id)
|
pif_sprite = PIFSprite.new(:AUTOGEN, head_id, body_id)
|
||||||
|
#Imported custom sprite
|
||||||
else
|
else
|
||||||
|
#Spritesheet custom sprite
|
||||||
pif_sprite = PIFSprite.new(:CUSTOM, head_id, body_id, alt_letter)
|
pif_sprite = PIFSprite.new(:CUSTOM, head_id, body_id, alt_letter)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
pif_sprite = PIFSprite.new(:BASE, dex_number, nil, alt_letter)
|
pif_sprite = PIFSprite.new(:BASE, dex_number, nil, alt_letter)
|
||||||
end
|
end
|
||||||
|
#use local sprites instead if they exist
|
||||||
|
if alt_letter && isLocalSprite(alt_letter)
|
||||||
|
sprite_path = alt_letter.split("_", 2)[1]
|
||||||
|
pif_sprite.local_path = sprite_path
|
||||||
|
end
|
||||||
return pif_sprite
|
return pif_sprite
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def isLocalSprite(alt_letter)
|
||||||
|
return alt_letter.start_with?("local_")
|
||||||
|
end
|
||||||
|
|
||||||
def isBaseSpritePath(path)
|
def isBaseSpritePath(path)
|
||||||
filename = File.basename(path).downcase
|
filename = File.basename(path).downcase
|
||||||
return filename.match?(/\A\d+\.png\Z/)
|
return filename.match?(/\A\d+\.png\Z/)
|
||||||
@@ -199,10 +207,9 @@ class PokemonPokedexInfo_Scene
|
|||||||
if previousIndex < 0
|
if previousIndex < 0
|
||||||
previousIndex = @available.size - 1
|
previousIndex = @available.size - 1
|
||||||
end
|
end
|
||||||
# @sprites["previousSprite"].visible = @available.size > 2
|
|
||||||
# @sprites["nextSprite"].visible = @available.size > 1
|
|
||||||
|
|
||||||
@selected_pif_sprite = get_pif_sprite(@available[@selected_index])
|
@selected_pif_sprite = get_pif_sprite(@available[@selected_index])
|
||||||
|
|
||||||
|
|
||||||
@previous_pif_sprite = get_pif_sprite(@available[previousIndex])
|
@previous_pif_sprite = get_pif_sprite(@available[previousIndex])
|
||||||
@next_pif_sprite = get_pif_sprite(@available[nextIndex])
|
@next_pif_sprite = get_pif_sprite(@available[nextIndex])
|
||||||
|
|
||||||
@@ -234,7 +241,7 @@ class PokemonPokedexInfo_Scene
|
|||||||
#todo give credits to Japeal - need to differenciate unfused sprites
|
#todo give credits to Japeal - need to differenciate unfused sprites
|
||||||
discord_name = "" #"Japeal\n(Generated)"
|
discord_name = "" #"Japeal\n(Generated)"
|
||||||
end
|
end
|
||||||
|
discord_name = "Imported sprite" if @selected_pif_sprite.local_path
|
||||||
author_name = File.basename(discord_name, '#*')
|
author_name = File.basename(discord_name, '#*')
|
||||||
|
|
||||||
label_base_color = Color.new(248, 248, 248)
|
label_base_color = Color.new(248, 248, 248)
|
||||||
@@ -311,30 +318,20 @@ class PokemonPokedexInfo_Scene
|
|||||||
@sprites["downarrow"].visible = false
|
@sprites["downarrow"].visible = false
|
||||||
end
|
end
|
||||||
|
|
||||||
# def is_main_sprite(index = nil)
|
|
||||||
# return false if !@available
|
|
||||||
# if index == nil
|
|
||||||
# index = @selected_index
|
|
||||||
# end
|
|
||||||
# return true if @available.size <= 1
|
|
||||||
# if @speciesData.always_use_generated
|
|
||||||
# selected_sprite = @available[index]
|
|
||||||
# return selected_sprite.start_with?(Settings::BATTLERS_FOLDER)
|
|
||||||
# end
|
|
||||||
# return index == 0
|
|
||||||
# end
|
|
||||||
|
|
||||||
def is_main_sprite(index = nil)
|
def is_main_sprite(index = nil)
|
||||||
dex_number = getDexNumberForSpecies(@species)
|
dex_number = getDexNumberForSpecies(@species)
|
||||||
if !index
|
if !index
|
||||||
index = @selected_index
|
index = @selected_index
|
||||||
end
|
end
|
||||||
selected_sprite = @available[index]
|
|
||||||
species_id = get_substitution_id(dex_number)
|
species_id = get_substitution_id(dex_number)
|
||||||
|
|
||||||
if $PokemonGlobal.alt_sprite_substitutions[species_id]
|
current_pif_sprite = $PokemonGlobal.alt_sprite_substitutions[species_id]
|
||||||
return $PokemonGlobal.alt_sprite_substitutions[species_id].alt_letter == selected_sprite
|
selected_pif_sprite = get_pif_sprite(@available[index])
|
||||||
|
|
||||||
|
if current_pif_sprite
|
||||||
|
return current_pif_sprite.equals(selected_pif_sprite)
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def sprite_is_alt(sprite_path)
|
def sprite_is_alt(sprite_path)
|
||||||
@@ -344,7 +341,7 @@ class PokemonPokedexInfo_Scene
|
|||||||
|
|
||||||
def select_sprite(brief = false)
|
def select_sprite(brief = false)
|
||||||
if @available.length > 1
|
if @available.length > 1
|
||||||
if is_main_sprite
|
if is_main_sprite()
|
||||||
if brief
|
if brief
|
||||||
pbMessage("This sprite will remain the displayed sprite")
|
pbMessage("This sprite will remain the displayed sprite")
|
||||||
return true
|
return true
|
||||||
@@ -365,59 +362,12 @@ class PokemonPokedexInfo_Scene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def swap_main_sprite
|
def swap_main_sprite
|
||||||
old_main_sprite = @available[0]
|
|
||||||
new_alt_letter = @available[@selected_index]
|
|
||||||
species_number = dexNum(@species)
|
species_number = dexNum(@species)
|
||||||
substitution_id = get_substitution_id(species_number)
|
substitution_id = get_substitution_id(species_number)
|
||||||
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = @selected_pif_sprite
|
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = @selected_pif_sprite
|
||||||
end
|
end
|
||||||
|
|
||||||
# def swap_main_sprite
|
|
||||||
# begin
|
|
||||||
# old_main_sprite = @available[0]
|
|
||||||
# new_main_sprite = @available[@selected_index]
|
|
||||||
#
|
|
||||||
# if main_sprite_is_non_custom()
|
|
||||||
# @speciesData.set_always_use_generated_sprite(false)
|
|
||||||
# return
|
|
||||||
# # new_name_without_ext = File.basename(old_main_sprite, ".png")
|
|
||||||
# # new_name_without_letter=new_name_without_ext.chop
|
|
||||||
# # File.rename(new_main_sprite, Settings::CUSTOM_BATTLERS_FOLDER+new_name_without_letter + ".png")
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# if new_main_sprite.start_with?(Settings::BATTLERS_FOLDER)
|
|
||||||
# @speciesData.set_always_use_generated_sprite(true)
|
|
||||||
# return
|
|
||||||
# # new_name_without_ext = File.basename(old_main_sprite, ".png")
|
|
||||||
# # File.rename(old_main_sprite, Settings::CUSTOM_BATTLERS_FOLDER+new_name_without_ext+"x" + ".png")x
|
|
||||||
# # return
|
|
||||||
# end
|
|
||||||
# File.rename(new_main_sprite, new_main_sprite + "temp")
|
|
||||||
# File.rename(old_main_sprite, new_main_sprite)
|
|
||||||
# File.rename(new_main_sprite + "temp", old_main_sprite)
|
|
||||||
# rescue
|
|
||||||
# pbMessage("There was an error while swapping the sprites. Please save and restart the game as soon as possible.")
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def main_sprite_is_non_custom()
|
|
||||||
# speciesData = getSpecies(@species)
|
|
||||||
# return speciesData.always_use_generated || @available.size <= 1
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class PokemonGlobalMetadata
|
class PokemonGlobalMetadata
|
||||||
attr_accessor :alt_sprite_substitutions
|
attr_accessor :alt_sprite_substitutions
|
||||||
end
|
end
|
||||||
|
|
||||||
# def set_alt_sprite_substitution(original_sprite_name, selected_alt, formIndex = 0)
|
|
||||||
# if !$PokemonGlobal.alt_sprite_substitutions
|
|
||||||
# initialize_alt_sprite_substitutions()
|
|
||||||
# end
|
|
||||||
# if formIndex
|
|
||||||
# form_suffix = formIndex != 0 ? "_" + formIndex.to_s : ""
|
|
||||||
# else
|
|
||||||
# form_suffix = ""
|
|
||||||
# end
|
|
||||||
# $PokemonGlobal.alt_sprite_substitutions[original_sprite_name.to_s + form_suffix] = selected_alt
|
|
||||||
# end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user