Advertisement
Guest User

XS - Title

a guest
Apr 5th, 2012
1,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.50 KB | None | 0 0
  1. #==============================================================================
  2. #   XaiL System - Title
  3. #   Author: Nicke
  4. #   Created: 02/01/2012
  5. #   Edited: 17/01/2012
  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. # No need for explaining, just a simple title scene with a few settings.
  14. #
  15. # *** Only for RPG Maker VX Ace. ***
  16. #==============================================================================
  17. ($imported ||= {})["XAIL-XS-TITLE"] = true
  18.  
  19. module XAIL
  20.   module TITLE
  21.   #--------------------------------------------------------------------------#
  22.   # * Settings
  23.   #--------------------------------------------------------------------------#
  24.   # title list, the icon_index (set to nil) and custom_scene is optional.
  25.   # TITLE_LIST:
  26.   # ID = ['Title', :symbol, :command, icon_index, custom_scene (not needed) ]
  27.   TITLE_LIST = []
  28.   TITLE_LIST[0] = ['New Game', :new_game, :command_new_game, 301]
  29.   TITLE_LIST[1] = ['Options',  :options,  :command_custom,   302,  Scene_Title]
  30.   TITLE_LIST[2] = ['Credits',  :credits,  :command_custom,   303,  Scene_Title]
  31.   TITLE_LIST[3] = ['Load',     :continue, :command_continue, 304]
  32.   TITLE_LIST[4] = ['Quit',     :shutdown, :command_shutdown, 305]
  33.  
  34.   # If center window is true you cannot modify the x value.
  35.   # TITLE_WINDOW [ Width, x, y, z, opacity, center window]
  36.   TITLE_WINDOW = [160, 0, 150, 200, 255, true]
  37.  
  38.   # Title logo. Set nil to use default.
  39.   # TITLE_LOGO = [ x, y, size, color, bold, shadow ]
  40.   TITLE_LOGO = [0, 0, 48, Colors::LightGreen, true, false]
  41.  
  42.   # TITLE_ALIGNMENT = 0 (left), 1 (center), 2 (right)
  43.   TITLE_ALIGNMENT = 1 # Default: 0.
  44.  
  45.   # The windowskin to use for the windows.
  46.   # nil to disable.
  47.   # SKIN = string
  48.   SKIN = nil
  49.  
  50.   # Disable all of the icons if you don't need them.
  51.   # ICON_ENABLE = true/false
  52.   ICON_ENABLE = true
  53.  
  54.   # Transition, nil to use default.
  55.   # TRANSITION [ SPEED, TRANSITION, OPACITY ]
  56.   # TRANSITION = [40, "Graphics/Transitions/1", 50]
  57.   TRANSITION = nil
  58.  
  59.   # Animate options.
  60.   # Set ANIM_WINDOW_TIMER to nil to disable.
  61.   ANIM_WINDOW_TIMER = 20 # Fade in time for window/icons.
  62.   ANIM_SCENE_FADE = 1000 # Fade out time for scene. Default: 1000.
  63.   ANIM_AUDIO_FADE = 1000 # Fade out time for audio. Default: 1000.
  64.  
  65.   # Switches enabled from start.
  66.   # Set to nil to disable.
  67.   # SWITCHES = [SWITCH_ID]
  68.   SWITCHES = [1]
  69.  
  70.   # Run a common event on startup?
  71.   # COMMON_EVENT = COMMON_EVENT_ID
  72.   COMMON_EVENT = 1
  73.  
  74.   # Skip title. (Only in test mode)
  75.   SKIP = true
  76.  
  77.   end
  78. end
  79. # *** Don't edit below unless you know what you are doing. ***
  80. #==============================================================================
  81. # ** Window_TitleCommand
  82. #==============================================================================
  83. class Window_TitleCommand < Window_Command
  84.  
  85.   def window_width
  86.     # // Method to return the width of TITLE_WINDOW.
  87.     return XAIL::TITLE::TITLE_WINDOW[0]
  88.   end
  89.  
  90.   def alignment
  91.     # // Method to return the alignment.
  92.     return XAIL::TITLE::TITLE_ALIGNMENT
  93.   end
  94.  
  95.   def make_command_list
  96.     # // Method to add the commands.
  97.     for i in XAIL::TITLE::TITLE_LIST
  98.       case i[1]
  99.       when :continue # Load
  100.         add_command(i[0], i[1], continue_enabled, i[4])
  101.       else
  102.         add_command(i[0], i[1], true, i[4])
  103.       end
  104.     end
  105.   end
  106.  
  107. end
  108. #==============================================================================#
  109. # ** Scene_Title
  110. #------------------------------------------------------------------------------
  111. #  New Scene :: Scene_Title
  112. #==============================================================================#
  113. class Scene_Title < Scene_Base
  114.  
  115.   alias xail_title_main main  
  116.   def main(*args, &block)
  117.     # // Method main.
  118.     command_new_game(true) if XAIL::TITLE::SKIP && $TEST && !$BTEST
  119.     return if XAIL::TITLE::SKIP && $TEST && !$BTEST
  120.     xail_title_main(*args, &block)
  121.   end
  122.  
  123.   alias xail_title_start start
  124.   def start(*args, &block)
  125.     # // Method to start the scene.
  126.     super
  127.     xail_title_start(*args, &block)
  128.     create_title_icon_window
  129.     create_title_command_window
  130.   end
  131.  
  132.   def terminate
  133.     # // Method to terminate.
  134.     super
  135.   end
  136.  
  137.   def create_title_command_window
  138.     # // Method to create the commands.
  139.     @command_window = Window_TitleCommand.new
  140.     @command_window.windowskin = Cache.system(XAIL::TITLE::SKIN) unless XAIL::TITLE::SKIN.nil?
  141.     if XAIL::TITLE::TITLE_WINDOW[5]
  142.       @command_window.x = (Graphics.width - @command_window.width) / 2
  143.     else
  144.       @command_window.x = XAIL::TITLE::TITLE_WINDOW[1]
  145.     end
  146.     @command_window.y = XAIL::TITLE::TITLE_WINDOW[2]
  147.     @command_window.z = XAIL::TITLE::TITLE_WINDOW[3]
  148.     @command_window.opacity = XAIL::TITLE::TITLE_WINDOW[4]
  149.     for i in XAIL::TITLE::TITLE_LIST
  150.       @command_window.set_handler(i[1], method(i[2]))
  151.     end
  152.     pre_animate_in(@command_window) unless XAIL::TITLE::ANIM_WINDOW_TIMER.nil?
  153.   end
  154.  
  155.   def create_title_icon_window
  156.     # // Method to create the menu icon window.
  157.     @command_icon = Window_Icon.new(0, 0, @command_window.width, XAIL::TITLE::TITLE_LIST.size)
  158.     @command_icon.alignment = XAIL::TITLE::TITLE_ALIGNMENT
  159.     @command_icon.enabled = XAIL::TITLE::ICON_ENABLE
  160.     @command_icon.draw_cmd_icons(XAIL::TITLE::TITLE_LIST, 3)
  161.     if XAIL::TITLE::TITLE_WINDOW[5]
  162.       @command_icon.x = (Graphics.width - @command_window.width) / 2
  163.     else
  164.       @command_icon.x = XAIL::TITLE::TITLE_WINDOW[1]
  165.     end
  166.     @command_icon.y = XAIL::TITLE::TITLE_WINDOW[2]
  167.     @command_icon.z = 201
  168.     @command_icon.opacity = 255
  169.     pre_animate_in(@command_icon) unless XAIL::TITLE::ANIM_WINDOW_TIMER.nil?
  170.   end
  171.  
  172.   def pre_animate_in(command)
  173.     # // Method for pre_animate the window.
  174.     command.opacity -= 255
  175.     command.contents_opacity -= 255
  176.   end
  177.  
  178.   def fade_animate(command, fade)
  179.     # // Method for fading in/out.
  180.     timer = XAIL::TITLE::ANIM_WINDOW_TIMER
  181.     while timer > 0
  182.       Graphics.update
  183.       case fade
  184.       when :fade_in
  185.       command.opacity += 255 / XAIL::TITLE::ANIM_WINDOW_TIMER unless command == @command_icon
  186.       command.contents_opacity += 255 / XAIL::TITLE::ANIM_WINDOW_TIMER
  187.       when :fade_out
  188.       command.opacity -= 255 / XAIL::TITLE::ANIM_WINDOW_TIMER unless command == @command_icon
  189.       command.contents_opacity -= 255 / XAIL::TITLE::ANIM_WINDOW_TIMER  
  190.       end
  191.       command.update
  192.       timer -= 1
  193.     end
  194.   end
  195.  
  196.   def post_start
  197.     # // Method for post_start.
  198.     super
  199.     unless XAIL::TITLE::ANIM_WINDOW_TIMER.nil?
  200.       fade_animate(@command_window, :fade_in)
  201.       fade_animate(@command_icon, :fade_in)
  202.     end
  203.   end
  204.  
  205.   def close_command_window
  206.     # // Method for close_command_window.
  207.     unless XAIL::TITLE::ANIM_WINDOW_TIMER.nil?
  208.       fade_animate(@command_icon, :fade_out)
  209.       fade_animate(@command_window, :fade_out)
  210.     end
  211.   end
  212.  
  213.   def fadeout_scene
  214.     time = XAIL::TITLE::ANIM_AUDIO_FADE
  215.     # // Method to fade out the scene.
  216.     RPG::BGM.fade(time)
  217.     RPG::BGS.fade(time)
  218.     RPG::ME.fade(time)
  219.     Graphics.fadeout(XAIL::TITLE::ANIM_SCENE_FADE * Graphics.frame_rate / 1000)
  220.     RPG::BGM.stop
  221.     RPG::BGS.stop
  222.     RPG::ME.stop
  223.   end
  224.  
  225.   def command_new_game(skip = false)
  226.     # // Method to call new game.
  227.     DataManager.setup_new_game
  228.     if skip
  229.       SceneManager.clear
  230.       DataManager.load_database
  231.       SceneManager.call(Scene_Map)
  232.     end
  233.     if !skip
  234.       close_command_window
  235.       fadeout_scene
  236.     end
  237.     $game_map.autoplay
  238.     if !XAIL::TITLE::SWITCHES.nil?
  239.       for i in XAIL::TITLE::SWITCHES
  240.         $game_switches[i] = true
  241.       end
  242.     end
  243.     if !XAIL::TITLE::COMMON_EVENT.nil?
  244.       $game_temp.reserve_common_event(XAIL::TITLE::COMMON_EVENT)
  245.     end
  246.     SceneManager.goto(Scene_Map) if !skip
  247.   end
  248.  
  249.   def command_continue
  250.     # // Method to call load.
  251.     close_command_window
  252.     SceneManager.call(Scene_Load)
  253.   end
  254.  
  255.   def command_shutdown
  256.     # // Method to call shutdown.
  257.     close_command_window
  258.     fadeout_scene
  259.     SceneManager.exit
  260.   end
  261.  
  262.   def command_custom
  263.     # // Method to call a custom command.
  264.     SceneManager.goto(@command_window.current_ext)
  265.   end
  266.  
  267.   alias xail_title_draw_game_title draw_game_title
  268.   def draw_game_title(*args, &block)
  269.     if !XAIL::TITLE::TITLE_LOGO.nil?
  270.       rect = Rect.new(XAIL::TITLE::TITLE_LOGO[0], XAIL::TITLE::TITLE_LOGO[1], Graphics.width, Graphics.height / 2)
  271.       @foreground_sprite.bitmap.font.size = XAIL::TITLE::TITLE_LOGO[2]
  272.       @foreground_sprite.bitmap.font.color = XAIL::TITLE::TITLE_LOGO[3]
  273.       @foreground_sprite.bitmap.font.bold = XAIL::TITLE::TITLE_LOGO[4]
  274.       @foreground_sprite.bitmap.font.shadow = XAIL::TITLE::TITLE_LOGO[5]
  275.     end
  276.     xail_title_draw_game_title(*args, &block)
  277.   end
  278.  
  279.   def perform_transition
  280.     # // Method to perform a transition.
  281.     if XAIL::TITLE::TRANSITION.nil?
  282.       Graphics.transition(15)
  283.     else
  284.       Graphics.transition(XAIL::TITLE::TRANSITION[0],XAIL::TITLE::TRANSITION[1],XAIL::TITLE::TRANSITION[2])
  285.     end
  286.   end
  287.  
  288. end # END OF FILE
  289.  
  290. #=*==========================================================================*=#
  291. # ** END OF FILE
  292. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement