class PokemonMenu_Scene
ANIM_SPEED=8
def pbShowCommands(commands)
pbDrawPanels(commands)
ret=-1
oldcommand=0
loop do
pbDrawOverlay
pbUpdateCursor(commands)
Graphics.update
Input.update
pbUpdateSceneMap
if Input.trigger?(Input::B)
ret=-1
break
end
if Input.trigger?(Input::RIGHT)
if @index%2==0 && @index<commands.length
@index+=1
elsif @index<commands.length
oldcommand=@index
@index=commands.length
end
elsif Input.trigger?(Input::LEFT)
if @index==commands.length
@index=oldcommand
elsif @index%2==0 || @index==commands.length-1
oldcommand=@index
@index=commands.length
else
@index-=1
end
elsif Input.trigger?(Input::DOWN)
if @index==commands.length-2
@index=commands.length-1
elsif @index<commands.length-2
@index+=2
end
elsif Input.trigger?(Input::UP)
if @index>commands.length-2
@index=commands.length-2
elsif @index>1
@index-=2
end
end
if Input.trigger?(Input::C)
ret=@index
ret=-1 if ret==commands.length
$PokemonTemp.menuLastChoice=ret
break
end
end
return ret
end
def pbUpdateCursor(commands)
if Input.press?(Input::C)
# @sprites["cursor"].src_rect.x=128
else
# cursorFrame=@frame/(ANIM_SPEED*2)
# @sprites["cursor"].src_rect.x=cursorFrame*80
end
if @index<commands.length-1
@sprites["cursor"].x=36+(@index%2)*158
@sprites["cursor"].y=42+(@index/2)*80
@sprites["cursor"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/MenuHGSScursor")
elsif @index==commands.length-1
@sprites["cursor"].x=36
@sprites["cursor"].y=282
@sprites["cursor"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/MenuHGSScursor")
else
@sprites["cursor"].x=0
@sprites["cursor"].y=0
@sprites["cursor"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/MenuHGSS_green Exit")
@sprites["cursor"].opacity=160
@sprites["cursor"].z=9999
end
end
def pbDrawPanels(commands)
@sprites["leftpanel"].opacity=210
leftPanel=@sprites["leftpanel"].bitmap
leftPanel.clear
leftPanel.blt(0,0,BitmapCache.load_bitmap("Graphics/Pictures/MenuHGSS_green.png"),Rect.new(0,0,324,376))
for i in 0...commands.length-1
if commands
!=""
leftPanel.blt(36+(i%2)*158,42+(i/2)*80,BitmapCache.load_bitmap("Graphics/Pictures/Hgss"+commands),Rect.new(0,0,80,52))
end
end
end
def pbDrawOverlay
if @frame%ANIM_SPEED==0
trainerFrame=@frame/ANIM_SPEED
pkmnFrame=trainerFrame%2
leftOverlay=@sprites["leftoverlay"].bitmap
leftOverlay.clear
rightOverlay=@sprites["rightoverlay"].bitmap
rightOverlay.clear
end
@frame+=1
@frame=0 if @frame>=(ANIM_SPEED*4)
end
def pbInitializePanels
@sprites["leftpanel"].x=-240
@sprites["leftpanel"].opacity=0
@sprites["rightpanel"].x=576
@sprites["rightpanel"].opacity=0
@sprites["leftoverlay"].x=-240
@sprites["leftoverlay"].opacity=0
@sprites["rightoverlay"].x=576
@sprites["rightoverlay"].opacity=0
end
def pbStartScene
@frame=0
@index=0
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites={}
@sprites["leftpanel"]=Sprite.new(@viewport)
@sprites["leftpanel"].bitmap=Bitmap.new(324,384)
@sprites["leftpanel"].opacity=210
@sprites["rightpanel"]=Sprite.new(@viewport)
@sprites["rightpanel"].bitmap=Bitmap.new(144,320)
@sprites["leftoverlay"]=Sprite.new(@viewport)
@sprites["leftoverlay"].bitmap=Bitmap.new(228,320)
@sprites["rightoverlay"]=Sprite.new(@viewport)
@sprites["rightoverlay"].bitmap=Bitmap.new(144,320)
@sprites["cursor"]=Sprite.new(@viewport)
@sprites["cursor"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/MenuHGSScursor")
@sprites["cursor"].visible=false
pbSEPlay("menu")
end
def pbHideMenu
@sprites["cursor"].visible=false
12.times do
Graphics.update
Input.update
pbDrawOverlay
@sprites["leftpanel"].x-=20
@sprites["leftpanel"].opacity-=22
@sprites["rightpanel"].x+=20
@sprites["rightpanel"].opacity-=22
@sprites["leftoverlay"].x-=20
@sprites["leftoverlay"].opacity-=22
@sprites["rightoverlay"].x+=20
@sprites["rightoverlay"].opacity-=22
end
@sprites["leftpanel"].visible=false
@sprites["rightpanel"].visible=false
@sprites["leftoverlay"].visible=false
@sprites["rightoverlay"].visible=false
end
def pbShowMenu
pbInitializePanels
@sprites["leftpanel"].visible=true
@sprites["rightpanel"].visible=true
@sprites["leftoverlay"].visible=true
@sprites["rightoverlay"].visible=true
12.times do
Graphics.update
Input.update
pbDrawOverlay
@sprites["leftpanel"].x+=20
@sprites["leftpanel"].opacity+=22
@sprites["rightpanel"].x-=20
@sprites["rightpanel"].opacity+=22
@sprites["leftoverlay"].x+=20
@sprites["leftoverlay"].opacity+=22
@sprites["rightoverlay"].x-=20
@sprites["rightoverlay"].opacity+=22
end
@sprites["cursor"].visible=true
end
def pbEndScene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
def pbRefresh
end
end
class PokemonMenu
def initialize(scene)
@scene=scene
end
def pbShowMenu
@scene.pbRefresh
@scene.pbShowMenu
end
def pbStartPokemonMenu
@scene.pbStartScene
endscene=true
commands=[]
cmdPokedex=-1
cmdPokemon=-1
cmdBag=-1
cmdTrainer=-1
cmdSave=-1
cmdOption=-1
cmdPokegear=-1
cmdDebug=-1
cmdQuit=-1
if !$Trainer
if $DEBUG
Kernel.pbMessage(_INTL("The player trainer was not defined, so the menu can't be displayed."))
Kernel.pbMessage(_INTL("Please see the documentation to learn how to set up the trainer player."))
end
return
end
commands[cmdPokedex=commands.length]="MenuPokedex" if $Trainer.pokedex
commands[cmdTrainer=commands.length]="MenuCard"
commands[cmdPokemon=commands.length]="MenuPokemon" if $Trainer.party.length>0
commands[cmdSave=commands.length]="MenuSave" if !$game_system || !$game_system.save_disabled
commands[cmdBag=commands.length]="MenuBag" if !pbInBugContest?
commands[cmdOption=commands.length]="MenuOption"
commands[cmdPokegear=commands.length]="MenuGear"
commands[cmdDebug=commands.length]="MenuOption" if $DEBUG
@scene.pbDrawPanels(commands)
@scene.pbShowMenu
loop do
[email protected](commands)
if cmdPokedex>=0 && command==cmdPokedex
pbFadeOutIn(99999) {
scene=PokemonPokedexScene.new
screen=PokemonPokedex.new(scene)
screen.pbStartScreen
@scene.pbRefresh
@scene.pbDrawPanels(commands)
}
elsif cmdPokegear>=0 && command==cmdPokegear
pbLoadRpgxpScene(Scene_Pokegear.new)
elsif cmdPokemon>=0 && command==cmdPokemon
sscene=PokemonScreen_Scene.new
sscreen=PokemonScreen.new(sscene,$Trainer.party)
hiddenmove=nil
pbFadeOutIn(99999) {
hiddenmove=sscreen.pbPokemonScreen
if hiddenmove
@scene.pbEndScene
else
@scene.pbRefresh
@scene.pbDrawPanels(commands)
end
}
if hiddenmove
Kernel.pbUseHiddenMove(hiddenmove[0],hiddenmove[1])
return
end
elsif cmdBag>=0 && command==cmdBag
item=0
scene=PokemonBag_Scene.new
screen=PokemonBagScreen.new(scene,$PokemonBag)
pbFadeOutIn(99999) {
item=screen.pbStartScreen
if item>0
@scene.pbEndScene
else
@scene.pbRefresh
@scene.pbDrawPanels(commands)
end
}
if item>0
Kernel.pbUseKeyItemInField(item)
return
end
elsif cmdTrainer>=0 && command==cmdTrainer
PBDebug.logonerr {
scene=PokemonTrainerCardScene.new
screen=PokemonTrainerCard.new(scene)
pbFadeOutIn(99999) {
screen.pbStartScreen
@scene.pbRefresh
@scene.pbDrawPanels(commands)
}
}
elsif cmdQuit>=0 && command==cmdQuit
@scene.pbHideMenu
elsif cmdSave>=0 && command==cmdSave
@scene.pbHideMenu
scene=PokemonSaveScene.new
screen=PokemonSave.new(scene)
if screen.pbSaveScreen
@scene.pbEndScene
endscene=false
break
else
pbShowMenu
end
elsif cmdDebug>=0 && command==cmdDebug
pbFadeOutIn(99999) {
pbDebugMenu
@scene.pbRefresh
@scene.pbDrawPanels(commands)
}
elsif cmdOption>=0 && command==cmdOption
scene=PokemonOptionScene.new
screen=PokemonOption.new(scene)
pbFadeOutIn(99999) {
screen.pbStartScreen
pbUpdateSceneMap
@scene.pbRefresh
@scene.pbDrawPanels(commands)
}
else
break
end
end
@scene.pbHideMenu if endscene
@scene.pbEndScene if endscene
end
end