Advertisement
Zetu

NMSLITEv1.11

Dec 9th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.50 KB | None | 0 0
  1.                             #======================#
  2.                             #  Z-Systems by: Zetu  #
  3. #===========================#======================#===========================#
  4. #              *  *  *  Z6 Neo Menu System - LITE  v1.11  *  *  *              #
  5. #=#==========================================================================#=#
  6.   #  This script allows easy customization to you menu commands. The way it  #
  7.   #  works is, the array 'MENU_ITEMS' stores all commands and the hash       #
  8.   #  'COMMAND' will run the script on that command's selection.  If the      #
  9.   #  COMMAND of the item contains '@status_window.index', then it will       #
  10.   #  prompt you to select an actor, and if it exists in DISABLES and the     #
  11.   #  statement is true, then the item will be disabled.                      #
  12.   #--------------------------------------------------------------------------#
  13.   #  From the free customization of this script, you can add/remove/change   #
  14.   #  order of the menu items.  When you add a new item (from another         #
  15.   #  script), you MUST add a new item in the COMMAND hash.                   #
  16.   #--------------------------------------------------------------------------#
  17.   #  Tip on finding the code within a script:                                #
  18.   #    Use Ctrl+F '$scene ='.  This should be able to locate the call method #
  19.   #    used in most every script.                                            #
  20.   #==========================================================================#
  21.  
  22. module Z6
  23.     #  If script includes '@status_window.index', it will prompt you to
  24.     #  select an actor.
  25.     MENU_ITEMS = [
  26.        #symbol,  label,    command $scene = ???
  27.       [:item,    "Item",   'Scene_Item.new'],
  28.       [:skill,   "Skill",  'Scene_Skill.new(@status_window.index)'],
  29.       [:equip,   "Equip",  'Scene_Equip.new(@status_window.index)'],
  30.       [:status,  "Status", 'Scene_Status.new(@status_window.index)'],
  31.       [:save,    "Save",   'Scene_File.new(true, false, false)'],
  32.       [:endgame, "End",    'Scene_End.new']
  33.     ] # DO NOT REMOVE
  34.      
  35.     #Expression that tests if script is to be disabled.
  36.     DISABLES = {#Disable option if true.
  37.       #This shows disabling if Save Game is disabled.
  38.       :save   => '$game_system.save_disabled',
  39.       #This shows disabling if game switch id 11 if off.
  40.       :examp1 => '$game_switches[11] == false',
  41.       #This shows disabling if variable id 1 is equal to or larger than 8.
  42.       :examp2 => '$game_variables[1] >= 8'
  43.     } # DO NOT REMOVE
  44.      
  45.     ICONS = { #Optional: Will not display an icon if nil.
  46.       :item    => 144,
  47.       :skill   => 137,
  48.       :equip   => 1,
  49.       :status  => 130,
  50.       :save    => 200,
  51.       :endgame => 224
  52.     } # DO NOT REMOVE
  53.    
  54.    
  55.     # $m_index is last selected menu index (for return scenes)
  56. #========#======================#====#================================#========#
  57. #--------#                      #----# DO NOT EDIT PAST THIS POINT!!! #--------#
  58. #--------# End of Customization #----# Editing will cause death by    #--------#
  59. #--------#                      #----# brain asplosions.              #--------#
  60. #========#======================#====#================================#========#
  61.  
  62.   def self.menu_symbols
  63.     result = []
  64.     for i in 0...MENU_ITEMS.size
  65.       result.push(MENU_ITEMS[i][0])
  66.     end
  67.     return result
  68.   end
  69.  
  70.   def self.menu_vocab
  71.     result = []
  72.     for i in 0...MENU_ITEMS.size
  73.       result.push(MENU_ITEMS[i][1])
  74.     end
  75.     return result
  76.   end
  77.  
  78. end
  79. $zsys = {} if $zsys == nil
  80. $zsys["Menu"] = true
  81.  
  82. class Scene_Menu < Scene_Base
  83.  
  84.   def create_command_window
  85.     $m_index = 0
  86.     @command_window = Window_CommandNMS.new(160, Z6::menu_vocab)
  87.     @command_window.index = @menu_index
  88.     zs_nms_disable
  89.   end
  90.  
  91.   def zs_nms_disable
  92.     if $game_party.members.size == 0
  93.       for i in 0...MENU_ITEMS.size
  94.         command = menu_symbols[i]
  95.         if needs_selection?(i)
  96.           @command_window.draw_item(i, false)
  97.         end
  98.       end
  99.     end
  100.     for i in 0...Z6::MENU_ITEMS.size
  101.       command = Z6::MENU_ITEMS[i][0]
  102.       if Z6::DISABLES.key?(command)
  103.         @command_window.draw_item(i, false) if eval(Z6::DISABLES[command])
  104.       end
  105.     end
  106.   end
  107.  
  108.   def needs_selection?(index)
  109.     print index unless index.is_a?(Integer)
  110.     return Z6::MENU_ITEMS[index][2].include? '@status_window.index'
  111.   end
  112.  
  113.   def update_command_selection
  114.     if Input.trigger?(Input::B)
  115.       Sound.play_cancel
  116.       $scene = Scene_Map.new
  117.     elsif Input.trigger?(Input::C)
  118.       selection = Z6::MENU_ITEMS[@command_window.index][0]
  119.       if $game_party.members.size == 0 and needs_selection?(@command_window.index)
  120.         Sound.play_buzzer
  121.         return
  122.       elsif Z6::DISABLES.key?(selection)
  123.         if eval(DISABLES[selection])
  124.           Sound.play_buzzer
  125.           return
  126.         end
  127.       end
  128.       Sound.play_decision
  129.       if needs_selection?(@command_window.index)
  130.         start_actor_selection
  131.       else
  132.         $m_index = @command_window.index
  133.         $scene = eval(Z6::MENU_ITEMS[@command_window.index][2])
  134.       end
  135.     end
  136.   end
  137.  
  138.   def update_actor_selection
  139.     if Input.trigger?(Input::B)
  140.       Sound.play_cancel
  141.       end_actor_selection
  142.     elsif Input.trigger?(Input::C)
  143.       $game_party.last_actor_index = @status_window.index
  144.       Sound.play_decision
  145.       $m_index = @command_window.index
  146.       $scene = eval(Z6::MENU_ITEMS[@command_window.index][2])
  147.     end
  148.   end
  149. end
  150.  
  151. class Scene_Base
  152.   def dispose_menu_background
  153.     @menuback_sprite.dispose if @menuback_sprite != nil
  154.   end
  155. end
  156.  
  157. #-------------------------------------------------------------------------------
  158. #Indexing Fix.  All default return_scenes have been OVERWRITE
  159. class Scene_Item < Scene_Base
  160.   def return_scene
  161.     $scene = Scene_Menu.new($m_index)
  162.   end
  163. end
  164. class Scene_Skill < Scene_Base
  165.   def return_scene
  166.     $scene = Scene_Menu.new($m_index)
  167.   end
  168. end
  169. class Scene_Equip < Scene_Base
  170.   def return_scene
  171.     $scene = Scene_Menu.new($m_index)
  172.   end
  173. end
  174. class Scene_Status < Scene_Base
  175.   def return_scene
  176.     $scene = Scene_Menu.new($m_index)
  177.   end
  178. end
  179. class Scene_Status < Scene_Base
  180.   def return_scene
  181.     $scene = Scene_Menu.new($m_index)
  182.   end
  183. end
  184. class Scene_File < Scene_Base
  185.   def return_scene
  186.     if @from_title
  187.       $scene = Scene_Title.new
  188.     elsif @from_event
  189.       $scene = Scene_Map.new
  190.     else
  191.       $scene = Scene_Menu.new($m_index)
  192.     end
  193.   end
  194. end
  195.  
  196. #-------------------------------------------------------------------------------
  197.  
  198. class Window_CommandNMS < Window_Selectable
  199.  
  200.   def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  201.     if row_max == 0
  202.       row_max = (commands.size + column_max - 1) / column_max
  203.     end
  204.     super(0, 0, width, row_max * WLH + 32, spacing)
  205.     @commands = commands
  206.     @item_max = commands.size
  207.     @column_max = column_max
  208.     refresh
  209.     self.index = 0
  210.   end
  211.  
  212.   def refresh
  213.     self.contents.clear
  214.     for i in 0...@item_max
  215.       draw_item(i)
  216.     end
  217.   end
  218.  
  219.   def draw_item(index, enabled = true)
  220.     rect = item_rect(index)
  221.     rect.x += 4
  222.     rect.width -= 8
  223.     self.contents.clear_rect(rect)
  224.     self.contents.font.color = normal_color
  225.     self.contents.font.color.alpha = enabled ? 255 : 128
  226.     if Z6::ICONS[@commands[index]] != nil
  227.       draw_icon(Z6::ICONS[@commands[index]], rect.x, rect.y)
  228.       rect.x += 24
  229.     end
  230.     self.contents.draw_text(rect, @commands[index])
  231.   end
  232.  
  233. end
  234.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement