bo4p5687

Pokegear (HGSS) - Fade in and out

Jan 13th, 2021 (edited)
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #-------------------------------------------------------------------------------
  2. # HGSS Pokegear menu
  3. # Credit: bo4p5687, graphics by Richard PT
  4. #-------------------------------------------------------------------------------
  5. PluginManager.register({
  6.   :name    => "HGSS Pokegear Menu",
  7.   :credits => ["bo4p5687", "graphics by Richard PT"]
  8. })
  9. #-------------------------------------------------------------------------------
  10. class PokemonGlobalMetadata
  11.   attr_accessor :backgroundPokegear
  12.  
  13.   alias backgroundNew initialize
  14.   def initialize
  15.     @backgroundPokegear = 0
  16.     backgroundNew
  17.   end
  18. end
  19. #-------------------------------------------------------------------------------
  20. # Call player in pokegear (signal)
  21. def canCall
  22.   # Map (player can't call, here)
  23.   map = []
  24.   return false if map && map.include?($game_map.map_id)
  25.   return true
  26. end
  27. #-------------------------------------------------------------------------------
  28. class PokemonPokegear_Scene
  29.  
  30.   # Music
  31.   ListMusicRadio = [
  32.   # Display name, Name of music (file)
  33.   ["March","Radio - March"],
  34.   ["Lullaby","Radio - Lullaby"],
  35.   ["Oak","Radio - Oak"],
  36.   # Add new music here
  37.   # Example: ["Music","Radio - Music"],
  38.   # [],
  39.   # Custom (use the file in "Audio/BGM/")
  40.   ["Custom"]
  41.   ]
  42.  
  43.   def initialize
  44.     @sprites={}
  45.     @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
  46.     @viewport.z = 99999
  47.     @viewport1 = Viewport.new(36,16,412,292)
  48.     @viewport1.z = 99999
  49.     @viewport2 = Viewport.new(0,0,Graphics.width,Graphics.height)
  50.     @viewport2.z = 99999
  51.     @exit = false
  52.     $PokemonGlobal.backgroundPokegear = 0 if !$PokemonGlobal.backgroundPokegear
  53.     # Background number: 0, 1, 2, 3, 4, 5
  54.     @background = $PokemonGlobal.backgroundPokegear
  55.     @process = 0
  56.     @features = 0
  57.     @beforeshowmap = 0
  58.     @choose = 0; @change = true; @otherfeatures = true
  59.     @listmusic = ["Default"]; @select = 0; @custom = false
  60.     @trainers = []; @store = []; @choice = 0; @sort = false; @sortselect = 0
  61.     @frame = 0; @current = 0
  62.     @se = 0
  63.   end
  64.  
  65.   def start
  66.     @fade = true; @show=false
  67.     # List music
  68.     putMusicCustom
  69.     # Start
  70.     loop do
  71.       # Update
  72.       update_ingame
  73.       # Exit
  74.       break if @exit
  75.       case @process
  76.       # Fading
  77.       when -1
  78.         fadingOut if !@show
  79.         case @beforeshowmap
  80.         # Radio
  81.         when 2; @process = 8
  82.         # Phone
  83.         when 3; (@trainers.length==0)? (@process=9) : (continueScenePhone;@process = 10)
  84.         end
  85.       # Main page
  86.       when 0
  87.         fadingIn if !@fade && !@show
  88.         @beforeshowmap = 0
  89.         # Dispose
  90.         dispose
  91.         clearTxt("text 2") if @sprites["text 2"]
  92.         clearTxt("text 3") if @sprites["text 3"]
  93.         # Scene
  94.         chooseScene
  95.         fadingOut if !@fade && !@show
  96.         @process = 5
  97.       # Customize
  98.       when 1
  99.         fadingIn if !@show
  100.         @beforeshowmap = 1
  101.         @otherfeatures = true
  102.         # Dispose
  103.         dispose
  104.         clearTxt("text 2") if @sprites["text 2"]
  105.         clearTxt("text 3") if @sprites["text 3"]
  106.         # Draw
  107.         drawBar
  108.         sceneCustomize
  109.         fadingOut if !@show
  110.         @process = 6
  111.       # Radio
  112.       when 2
  113.         fadingIn if !@show
  114.         @beforeshowmap = 2
  115.         @otherfeatures = true
  116.         # Dispose
  117.         dispose
  118.         clearTxt("text 2") if @sprites["text 2"]
  119.         clearTxt("text 3") if @sprites["text 3"]
  120.         # Draw
  121.         drawBar
  122.         sceneRadio
  123.         @process = -1
  124.       # Map
  125.       when 3
  126.         # Dispose
  127.         dispose
  128.         clearTxt("text 2") if @sprites["text 2"]
  129.         clearTxt("text 3") if @sprites["text 3"]
  130.         @show = true
  131.         # Show map
  132.         pbShowMapPokegear
  133.         # Change
  134.         case @beforeshowmap
  135.         when 0; @process = 0
  136.         when 1; @process = 1
  137.         when 2; @process = 2
  138.         when 3; @process = 4
  139.         end
  140.       # Phone
  141.       when 4
  142.         fadingIn if !@show
  143.         @beforeshowmap = 3
  144.         @otherfeatures = true
  145.         # Dispose
  146.         dispose
  147.         clearTxt("text 2") if @sprites["text 2"]
  148.         clearTxt("text 3") if @sprites["text 3"]
  149.         # Draw
  150.         drawBar
  151.         scenePhone
  152.       # Main page (control)
  153.       when 5
  154.         @fade = false; @show = false
  155.         # Redraw time
  156.         x = setPositionTime[0]; y = setPositionTime[1]
  157.         width = setPositionTime[2]; height = setPositionTime[3]
  158.         drawTime(x,y,width,height)
  159.         # Input
  160.         chooseFeature
  161.         # Mouse
  162.         chooseFeatureMouse
  163.       # Customize page (control)
  164.       when 6
  165.         @show = false
  166.         setPositionFrame
  167.         # Input
  168.         chooseCustomize
  169.         # Mouse
  170.         chooseCustomizeMouse
  171.         chooseFeatureMouse
  172.       # Customize page (change background)
  173.       when 7
  174.         # Input, mouse
  175.         chooseChangeCustom
  176.         sePlayAll
  177.       # Radio page (control)
  178.       when 8
  179.         @show = false
  180.         # Input
  181.         chooseRadio
  182.         # Mouse
  183.         chooseRadioMouse
  184.         chooseFeatureMouse
  185.       # Phone page (control - no phone numbers)
  186.       when 9
  187.         @show = false
  188.         # Input
  189.         chooseFeature
  190.         # Mouse
  191.         chooseFeatureMouse
  192.       # Phone page (control)
  193.       when 10
  194.         @show = false
  195.         # Input
  196.         choosePhone
  197.         # Mouse
  198.         choosePhoneMouse
  199.         chooseFeatureMouse
  200.       # Phone page (Show information)
  201.       when 11
  202.         animationIcon
  203.         # Input, mouse
  204.         choosePhoneInformation
  205.         sePlayAll
  206.       # Phone page (Call)
  207.       when 12
  208.         # Input, mouse
  209.         choosePhoneSelect
  210.         sePlayAll
  211.       end
  212.     end
  213.     # End
  214.     endScene
  215.   end
  216. #-------------------------------------------------------------------------------
  217. #-------------------------------------------------------------------------------
  218.   def pbShowMapPokegear
  219.     scene = PokemonRegionMap_Scene.new(-1,false)
  220.     screen = PokemonRegionMapScreen.new(scene)
  221.     addBackgroundOrColoredPlane(@sprites,"black",nil,Color.new(0,0,0),@viewport)
  222.     @sprites["black"].opacity = 255
  223.     screen.pbStartScreen
  224.   end
  225.  
  226.   def fadingIn(h=nil)
  227.     vp = (h.nil?)? @viewport2 : @viewport
  228.     col = Color.new(0,0,0,0)
  229.     numFrames = (Graphics.frame_rate*0.4).floor
  230.     alphaDiff = (255.0/numFrames).ceil
  231.     for j in 0..numFrames
  232.       col.set(0,0,0,j*alphaDiff)
  233.       vp.color=col
  234.       Graphics.update
  235.       Input.update
  236.     end
  237.     pbPushFade
  238.   end
  239.  
  240.   def fadingOut(h=nil)
  241.     vp = (h.nil?)? @viewport2 : @viewport
  242.     col = Color.new(0,0,0,0)
  243.     numFrames = (Graphics.frame_rate*0.4).floor
  244.     alphaDiff = (255.0/numFrames).ceil
  245.     pbPopFade
  246.     for j in 0..numFrames
  247.       col.set(0,0,0,(numFrames-j)*alphaDiff)
  248.       vp.color=col
  249.       Graphics.update
  250.       Input.update
  251.     end
  252.   end
  253. #-------------------------------------------------------------------------------
  254. # # Scene
  255. #-------------------------------------------------------------------------------
  256.   # Main Page
  257.   DayOfWeek = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
  258.   def chooseScene
  259.     # Scene
  260.     create_sprite("scene","Background",@viewport)
  261.     set_src_wh_sprite("scene",SCREEN_WIDTH,SCREEN_HEIGHT)
  262.     set_src_xy_sprite("scene",SCREEN_WIDTH*@background,0)
  263.     # Draw text
  264.     create_sprite_2("text",@viewport)
  265.     x = setPositionTime[0]; y = setPositionTime[1]
  266.     width = setPositionTime[2]; height = setPositionTime[3]
  267.     drawTime(x,y,width,height)
  268.     # Phone signal
  269.     filename = (canCall)? "signalon" : "signaloff"
  270.     create_sprite("signal",filename,@viewport)
  271.     x += 230
  272.     y = (@background==2)? y-15 : y+5
  273.     set_xy_sprite("signal",x,y)
  274.     (@background==2)? set_angle_sprite("signal",5) : set_angle_sprite("signal",0)
  275.     # Bar (features)
  276.     drawBar
  277.   end
  278.  
  279.   def drawBar
  280.     # Bar
  281.     create_sprite("bar","Bar",@viewport)
  282.     set_src_wh_sprite("bar",SCREEN_WIDTH,55)
  283.     set_src_xy_sprite("bar",SCREEN_WIDTH*@background,0)
  284.     set_xy_sprite("bar",0,SCREEN_HEIGHT-55)
  285.     # Icon
  286.     create_sprite("customize","Icon",@viewport)
  287.     create_sprite("radio","Icon",@viewport)
  288.     create_sprite("map","Icon",@viewport)
  289.     create_sprite("phone","Icon",@viewport)
  290.     create_sprite("exit","Icon",@viewport)
  291.     srcw = 80; srch = 52
  292.     set_src_wh_sprite("customize",srcw,srch)
  293.     set_src_wh_sprite("radio",srcw,srch)
  294.     set_src_wh_sprite("map",srcw,srch)
  295.     set_src_wh_sprite("phone",srcw,srch)
  296.     set_src_wh_sprite("exit",srcw,srch)
  297.     srcx = 0; srcy = 52*@background
  298.     set_src_xy_sprite("customize",srcx,srcy)
  299.     set_src_xy_sprite("radio",srcx+srcw,srcy)
  300.     set_src_xy_sprite("map",srcx+srcw*2,srcy)
  301.     set_src_xy_sprite("phone",srcx+srcw*3,srcy)
  302.     set_src_xy_sprite("exit",srcx+srcw*4,srcy)
  303.     x = 25; y = SCREEN_HEIGHT - 54
  304.     set_xy_sprite("customize",x,y)
  305.     set_xy_sprite("radio",x+srcw+15,y)
  306.     set_xy_sprite("map",x+srcw*2+30,y)
  307.     set_xy_sprite("phone",x+srcw*3+45,y)
  308.     set_xy_sprite("exit",x+srcw*4+60,y)
  309.     # Icon when choose
  310.     create_sprite("customize2","Icon after",@viewport)
  311.     create_sprite("radio2","Icon after",@viewport)
  312.     create_sprite("map2","Icon after",@viewport)
  313.     create_sprite("phone2","Icon after",@viewport)
  314.     create_sprite("exit2","Icon after",@viewport)
  315.     set_src_wh_sprite("customize2",srcw,srch)
  316.     set_src_wh_sprite("radio2",srcw,srch)
  317.     set_src_wh_sprite("map2",srcw,srch)
  318.     set_src_wh_sprite("phone2",srcw,srch)
  319.     set_src_wh_sprite("exit2",srcw,srch)
  320.     set_src_xy_sprite("customize2",srcx,srcy)
  321.     set_src_xy_sprite("radio2",srcx+srcw,srcy)
  322.     set_src_xy_sprite("map2",srcx+srcw*2,srcy)
  323.     set_src_xy_sprite("phone2",srcx+srcw*3,srcy)
  324.     set_src_xy_sprite("exit2",srcx+srcw*4,srcy)
  325.     set_xy_sprite("customize2",x,y)
  326.     set_xy_sprite("radio2",x+srcw+15,y)
  327.     set_xy_sprite("map2",x+srcw*2+30,y)
  328.     set_xy_sprite("phone2",x+srcw*3+45,y)
  329.     set_xy_sprite("exit2",x+srcw*4+60,y)
  330.     set_visible_sprite("customize2")
  331.     set_visible_sprite("radio2")
  332.     set_visible_sprite("map2")
  333.     set_visible_sprite("phone2")
  334.     set_visible_sprite("exit2")
  335.     # Select icon (rectangle)
  336.     create_sprite("selectI","Select Icon",@viewport)
  337.     set_xy_sprite("selectI",x+(srcw+15)*@features,y)
  338.   end
  339.  
  340.   def setPositionTime
  341.     width = 270; height = 45
  342.     case @background
  343.     when 0; x = (SCREEN_WIDTH-width)/2; y = 59
  344.     when 1; x = (SCREEN_WIDTH-width)/2; y = 59
  345.     when 2; x = 130; y = 78
  346.     when 3; x = 125; y = 60
  347.     when 4; x = (SCREEN_WIDTH-width)/2; y = 50
  348.     else; x = 140; y = 60
  349.     end
  350.     return ret = [x,y,width,height]
  351.   end
  352.  
  353.   def drawTime(x,y,w,h)
  354.     (@background == 2)? set_angle_sprite("text",3) : set_angle_sprite("text",0)
  355.     time = Time.now
  356.     hour = time.hour; min = time.min
  357.     hour = "0#{hour}" if hour < 10
  358.     min = "0#{min}" if min < 10
  359.     string = "#{hour} : #{min}    #{DayOfWeek[time.wday]}"
  360.     drawTxt("text",x,y,w,h,string,"Arial")
  361.   end
  362. #-------------------------------------------------------------------------------
  363.   # Customize Page
  364.   def sceneCustomize
  365.     # Scene
  366.     create_sprite("customize scene","Page customize",@viewport)
  367.     set_src_wh_sprite("customize scene",SCREEN_WIDTH,SCREEN_HEIGHT)
  368.     set_src_xy_sprite("customize scene",SCREEN_WIDTH*@background,0)
  369.     # Select
  370.     create_sprite("customize frame","Frame",@viewport)
  371.     create_sprite("customize select frame","Select Frame",@viewport)
  372.     # Change menu
  373.     create_sprite("customize change menu","Change Menu",@viewport)
  374.     create_sprite("customize select change","Select Change",@viewport)
  375.     width = @sprites["customize select change"].bitmap.width
  376.     height = @sprites["customize select change"].bitmap.height
  377.     set_src_wh_sprite("customize select change",width,height/2)
  378.     set_src_xy_sprite("customize select change",0,0)
  379.     set_visible_sprite("customize change menu")
  380.     set_visible_sprite("customize select change")
  381.     @choose = @background
  382.     setPositionFrame
  383.   end
  384.  
  385.   def setPositionFrame
  386.     xa = [46,207,367]
  387.     x = (@choose%3==0)? xa[0] : (@choose%3==1)? xa[1] : xa[2]
  388.     y = (@choose<3)? 52 : 210
  389.     set_xy_sprite("customize frame",x,y)
  390.     set_xy_sprite("customize select frame",x-10,y-10)
  391.   end
  392.  
  393.   def sceneChooseCustom
  394.     set_visible_sprite("customize change menu",true)
  395.     xa = [46,207,367]
  396.     x = (@choose%3==0)? xa[0]+108 : (@choose%3==1)? xa[1]+108 : xa[2]-138
  397.     y = (@choose<3)? 52 : 210
  398.     set_xy_sprite("customize change menu",x,y)
  399.     return ret = [x,y]
  400.   end
  401. #-------------------------------------------------------------------------------
  402.   # Set text (radio, phone)
  403.   def setTextRP
  404.     # Text
  405.     create_sprite_2("text 2",@viewport1) if !@sprites["text 2"]
  406.     clearTxt("text 2")
  407.     create_sprite_2("text 3",@viewport1) if !@sprites["text 3"]
  408.     clearTxt("text 3")
  409.   end
  410.  
  411.   # Set position of arrow
  412.   def posArrow(range)
  413.     y = 10 + 50*range
  414.     set_xy_sprite("arrow",26,y)
  415.   end
  416.  
  417.   # Radio page
  418.   def sceneRadio
  419.     @select = 0
  420.     # Scene
  421.     create_sprite("radio scene","Page Radio",@viewport)
  422.     set_src_wh_sprite("radio scene",SCREEN_WIDTH,SCREEN_HEIGHT)
  423.     set_src_xy_sprite("radio scene",SCREEN_WIDTH*@background,0)
  424.     # Text
  425.     (@custom)? nameMusic(1) : nameMusic(0)
  426.     # Arrow
  427.     create_sprite("arrow","Arrow",@viewport)
  428.     posArrow(@select)
  429.   end
  430.  
  431.   # Put the files in "Audio/BGM/"
  432.   def putMusicCustom
  433.     @listmusic = ["Default"]
  434.     Dir.chdir("Audio/BGM/") {
  435.       Dir.glob("*.mp3") { |f| @listmusic.push(f) }
  436.       Dir.glob("*.MP3") { |f| @listmusic.push(f) }
  437.       Dir.glob("*.ogg") { |f| @listmusic.push(f) }
  438.       Dir.glob("*.OGG") { |f| @listmusic.push(f) }
  439.       Dir.glob("*.wav") { |f| @listmusic.push(f) }
  440.       Dir.glob("*.WAV") { |f| @listmusic.push(f) }
  441.       Dir.glob("*.mid") { |f| @listmusic.push(f) }
  442.       Dir.glob("*.MID") { |f| @listmusic.push(f) }
  443.       Dir.glob("*.midi") { |f| @listmusic.push(f) }
  444.       Dir.glob("*.MIDI") { |f| @listmusic.push(f) } }
  445.   end
  446.  
  447.   # Radio (draw name)
  448.   def nameMusic(list)
  449.     # Text (bitmap)
  450.     setTextRP
  451.     # List: 0: begin; 1: custom
  452.     max = (list==0)? ListMusicRadio.length : @listmusic.length
  453.     if list==0
  454.       (0...ListMusicRadio.length).each { |i|
  455.       x = 45
  456.       y = (@select>=max-6 && max>=6)? (5+50*i-(max-6)*50) : (5+50*i-@select*50)
  457.       width = 412; height = 40
  458.       string = ListMusicRadio[i][0]
  459.       drawTxt("text 2",x,y,width,height,string,"Arial",26,0,true) }
  460.     else
  461.       (0...@listmusic.length).each { |i|
  462.       x = 45
  463.       y = (@select>=max-6 && max>=6)? (5+50*i-(max-6)*50) : (5+50*i-@select*50)
  464.       width = 412; height = 40
  465.       string = @listmusic[i]
  466.       drawTxt("text 2",x,y,width,height,string,"Arial",26,0,true) }
  467.     end
  468.   end
  469.  
  470.   # Set song
  471.   def songPlayBGM(song=nil,white=false,black=false)
  472.     $game_system.setDefaultBGM(song)
  473.     $PokemonMap.whiteFluteUsed = white if $PokemonMap
  474.     $PokemonMap.blackFluteUsed = black if $PokemonMap
  475.   end
  476.  
  477.   def fluteMusic(white=false,black=false)
  478.     $PokemonMap.whiteFluteUsed = white if $PokemonMap
  479.     $PokemonMap.blackFluteUsed = black if $PokemonMap
  480.   end
  481. #-------------------------------------------------------------------------------
  482.   # Phone page
  483.   def scenePhone
  484.     @select = 0
  485.     # Scene
  486.     create_sprite("phone scene","Page Phone",@viewport)
  487.     set_src_wh_sprite("phone scene",SCREEN_WIDTH,SCREEN_HEIGHT)
  488.     set_src_xy_sprite("phone scene",SCREEN_WIDTH*@background,0)
  489.     # List Trainer (phonebook)
  490.     putTrainerList
  491.     #(@trainers.length==0)? (@process=9) : (continueScenePhone;@process = 10)
  492.     @process = -1
  493.   end
  494.    
  495.   def continueScenePhone
  496.     # Text
  497.     namePhone
  498.     # Arrow
  499.     create_sprite("arrow","Arrow",@viewport)
  500.     posArrow(@select)
  501.     create_sprite("arrow2","Arrow Sort",@viewport)
  502.     posArrowSort(@sortselect)
  503.     visibleSortArrow
  504.     # Choose
  505.     create_sprite("phone menu","Phone Menu",@viewport2)
  506.     pos = posPhoneMenu
  507.     set_visible_sprite("phone menu")
  508.     @choice==0
  509.     create_sprite("phone select","Phone Select",@viewport2)
  510.     x = pos[0] + 8; y = 10
  511.     set_xy_sprite("phone select",x,y)
  512.     width = @sprites["phone select"].bitmap.width
  513.     height = @sprites["phone select"].bitmap.height
  514.     set_src_wh_sprite("phone select",width,height/3)
  515.     set_src_xy_sprite("phone select",0,height/3*@choice)
  516.     set_visible_sprite("phone select")
  517.     # Information
  518.     create_sprite("phone information","Information",@viewport2)
  519.     set_src_wh_sprite("phone information",340,202)
  520.     set_src_xy_sprite("phone information",340*@background,0)
  521.     set_xy_sprite("phone information",-340,12)
  522.     # Rematch
  523.     rematchIcon
  524.   end
  525.  
  526.   # Set position of arrow (sort)
  527.   def posArrowSort(range)
  528.     y = 10 + 50*range
  529.     set_xy_sprite("arrow2",26,y)
  530.   end
  531.  
  532.   def visibleSortArrow
  533.     if @sort
  534.       set_visible_sprite("arrow")
  535.       set_visible_sprite("arrow2",true)
  536.     else
  537.       set_visible_sprite("arrow",true)
  538.       set_visible_sprite("arrow2")
  539.     end
  540.   end
  541.  
  542.   def posPhoneMenu
  543.     x = 224; y = 169
  544.     set_xy_sprite("phone menu",x,y)
  545.     return ret = [x,y]
  546.   end
  547.  
  548.   # Trainer list
  549.   def putTrainerList
  550.     @trainers = []; @store = []
  551.     if $PokemonGlobal.phoneNumbers
  552.       for num in $PokemonGlobal.phoneNumbers
  553.         if num[0]   # if visible
  554.           if num.length==8   # if trainer
  555.             @trainers.push([num[1],num[2],num[6],(num[4]>=2)])
  556.             @store.push([num[1],num[2],num[6],num[7]]) # Store
  557.           else               # if NPC
  558.             @trainers.push([num[1],num[2],num[3]])
  559.             @store.push([num[1],num[2],num[3]]) # Store
  560.           end
  561.         end
  562.       end
  563.     end
  564.   end
  565.  
  566.   def setForSorting(order)
  567.     if $PokemonGlobal.phoneNumbers
  568.       (0...$PokemonGlobal.phoneNumbers.size).each { |i|
  569.       num = $PokemonGlobal.phoneNumbers[i]
  570.       if num[0] # if visible
  571.         if num.length==8 # Trainer
  572.           if @store[order][0]==num[1] && @store[order][1]==num[2] &&
  573.             @store[order][2]==num[6] && @store[order][3]==num[7]
  574.             return ret = [i,num]
  575.             break
  576.           end
  577.         else # NPC
  578.           if @store[order][0]==num[1] && @store[order][1]==num[2] &&
  579.             @store[order][2]==num[3]
  580.             return ret = [i,num]
  581.             break
  582.           end
  583.         end
  584.       end }
  585.     end
  586.   end
  587.  
  588.   def sortTrainer(old,new)
  589.     if $PokemonGlobal.phoneNumbers
  590.       oldnum = setForSorting(old)
  591.       newnum = setForSorting(new)
  592.       $PokemonGlobal.phoneNumbers[oldnum[0]] = newnum[1]
  593.       $PokemonGlobal.phoneNumbers[newnum[0]] = oldnum[1]
  594.     end
  595.   end
  596.  
  597.   # Name trainer
  598.   def namePhone(order=nil)
  599.     setTextRP
  600.     # Write list
  601.     num = (order.nil?)? @select : @sortselect
  602.     max = @trainers.length
  603.     (0...max).each { |i|
  604.     x = 20
  605.     y = (num>=max-6 && max>=6)? (5+50*i-(max-6)*50) : (5+50*i-num*50)
  606.     width = 160; height = 40
  607.     if @trainers[i].length==4
  608.       string = pbGetMessageFromHash(MessageTypes::TrainerNames,@trainers[i][1])
  609.     else
  610.       string = @trainers[i][1]
  611.     end
  612.     drawTxt("text 2",x,y,width,height,string,"Arial",26,0,true)
  613.     if @trainers[i].length==4
  614.       x += width
  615.       width = 252; height = 40
  616.       string = PBTrainers.getName(@trainers[i][0])
  617.       drawTxt("text 3",x,y,width,height,string,"Arial",26,0,true)
  618.     end }
  619.   end
  620.  
  621.   def showInformationTrainer(show)
  622.     pos = (@sort)? @sortselect : @select
  623.     if show
  624.       5.times { @sprites["phone information"].x += 68 } if @sprites["phone information"].x<340
  625.       if @trainers[pos].length==4
  626.         filename = pbTrainerCharFile(@trainers[pos][0])
  627.       else
  628.         filename = sprintf("Graphics/Characters/phone%03d",@trainers[pos][0])
  629.       end
  630.       @sprites["phone icon"] = Sprite.new(@viewport2)
  631.       @sprites["phone icon"].bitmap = Bitmap.new(filename)
  632.       charwidth  = @sprites["phone icon"].bitmap.width
  633.       charheight = @sprites["phone icon"].bitmap.height
  634.       set_src_wh_sprite("phone icon",charwidth/4,charheight/4)
  635.       set_src_xy_sprite("phone icon",0,0)
  636.       x = 24; y = @sprites["phone information"].y + 28
  637.       set_xy_sprite("phone icon",24,28)
  638.       create_sprite_2("text 4",@viewport2) if !@sprites["text 4"]
  639.       clearTxt("text 4")
  640.       # Up
  641.       x = 100; y = @sprites["phone information"].y+20
  642.       width = 220; height = 30
  643.       string = "Location :"
  644.       drawTxt("text 4",x,y,width,height,string,"Arial",26,0,true)
  645.       string = (@trainers[pos][2]) ? pbGetMessage(MessageTypes::MapNames,@trainers[pos][2]) : ""
  646.       drawTxt("text 4",x+10,y+35,width,height,string,"Arial",26,0,true)
  647.       # Down
  648.       x = 10; y = @sprites["phone information"].y+114
  649.       width = 330; height = 50
  650.       string = "Registered : #{@trainers.length}"
  651.       drawTxt("text 4",x,y+5,width,height,string,"Arial",26,0,true)
  652.       string = "Waiting for a rematch : #{rematchCount}"
  653.       drawTxt("text 4",x,y+44,width,height,string,"Arial",26,0,true)
  654.     else
  655.       set_visible_sprite("phone icon")
  656.       clearTxt("text 4") if @sprites["text 4"]
  657.       5.times { @sprites["phone information"].x -= 68} if @sprites["phone information"].x<340
  658.     end
  659.   end
  660.  
  661.   def rematchCount
  662.     rematch = 0
  663.     (0...@trainers.length).each { |i|
  664.     rematch+=1 if @trainers[i].length==4 && @trainers[i][3] }
  665.     return rematch
  666.   end
  667.  
  668.   def animationIcon
  669.     charwidth = @sprites["phone icon"].bitmap.width/4
  670.     @frame+=1
  671.     if @frame==5
  672.       @frame = 0
  673.       @current+=1
  674.       @current%=4
  675.       set_src_xy_sprite("phone icon",@current*charwidth,0)
  676.     end
  677.   end
  678.  
  679.   # Set rematch icon
  680.   def rematchIcon
  681.     (0...@trainers.length).each { |i| x = 0; y = 5
  682.     create_sprite_3("rematch #{i}",x,y,"phoneRematch",@viewport1) if !@sprites["rematch #{i}"]
  683.     set_visible_sprite("rematch #{i}",(@trainers[i].length==4 && @trainers[i][3])) }
  684.   end
  685.  
  686. #-------------------------------------------------------------------------------
  687. # Choose feature (Input)
  688. #-------------------------------------------------------------------------------
  689.   def chooseFeature
  690.     set_xy_sprite("selectI",25+95*@features,SCREEN_HEIGHT-54)
  691.     if Input.trigger?(Input::LEFT)
  692.       pbPlayDecisionSE
  693.       @features -= 1
  694.       @features = 4 if @features < 0
  695.     end
  696.     if Input.trigger?(Input::RIGHT)
  697.       pbPlayDecisionSE
  698.       @features += 1
  699.       @features = 0  if @features > 4
  700.     end
  701.     if Input.trigger?(Input::C)
  702.       (@features==4)? pbPlayCloseMenuSE : pbPlayDecisionSE
  703.       case @features
  704.       # Customize
  705.       when 0
  706.         set_visible_sprite("customize2",true)
  707.         pbWait(5)
  708.         set_visible_sprite("customize2")
  709.         @process = 1
  710.       # Radio
  711.       when 1
  712.         set_visible_sprite("radio2",true)
  713.         pbWait(5)
  714.         set_visible_sprite("radio2")
  715.         @process = 2
  716.       # Map
  717.       when 2
  718.         set_visible_sprite("map2",true)
  719.         pbWait(5)
  720.         set_visible_sprite("map2")
  721.         @process = 3
  722.       # Phone
  723.       when 3
  724.         set_visible_sprite("phone2",true)
  725.         pbWait(5)
  726.         set_visible_sprite("phone2")
  727.         @process = 4
  728.       # Exit
  729.       else
  730.         set_visible_sprite("exit2",true)
  731.         pbWait(5)
  732.         set_visible_sprite("exit2")
  733.         (@process!=5)? (@process=0) : (@exit=true)
  734.       end
  735.     end
  736.     if Input.trigger?(Input::B)
  737.       pbPlayCloseMenuSE
  738.       (@process!=5)? (@process=0) : (@exit=true)
  739.     end
  740.   end
  741.  
  742.   def chooseFeatureMouse
  743.     set_xy_sprite("selectI",25+95*@features,SCREEN_HEIGHT-54)
  744.     w = 80; h = 52
  745.     x = []; t = 0
  746.     5.times { x.push(25+(w+15)*t); t+=1 }
  747.     y = SCREEN_HEIGHT - 54
  748.     # Customize
  749.     if rectMouse(x[0],y,w,h)
  750.       @features = 0
  751.       if clickedMouse
  752.         pbPlayDecisionSE
  753.         set_visible_sprite("customize2",true)
  754.         pbWait(5)
  755.         set_visible_sprite("customize2")
  756.         @process = 1
  757.       end
  758.     # Radio
  759.     elsif rectMouse(x[1],y,w,h)
  760.       @features = 1
  761.       if clickedMouse
  762.         pbPlayDecisionSE
  763.         set_visible_sprite("radio2",true)
  764.         pbWait(5)
  765.         set_visible_sprite("radio2")
  766.         @process = 2
  767.       end
  768.     # Map
  769.     elsif rectMouse(x[2],y,w,h)
  770.       @features = 2
  771.       if clickedMouse
  772.         pbPlayDecisionSE
  773.         set_visible_sprite("map2",true)
  774.         pbWait(5)
  775.         set_visible_sprite("map2")
  776.         @process = 3
  777.       end
  778.     # Phone
  779.     elsif rectMouse(x[3],y,w,h)
  780.       @features = 3
  781.       if clickedMouse
  782.         pbPlayDecisionSE
  783.         set_visible_sprite("phone2",true)
  784.         pbWait(5)
  785.         set_visible_sprite("phone2")
  786.         @process = 4
  787.       end
  788.     # Exit
  789.     elsif rectMouse(x[4],y,w,h)
  790.       @features = 4
  791.       if clickedMouse
  792.         pbPlayCloseMenuSE
  793.         set_visible_sprite("exit2",true)
  794.         pbWait(5)
  795.         set_visible_sprite("exit2")
  796.         if @process==5
  797.           @exit=true
  798.         elsif @process==8
  799.           if @custom
  800.             @custom=false
  801.             @select = 0
  802.             # Redraw music list
  803.             nameMusic(0)
  804.           else
  805.             @process=0
  806.           end
  807.         elsif @process==10
  808.           (@sort)? (@sort=false) : (@process=0)
  809.         else
  810.           @process=0
  811.         end
  812.       end
  813.     end
  814.     # Play SE
  815.     sePlayAll
  816.   end
  817. #-------------------------------------------------------------------------------
  818. # Choose customize (Input)
  819. #-------------------------------------------------------------------------------
  820.   def setReturnPageCustom
  821.     # Set can't visible
  822.     set_visible_sprite("customize change menu")
  823.     set_visible_sprite("customize select change")
  824.     @change = true; @process = 6
  825.   end
  826.  
  827.   def chooseCustomize
  828.     if @otherfeatures
  829.       if Input.trigger?(Input::LEFT)
  830.         pbPlayDecisionSE
  831.         @choose -= 1
  832.         @choose = 5 if @choose < 0
  833.       end
  834.       if Input.trigger?(Input::RIGHT)
  835.         pbPlayDecisionSE
  836.         @choose += 1
  837.         @choose = 0  if @choose > 5
  838.       end
  839.       if Input.trigger?(Input::UP)
  840.         pbPlayDecisionSE
  841.         @choose -= 3
  842.         @choose += 6 if @choose < 0
  843.       end
  844.       if Input.trigger?(Input::DOWN)
  845.         pbPlayDecisionSE
  846.         @choose += 3
  847.         @choose -= 6 if @choose > 5
  848.       end
  849.       if Input.trigger?(Input::C)
  850.         pbPlayDecisionSE
  851.         @process=7
  852.       end
  853.     else
  854.       chooseFeature
  855.     end
  856.     if Input.trigger?(Input::B)
  857.       if @otherfeatures
  858.         pbPlayCloseMenuSE
  859.         @otherfeatures = false
  860.       end
  861.     end
  862.   end
  863.  
  864.   def chooseCustomizeMouse
  865.     w = 98; h = 89
  866.     x = [46,207,367]; y = [52,210]
  867.     if rectMouse(x[0],y[0],w,h) || rectMouse(x[1],y[0],w,h) ||
  868.       rectMouse(x[2],y[0],w,h) || rectMouse(x[0],y[1],w,h) ||
  869.       rectMouse(x[1],y[1],w,h) || rectMouse(x[2],y[1],w,h)
  870.       if clickedMouse
  871.         pbPlayDecisionSE
  872.         @process=7
  873.       end
  874.     end
  875.     if rectMouse(x[0],y[0],w,h)
  876.       @choose = 0
  877.     elsif rectMouse(x[1],y[0],w,h)
  878.       @choose = 1
  879.     elsif rectMouse(x[2],y[0],w,h)
  880.       @choose = 2
  881.     elsif rectMouse(x[0],y[1],w,h)
  882.       @choose = 3
  883.     elsif rectMouse(x[1],y[1],w,h)
  884.       @choose = 4
  885.     elsif rectMouse(x[2],y[1],w,h)
  886.       @choose = 5
  887.     end
  888.   end
  889.  
  890.   # Change background
  891.   def chooseChangeCustom
  892.     xy = sceneChooseCustom
  893.     x = xy[0] + 8
  894.     y = (@change)? xy[1]+10 : xy[1]+58
  895.     height = @sprites["customize select change"].bitmap.height/2
  896.     set_src_xy_sprite("customize select change",0,((@change)? 0 : height))
  897.     set_xy_sprite("customize select change",x,y)
  898.     set_visible_sprite("customize select change",true)
  899.     if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN)
  900.       pbPlayDecisionSE
  901.       @change = (@change)? false : true
  902.     end
  903.     if Input.trigger?(Input::C)
  904.       if @change
  905.         pbPlayDecisionSE
  906.         $PokemonGlobal.backgroundPokegear = @choose
  907.         if @background!=$PokemonGlobal.backgroundPokegear
  908.           @background = $PokemonGlobal.backgroundPokegear
  909.           @change = true
  910.           @process = 1
  911.         end
  912.       else
  913.         pbPlayCloseMenuSE
  914.         setReturnPageCustom
  915.       end
  916.     end
  917.     if Input.trigger?(Input::B)
  918.       pbPlayCloseMenuSE
  919.       setReturnPageCustom
  920.     end
  921.     w = 112; h = 44
  922.     if rectMouse(x,xy[1]+10,w,h)
  923.       @change = true
  924.       if clickedMouse
  925.         pbPlayDecisionSE
  926.         $PokemonGlobal.backgroundPokegear = @choose
  927.         if @background!=$PokemonGlobal.backgroundPokegear
  928.           @background = $PokemonGlobal.backgroundPokegear
  929.           @change = true
  930.           @process = 1
  931.         end
  932.       end
  933.     elsif rectMouse(x,xy[1]+58,w,h)
  934.       @change = false
  935.       if clickedMouse
  936.         pbPlayCloseMenuSE
  937.         setReturnPageCustom
  938.       end
  939.     end
  940.   end
  941. #-------------------------------------------------------------------------------
  942. # Choose radio (Input)
  943. #-------------------------------------------------------------------------------
  944.   def chooseRadio
  945.     max = (@custom)? @listmusic.length : ListMusicRadio.length
  946.     # Move arrow
  947.     (max<6)? posArrow(@select) : (@select>=max-6)? posArrow(@select-max+6) : posArrow(0)
  948.     if @otherfeatures
  949.       if Input.trigger?(Input::UP)
  950.         pbPlayDecisionSE
  951.         @select -= 1
  952.         @select = 0 if @select < 0
  953.         if max>=6
  954.           (@custom)? nameMusic(1) : nameMusic(0)
  955.         end
  956.       end
  957.       if Input.trigger?(Input::DOWN)
  958.         pbPlayDecisionSE
  959.         @select += 1
  960.         @select = max-1 if @select>=max
  961.         if max>=6
  962.           (@custom)? nameMusic(1) : nameMusic(0)
  963.         end
  964.       end
  965.       if Input.trigger?(Input::C)
  966.         pbPlayDecisionSE
  967.         # Custom
  968.         if @custom
  969.           (@select==0)? songPlayBGM : songPlayBGM(@listmusic[@select])
  970.         # Music
  971.         else
  972.           if @select==max-1
  973.             @custom = true
  974.             @select = 0
  975.             nameMusic(1)
  976.           else
  977.             pbBGMPlay(ListMusicRadio[@select][1],100,100)
  978.             case @select
  979.             when 0; fluteMusic(true)
  980.             when 1; fluteMusic(true)
  981.             end
  982.           end
  983.         end
  984.       end
  985.     else
  986.       chooseFeature
  987.     end
  988.     if Input.trigger?(Input::B)
  989.       if @otherfeatures
  990.         pbPlayCloseMenuSE
  991.         if @custom
  992.           @custom=false
  993.           @select = 0
  994.           nameMusic(0)
  995.         else
  996.           @otherfeatures=false
  997.         end
  998.       end
  999.     end
  1000.   end
  1001.  
  1002.   def chooseRadioMouse
  1003.     # Change position
  1004.     x = 462; y = [33,183]
  1005.     w = 48; h = 117
  1006.     max = (@custom)? @listmusic.length : ListMusicRadio.length
  1007.     if clickedMouse
  1008.       pbPlayDecisionSE
  1009.       if rectMouse(x,y[0],w,h)
  1010.         @select -= 1
  1011.         @select = 0 if @select < 0
  1012.         if max>=6
  1013.           (@custom)? nameMusic(1) : nameMusic(0)
  1014.         end
  1015.       elsif rectMouse(x,y[1],w,h)
  1016.         @select += 1
  1017.         @select = max-1 if @select>=max
  1018.         if max>=6
  1019.           (@custom)? nameMusic(1) : nameMusic(0)
  1020.         end
  1021.       # Music
  1022.       elsif rectMouse(26,10,432,313)
  1023.         if @custom
  1024.           (@select==0)? songPlayBGM : songPlayBGM(@listmusic[@select])
  1025.         else
  1026.           #(0...max).each { |i|
  1027.           if @select==max-1
  1028.             @custom = true
  1029.             @select = 0
  1030.             nameMusic(1)
  1031.           else
  1032.             pbBGMPlay(ListMusicRadio[@select][1],100,100)
  1033.             case @select
  1034.             when 0; fluteMusic(true)
  1035.             when 1; fluteMusic(true)
  1036.             end
  1037.           end #}
  1038.         end
  1039.       end
  1040.     end
  1041.   end
  1042. #-------------------------------------------------------------------------------
  1043. # Choose phone (Input)
  1044. #-------------------------------------------------------------------------------
  1045.   def setReturnPagePhone(num=nil)
  1046.     (num.nil?)? pbPlayDecisionSE : pbPlayCloseMenuSE
  1047.     # Visible
  1048.     set_visible_sprite("phone menu"); set_visible_sprite("phone select")
  1049.     @choice = 0; @process = 10
  1050.   end
  1051.  
  1052.   def choosePhone
  1053.     max = @trainers.length
  1054.     # Visible
  1055.     visibleSortArrow
  1056.     if !@sort
  1057.       num = @select
  1058.       (max<6)? posArrow(num) : (num>=max-6)? posArrow(num-max+6) : posArrow(0)
  1059.       if @otherfeatures
  1060.         if Input.trigger?(Input::UP)
  1061.           pbPlayDecisionSE
  1062.           @select -= 1
  1063.           @select = 0 if @select<0
  1064.           namePhone if max>=6
  1065.         end
  1066.         if Input.trigger?(Input::DOWN)
  1067.           pbPlayDecisionSE
  1068.           @select += 1
  1069.           @select = max-1 if @select>=max
  1070.           namePhone if max>=6
  1071.         end
  1072.         if Input.trigger?(Input::C)
  1073.           pbPlayDecisionSE
  1074.           @sortselect = @select
  1075.           # Visible
  1076.           set_visible_sprite("phone menu",true)
  1077.           set_visible_sprite("phone select",true)
  1078.           @process = 12
  1079.         end
  1080.       else
  1081.         chooseFeature
  1082.       end
  1083.       if Input.trigger?(Input::B)
  1084.         pbPlayCloseMenuSE
  1085.         @otherfeatures=false if @otherfeatures
  1086.       end
  1087.     # Mode: sort
  1088.     else
  1089.       num = @sortselect
  1090.       (max<6)? posArrowSort(num) : (num>=max-6)? posArrowSort(num-max+6) : posArrowSort(0)
  1091.       if Input.trigger?(Input::UP)
  1092.         pbPlayDecisionSE
  1093.         @sortselect -= 1
  1094.         @sortselect = 0 if @sortselect<0
  1095.         namePhone(0) if max>=6
  1096.       end
  1097.       if Input.trigger?(Input::DOWN)
  1098.         pbPlayDecisionSE
  1099.         @sortselect += 1
  1100.         @sortselect = max-1 if @sortselect>=max
  1101.         namePhone(0) if max>=6
  1102.       end
  1103.       if Input.trigger?(Input::C)
  1104.         pbPlayDecisionSE
  1105.         # Sort (change position)
  1106.         sortTrainer(@select,@sortselect)
  1107.         @sort = false
  1108.         @process = 4
  1109.       end
  1110.        if Input.trigger?(Input::B)
  1111.         pbPlayCloseMenuSE
  1112.         namePhone
  1113.         @sort = false
  1114.       end      
  1115.     end
  1116.     # Show information
  1117.     if Input.trigger?(Input::A) && @otherfeatures
  1118.       pbPlayDecisionSE
  1119.       showInformationTrainer(true)
  1120.       @process = 11
  1121.     end
  1122.   end
  1123.  
  1124.   def choosePhoneMouse
  1125.     # Change position
  1126.     x = 462; y = [33,183]
  1127.     w = 48; h = 117
  1128.     max = @trainers.length
  1129.     if clickedMouse
  1130.       if !@sort
  1131.         pbPlayDecisionSE
  1132.         if rectMouse(x,y[0],w,h)
  1133.           @select -= 1
  1134.           @select = 0 if @select<0
  1135.           namePhone if max>=6
  1136.         elsif rectMouse(x,y[1],w,h)
  1137.           @select += 1
  1138.           @select = max-1 if @select>=max
  1139.           namePhone if max>=6
  1140.         elsif rectMouse(26,10,432,313)
  1141.           pbPlayDecisionSE
  1142.           @sortselect = @select
  1143.           # Visible
  1144.           set_visible_sprite("phone menu",true)
  1145.           set_visible_sprite("phone select",true)
  1146.           @process = 12
  1147.         end
  1148.       # Mode: sort
  1149.       else
  1150.         pbPlayDecisionSE
  1151.         if rectMouse(x,y[0],w,h)
  1152.           @sortselect -= 1
  1153.           @sortselect = 0 if @sortselect<0
  1154.           namePhone(0) if max>=6
  1155.         elsif rectMouse(x,y[1],w,h)
  1156.           @sortselect += 1
  1157.           @sortselect = max-1 if @sortselect>=max
  1158.           namePhone(0) if max>=6
  1159.         elsif rectMouse(26,10,432,313)
  1160.           # Sort (change position)
  1161.           sortTrainer(@select,@sortselect)
  1162.           @sort = false
  1163.           @process = 4
  1164.         end
  1165.       end
  1166.       # Show information
  1167.       if rectMouse(460,0,52,17)
  1168.         showInformationTrainer(true)
  1169.         @process = 11
  1170.       end
  1171.     end
  1172.   end
  1173.  
  1174.   def choosePhoneInformation
  1175.     x = 327
  1176.     y = @sprites["phone information"].y
  1177.     if Input.trigger?(Input::B) || (rectMouse(x,y,13,26) && clickedMouse)
  1178.       pbPlayCloseMenuSE
  1179.       showInformationTrainer(false)
  1180.       @process = 10
  1181.     end
  1182.   end
  1183.  
  1184.   def choosePhoneSelect
  1185.     pos = posPhoneMenu
  1186.     x = pos[0] + 8; ya = [10,58,106]
  1187.     y = (@choice==0)? pos[1] + ya[0] : (@choice==1)? pos[1] + ya[1] : pos[1] + ya[2]
  1188.     height = @sprites["phone select"].bitmap.height/3
  1189.     set_src_xy_sprite("phone select",0,height*@choice)
  1190.     set_xy_sprite("phone select",x,y)
  1191.     if Input.trigger?(Input::UP)
  1192.       @choice -= 1
  1193.       @choice = 2 if @choice<0
  1194.     end
  1195.     if Input.trigger?(Input::DOWN)
  1196.       @choice += 1
  1197.       @choice = 0 if @choice>2
  1198.     end
  1199.     if Input.trigger?(Input::C)
  1200.       pbPlayDecisionSE
  1201.       case @choice
  1202.       # Call
  1203.       when 0
  1204.         setReturnPagePhone
  1205.         if canCall
  1206.           pbCallTrainer(@trainers[@select][0],@trainers[@select][1]) # Call
  1207.           putTrainerList
  1208.           rematchIcon
  1209.         else
  1210.           pbMessage(_INTL("Got no signal."))
  1211.         end
  1212.       # Sort
  1213.       when 1
  1214.         @sort = true
  1215.         setReturnPagePhone
  1216.       else
  1217.         setReturnPagePhone
  1218.       end
  1219.     end
  1220.     setReturnPagePhone(0) if Input.trigger?(Input::B)
  1221.     # Mouse
  1222.     # Call
  1223.     if rectMouse(x,pos[1]+ya[0],272,44)
  1224.       @choice=0
  1225.       if clickedMouse
  1226.         setReturnPagePhone
  1227.         if canCall
  1228.           pbCallTrainer(@trainers[@select][0],@trainers[@select][1]) # Call
  1229.           putTrainerList
  1230.           rematchIcon
  1231.         else
  1232.           pbMessage(_INTL("Got no signal."))
  1233.         end
  1234.       end
  1235.     # Sort
  1236.     elsif rectMouse(x,pos[1]+ya[1],272,44)
  1237.       @choice=1
  1238.       if clickedMouse
  1239.         @sort = true
  1240.         setReturnPagePhone
  1241.       end
  1242.     # Quit
  1243.     elsif rectMouse(x,pos[1]+ya[2],272,44)
  1244.       @choice=2
  1245.       setReturnPagePhone(0) if clickedMouse
  1246.     end
  1247.   end
  1248.  
  1249. #-------------------------------------------------------------------------------
  1250. # SE play
  1251. #-------------------------------------------------------------------------------
  1252.   def playSEMainPage
  1253.     w = 80; h = 52
  1254.     x = []; t = 0
  1255.     5.times { x.push(25+(w+15)*t); t+=1 }
  1256.     y = SCREEN_HEIGHT - 54
  1257.     if rectMouse(x[0],y,w,h) || rectMouse(x[1],y,w,h) || rectMouse(x[2],y,w,h) ||
  1258.      rectMouse(x[3],y,w,h) || rectMouse(x[4],y,w,h)
  1259.      return true
  1260.     end
  1261.   end
  1262.  
  1263.   def xyForSE(number)
  1264.     case number
  1265.     # Customize
  1266.     when 0
  1267.       x = [46,207,367]; y = [52,210]
  1268.       w = 98; h = 89
  1269.       if rectMouse(x[0],y[0],w,h) || rectMouse(x[1],y[0],w,h) ||
  1270.         rectMouse(x[2],y[0],w,h) || rectMouse(x[0],y[1],w,h) ||
  1271.         rectMouse(x[1],y[1],w,h) || rectMouse(x[2],y[1],w,h)
  1272.         return true
  1273.       end
  1274.     # Customize (change)
  1275.     when 1
  1276.       xy = sceneChooseCustom
  1277.       x = xy[0] + 8; y = (@change)? xy[1]+10 : xy[1]+58
  1278.       w = 112; h = 44
  1279.       return true if rectMouse(x,xy[1]+10,w,h) || rectMouse(x,xy[1]+58,w,h)
  1280.     # Radio
  1281.     when 2
  1282.       x = 462; y = [33,183]
  1283.       w = 48; h = 117
  1284.       return true if rectMouse(x,y[0],w,h) || rectMouse(x,y[1],w,h) || rectMouse(26,10,432,313)
  1285.     # Phone (show information)
  1286.     when 3
  1287.       x = 327
  1288.       y = @sprites["phone information"].y
  1289.       return true if rectMouse(x,y,13,26)
  1290.     # Phone (use features)
  1291.     when 4
  1292.       pos = posPhoneMenu
  1293.       x = pos[0] + 8; y = [10,58,106]
  1294.       (0...y.length).each {|i| y[i]+=pos[1]}
  1295.       return true if rectMouse(x,y[0],272,44) || rectMouse(x,y[1],272,44) || rectMouse(x,y[2],272,44)
  1296.     end
  1297.   end
  1298.  
  1299.   def sePlayAll
  1300.     if ((@process==5 || @process==9) && playSEMainPage) || # Main page and Phone page (0 phone number)
  1301.       # Customize (control)
  1302.       (@process==6 && (playSEMainPage || xyForSE(0))) ||
  1303.       # Customize (change)
  1304.       (@process==7 && xyForSE(1)) ||
  1305.       # Radio (control)
  1306.       (@process==8 && (playSEMainPage || xyForSE(2))) ||
  1307.       # Phone (control)
  1308.       (@process==10 && (playSEMainPage || xyForSE(2) || rectMouse(460,0,52,17))) ||
  1309.       # Phone (show information)
  1310.       (@process==11 && xyForSE(3)) ||
  1311.       # Phone (use features)
  1312.       (@process==12 && xyForSE(4))
  1313.       # Play SE
  1314.       playSEMouse
  1315.     else
  1316.       @se = 0
  1317.     end
  1318.   end
  1319.  
  1320.   def playSEMouse
  1321.     @se = 1 if @se==0
  1322.     if @se==1
  1323.       @se = 2
  1324.       pbPlayDecisionSE
  1325.     end
  1326.   end
  1327. #-------------------------------------------------------------------------------
  1328. # Set bitmap
  1329. #-------------------------------------------------------------------------------
  1330.   # Image
  1331.   def create_sprite(spritename,filename,vp,dir="Pictures/Pokegear HGSS")
  1332.     @sprites["#{spritename}"] = Sprite.new(vp)
  1333.     @sprites["#{spritename}"].bitmap = Bitmap.new("Graphics/#{dir}/#{filename}")
  1334.   end
  1335.  
  1336.   # Set ox, oy
  1337.   def set_oxoy_sprite(spritename,ox,oy)
  1338.     @sprites["#{spritename}"].ox = ox
  1339.     @sprites["#{spritename}"].oy = oy
  1340.   end
  1341.  
  1342.   # Set x, y
  1343.   def set_xy_sprite(spritename,x,y)
  1344.     @sprites["#{spritename}"].x = x
  1345.     @sprites["#{spritename}"].y = y
  1346.   end
  1347.  
  1348.   # Set zoom
  1349.   def set_zoom(spritename,zoom_x,zoom_y)
  1350.     @sprites["#{spritename}"].zoom_x = zoom_x
  1351.     @sprites["#{spritename}"].zoom_y = zoom_y
  1352.   end
  1353.  
  1354.   # Set visible
  1355.   def set_visible_sprite(spritename,vsb=false)
  1356.     @sprites["#{spritename}"].visible = vsb
  1357.   end
  1358.  
  1359.   # Set angle
  1360.   def set_angle_sprite(spritename,angle)
  1361.     @sprites["#{spritename}"].angle = angle
  1362.   end
  1363.  
  1364.   # Set src
  1365.   def set_src_wh_sprite(spritename,w,h)
  1366.     @sprites["#{spritename}"].src_rect.width = w
  1367.     @sprites["#{spritename}"].src_rect.height = h
  1368.   end
  1369.  
  1370.   def set_src_xy_sprite(spritename,x,y)
  1371.     @sprites["#{spritename}"].src_rect.x = x
  1372.     @sprites["#{spritename}"].src_rect.y = y
  1373.   end
  1374. #-------------------------------------------------------------------------------
  1375. # Text
  1376. #-------------------------------------------------------------------------------
  1377.   # Draw
  1378.   def create_sprite_2(spritename,vp)
  1379.     @sprites["#{spritename}"] = Sprite.new(vp)
  1380.     @sprites["#{spritename}"].bitmap = Bitmap.new(Graphics.width,Graphics.height)
  1381.   end
  1382.  
  1383.   # Write
  1384.   BaseColor = Color.new(255,255,255)
  1385.   ShadowColor = Color.new(0,0,0)
  1386.   def drawTxt(bitmap,x,y,width,height,string,font=nil,fontsize=26,align=0,nclear=false,bcolor=BaseColor,scolor=ShadowColor)
  1387.     # Sprite
  1388.     bitmap = @sprites["#{bitmap}"].bitmap
  1389.     bitmap.clear if !nclear
  1390.     # Set font, size
  1391.     (font!=nil)? (bitmap.font.name=font) : pbSetSystemFont(bitmap)
  1392.     bitmap.font.size = fontsize
  1393.     pbDrawOutlineText(bitmap, # Bitmap
  1394.     x,y,width,height, # Position
  1395.     _INTL("#{string}"), # Title
  1396.     bcolor,scolor, # Color
  1397.     align) # Align
  1398.   end
  1399.  
  1400.   # Clear
  1401.   def clearTxt(bitmap)
  1402.     @sprites["#{bitmap}"].bitmap.clear
  1403.   end
  1404. #-------------------------------------------------------------------------------
  1405. # Icon
  1406. #-------------------------------------------------------------------------------
  1407.   def create_sprite_3(spritename,x,y,filename,vp,dir="Pictures")
  1408.     @sprites["#{spritename}"] = IconSprite.new(x,y,vp)
  1409.     @sprites["#{spritename}"].setBitmap("Graphics/#{dir}/#{filename}")
  1410.   end
  1411.  
  1412. #-------------------------------------------------------------------------------
  1413. # Mouse
  1414. #-------------------------------------------------------------------------------
  1415.   def rectMouse(x,y,w,h)
  1416.     rect = [x,w+x,y,h+y]
  1417.     mouse = Mouse::getMousePos
  1418.     mouse = [0,0] if !mouse
  1419.     if mouse[0]>=rect[0] && mouse[0]<= rect[1] &&
  1420.       mouse[1]>=rect[2] && mouse[1]<= rect[3]
  1421.       return true
  1422.     end
  1423.     return false
  1424.   end
  1425.  
  1426.   def clickedMouse
  1427.     return true if Input.triggerex?(Input::RightMouseKey) || Input.triggerex?(Input::LeftMouseKey)
  1428.     return false
  1429.   end
  1430. #-------------------------------------------------------------------------------
  1431. #-------------------------------------------------------------------------------
  1432.   def dispose(id=nil)
  1433.     (!id)? pbDisposeSprite(@sprites,id) : pbDisposeSpriteHash(@sprites)
  1434.   end
  1435.  
  1436.   def update_ingame
  1437.     Graphics.update
  1438.     Input.update
  1439.     pbUpdateSpriteHash(@sprites)
  1440.   end
  1441.  
  1442.   def endScene
  1443.     # End
  1444.     dispose
  1445.     @viewport.dispose
  1446.     @viewport1.dispose
  1447.     @viewport2.dispose
  1448.   end
  1449. end
  1450. #-------------------------------------------------------------------------------
  1451. class PokemonPokegearScreen
  1452.   def initialize(scene)
  1453.     @scene = scene
  1454.   end
  1455.  
  1456.   def pbStartScreen
  1457.     @scene.start
  1458.   end
  1459. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×