Advertisement
Zetu

Neo Menu System LITE

May 24th, 2011
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.33 KB | None | 0 0
  1.                             #======================#
  2.                             #  Z-Systems by: Zetu  #
  3. #===========================#======================#===========================#
  4. #                *  *  *  Neo Menu System - LITE v1.09  *  *  *                #
  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.   $zsys = {} if $zsys == nil
  22.   $zsys["Menu"] = true
  23. module Z_Systems
  24.   module NeoMenu
  25.     #Items in Menu
  26.     MENU_ITEMS = [
  27.     'Item',
  28.     'Skill',
  29.     'Equip',
  30.     'Status',
  31.     'Save',
  32.     'End Game'
  33.     ]
  34.    
  35.     #Script to Run once Menu Item is selected
  36.     #If script includes '@status_window.index', it will prompt you to
  37.     #  select an actor.
  38.     COMMAND = {
  39.       'Item'       => '$scene = Scene_Item.new',
  40.       'Skill'      => '$scene = Scene_Skill.new(@status_window.index)',
  41.       'Equip'      => '$scene = Scene_Equip.new(@status_window.index)',
  42.       'Status'     => '$scene = Scene_Status.new(@status_window.index)',
  43.       'Save'       => '$scene = Scene_File.new(true, false, false)',
  44.       'End Game'   => '$scene = Scene_End.new',
  45.       #From Popular Scripts (Must have approprate script installed)
  46.       # KCG Large Party: (Capatability still in BETA/May not work in all layouts)
  47.       'Party'      => '$scene = Scene_PartyForm.new(0, Scene_PartyForm::HOST_MAP)'}
  48.      
  49.     #Expression that tests if script is to be disabled.
  50.     DISABLES = {#Disable option if true.
  51.       #This shows disabling if Save Game is disabled.
  52.       'Save'     => '$game_system.save_disabled',
  53.       #This shows disabling if game switch id 11 if off.
  54.       'Example1' => '$game_switches[11] == false',
  55.       #This shows disabling if variable id 1 is equal to or larger than 8.
  56.       'Example2' => '$game_variables[1] >= 8'}
  57.      
  58.     ICONS = { #Optional: Will not display an icon if nil.
  59.       'Item'     => 144,
  60.       'Skill'    => 137,
  61.       'Equip'    => 1,
  62.       'Status'   => 130,
  63.       'Save'     => 200,
  64.       'End Game' => 224,
  65.       'Party'    => 96,
  66.       'Clan'     => 176}
  67.    
  68.     module Index
  69.       ITEM      = Z_Systems::NeoMenu::MENU_ITEMS.index('Item')
  70.       SKILL     = Z_Systems::NeoMenu::MENU_ITEMS.index('Skill')
  71.       EQUIP     = Z_Systems::NeoMenu::MENU_ITEMS.index('Equip')
  72.       STATUS    = Z_Systems::NeoMenu::MENU_ITEMS.index('Status')
  73.       SAVE      = Z_Systems::NeoMenu::MENU_ITEMS.index('Save')
  74.       ENDGAME   = Z_Systems::NeoMenu::MENU_ITEMS.index('End Game')
  75.     end
  76. #========#======================#====#================================#========#
  77. #--------#                      #----# DO NOT EDIT PAST THIS POINT!!! #--------#
  78. #--------# End of Customization #----# Editing will cause death by    #--------#
  79. #--------#                      #----# brain asplosions.              #--------#
  80. #========#======================#====#================================#========#
  81.   end
  82. end
  83. $zsys = {} if $zsys == nil
  84. $zsys["Menu"] = true
  85.  
  86. class Scene_Menu < Scene_Base
  87.  
  88.   def create_command_window
  89.     menuitems = Z_Systems::NeoMenu::MENU_ITEMS
  90.     @command_window = Window_CommandNMS.new(160, menuitems)
  91.     @command_window.index = @menu_index
  92.     zs_nms_disable
  93.   end
  94.  
  95.   def zs_nms_disable
  96.     if $game_party.members.size == 0
  97.       for i in 0...Z_Systems::NeoMenu::MENU_ITEMS.size
  98.         command = Z_Systems::NeoMenu::MENU_ITEMS[i]
  99.         if needs_selection?(command)
  100.           @command_window.draw_item(i, false)
  101.         end
  102.       end
  103.     end
  104.     for i in 0...Z_Systems::NeoMenu::MENU_ITEMS.size
  105.       command = Z_Systems::NeoMenu::MENU_ITEMS[i]
  106.       if Z_Systems::NeoMenu::DISABLES.key?(command)
  107.         @command_window.draw_item(i, false) if eval(Z_Systems::NeoMenu::DISABLES[command])
  108.       end
  109.     end
  110.   end
  111.   def needs_selection?(command)
  112.     return Z_Systems::NeoMenu::COMMAND[command].include?('@status_window.index')
  113.   end
  114.   def update_command_selection
  115.     if Input.trigger?(Input::B)
  116.       Sound.play_cancel
  117.       $scene = Scene_Map.new
  118.     elsif Input.trigger?(Input::C)
  119.       selection = Z_Systems::NeoMenu::MENU_ITEMS[@command_window.index]
  120.       if $game_party.members.size == 0 and needs_selection?(selection)
  121.         Sound.play_buzzer
  122.         return
  123.       elsif Z_Systems::NeoMenu::DISABLES.key?(selection)
  124.         if eval(Z_Systems::NeoMenu::DISABLES[selection])
  125.           Sound.play_buzzer
  126.           return
  127.         end
  128.       end
  129.       Sound.play_decision
  130.       selection = Z_Systems::NeoMenu::MENU_ITEMS[@command_window.index]
  131.       if needs_selection?(selection)
  132.         start_actor_selection
  133.       else
  134.         eval(Z_Systems::NeoMenu::COMMAND[selection])
  135.       end
  136.     end
  137.   end
  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.       selection = Z_Systems::NeoMenu::MENU_ITEMS[@command_window.index]
  144.       $game_party.last_actor_index = @status_window.index
  145.       Sound.play_decision
  146.       eval(Z_Systems::NeoMenu::COMMAND[selection])
  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_scene's have been OVERWRITE
  159. class Scene_Item < Scene_Base
  160.   def return_scene
  161.     $scene = Scene_Menu.new(Z_Systems::NeoMenu::Index::ITEM)
  162.   end
  163. end
  164. class Scene_Skill < Scene_Base
  165.   def return_scene
  166.     $scene = Scene_Menu.new(Z_Systems::NeoMenu::Index::SKILL)
  167.   end
  168. end
  169. class Scene_Equip < Scene_Base
  170.   def return_scene
  171.     $scene = Scene_Menu.new(Z_Systems::NeoMenu::Index::EQUIP)
  172.   end
  173. end
  174. class Scene_Status < Scene_Base
  175.   def return_scene
  176.     $scene = Scene_Menu.new(Z_Systems::NeoMenu::Index::STATUS)
  177.   end
  178. end
  179. class Scene_Status < Scene_Base
  180.   def return_scene
  181.     $scene = Scene_Menu.new(Z_Systems::NeoMenu::Index::ENDGAME)
  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(Z_Systems::NeoMenu::Index::SAVE)
  192.     end
  193.   end
  194. end
  195. #-------------------------------------------------------------------------------
  196.  
  197. class Window_CommandNMS < Window_Selectable
  198.  
  199.   def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  200.     if row_max == 0
  201.       row_max = (commands.size + column_max - 1) / column_max
  202.     end
  203.     super(0, 0, width, row_max * WLH + 32, spacing)
  204.     @commands = commands
  205.     @item_max = commands.size
  206.     @column_max = column_max
  207.     refresh
  208.     self.index = 0
  209.   end
  210.  
  211.   def refresh
  212.     self.contents.clear
  213.     for i in 0...@item_max
  214.       draw_item(i)
  215.     end
  216.   end
  217.  
  218.   def draw_item(index, enabled = true)
  219.     rect = item_rect(index)
  220.     rect.x += 4
  221.     rect.width -= 8
  222.     self.contents.clear_rect(rect)
  223.     self.contents.font.color = normal_color
  224.     self.contents.font.color.alpha = enabled ? 255 : 128
  225.     if Z_Systems::NeoMenu::ICONS[@commands[index]] != nil
  226.       draw_icon(Z_Systems::NeoMenu::ICONS[@commands[index]], rect.x, rect.y)
  227.       rect.x += 24
  228.     end
  229.     self.contents.draw_text(rect, @commands[index])
  230.   end
  231.  
  232. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement