mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 13:44:59 +00:00
Adds cache for autogen sprites to reduce lag when loading sprites
This commit is contained in:
@@ -48,7 +48,7 @@ module GameData
|
|||||||
end
|
end
|
||||||
|
|
||||||
if !self::DATA.has_key?(other)
|
if !self::DATA.has_key?(other)
|
||||||
echo _INTL("Unknown ID {1}.", other)
|
echoln _INTL("Unknown ID {1}.", other)
|
||||||
return self::get(:PIKACHU)
|
return self::get(:PIKACHU)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class PokemonStorage
|
|||||||
def pbStoreCaught(pkmn)
|
def pbStoreCaught(pkmn)
|
||||||
if @currentBox>=0
|
if @currentBox>=0
|
||||||
pkmn.time_form_set = nil
|
pkmn.time_form_set = nil
|
||||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
#pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||||
#pkmn.heal
|
#pkmn.heal
|
||||||
end
|
end
|
||||||
for i in 0...maxPokemon(@currentBox)
|
for i in 0...maxPokemon(@currentBox)
|
||||||
|
|||||||
@@ -1932,7 +1932,7 @@ class PokemonStorageScreen
|
|||||||
if heldpoke || selected[0] == -1
|
if heldpoke || selected[0] == -1
|
||||||
p = (heldpoke) ? heldpoke : @storage[-1, index]
|
p = (heldpoke) ? heldpoke : @storage[-1, index]
|
||||||
p.time_form_set = nil
|
p.time_form_set = nil
|
||||||
p.form = 0 if p.isSpecies?(:SHAYMIN)
|
#p.form = 0 if p.isSpecies?(:SHAYMIN)
|
||||||
#p.heal
|
#p.heal
|
||||||
end
|
end
|
||||||
@scene.pbStore(selected, heldpoke, destbox, firstfree)
|
@scene.pbStore(selected, heldpoke, destbox, firstfree)
|
||||||
|
|||||||
@@ -257,7 +257,18 @@ def record_sprite_substitution(substitution_id, sprite_name)
|
|||||||
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = sprite_name
|
$PokemonGlobal.alt_sprite_substitutions[substitution_id] = sprite_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_to_autogen_cache(pokemon_id, sprite_name)
|
||||||
|
return if !$PokemonGlobal
|
||||||
|
return if !$PokemonGlobal.autogen_sprites_cache
|
||||||
|
$PokemonGlobal.autogen_sprites_cache[pokemon_id]=sprite_name
|
||||||
|
end
|
||||||
|
|
||||||
|
class PokemonGlobalMetadata
|
||||||
|
attr_accessor :autogen_sprites_cache
|
||||||
|
end
|
||||||
|
|
||||||
def get_fusion_sprite_path(head_id, body_id, spriteform_body = nil, spriteform_head = nil)
|
def get_fusion_sprite_path(head_id, body_id, spriteform_body = nil, spriteform_head = nil)
|
||||||
|
$PokemonGlobal.autogen_sprites_cache = {} if $PokemonGlobal && !$PokemonGlobal.autogen_sprites_cache
|
||||||
#Todo: ça va chier si on fusionne une forme d'un pokemon avec une autre forme, mais pas un problème pour tout de suite
|
#Todo: ça va chier si on fusionne une forme d'un pokemon avec une autre forme, mais pas un problème pour tout de suite
|
||||||
form_suffix = ""
|
form_suffix = ""
|
||||||
form_suffix += "_" + spriteform_body.to_s if spriteform_body
|
form_suffix += "_" + spriteform_body.to_s if spriteform_body
|
||||||
@@ -286,6 +297,11 @@ def get_fusion_sprite_path(head_id, body_id, spriteform_body = nil, spriteform_h
|
|||||||
record_sprite_substitution(substitution_id, local_custom_path)
|
record_sprite_substitution(substitution_id, local_custom_path)
|
||||||
return local_custom_path
|
return local_custom_path
|
||||||
end
|
end
|
||||||
|
echoln $PokemonGlobal.autogen_sprites_cache
|
||||||
|
|
||||||
|
#if the game has loaded an autogen earlier, no point in trying to redownload, so load that instead
|
||||||
|
return $PokemonGlobal.autogen_sprites_cache[substitution_id] if $PokemonGlobal.autogen_sprites_cache[substitution_id] && $PokemonGlobal
|
||||||
|
|
||||||
#Try to download custom sprite if none found locally
|
#Try to download custom sprite if none found locally
|
||||||
downloaded_custom = download_custom_sprite(head_id, body_id, spriteform_body_letter, spriteform_head_letter, random_alt)
|
downloaded_custom = download_custom_sprite(head_id, body_id, spriteform_body_letter, spriteform_head_letter, random_alt)
|
||||||
if downloaded_custom
|
if downloaded_custom
|
||||||
@@ -295,11 +311,17 @@ def get_fusion_sprite_path(head_id, body_id, spriteform_body = nil, spriteform_h
|
|||||||
|
|
||||||
#Try local generated sprite
|
#Try local generated sprite
|
||||||
local_generated_path = Settings::BATTLERS_FOLDER + head_id.to_s + spriteform_head_letter + "/" + filename
|
local_generated_path = Settings::BATTLERS_FOLDER + head_id.to_s + spriteform_head_letter + "/" + filename
|
||||||
return local_generated_path if pbResolveBitmap(local_generated_path)
|
if pbResolveBitmap(local_generated_path)
|
||||||
|
add_to_autogen_cache(substitution_id,local_generated_path)
|
||||||
|
return local_generated_path
|
||||||
|
end
|
||||||
|
|
||||||
#Download generated sprite if nothing else found
|
#Download generated sprite if nothing else found
|
||||||
autogen_path = download_autogen_sprite(head_id, body_id,spriteform_body,spriteform_head)
|
autogen_path = download_autogen_sprite(head_id, body_id,spriteform_body,spriteform_head)
|
||||||
return autogen_path if pbResolveBitmap(autogen_path)
|
if pbResolveBitmap(autogen_path)
|
||||||
|
add_to_autogen_cache(substitution_id,autogen_path)
|
||||||
|
return autogen_path
|
||||||
|
end
|
||||||
|
|
||||||
return Settings::DEFAULT_SPRITE_PATH
|
return Settings::DEFAULT_SPRITE_PATH
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ def download_sprite(base_path, head_id, body_id, saveLocation = "Graphics/temp",
|
|||||||
echoln _INTL("\nDownloaded file from {1} to {2}", base_path, saveLocation)
|
echoln _INTL("\nDownloaded file from {1} to {2}", base_path, saveLocation)
|
||||||
return downloaded_file_name
|
return downloaded_file_name
|
||||||
end
|
end
|
||||||
|
echoln "tried to download " + base_path
|
||||||
return nil
|
return nil
|
||||||
rescue MKXPError, Errno::ENOENT
|
rescue MKXPError, Errno::ENOENT
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -412,6 +412,7 @@ class PokemonLoadScreen
|
|||||||
Game.load(@save_data)
|
Game.load(@save_data)
|
||||||
$game_switches[SWITCH_V5_1] = true
|
$game_switches[SWITCH_V5_1] = true
|
||||||
$PokemonGlobal.alt_sprite_substitutions = {} if !$PokemonGlobal.alt_sprite_substitutions
|
$PokemonGlobal.alt_sprite_substitutions = {} if !$PokemonGlobal.alt_sprite_substitutions
|
||||||
|
$PokemonGlobal.autogen_sprites_cache = {}
|
||||||
return
|
return
|
||||||
when cmd_new_game
|
when cmd_new_game
|
||||||
@scene.pbEndScene
|
@scene.pbEndScene
|
||||||
|
|||||||
@@ -1482,7 +1482,7 @@ def pbUnfuse(pokemon, scene, supersplicers, pcPosition = nil)
|
|||||||
bodyPoke = getBasePokemonID(pokemon.species_data.id_number, true)
|
bodyPoke = getBasePokemonID(pokemon.species_data.id_number, true)
|
||||||
headPoke = getBasePokemonID(pokemon.species_data.id_number, false)
|
headPoke = getBasePokemonID(pokemon.species_data.id_number, false)
|
||||||
|
|
||||||
if (pokemon.obtain_method == 2 || pokemon.ot != $Trainer.name) # && !canunfuse
|
if (pokemon.obtain_method == 2 || pokemon.ot != $Trainer.name) && false # && !canunfuse
|
||||||
scene.pbDisplay(_INTL("You can't unfuse a Pokémon obtained in a trade!"))
|
scene.pbDisplay(_INTL("You can't unfuse a Pokémon obtained in a trade!"))
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user