Advertisement
FDAVILOKA

mousestoragesystem

Apr 12th, 2017
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.36 KB | None | 0 0
  1. #===============================================================================
  2. #  Storage system mouse compatibility - By DaviRx // FDAVILOKA
  3. #-------------------------------------------------------------------------------
  4. # Mouse update to the Storage class to allow use
  5. # of the mouse in boxes.
  6. #
  7. #     * Requires EasyMouseSystem from Luka S.J.
  8. #     * Thanks to KleinStudios for the base idea of the script in his BW_pack.
  9. #     (using arrays for the mouse check)
  10. #===============================================================================
  11. class PokemonStorageScene
  12.   def pbSelectPartyInternal(party,depositing)
  13.     selection=@selection
  14.     pbPartySetArrow(@sprites["arrow"],selection)
  15.     pbUpdateOverlay(selection,party)
  16.     pbSetMosaic(selection)
  17.     lastsel=1
  18.     loop do
  19.       Graphics.update
  20.       Input.update
  21.       key=-1
  22.       key=Input::DOWN if Input.repeat?(Input::DOWN)
  23.       key=Input::RIGHT if Input.repeat?(Input::RIGHT)
  24.       key=Input::LEFT if Input.repeat?(Input::LEFT)
  25.       key=Input::UP if Input.repeat?(Input::UP)
  26.       if key>=0
  27.         pbPlayCursorSE()
  28.         newselection=pbPartyChangeSelection(key,selection)
  29.         if newselection==-1
  30.           return -1 if !depositing
  31.         elsif newselection==-2
  32.           selection=lastsel
  33.         else
  34.           selection=newselection
  35.         end
  36.         pbPartySetArrow(@sprites["arrow"],selection)
  37.         lastsel=selection if selection>0
  38.         pbUpdateOverlay(selection,party)
  39.         pbSetMosaic(selection)
  40.       end
  41.       pbUpdateSpriteHash(@sprites)
  42.      
  43.       partyxval=[202,283,208,285,208,285]
  44.       partyyval=[53,67,116,132,180,195]
  45.       for i in 0...6
  46.         if $mouse.inArea?(partyxval[i],partyyval[i],50,48)
  47.           selection=i
  48.           pbPartySetArrow(@sprites["arrow"],selection)
  49.           selection=-1 if selection==-4||selection==-5
  50.           pbUpdateOverlay(selection,party) if not @screen.pbHeldPokemon
  51.         end
  52.       end
  53.       if Input.trigger?(Input::C) or $mouse.leftClick?
  54.         if selection>=0 && selection<6
  55.           @selection=selection
  56.           return selection
  57.         elsif selection==6 # Close Box
  58.           @selection=selection
  59.           return (depositing) ? -3 : -1
  60.         end
  61.       end
  62.       if Input.trigger?(Input::B) or $mouse.rightClick?
  63.         @selection=selection
  64.         return -1
  65.       end
  66.     end
  67.   end
  68.  
  69.   def pbSelectBoxInternal(party)
  70.     selection=@selection
  71.     pbSetArrow(@sprites["arrow"],selection)
  72.     pbUpdateOverlay(selection)
  73.     pbSetMosaic(selection)
  74.     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)]
  75.     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)]
  76.     loop do
  77.       Graphics.update
  78.       Input.update
  79.       key=-1
  80.       key=Input::DOWN if Input.repeat?(Input::DOWN)
  81.       key=Input::RIGHT if Input.repeat?(Input::RIGHT)
  82.       key=Input::LEFT if Input.repeat?(Input::LEFT)
  83.       key=Input::UP if Input.repeat?(Input::UP)
  84.       for i in 0...30
  85.         if $mouse.inArea?(xval[i],yval[i],50,48)
  86.           selection=i
  87.           pbSetArrow(@sprites["arrow"],selection)
  88.           nextbox=-1
  89.           selection=-1 if selection==-4||selection==-5
  90.           pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
  91.         end
  92.         if $mouse.inArea?(230,18,232,46)#Box Number
  93.           selection=-1
  94.           pbSetArrow(@sprites["arrow"],selection)
  95.           nextbox=-1
  96.           selection=-1 if selection==-4||selection==-5
  97.           pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
  98.         end
  99.         if $mouse.inArea?(186,320,168,46)#Party Button
  100.           selection=-2
  101.           pbSetArrow(@sprites["arrow"],selection)
  102.           nextbox=-1
  103.           selection=-1 if selection==-4||selection==-5
  104.           pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
  105.         end
  106.         if $mouse.inArea?(385,320,126,46)#Close Button
  107.           selection=-3
  108.           pbSetArrow(@sprites["arrow"],selection)
  109.           nextbox=-1
  110.           selection=-1 if selection==-4||selection==-5
  111.           pbUpdateOverlay(selection) if not @screen.pbHeldPokemon
  112.         end
  113.       end
  114.         if key>=0
  115.           pbPlayCursorSE()
  116.           selection=pbChangeSelection(key,selection)
  117.           pbSetArrow(@sprites["arrow"],selection)
  118.           nextbox=-1          
  119.         if selection==-4
  120.           nextbox=(@storage.currentBox==0) ? @storage.maxBoxes-1 : @storage.currentBox-1
  121.           pbSwitchBoxToLeft(nextbox)
  122.           @storage.currentBox=nextbox
  123.           selection=-1
  124.         elsif selection==-5
  125.           nextbox=(@storage.currentBox==@storage.maxBoxes-1) ? 0 : @storage.currentBox+1
  126.           pbSwitchBoxToRight(nextbox)
  127.           @storage.currentBox=nextbox
  128.           selection=-1
  129.         end
  130.         selection=-1 if selection==-4 || selection==-5
  131.         pbUpdateOverlay(selection)
  132.         pbSetMosaic(selection)
  133.       end
  134.       pbUpdateSpriteHash(@sprites)
  135.       if Input.trigger?(Input::C) || $mouse.leftClick?
  136.         if selection>=0
  137.           @selection=selection
  138.           return [@storage.currentBox,selection]
  139.         elsif selection==-1 # Box name
  140.           @selection=selection
  141.           return [-4,-1]
  142.         elsif selection==-2 # Party Pokémon
  143.           @selection=selection
  144.           return [-2,-1]
  145.         elsif selection==-3 # Close Box
  146.           @selection=selection
  147.           return [-3,-1]
  148.         end
  149.       end
  150.       if Input.trigger?(Input::B) || $mouse.rightClick?
  151.         @selection=selection
  152.         return nil
  153.       end
  154.       if Input.trigger?(Input::L) or $mouse.scroll_up?
  155.         nextbox=(@storage.currentBox==0) ? @storage.maxBoxes-1 : @storage.currentBox-1
  156.         pbSwitchBoxToLeft(nextbox)
  157.         @storage.currentBox=nextbox
  158.       end
  159.       if Input.trigger?(Input::R) or $mouse.scroll_down?
  160.         nextbox=(@storage.currentBox==@storage.maxBoxes-1) ? 0 : @storage.currentBox+1
  161.         pbSwitchBoxToRight(nextbox)
  162.         @storage.currentBox=nextbox
  163.       end
  164.     end
  165.   end
  166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement