Advertisement
AngryPacman

[VXA] PAC Main Menu Ace

Jul 11th, 2012
5,808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.52 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # PAC Main Menu Ace (1.2)
  4. # 15/7/2012
  5. # By Pacman
  6. #
  7. #===============================================================================
  8. #
  9. # This is the PAC Main Menu converted to VX Ace. On a basic level, this offers
  10. # a configurable setup for your main menu, allowing the user to create, alter
  11. # and move the position of menu commands at their pleasure. It can be used
  12. # very simply to merely reorder the default commands, or to its' fullest
  13. # potential, that is creating commands to put custom scenes into the menu. It
  14. # also offers two graphical features: adding an EXP gauge into the menu status
  15. # window, and adding icons into the command display. Both are optional and
  16. # customizable.
  17. #
  18. #===============================================================================
  19. #
  20. #   ~! INSTALLATION !~
  21. # Paste above Main, below Materials. I suggest you paste this high up in your
  22. # custom scripts list, for technical reasons considering overwriting methods.
  23. # There are details for configuration below.
  24. #
  25. #===============================================================================
  26. #
  27. #   ~! DO NOT HESITATE TO ASK FOR HELP !~
  28. # This can get very confusing, and there is so much you can do with this, so if
  29. # you would like to know anything, just ask.
  30. #
  31. #===============================================================================
  32. #--------------------
  33. module PAC; module MM # <- Do not touch.
  34.   #------------------
  35.   # How to set up your menu commands:
  36.   # Below is the COMMANDS array, which holds all the commands for the menu in
  37.   # it. Within the array is a set of more arrays. Each array represents one
  38.   # command. These command arrays can contain 5 elements, which each give a
  39.   # piece of information to the script that sets up the menu. Note that each
  40.   # element must be followed by a comma or an error will occur. Make sure that
  41.   # each array begins with an open square bracket ([) and a close square bracket
  42.   # (]).
  43.   #----------
  44.   # Element 1 - The Name
  45.   # The first element of each array is the name that is displayed for that
  46.   # command on the menu. It must be written in quotation marks ('' or "").
  47.   #----------
  48.   # Element 2 - The Method
  49.   # The second element of each array is the name of the method that is executed
  50.   # when the command is selected. The method must be located in the Scene_Menu
  51.   # class. If you are planning on using this in tandem with a custom script's
  52.   # scene, you should try and find the methods necessary to open that scene.
  53.   # If a scene requires actor selection (Skill, Equip, etc.), put
  54.   # "command_personal" as the method and set the scene in element 5.
  55.   #----------
  56.   # Element 3 - The Icon
  57.   # The third element of each array is a number: the index of the icon to be
  58.   # displayed in the menu window. The index is the number displayed at the
  59.   # bottom-left of the icon selection window.
  60.   #----------
  61.   # Element 4 - The Disable Method
  62.   # The fourth element of each array is a condition which, if met, disables
  63.   # the command associated with it. The method must be located in the Scene_Menu
  64.   # class, or accessible otherwise. To disable a command with a switch, use:
  65.   # "$game_switches[x]" which will disable the command when switch with ID x is
  66.   # on. To do the same with a variable, use:
  67.   # "$game_variables[x] <=> n" which will disable the command when variable with
  68.   # ID x is <=> to n.
  69.   # This element can be ommited, or simply written as nil if you don't want one.
  70.   # It must be there if you wish to include the fifth element though.
  71.   #----------
  72.   # Element 5 - The Scene Call
  73.   # The fifth element (teehee) of each array is only required if the second
  74.   # element is set to 'command_personal'. It is the command to be executed upon
  75.   # actor selection. This is required for scenes that are specific to actors,
  76.   # namely Skill, Equip, Status and any custom scenes that are similar.
  77.   #----------
  78.   # If you have any inquiries on how to use these elements in the most effective
  79.   # way possible, or at all, ask away.
  80.   #----------
  81.   COMMANDS = [  # <- Do not touch
  82.   #----------
  83.     ['Inventory',             # Command Name
  84.     'command_item',           # Command Method
  85.     270,                      # Command Icon
  86.     'main_commands_enabled'], # Disable Method
  87.   #----------
  88.     ['Skills',
  89.     'command_personal',
  90.     112,
  91.     'main_commands_enabled',
  92.     'SceneManager.call(Scene_Skill)'],  # Scene Call.
  93.   #----------
  94.     ['Equipment',
  95.     'command_personal',
  96.     147,
  97.     'main_commands_enabled',
  98.     'SceneManager.call(Scene_Equip)'],
  99.   #----------
  100.     ['Status',
  101.     'command_personal',
  102.     121,
  103.     'main_commands_enabled',
  104.     'SceneManager.call(Scene_Status)'],
  105.   #----------
  106.     ['Formation',
  107.     'command_formation',
  108.     12,
  109.     'formation_enabled'],
  110.   #----------
  111.     ['Save',
  112.     'command_save',
  113.     117,
  114.     'save_enabled'],
  115.   #----------
  116.     ['Game End',
  117.     'command_game_end',
  118.     6]
  119.   #----------
  120.   ] # <- Do not touch.
  121.   #------------------
  122.   Exp_Gauge = true  # Use the EXP Gauge?
  123.   Exp_Color1 = "text_color(30)" # Color 1 for EXP gauge.
  124.   Exp_Color2 = "text_color(31)" # Color 2 for EXP gauge.
  125.   Exp_a = "EXP" # Text displayed on the EXP Gauge.
  126.   Icons = true  # Use icons in the menu display?
  127.   ALIGNMENT = 0 # Alignment of menu command text. 0 for left, 1 for center, 2
  128.   # for right.
  129.   Map_Window = true   # Use the map window in the menu display?
  130.   Time_Window = true  # Use the time window in the menu display?
  131.   Time_Height = 1     # Height of the time window.
  132.   Gold_Window = true  # Use the gold window in the menu display
  133.   Gold_Correction = true  # Correct the gold window's y value to fit in?
  134.   Windows_Pos = :left # Command, gold, map and time window orientation. :left
  135.   # or :right. Anything else will go to :left.
  136.   Heal_Button = :F5 # Button to fully heal the party in the menu. Set to nil if
  137.   # you don't want that. It will also clear all statuses. Only in test play, of
  138.   # course.
  139. #--------------------
  140. end; end
  141. #--------------------
  142.  
  143. #===============================================================================
  144. #
  145. # END OF CONFIGURATION
  146. #
  147. #==============================================================================
  148. # ** Game_System
  149. #------------------------------------------------------------------------------
  150. #  This class handles system data. It saves the disable state of saving and
  151. # menus. Instances of this class are referenced by $game_system.
  152. #==============================================================================
  153.  
  154. class Game_System
  155.   #--------------------------------------------------------------------------
  156.   # Public Instance Variables
  157.   #--------------------------------------------------------------------------
  158.   attr_accessor :menu_index, :menu_actor_selection
  159.   #--------------------------------------------------------------------------
  160.   # Alias listing
  161.   #--------------------------------------------------------------------------
  162.   alias pac_mm_gsys_ini initialize
  163.   #--------------------------------------------------------------------------
  164.   # * Object Initialization
  165.   #--------------------------------------------------------------------------
  166.   def initialize(*args)
  167.     pac_mm_gsys_ini(*args)
  168.     @menu_index = 0
  169.     @menu_actor_selection = false
  170.   end
  171. end
  172.  
  173. #==============================================================================
  174. # ** Window_Base
  175. #------------------------------------------------------------------------------
  176. #  This is a super class of all windows within the game.
  177. #==============================================================================
  178.  
  179. if PAC::MM::Exp_Gauge
  180. class Window_Base < Window
  181.   #--------------------------------------------------------------------------
  182.   # Alias Listing
  183.   #--------------------------------------------------------------------------
  184.   alias pac_mm_wnbs_simsta draw_actor_simple_status if PAC::MM::Exp_Gauge
  185.   #--------------------------------------------------------------------------
  186.   # * Get Text Colors (writing color without the u is killing me)
  187.   #--------------------------------------------------------------------------
  188.   def exp_gauge_color1; eval PAC::MM::Exp_Color1 rescue text_color(30); end
  189.   def exp_gauge_color2; eval PAC::MM::Exp_Color2 rescue text_color(31); end
  190.   #--------------------------------------------------------------------------
  191.   # * Draw EXP
  192.   #--------------------------------------------------------------------------
  193.   def draw_actor_exp(actor, x, y, width = 60)
  194.     draw_gauge(x, y, width, actor.final_exp_rate, exp_gauge_color1,
  195.      exp_gauge_color2)
  196.     change_color(system_color)
  197.     draw_text(x, y, 30, line_height, PAC::MM::Exp_a)
  198.     draw_current_and_max_values(x, y, width, actor.exp, actor.next_level_exp,
  199.       normal_color, normal_color)
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # * Draw Simple Status
  203.   #--------------------------------------------------------------------------
  204.   def draw_actor_simple_status(actor, x, y, *args)
  205.     pac_mm_wnbs_simsta(actor, x, y, *args)
  206.     draw_actor_exp(actor, x + 58, y + line_height)
  207.   end
  208. end
  209. end
  210.  
  211. #==============================================================================
  212. # ** Window_MenuStatus
  213. #------------------------------------------------------------------------------
  214. #  This window displays the map name on the menu screen.
  215. #==============================================================================
  216.  
  217. class Window_MenuMap < Window_Base
  218.   #--------------------------------------------------------------------------
  219.   # * Object Initialization
  220.   #--------------------------------------------------------------------------
  221.   def initialize(x, y)
  222.     super(x, y, window_width, fitting_height(1))
  223.     refresh
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # * Get Window Width
  227.   #--------------------------------------------------------------------------
  228.   def window_width
  229.     return 160
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # * Refresh
  233.   #--------------------------------------------------------------------------
  234.   def refresh
  235.     contents.clear
  236.     change_color(normal_color)
  237.     unless $game_map.display_name.empty?
  238.       draw_text(contents.rect, $game_map.display_name, 1)
  239.     end
  240.   end
  241. end
  242.  
  243. #==============================================================================
  244. # ** Window_Time
  245. #------------------------------------------------------------------------------
  246. #  This window displays play time on the menu screen.
  247. #==============================================================================
  248.  
  249. class Window_Time < Window_Base
  250.   #--------------------------------------------------------------------------
  251.   # * Object Initialization
  252.   #--------------------------------------------------------------------------
  253.   def initialize(x, y)
  254.     super(x, y, window_width, fitting_height(PAC::MM::Time_Height || 1))
  255.     refresh
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # * Get Window Width
  259.   #--------------------------------------------------------------------------
  260.   def window_width
  261.     return 160
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # * Refresh
  265.   #--------------------------------------------------------------------------
  266.   def refresh
  267.     contents.clear
  268.     @time = Graphics.frame_count / Graphics.frame_rate
  269.     hour = @time / 3600
  270.     min = @time / 60 % 60
  271.     sec = @time % 60
  272.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  273.     change_color(normal_color)
  274.     draw_text(contents.rect, text, 1)
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # * Frame Update
  278.   #--------------------------------------------------------------------------
  279.   def update
  280.     super
  281.     refresh if Graphics.frame_count / Graphics.frame_rate != @time
  282.   end
  283. end
  284.  
  285. #==============================================================================
  286. # ** Window_MenuCommand
  287. #------------------------------------------------------------------------------
  288. #  This command window appears on the menu screen.
  289. #==============================================================================
  290.  
  291. class Window_MenuCommand < Window_Command
  292.   #--------------------------------------------------------------------------
  293.   # * Initialize Command Selection Position (Class Method)
  294.   #--------------------------------------------------------------------------
  295.   def self.init_command_position(*args)
  296.     @@last_command_symbol ||= nil
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # * Create Command List
  300.   #--------------------------------------------------------------------------
  301.   def make_command_list(*args)
  302.     PAC::MM::COMMANDS.each {|c| add_command(c[0], c[0].to_sym, pac_disable(c))}
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # * Disable PAC Command
  306.   #--------------------------------------------------------------------------
  307.   def pac_disable(command)
  308.     command[3] || ''
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # * Draw Item
  312.   #--------------------------------------------------------------------------
  313.   def draw_item(index, *args)
  314.     rect = item_rect_for_text(index)
  315.     if PAC::MM::Icons && PAC::MM::COMMANDS[index][2] != nil
  316.       irect = item_rect(index)
  317.       draw_icon(PAC::MM::COMMANDS[index][2], irect.x, irect.y)
  318.       rect.x += 24
  319.     end
  320.     change_color(normal_color, command_enabled?(index))
  321.     draw_text(rect, command_name(index), PAC::MM::ALIGNMENT)
  322.   end
  323. end
  324.  
  325. #==============================================================================
  326. # ** Scene_Menu
  327. #------------------------------------------------------------------------------
  328. #  This class performs the menu screen processing.
  329. #==============================================================================
  330.  
  331. class Scene_Menu < Scene_MenuBase
  332.   #--------------------------------------------------------------------------
  333.   # Alias listing
  334.   #--------------------------------------------------------------------------
  335.   alias pac_mm_start  start
  336.   alias pac_mm_update update
  337.   alias pac_mm_cgw    create_gold_window if PAC::MM::Gold_Correction
  338.   alias pac_mm_opc    on_personal_cancel
  339.   #--------------------------------------------------------------------------
  340.   # * Start Processing
  341.   #--------------------------------------------------------------------------
  342.   def start(*args)
  343.     pac_mm_start
  344.     @@start_personal ||= false
  345.     if @@start_personal; @command_window.deactivate; command_personal; end
  346.     if PAC::MM::Windows_Pos == :right
  347.       @gold_window.x = Graphics.width-@gold_window.width if @gold_window != nil
  348.       @status_window.x = 0
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # * Frame Update
  353.   #--------------------------------------------------------------------------
  354.   def update(*args)
  355.     pac_mm_update(*args)
  356.     update_heal
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # * Update Heal Butten
  360.   #--------------------------------------------------------------------------
  361.   def update_heal # BUTTEN
  362.     if $TEST && PAC::MM::Heal_Button != nil &&
  363.      Input.trigger?(PAC::MM::Heal_Button)
  364.       Sound.play_recovery
  365.       $game_party.members do |actor| actor.recover_all end
  366.     end
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # * Create Command Window
  370.   #--------------------------------------------------------------------------
  371.   def create_command_window(*args)
  372.     @command_window = Window_MenuCommand.new
  373.     PAC::MM::COMMANDS.each {|c|
  374.       @command_window.set_handler(c[0].to_sym, pac_method(c))
  375.     }
  376.     @command_window.set_handler(:cancel, method(:return_scene))
  377.     if PAC::MM::Windows_Pos == :right
  378.       @command_window.x = Graphics.width - @command_window.width
  379.     end
  380.     create_map_window
  381.     create_time_window
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # * Create Gold Window
  385.   #--------------------------------------------------------------------------
  386.   if PAC::MM::Gold_Correction; def create_gold_window(*args)
  387.     pac_mm_cgw(*args)
  388.     @gold_window.visible = false if !PAC::MM::Gold_Window
  389.     y = @command_window.height
  390.     y += @map_window.height if @map_window
  391.     y += @time_window.height if @time_window
  392.     @gold_window.y = y
  393.   end; end
  394.   #--------------------------------------------------------------------------
  395.   # * Create Map Window
  396.   #--------------------------------------------------------------------------
  397.   def create_map_window
  398.     x = PAC::MM::Windows_Pos ==:right ? Graphics.width-@command_window.width : 0
  399.     @map_window = Window_MenuMap.new(x, @command_window.height)
  400.     @map_window.visible = false if !PAC::MM::Map_Window
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # * Create Time Window
  404.   #--------------------------------------------------------------------------
  405.   def create_time_window
  406.     x = PAC::MM::Windows_Pos ==:right ? Graphics.width-@command_window.width : 0
  407.     y = @map_window.nil? ? @command_window.height : @map_window.height +
  408.      @map_window.y
  409.     @time_window = Window_Time.new(x, y)
  410.     @time_window.visible = fasle if !PAC::MM::Time_Window
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # * Get Method for Command
  414.   #--------------------------------------------------------------------------
  415.   def pac_method(command)
  416.     method(command[1] || '')
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # * [OK] Personal Command
  420.   #--------------------------------------------------------------------------
  421.   def on_personal_ok(*args)
  422.     @@start_personal = true
  423.     eval(PAC::MM::COMMANDS[@command_window.index][4]) rescue nil
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # * [Cancel] Personal Command
  427.   #--------------------------------------------------------------------------
  428.   def on_personal_cancel(*args)
  429.     pac_mm_opc(*args)
  430.     @command_window.activate
  431.     @@start_personal = false
  432.   end
  433. end
  434.  
  435. ($pac ||= {})[:main_menu] = 1.2
  436.  
  437. #===============================================================================
  438. #
  439. # END OF SCRIPT
  440. #
  441. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement