Advertisement
TheSixth

Image Grid Menu - Main Menu Command Addon by Sixth

Mar 4th, 2016
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.19 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Image Grid Menu - Main Menu Command Addon
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.0
  6. # * Updated: 04/03/2016
  7. # * Requires: Sixth's Image Grid Menu
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (04/03/2016)
  12. #   - Initial release.
  13. #-------------------------------------------------------------------------------
  14. # * < Description >
  15. #-------------------------------------------------------------------------------
  16. # * This addon will let you add your new image grid menus to your main menu
  17. #   commands, so the player can easily open these menus from the main menu.
  18. #-------------------------------------------------------------------------------
  19. # * < Installation >
  20. #-------------------------------------------------------------------------------
  21. # * Place this script below my Image Grid Menu script!
  22. # * This must be below all grid menu module settings (if you use more)!
  23. #-------------------------------------------------------------------------------
  24. # * < Compatibility Info >
  25. #-------------------------------------------------------------------------------
  26. # * No known incompatibilities.
  27. #-------------------------------------------------------------------------------
  28. # * < Known Issues >
  29. #-------------------------------------------------------------------------------
  30. # * No known issues.
  31. #-------------------------------------------------------------------------------
  32. # * < Terms of Use >
  33. #-------------------------------------------------------------------------------
  34. # * Free to use for whatever purposes you want.
  35. # * Credit me (Sixth) in your game, pretty please! :P
  36. # * Posting modified versions of this script is allowed as long as you notice me
  37. #   about it with a link to it!
  38. #===============================================================================
  39. $imported = {} if $imported.nil?
  40. $imported["SixthImgGridMenuButtons"] = true
  41. #===============================================================================
  42. # Settings:
  43. #===============================================================================
  44. module GridMenuCommands
  45.   #-----------------------------------------------------------------------------
  46.   # Command Settings:
  47.   #-----------------------------------------------------------------------------
  48.   # This is where you can set up your new main menu buttons for your grid menus.
  49.   # Surprisingly, this is a short little settings area. o.o
  50.   # You can add as many main menu buttons as you want here, and all of them can
  51.   # call a different grid menu!
  52.   #
  53.   # Format:
  54.   #
  55.   #   "Command Name" => {
  56.   #     :index => number, :module => Module_Name,
  57.   #     :enable => enable_setting, :show => show_setting,
  58.   #   },
  59.   #
  60.   # Details:
  61.   #
  62.   #   "Command Name" => { *settings inside* },
  63.   # The "Command Name" will be the text displayed for your command button in the
  64.   # main menu. Make sure that there are no duplicates in the settings!
  65.   #
  66.   #   :index => number,
  67.   # This determines where exactly the button will appear on the main command
  68.   # list. 0 means the 1st command, 1 means the 2nd command, and so on.
  69.   #
  70.   #   :enable => enable_setting,
  71.   # This uses the same format and options like the :enable setting in the
  72.   # Image Grid Menu script. You got the same options, so you can set it to:
  73.   # 1. An integer number. That number will be the ID of the switch will have to
  74.   #    be turned ON in order for the command to be enabled.
  75.   # 2. A symbol. The symbol will be the name of the method called. The result
  76.   #    of the method will decide if the command is enabled or not.
  77.   # 3. A string. The string will be a valid ruby code which will be evaluated.
  78.   #    the result will decide if the command is enabled or not.
  79.   # 4. An array. The array's first element will be the name of the method called
  80.   #    and the second element will be another array containing the method's
  81.   #    arguments. The arguments are evaluated in this module, so they will all
  82.   #    be static arguments! The result of the method will decide if the command
  83.   #    will be enabled or not.
  84.   # 5. A boolean value. This means either true or false. If you set it to true,
  85.   #    the command will always be enabled, and if you set it to false, it will
  86.   #    always be disabled. Not much point in the latter, but it's there. :P
  87.   # The methods and codes in option 2, 3 and 4 will be evaluated in the
  88.   # Window_MenuCommand class!
  89.   #
  90.   #   :show => show_setting,
  91.   # This is the same as the above :enable setting, but this will decide if the
  92.   # command will show up on the list or not.
  93.   # Got the same layout and options as the :enable setting.
  94.   #
  95.   #   :module => Module_Name,
  96.   # This is the name of the module which contains your image grid menu settings.
  97.   # This will decide which grid menu will be called, which means that you can
  98.   # add a main menu button for all of your grid menus if you want.
  99.   # Only use valid module names which contain grid menu settings!
  100.   # The default grid menu uses the module named SGridMenu.
  101.   #-----------------------------------------------------------------------------
  102.   MainCmds = {
  103.     "Stage Selection" => {
  104.       :index => 5, :enable => true, :show => true, :module => SGridMenu,
  105.     },
  106.     # Add more main menu command settings here for your grid menus!
  107.   }
  108.  
  109. end
  110. #===============================================================================
  111. # End of settings! Editing anything below may lead to... you know it, right? o.o
  112. #===============================================================================
  113.  
  114. class Window_MenuCommand < Window_Command
  115.  
  116.   alias add_grid_menu_buttons8262 make_command_list
  117.   def make_command_list
  118.     add_grid_menu_buttons8262
  119.     insert_grid_buttons
  120.   end
  121.  
  122.   def insert_grid_buttons
  123.     GridMenuCommands::MainCmds.each do |key,dt|
  124.       next unless check_cmd(dt,:show)
  125.       ccmd = {
  126.         :name => key,
  127.         :symbol => :grid,
  128.         :enabled => check_cmd(dt,:enable),
  129.         :ext => dt[:module]
  130.       }
  131.       ix = dt[:index]
  132.       @list.insert(ix,ccmd)
  133.     end
  134.   end
  135.    
  136.   def check_cmd(dt,type)
  137.     case dt[type]
  138.     when Integer
  139.       return $game_switches[dt[type]]
  140.     when Symbol
  141.       return method(dt[type]).call
  142.     when Array
  143.       return method(dt[type][0]).call(*dt[type][1])
  144.     when String
  145.       return eval(dt[type])
  146.     else
  147.       return dt[type]
  148.     end
  149.   end
  150.  
  151. end
  152.  
  153. class Scene_Menu < Scene_MenuBase
  154.  
  155.   alias add_grid_menu_calls9764 create_command_window
  156.   def create_command_window
  157.     add_grid_menu_calls9764
  158.     @command_window.set_handler(:grid, method(:call_grid_menu))
  159.   end
  160.  
  161.   def call_grid_menu
  162.     SceneManager.call(Grid_Menu)
  163.     SceneManager.scene.prepare(@command_window.current_ext)
  164.   end
  165.    
  166. end
  167. #==============================================================================
  168. # !!END OF SCRIPT - OHH, NOES!!
  169. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement