Advertisement
TheSixth

Show Image Menu Command Button

Nov 14th, 2016
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.02 KB | None | 0 0
  1. =begin
  2.  
  3. A snippet to make a menu command button that shows an image when selected.
  4.  
  5. Made by: Sixth
  6.  
  7. =end
  8.  
  9. module MenuPic
  10.  
  11.   Pic = {
  12.     :folder => "Graphics/Pictures/", # Folder where the image is.
  13.     :img => "gameback2",             # Name of the image.
  14.     :pos => [0,0],                   # Position of the image.
  15.     :z => 500,                       # Z level of the image.
  16.   }
  17.  
  18.   Command = {
  19.     :index => 5,           # Position of the command button.
  20.     :name => "Parameters", # Name of the command button.
  21.     :show => 0,            # Show switch ID. 0 = always enabled.
  22.     :enable => 0,          # Enable switch ID. 0 = always enabled.
  23.   }
  24.  
  25. end
  26.  
  27. # End of settings!
  28.  
  29. module Cache
  30.  
  31.   def self.custom_imgs(filename,folder)
  32.     load_bitmap(folder,filename)
  33.   end
  34.  
  35. end
  36.  
  37. class Window_MenuCommand < Window_Command
  38.  
  39.   alias add_pic_cmd1112 make_command_list
  40.   def make_command_list
  41.     add_pic_cmd1112
  42.     return unless check_bool(MenuPic::Command[:show])
  43.     cmd_data = {
  44.       :name => MenuPic::Command[:name],
  45.       :symbol=> :show_pic,
  46.       :enabled => check_bool(MenuPic::Command[:enable]),
  47.       :ext => MenuPic::Pic,
  48.     }
  49.     @list.insert(MenuPic::Command[:index],cmd_data)
  50.   end
  51.  
  52.   def check_bool(data)
  53.     case data
  54.     when Integer
  55.       return data == 0 || $game_switches[data]
  56.     else
  57.       return data
  58.     end
  59.   end
  60.  
  61. end
  62.  
  63. class Scene_Menu < Scene_MenuBase
  64.  
  65.   alias add_pic_funct5588 create_command_window
  66.   def create_command_window
  67.     add_pic_funct5588
  68.     @command_window.set_handler(:show_pic, method(:trigger_show_pic))
  69.   end
  70.    
  71.   def trigger_show_pic
  72.     data = @command_window.current_ext
  73.     pic = Sprite.new
  74.     pic.bitmap = Cache.custom_imgs(data[:img],data[:folder])
  75.     pic.x = data[:pos][0]
  76.     pic.y = data[:pos][1]
  77.     pic.z = data[:z]
  78.     until Input.trigger?(:C) || Input.trigger?(:B)
  79.       update
  80.     end
  81.     Sound.play_ok
  82.     pic.bitmap.dispose
  83.     pic.dispose
  84.     @command_window.activate
  85.   end
  86.  
  87. end
  88.  
  89. # End of script!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement