Advertisement
Guest User

XaiL System - Menu delux

a guest
May 2nd, 2015
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 26.52 KB | None | 0 0
  1. #==============================================================================
  2. #   XaiL System - Menu Delux
  3. #   Author: Nicke
  4. #   Created: 20/11/2012
  5. #   Edited: 08/02/2013
  6. #   Version: 1.1b
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ? Materials but above ? Main. Remember to save.
  12. #==============================================================================
  13. # Requires: XS - Core Script.
  14. #==============================================================================
  15. #
  16. # This script changes the way the menu scene works. Not compatible with
  17. # XS - Menu or XS - Icon Menu.
  18. #
  19. # Instructions are in the settings module below. Make sure you read through
  20. # everything so you understand each section.
  21. #
  22. # *** Only for RPG Maker VX Ace. ***
  23. #==============================================================================
  24. ($imported ||= {})["XAIL-XS-MENU_DELUX"] = true
  25.  
  26. module XAIL
  27.   module MENU_DELUX
  28.     #--------------------------------------------------------------------------#
  29.     # * Settings
  30.     #--------------------------------------------------------------------------#
  31.     # FONT:
  32.     # FONT = [name, size, color, bold, shadow]
  33.     FONT = [["Calibri", "Verdana"], 18, Color.new(255,255,255), true, true]
  34.    
  35.     # PLAYTIME_ICON:
  36.     # Set playtime window icon.
  37.     # PLAYTIME_ICON = icon_id
  38.     PLAYTIME_ICON = 280
  39.    
  40.     # MENU_ALIGNMENT:
  41.     # MENU_ALIGNMENT = 0 (left), 1 (center), 2 (right)
  42.     MENU_ALIGNMENT = 0 # Default: 2.
  43.    
  44.     # MENU_SKIN:
  45.     # The windowskin to use for the windows.
  46.     # Set to nil to disable.
  47.     # MENU_SKIN = string
  48.     MENU_SKIN = nil
  49.    
  50.     # MENU_LIST:
  51.     # name, icon_index and custom are optional.
  52.     # If name is empty it will use the corresponding symbol as name instead.
  53.     # To make a command a common event you need to set custom to the common event
  54.     # id you want to run as seen below.
  55.     # symbol => [name, description, icon_index, enabled, personal, custom]
  56.     MENU_LIST = {
  57.       :item      => ["Objets", "Browse through your acquired items.", 264, true, false],
  58.       :equip     => ["Équipment", "Change your equipment.", 170, true, true],
  59.       :skill     => ["Compétences", "Manage your available skills.", 115, true, true],
  60.       :status    => ["Stats", "See the current status of the hero.", 234, true, true],
  61.       :formation => ["Groupe", "Change the formation of the party.", 12, true, false],
  62.       :com_event => ["Map", "Not working", 231, true, false, 1],
  63.       :quest => ["Quête", "Liste des quêtes.", 238, true, false],
  64.       :save      => ["Sauvegarder", "Record your progress.", 286, true, false],
  65.       :load      => ["Charger", "Load your saved progress.", 230, true, false, Scene_Load],
  66.       :game_end  => ["Quitter", "Exit the program.", 121, true, false]
  67.     } # Don't remove this line!
  68.    
  69.     # MENU_SAVE = true/false
  70.     # Override enabled option for save (so you can change it ingame).
  71.     MENU_SAVE = true
  72.    
  73.     # If MENU_CUSTOM is true you will have to add the commands yourself
  74.     # ingame, which can be useful for certain quest related stuff or if you
  75.     # want to enable/disable menu commands.
  76.     # To add/remove a command ingame follow these instructions:
  77.     #
  78.     # In a script call do like this:
  79.     # menu_scene(key, type)
  80.     # menu_scene(:item,:add) # To add item to menu list.
  81.     # menu_scene(:item,:del) # To remove item from menu list.
  82.     #
  83.     # In a conditional branch you can check if a menu command is
  84.     # enabled/disabled:
  85.     # menu_active?(key)
  86.     # menu_active?(:item) # Check if item is enabled.
  87.     # !menu_active?(:item) # Check if item is disabled.
  88.     #
  89.     # To set a id to be enabled do like this:
  90.     # menu_active(:skill, true) # Set menu skill to be enabled.
  91.     #
  92.     # To add/remove all available menu commands use one of the
  93.     # following methods in a script call:
  94.     # menu_add_all
  95.     # menu_del_all
  96.     #
  97.     # MENU_CUSTOM = true/false
  98.     MENU_CUSTOM = false
  99.    
  100.     # The text to be displayed if no menu items is available.
  101.     # Only used if MENU_CUSTOM is true.
  102.     # MENU_EMPTY = string
  103.     EMPTY = "Menu is not available at this point..."
  104.    
  105.     # MENU_MUSIC:
  106.     # Set the music to be played at the menu scene.
  107.     # This is optional.
  108.     # MUSIC = true/false
  109.     MUSIC = true
  110.     # MUSIC_BGM = [name, volume, pitch]
  111.     MUSIC_BGM = ["", 70, 100]
  112.     # MUSIC_BGS = [name, volume, pitch]
  113.     MUSIC_BGS = ["Darkness", 50, 100]
  114.    
  115.     # ANIM_LIST:
  116.     # A list of animation images.
  117.     # name  =>  [z, zoom_x, zoom_y, blend_type, opacity]
  118.     ANIM_LIST = {
  119.       "Menu_Fog1"   => [1, 1.2, 1.2, 1, 125],
  120.       "Menu_Fog2"   => [1, 1.8, 1.8, 1, 155]
  121.     } # Don't remove this line!
  122.    
  123.     # BACKGROUND:
  124.     # name => [x, y, z, opacity]
  125.     BACKGROUND = {
  126.       #"" => [0, 0, 200, 255]
  127.     } # Don't remove this line!
  128.    
  129.     # Show vocab for HP, MP and TP.
  130.     # BAR_VOCAB = true/false
  131.     BAR_VOCAB = true
  132.    
  133.     # BAR_COLOR = rgba(255,255,255,255)
  134.     # Set the color of the gauges.
  135.     BAR_HP = [Color.new(255,25,25,32), Color.new(255,150,150)]
  136.     BAR_MP = [Color.new(25,25,255,32), Color.new(150,150,255)]
  137.     BAR_TP = [Color.new(25,255,25,32), Color.new(150,255,150)]
  138.    
  139.     # DETAILS:
  140.     # Setup details here. (Recommended to use the default ones since you will
  141.     # need a bit RGSS knowledge to add more.)
  142.     def self.details
  143.       ["#{Vocab::currency_unit}: #{$game_party.gold}",
  144.       "Steps: #{$game_party.steps}",
  145.       "Collected Items: #{$game_party.all_items.size}",
  146.       "Map: #{$data_mapinfos[$game_map.map_id].name}",
  147.       "Leader: #{$game_party.leader.name}",
  148.       "Battle Count: #{$game_system.battle_count}",
  149.       "Save Count: #{$game_system.save_count}",
  150.       "Party Members: #{$game_party.all_members.size}",
  151.       "Highest Level: #{$game_party.highest_level}",
  152.       "Variable II: #{$game_variables[2]}"]
  153.     end
  154.    
  155.     # DETAILS_ICONS:
  156.     # DETAILS_ICONS[id] = icon_id
  157.     # Set the details icon_id. (optional)
  158.     # Should be in the same order as details.
  159.     # Use nil to disable a icon.
  160.     DETAILS_ICONS = []
  161.     DETAILS_ICONS[0]  = 361 # GOLD
  162.     DETAILS_ICONS[1]  = 474  # STEPS
  163.     DETAILS_ICONS[2]  = 260  # ITEMS
  164.     DETAILS_ICONS[3]  = 232  # MAP
  165.     DETAILS_ICONS[4]  = 158 # LEADER
  166.     DETAILS_ICONS[5]  = 131  # BATTLE COUNT
  167.     DETAILS_ICONS[6]  = 224  # SAVE COUNT
  168.     DETAILS_ICONS[7]  = 121  # PARTY MEMBERS à changer
  169.     DETAILS_ICONS[8]  = 14   # HIGHEST LEVEL
  170.     DETAILS_ICONS[9]  = 1  # DEATH
  171.     DETAILS_ICONS[10] = nil  # VARIABLE 2
  172.    
  173.     # Transition, nil to use default.
  174.     # TRANSITION [speed, transition, opacity]
  175.     TRANSITION = nil
  176.    
  177.   end
  178. end
  179. # *** Don't edit below unless you know what you are doing. ***
  180. #==============================================================================#
  181. # ** Error Handler
  182. #==============================================================================#
  183.   unless $imported["XAIL-XS-CORE"]
  184.     # // Error handler when XS - Core is not installed.
  185.     msg = "The script %s requires the latest version of XS - Core in order to function properly."
  186.     name = "XS - Menu Delux"
  187.     msgbox(sprintf(msg, name))
  188.     exit
  189.   end
  190. #==============================================================================#
  191. # ** Game_System
  192. #==============================================================================#
  193. class Game_System
  194.  
  195.   attr_accessor :menu_list
  196.  
  197.   alias xail_menu_delux_gm_sys_initialize initialize
  198.   def initialize(*args, &block)
  199.     # // Method to initialize game system.
  200.     xail_menu_delux_gm_sys_initialize(*args, &block)
  201.     @menu_list = {}
  202.   end
  203.  
  204.   def get_menu
  205.     # // Method to get the menu list.
  206.     XAIL::MENU_DELUX::MENU_CUSTOM ? @menu_list : XAIL::MENU_DELUX::MENU_LIST
  207.   end
  208.  
  209. end
  210. #==============================================================================#
  211. # ** Game_Interpreter
  212. #==============================================================================#
  213. class Game_Interpreter
  214.  
  215.   def menu_scene(key, type = :add)  
  216.     # // Method to add/remove a menu item to the list.
  217.     case type
  218.       when :add # // Add menu id.
  219.        unless $game_system.menu_list.include?(XAIL::MENU_DELUX::MENU_LIST[key])
  220.          $game_system.menu_list[key] = XAIL::MENU_DELUX::MENU_LIST[key]          
  221.        end unless XAIL::MENU_DELUX::MENU_LIST[key].nil?
  222.       when :del # // Remove menu id.
  223.       unless XAIL::MENU_DELUX::MENU_LIST[key].nil?
  224.         $game_system.menu_list.delete(key)
  225.       end
  226.     end
  227.   end
  228.  
  229.   def menu_active?(key)
  230.     # // Method to check if menu key is enabled.
  231.     # This will return nil if menu item not added in the list.
  232.     return $game_system.menu_list[key][3] rescue nil
  233.   end
  234.  
  235.   def menu_active(key, enabled)
  236.     # // Method to enable id.
  237.     $game_system.menu_list[key][3] = enabled
  238.   end
  239.  
  240.   def menu_add_all
  241.     # // Method to add all available menu items.
  242.     XAIL::MENU_DELUX::MENU_LIST.each_key {|key| menu_scene(key) }
  243.   end
  244.  
  245.   def menu_del_all
  246.     # // Method to remove all available menu items.
  247.     XAIL::MENU_DELUX::MENU_LIST.each_key {|key| menu_scene(key, :del) }
  248.   end
  249.  
  250. end
  251. #==============================================================================
  252. # ** Window_MenuCommand
  253. #==============================================================================
  254. class Window_MenuCommand < Window_Command
  255.  
  256.   def window_width
  257.     # // Method to return the width of the window.
  258.     return Graphics.width / 4
  259.   end
  260.  
  261.   def window_height
  262.     # // Method to return the height of the window.
  263.     return Graphics.height
  264.   end
  265.  
  266.   def alignment
  267.     # // Method to return the alignment.
  268.     return XAIL::MENU_DELUX::MENU_ALIGNMENT
  269.   end
  270.  
  271.   def menu_color(color, enabled = true)
  272.      # // Method to set the color and alpha if not enabled.
  273.     contents.font.color.set(color)
  274.     contents.font.color.alpha = Colors::AlphaMenu unless enabled
  275.   end
  276.  
  277.   def item_rect_for_text(index)
  278.     # // Method to draw item rect for text.
  279.     rect = item_rect(index)
  280.     rect.x += 25
  281.     draw_line_ex(rect.x - 4, rect.y + 9, Color.new(255,255,255), Color.new(0,0,0,128))
  282.     draw_icon(XAIL::MENU_DELUX::MENU_LIST.values[index][2], -2, rect.y) unless XAIL::MENU_DELUX::MENU_LIST.values[index][2].nil?
  283.     rect
  284.   end
  285.  
  286.   def draw_item(index)
  287.     # // Method to draw the command item.
  288.     contents.font.name = XAIL::MENU_DELUX::FONT[0]
  289.     contents.font.size = XAIL::MENU_DELUX::FONT[1]
  290.     # // Save enable option.
  291.     XAIL::MENU_DELUX::MENU_LIST[:save][3] = save_enabled if XAIL::MENU_DELUX::MENU_SAVE
  292.     # // Default enable option.
  293.     menu_color(XAIL::MENU_DELUX::FONT[2], menu_enabled?(index))
  294.     # // Font settings
  295.     contents.font.bold = XAIL::MENU_DELUX::FONT[3]
  296.     contents.font.shadow = XAIL::MENU_DELUX::FONT[4]
  297.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  298.     reset_font_settings
  299.   end
  300.  
  301.   def menu_enabled?(index)
  302.     # // Method to check if menu item is enabled.
  303.     return $game_system.get_menu.values[index][3]
  304.   end
  305.  
  306.   def make_command_list
  307.     # // Method to add the commands.
  308.     $game_system.get_menu.each {|key, value|
  309.       name = value[0] == "" ? key.id2name.capitalize : value[0]
  310.       XAIL::MENU_DELUX::MENU_LIST[:save][3] = save_enabled if XAIL::MENU_DELUX::MENU_SAVE
  311.       add_command(name, key, value[3], value[5].nil? ? nil : value[5])
  312.     }
  313.   end
  314.  
  315. end
  316. #==============================================================================
  317. # ** Window_MenuStatus
  318. #==============================================================================
  319. class Window_MenuStatus < Window_Selectable
  320.  
  321.   def initialize(x, y)
  322.     # // Method to initialize the window.
  323.     super(x, y, window_width, window_height)
  324.     self.arrows_visible = false
  325.     @pending_index = -1
  326.     refresh
  327.   end
  328.  
  329.   def window_width
  330.     # // Method to determine window width.
  331.     return Graphics.width / 2.4
  332.   end
  333.  
  334.   def col_max
  335.     # // Method to determine col max.
  336.     return 2
  337.   end
  338.  
  339.   def spacing
  340.     # // Method to determine spacing.
  341.     return 6 if Graphics.width == 544 # For standard resolution.
  342.     return 44                         # For high resolution.
  343.   end
  344.  
  345.   def item_width
  346.     # // Method to determine item width.
  347.     return 98
  348.   end
  349.  
  350.   def item_height
  351.     # // Method to determine item height.
  352.     return 128
  353.   end
  354.  
  355.   def refresh
  356.     # // Method to refresh the window.
  357.     super
  358.     # // Only display cursor arrow if more or equal to 5 party members.
  359.     if $game_party.all_members.size >= 5
  360.       self.arrows_visible = true
  361.     end
  362.   end
  363.  
  364.   def draw_item(index)
  365.     # // Method to draw item.
  366.     actor = $game_party.members[index]
  367.     rect = item_rect(index)
  368.     # // Face
  369.     draw_actor_face(actor, rect.x + 1, rect.y + 1, true)
  370.     # // Name
  371.     draw_font_text(actor.name, rect.x + 4, rect.y, rect.width, 0, XAIL::MENU_DELUX::FONT[0], 20, XAIL::MENU_DELUX::FONT[2])
  372.     # // Level
  373.     lvl = "#{Vocab::level_a}: #{actor.level}"
  374.     draw_font_text(lvl, rect.x + 4, rect.y + 64, rect.width, 0, XAIL::MENU_DELUX::FONT[0], 18, XAIL::MENU_DELUX::FONT[2])
  375.     # // Class
  376.     # // Check if Yanfly Class System is installed.
  377.     if $imported["YEA-ClassSystem"]
  378.       actor_class = actor.subclass.nil? ? actor.class.name : "#{actor.class.name} [#{actor.subclass.name}]"
  379.     else
  380.       actor_class = actor.class.name
  381.     end    
  382.     draw_font_text(actor_class, rect.x - 4, rect.y + 76, rect.width, 2, XAIL::MENU_DELUX::FONT[0], 16, XAIL::MENU_DELUX::FONT[2])
  383.     # // Stats
  384.     draw_menu_stats(actor, :hp, rect.x, rect.y + 90, XAIL::MENU_DELUX::BAR_HP[0], XAIL::MENU_DELUX::BAR_HP[1], rect.width - 2)
  385.     draw_menu_stats(actor, :mp, rect.x, rect.y + 100, XAIL::MENU_DELUX::BAR_MP[0], XAIL::MENU_DELUX::BAR_MP[1], rect.width - 2)
  386.     draw_menu_stats(actor, :tp, rect.x, rect.y + 110, XAIL::MENU_DELUX::BAR_TP[0], XAIL::MENU_DELUX::BAR_TP[1], rect.width - 2)
  387.   end
  388.  
  389.   def draw_menu_stats(actor, stat, x, y, color1, color2, width)
  390.     # // Method to draw actor hp & mp.
  391.     case stat
  392.     when :hp
  393.       rate = actor.hp_rate ; vocab = Vocab::hp_a ; values = [actor.hp, actor.mhp]
  394.     when :mp
  395.       rate = actor.mp_rate ; vocab = Vocab::mp_a ; values = [actor.mp, actor.mmp]
  396.     when :tp
  397.       rate = actor.tp_rate ; vocab = Vocab::tp_a ; values = [actor.tp, actor.max_tp]
  398.     end
  399.     contents.font.name = XAIL::MENU_DELUX::FONT[0]
  400.     contents.font.size = 14 # // Override font size.
  401.     contents.font.color = XAIL::MENU_DELUX::FONT[2]
  402.     contents.font.bold = XAIL::MENU_DELUX::FONT[3]
  403.     contents.font.shadow = XAIL::MENU_DELUX::FONT[4]
  404.     # // Draw guage.
  405.     draw_gauge_ex(x, y - 8, width, 8, rate, color1, color2)
  406.     # // Draw stats.
  407.     draw_text(x + 2, y, width, line_height, values[0], 0)
  408.     draw_text(x + 1, y, width, line_height, values[1], 2)
  409.     # // Draw vocab.
  410.     draw_text(x, y, width, line_height, vocab, 1) if XAIL::MENU_DELUX::BAR_VOCAB
  411.     reset_font_settings
  412.   end
  413.  
  414. end
  415. #==============================================================================
  416. # ** Window_Menu_Details
  417. #==============================================================================
  418. class Window_Menu_Details < Window_Base
  419.  
  420.   def initialize(x, y)
  421.     # // Method to initialize.
  422.     super(x, y, window_width, window_height)
  423.     @leader = $game_party.leader
  424.     refresh
  425.   end
  426.  
  427.   def window_width
  428.     # // Method to determine window width.
  429.     return Graphics.width / 3
  430.   end
  431.  
  432.   def window_height
  433.     # // Method to determine window height.
  434.     return Graphics.height
  435.   end
  436.  
  437.   def refresh
  438.     # // Method to refresh the window.
  439.     contents.clear
  440.     # // Draw details.
  441.     y = -10
  442.     XAIL::MENU_DELUX.details.each_index {|i|
  443.       draw_line_ex(0, y += 24, Color.new(255,255,255,32), Color.new(0,0,0,64))
  444.       draw_font_text(XAIL::MENU_DELUX.details[i], -4, line_height * i + 4, contents_width, 2, XAIL::MENU_DELUX::FONT[0], 16, XAIL::MENU_DELUX::FONT[2])
  445.     }
  446.     # // Draw icons.
  447.     draw_icons(XAIL::MENU_DELUX::DETAILS_ICONS, :vertical, 2, line_height * 0 + 2)
  448.   end
  449.  
  450.   def update
  451.     # // Method to update details window.
  452.     super
  453.     if @leader != $game_party.leader
  454.       @leader = $game_party.leader
  455.       refresh
  456.     end
  457.   end
  458.  
  459. end
  460. #==============================================================================
  461. # ** Window_Menu_Playtime
  462. #==============================================================================
  463. class Window_Menu_Playtime < Window_Base
  464.  
  465.   def initialize(x, y)
  466.     # // Method to initialize.
  467.     super(x, y, 120, fitting_height(1))
  468.     @playtime = $game_system.playtime_s
  469.     refresh
  470.   end
  471.  
  472.   def refresh
  473.     # // Method to refresh the window.
  474.     contents.clear
  475.     # // Draw icon.
  476.     draw_icon(XAIL::MENU_DELUX::PLAYTIME_ICON, 4, 0)
  477.     # // Draw playtime.
  478.     draw_font_text(@playtime, 0, 6, contents_width, 2, XAIL::MENU_DELUX::FONT[0], 22, XAIL::MENU_DELUX::FONT[2])
  479.   end
  480.  
  481.   def update
  482.     # // Method to update the window.
  483.     super
  484.     @playtime = $game_system.playtime_s
  485.     refresh
  486.   end
  487.  
  488. end
  489. #==============================================================================#
  490. # ** Window_Menu_Help
  491. #==============================================================================#
  492. class Window_Menu_Help < Window_Help
  493.  
  494.   attr_accessor :index
  495.  
  496.   alias xail_icon_menu_winhelp_init initialize
  497.   def initialize(*args, &block)
  498.     # // Method to initialize help window.
  499.     xail_icon_menu_winhelp_init(*args, &block)
  500.     @index = 0
  501.   end
  502.  
  503.   def set_text(text, enabled)
  504.     # // Method to set a new help text.
  505.     if text != @text
  506.       menu_color(XAIL::MENU_DELUX::FONT[2], enabled)
  507.       @text = text
  508.       refresh
  509.     end
  510.   end
  511.  
  512.   def refresh
  513.     # // Refresh help contents.
  514.     contents.clear
  515.     draw_help_text
  516.   end
  517.  
  518.   def draw_help_text
  519.     # // Method to draw the help text.
  520.     contents.font.name = XAIL::MENU_DELUX::FONT[0]
  521.     contents.font.size = XAIL::MENU_DELUX::FONT[1]
  522.     menu_color(XAIL::MENU_DELUX::FONT[2], menu_enabled?(@index))
  523.     contents.font.bold = XAIL::MENU_DELUX::FONT[3]
  524.     contents.font.shadow = XAIL::MENU_DELUX::FONT[4]
  525.     # // Draw title and description for the menu.
  526.     draw_line_ex(0, 14, Color.new(255,255,255), Color.new(0,0,0,128))
  527.     draw_text_ex_no_reset(0, 0, @text)
  528.     reset_font_settings
  529.   end
  530.  
  531.   def menu_enabled?(index)
  532.     # // Method to check if menu item is enabled.
  533.     return $game_system.get_menu.values[index][3]
  534.   end
  535.  
  536.   def menu_color(color, enabled = true)
  537.      # // Method to set the color and alpha if not enabled.
  538.     contents.font.color.set(color)
  539.     contents.font.color.alpha = 150 unless enabled
  540.   end
  541.  
  542. end
  543. #==============================================================================#
  544. # ** Scene_MenuBase
  545. #==============================================================================#
  546. class Scene_MenuBase < Scene_Base
  547.  
  548.   def start
  549.     # // Method to start the scene.
  550.     super
  551.     @actor = $game_party.menu_actor
  552.     if SceneManager.scene_is?(Scene_Menu)
  553.       @backgrounds = []
  554.       @animations = []
  555.       create_menu_backgrounds
  556.       create_menu_animations
  557.     end
  558.   end
  559.  
  560.   def create_menu_backgrounds
  561.     # // Method to create custom background(s).
  562.     XAIL::MENU_DELUX::BACKGROUND.each {|key, value| @backgrounds << [Sprite.new, key] }
  563.     @backgrounds.each {|i|
  564.       i[0].bitmap = Cache.system(i[1])
  565.       i[0].x = XAIL::MENU_DELUX::BACKGROUND[i[1]][0]
  566.       i[0].y = XAIL::MENU_DELUX::BACKGROUND[i[1]][1]
  567.       i[0].z = XAIL::MENU_DELUX::BACKGROUND[i[1]][2]
  568.       i[0].opacity = XAIL::MENU_DELUX::BACKGROUND[i[1]][3]
  569.     }
  570.   end
  571.  
  572.   def create_menu_animations
  573.     # // Method to create custom animation(s).
  574.     # name  =>  [z, zoom_x, zoom_y, blend_type, opacity]
  575.     XAIL::MENU_DELUX::ANIM_LIST.each {|key, value| @animations.push << [Plane.new, key] }
  576.     @animations.each {|i|
  577.       i[0].bitmap = Cache.system(i[1])
  578.       i[0].z = XAIL::MENU_DELUX::ANIM_LIST[i[1]][0]
  579.       i[0].zoom_x = XAIL::MENU_DELUX::ANIM_LIST[i[1]][1]
  580.       i[0].zoom_y = XAIL::MENU_DELUX::ANIM_LIST[i[1]][2]
  581.       i[0].blend_type = XAIL::MENU_DELUX::ANIM_LIST[i[1]][3]
  582.       i[0].opacity = XAIL::MENU_DELUX::ANIM_LIST[i[1]][4]
  583.     }
  584.   end
  585.  
  586.   alias xail_upd_menubase_delux_upd update
  587.   def update(*args, &block)
  588.     # // Method for updating the scene.
  589.     xail_upd_menubase_delux_upd(*args, &block)
  590.     if SceneManager.scene_is?(Scene_Menu)
  591.       for i in 0...@animations.size
  592.         @animations[i][0].ox += 1.2 - i
  593.         @animations[i][0].oy -= 0.6 + i
  594.       end unless scene_changing?
  595.       delay?(1)
  596.     end
  597.   end
  598.  
  599.   def delay?(amount)
  600.     # // Method to delay.
  601.     amount.times do
  602.       update_basic
  603.     end
  604.   end
  605.  
  606.   alias xail_menubase_delux_transition perform_transition
  607.   def perform_transition(*args, &block)
  608.     # // Method to create the transition.
  609.     return if $game_system.get_menu.empty?
  610.     if XAIL::MENU_DELUX::TRANSITION.nil?
  611.       xail_menubase_delux_transition(*args, &block)
  612.     else
  613.       Graphics.transition(XAIL::MENU_DELUX::TRANSITION[0],XAIL::MENU_DELUX::TRANSITION[1],XAIL::MENU_DELUX::TRANSITION[2])
  614.     end
  615.   end
  616.  
  617.   def dispose_sprites
  618.     # // Method to dispose sprites.
  619.     @backgrounds.each {|i| i[0].dispose unless i[0].nil? ; i[0] = nil } rescue nil
  620.     @animations.each {|i| i[0].dispose unless i[0].nil? ; i[0] = nil } rescue nil
  621.   end
  622.  
  623.   def terminate
  624.     # // Method to terminate.
  625.     super
  626.     dispose_sprites unless SceneManager.scene_is?(Scene_Menu)
  627.   end
  628.  
  629. end
  630. #==============================================================================#
  631. # ** Scene_Menu
  632. #==============================================================================#
  633. class Scene_Menu < Scene_MenuBase
  634.  
  635.   def start
  636.     super
  637.     # // Method to start the scene.
  638.     # // Return if menu empty.
  639.     return command_map if $game_system.get_menu.empty?
  640.     # // Create windows.
  641.     create_menu_command_window
  642.     create_menu_status_window
  643.     create_menu_details_window
  644.     create_menu_playtime_window
  645.     create_menu_help_window
  646.     # // Set help text to first menu command.
  647.     help_update(@command_window.index)
  648.     # // Play music if enabled.
  649.     play_menu_music if XAIL::MENU_DELUX::MUSIC
  650.   end
  651.  
  652.   def create_menu_command_window
  653.     # // Method to create the command window.
  654.     @command_window = Window_MenuCommand.new
  655.     @command_window.windowskin = Cache.system(XAIL::MENU_DELUX::MENU_SKIN) unless XAIL::MENU_DELUX::MENU_SKIN.nil?
  656.     @command_window.back_opacity = 96
  657.     $game_system.get_menu.each {|key, value|
  658.       unless value[5].nil?
  659.         @command_window.set_handler(key, method(:command_custom))
  660.       else
  661.         if value[4]
  662.           @command_window.set_handler(key, method(:command_personal))
  663.         else
  664.           @command_window.set_handler(key, method("command_#{key}".to_sym))
  665.         end
  666.       end
  667.     }    
  668.     @command_window.set_handler(:cancel, method(:return_scene))
  669.   end
  670.  
  671.   def create_menu_status_window
  672.     # // Method to create the status window.
  673.     @status_window = Window_MenuStatus.new(0, 0)
  674.     @status_window.height = Graphics.height - 72
  675.     @status_window.x = @command_window.width
  676.     @status_window.back_opacity = 96
  677.   end
  678.  
  679.   def create_menu_details_window
  680.     # // Method to create the details window.
  681.     @details_window = Window_Menu_Details.new(0, 0)
  682.     @details_window.x = Graphics.width - @details_window.width
  683.     @details_window.back_opacity = 96
  684.   end
  685.  
  686.   def create_menu_playtime_window
  687.     # // Method to create the playtime window.
  688.     @playtime_window = Window_Menu_Playtime.new(0, 0)
  689.     @playtime_window.x = Graphics.width - @playtime_window.width
  690.     @playtime_window.y = Graphics.height - @playtime_window.height - 26
  691.     @playtime_window.opacity = 0
  692.     @playtime_window.z = 201
  693.   end
  694.  
  695.   def create_menu_help_window
  696.     # // Method to create the help window.
  697.     @help_window = Window_Menu_Help.new(2)
  698.     @help_window.viewport = @viewport
  699.     @help_window.windowskin = Cache.system(XAIL::MENU_DELUX::MENU_SKIN) unless XAIL::MENU_DELUX::MENU_SKIN.nil?
  700.     @help_window.index = @command_window.index
  701.     @help_window.y = Graphics.height - @help_window.height
  702.     @help_window.back_opacity = 255
  703.     @help_window.z = 200
  704.   end
  705.  
  706.   def play_menu_music
  707.     # // Method to play menu music.
  708.     @last_bgm = RPG::BGM.last
  709.     @last_bgs = RPG::BGS.last
  710.     bgm = XAIL::MENU_DELUX::MUSIC_BGM
  711.     bgs = XAIL::MENU_DELUX::MUSIC_BGS
  712.     Sound.play(bgm[0], bgm[1], bgm[2], :bgm)
  713.     Sound.play(bgs[0], bgs[1], bgs[2], :bgs)
  714.   end
  715.  
  716.   alias xail_upd_menu_delux_upd update
  717.   def update(*args, &block)
  718.     # // Method for updating the scene.
  719.     xail_upd_menu_delux_upd(*args, &block)
  720.     old_index = @help_window.index
  721.     help_update(@command_window.index) if old_index != @command_window.index
  722.   end
  723.  
  724.   def help_update(index)
  725.     # // If index changes update help window text.
  726.     list = XAIL::MENU_DELUX::MENU_LIST
  727.     icon = list.values[index][2].nil? ? "" : list.values[index][2]
  728.     name = list.values[index][0] == "" ? list.keys[index].id2name.capitalize : list.values[index][0]
  729.     if icon == "" ; title = name ; else ; title = '\i[' + icon.to_s + ']' + name ; end
  730.     desc = '\c[0]' + list.values[index][1]
  731.     text = "#{title}\n#{desc}"
  732.     enabled = list.values[index][3]
  733.     @help_window.index = index
  734.     @help_window.set_text(text, enabled)
  735.   end
  736.  
  737.   def on_personal_ok
  738.     # // Method override on personal ok.
  739.     scene = "Scene_#{@command_window.current_symbol.to_s.capitalize}".to_class
  740.     SceneManager.call(scene)
  741.   end
  742.  
  743.   def command_custom
  744.     # // Method to call a custom command. (Don't remove)
  745.     if @command_window.current_ext.is_a?(Integer)
  746.       $game_temp.reserve_common_event(@command_window.current_ext)
  747.       return command_map
  748.     end
  749.     SceneManager.call(@command_window.current_ext)
  750.   end
  751.  
  752.   def command_map
  753.     # // command_map (Don't remove)
  754.     if $game_system.get_menu.empty?
  755.       Sound.play_buzzer
  756.       $game_message.texts << XAIL::MENU_DELUX::EMPTY
  757.     end
  758.     SceneManager.call(Scene_Map)
  759.   end
  760.  
  761.   def pre_terminate
  762.     # // Method to pre terminate scene menu.
  763.     # // Play last bgm and bgs if menu music is enabled.
  764.     if XAIL::MENU_DELUX::MUSIC
  765.       @last_bgm.replay rescue nil
  766.       @last_bgs.replay rescue nil
  767.     end
  768.   end
  769.  
  770. end # END OF FILE
  771.  
  772. #=*==========================================================================*=#
  773. # ** END OF FILE
  774. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement