mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Created and implemented GameData::Species
This commit is contained in:
@@ -54,7 +54,7 @@ class PokemonPokedexInfo_Scene
|
||||
@sprites["formback"] = PokemonSprite.new(@viewport)
|
||||
@sprites["formback"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["formback"].x = 382 # y is set below as it depends on metrics
|
||||
@sprites["formicon"] = PokemonSpeciesIconSprite.new(0,@viewport)
|
||||
@sprites["formicon"] = PokemonSpeciesIconSprite.new(nil, @viewport)
|
||||
@sprites["formicon"].setOffset(PictureOrigin::Center)
|
||||
@sprites["formicon"].x = 82
|
||||
@sprites["formicon"].y = 328
|
||||
@@ -79,20 +79,18 @@ class PokemonPokedexInfo_Scene
|
||||
def pbStartSceneBrief(species) # For standalone access, shows first page only
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
# @region = 0
|
||||
dexnum = species
|
||||
dexnumshift = false
|
||||
if $PokemonGlobal.pokedexUnlocked[$PokemonGlobal.pokedexUnlocked.length-1]
|
||||
dexnumshift = true if DEXES_WITH_OFFSETS.include?(-1)
|
||||
if $PokemonGlobal.pokedexUnlocked[$PokemonGlobal.pokedexUnlocked.length - 1]
|
||||
dexnumshift = true if DEXES_WITH_OFFSETS.include?(-1) # National Dex
|
||||
else
|
||||
dexnum = 0
|
||||
for i in 0...$PokemonGlobal.pokedexUnlocked.length-1
|
||||
for i in 0...$PokemonGlobal.pokedexUnlocked.length - 1 # Regional Dexes
|
||||
next if !$PokemonGlobal.pokedexUnlocked[i]
|
||||
num = pbGetRegionalNumber(i,species)
|
||||
next if num<=0
|
||||
next if num <= 0
|
||||
dexnum = num
|
||||
dexnumshift = true if DEXES_WITH_OFFSETS.include?(i)
|
||||
# @region = pbDexNames[i][1] if pbDexNames[i].is_a?(Array)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -132,17 +130,19 @@ class PokemonPokedexInfo_Scene
|
||||
|
||||
def pbUpdateDummyPokemon
|
||||
@species = @dexlist[@index][0]
|
||||
@gender = ($Trainer.formlastseen[@species][0] rescue 0)
|
||||
@form = ($Trainer.formlastseen[@species][1] rescue 0)
|
||||
@sprites["infosprite"].setSpeciesBitmap(@species,(@gender==1),@form)
|
||||
$Trainer.formlastseen = {} if !$Trainer.formlastseen
|
||||
$Trainer.formlastseen[@species] = [] if !$Trainer.formlastseen[@species]
|
||||
@gender = $Trainer.formlastseen[@species][0] || 0
|
||||
@form = $Trainer.formlastseen[@species][1] || 0
|
||||
species_data = GameData::Species.get_species_form(@species, @form)
|
||||
@sprites["infosprite"].setSpeciesBitmap(@species,@gender,@form)
|
||||
if @sprites["formfront"]
|
||||
@sprites["formfront"].setSpeciesBitmap(@species,(@gender==1),@form)
|
||||
@sprites["formfront"].setSpeciesBitmap(@species,@gender,@form)
|
||||
end
|
||||
if @sprites["formback"]
|
||||
@sprites["formback"].setSpeciesBitmap(@species,(@gender==1),@form,false,false,true)
|
||||
@sprites["formback"].setSpeciesBitmap(@species,@gender,@form,false,false,true)
|
||||
@sprites["formback"].y = 256
|
||||
fSpecies = pbGetFSpeciesFromForm(@species,@form)
|
||||
@sprites["formback"].y += (pbLoadSpeciesMetrics[SpeciesData::METRIC_PLAYER_Y][fSpecies] || 0)*2
|
||||
@sprites["formback"].y += species_data.back_sprite_y * 2
|
||||
end
|
||||
if @sprites["formicon"]
|
||||
@sprites["formicon"].pbSetParams(@species,@gender,@form)
|
||||
@@ -150,53 +150,44 @@ class PokemonPokedexInfo_Scene
|
||||
end
|
||||
|
||||
def pbGetAvailableForms
|
||||
available = [] # [name, gender, form]
|
||||
formdata = pbLoadFormToSpecies
|
||||
possibleforms = []
|
||||
multiforms = false
|
||||
if formdata[@species]
|
||||
for i in 0...formdata[@species].length
|
||||
fSpecies = pbGetFSpeciesFromForm(@species,i)
|
||||
formname = pbGetMessage(MessageTypes::FormNames,fSpecies)
|
||||
genderRate = pbGetSpeciesData(@species,i,SpeciesData::GENDER_RATE)
|
||||
if i==0 || (formname && formname!="")
|
||||
multiforms = true if i>0
|
||||
case genderRate
|
||||
when PBGenderRates::AlwaysMale,
|
||||
PBGenderRates::AlwaysFemale,
|
||||
PBGenderRates::Genderless
|
||||
gendertopush = (genderRate==PBGenderRates::AlwaysFemale) ? 1 : 0
|
||||
if $Trainer.formseen[@species][gendertopush][i] || DEX_SHOWS_ALL_FORMS
|
||||
gendertopush = 2 if genderRate==PBGenderRates::Genderless
|
||||
possibleforms.push([i,gendertopush,formname])
|
||||
end
|
||||
else # Both male and female
|
||||
for g in 0...2
|
||||
if $Trainer.formseen[@species][g][i] || DEX_SHOWS_ALL_FORMS
|
||||
possibleforms.push([i,g,formname])
|
||||
break if (formname && formname!="")
|
||||
end
|
||||
end
|
||||
end
|
||||
ret = []
|
||||
multiple_forms = false
|
||||
# Find all genders/forms of @species that have been seen
|
||||
GameData::Species.each do |sp|
|
||||
next if sp.species != @species
|
||||
next if sp.form != 0 && (!sp.real_form_name || sp.real_form_name.empty?)
|
||||
next if sp.pokedex_form != sp.form
|
||||
multiple_forms = true if sp.form > 0
|
||||
$Trainer.formseen[@species] = [[], []] if !$Trainer.formseen[@species]
|
||||
case sp.gender_rate
|
||||
when PBGenderRates::AlwaysMale, PBGenderRates::AlwaysFemale, PBGenderRates::Genderless
|
||||
real_gender = (sp.gender_rate == PBGenderRates::AlwaysFemale) ? 1 : 0
|
||||
next if !$Trainer.formseen[@species][real_gender][sp.form] && !DEX_SHOWS_ALL_FORMS
|
||||
real_gender = 2 if sp.gender_rate == PBGenderRates::Genderless
|
||||
ret.push([sp.form_name, real_gender, sp.form])
|
||||
else # Both male and female
|
||||
for real_gender in 0...2
|
||||
next if !$Trainer.formseen[@species][real_gender][sp.form] && !DEX_SHOWS_ALL_FORMS
|
||||
ret.push([sp.form_name, real_gender, sp.form])
|
||||
break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form
|
||||
end
|
||||
end
|
||||
end
|
||||
for thisform in possibleforms
|
||||
if thisform[2] && thisform[2]!="" # Has a form name
|
||||
thisformname = thisform[2]
|
||||
else # Necessarily applies only to form 0
|
||||
case thisform[1]
|
||||
when 0 then thisformname = _INTL("Male")
|
||||
when 1 then thisformname = _INTL("Female")
|
||||
# Sort all entries
|
||||
ret.sort! { |a, b| (a[2] == b[2]) ? a[1] <=> b[1] : a[2] <=> b[2] }
|
||||
# Create form names for entries if they don't already exist
|
||||
ret.each do |entry|
|
||||
if !entry[0] || entry[0].empty? # Necessarily applies only to form 0
|
||||
case entry[1]
|
||||
when 0 then entry[0] = _INTL("Male")
|
||||
when 1 then entry[0] = _INTL("Female")
|
||||
else
|
||||
thisformname = (multiforms) ? _INTL("One Form") : _INTL("Genderless")
|
||||
entry[0] = (multiple_forms) ? _INTL("One Form") : _INTL("Genderless")
|
||||
end
|
||||
end
|
||||
# Push to available array
|
||||
gendertopush = (thisform[1]==2) ? 0 : thisform[1]
|
||||
available.push([thisformname,gendertopush,thisform[0]])
|
||||
entry[1] = 0 if entry[1] == 2 # Genderless entries are treated as male
|
||||
end
|
||||
return available
|
||||
return ret
|
||||
end
|
||||
|
||||
def drawPage(page)
|
||||
@@ -221,82 +212,78 @@ class PokemonPokedexInfo_Scene
|
||||
def drawPageInfo
|
||||
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_info"))
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
base = Color.new(88,88,80)
|
||||
shadow = Color.new(168,184,184)
|
||||
base = Color.new(88, 88, 80)
|
||||
shadow = Color.new(168, 184, 184)
|
||||
imagepos = []
|
||||
if @brief
|
||||
imagepos.push([_INTL("Graphics/Pictures/Pokedex/overlay_info"),0,0])
|
||||
imagepos.push([_INTL("Graphics/Pictures/Pokedex/overlay_info"), 0, 0])
|
||||
end
|
||||
species_data = GameData::Species.get_species_form(@species, @form)
|
||||
# Write various bits of text
|
||||
indexText = "???"
|
||||
if @dexlist[@index][4]>0
|
||||
if @dexlist[@index][4] > 0
|
||||
indexNumber = @dexlist[@index][4]
|
||||
indexNumber -= 1 if @dexlist[@index][5]
|
||||
indexText = sprintf("%03d",indexNumber)
|
||||
indexText = sprintf("%03d", indexNumber)
|
||||
end
|
||||
textpos = [
|
||||
[_INTL("{1}{2} {3}",indexText," ",PBSpecies.getName(@species)),
|
||||
246,42,0,Color.new(248,248,248),Color.new(0,0,0)],
|
||||
[_INTL("Height"),314,158,0,base,shadow],
|
||||
[_INTL("Weight"),314,190,0,base,shadow]
|
||||
[_INTL("{1}{2} {3}", indexText, " ", species_data.name),
|
||||
246, 42, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)],
|
||||
[_INTL("Height"), 314, 158, 0, base, shadow],
|
||||
[_INTL("Weight"), 314, 190, 0, base, shadow]
|
||||
]
|
||||
if $Trainer.owned[@species]
|
||||
speciesData = pbGetSpeciesData(@species,@form)
|
||||
fSpecies = pbGetFSpeciesFromForm(@species,@form)
|
||||
# Write the kind
|
||||
kind = pbGetMessage(MessageTypes::Kinds,fSpecies)
|
||||
kind = pbGetMessage(MessageTypes::Kinds,@species) if !kind || kind==""
|
||||
textpos.push([_INTL("{1} Pokémon",kind),246,74,0,base,shadow])
|
||||
# Write the category
|
||||
textpos.push([_INTL("{1} Pokémon", species_data.category), 246, 74, 0, base, shadow])
|
||||
# Write the height and weight
|
||||
height = speciesData[SpeciesData::HEIGHT] || 1
|
||||
weight = speciesData[SpeciesData::WEIGHT] || 1
|
||||
if pbGetCountry==0xF4 # If the user is in the United States
|
||||
inches = (height/0.254).round
|
||||
pounds = (weight/0.45359).round
|
||||
textpos.push([_ISPRINTF("{1:d}'{2:02d}\"",inches/12,inches%12),460,158,1,base,shadow])
|
||||
textpos.push([_ISPRINTF("{1:4.1f} lbs.",pounds/10.0),494,190,1,base,shadow])
|
||||
height = species_data.height
|
||||
weight = species_data.weight
|
||||
if pbGetCountry == 0xF4 # If the user is in the United States
|
||||
inches = (height / 0.254).round
|
||||
pounds = (weight / 0.45359).round
|
||||
textpos.push([_ISPRINTF("{1:d}'{2:02d}\"", inches / 12, inches % 12), 460, 158, 1, base, shadow])
|
||||
textpos.push([_ISPRINTF("{1:4.1f} lbs.", pounds / 10.0), 494, 190, 1, base, shadow])
|
||||
else
|
||||
textpos.push([_ISPRINTF("{1:.1f} m",height/10.0),470,158,1,base,shadow])
|
||||
textpos.push([_ISPRINTF("{1:.1f} kg",weight/10.0),482,190,1,base,shadow])
|
||||
textpos.push([_ISPRINTF("{1:.1f} m", height / 10.0), 470, 158, 1, base, shadow])
|
||||
textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 190, 1, base, shadow])
|
||||
end
|
||||
# Draw the Pokédex entry text
|
||||
entry = pbGetMessage(MessageTypes::Entries,fSpecies)
|
||||
entry = pbGetMessage(MessageTypes::Entries,@species) if !entry || entry==""
|
||||
drawTextEx(overlay,40,240,Graphics.width-(40*2),4,entry,base,shadow)
|
||||
drawTextEx(overlay, 40, 240, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
|
||||
species_data.pokedex_entry, base, shadow)
|
||||
# Draw the footprint
|
||||
footprintfile = pbPokemonFootprintFile(@species,@form)
|
||||
footprintfile = GameData::Species.footprint_filename(@species, @form)
|
||||
if footprintfile
|
||||
footprint = BitmapCache.load_bitmap(footprintfile)
|
||||
overlay.blt(226,138,footprint,footprint.rect)
|
||||
overlay.blt(226, 138, footprint, footprint.rect)
|
||||
footprint.dispose
|
||||
end
|
||||
# Show the owned icon
|
||||
imagepos.push(["Graphics/Pictures/Pokedex/icon_own",212,44])
|
||||
imagepos.push(["Graphics/Pictures/Pokedex/icon_own", 212, 44])
|
||||
# Draw the type icon(s)
|
||||
type1 = speciesData[SpeciesData::TYPE1]
|
||||
type2 = speciesData[SpeciesData::TYPE2] || type1
|
||||
type1 = species_data.type1
|
||||
type2 = species_data.type2
|
||||
type1_number = GameData::Type.get(type1).id_number
|
||||
type2_number = GameData::Type.get(type2).id_number
|
||||
type1rect = Rect.new(0,type1_number*32,96,32)
|
||||
type2rect = Rect.new(0,type2_number*32,96,32)
|
||||
overlay.blt(296,120,@typebitmap.bitmap,type1rect)
|
||||
overlay.blt(396,120,@typebitmap.bitmap,type2rect) if type1!=type2
|
||||
type1rect = Rect.new(0, type1_number * 32, 96, 32)
|
||||
type2rect = Rect.new(0, type2_number * 32, 96, 32)
|
||||
overlay.blt(296, 120, @typebitmap.bitmap, type1rect)
|
||||
overlay.blt(396, 120, @typebitmap.bitmap, type2rect) if type1 != type2
|
||||
else
|
||||
# Write the kind
|
||||
textpos.push([_INTL("????? Pokémon"),246,74,0,base,shadow])
|
||||
# Write the category
|
||||
textpos.push([_INTL("????? Pokémon"), 246, 74, 0, base, shadow])
|
||||
# Write the height and weight
|
||||
if pbGetCountry()==0xF4 # If the user is in the United States
|
||||
textpos.push([_INTL("???'??\""),460,158,1,base,shadow])
|
||||
textpos.push([_INTL("????.? lbs."),494,190,1,base,shadow])
|
||||
if pbGetCountry == 0xF4 # If the user is in the United States
|
||||
textpos.push([_INTL("???'??\""), 460, 158, 1, base, shadow])
|
||||
textpos.push([_INTL("????.? lbs."), 494, 190, 1, base, shadow])
|
||||
else
|
||||
textpos.push([_INTL("????.? m"),470,158,1,base,shadow])
|
||||
textpos.push([_INTL("????.? kg"),482,190,1,base,shadow])
|
||||
textpos.push([_INTL("????.? m"), 470, 158, 1, base, shadow])
|
||||
textpos.push([_INTL("????.? kg"), 482, 190, 1, base, shadow])
|
||||
end
|
||||
end
|
||||
# Draw all text
|
||||
pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
|
||||
pbDrawTextPositions(overlay, textpos)
|
||||
# Draw all images
|
||||
pbDrawImagePositions(overlay,imagepos)
|
||||
pbDrawImagePositions(overlay, imagepos)
|
||||
end
|
||||
|
||||
def drawPageArea
|
||||
@@ -374,7 +361,7 @@ class PokemonPokedexInfo_Scene
|
||||
textpos.push([_INTL("Area unknown"),Graphics.width/2,Graphics.height/2,2,base,shadow])
|
||||
end
|
||||
textpos.push([pbGetMessage(MessageTypes::RegionNames,@region),414,44,2,base,shadow])
|
||||
textpos.push([_INTL("{1}'s area",PBSpecies.getName(@species)),
|
||||
textpos.push([_INTL("{1}'s area",GameData::Species.get(@species).name),
|
||||
Graphics.width/2,352,2,base,shadow])
|
||||
pbDrawTextPositions(overlay,textpos)
|
||||
end
|
||||
@@ -392,7 +379,7 @@ class PokemonPokedexInfo_Scene
|
||||
end
|
||||
end
|
||||
textpos = [
|
||||
[PBSpecies.getName(@species),Graphics.width/2,Graphics.height-88,2,base,shadow],
|
||||
[GameData::Species.get(@species).name,Graphics.width/2,Graphics.height-88,2,base,shadow],
|
||||
[formname,Graphics.width/2,Graphics.height-56,2,base,shadow],
|
||||
]
|
||||
# Draw all text
|
||||
@@ -432,6 +419,8 @@ class PokemonPokedexInfo_Scene
|
||||
oldindex = -1
|
||||
loop do
|
||||
if oldindex!=index
|
||||
$Trainer.formlastseen = {} if !$Trainer.formlastseen
|
||||
$Trainer.formlastseen[@species] = [] if !$Trainer.formlastseen
|
||||
$Trainer.formlastseen[@species][0] = @available[index][1]
|
||||
$Trainer.formlastseen[@species][1] = @available[index][2]
|
||||
pbUpdateDummyPokemon
|
||||
@@ -462,7 +451,7 @@ class PokemonPokedexInfo_Scene
|
||||
end
|
||||
|
||||
def pbScene
|
||||
pbPlayCrySpecies(@species,@form)
|
||||
GameData::Species.play_cry_from_species(@species, @form)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@@ -470,7 +459,7 @@ class PokemonPokedexInfo_Scene
|
||||
dorefresh = false
|
||||
if Input.trigger?(Input::A)
|
||||
pbSEStop
|
||||
pbPlayCrySpecies(@species,@form) if @page==1
|
||||
GameData::Species.play_cry_from_species(@species, @form) if @page == 1
|
||||
elsif Input.trigger?(Input::B)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
@@ -491,7 +480,7 @@ class PokemonPokedexInfo_Scene
|
||||
pbUpdateDummyPokemon
|
||||
@available = pbGetAvailableForms
|
||||
pbSEStop
|
||||
(@page==1) ? pbPlayCrySpecies(@species,@form) : pbPlayCursorSE
|
||||
(@page==1) ? GameData::Species.play_cry_from_species(@species, @form) : pbPlayCursorSE
|
||||
dorefresh = true
|
||||
end
|
||||
elsif Input.trigger?(Input::DOWN)
|
||||
@@ -501,7 +490,7 @@ class PokemonPokedexInfo_Scene
|
||||
pbUpdateDummyPokemon
|
||||
@available = pbGetAvailableForms
|
||||
pbSEStop
|
||||
(@page==1) ? pbPlayCrySpecies(@species,@form) : pbPlayCursorSE
|
||||
(@page==1) ? GameData::Species.play_cry_from_species(@species, @form) : pbPlayCursorSE
|
||||
dorefresh = true
|
||||
end
|
||||
elsif Input.trigger?(Input::LEFT)
|
||||
@@ -531,14 +520,14 @@ class PokemonPokedexInfo_Scene
|
||||
end
|
||||
|
||||
def pbSceneBrief
|
||||
pbPlayCrySpecies(@species,@form)
|
||||
GameData::Species.play_cry_from_species(@species, @form)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::A)
|
||||
pbSEStop
|
||||
pbPlayCrySpecies(@species,@form)
|
||||
GameData::Species.play_cry_from_species(@species, @form)
|
||||
elsif Input.trigger?(Input::B)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
@@ -574,7 +563,7 @@ class PokemonPokedexInfoScreen
|
||||
end
|
||||
dexnum = pbGetRegionalNumber(region,species)
|
||||
dexnumshift = DEXES_WITH_OFFSETS.include?(region)
|
||||
dexlist = [[species,PBSpecies.getName(species),0,0,dexnum,dexnumshift]]
|
||||
dexlist = [[species,GameData::Species.get(species).name,0,0,dexnum,dexnumshift]]
|
||||
@scene.pbStartScene(dexlist,0,region)
|
||||
@scene.pbScene
|
||||
@scene.pbEndScene
|
||||
|
||||
Reference in New Issue
Block a user