Advertisement
diamondandplatinum3

Common Event: Menu Options ~ RGSS3

Dec 10th, 2012
1,426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.11 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Common Event: Menu Options
  3. #             Author: DiamondandPlatinum3
  4. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. #  Description:
  6. #
  7. #    This script will allow you to put options in the menu that will run a
  8. #    common event if selected, it also has the option of being disabled with
  9. #    an event switch.
  10. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. module DiamondandPlatinum3
  12.   module Common_Event_Menu_Option
  13.     #=======================================================
  14.     #     Editable Region
  15.     #=======================================================
  16.    
  17.     # Option Label    : The Custom Text that will appear for your menu option
  18.     # Event Switch ID : Only if this Event Switch is Activated will the option be enabled,
  19.     #                   You may keep the option always enabled by setting this to zero,
  20.     # Common Event ID : The Common Event to Call when this option is selected
  21.    
  22.     CUSTOM_OPTIONS =
  23.     {
  24.    
  25.     # "Option Label"  => [ Event Switch ID, Common Event ID ],
  26.    
  27.       "World Map"     => [    10,                   2       ],
  28.       "Party Chat"    => [    0,                   12       ],
  29.      
  30.     # You can add more options above this line be sure it looks the same as the others
  31.     }
  32.  
  33.   #=======================================================
  34.   end # of Editable region
  35.   #=======================================================
  36. end
  37.  
  38.  
  39.  
  40. #==============================================================================
  41. # ** Window_MenuCommand
  42. #------------------------------------------------------------------------------
  43. #  This command window appears on the menu screen.
  44. #==============================================================================
  45.  
  46. class Window_MenuCommand < Window_Command
  47.   #--------------------------------------------------------------------------
  48.   # * Aliased Method: For Adding Original Commands
  49.   #--------------------------------------------------------------------------
  50.   alias dp3_windowmenucommand_addoriginalcommands_134hfn      add_original_commands
  51.   #--------------------------------------------------------------------------
  52.   def add_original_commands
  53.     # Call Original Method
  54.     dp3_windowmenucommand_addoriginalcommands_134hfn()
  55.    
  56.     DiamondandPlatinum3::Common_Event_Menu_Option::CUSTOM_OPTIONS.each_key do |label|
  57.       switch_id = DiamondandPlatinum3::Common_Event_Menu_Option::CUSTOM_OPTIONS[label][0]
  58.       enabled   = (switch_id > 0) ? $game_switches[switch_id] : true
  59.       add_command(label, label.to_sym, enabled)
  60.     end
  61.   end
  62. end
  63.  
  64.  
  65.  
  66.  
  67. #==============================================================================
  68. # ** Scene_Menu
  69. #------------------------------------------------------------------------------
  70. #  This class performs the menu screen processing.
  71. #==============================================================================
  72.  
  73. class Scene_Menu < Scene_MenuBase
  74.   #--------------------------------------------------------------------------
  75.   # * Create Command Window
  76.   #--------------------------------------------------------------------------
  77.   alias dp3_scenemenu_createcommandwindow_134hfn      create_command_window
  78.   #--------------------------------------------------------------------------
  79.   def create_command_window
  80.     # Run Original Method
  81.     dp3_scenemenu_createcommandwindow_134hfn()
  82.    
  83.     DiamondandPlatinum3::Common_Event_Menu_Option::CUSTOM_OPTIONS.each_key do |label|
  84.       @command_window.set_handler(label.to_sym, method(:dp3_common_event_menu_option))
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # * New Method: Common Event Menu Option
  89.   #--------------------------------------------------------------------------
  90.   def dp3_common_event_menu_option
  91.     key = @command_window.current_symbol.to_s
  92.     $game_temp.reserve_common_event( DiamondandPlatinum3::Common_Event_Menu_Option::CUSTOM_OPTIONS[key][1] )
  93.     SceneManager.call(Scene_Map)
  94.   end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement