Advertisement
Zetu

Untitled

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