mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Adds art gallery
This commit is contained in:
@@ -27,6 +27,7 @@ module Settings
|
||||
DOWNLOADED_SPRITES_FOLDER = "Graphics/temp/"
|
||||
DEFAULT_SPRITE_PATH = "Graphics/Battlers/Special/000.png"
|
||||
CREDITS_FILE_PATH = "Data/credits.csv"
|
||||
CREDITS_FILE_URL = "https://raw.githubusercontent.com/infinitefusion/sprites/main/Sprite Credits.csv"
|
||||
FRONTSPRITE_POSITION_OFFSET = 20
|
||||
FRONTSPRITE_SCALE = 0.6666666666
|
||||
BACKRPSPRITE_SCALE = 1
|
||||
|
||||
@@ -228,7 +228,7 @@ def pbBattleOnStepTaken(repel_active)
|
||||
if isFusedEncounter()
|
||||
encounter_fusedWith = getEncounter(encounter_type)
|
||||
if encounter[0] != encounter_fusedWith[0]
|
||||
encounter[0] = getFusionSpecies(encounter[0], encounter_fusedWith[0])
|
||||
encounter[0] = getFusionSpeciesSymbol(encounter[0], encounter_fusedWith[0])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -122,6 +122,10 @@ VAR_FUSE_COUNTER = 126
|
||||
VAR_BATTLE_TOWER_MIN_BST = 257
|
||||
VAR_BATTLE_TOWER_MAX_BST = 258
|
||||
|
||||
VAR_GALLERY_FEATURED_ARTIST = 259
|
||||
VAR_GALLERY_FEATURED_SPRITES = 260
|
||||
VAR_GALLERY_ALL_ARTIST_SPRITES = 261
|
||||
|
||||
|
||||
#Randomizer
|
||||
VAR_RANDOMIZER_WILD_POKE_BST=197
|
||||
|
||||
@@ -163,7 +163,7 @@ def generateSameEggGroupFusionsTeam(eggGroup_id)
|
||||
while !foundFusionPartner
|
||||
species2 = rand(Settings::NB_POKEMON) + 1
|
||||
if getPokemonEggGroups(species2).include?(eggGroup)
|
||||
generatedTeam << getFusionSpecies(species1, species2)
|
||||
generatedTeam << getFusionSpeciesSymbol(species1, species2)
|
||||
foundFusionPartner = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
def test_http_get
|
||||
url = "http://localhost:8080"
|
||||
response = HTTPLite.get(url)
|
||||
@@ -7,35 +6,55 @@ def test_http_get
|
||||
end
|
||||
end
|
||||
|
||||
def downloadCustomSprite(head_id,body_id)
|
||||
base_custom_path = "https://raw.githubusercontent.com/Aegide/custom-fusion-sprites/main/CustomBattlers/{1}.{2}.png"
|
||||
|
||||
def downloadCustomSprite(head_id, body_id)
|
||||
base_custom_path = "https://raw.githubusercontent.com/infinitefusion/sprites/main/Sprite%20Credits.csv"
|
||||
end
|
||||
|
||||
def download_sprite(base_path, head_id, body_id, saveLocation="Graphics/temp")
|
||||
def updateCreditsFile
|
||||
return if $PokemonSystem.download_sprites != 0
|
||||
download_file(Settings::CREDITS_FILE_URL,Settings::CREDITS_FILE_PATH,)
|
||||
end
|
||||
|
||||
def download_file(url, saveLocation)
|
||||
begin
|
||||
downloaded_file_name = _INTL("{1}/{2}.{3}.png",saveLocation,head_id,body_id)
|
||||
return downloaded_file_name if pbResolveBitmap(downloaded_file_name)
|
||||
url = _INTL(base_path,head_id,body_id)
|
||||
response = HTTPLite.get(url)
|
||||
if response[:status] == 200
|
||||
File.open(downloaded_file_name, "wb") do |file|
|
||||
file.write(response[:body])
|
||||
response = HTTPLite.get(url)
|
||||
if response[:status] == 200
|
||||
File.open(saveLocation, "wb") do |file|
|
||||
file.write(response[:body])
|
||||
end
|
||||
echo _INTL("\nDownloaded file {1} to {2}", url, saveLocation)
|
||||
return saveLocation
|
||||
end
|
||||
echo _INTL("\nDownloaded file {1} to {2}",downloaded_file_name,saveLocation)
|
||||
return downloaded_file_name
|
||||
end
|
||||
return nil
|
||||
return nil
|
||||
rescue MKXPError
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def download_sprite(base_path, head_id, body_id, saveLocation = "Graphics/temp")
|
||||
begin
|
||||
downloaded_file_name = _INTL("{1}/{2}.{3}.png", saveLocation, head_id, body_id)
|
||||
return downloaded_file_name if pbResolveBitmap(downloaded_file_name)
|
||||
url = _INTL(base_path, head_id, body_id)
|
||||
response = HTTPLite.get(url)
|
||||
if response[:status] == 200
|
||||
File.open(downloaded_file_name, "wb") do |file|
|
||||
file.write(response[:body])
|
||||
end
|
||||
echo _INTL("\nDownloaded file {1} to {2}", downloaded_file_name, saveLocation)
|
||||
return downloaded_file_name
|
||||
end
|
||||
return nil
|
||||
rescue MKXPError
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def download_autogen_sprite(head_id, body_id)
|
||||
return nil if $PokemonSystem.download_sprites != 0
|
||||
url = "https://raw.githubusercontent.com/Aegide/autogen-fusion-sprites/master/Battlers/{1}/{1}.{2}.png"
|
||||
destPath = _INTL("{1}{2}",Settings::BATTLERS_FOLDER,head_id)
|
||||
sprite = download_sprite(_INTL(url,head_id,body_id),head_id,body_id,destPath)
|
||||
destPath = _INTL("{1}{2}", Settings::BATTLERS_FOLDER, head_id)
|
||||
sprite = download_sprite(_INTL(url, head_id, body_id), head_id, body_id, destPath)
|
||||
return sprite if sprite
|
||||
return nil
|
||||
end
|
||||
@@ -44,8 +63,8 @@ def download_custom_sprite(head_id, body_id)
|
||||
return nil if $PokemonSystem.download_sprites != 0
|
||||
#base_path = "https://raw.githubusercontent.com/Aegide/custom-fusion-sprites/main/CustomBattlers/{1}.{2}.png"
|
||||
url = "https://raw.githubusercontent.com/infinitefusion/sprites/main/CustomBattlers/{1}.{2}.png"
|
||||
destPath= _INTL("{1}{2}",Settings::CUSTOM_BATTLERS_FOLDER_INDEXED,head_id)
|
||||
sprite = download_sprite(_INTL(url,head_id,body_id),head_id,body_id,destPath)
|
||||
destPath = _INTL("{1}{2}", Settings::CUSTOM_BATTLERS_FOLDER_INDEXED, head_id)
|
||||
sprite = download_sprite(_INTL(url, head_id, body_id), head_id, body_id, destPath)
|
||||
return sprite if sprite
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -320,6 +320,7 @@ class PokemonLoadScreen
|
||||
end
|
||||
|
||||
def pbStartLoadScreen
|
||||
updateCreditsFile
|
||||
if ($game_temp.unimportedSprites && $game_temp.unimportedSprites.size > 0)
|
||||
handleReplaceExistingSprites()
|
||||
end
|
||||
|
||||
92
Data/Scripts/050_AddOns/SpriteCreditsUtils.rb
Normal file
92
Data/Scripts/050_AddOns/SpriteCreditsUtils.rb
Normal file
@@ -0,0 +1,92 @@
|
||||
def map_sprites_by_artist
|
||||
creditsMap = Hash.new
|
||||
File.foreach(Settings::CREDITS_FILE_PATH) do |line|
|
||||
row = line.split(',')
|
||||
spritename = row[0]
|
||||
artist = row[1].chomp
|
||||
sprites = creditsMap.key?(artist) ? creditsMap[artist] : []
|
||||
sprites << spritename
|
||||
creditsMap[artist] = sprites
|
||||
end
|
||||
return creditsMap
|
||||
end
|
||||
|
||||
def analyzeSpritesList(spritesList)
|
||||
pokemon_map = Hash.new
|
||||
for spritename in spritesList
|
||||
splitName = spritename.split(".")
|
||||
headNum = splitName[0].to_i
|
||||
bodyNum = splitName[1].to_i
|
||||
|
||||
if pokemon_map.key?(headNum)
|
||||
pokemon_map[headNum] += 1
|
||||
else
|
||||
pokemon_map[headNum] = 1
|
||||
end
|
||||
|
||||
if pokemon_map.key?(bodyNum)
|
||||
pokemon_map[bodyNum] += 1
|
||||
else
|
||||
pokemon_map[bodyNum] = 1
|
||||
end
|
||||
end
|
||||
most_popular = pokemon_map.max_by { |key, value| value }[0]
|
||||
species = getSpecies(most_popular)
|
||||
|
||||
return species
|
||||
end
|
||||
|
||||
def getPokemonSpeciesFromSprite(spritename)
|
||||
splitName = spritename.split(".")
|
||||
headNum = splitName[0].to_i
|
||||
bodyNum = splitName[1].to_i
|
||||
|
||||
#call this to make sure that the sprite is downloaded
|
||||
get_fusion_sprite_path(headNum, bodyNum)
|
||||
|
||||
species = getFusionSpecies(bodyNum, headNum)
|
||||
return species
|
||||
end
|
||||
|
||||
def doesCurrentExhibitionFeaturePokemon(displayedSprites,pokemon)
|
||||
for sprite in displayedSprites
|
||||
parts = sprite.split(".")
|
||||
headNum = parts[0].to_i
|
||||
bodyNum = parts[1].to_i
|
||||
return true if headNum == pokemon.id_number || bodyNum == pokemon.id_number
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def generateArtGallery(nbSpritesDisplayed = 6, saveArtistNameInVariable = 1, saveSpritesInVariable = 2, saveAllArtistSpritesInVariable=3,artistName=nil)
|
||||
creditsMap = map_sprites_by_artist
|
||||
featuredArtist = artistName ? artistName : getRandomSpriteArtist(creditsMap, nbSpritesDisplayed)
|
||||
if featuredArtist
|
||||
featuredSprites = creditsMap[featuredArtist].shuffle.take(nbSpritesDisplayed)
|
||||
pbSet(saveArtistNameInVariable, File.basename(featuredArtist, '#*'))
|
||||
pbSet(saveSpritesInVariable, featuredSprites)
|
||||
pbSet(saveAllArtistSpritesInVariable, creditsMap[featuredArtist])
|
||||
return featuredSprites
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getRandomSpriteArtist(creditsMap = nil, minimumNumberOfSprites = 1, giveUpAfterX = 50)
|
||||
creditsMap = map_sprites_by_artist if !creditsMap
|
||||
i = 0
|
||||
while i < giveUpAfterX
|
||||
artist = creditsMap.keys.sample
|
||||
return artist if creditsMap[artist].length >= minimumNumberOfSprites
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpriteCredits(spriteName)
|
||||
File.foreach(Settings::CREDITS_FILE_PATH) do |line|
|
||||
row = line.split(',')
|
||||
if row[0].include?(spriteName)
|
||||
return row[1]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@@ -208,13 +208,20 @@ def getEvolution(speciesParam, halfToEvolve=nil)
|
||||
end
|
||||
end
|
||||
|
||||
def getFusionSpecies(body, head)
|
||||
def getFusionSpeciesSymbol(body, head)
|
||||
body_num = dexNum(body)
|
||||
head_num = dexNum(head)
|
||||
id = body_num * Settings::NB_POKEMON + head_num
|
||||
return GameData::Species.get(id).species
|
||||
end
|
||||
|
||||
def getFusionSpecies(body, head)
|
||||
body_num = dexNum(body)
|
||||
head_num = dexNum(head)
|
||||
id = body_num * Settings::NB_POKEMON + head_num
|
||||
return GameData::Species.get(id)
|
||||
end
|
||||
|
||||
#
|
||||
def evolveHead(species)
|
||||
species_id = getDexNumberForSpecies(species)
|
||||
@@ -225,7 +232,7 @@ def evolveHead(species)
|
||||
head = getBasePokemonID(species_id, false)
|
||||
body = getBasePokemonID(species_id)
|
||||
headEvo = getEvolution(head)
|
||||
return headEvo == -1 ? species_id : getFusionSpecies(body, headEvo)
|
||||
return headEvo == -1 ? species_id : getFusionSpeciesSymbol(body, headEvo)
|
||||
end
|
||||
|
||||
def evolveBody(species)
|
||||
@@ -237,7 +244,7 @@ def evolveBody(species)
|
||||
head = getBasePokemonID(species_id, false)
|
||||
body = getBasePokemonID(species_id)
|
||||
bodyEvo = getEvolution(body)
|
||||
return bodyEvo == -1 ? species_id : getFusionSpecies(bodyEvo, head)
|
||||
return bodyEvo == -1 ? species_id : getFusionSpeciesSymbol(bodyEvo, head)
|
||||
end
|
||||
|
||||
def getCorrectEvolvedSpecies(pokemon)
|
||||
|
||||
Reference in New Issue
Block a user