Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Storage system mouse compatibility - By DaviRx // FDAVILOKA
- #-------------------------------------------------------------------------------
- # Mouse update to the Storage class to allow use
- # of the mouse in boxes.
- #
- # * Requires EasyMouseSystem from Luka S.J.
- # * Thanks to KleinStudios for the base idea of the script in his BW_pack.
- # (using arrays for the mouse check)
- #===============================================================================
- class PokemonStorageScene
- def pbSelectPartyInternal(party,depositing)
- selection=@selection
- pbPartySetArrow(@sprites["arrow"],selection)
- pbUpdateOverlay(selection,party)
- pbSetMosaic(selection)
- lastsel=1
- loop do
- Graphics.update
- Input.update
- key=-1
- key=Input::DOWN if Input.repeat?(Input::DOWN)
- key=Input::RIGHT if Input.repeat?(Input::RIGHT)
- key=Input::LEFT if Input.repeat?(Input::LEFT)
- key=Input::UP if Input.repeat?(Input::UP)
- if key>=0
- pbPlayCursorSE()
- newselection=pbPartyChangeSelection(key,selection)
- if newselection==-1
- return -1 if !depositing
- elsif newselection==-2
- selection=lastsel
- else
- selection=newselection
- end
- pbPartySetArrow(@sprites["arrow"],selection)
- lastsel=selection if selection>0
- pbUpdateOverlay(selection,party)
- pbSetMosaic(selection)
- end
- pbUpdateSpriteHash(@sprites)
- partyxval=[202,283,208,285,208,285]
- partyyval=[53,67,116,132,180,195]
- for i in 0...6
- if $mouse.inArea?(partyxval[i],partyyval[i],50,48)
- selection=i
- pbPartySetArrow(@sprites["arrow"],selection)
- selection=-1 if selection==-4||selection==-5
- pbUpdateOverlay(selection,party) if not @screen.pbHeldPokemon
- end
- end
- if Input.trigger?(Input::C) or $mouse.leftClick?
- if selection>=0 && selection<6
- @selection=selection
- return selection
- elsif selection==6 # Close Box
- @selection=selection
- return (depositing) ? -3 : -1
- end
- end
- if Input.trigger?(Input::B) or $mouse.rightClick?
- @selection=selection
- return -1
- end
- end
- end
- def pbSelectBoxInternal(party)
- selection=@selection
- pbSetArrow(@sprites["arrow"],selection)
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- xval=[190,190+(53*1),190+(53*2),190+(53*3),190+(53*4),190+(53*5),216,190+(53*1),190+(53*2),190+(53*3),190+(53*4),190+(53*5),216,190+(53*1),190+(53*2),190+(53*3),190+(53*4),190+(53*5),216,190+(53*1),190+(53*2),190+(53*3),190+(53*4),190+(53*5),216,190+(53*1),190+(53*2),190+(53*3),190+(53*4),190+(53*5)]
- yval=[66,66,66,66,66,66,66+(48*1),66+(48*1),66+(48*1),66+(48*1),66+(48*1),66+(48*1),66+(48*2),66+(48*2),66+(48*2),66+(48*2),66+(48*2),66+(48*2),66+(48*3),66+(48*3),66+(48*3),66+(48*3),66+(48*3),66+(48*3),66+(48*4),66+(48*4),66+(48*4),66+(48*4),66+(48*4),66+(48*4)]
- loop do
- Graphics.update
- Input.update
- key=-1
- key=Input::DOWN if Input.repeat?(Input::DOWN)
- key=Input::RIGHT if Input.repeat?(Input::RIGHT)
- key=Input::LEFT if Input.repeat?(Input::LEFT)
- key=Input::UP if Input.repeat?(Input::UP)
- for i in 0...30
- if $mouse.inArea?(xval[i],yval[i],50,48)
- selection=i
- pbSetArrow(@sprites["arrow"],selection)
- nextbox=-1
- selection=-1 if selection==-4||selection==-5
- pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
- end
- if $mouse.inArea?(230,18,232,46)#Box Number
- selection=-1
- pbSetArrow(@sprites["arrow"],selection)
- nextbox=-1
- selection=-1 if selection==-4||selection==-5
- pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
- end
- if $mouse.inArea?(186,320,168,46)#Party Button
- selection=-2
- pbSetArrow(@sprites["arrow"],selection)
- nextbox=-1
- selection=-1 if selection==-4||selection==-5
- pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
- end
- if $mouse.inArea?(385,320,126,46)#Close Button
- selection=-3
- pbSetArrow(@sprites["arrow"],selection)
- nextbox=-1
- selection=-1 if selection==-4||selection==-5
- pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
- end
- end
- if key>=0
- pbPlayCursorSE()
- selection=pbChangeSelection(key,selection)
- pbSetArrow(@sprites["arrow"],selection)
- nextbox=-1
- if selection==-4
- nextbox=(@storage.currentBox==0) ? @storage.maxBoxes-1 : @storage.currentBox-1
- pbSwitchBoxToLeft(nextbox)
- @storage.currentBox=nextbox
- selection=-1
- elsif selection==-5
- nextbox=(@storage.currentBox==@storage.maxBoxes-1) ? 0 : @storage.currentBox+1
- pbSwitchBoxToRight(nextbox)
- @storage.currentBox=nextbox
- selection=-1
- end
- selection=-1 if selection==-4 || selection==-5
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- end
- pbUpdateSpriteHash(@sprites)
- if Input.trigger?(Input::C) || $mouse.leftClick?
- if selection>=0
- @selection=selection
- return [@storage.currentBox,selection]
- elsif selection==-1 # Box name
- @selection=selection
- return [-4,-1]
- elsif selection==-2 # Party Pokémon
- @selection=selection
- return [-2,-1]
- elsif selection==-3 # Close Box
- @selection=selection
- return [-3,-1]
- end
- end
- if Input.trigger?(Input::B) || $mouse.rightClick?
- @selection=selection
- return nil
- end
- if Input.trigger?(Input::L) or $mouse.scroll_up?
- nextbox=(@storage.currentBox==0) ? @storage.maxBoxes-1 : @storage.currentBox-1
- pbSwitchBoxToLeft(nextbox)
- @storage.currentBox=nextbox
- end
- if Input.trigger?(Input::R) or $mouse.scroll_down?
- nextbox=(@storage.currentBox==@storage.maxBoxes-1) ? 0 : @storage.currentBox+1
- pbSwitchBoxToRight(nextbox)
- @storage.currentBox=nextbox
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement