modern_algebra

[VXA] Customizable Menu System

Jan 18th, 2012
2,054
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    Customizable Main Menu
  3. #    Version: 1.0c
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: February 17, 2012
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script is a base menu script which allows you to create custom menu
  10. #   commands and to move, add, or remove them from the menu easily. Not only  
  11. #   can you easily add a command which directly calls a scene, you can also add
  12. #   commands which call common events or which call a particular method (the
  13. #   method needs to be defined). At the same time, the script is also designed
  14. #   to recongize and include any commands that are added by another script,
  15. #   without requiring setup in this one.
  16. #
  17. #    Additionally, this script allows easy creation of custom windows which
  18. #   show simple data, so you are not limited to just the gold window - you
  19. #   could, for instance, show data such as the value of particular variables or
  20. #   the playtime, etc.. These optional windows can be added and removed at
  21. #   will, and they show up beneath the command window in the menu.
  22. #
  23. #    Since too many windows could overlap with the command window, this script
  24. #   also allows you to set a row max for the command window so that you need to
  25. #   scroll the window down to see the other commands. Additionally, you can
  26. #   change the width of the command and data windows and the Menu Status window
  27. #   will now better accomodate different resolutions. Finally, you can also
  28. #   change the alignment so that the status window is on the left and the
  29. #   command window is on the right.
  30. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  31. #  Instructions:
  32. #
  33. #    Paste this script into its own slot in the Script Editor, above Main and
  34. #   below Materials. If you are using any scripts which require this menu, then
  35. #   this script should be above them as well.
  36. #
  37. #    Aside from that, you can go to the Editable Region at line 64 to figure
  38. #   out how to configure the menu. If you do not change anything, then the
  39. #   menu will operate exactly like the default menu.
  40. #
  41. #    I understand that the configuration can be very difficult. If you do not
  42. #   understand it, please do not hesitate to visit me at RMRK and ask for help
  43. #   adding any specific command or window to the menu. The topic link is:
  44. #
  45. #       http://rmrk.net/index.php/topic,44906.0.html
  46. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  47. #  Thanks:
  48. #
  49. #    Yanfly, as the configuration for my Full Status Menu in VX was inspired
  50. #   by his Menu scripts for VX, and this script borrows from the FSCMS
  51. #==============================================================================
  52.  
  53. $imported = {} unless $imported
  54. $imported[:MA_CustomizableMenu] = true
  55.  
  56. #==============================================================================
  57. # *** MA_CustomizableMenu
  58. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  59. #  This module holds configuration data for the CMS
  60. #==============================================================================
  61.  
  62. module MA_CustomizableMenu
  63.   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  64.   #  Editable Region
  65.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  66.   #  CUSTOM_COMMANDS - This is where you can set up your own commands. You can
  67.   # add here almost any type of command you want here as long as you know the
  68.   # syntax. Given that, however, I understand that it may be difficult to
  69.   # understand for the scripter, so if you want any assistance in adding a
  70.   # command to the menu for any purpose, then I encourage you to ask me at this
  71.   # script's thread at RMRK and I will be happy to oblige. That said, I will
  72.   # nevertheless go over everything here, starting with the simplest setups and
  73.   # and then going into the rest.
  74.   #
  75.   #  Firstly, I will note that every new command requires a unique symbol by
  76.   # which you can identify it and add it to the command list. I will refer to
  77.   # that symbol as :unique in all generic examples, but essentially it can be
  78.   # anything you choose and must be different for each command. The format for
  79.   # all of the following commands will be:
  80.   #
  81.   #    :unique => [],
  82.   #
  83.   #  The content of the array will change depending on what you are trying
  84.   # to do, so I will go over everything in detail.
  85.   #``````````````````````````````````````````````````````````````````````````
  86.   #  To call a custom scene, the format is as follows:
  87.   #    :unique => ["command name", enable_condition, :Scene_Name, select_actor],
  88.   #
  89.   #  Note that if it ends up being too long, you can press enter after any of
  90.   # the commas and split it into more than one line. That is fine.
  91.   #
  92.   #  To help explain each of these parameters, I will use an example of adding
  93.   # the Debug scene to the menu:
  94.   #    :debug => ["Debug", true, :Scene_Debug],
  95.   #  
  96.   #    -Command Name-
  97.   #
  98.   #  So, the first thing is the name. This is what shows up in the command list
  99.   # when the menu is opened. So, if :debug is added to COMMAND_LIST (see below
  100.   # at line xx), then when the player opens the menu, they will see that Debug
  101.   # is there. The command name must have quotations around it.
  102.   #
  103.   # However, you can also evaluate an expression to return the name. To do so,
  104.   # all you need to do is make a symbol with the expression you want to call.
  105.   # So, for instance, if you used something like:
  106.   #    :debug => [:"Vocab::Continue", true, :Scene_Debug]
  107.   #
  108.   #  When you went to the menu, your Debug command would show up as whatever
  109.   # word you set for Continue in the Terms section of the Database.
  110.   #
  111.   #    -Enable Condition-
  112.   #
  113.   #  Second, we have the enable_condition. This allows you to set a condition
  114.   # such that, if it is not met, the command is unselectable. In our example it
  115.   # is true. This means that it will always be enabled. However, there are a
  116.   # number of ways you can use an enable condition. I will go over them one by
  117.   # one:
  118.   #
  119.   #  1. Always enabled - to set a command to always be enabled, simply use
  120.   #     true, as in the example.
  121.   #  2. In-game switch - if you use an integer instead of true, then the
  122.   #     command can only be selected if the switch with that ID is on. EX:
  123.   #      :debug => ["Debug", 7, :Scene_Debug],
  124.   #     The Debug command will only be enabled if Switch 7 is on.
  125.   #  3. Method call - This requires some knowledge of scripting, but this
  126.   #     allows you to call a method in the Window_MenuCommand class. Just put
  127.   #     a symbol of the method name. By default, there are three that might be
  128.   #     relevant -
  129.   #       (a) :main_commands_enabled - enabled when Skill, Equip, Status are
  130.   #       (b) :save_enabled - enabled when Save is
  131.   #       (c) :formation_enabled - enabled when Formation is
  132.   #     EX:
  133.   #       :debug => ["Debug", :main_commands_enabled, :Scene_Debug],
  134.   #     The Debug command would only be enabled if Status, Equip, and Skill
  135.   #     are (by default, this is when there are actors in the party).
  136.   #  4. Expression - This also requires some knowledge of scripting, but this
  137.   #     option allows you to set the enabled condition to be the result of
  138.   #     any scripting expression. Just set it up as a string Ex:
  139.   #       :debug => ["Debug", "$game_variables[10] > 5", :Scene_Debug],
  140.   #     The Debug command would only be enabled if the variable with ID 10
  141.   #     had a value greater than 5.
  142.   #
  143.   #    -Scene_Name-
  144.   #
  145.   #  This is a symbol containing the name of the class you want to run. In our
  146.   # example, we are calling :Scene_Debug, but we could also use any scene,
  147.   # such as :Scene_Item, :Scene_Equip, :Scene_Load, etc. This is most useful
  148.   # if you are installing a custom script that includes a scene and you want
  149.   # it accessible through the menu.
  150.   #
  151.   #  However, despite the fact that I labelled it as Scene_Name, you can do
  152.   # more than just call a scene. You can also:
  153.   #    (1) call a common event. To do that, just put the ID of the common
  154.   #       event you want to call. Ex:
  155.   #         :sonata => ["Sonata", true, 14],
  156.   #       That would call common event 14 when you choose the "Sonata" option
  157.   #       from the menu.
  158.   #    (2) evaluate an expression. To do this, just put the expression you
  159.   #       want to evaluate when the player selects this option as a string. EX:
  160.   #         :rmrk => ["RMRK", true,
  161.   #                   "Thread.new { system(\"start http://rmrk.net\") }
  162.   #                    @command_window.activate"],
  163.   #       That would be a command called "RMRK" which, when selected, would
  164.   #       open up the RMRK website in the player's browser.
  165.   #
  166.   #    -Select Actor-
  167.   #
  168.   #  If you add a fourth entry, you can do even more. In particular, if you
  169.   # add a true after your command:
  170.   #
  171.   #    :debug => ["Debug", true, :Scene_Debug, true],
  172.   #
  173.   # Then that will mean that when the player selects the Debug command, it
  174.   # will then go on to permit the player to select an actor. That is not
  175.   # useful for Debug, but would be useful for any scene that shows something
  176.   # about a particular actor. For instance, if you were to make a command
  177.   # for showing Equip (which you don't need to do, since it is default), you
  178.   # could do the following:
  179.   #
  180.   #    :equip => [:"Vocab::equip", :main_commands_enabled, :Scene_Equip, true],
  181.   #
  182.   # Then, when the player selects the Equip option, it will behave exactly
  183.   # as the Equip option should - it will let you select an Actor, and it will
  184.   # then bring you to that actor's Equip scene.
  185.   #
  186.   #  However, like with Scene_Name, although I have called this option
  187.   # Select_Actor, that is not the only thing you can put here, although the
  188.   # others require some scripting knowledge. In any case, you can also call a
  189.   # method - it can be useful, but you might need a script specifically
  190.   # designed to use it. As an example though, the following code would be
  191.   # identical to using true in this position:
  192.   #
  193.   #   :equip => [:"Vocab::equip", :main_commands_enabled, :Scene_Equip,
  194.   #              :command_personal],
  195.   #``````````````````````````````````````````````````````````````````````````
  196.   #   EXAMPLES
  197.   #
  198.   #  To assist in your understanding of this script, I will show you,
  199.   # essentially, how you could add the default commands. Obviously, it is
  200.   # unnecessary to do this, since they are set up this way by default, but I
  201.   # just figure that since you know how the default commands behave, it will
  202.   # help you understand how to use custom commands if you see how that
  203.   # behaviour could be captured through the custom command framework.
  204.   # Additionally, I will add just a few other examples. Without further ado:
  205.   #
  206.   #  CUSTOM_COMMANDS = {
  207.   #    :item =>        [:"Vocab::item", :main_commands_enabled, :Scene_Item],
  208.   #    :skill =>       [:"Vocab::skill", :main_commands_enabled, :Scene_Skill,
  209.   #                     true],
  210.   #    :equip =>       [:"Vocab::equip", :main_commands_enabled, :Scene_Equip,
  211.   #                     true],
  212.   #    :status =>      [:"Vocab::status", :main_commands_enabled, :Scene_Status,
  213.   #                     true],
  214.   #    :formation =>   [:"Vocab::formation", :formation_enabled,
  215.   #                     "command_formation"],
  216.   #    :save =>        [:"Vocab::save", :save_enabled, :Scene_Save],
  217.   #    :game_end =>    [:"Vocab::game_end", true, :Scene_Title],
  218.   #    :rmrk =>        ["RMRK", true,
  219.   #                     "Thread.new { system(\"start http://rmrk.net\") }; @command_window.activate"],
  220.   #    :debug =>       ["Debug", "$TEST", :Scene_Debug],
  221.   #    :cust_scene1 => ["Command Name", 5, :Scene_Custom1],
  222.   #    :cust_scene2 => ["Command Name", :main_commands_enabled, :Scene_Custom2,
  223.   #                     true],
  224.   #    :commonevent => ["Camp", "$game_party.item_number($data_items[7]) > 0",
  225.   #                     13],
  226.   #  }
  227.   #
  228.   #    :rmrk would open up the RMRK website when selected. It is always enabled
  229.   #    :debug would open the Debug scene, but is only enabled in Test Play
  230.   #    :cust_scene1 would call Scene_Custom1 (not a real scene), but is only
  231.   #      enabled if Switch 5 is on.
  232.   #    :cust_scene2 would call Scene_Custom2 (not a real scene), but would only
  233.   #      be available when there are actors in the party
  234.   #    :commonevent would call Common Event 13 if the party has one or more of
  235.   #      Item 7.
  236.   #
  237.   #  All that said, it is important to remember that none of the custom
  238.   # commands will show up in the menu unless you add their unique identifier
  239.   # into the COMMAND_LIST array, just below this hash, around line 275. That is
  240.   # a REQUIRED step.
  241.   CUSTOM_COMMANDS = { # <- Do not touch!
  242.     # Call Debug scene - enabled always
  243.     :debug => ["Debug", true, :Scene_Debug],
  244.     # Opens up RMRK in your browser - enabled always
  245.     :rmrk =>  ["RMRK", true,
  246.               "Thread.new { system(\"start http://rmrk.net\") }
  247.              @command_window.activate"],
  248.     # Call Load scene - enabled if a save file is in the game folder
  249.     :load =>  [:"Vocab::continue", "DataManager.save_file_exists?", :Scene_Load],
  250.     # Call common event 4 - enabled if party has Item 7 (a tent).
  251.     :camp =>  ["Camp", "$game_party.has_item?($data_items[7])", 4],
  252.   } # <- Do not touch!
  253.   # COMMAND_LIST - In this array, add the unique identifer of the custom
  254.   # commands that you want added to the menu. Additionally, there are 7 default
  255.   # commands which you can add, each corresponding to the default menu
  256.   # commands. These are:
  257.   #   :item, :skill, :equip, :status, :formation, :save, and :game_end.
  258.   #
  259.   #  You can, of course, delete them from the array and then they won't be
  260.   # available. In fact, no command will show up unless it is included in this
  261.   # array! You can modify the contents of this array in-game with the following
  262.   # script calls:
  263.   #
  264.   #    add_menu_command(:unique, index)
  265.   #    remove_menu_command(:unique)
  266.   #
  267.   #  :unique is the unique identifier of the custom or default command you want
  268.   # to add or remove.
  269.   #  index is an integer which allows you to choose where the command shows up
  270.   # in the list when it is added. If you exclude it and just put:
  271.   #
  272.   #    add_menu_command(:unique)
  273.   #
  274.   # then it will be the last command in the command window.
  275.   COMMAND_LIST = [ # <- Do not touch!
  276.     :item,
  277.     :skill,
  278.     :equip,
  279.     :status,
  280.     :formation,
  281.     :save,
  282.     :game_end,
  283.   ] # <- Do not touch!
  284.   #  COMMAND_WINDOW_ROWMAX - This lets you determine how many commands will be
  285.   # in the command window before the rest are hidden and only become visible
  286.   # when scrolling down. If set to 0, then it will show all commands at once.
  287.   COMMAND_WINDOW_ROWMAX = 0
  288.   #  COMMAND_WINDOW_WIDTH - This determines how wide the command window and
  289.   # optional windows are. If you need more room horizontal room for your
  290.   # commands, then just increase this value.
  291.   COMMAND_WINDOW_WIDTH = 160
  292.   #  COMMAND_WINDOW_ON_RIGHT - If set to true, then the command window will be
  293.   # on the right of the screen and the actor window will be on the left.
  294.   COMMAND_WINDOW_ON_RIGHT = false
  295.   #  CUSTOM_WINDOWS - Here you can set up your own windows to show simple
  296.   # data, like the gold window. Basically, you can show a label, and then real
  297.   # data. The format is as follows:
  298.   #
  299.   #    :unique => ["Label", value],
  300.   #
  301.   #  As with the CUSTOM_COMMANDS, :unique must be a unique identifier so that
  302.   # you can add it into the OPTIONAL_WINDOWS_LIST.
  303.   #
  304.   #  "Label" is a String which will show up on the left hand side. It
  305.   # recognizes special message codes, but if you are using double quotation
  306.   # marks (" "), then you need to use \\, not \. Ie, it would be \\c[16], not
  307.   # \c[16].
  308.   #
  309.   #  value can show one of three things:
  310.   #   (1) The value of a variable - to show this, just put the ID of the
  311.   #      variable you want to show.
  312.   #   (2) Any expression you evaluate - this requires some scripting knowledge,
  313.   #      but if you know the correct code then just put it in a string. Ex:
  314.   #        :steps =>     ["\\c[6]Steps\\c[0]", "$game_party.steps"],
  315.   #        :keys =>      ["Keys", "$game_party.item_number($data_items[8])"],
  316.   #   (3) Playtime - To show playtime, you need to just use :playtime. Ex:
  317.   #        :playtime =>  ["\\i[280]", :playtime],
  318.   #   (4) Other - If you know how to script, then it is possible to add
  319.   #      special data as well, like playtime.
  320.   #
  321.   #  Additionally, you can make windows that have more than one data line,
  322.   # simply by adding further lines. So, for instance:
  323.   #
  324.   #   :combined => ["\\i[280]", :playtime,
  325.   #                 "\\i[467]", "$game_party.steps",
  326.   #                 "\\i[347]", 5],
  327.   #
  328.   #  That would show all of that data in one line. It is the same format, they
  329.   # just need to be within the same [].
  330.   CUSTOM_WINDOWS = { # <- Do not touch!
  331.     :playtime =>  ["\\i[280]", :playtime],
  332.     :variable5 => ["\\i[122]", 5],
  333.     :steps =>     ["\\c[6]Steps\\c[0]", "$game_party.steps"],
  334.     :item8 =>     ["Keys", "$game_party.item_number($data_items[8])"],
  335.     :combined =>  ["\\i[280]", :playtime,
  336.                    "\\i[467]", "$game_party.steps",
  337.                    "\\i[347]", 5,
  338.                    "\\i[262]", "$game_party.gold"],
  339.   } # <- Do not touch!
  340.   #  OPTIONAL_WINDOWS_LIST - Like the COMMAND_LIST, any windows you want to add
  341.   # to the menu need to be included in this array. Just add the :unique
  342.   # identifier, and that is the position the window will show up. The only
  343.   # default option is :gold, which shows the regular gold window. You can
  344.   # delete it if you want. To add windows in-game, you can use the following
  345.   # script calls:
  346.   #  
  347.   #    add_menu_window(:unique, index)
  348.   #    remove_menu_window(:unique)
  349.   #
  350.   #  :unique is the unique identifier of the window you want to add or remove.
  351.   #  index is an integer which allows you to choose where the command shows up
  352.   # in the list when it is added. If you exclude it and just put:
  353.   #
  354.   #    add_menu_window(:unique)
  355.   #
  356.   # then it will be the placed at the bottom.
  357.   OPTIONAL_WINDOWS_LIST = [ # <- Do not touch!
  358.     :gold,
  359.   ] # <- Do not touch!
  360.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  361.   #  END Editable Region
  362.   #//////////////////////////////////////////////////////////////////////////
  363.   #============================================================================
  364.   # *** Alter_MenuStatus
  365.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  366.   #  This module is to be mixed in to the metaclass to the Window_MenuStatus
  367.   # created in Scene_Menu, since I don't want to change it in any other scene.
  368.   #============================================================================
  369.  
  370.   module Alter_MenuStatus
  371.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  372.     # * Draw Actor Simple Status
  373.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  374.     def draw_actor_simple_status(actor, x, y, *args, &block)
  375.       y += (item_height - 96) / 2
  376.       if contents_width.between?(346, 394)
  377.         # Only need to alter the x value if within this range.
  378.         if contents_width < 354
  379.           x -= (354 - contents_width)
  380.         elsif contents_width > 360
  381.           x += (contents_width - 360) / 2
  382.         end
  383.         super(actor, x, y, *args, &block)
  384.       else # If outside that range, will need to reduce width
  385.         if contents_width < 346
  386.           x -= 8
  387.           room_needed = 346 - contents_width
  388.           space = room_needed > 4 ? 4 : 8 - room_needed
  389.           # Take first four pixels off w2, then equally off w1 and w2
  390.           w1 = room_needed > 8 ? 112 - ((room_needed - 8) / 2) : 112
  391.           w2 = contents_width - w1 - space - x
  392.         else
  393.           x += 17
  394.           room_needed = contents_width - 394
  395.           space = 8
  396.           w2 = 124
  397.           if room_needed > 8
  398.             w1 = 120
  399.             if room_needed > 16
  400.               space += 8
  401.               w2 += (room_needed - 16)
  402.             else
  403.               space += room_needed
  404.             end
  405.           else
  406.             w1 = 112 + room_needed
  407.           end
  408.         end
  409.         draw_actor_name(actor, x, y, w1)
  410.         draw_actor_level(actor, x, y + line_height * 1)
  411.         draw_actor_icons(actor, x, y + line_height * 2, w1)
  412.         draw_actor_class(actor, x + w1 + space, y, w2)
  413.         draw_actor_hp(actor, x + w1 + space, y + line_height * 1, w2)
  414.         draw_actor_mp(actor, x + w1 + space, y + line_height * 2, w2)
  415.       end
  416.     end
  417.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  418.     # * Item Height
  419.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  420.     def item_height(*args, &block)
  421.       total_height = height - (standard_padding * 2)
  422.       if total_height > 96
  423.         total_height / (total_height / 96)
  424.       else
  425.         super(*args, &block)
  426.       end
  427.     end
  428.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429.     # * Item Rect
  430.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  431.     def item_rect(*args, &block)
  432.       rect = super(*args, &block)
  433.       rect.y += [(rect.height - 98) / 2, 0].max
  434.       rect.height = 98
  435.       rect
  436.     end
  437.   end
  438. end
  439.  
  440. #==============================================================================
  441. # *** DataManager
  442. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  443. #  Summary of Changes:
  444. #    aliased method - self.extract_save_contents
  445. #==============================================================================
  446.  
  447. module DataManager
  448.   class << self
  449.     alias macmm_extrctsvcon_2qk8 extract_save_contents
  450.   end
  451.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  452.   # * Extract Save Contents
  453.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  454.   def self.extract_save_contents(*args, &block)
  455.     macmm_extrctsvcon_2qk8(*args, &block) # Run Original Method
  456.     # Preserve old save files
  457.     $game_system.macmm_initialize_menubase_data if !$game_system.macmm_command_list
  458.   end
  459. end
  460.  
  461. #==============================================================================
  462. # ** Game System
  463. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  464. #  Summary of Changes:
  465. #    new public instance variable - macmm_command_list; macmm_optional_windows
  466. #    aliased method - initialize
  467. #==============================================================================
  468.  
  469. class Game_System
  470.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  471.   # * Public Instance Variables
  472.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  473.   attr_reader   :macmm_command_list
  474.   attr_reader   :macmm_optional_windows
  475.   attr_accessor :macmm_row_max
  476.   attr_accessor :macmm_command_width
  477.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  478.   # * Object Initialization
  479.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  480.   alias ma_cmsb_initilz_6dq1 initialize
  481.   def initialize(*args, &block)
  482.     ma_cmsb_initilz_6dq1(*args, &block) # Run Original Method
  483.     macmm_initialize_menubase_data
  484.   end
  485.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  486.   # * Initialize MenuBase Data
  487.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  488.   def macmm_initialize_menubase_data
  489.     @macmm_command_list = MA_CustomizableMenu::COMMAND_LIST.compact
  490.     @macmm_optional_windows = MA_CustomizableMenu::OPTIONAL_WINDOWS_LIST.compact
  491.     @macmm_row_max = MA_CustomizableMenu::COMMAND_WINDOW_ROWMAX
  492.     @macmm_command_width = MA_CustomizableMenu::COMMAND_WINDOW_WIDTH
  493.   end
  494. end
  495.  
  496. #==============================================================================
  497. # ** Game_Interpreter
  498. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  499. #  Summary of Changes:
  500. #    new methods - add_menu_command; remove_menu_command; add_menu_window;
  501. #      remove_menu_window
  502. #==============================================================================
  503.  
  504. class Game_Interpreter
  505.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  506.   # * Add & Remove Menu Commands
  507.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  508.   def add_menu_command(command, index = -1)
  509.     remove_menu_command(command)
  510.     $game_system.macmm_command_list.insert(index, command)
  511.   end
  512.   def remove_menu_command(command)
  513.     $game_system.macmm_command_list.delete(command)
  514.   end
  515.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  516.   # * Add & Remove Menu Windows
  517.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  518.   def add_menu_window(win, index = -1)
  519.     remove_menu_window(win)
  520.     $game_system.macmm_optional_windows.insert(index, win)
  521.   end
  522.   def remove_menu_window(win)
  523.     $game_system.macmm_optional_windows.delete(win)
  524.   end
  525. end
  526.  
  527. #==============================================================================
  528. # ** Window_MenuCommand
  529. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  530. #  Summary of Changes:
  531. #    overwritten method - window_width
  532. #    aliased method - make_command_list; visible_line_number
  533. #    new method - macmm_remake_command_list; macmm_preserve_noncustom_commands
  534. #      macmm_add_custom_command
  535. #==============================================================================
  536.  
  537. class Window_MenuCommand
  538.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  539.   # * Window Width
  540.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  541.   def window_width
  542.     $game_system.macmm_command_width
  543.   end
  544.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  545.   # * Add Original Commands
  546.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  547.   alias ma_cmsb_makecndlist_5fk8 make_command_list
  548.   def make_command_list(*args, &block)
  549.     #  I know that this is a very strange way to do this, but my purpose is to
  550.     # interfere as little as possible with unknown scripts which add scenes
  551.     # to the menu. In order to do that, I call the original method and only
  552.     # afterwards reconfigure things.
  553.     ma_cmsb_makecndlist_5fk8(*args, &block)
  554.     # Retain unknown commands, as well as non-overridden default commands
  555.     macmm_preserve_noncustom_commands
  556.     clear_command_list
  557.     # Remake command list with order specified
  558.     macmm_remake_command_list
  559.   end
  560.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  561.   # * Preserve Non-Custom Commands
  562.   #``````````````````````````````````````````````````````````````````````````
  563.   #  This method scans the current list and retains all commands that are
  564.   # either unknown (from another script) or default and not overridden (so
  565.   # that, unless specified by the user, it will act exactly as it would
  566.   # without having this sctipt. That is important in case there is some other
  567.   # script which modifies the default commands.)
  568.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  569.   def macmm_preserve_noncustom_commands
  570.     default_list = [:item, :skill, :equip, :status, :formation, :save, :game_end]
  571.     @noncustom_commands = {}
  572.     for i in 0...@list.size
  573.       cmnd = @list[i]
  574.       sym = cmnd[:symbol]
  575.       # Don't preserve any command defined in CUSTOM_COMMANDS
  576.       if $game_system.macmm_command_list.include?(sym)
  577.         next if MA_CustomizableMenu::CUSTOM_COMMANDS.key?(sym)
  578.       else # Don't preserve default commands that are not specified
  579.         next if default_list.include?(sym)
  580.       end
  581.       # Retain the index and the command
  582.       @noncustom_commands[sym] = [i, cmnd]
  583.     end
  584.   end
  585.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  586.   # * Remake Command List
  587.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  588.   def macmm_remake_command_list
  589.     # Go through the command list in order
  590.     $game_system.macmm_command_list.each { |sym|
  591.       if MA_CustomizableMenu::CUSTOM_COMMANDS.key?(sym)
  592.         macmm_add_custom_command(sym)
  593.       elsif @noncustom_commands.key?(sym)
  594.         # Add default command to the list
  595.         @list.push(@noncustom_commands[sym][1])
  596.         @noncustom_commands.delete(sym)
  597.       else
  598.         p "Error: MA_MenuBase - No command is set up for #{sym}"
  599.       end
  600.     }
  601.     #  Add all remaining noncustom commands, under the assumption that they are
  602.     # intentionally placed there by an unknown script.
  603.     @noncustom_commands.values.each { |el| @list.insert([el[0], @list.size].min, el[1]) }
  604.   end
  605.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  606.   # * Add Custom Command
  607.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  608.   def macmm_add_custom_command(symbol)
  609.     cc = MA_CustomizableMenu::CUSTOM_COMMANDS[symbol] # Get custom command setup
  610.     # Get the command name
  611.     name = cc[0].is_a?(Symbol) ? eval(cc[0].to_s) : cc[0]
  612.     # Add the command to the list
  613.     add_command(name, symbol, macmm_custom_command_enabled(cc[1]))
  614.   end
  615.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  616.   # * Custom Command Enabled
  617.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  618.   def macmm_custom_command_enabled(enable_condition)
  619.     # Check whether enabled
  620.     return case enable_condition
  621.     when Integer then $game_switches[enable_condition]
  622.     when String then eval(enable_condition)
  623.     when Symbol then self.send(enable_condition)
  624.     else
  625.       return true
  626.     end
  627.   end
  628.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  629.   # * Visible Line Number
  630.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  631.   alias mlgb_cmsb_vislnnum_4rk9 visible_line_number
  632.   def visible_line_number(*args, &block)
  633.     r = mlgb_cmsb_vislnnum_4rk9(*args, &block) # Run Original Method
  634.     return r if $game_system.macmm_row_max < 1
  635.     [r, $game_system.macmm_row_max].min
  636.   end
  637. end
  638.  
  639. #==============================================================================
  640. # ** Window_MACMM_AutoCustom
  641. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  642. #  This window displays some specified data, along with an identifying label
  643. #==============================================================================
  644.  
  645. class Window_MACMM_AutoCustom < Window_Base
  646.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  647.   # * Object Initialization
  648.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  649.   def initialize(cw_data = ["", 0])
  650.     @cw_data = cw_data
  651.     x = MA_CustomizableMenu::COMMAND_WINDOW_ON_RIGHT ? Graphics.width - window_width : 0
  652.     super(x, 0, window_width, fitting_height(@cw_data.size / 2))
  653.     refresh
  654.   end
  655.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  656.   # * Window Width
  657.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  658.   def window_width
  659.     $game_system.macmm_command_width
  660.   end
  661.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  662.   # * Refresh Window
  663.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  664.   def refresh
  665.     contents.clear
  666.     for i in 0...(@cw_data.size / 2)
  667.       draw_text_ex(0, line_height*i, "\\c[16]" + @cw_data[i*2])
  668.       reset_font_settings
  669.       draw_text(0, line_height*i, contents_width, line_height, value(@cw_data[i*2 + 1]), 2)
  670.     end
  671.   end
  672.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  673.   # * Value
  674.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  675.   def value(val = 0)
  676.     return case val
  677.     when Integer then $game_variables[val].to_s
  678.     when String then (eval(val)).to_s
  679.     when Symbol then manual_value(val)
  680.     else
  681.       return ""
  682.     end
  683.   end
  684.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  685.   # * Manual Value
  686.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  687.   def manual_value(val)
  688.     if val == :playtime
  689.       @total_sec = Graphics.frame_count / Graphics.frame_rate
  690.       hour = @total_sec / 60 / 60
  691.       min = @total_sec / 60 % 60
  692.       sec = @total_sec % 60
  693.       return sprintf("%02d:%02d:%02d", hour, min, sec)
  694.     end
  695.   end
  696.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  697.   # * Open Window
  698.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  699.   def open
  700.     refresh
  701.     super
  702.   end
  703.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  704.   # * Frame Update
  705.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  706.   def update
  707.     super
  708.     refresh if @cw_data.include?(:playtime) && Graphics.frame_count / Graphics.frame_rate != @total_sec
  709.   end
  710. end
  711.  
  712. #==============================================================================
  713. # ** Scene_Menu
  714. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  715. #  Summary of Changes:
  716. #    aliased method - start; create_command_window; create_gold_window;
  717. #      create_status_window; on_personal_ok
  718. #    new method - macmm_command_custom; macmm_command_common_event;
  719. #      create_optional_windows; manual_custom_window; auto_custom_window;
  720. #      set_custom_window_y; macmm_set_custom_handler
  721. #==============================================================================
  722.  
  723. class Scene_Menu
  724.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  725.   # * Start
  726.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  727.   alias ma_cmsb_strt_7tg9 start
  728.   def start(*args, &block)
  729.     @opt_y = Graphics.height
  730.     ma_cmsb_strt_7tg9(*args, &block) # Run Original Method
  731.     create_optional_windows
  732.   end
  733.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  734.   # * Create Command Window
  735.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  736.   alias ma_cmsb_crtcmndwin_5ta4 create_command_window
  737.   def create_command_window(*args, &block)
  738.     ma_cmsb_crtcmndwin_5ta4(*args, &block) # Run Original Method
  739.     # Add handlers for all custom commands
  740.     $game_system.macmm_command_list.each { |sym|
  741.       next unless MA_CustomizableMenu::CUSTOM_COMMANDS.key?(sym)
  742.       macmm_set_custom_handler(sym)
  743.     }
  744.     @command_window.x = Graphics.width - $game_system.macmm_command_width if MA_CustomizableMenu::COMMAND_WINDOW_ON_RIGHT
  745.   end
  746.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  747.   # * Create Status Window
  748.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  749.   alias macmm_createstatusw_9ja2 create_status_window
  750.   def create_status_window(*args, &block)
  751.     macmm_createstatusw_9ja2(*args, &block) # Call Original Method
  752.     @status_window.extend(MA_CustomizableMenu::Alter_MenuStatus)
  753.     @status_window.width = Graphics.width - $game_system.macmm_command_width
  754.     @status_window.x = 0 if MA_CustomizableMenu::COMMAND_WINDOW_ON_RIGHT
  755.     @status_window.create_contents
  756.     @status_window.refresh
  757.   end
  758.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  759.   # * Create Gold Window
  760.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  761.   alias ma_cmsb_crtgldwin_5yx1 create_gold_window
  762.   def create_gold_window(*args, &block)
  763.     if $game_system.macmm_optional_windows.include?(:gold) && !MA_CustomizableMenu::CUSTOM_WINDOWS.key?(:gold)
  764.       ma_cmsb_crtgldwin_5yx1(*args, &block) # Run Original Method
  765.       @gold_window.width = $game_system.macmm_command_width
  766.       @gold_window.x = Graphics.width - $game_system.macmm_command_width if MA_CustomizableMenu::COMMAND_WINDOW_ON_RIGHT
  767.       @gold_window.create_contents
  768.       @gold_window.refresh
  769.     end
  770.   end
  771.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  772.   # * Create Optional Window
  773.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  774.   def create_optional_windows
  775.     @macmm_optional_windows = []
  776.     $game_system.macmm_optional_windows.reverse.each { |sym|
  777.       cw = MA_CustomizableMenu::CUSTOM_WINDOWS[sym]
  778.       if cw.nil?
  779.         manual_custom_window(sym)
  780.       else
  781.         auto_custom_window(sym)
  782.       end
  783.     }
  784.   end
  785.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  786.   # * Create Custom Window
  787.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  788.   def auto_custom_window(symbol)
  789.     cw = MA_CustomizableMenu::CUSTOM_WINDOWS[symbol]
  790.     window = Window_MACMM_AutoCustom.new(cw)
  791.     set_custom_window_y(window)
  792.     @macmm_optional_windows << window
  793.     instance_variable_set(:"@macmm_#{symbol.to_s}_window", window)
  794.   end
  795.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  796.   # * Create Manually Set Custom Window
  797.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  798.   def manual_custom_window(symbol)
  799.     case symbol
  800.     when :gold then set_custom_window_y(@gold_window)
  801.     else
  802.       p "Error: MA_MenuBase - No window setup for #{symbol}"
  803.     end
  804.   end
  805.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  806.   # * Set Y for Custom Window
  807.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  808.   def set_custom_window_y(window)
  809.     @opt_y -= window.height
  810.     window.y = @opt_y
  811.   end
  812.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  813.   # * Personal OK
  814.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  815.   alias mala_cmsb_prsnlok_8yj7 on_personal_ok
  816.   def on_personal_ok(*args, &block)
  817.     if MA_CustomizableMenu::CUSTOM_COMMANDS.include?(@command_window.current_symbol)
  818.       # If calling a common event
  819.       case MA_CustomizableMenu::CUSTOM_COMMANDS[@command_window.current_symbol][2]
  820.       when Integer then macmm_command_common_event
  821.       when Symbol then send(MA_CustomizableMenu::CUSTOM_COMMANDS[@command_window.current_symbol][2])
  822.       when String then eval(MA_CustomizableMenu::CUSTOM_COMMANDS[@command_window.current_symbol][2])
  823.       else
  824.         macmm_command_custom # If nil or anything else, normal
  825.       end
  826.     else
  827.       mala_cmsb_prsnlok_8yj7(*args, &block) # Run Original Method
  828.     end
  829.   end
  830.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  831.   # * Set Custom Handler
  832.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  833.   def macmm_set_custom_handler(symbol)
  834.     cc = MA_CustomizableMenu::CUSTOM_COMMANDS
  835.     handler = case cc[symbol][3]
  836.     when Symbol then method(cc[symbol][3])
  837.     when TrueClass then method(:command_personal)
  838.     else
  839.       handler = case cc[symbol][2]
  840.       when Integer then method(:macmm_command_common_event)
  841.       when String then lambda { eval(cc[symbol][2]) }
  842.       else
  843.         handler = method(:macmm_command_custom) # If nil or anything else, normal
  844.       end
  845.     end
  846.     @command_window.set_handler(symbol, handler)
  847.   end
  848.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  849.   # * Custom Command
  850.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  851.   def macmm_command_custom
  852.     SceneManager.call(Kernel.const_get(MA_CustomizableMenu::CUSTOM_COMMANDS[@command_window.current_symbol][2]))
  853.   end
  854.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  855.   # * Command Common Event
  856.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  857.   def macmm_command_common_event
  858.     $game_temp.reserve_common_event(MA_CustomizableMenu::CUSTOM_COMMANDS[@command_window.current_symbol][2])
  859.     return_scene
  860.   end
  861. end
RAW Paste Data