Advertisement
Guest User

Simple Title

a guest
Dec 31st, 2011
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.71 KB | None | 0 0
  1. #==============================================================================
  2. #   Simple Title
  3. #   Author: Nicke
  4. #   Created: 23/12/2011
  5. #   Edited: 23/12/2011
  6. #   Version: 1.0
  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. ($imported ||= {})["NICKE-SIMPLE-TITLE"] = true
  16.  
  17. module NICKE
  18.   module TITLE
  19.   #--------------------------------------------------------------------------#
  20.   # * Settings
  21.   #--------------------------------------------------------------------------#
  22.   # When adding a new menu item make sure you edit in title_choice method as well.
  23.   # Right now the menu supports 5 items with the appropriated methods to it.
  24.   # MENU_LIST ['ITEM 1', 'ITEM 2'] etc.
  25.   MENU_LIST = ['New Tale', 'Load', 'Credits', 'Options', 'Quit']
  26.  
  27.   # If you use MENU_LIST.size the menu items will be pushed horizontal and
  28.   # when using that option make sure you don't add too much items or else a
  29.   # few of them will go off the screen eventually.
  30.   # Menu Window [ Columns, x, y, z, opacity ]
  31.   WINDOW = [MENU_LIST.size, 0, 360, 200, 255]
  32.  
  33.   # Transition, nil to use default.
  34.   # TRANSITION [ SPEED, TRANSITION, OPACITY ]
  35.   TRANSITION = nil
  36.  
  37.   # Title background. (System folder)
  38.   BACK = "Title" # (Default name)
  39.  
  40.   # Title window to fade in/out.
  41.   # Set to nil to disable.
  42.   ANIM_WINDOW_TIMER = 60
  43.  
  44.   # Player transparent on startup.
  45.   PLAYER_TRANSPARENT = true
  46.  
  47.   # Switches enabled from start.
  48.   # Set to nil to disable.
  49.   # SWITCHES = [SWITCH_ID]
  50.   SWITCHES = nil
  51.  
  52.   # Start placement for the player as in map_id, x and y coordinates.
  53.   # Set to nil to disable.
  54.   # START_POS = [MAP_ID, X, Y]
  55.   START_POS = nil
  56.  
  57.   # Run a common event on startup?
  58.   # COMMON_EVENT = { ID => COMMON_EVENT_ID }
  59.   COMMON_EVENT = {
  60.          0 => 1,
  61.          1 => 3,
  62.   } # Do Not Remove
  63.  
  64.   # Skip title.
  65.   SKIP = false
  66.  
  67.   end
  68. end
  69. # *** Don't edit below unless you know what you are doing. ***
  70. #==============================================================================#
  71. # ** Game_Interpreter
  72. #------------------------------------------------------------------------------
  73. #  Method for running a commont event.
  74. #==============================================================================#
  75. class Game_Interpreter
  76.  
  77.   def run_event(event_list, event_id=0)
  78.     @child_interpreter = Game_Interpreter.new(@depth + 1)
  79.     @child_interpreter.setup(event_list, event_id)
  80.   end
  81.  
  82. end
  83. #==============================================================================#
  84. # ** Scene_Title
  85. #------------------------------------------------------------------------------
  86. #  New Scene :: Scene_Title
  87. #==============================================================================#
  88. class Scene_Title < Scene_Base
  89.  
  90.   alias nicke_title_main main unless $@
  91.   def main(*args, &block)
  92.     title_skip if NICKE::TITLE::SKIP && $TEST && !$BTEST
  93.     return if NICKE::TITLE::SKIP && $TEST && !$BTEST
  94.     nicke_title_main(*args, &block)
  95.   end
  96.  
  97.   alias nicke_title_start start unless $@
  98.   def start(*args, &block)
  99.     nicke_title_start(*args, &block)
  100.     super
  101.     create_title
  102.     create_command_window
  103.   end
  104.  
  105.   def create_command_window
  106.     @command_title = NICKE::TITLE::MENU_LIST
  107.     @command_title = Window_Command.new(Graphics.width, @command_title, NICKE::TITLE::WINDOW[0])
  108.     if @continue_enabled
  109.       @command_title.index = 1      
  110.     else
  111.       @command_title.draw_item(1, false)
  112.     end
  113.     @command_title.x = NICKE::TITLE::WINDOW[1]
  114.     @command_title.y = NICKE::TITLE::WINDOW[2]
  115.     @command_title.z = NICKE::TITLE::WINDOW[3]
  116.     @command_title.opacity = NICKE::TITLE::WINDOW[4]
  117.     pre_animate_in unless NICKE::TITLE::ANIM_WINDOW_TIMER.nil?
  118.   end
  119.  
  120.   def perform_transition
  121.     if NICKE::TITLE::TRANSITION.nil?
  122.       Graphics.transition(30)
  123.     else
  124.       Graphics.transition(NICKE::TITLE::TRANSITION[0],NICKE::TITLE::TRANSITION[1],NICKE::TITLE::TRANSITION[2])
  125.     end
  126.   end
  127.  
  128.   def pre_animate_in
  129.     @command_title.opacity -= 255
  130.     @command_title.contents_opacity -= 255
  131.   end
  132.  
  133.   def post_start
  134.     super
  135.     animate_in unless NICKE::TITLE::ANIM_WINDOW_TIMER.nil?
  136.   end
  137.  
  138.   def animate_in
  139.     # // Method for animating the title window in.
  140.     timer = NICKE::TITLE::ANIM_WINDOW_TIMER
  141.     while timer > 0
  142.       Graphics.update
  143.       @command_title.opacity += 255 / NICKE::TITLE::ANIM_WINDOW_TIMER
  144.       @command_title.contents_opacity += 255 / NICKE::TITLE::ANIM_WINDOW_TIMER
  145.       @command_title.update
  146.       timer -= 1
  147.     end
  148.   end
  149.  
  150.   def pre_terminate
  151.     super
  152.     animate_out
  153.   end
  154.  
  155.   def animate_out
  156.     # // Method for animating the title window out.
  157.     timer = NICKE::TITLE::ANIM_WINDOW_TIMER
  158.     while timer > 0
  159.       Graphics.update
  160.       @command_title.opacity -= 255 / NICKE::TITLE::ANIM_WINDOW_TIMER
  161.       @command_title.contents_opacity -= 255 / NICKE::TITLE::ANIM_WINDOW_TIMER
  162.       @command_title.update
  163.       timer -= 1
  164.     end
  165.   end
  166.  
  167.   def open_command_window
  168.     @command_title.open
  169.     begin
  170.       @command_title.update
  171.       Graphics.update
  172.     end until @command_title.openness == 255
  173.   end
  174.   def close_command_window
  175.     @command_title.close
  176.     begin
  177.       @command_title.update
  178.       Graphics.update
  179.     end until @command_title.openness == 0
  180.   end
  181.  
  182.   def update
  183.     super
  184.     @command_title.update
  185.     if Input.trigger?(Input::C)
  186.       case @command_title.index
  187.         when 0...NICKE::TITLE::MENU_LIST.size
  188.           Sound.play_decision unless @command_title.index == 1 # If load disabled. item.
  189.           title_choice(@command_title.index)
  190.         end
  191.     end
  192.   end
  193.  
  194.   def title_choice(index)
  195.     # // Method for selecting the appropriated items in MENU_LIST.
  196.     case index
  197.     when 0 # New Game
  198.       command_new_game
  199.     when 1 # Load
  200.       command_continue
  201.     when 2 # Credits
  202.       command_credits
  203.     when 3 # Options
  204.       command_options
  205.     when 4 # Quit
  206.       command_shutdown
  207.     end
  208.   end
  209.  
  210.   def title_skip
  211.     # // Method for skipping the title.
  212.     load_database
  213.     create_game_objects
  214.     confirm_player_location
  215.     $game_party.setup_starting_members
  216.     setup_start_pos
  217.     $game_player.refresh
  218.     $game_player.transparent = NICKE::TITLE::PLAYER_TRANSPARENT
  219.     if !NICKE::TITLE::SWITCHES.nil?
  220.       for i in NICKE::TITLE::SWITCHES
  221.         $game_switches[i] = true
  222.       end
  223.     end
  224.     if !NICKE::TITLE::COMMON_EVENT.nil?
  225.       for i in NICKE::TITLE::COMMON_EVENT.values
  226.         next unless NICKE::TITLE::COMMON_EVENT.include?(i)
  227.         $game_map.interpreter.run_event($data_common_events[i].list)
  228.       end
  229.     end
  230.     $scene = Scene_Map.new
  231.     Graphics.frame_count = 0
  232.     RPG::BGM.stop
  233.     $game_map.autoplay
  234.   end
  235.  
  236.   def command_new_game
  237.     # // Override new game method.
  238.     confirm_player_location
  239.     Sound.play_decision
  240.     $game_party.setup_starting_members            
  241.     setup_start_pos
  242.     $game_player.refresh
  243.     $game_player.transparent = NICKE::TITLE::PLAYER_TRANSPARENT
  244.     if !NICKE::TITLE::SWITCHES.nil?
  245.       for i in NICKE::TITLE::SWITCHES
  246.         $game_switches[i] = true
  247.       end
  248.     end
  249.     if !NICKE::TITLE::COMMON_EVENT.nil?
  250.       for i in NICKE::TITLE::COMMON_EVENT.values
  251.         next unless NICKE::TITLE::COMMON_EVENT.include?(i)
  252.         $game_map.interpreter.run_event($data_common_events[i].list)
  253.       end
  254.     end
  255.     $scene = Scene_Map.new
  256.     RPG::BGM.fade(1500)
  257.     close_command_window
  258.     Graphics.fadeout(60)
  259.     Graphics.wait(40)
  260.     Graphics.frame_count = 0
  261.     RPG::BGM.stop
  262.     $game_map.autoplay
  263.   end
  264.  
  265.   def setup_start_pos
  266.     # // Method to determine the player startup positions.
  267.     if NICKE::TITLE::START_POS.nil?
  268.       $game_map.setup($data_system.start_map_id)
  269.       $game_player.moveto($data_system.start_x, $data_system.start_y)
  270.     else
  271.       $game_map.setup(NICKE::TITLE::START_POS[0])
  272.       $game_player.moveto(NICKE::TITLE::START_POS[1], NICKE::TITLE::START_POS[2])
  273.     end
  274.   end
  275.  
  276.   #----------------------------------------------------------------------------#
  277.   # // Feel free to comment this section out if you don't use it.
  278.   # It's doesn't do anything from start as you need to customize it.
  279.   def command_credits
  280.     # // Method for credits.
  281.     # Call the scene you want as credit in here.
  282.   end
  283.  
  284.   def command_options
  285.     # // Method for options.
  286.     # Call the scene you want as option in here.
  287.   end
  288.   #----------------------------------------------------------------------------#
  289.  
  290.   def command_shutdown
  291.     # // Method for quit.
  292.     Graphics.fadeout(60)
  293.     Graphics.wait(20)
  294.     RPG::BGM.fade(800)
  295.     RPG::BGS.fade(800)
  296.     RPG::ME.fade(800)
  297.     $scene = nil
  298.   end
  299.  
  300.   def create_title
  301.     @sprite_title_bg = Sprite.new
  302.     @sprite_title_bg.bitmap = Cache.system(NICKE::TITLE::BACK)
  303.   end
  304.  
  305.   def dispose_command_window
  306.     @sprite_title_bg.dispose unless @sprite_title_bg.nil?
  307.     @sprite_title_bg = nil
  308.     @command_title.dispose unless @command_title.nil?
  309.     @command_title = nil
  310.   end
  311.  
  312.   alias nicke_title_terminate terminate unless $@
  313.   def terminate(*args,&block)
  314.     nicke_title_terminate(*args,&block)
  315.     super
  316.   end
  317.  
  318. end # END OF FILE
  319.  
  320. #=*==========================================================================*=#
  321. # ** END OF FILE
  322. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement