Advertisement
FlipelyFlip

Simple Title Edited

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