Advertisement
Vendily

pokedex

Aug 5th, 2018
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 40.53 KB | None | 0 0
  1. #===============================================================================
  2. # Pokédex menu screen
  3. # * For choosing which region list to view.  Only appears when there is more
  4. #   than one viable region list to choose from, and if DEXDEPENDSONLOCATION is
  5. #   false.
  6. # * Adapted from the Pokégear menu script by Maruno.
  7. #===============================================================================
  8. HABITAT_2_PIC=["None",
  9.                "Grassland",
  10.                "Forest",
  11.                "WatersEdge",
  12.                "Sea",
  13.                "Cave",
  14.                "Mountain",
  15.                "RoughTerrain",
  16.                "Urban",
  17.                "Rare"]
  18.  
  19. class Window_DexesList < Window_CommandPokemon
  20.   def initialize(commands,width,seen,owned)
  21.     @seen=seen
  22.     @owned=owned
  23.     super(commands,width)
  24.     @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrowwhite")
  25.     self.windowskin=nil
  26.   end
  27.  
  28.   def drawItem(index,count,rect)
  29.     super(index,count,rect)
  30.     if index>=0 && index<@seen.length
  31.       pbDrawShadowText(self.contents,rect.x+236,rect.y,64,rect.height,
  32.          @seen[index],self.baseColor,self.shadowColor,1)
  33.       pbDrawShadowText(self.contents,rect.x+332,rect.y,64,rect.height,
  34.          @owned[index],self.baseColor,self.shadowColor,1)
  35.     end
  36.   end
  37. end
  38.  
  39.  
  40.  
  41. class Scene_PokedexMenu
  42.   def initialize(menu_index = 0)
  43.     @menu_index = menu_index
  44.   end
  45.  
  46.   def main
  47.     commands=[]; seen=[]; owned=[]
  48.     dexnames=pbDexNames
  49.     for i in 0...$PokemonGlobal.pokedexViable.length
  50.       index=$PokemonGlobal.pokedexViable[i]
  51.       if dexnames[index]==nil
  52.         commands.push(_INTL("Pokédex"))
  53.       else
  54.         if dexnames[index].is_a?(Array)
  55.           commands.push(dexnames[index][0])
  56.         else
  57.           commands.push(dexnames[index])
  58.         end
  59.       end
  60.       index=-1 if index>=$PokemonGlobal.pokedexUnlocked.length-1
  61.       seen.push($Trainer.pokedexSeen(index).to_s)
  62.       owned.push($Trainer.pokedexOwned(index).to_s)
  63.     end
  64.     commands.push(_INTL("Exit"))
  65.     @sprites={}
  66.     @sprites["background"] = IconSprite.new(0,0)
  67.     @sprites["background"].setBitmap("Graphics/Pictures/pokedexMenubg")
  68.     @sprites["commands"] = Window_DexesList.new(commands,Graphics.width,seen,owned)
  69.     @sprites["commands"].index = @menu_index
  70.     @sprites["commands"].x = 42
  71.     @sprites["commands"].y = 160
  72.     @sprites["commands"].width = Graphics.width-84
  73.     @sprites["commands"].height = 224
  74.     @sprites["commands"].windowskin=nil
  75.     @sprites["commands"].baseColor=Color.new(248,248,248)
  76.     @sprites["commands"].shadowColor=Color.new(0,0,0)
  77.     @sprites["headings"]=Window_AdvancedTextPokemon.newWithSize(
  78.        _INTL("<c3=F8F8F8,C02028>SEEN<r>OBTAINED</c3>"),286,104,208,64,@viewport)
  79.     @sprites["headings"].windowskin=nil
  80.     Graphics.transition
  81.     loop do
  82.       Graphics.update
  83.       Input.update
  84.       update
  85.       if $scene != self
  86.         break
  87.       end
  88.     end
  89.     Graphics.freeze
  90.     pbDisposeSpriteHash(@sprites)
  91.   end
  92.  
  93.   def update
  94.     pbUpdateSpriteHash(@sprites)
  95.     if @sprites["commands"].active
  96.       update_command
  97.       return
  98.     end
  99.   end
  100.  
  101.   def update_command
  102.     if Input.trigger?(Input::B)
  103.       pbPlayCancelSE()
  104.       $scene = Scene_Map.new
  105.       return
  106.     end
  107.     if Input.trigger?(Input::C)
  108.       case @sprites["commands"].index
  109.       when @sprites["commands"].itemCount-1
  110.         pbPlayDecisionSE()
  111.         $scene = Scene_Map.new
  112.       else
  113.         pbPlayDecisionSE()
  114.         $PokemonGlobal.pokedexDex=$PokemonGlobal.pokedexViable[@sprites["commands"].index]
  115.         $PokemonGlobal.pokedexDex=-1 if $PokemonGlobal.pokedexDex==$PokemonGlobal.pokedexUnlocked.length-1
  116.         pbFadeOutIn(99999) {
  117.            scene=PokemonPokedexScene.new
  118.            screen=PokemonPokedex.new(scene)
  119.            screen.pbStartScreen
  120.         }
  121.       end
  122.       return
  123.     end
  124.   end
  125. end
  126.  
  127.  
  128.  
  129. #===============================================================================
  130. # Pokédex main screen
  131. #===============================================================================
  132. class Window_CommandPokemonWhiteArrow < Window_CommandPokemon
  133.   def drawCursor(index,rect)
  134.     selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrowwhite")
  135.     if self.index==index
  136.       pbCopyBitmap(self.contents,selarrow.bitmap,rect.x,rect.y)
  137.     end
  138.     return Rect.new(rect.x+16,rect.y,rect.width-16,rect.height)
  139.   end
  140. end
  141.  
  142.  
  143.  
  144. class Window_Pokedex < Window_DrawableCommand
  145.   def initialize(x,y,width,height)
  146.     @pokeballOwned=AnimatedBitmap.new("Graphics/Pictures/pokedexOwned")
  147.     @pokeballSeen=AnimatedBitmap.new("Graphics/Pictures/pokedexSeen")
  148.     @commands=[]
  149.     super(x,y,width,height)
  150.     self.windowskin=nil
  151.     self.baseColor=Color.new(88,88,80)
  152.     self.shadowColor=Color.new(168,184,184)
  153.   end
  154.  
  155.   def drawCursor(index,rect)
  156.     selarrow=AnimatedBitmap.new("Graphics/Pictures/pokedexSel")
  157.     if self.index==index
  158.       pbCopyBitmap(self.contents,selarrow.bitmap,rect.x,rect.y)
  159.     end
  160.     return Rect.new(rect.x+16,rect.y,rect.width-16,rect.height)
  161.   end
  162.  
  163.   def commands=(value)
  164.     @commands=value
  165.     refresh
  166.   end
  167.  
  168.   def dispose
  169.     @pokeballOwned.dispose
  170.     @pokeballSeen.dispose
  171.     super
  172.   end
  173.  
  174.   def species
  175.     return @commands.length==0 ? 0 : @commands[self.index][0]
  176.   end
  177.  
  178.   def itemCount
  179.     return @commands.length
  180.   end
  181.  
  182.   def drawItem(index,count,rect)
  183.     return if index >= self.top_row + self.page_item_max
  184.     rect=drawCursor(index,rect)
  185.     indexNumber=@commands[index][4]
  186.     species=@commands[index][0]
  187.     if $Trainer.seen[species]
  188.       if $Trainer.owned[species]
  189.         pbCopyBitmap(self.contents,@pokeballOwned.bitmap,rect.x-6,rect.y+8)
  190.       else
  191.         pbCopyBitmap(self.contents,@pokeballSeen.bitmap,rect.x-6,rect.y+8)
  192.       end
  193.       text=_ISPRINTF("{1:03d}{2:s} {3:s}",(@commands[index][5]) ? indexNumber-1 : indexNumber," ",@commands[index][1])
  194.     else
  195.       text=_ISPRINTF("{1:03d}  ----------",(@commands[index][5]) ? indexNumber-1 : indexNumber)
  196.     end
  197.     pbDrawShadowText(self.contents,rect.x+34,rect.y+6,rect.width,rect.height,text,
  198.        self.baseColor,self.shadowColor)
  199.     overlapCursor=drawCursor(index-1,itemRect(index-1))
  200.   end
  201. end
  202.  
  203.  
  204.  
  205. class Window_ComplexCommandPokemon < Window_DrawableCommand
  206.   attr_reader :commands
  207.  
  208.   def initialize(commands,width=nil)
  209.     @starting=true
  210.     @commands=commands
  211.     dims=[]
  212.     getAutoDims(commands,dims,width)
  213.     super(0,0,dims[0],dims[1])
  214.     @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrowwhite")
  215.     @starting=false
  216.   end
  217.  
  218.   def self.newEmpty(x,y,width,height,viewport=nil)
  219.     ret=self.new([],width)
  220.     ret.x=x
  221.     ret.y=y
  222.     ret.width=width
  223.     ret.height=height
  224.     ret.viewport=viewport
  225.     return ret
  226.   end
  227.  
  228.   def index=(value)
  229.     super
  230.     refresh if !@starting
  231.   end
  232.  
  233.   def indexToCommand(index)
  234.     curindex=0
  235.     i=0; loop do break unless i<@commands.length
  236.       return [i/2,-1] if index==curindex
  237.       curindex+=1
  238.       return [i/2,index-curindex] if index-curindex<commands[i+1].length
  239.       curindex+=commands[i+1].length
  240.       i+=2
  241.     end
  242.     return [-1,-1]
  243.   end
  244.  
  245.   def getText(array,index)
  246.     cmd=indexToCommand(index)
  247.     return "" if cmd[0]==-1
  248.     return array[cmd[0]*2] if cmd[1]<0
  249.     return array[cmd[0]*2+1][cmd[1]]
  250.   end
  251.  
  252.   def commands=(value)
  253.     @commands=value
  254.     @item_max=commands.length  
  255.     self.index=self.index
  256.   end
  257.  
  258.   def width=(value)
  259.     super
  260.     if !@starting
  261.       self.index=self.index
  262.     end
  263.   end
  264.  
  265.   def height=(value)
  266.     super
  267.     if !@starting
  268.       self.index=self.index
  269.     end
  270.   end
  271.  
  272.   def resizeToFit(commands)
  273.     dims=[]
  274.     getAutoDims(commands,dims)
  275.     self.width=dims[0]
  276.     self.height=dims[1]
  277.   end
  278.  
  279.   def itemCount
  280.     mx=0
  281.     i=0; loop do break unless i<@commands.length
  282.       mx+=1+@commands[i+1].length
  283.       i+=2
  284.     end
  285.     return mx
  286.   end
  287.  
  288.   def drawItem(index,count,rect)
  289.     command=indexToCommand(index)
  290.     return if command[0]<0
  291.     text=getText(@commands,index)
  292.     if command[1]<0
  293.       pbDrawShadowText(self.contents,rect.x+32,rect.y,rect.width,rect.height,text,
  294.          self.baseColor,self.shadowColor)
  295.     else
  296.       rect=drawCursor(index,rect)
  297.       pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,text,
  298.          self.baseColor,self.shadowColor)
  299.     end
  300.   end
  301. end
  302.  
  303.  
  304.  
  305. class PokemonPokedexScene
  306.   def pbUpdate
  307.     pbUpdateSpriteHash(@sprites)
  308.   end
  309.  
  310.   def setIconBitmap(species)
  311.     gender=($Trainer.formlastseen[species][0] rescue 0)
  312.     form=($Trainer.formlastseen[species][1] rescue 0)
  313.     @sprites["icon"].setSpeciesBitmap(species,(gender==1),form)
  314.     pbPositionPokemonSprite(@sprites["icon"],116-64,164-64)
  315.   end
  316.  
  317. # Gets the region used for displaying Pokédex entries.  Species will be listed
  318. # according to the given region's numbering and the returned region can have
  319. # any value defined in the town map data file.  It is currently set to the
  320. # return value of pbGetCurrentRegion, and thus will change according to the
  321. # current map's MapPosition metadata setting.
  322.   def pbGetPokedexRegion
  323.     if DEXDEPENDSONLOCATION
  324.       region=pbGetCurrentRegion
  325.       region=-1 if region>=$PokemonGlobal.pokedexUnlocked.length-1
  326.       return region
  327.     else
  328.       return $PokemonGlobal.pokedexDex # National Dex -1, regional dexes 0 etc.
  329.     end
  330.   end
  331.  
  332. # Determines which index of the array $PokemonGlobal.pokedexIndex to save the
  333. # "last viewed species" in.  All regional dexes come first in order, then the
  334. # National Dex at the end.
  335.   def pbGetSavePositionIndex
  336.     index=pbGetPokedexRegion
  337.     if index==-1 # National Dex
  338.       index=$PokemonGlobal.pokedexUnlocked.length-1 # National Dex index comes
  339.     end                                             # after regional Dex indices
  340.     return index
  341.   end
  342.  
  343.   def pbStartScene
  344.     @dummypokemon=PokeBattle_Pokemon.new(1,1)
  345.     @sprites={}
  346.     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  347.     @viewport.z=99999
  348.     @sprites["pokedex"]=Window_Pokedex.new(214,18,268,332)
  349.     @sprites["pokedex"].viewport=@viewport
  350.     @sprites["dexbg"]=IconSprite.new(0,0,@viewport)
  351.     @sprites["dexbg"].setBitmap(_INTL("Graphics/Pictures/Habitat/{1}",HABITAT_2_PIC[@dummypokemon.habitat]))
  352.     @sprites["dexbg"].visible=false
  353.     @sprites["dexentry"]=IconSprite.new(0,0,@viewport)
  354.     @sprites["dexentry"].setBitmap(_INTL("Graphics/Pictures/Habitat/pokedexEntry"))
  355.     @sprites["dexentry"].visible=false
  356.     @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
  357.     pbSetSystemFont(@sprites["overlay"].bitmap)
  358.     @sprites["overlay"].x=0
  359.     @sprites["overlay"].y=0
  360.     @sprites["overlay"].visible=false
  361.     @sprites["searchtitle"]=Window_AdvancedTextPokemon.newWithSize("",2,-18,Graphics.width,64,@viewport)
  362.     @sprites["searchtitle"].windowskin=nil
  363.     @sprites["searchtitle"].baseColor=Color.new(248,248,248)
  364.     @sprites["searchtitle"].shadowColor=Color.new(0,0,0)
  365.     @sprites["searchtitle"].text=_ISPRINTF("<ac>Search Mode</ac>")
  366.     @sprites["searchtitle"].visible=false
  367.     @sprites["searchlist"]=Window_ComplexCommandPokemon.newEmpty(-6,32,284,352,@viewport)
  368.     @sprites["searchlist"].baseColor=Color.new(248,248,248)
  369.     @sprites["searchlist"].shadowColor=Color.new(0,0,0)
  370.     @sprites["searchlist"].visible=false
  371.     @sprites["auxlist"]=Window_CommandPokemonWhiteArrow.newEmpty(256,32,284,224,@viewport)
  372.     @sprites["auxlist"].baseColor=Color.new(248,248,248)
  373.     @sprites["auxlist"].shadowColor=Color.new(0,0,0)
  374.     @sprites["auxlist"].visible=false
  375.     @sprites["messagebox"]=Window_UnformattedTextPokemon.newWithSize("",254,256,264,128,@viewport)
  376.     @sprites["messagebox"].baseColor=Color.new(248,248,248)
  377.     @sprites["messagebox"].shadowColor=Color.new(0,0,0)
  378.     @sprites["messagebox"].visible=false
  379.     @sprites["messagebox"].letterbyletter=false
  380.     @sprites["dexname"]=Window_AdvancedTextPokemon.newWithSize("",2,-18,Graphics.width,64,@viewport)
  381.     @sprites["dexname"].windowskin=nil
  382.     @sprites["dexname"].baseColor=Color.new(248,248,248)
  383.     @sprites["dexname"].shadowColor=Color.new(0,0,0)
  384.     @sprites["species"]=Window_AdvancedTextPokemon.newWithSize("",38,22,160,64,@viewport)
  385.     @sprites["species"].windowskin=nil
  386.     @sprites["species"].baseColor=Color.new(88,88,80)
  387.     @sprites["species"].shadowColor=Color.new(168,184,184)
  388.     @sprites["seen"]=Window_AdvancedTextPokemon.newWithSize("",38,242,164,64,@viewport)
  389.     @sprites["seen"].windowskin=nil
  390.     @sprites["seen"].baseColor=Color.new(88,88,80)
  391.     @sprites["seen"].shadowColor=Color.new(168,184,184)
  392.     @sprites["owned"]=Window_AdvancedTextPokemon.newWithSize("",38,282,164,64,@viewport)
  393.     @sprites["owned"].windowskin=nil
  394.     @sprites["owned"].baseColor=Color.new(88,88,80)
  395.     @sprites["owned"].shadowColor=Color.new(168,184,184)
  396.     addBackgroundPlane(@sprites,"searchbg",_INTL("pokedexSearchbg"),@viewport)
  397.     @sprites["searchbg"].visible=false
  398.     @searchResults=false
  399. =begin
  400. # Suggestion for changing the background depending on region.  You
  401. # can change the line below with the following:
  402.     if pbGetPokedexRegion==-1 # Using national Pokédex
  403.       addBackgroundPlane(@sprites,"background","pokedexbg_national",@viewport)
  404.     elsif pbGetPokedexRegion==0 # Using first regional Pokédex
  405.       addBackgroundPlane(@sprites,"background","pokedexbg_regional",@viewport)
  406.     end
  407. =end
  408.     addBackgroundPlane(@sprites,"background",_INTL("pokedexbg"),@viewport)
  409.     @sprites["slider"]=IconSprite.new(Graphics.width-44,62,@viewport)
  410.     @sprites["slider"].setBitmap(sprintf("Graphics/Pictures/pokedexSlider"))
  411.     @sprites["icon"]=PokemonSprite.new(@viewport)
  412.     @sprites["entryicon"]=PokemonSprite.new(@viewport)
  413.     pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex])
  414.     pbDeactivateWindows(@sprites)
  415.     pbFadeInAndShow(@sprites)
  416.   end
  417.  
  418.   def pbDexSearchCommands(commands,selitem,helptexts=nil)
  419.     ret=-1
  420.     auxlist=@sprites["auxlist"]
  421.     messagebox=@sprites["messagebox"]
  422.     auxlist.commands=commands
  423.     auxlist.index=selitem
  424.     messagebox.text=helptexts ? helptexts[auxlist.index] : ""
  425.     pbActivateWindow(@sprites,"auxlist"){
  426.        loop do
  427.          Graphics.update
  428.          Input.update
  429.          oldindex=auxlist.index
  430.          pbUpdate
  431.          if auxlist.index!=oldindex && helptexts
  432.            messagebox.text=helptexts[auxlist.index]
  433.          end
  434.          if Input.trigger?(Input::B)
  435.            ret=selitem
  436.            pbPlayCancelSE()
  437.            break
  438.          end
  439.          if Input.trigger?(Input::C)
  440.            ret=auxlist.index
  441.            pbPlayDecisionSE()
  442.            break
  443.          end
  444.        end
  445.        @sprites["auxlist"].commands=[]
  446.     }
  447.     Input.update
  448.     return ret
  449.   end
  450.  
  451.   def pbCanAddForModeList?(mode,nationalSpecies)
  452.     case mode
  453.     when 0
  454.       return true
  455.     when 1
  456.       return $Trainer.seen[nationalSpecies]
  457.     when 2, 3, 4, 5
  458.       return $Trainer.owned[nationalSpecies]
  459.     end
  460.   end
  461.  
  462.   def pbCanAddForModeSearch?(mode,nationalSpecies)
  463.     case mode
  464.     when 0, 1
  465.       return $Trainer.seen[nationalSpecies]
  466.     when 2, 3, 4, 5
  467.       return $Trainer.owned[nationalSpecies]
  468.     end
  469.   end
  470.  
  471.   def pbGetDexList()
  472.     dexlist=[]
  473.     dexdata=pbOpenDexData
  474.     region=pbGetPokedexRegion()
  475.     regionalSpecies=pbAllRegionalSpecies(region)
  476.     if regionalSpecies.length==1
  477.       # If no regional species defined, use National Pokédex order
  478.       for i in 1..PBSpecies.maxValue
  479.         regionalSpecies.push(i)
  480.       end
  481.     end
  482.     for i in 1...regionalSpecies.length
  483.       nationalSpecies=regionalSpecies[i]
  484.       if pbCanAddForModeList?($PokemonGlobal.pokedexMode,nationalSpecies)
  485.         pbDexDataOffset(dexdata,nationalSpecies,33)
  486.         height=dexdata.fgetw
  487.         weight=dexdata.fgetw
  488.         # Pushing national species, name, height, weight, index number
  489.         shift=DEXINDEXOFFSETS.include?(region)
  490.         dexlist.push([nationalSpecies,
  491.            PBSpecies.getName(nationalSpecies),height,weight,i,shift])
  492.       end
  493.     end
  494.     dexdata.close
  495.     return dexlist
  496.   end
  497.  
  498.   def pbRefreshDexList(index=0)
  499.     dexlist=pbGetDexList()
  500.     case $PokemonGlobal.pokedexMode
  501.     when 0 # Numerical mode
  502.       # Remove species not seen from the list
  503.       i=0; loop do break unless i<dexlist.length
  504.         break if $Trainer.seen[dexlist[i][0]]
  505.         dexlist[i]=nil
  506.         i+=1
  507.       end
  508.       i=dexlist.length-1; loop do break unless i>=0
  509.         break if !dexlist[i] || $Trainer.seen[dexlist[i][0]]
  510.         dexlist[i]=nil
  511.         i-=1
  512.       end
  513.       dexlist.compact!
  514.       # Sort species in ascending order by index number, not national species
  515.       dexlist.sort!{|a,b| a[4]<=>b[4]}
  516.     when 1 # Alphabetical mode
  517.       dexlist.sort!{|a,b| a[1]==b[1] ? a[4]<=>b[4] : a[1]<=>b[1]}
  518.     when 2 # Heaviest mode
  519.       dexlist.sort!{|a,b| a[3]==b[3] ? a[4]<=>b[4] : b[3]<=>a[3]}
  520.     when 3 # Lightest mode
  521.       dexlist.sort!{|a,b| a[3]==b[3] ? a[4]<=>b[4] : a[3]<=>b[3]}
  522.     when 4 # Tallest mode
  523.       dexlist.sort!{|a,b| a[2]==b[2] ? a[4]<=>b[4] : b[2]<=>a[2]}
  524.     when 5 # Smallest mode
  525.       dexlist.sort!{|a,b| a[2]==b[2] ? a[4]<=>b[4] : a[2]<=>b[2]}
  526.     end
  527.     dexname=_INTL("Pokédex")
  528.     if $PokemonGlobal.pokedexUnlocked.length>1
  529.       thisdex=pbDexNames[pbGetSavePositionIndex]
  530.       if thisdex!=nil
  531.         if thisdex.is_a?(Array)
  532.           dexname=thisdex[0]
  533.         else
  534.           dexname=thisdex
  535.         end
  536.       end
  537.     end
  538.     if !@searchResults
  539.       @sprites["seen"].text=_ISPRINTF("Seen:<r>{1:d}",$Trainer.pokedexSeen(pbGetPokedexRegion))
  540.       @sprites["owned"].text=_ISPRINTF("Owned:<r>{1:d}",$Trainer.pokedexOwned(pbGetPokedexRegion))
  541.       @sprites["dexname"].text=_ISPRINTF("<ac>{1:s}</ac>",dexname)
  542.     else
  543.       seenno=0
  544.       ownedno=0
  545.       for i in dexlist
  546.         seenno+=1 if $Trainer.seen[i[0]]
  547.         ownedno+=1 if $Trainer.owned[i[0]]
  548.       end
  549.       @sprites["seen"].text=_ISPRINTF("Seen:<r>{1:d}",seenno)
  550.       @sprites["owned"].text=_ISPRINTF("Owned:<r>{1:d}",ownedno)
  551.       @sprites["dexname"].text=_ISPRINTF("<ac>{1:s} - Search results</ac>",dexname)
  552.     end
  553.     @dexlist=dexlist
  554.     @sprites["pokedex"].commands=@dexlist
  555.     @sprites["pokedex"].index=index
  556.     @sprites["pokedex"].refresh
  557.     # Draw the slider
  558.     ycoord=62
  559.     if @sprites["pokedex"].itemCount>1
  560.       ycoord+=188.0 * @sprites["pokedex"].index/(@sprites["pokedex"].itemCount-1)
  561.     end
  562.     @sprites["slider"].y=ycoord
  563.     iconspecies=@sprites["pokedex"].species
  564.     iconspecies=0 if !$Trainer.seen[iconspecies]
  565.     setIconBitmap(iconspecies)
  566.     if iconspecies>0
  567.       @sprites["species"].text=_ISPRINTF("<ac>{1:s}</ac>",PBSpecies.getName(iconspecies))
  568.     else
  569.       @sprites["species"].text=""
  570.     end
  571.   end
  572.  
  573.   def pbSearchDexList(params)
  574.     $PokemonGlobal.pokedexMode=params[4]
  575.     dexlist=pbGetDexList()
  576.     dexdata=pbOpenDexData()
  577.     if params[0]!=0 # Filter by name
  578.       nameCommands=[
  579.          "",_INTL("ABC"),_INTL("DEF"),_INTL("GHI"),
  580.          _INTL("JKL"),_INTL("MNO"),_INTL("PQR"),
  581.          _INTL("STU"),_INTL("VWX"),_INTL("YZ")
  582.       ]
  583.       scanNameCommand=nameCommands[params[0]].scan(/./)
  584.       dexlist=dexlist.find_all {|item|
  585.          next false if !$Trainer.seen[item[0]]
  586.          firstChar=item[1][0,1]
  587.          next scanNameCommand.any? { |v|  v==firstChar }
  588.       }
  589.     end
  590.     if params[1]!=0 # Filter by color
  591.       dexlist=dexlist.find_all {|item|
  592.          next false if !$Trainer.seen[item[0]]
  593.          pbDexDataOffset(dexdata,item[0],6)
  594.          color=dexdata.fgetb
  595.          next color==params[1]-1
  596.       }
  597.     end
  598.     if params[2]!=0 || params[3]!=0 # Filter by type
  599.       typeCommands=[-1]
  600.       for i in 0..PBTypes.maxValue
  601.         if !PBTypes.isPseudoType?(i)
  602.           typeCommands.push(i) # Add type
  603.         end
  604.       end
  605.       stype1=typeCommands[params[2]]
  606.       stype2=typeCommands[params[3]]
  607.       dexlist=dexlist.find_all {|item|
  608.          next false if !$Trainer.owned[item[0]]
  609.          pbDexDataOffset(dexdata,item[0],8)
  610.          type1=dexdata.fgetb
  611.          type2=dexdata.fgetb
  612.          if stype1>=0 && stype2>=0
  613.            # Find species that match both types
  614.            next (stype1==type1 && stype2==type2) || (stype1==type2 && stype2==type1)
  615.          elsif stype1>=0
  616.            # Find species that match first type entered
  617.            next type1==stype1 || type2==stype1
  618.          else
  619.            # Find species that match second type entered
  620.            next type1==stype2 || type2==stype2
  621.          end
  622.       }
  623.     end
  624.     dexdata.close
  625.     dexlist=dexlist.find_all {|item| # Remove all unseen species from the results
  626.        next ($Trainer.seen[item[0]])
  627.     }
  628.     case params[4]
  629.     when 0 # Numerical mode
  630.       # Sort by index number, not national number
  631.       dexlist.sort!{|a,b| a[4]<=>b[4]}
  632.     when 1 # Alphabetical mode
  633.       dexlist.sort!{|a,b| a[1]<=>b[1]}
  634.     when 2 # Heaviest mode
  635.       dexlist.sort!{|a,b| b[3]<=>a[3]}
  636.     when 3 # Lightest mode
  637.       dexlist.sort!{|a,b| a[3]<=>b[3]}
  638.     when 4 # Tallest mode
  639.       dexlist.sort!{|a,b| b[2]<=>a[2]}
  640.     when 5 # Smallest mode
  641.       dexlist.sort!{|a,b| a[2]<=>b[2]}
  642.     end
  643.     return dexlist
  644.   end
  645.  
  646.   def pbRefreshDexSearch(params)
  647.     searchlist=@sprites["searchlist"]
  648.     messagebox=@sprites["messagebox"]
  649.     searchlist.commands=[
  650.        _INTL("Search"),[
  651.           _ISPRINTF("Name: {1:s}",@nameCommands[params[0]]),
  652.           _ISPRINTF("Color: {1:s}",@colorCommands[params[1]]),
  653.           _ISPRINTF("Type 1: {1:s}",@typeCommands[params[2]]),
  654.           _ISPRINTF("Type 2: {1:s}",@typeCommands[params[3]]),
  655.           _ISPRINTF("Order: {1:s}",@orderCommands[params[4]]),
  656.           _INTL("Start Search")
  657.        ],
  658.        _INTL("Sort"),[
  659.           _ISPRINTF("Order: {1:s}",@orderCommands[params[5]]),
  660.           _INTL("Start Sort")
  661.        ]
  662.     ]
  663.     helptexts=[
  664.        _INTL("Search for Pokémon based on selected parameters."),[
  665.           _INTL("List by the first letter in the name.\r\nSpotted Pokémon only."),
  666.           _INTL("List by body color.\r\nSpotted Pokémon only."),
  667.           _INTL("List by type.\r\nOwned Pokémon only."),
  668.           _INTL("List by type.\r\nOwned Pokémon only."),
  669.           _INTL("Select the Pokédex listing mode."),
  670.           _INTL("Execute search."),
  671.        ],
  672.        _INTL("Switch Pokédex listings."),[
  673.           _INTL("Select the Pokédex listing mode."),
  674.           _INTL("Execute sort."),
  675.        ]
  676.     ]
  677.     messagebox.text=searchlist.getText(helptexts,searchlist.index)
  678.   end
  679.  
  680.   def pbChangeToDexEntry(species)
  681.     @sprites["entryicon"].visible=true
  682.     @sprites["dexentry"].visible=true
  683.     @sprites["overlay"].visible=true
  684.     @sprites["overlay"].bitmap.clear
  685.     basecolor=Color.new(88,88,80)
  686.     shadowcolor=Color.new(168,184,184)
  687.     indexNumber=pbGetRegionalNumber(pbGetPokedexRegion(),species)
  688.     indexNumber=species if indexNumber==0
  689.     indexNumber-=1 if DEXINDEXOFFSETS.include?(pbGetPokedexRegion)
  690.     gender=($Trainer.formlastseen[species][0] rescue 0)
  691.     form=($Trainer.formlastseen[species][1] rescue 0)
  692.     @dummypokemon.species=species
  693.     @dummypokemon.setGender(gender)
  694.     @dummypokemon.forceForm(form)
  695.     @sprites["dexbg"].setBitmap(_INTL("Graphics/Pictures/Habitat/{1}",HABITAT_2_PIC[@dummypokemon.habitat]))
  696.     @sprites["dexbg"].visible=true
  697.     textpos=[
  698.        [_ISPRINTF("{1:03d}{2:s} {3:s}",indexNumber," ",PBSpecies.getName(species)),
  699.           244,40,0,Color.new(248,248,248),Color.new(0,0,0)],
  700.        [sprintf(_INTL("HT")),318,158,0,basecolor,shadowcolor],
  701.        [sprintf(_INTL("WT")),318,190,0,basecolor,shadowcolor]
  702.     ]
  703.     if $Trainer.owned[species]
  704.       type1=@dummypokemon.type1
  705.       type2=@dummypokemon.type2
  706.       height=@dummypokemon.height
  707.       weight=@dummypokemon.weight
  708.       kind=@dummypokemon.kind
  709.       dexentry=@dummypokemon.dexEntry
  710.       inches=(height/0.254).round
  711.       pounds=(weight/0.45359).round
  712.       #formEntry = MultipleForms.call("dexEntry",form)
  713.       #if formEntry!=nil
  714.       #  dexentry = formEntry
  715.       #end
  716.       if (@dummypokemon.species==PBSpecies::SYMBIONT) || (@dummypokemon.species==PBSpecies::ABSORPTION) || (@dummypokemon.species==PBSpecies::BEAUTY) || (@dummypokemon.species==PBSpecies::LIGHTNING) || (@dummypokemon.species==PBSpecies::BLASTER) || (@dummypokemon.species==PBSpecies::BLADE) || (@dummypokemon.species==PBSpecies::GLUTTON) ||  (@dummypokemon.species==PBSpecies::ADHESIVE) || (@dummypokemon.species==PBSpecies::STINGER) || (@dummypokemon.species==PBSpecies::ASSEMBLY) || (@dummypokemon.species==PBSpecies::BURST) || (@dummypokemon.species==PBSpecies::MOTHER)
  717.         textpos.push([_ISPRINTF("{1:s} Ultra Beast",kind),244,74,0,basecolor,shadowcolor])
  718.       else
  719.         textpos.push([_ISPRINTF("{1:s} Pokémon",kind),244,74,0,basecolor,shadowcolor])
  720.       end
  721.       if pbGetCountry()==0xF4 # If the user is in the United States
  722.         textpos.push([_ISPRINTF("{1:d}'{2:02d}\"",inches/12,inches%12),456,158,1,basecolor,shadowcolor])
  723.         textpos.push([_ISPRINTF("{1:4.1f} lbs.",pounds/10.0),490,190,1,basecolor,shadowcolor])
  724.       else
  725.         textpos.push([_ISPRINTF("{1:.1f} m",height/10.0),466,158,1,basecolor,shadowcolor])
  726.         textpos.push([_ISPRINTF("{1:.1f} kg",weight/10.0),478,190,1,basecolor,shadowcolor])
  727.       end
  728.       drawTextEx(@sprites["overlay"].bitmap,
  729.          42,240,Graphics.width-(42*2),4,dexentry,basecolor,shadowcolor)
  730.       footprintfile=pbPokemonFootprintFile(@dummypokemon)
  731.       if footprintfile
  732.         footprint=BitmapCache.load_bitmap(footprintfile)
  733.         @sprites["overlay"].bitmap.blt(226,136,footprint,footprint.rect)
  734.         footprint.dispose
  735.       end
  736.       dexdata=pbOpenDexData
  737.       pbDexDataOffset(dexdata,species,31)
  738.       compat10=dexdata.fgetb
  739.       compat11=dexdata.fgetb
  740.       eggGroupbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/typesEgg"))
  741.       eggGroup1rect=Rect.new(0,compat10*28,64,28)
  742.       eggGroup2rect=Rect.new(0,compat11*28,64,28)
  743.       if compat10==compat11
  744.         @sprites["overlay"].bitmap.blt(210,194,eggGroupbitmap.bitmap,eggGroup1rect)
  745.       else
  746.         @sprites["overlay"].bitmap.blt(210,186,eggGroupbitmap.bitmap,eggGroup1rect)
  747.         @sprites["overlay"].bitmap.blt(210,214,eggGroupbitmap.bitmap,eggGroup2rect)
  748.       end
  749.       dexdata.close
  750.       pbDrawImagePositions(@sprites["overlay"].bitmap,[["Graphics/Pictures/pokedexOwned",212,42,0,0,-1,-1]])
  751.       typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/pokedexTypes"))
  752.       type1rect=Rect.new(0,type1*32,96,32)
  753.       type2rect=Rect.new(0,type2*32,96,32)
  754.       @sprites["overlay"].bitmap.blt(296,118,typebitmap.bitmap,type1rect)
  755.       @sprites["overlay"].bitmap.blt(396,118,typebitmap.bitmap,type2rect) if type1!=type2
  756.       typebitmap.dispose
  757.     else
  758.       textpos.push([_INTL("????? Pokémon"),244,74,0,basecolor,shadowcolor])
  759.       if pbGetCountry()==0xF4 # If the user is in the United States
  760.         textpos.push([_INTL("???'??\""),456,158,1,basecolor,shadowcolor])
  761.         textpos.push([_INTL("????.? lbs."),490,190,1,basecolor,shadowcolor])
  762.       else
  763.         textpos.push([_INTL("????.? m"),466,158,1,basecolor,shadowcolor])
  764.         textpos.push([_INTL("????.? kg"),478,190,1,basecolor,shadowcolor])
  765.       end
  766.     end
  767.     pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
  768.     @sprites["entryicon"].setSpeciesBitmap(species,(gender==1),form)
  769.     pbPositionPokemonSprite(@sprites["entryicon"],40,70)
  770.     pbPlayCry(@dummypokemon)
  771.   end
  772.  
  773.   def pbStartDexEntryScene(species)     # Used only when capturing a new species
  774.     @dummypokemon=PokeBattle_Pokemon.new(species,1)
  775.     @dummypokemon.makeNotShiny
  776.     @dummypokemon.makeNotDelta
  777.     @sprites={}
  778.     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  779.     @viewport.z=99999
  780.     @sprites["dexbg"]=IconSprite.new(0,0,@viewport)
  781.     @sprites["dexbg"].setBitmap(_INTL("Graphics/Pictures/Habitat/{1}",HABITAT_2_PIC[@dummypokemon.habitat]))
  782.     @sprites["dexbg"].visible=false
  783.     @sprites["dexentry"]=IconSprite.new(0,0,@viewport)
  784.     @sprites["dexentry"].setBitmap(_INTL("Graphics/Pictures/pokedexentry"))
  785.     @sprites["dexentry"].visible=false
  786.     @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
  787.     pbSetSystemFont(@sprites["overlay"].bitmap)
  788.     @sprites["overlay"].x=0
  789.     @sprites["overlay"].y=0
  790.     @sprites["overlay"].visible=false
  791.     @sprites["entryicon"]=PokemonSprite.new(@viewport)
  792.     pbChangeToDexEntry(species)
  793.     pbDrawImagePositions(@sprites["overlay"].bitmap,[["Graphics/Pictures/pokedexBlank",0,0,0,0,-1,-1]])
  794.     pbFadeInAndShow(@sprites)
  795.   end
  796.  
  797.   def pbMiddleDexEntryScene             # Used only when capturing a new species
  798.     pbActivateWindow(@sprites,nil){
  799.        loop do
  800.          Graphics.update
  801.          Input.update
  802.          pbUpdate
  803.          if Input.trigger?(Input::B) || Input.trigger?(Input::C)
  804.            break
  805.          end
  806.        end
  807.     }
  808.   end
  809.  
  810.   def pbDexEntry(index)
  811.     oldsprites=pbFadeOutAndHide(@sprites)
  812.     pbChangeToDexEntry(@dexlist[index][0])
  813.     pbFadeInAndShow(@sprites)
  814.     curindex=index
  815.     page=1
  816.     newpage=0
  817.     ret=0
  818.     pbActivateWindow(@sprites,nil){
  819.        loop do
  820.          Graphics.update if page==1
  821.          Input.update
  822.          pbUpdate
  823.          if Input.trigger?(Input::B) || ret==1
  824.            if page==1
  825.              pbPlayCancelSE()
  826.              pbFadeOutAndHide(@sprites)
  827.            end
  828.            @sprites["entryicon"].clearBitmap
  829.            break
  830.          elsif Input.trigger?(Input::UP) || ret==8
  831.            nextindex=-1
  832.            i=curindex-1; loop do break unless i>=0
  833.              if $Trainer.seen[@dexlist[i][0]]
  834.                nextindex=i
  835.                break
  836.              end
  837.              i-=1
  838.            end
  839.            if nextindex>=0
  840.              curindex=nextindex
  841.              newpage=page
  842.            end
  843.            pbPlayCursorSE() if newpage>1
  844.          elsif Input.trigger?(Input::DOWN) || ret==2
  845.            nextindex=-1
  846.            for i in curindex+1...@dexlist.length
  847.              if $Trainer.seen[@dexlist[i][0]]
  848.                nextindex=i
  849.                break
  850.              end
  851.            end
  852.            if nextindex>=0
  853.              curindex=nextindex
  854.              newpage=page
  855.            end
  856.            pbPlayCursorSE() if newpage>1
  857.          elsif Input.trigger?(Input::LEFT) || ret==4
  858.            newpage=page-1 if page>1
  859.            pbPlayCursorSE() if newpage>1
  860.          elsif Input.trigger?(Input::RIGHT) || ret==6
  861.            newpage=page+1 if page<3
  862.            pbPlayCursorSE() if newpage>1
  863.          elsif Input.trigger?(Input::A)
  864.            pbPlayCry(@dexlist[curindex][0])
  865.          end
  866.          ret=0
  867.          if newpage>0
  868.            page=newpage
  869.            newpage=0
  870.            listlimits=0
  871.            listlimits+=1 if curindex==0                 # At top of list
  872.            listlimits+=2 if curindex==@dexlist.length-1 # At bottom of list
  873.            case page
  874.            when 1 # Show entry
  875.              pbChangeToDexEntry(@dexlist[curindex][0])
  876.            when 2 # Show nest
  877.              region=-1
  878.              if !DEXDEPENDSONLOCATION
  879.                dexnames=pbDexNames
  880.                if dexnames[pbGetSavePositionIndex].is_a?(Array)
  881.                  region=dexnames[pbGetSavePositionIndex][1]
  882.                end
  883.              end
  884.              scene=PokemonNestMapScene.new
  885.              screen=PokemonNestMap.new(scene)
  886.              ret=screen.pbStartScreen(@dexlist[curindex][0],region,listlimits)
  887.            when 3 # Show forms
  888.              scene=PokedexFormScene.new
  889.              screen=PokedexForm.new(scene)
  890.              ret=screen.pbStartScreen(@dexlist[curindex][0],listlimits)
  891.            end
  892.          end
  893.        end
  894.     }
  895.     $PokemonGlobal.pokedexIndex[pbGetSavePositionIndex]=curindex if !@searchResults
  896.     @sprites["pokedex"].index=curindex
  897.     @sprites["pokedex"].refresh
  898.     iconspecies=@sprites["pokedex"].species
  899.     iconspecies=0 if !$Trainer.seen[iconspecies]
  900.     setIconBitmap(iconspecies)
  901.     if iconspecies>0
  902.       @sprites["species"].text=_ISPRINTF("<ac>{1:s}</ac>",PBSpecies.getName(iconspecies))
  903.     else
  904.       @sprites["species"].text=""
  905.     end
  906.     # Update the slider
  907.     ycoord=62
  908.     if @sprites["pokedex"].itemCount>1
  909.       ycoord+=188.0 * @sprites["pokedex"].index/(@sprites["pokedex"].itemCount-1)
  910.     end
  911.     @sprites["slider"].y=ycoord
  912.     pbFadeInAndShow(@sprites,oldsprites)
  913.   end
  914.  
  915.   def pbDexSearch
  916.     oldsprites=pbFadeOutAndHide(@sprites)
  917.     params=[]
  918.     params[0]=0
  919.     params[1]=0
  920.     params[2]=0
  921.     params[3]=0
  922.     params[4]=0
  923.     params[5]=$PokemonGlobal.pokedexMode
  924.     @nameCommands=[
  925.        _INTL("Don't specify"),
  926.        _INTL("ABC"),_INTL("DEF"),_INTL("GHI"),
  927.        _INTL("JKL"),_INTL("MNO"),_INTL("PQR"),
  928.        _INTL("STU"),_INTL("VWX"),_INTL("YZ")
  929.     ]
  930.     @typeCommands=[
  931.        _INTL("None"),
  932.        _INTL("Normal"),_INTL("Fighting"),_INTL("Flying"),
  933.        _INTL("Poison"),_INTL("Ground"),_INTL("Rock"),
  934.        _INTL("Bug"),_INTL("Ghost"),_INTL("Steel"),
  935.        _INTL("Fire"),_INTL("Water"),_INTL("Grass"),
  936.        _INTL("Electric"),_INTL("Psychic"),_INTL("Ice"),
  937.        _INTL("Dragon"),_INTL("Dark"),_INTL("Fairy")
  938.     ]
  939.     @colorCommands=[_INTL("Don't specify")]
  940.     for i in 0..PBColors.maxValue
  941.       j=PBColors.getName(i)
  942.       @colorCommands.push(j) if j
  943.     end
  944. #    @colorCommands=[
  945. #       _INTL("Don't specify"),
  946. #       _INTL("Red"),_INTL("Blue"),_INTL("Yellow"),
  947. #       _INTL("Green"),_INTL("Black"),_INTL("Brown"),
  948. #       _INTL("Purple"),_INTL("Gray"),_INTL("White"),_INTL("Pink")
  949. #    ]
  950.     @orderCommands=[
  951.        _INTL("Numeric Mode"),
  952.        _INTL("A to Z Mode"),
  953.        _INTL("Heaviest Mode"),
  954.        _INTL("Lightest Mode"),
  955.        _INTL("Tallest Mode"),
  956.        _INTL("Smallest Mode")
  957.     ]
  958.     @orderHelp=[
  959.        _INTL("Pokémon are listed according to their number."),
  960.        _INTL("Spotted and owned Pokémon are listed alphabetically."),
  961.        _INTL("Owned Pokémon are listed from heaviest to lightest."),
  962.        _INTL("Owned Pokémon are listed from lightest to heaviest."),
  963.        _INTL("Owned Pokémon are listed from tallest to smallest."),
  964.        _INTL("Owned Pokémon are listed from smallest to tallest.")
  965.     ]
  966.     @sprites["searchlist"].index=1
  967.     searchlist=@sprites["searchlist"]
  968.     @sprites["messagebox"].visible=true
  969.     @sprites["auxlist"].visible=true
  970.     @sprites["searchlist"].visible=true
  971.     @sprites["searchbg"].visible=true
  972.     @sprites["searchtitle"].visible=true
  973.     pbRefreshDexSearch(params)
  974.     pbFadeInAndShow(@sprites)
  975.     pbActivateWindow(@sprites,"searchlist"){
  976.        loop do
  977.          Graphics.update
  978.          Input.update
  979.          oldindex=searchlist.index
  980.          pbUpdate
  981.          if searchlist.index==0
  982.            if oldindex==9 && Input.trigger?(Input::DOWN)
  983.              searchlist.index=1
  984.            elsif oldindex==1 && Input.trigger?(Input::UP)
  985.              searchlist.index=9
  986.            else
  987.              searchlist.index=1
  988.            end
  989.          elsif searchlist.index==7
  990.            if oldindex==8
  991.              searchlist.index=6
  992.            else
  993.              searchlist.index=8
  994.            end
  995.          end
  996.          if searchlist.index!=oldindex
  997.            pbRefreshDexSearch(params)
  998.          end
  999.          if Input.trigger?(Input::C)
  1000.            pbPlayDecisionSE()
  1001.            command=searchlist.indexToCommand(searchlist.index)
  1002.            if command==[2,0]
  1003.              break
  1004.            end
  1005.            if command==[0,0]
  1006.              params[0]=pbDexSearchCommands(@nameCommands,params[0])
  1007.              pbRefreshDexSearch(params)
  1008.            elsif command==[0,1]
  1009.              params[1]=pbDexSearchCommands(@colorCommands,params[1])
  1010.              pbRefreshDexSearch(params)
  1011.            elsif command==[0,2]
  1012.              params[2]=pbDexSearchCommands(@typeCommands,params[2])
  1013.              pbRefreshDexSearch(params)
  1014.            elsif command==[0,3]
  1015.              params[3]=pbDexSearchCommands(@typeCommands,params[3])
  1016.              pbRefreshDexSearch(params)
  1017.            elsif command==[0,4]
  1018.              params[4]=pbDexSearchCommands(@orderCommands,params[4],@orderHelp)
  1019.              pbRefreshDexSearch(params)
  1020.            elsif command==[0,5]
  1021.              dexlist=pbSearchDexList(params)
  1022.              if dexlist.length==0
  1023.                Kernel.pbMessage(_INTL("No matching Pokémon were found."))
  1024.              else
  1025.                @dexlist=dexlist
  1026.                @sprites["pokedex"].commands=@dexlist
  1027.                @sprites["pokedex"].index=0
  1028.                @sprites["pokedex"].refresh
  1029.                iconspecies=@sprites["pokedex"].species
  1030.                iconspecies=0 if !$Trainer.seen[iconspecies]
  1031.                setIconBitmap(iconspecies)
  1032.                if iconspecies>0
  1033.                  @sprites["species"].text=_ISPRINTF("<ac>{1:s}</ac>",PBSpecies.getName(iconspecies))
  1034.                else
  1035.                  @sprites["species"].text=""
  1036.                end
  1037.                seenno=0
  1038.                ownedno=0
  1039.                for i in dexlist
  1040.                  seenno+=1 if $Trainer.seen[i[0]]
  1041.                  ownedno+=1 if $Trainer.owned[i[0]]
  1042.                end
  1043.                @sprites["seen"].text=_ISPRINTF("Seen:<r>{1:d}",seenno)
  1044.                @sprites["owned"].text=_ISPRINTF("Owned:<r>{1:d}",ownedno)
  1045.                dexname=_INTL("Pokédex")
  1046.                if $PokemonGlobal.pokedexUnlocked.length>1
  1047.                  thisdex=pbDexNames[pbGetSavePositionIndex]
  1048.                  if thisdex!=nil
  1049.                    if thisdex.is_a?(Array)
  1050.                      dexname=thisdex[0]
  1051.                    else
  1052.                      dexname=thisdex
  1053.                    end
  1054.                  end
  1055.                end
  1056.                @sprites["dexname"].text=_ISPRINTF("<ac>{1:s} - Search results</ac>",dexname)
  1057.                # Update the slider
  1058.                ycoord=62
  1059.                if @sprites["pokedex"].itemCount>1
  1060.                  ycoord+=188.0 * @sprites["pokedex"].index/(@sprites["pokedex"].itemCount-1)
  1061.                end
  1062.                @sprites["slider"].y=ycoord
  1063.                @searchResults=true
  1064.                break
  1065.              end
  1066.            elsif command==[1,0]
  1067.              params[5]=pbDexSearchCommands(@orderCommands,params[5],@orderHelp)
  1068.              pbRefreshDexSearch(params)
  1069.            elsif command==[1,1]
  1070.              $PokemonGlobal.pokedexMode=params[5]
  1071.              $PokemonGlobal.pokedexIndex[pbGetSavePositionIndex]=0
  1072.              pbRefreshDexList
  1073.              break
  1074.            end
  1075.          elsif Input.trigger?(Input::B)
  1076.            pbPlayCancelSE()
  1077.            break
  1078.          end
  1079.        end
  1080.     }
  1081.     pbFadeOutAndHide(@sprites)
  1082.     pbFadeInAndShow(@sprites,oldsprites)
  1083.     Input.update
  1084.     return 0
  1085.   end
  1086.  
  1087.   def pbCloseSearch
  1088.     oldsprites=pbFadeOutAndHide(@sprites)
  1089.     @searchResults=false
  1090.     $PokemonGlobal.pokedexMode=0
  1091.     pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex])
  1092.     pbFadeInAndShow(@sprites,oldsprites)
  1093.   end
  1094.  
  1095.   def pbPokedex
  1096.     pbActivateWindow(@sprites,"pokedex"){
  1097.        loop do
  1098.          Graphics.update
  1099.          Input.update
  1100.          oldindex=@sprites["pokedex"].index
  1101.          pbUpdate
  1102.          if oldindex!=@sprites["pokedex"].index
  1103.            $PokemonGlobal.pokedexIndex[pbGetSavePositionIndex]=@sprites["pokedex"].index if !@searchResults
  1104.            iconspecies=@sprites["pokedex"].species
  1105.            iconspecies=0 if !$Trainer.seen[iconspecies]
  1106.            setIconBitmap(iconspecies)
  1107.            if iconspecies>0
  1108.              @sprites["species"].text=_ISPRINTF("<ac>{1:s}</ac>",PBSpecies.getName(iconspecies))
  1109.            else
  1110.              @sprites["species"].text=""
  1111.            end
  1112.            # Update the slider
  1113.            ycoord=62
  1114.            if @sprites["pokedex"].itemCount>1
  1115.              ycoord+=188.0 * @sprites["pokedex"].index/(@sprites["pokedex"].itemCount-1)
  1116.            end
  1117.            @sprites["slider"].y=ycoord
  1118.          end
  1119.          if Input.trigger?(Input::B)
  1120.            pbPlayCancelSE()
  1121.            if @searchResults
  1122.              pbCloseSearch
  1123.            else
  1124.              break
  1125.            end
  1126.          elsif Input.trigger?(Input::C)
  1127.            if $Trainer.seen[@sprites["pokedex"].species]
  1128.              pbPlayDecisionSE()
  1129.              pbDexEntry(@sprites["pokedex"].index)
  1130.            end
  1131.          elsif Input.trigger?(Input::F5)
  1132.            pbPlayDecisionSE()
  1133.            pbDexSearch
  1134.          end
  1135.        end
  1136.     }
  1137.   end
  1138.  
  1139.   def pbEndScene
  1140.     pbFadeOutAndHide(@sprites)
  1141.     pbDisposeSpriteHash(@sprites)
  1142.     pbSEPlay("PokedexClose")
  1143.     @viewport.dispose
  1144.   end
  1145. end
  1146.  
  1147.  
  1148.  
  1149. class PokemonPokedex
  1150.   def initialize(scene)
  1151.     pbSEPlay("PokedexOpen")
  1152.     @scene=scene
  1153.   end
  1154.  
  1155.   def pbDexEntry(species)
  1156.     @scene.pbStartDexEntryScene(species)
  1157.     @scene.pbMiddleDexEntryScene
  1158.     @scene.pbEndScene
  1159.   end
  1160.  
  1161.   def pbStartScreen
  1162.     @scene.pbStartScene
  1163.     @scene.pbPokedex
  1164.     @scene.pbEndScene
  1165.   end
  1166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement