Advertisement
TechSkylander1518

bo4p5687's HGSS Menu for Honor/Glory

May 22nd, 2021 (edited)
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.99 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # HGSS PauseMenu
  3. # Credit: bo4p5687, graphics by Richard PT
  4. #-------------------------------------------------------------------------------
  5. PluginManager.register({
  6.   :name    => "HGSS_PauseMenu",
  7.   :credits => ["bo4p5687", "graphics by Richard PT"]
  8. })
  9. #-------------------------------------------------------------------------------
  10. class HGSS_PauseMenu
  11.  
  12.   def initialize
  13.     @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
  14.     @viewport.z = 99999
  15.     @sprites = {}
  16.     # Scene
  17.     @sprites["scene"] = Sprite.new(@viewport)
  18.     @sprites["scene"].bitmap = Bitmap.new("Graphics/Pictures/HGSSPauseMenu/hgsspausemenubg")
  19.     # Choose bar
  20.     @sprites["select"] = Sprite.new(@viewport)
  21.     @sprites["select"].bitmap = Bitmap.new("Graphics/Pictures/HGSSPauseMenu/select")
  22.     # Ball (Overlay)
  23.     (1..3).each{|i|
  24.     @sprites["b#{i}"] = Sprite.new(@viewport)
  25.     @sprites["b#{i}"].bitmap = Bitmap.new(Graphics.width, Graphics.height)}
  26.     # Set x_y (12)
  27.     create_xy_arr
  28.     # Position
  29.     @position = 0
  30.     # Exit
  31.     @exit = false
  32.   end
  33. #-------------------------------------------------------------------------------
  34. #-------------------------------------------------------------------------------
  35.   def loop_pause_menu
  36.     if !$Trainer
  37.       if $DEBUG
  38.         pbMessage(_INTL("The player trainer was not defined, so the pause menu can't be displayed."))
  39.         pbMessage(_INTL("Please see the documentation to learn how to set up the trainer player."))
  40.       end
  41.       return
  42.     end
  43.     # Check pokedex
  44.     pbSEPlay("GUI menu open")
  45.     # Create
  46.     push_option
  47.     set_option
  48.     # Position
  49.     set_position_img
  50.     return if @option.size == 0
  51.     # Loop
  52.     loop do
  53.       break if @exit
  54.       # Update
  55.       update_ingame
  56.       # Set position
  57.       set_position_p
  58.       # Input
  59.       if Input.trigger?(Input::DOWN)
  60.         pbPlayCursorSE
  61.         @position += 1
  62.         @position = 0 if @position >= (@option.size)
  63.       end
  64.       if Input.trigger?(Input::UP)
  65.         pbPlayCursorSE
  66.         @position -= 1
  67.         @position = (@option.size-1) if @position < 0
  68.       end
  69.       if Input.trigger?(Input::RIGHT)
  70.         pbPlayCursorSE
  71.         @position += 3
  72.         @position = 0 if @position >= @option.size
  73.       end
  74.       if Input.trigger?(Input::LEFT)
  75.         pbPlayCursorSE
  76.         @position -= 3
  77.         if @position <= (-3)
  78.           @position = (@option.size-1)
  79.         elsif @position==(-1) || @position==(-2)
  80.           @position+=((@position+11) < @option.size)? 11 : ((@position+8) < @option.size)? 8 : ((@position+5) < @option.size)? 5 : 2
  81.         end
  82.       end
  83.       if Input.trigger?(Input::C) || $mouse && $mouse.click?
  84.         pbPlayCursorSE
  85.         # Play
  86.         position_option
  87.       end
  88.       if Input.trigger?(Input::B)
  89.         pbPlayCursorSE
  90.         # Exit
  91.         @exit = true
  92.       end
  93.     end
  94.     # Dispose
  95.     pbEndScene
  96.   end
  97. #-------------------------------------------------------------------------------
  98. #-------------------------------------------------------------------------------
  99.   def create_sprite(spritename,filename)
  100.     @sprites["#{spritename}"] = Sprite.new(@viewport)
  101.     @sprites["#{spritename}"].bitmap = Bitmap.new("Graphics/Pictures/HGSSPauseMenu/#{filename}")
  102.   end
  103.  
  104.   def create_sprite_2(spritename)
  105.     @sprites["#{spritename}"] = Sprite.new(@viewport)
  106.     @sprites["#{spritename}"].bitmap = Bitmap.new(Graphics.width, Graphics.height)
  107.   end
  108.  
  109.   def create_xy_arr
  110.     @xyarr = []
  111.     (0...20).each{|i| @xyarr.push([0,0])}
  112.     (0...@xyarr.size).each{ |i|
  113.     if (i%3)==0
  114.       @xyarr[i][0] = (i==0)? 27 : 27+122*((i%4-4).abs)
  115.       @xyarr[i][1] = 60
  116.     elsif (i%3)==1
  117.       @xyarr[i][0] = ((i%4)==2)? 27+122*((i%4+1).abs) : 27+122*((i%4-1).abs)
  118.       @xyarr[i][1] = 60+100
  119.     elsif (i%3)==2
  120.       @xyarr[i][0] = ((i%4)==3)? 27+122*((i%4).abs) : 27+122*((i%4-2).abs)
  121.       @xyarr[i][1] = 60+100*2
  122.     end }
  123.   end
  124.  
  125.   def set_visible(spritename,vsb=false)
  126.     @sprites["#{spritename}"].visible = vsb
  127.   end
  128. #-------------------------------------------------------------------------------
  129.   def draw_text(bitmap,name,x,y,ball=false)
  130.     # Color
  131.     basecolor = Color.new(255,255,255)
  132.     shadowcolor = Color.new(0,0,0)
  133.     # Sprite
  134.     bitmap = @sprites["#{bitmap}"].bitmap
  135.     bitmap.clear
  136.     text = []
  137.     # Text
  138.     text.push([_INTL("#{name}"),x,y,3,basecolor,shadowcolor])
  139.     pbSetSystemFont(bitmap)
  140.    # bitmap.font.size = 23
  141.    # bitmap.font.name = "Arial"
  142.     pbDrawTextPositions(bitmap,text)
  143.   end
  144.  
  145.   def clear_text(bitmap)
  146.     bitmap = @sprites["#{bitmap}"].bitmap
  147.     bitmap.clear
  148.   end
  149. #-------------------------------------------------------------------------------
  150. #-------------------------------------------------------------------------------
  151.   def push_option
  152.     # Option
  153.     @option = []
  154.     # Retire, pokedex, pokemon, bag          (0,1,2,3)
  155.     # pokegear, pokenav, name, save, option  (4,5,6,7,8)
  156.     # control, debug, quit, ball             (9,10,11,12)
  157.     # Name sprite, bitmap, number, title
  158.     # Retire
  159.     a = ["retire","retireicon",0,"RETIRE"]
  160.     # Pokedex
  161.     b = ["pokedex","pokedexicon",1,"POKéDEX"]
  162.     # Pokemon
  163.     c = ["pokemon","pokemonicon",2,"POKéMON"]
  164.     # Bag
  165.     d = ["bag","bagicon",3,"BAG"]
  166.     # Pokegear
  167.     e = ["pokegear","pokegearicon",4,"POKéGEAR"]
  168.     # Pokenav
  169.     f = ["pokenav","pokenavicon",5,"POKéNAV"]
  170.     # Trainer card
  171.     tname = $Trainer.name
  172.     g = ["name","trainercardicon",6,"#{$Trainer.name}"]
  173.     # Save
  174.     h = ["save","savegameicon",7,"SAVE"]
  175.     # Option
  176.     i = ["option","optionsicon",8,"OPTIONS"]
  177.     # Debug
  178.     j = ["debug","debugicon",9,"DEBUG"]
  179.     # Quit
  180.     k = ["quit","quitgameicon",10,"QUIT"]
  181.     # Ball
  182.     l = ["ball","",11,""]
  183.     @option.push(a,b,c,d,e,f,g,h,i,j,k,l)
  184.     # Delete (check)
  185.     # Retire
  186.     @option.delete(a) if !pbInSafari? && !pbInBugContest?
  187.     # Pokedex
  188.     @option.delete(b) if !$Trainer.has_pokedex && $Trainer.pokedex.accessible_dexes.length == 0
  189.     # Pokemon
  190.     @option.delete(c) if $Trainer.party.length <= 0
  191.     # Bag
  192.     @option.delete(d) if pbInBugContest?
  193.     # Pokegear
  194.     @option.delete(e) if !$Trainer.has_pokegear
  195.     # Save
  196.     @option.delete(h) if !$game_system || $game_system.save_disabled || pbInSafari? || pbInBugContest?
  197.     # Debug
  198.     @option.delete(j) if !$DEBUG
  199.     # Quit
  200.     @option.delete(k) if pbInBugContest? || pbInSafari?
  201.     # Ball
  202.     @option.delete(l) if !pbInBugContest? && !pbInSafari?
  203.   end
  204. #-------------------------------------------------------------------------------
  205. #-------------------------------------------------------------------------------
  206.   def set_option
  207.     (0...@option.size).each{|i|
  208.     if @option[i][2] != 12
  209.       create_sprite(@option[i][0],@option[i][1])
  210.       create_sprite_2("#{i}")
  211.     end }
  212.     ball = nil
  213.     if pbInSafari?
  214.       ball = getConst(PBItems,:SAFARIBALL)
  215.     # Safari Zone/Bug Contest
  216.     elsif pbInBugContest?
  217.       ball = getConst(PBItems,:SPORTBALL)
  218.     end
  219.     if ball != nil
  220.       filename = sprintf("%s",ball) rescue nil
  221.       filename = sprintf("item%03d",ball) if !pbResolveBitmap("Graphics/Icons/#{filename}")
  222.       @sprites["ball"] = Sprite.new(@viewport)
  223.       @sprites["ball"].bitmap = Bitmap.new("Graphics/Icons/#{filename}")
  224.     end
  225.   end
  226.  
  227.   # Position (images)
  228.   def set_position_img
  229.     (0...@option.size).each{|i|
  230.     if @option[i][2] == 12
  231.       @sprites[@option[i][0]].x = @xyarr[i][0] + 20
  232.       @sprites[@option[i][0]].y = @xyarr[i][1] - 5
  233.       draw_ball_text(@xyarr[i][0]+20,@xyarr[i][1]-5)
  234.     else
  235.       @sprites[@option[i][0]].x = @xyarr[i][0]
  236.       @sprites[@option[i][0]].y = @xyarr[i][1]
  237.       if @option[i][3].length<=4
  238.         draw_text("#{i}",@option[i][3],@xyarr[i][0]+15,@xyarr[i][1]+62)
  239.       elsif @option[i][3].length==5
  240.         draw_text("#{i}",@option[i][3],@xyarr[i][0]+10,@xyarr[i][1]+62)
  241.       elsif @option[i][3].length==6
  242.         draw_text("#{i}",@option[i][3],@xyarr[i][0],@xyarr[i][1]+62)
  243.       else
  244.         draw_text("#{i}",@option[i][3],@xyarr[i][0]-8,@xyarr[i][1]+62)
  245.       end
  246.     end }
  247.   end
  248.  
  249.   # Position (select)
  250.   def set_position_p
  251.     # Mouse
  252.     if $mouse
  253.       (0...@option.size).each{|i|
  254.       if i != @position && $mouse.inArea?(@xyarr[i][0],@xyarr[i][1],80,52)
  255.         pbPlayCursorSE
  256.         @position = i  
  257.       end}
  258.     end
  259.     if @option[@position][2] == 12
  260.       @sprites["select"].zoom_x = 0.5
  261.       @sprites["select"].zoom_y = 0.75
  262.       @sprites["select"].x = @sprites[@option[@position][0]].x
  263.       @sprites["select"].y = @sprites[@option[@position][0]].y-2
  264.     else
  265.       @sprites["select"].zoom_x = 1
  266.       @sprites["select"].zoom_y = 1
  267.       @sprites["select"].x = @sprites[@option[@position][0]].x-8
  268.       @sprites["select"].y = @sprites[@option[@position][0]].y-8
  269.     end
  270.   end
  271.  
  272.   def draw_ball_text(x,y)
  273.     if pbInSafari?
  274.       if SAFARI_STEPS<=0
  275.         draw_text("b1","Balls: #{pbSafariState.ballcount}",
  276.           x-15,y+55,true)
  277.       else
  278.         ball = pbSafariState.ballcount
  279.         s_f = pbSafariState.steps
  280.         s_p = SAFARI_STEPS
  281.         draw_text("b1","Balls: #{ball}",
  282.           x-15,y+55,true)
  283.         draw_text("b2","Steps: #{s_f}/#{s_p}",
  284.           x-50,y+75,true)
  285.       end
  286.     elsif pbInBugContest?
  287.       if pbBugContestState.lastPokemon
  288.         ball = pbBugContestState.ballcount
  289.         cg = PBSpecies.getName(pbBugContestState.lastPokemon.species)
  290.         lv = pbBugContestState.lastPokemon.level
  291.         draw_text("b1","Balls: #{ball}",
  292.           x-15,y+55,true)
  293.         draw_text("b2","Caught: #{cg}",
  294.           x-30,y+75,true)
  295.         draw_text("b3","Level: #{lv}",
  296.           x-30,y+95,true)
  297.       else
  298.         ball = pbBugContestState.ballcount
  299.         draw_text("b1","Balls: #{ball}",
  300.           x-15,y+55,true)
  301.         draw_text("b2","Caught: None",
  302.           x-30,y+75,true)
  303.       end
  304.     end
  305.   end
  306.  
  307.   # Set visible (menu)
  308.   def hide_menu
  309.     (0...@option.size).each{|i|
  310.     set_visible(@option[i][0])
  311.     @sprites["ball"].visible = false if @option[i][2] == 12 && @sprites["ball"]
  312.     clear_text("#{i}") if @option[i][2] != 12}
  313.     (1..3).each{|i| @sprites["b#{i}"].bitmap.clear}
  314.     set_visible("scene"); set_visible("select")
  315.   end
  316.  
  317.   def show_menu
  318.     (0...@option.size).each{|i|
  319.     set_visible(@option[i][0],true)
  320.     @sprites["ball"].visible = true if @option[i][2] == 12 && @sprites["ball"]
  321.     if @option[i][2] == 12
  322.       draw_ball_text(@xyarr[i][0]+20,@xyarr[i][1]-5)
  323.     else
  324.       if @option[i][3].length<=4
  325.         draw_text(i,@option[i][3],@xyarr[i][0]+15,@xyarr[i][1]+62)
  326.       elsif @option[i][3].length==5
  327.         draw_text(i,@option[i][3],@xyarr[i][0]+10,@xyarr[i][1]+62)
  328.       elsif @option[i][3].length==6
  329.         draw_text(i,@option[i][3],@xyarr[i][0],@xyarr[i][1]+62)
  330.       else
  331.         draw_text(i,@option[i][3],@xyarr[i][0]-8,@xyarr[i][1]+62)
  332.       end
  333.     end }
  334.     set_visible("scene",true); set_visible("select",true)
  335.   end
  336. #-------------------------------------------------------------------------------
  337. #-------------------------------------------------------------------------------
  338.   # Input C
  339.   def position_option
  340.     # Retire event
  341.     if @option[@position][2] == 0
  342.       # Hide
  343.       hide_menu
  344.       # Safari
  345.       if pbInSafari?
  346.         if pbConfirmMessage(_INTL("Would you like to leave the Safari Game right now?"))
  347.           pbSafariState.decision = 1
  348.           pbSafariState.pbGoToStart
  349.           @exit = true
  350.         else
  351.           # Show
  352.           show_menu
  353.         end
  354.       # Bug Contest
  355.       elsif pbInBugContest?
  356.         if pbConfirmMessage(_INTL("Would you like to end the Contest now?"))
  357.           pbBugContestState.pbStartJudging
  358.           @exit = true
  359.         else
  360.           # Show
  361.           show_menu
  362.         end
  363.       end
  364.     # Pokedex
  365.     elsif @option[@position][2] == 1
  366.         if Settings::USE_CURRENT_REGION_DEX
  367.           pbFadeOutIn {
  368.             scene = PokemonPokedex_Scene.new
  369.             screen = PokemonPokedexScreen.new(scene)
  370.             screen.pbStartScreen
  371.           }
  372.         else
  373.           if $Trainer.pokedex.accessible_dexes.length == 1
  374.             $PokemonGlobal.pokedexDex = $Trainer.pokedex.accessible_dexes[0]
  375.             pbFadeOutIn {
  376.               scene = PokemonPokedex_Scene.new
  377.               screen = PokemonPokedexScreen.new(scene)
  378.               screen.pbStartScreen
  379.             }
  380.           else
  381.             pbFadeOutIn {
  382.               scene = PokemonPokedexMenu_Scene.new
  383.               screen = PokemonPokedexMenuScreen.new(scene)
  384.               screen.pbStartScreen
  385.             }
  386.           end
  387.         end
  388.     # Pokemon
  389.     elsif @option[@position][2] == 2
  390.       hiddenmove = nil
  391.       pbFadeOutIn {
  392.         sscene = PokemonParty_Scene.new
  393.         sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  394.         hiddenmove = sscreen.pbPokemonScreen
  395.         pbEndScene if hiddenmove
  396.       }
  397.       if hiddenmove
  398.         $game_temp.in_menu = false
  399.         pbUseHiddenMove(hiddenmove[0],hiddenmove[1])
  400.         @exit = true
  401.       end
  402.     # Bag
  403.     elsif @option[@position][2] == 3
  404.         item = nil
  405.         pbFadeOutIn {
  406.           scene = PokemonBag_Scene.new
  407.           screen = PokemonBagScreen.new(scene,$PokemonBag)
  408.           item = screen.pbStartScreen
  409.         }
  410.         if item
  411.           $game_temp.in_menu = false
  412.           pbUseKeyItemInField(item)
  413.           return
  414.         end
  415.     # Pokegear
  416.     elsif @option[@position][2] == 4
  417.       pbFadeOutIn {
  418.         scene = PokemonPokegear_Scene.new
  419.         screen = PokemonPokegearScreen.new(scene)
  420.         screen.pbStartScreen }
  421.     # Pokenav
  422.     elsif @option[@position][2] == 5
  423.      
  424.     # Trainer Card
  425.     elsif @option[@position][2] == 6
  426.       pbFadeOutIn {
  427.         scene = PokemonTrainerCard_Scene.new
  428.         screen = PokemonTrainerCardScreen.new(scene)
  429.         screen.pbStartScreen }
  430.     # Save
  431.     elsif @option[@position][2] == 7
  432.       # Hide
  433.       hide_menu
  434.       scene = PokemonSave_Scene.new
  435.       screen = PokemonSaveScreen.new(scene)
  436.       if screen.pbSaveScreen
  437.         @exit = true
  438.       else
  439.         # Show
  440.         show_menu
  441.       end
  442.     # Option
  443.     elsif @option[@position][2] == 8
  444.       pbFadeOutIn {
  445.         scene = PokemonOption_Scene.new
  446.         screen = PokemonOptionScreen.new(scene)
  447.         screen.pbStartScreen
  448.         pbUpdateSceneMap }
  449.     # Debug
  450.     elsif @option[@position][2] == 9
  451.       pbFadeOutIn { pbDebugMenu }
  452.     # Quit
  453.     elsif @option[@position][2] == 10
  454.       # Hide
  455.       hide_menu
  456.       if pbConfirmMessage(_INTL("Are you sure you want to quit the game?"))
  457.         scene = PokemonSave_Scene.new
  458.         screen = PokemonSaveScreen.new(scene)
  459.         screen.pbSaveScreen
  460.         @exit = true
  461.         $scene=nil
  462.       else
  463.         # Show
  464.         show_menu
  465.       end
  466.     end
  467.   end
  468. #-------------------------------------------------------------------------------
  469. #-------------------------------------------------------------------------------
  470. #-------------------------------------------------------------------------------
  471.   def update_ingame
  472.     Graphics.update
  473.     Input.update
  474.     pbUpdateSpriteHash(@sprites)
  475.     pbUpdateSceneMap
  476.   end
  477.  
  478.   def pbEndScene
  479.     pbDisposeSpriteHash(@sprites)
  480.     @viewport.dispose
  481.   end
  482.  
  483. end
  484. #-------------------------------------------------------------------------------
  485. #-------------------------------------------------------------------------------
  486. #-------------------------------------------------------------------------------
  487. def pbPauseMenu
  488.   p = HGSS_PauseMenu.new
  489.   p.loop_pause_menu
  490. end
  491. #-------------------------------------------------------------------------------
  492. class Scene_Map
  493.   def call_menu
  494.     $game_temp.menu_calling = false
  495.     $game_temp.in_menu = true
  496.     $game_player.straighten
  497.     $game_map.update
  498.     # HGSS Pause Menu
  499.     pbPauseMenu
  500.     $game_temp.in_menu = false
  501.   end
  502. end
  503. #-------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement