Advertisement
diamondandplatinum3

Idle Title Screen Cutscene

Jun 7th, 2014
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.39 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Idle Title Screen Cutscene
  3. #             Version: 1.0
  4. #             Author: DiamondandPlatinum3
  5. #             Date: June 7, 2014
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script adds a timer on the title screen that, when reached, transfers
  10. #    to a Game Map. On this game map, you can use events to show cutscenes or a
  11. #    "story so far" demo.
  12. #
  13. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. #------------------------------------------------------------------------------
  15. #  Instructions:
  16. #
  17. #  ~  Modify Editable Region to your liking.
  18. #
  19. #  ~  When Transferring to the Map, the map begins in a screen_fadeout state.
  20. #       This is to allow you to set up the map behind the scenes.
  21. #       When the map is ready to view, use the "Fadein Screen" Event.
  22. #
  23. #  ~  When finished with the Map Cutscene, be sure to use the
  24. #       "Return to Title Screen" event to return to the title screen.
  25. #
  26. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  27. module DiamondandPlatinum3
  28.   module IdleTitleScreenCutscene
  29.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  30.     #                                                        -=
  31.     #                 Editable Region        ////            ==
  32.     #                                                        =-
  33.     #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  34.    
  35.     # How long does the Title Screen have to be waiting before
  36.     # skipping to the map?
  37.     #
  38.     # Note: this is done with seconds. So 30.5 would quite literally
  39.     #       mean "30 and a half seconds"
  40.     SkipTimer = 30.0
  41.    
  42.     # If the player presses any button. Should the Timer be reset?
  43.     # Note: If set to false, then the title screen will skip to the map
  44.     #       when the timer has been reached regardles of what the player
  45.     #       was doing
  46.     InputCancel = true
  47.    
  48.    
  49.     # This is the map the Title Screen will skip to. Use this map to display an
  50.     # cutscene or whatever you'd like. Be sure that when finished you use the
  51.     # "Return to Title Screen" event.
  52.     MapID = 1
  53.    
  54.     #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  55.     #                                           \/
  56.     #               End of Editable Region      /\
  57.     #                                           \/
  58.     #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  59.   end
  60. end
  61.  
  62.  
  63.  
  64.  
  65. #==============================================================================
  66. # ** Scene_Title
  67. #------------------------------------------------------------------------------
  68. #  This class performs the title screen processing.
  69. #==============================================================================
  70.  
  71. class Scene_Title < Scene_Base
  72.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73.   # *= Alias Listings
  74.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75.   alias_method(:dp3_itss_scntitle_start_qw90y,              :start)
  76.   alias_method(:dp3_itss_scntitle_update_qw90y,             :update)
  77.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78.   # * Aliased Method: Start Processing
  79.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80.   def start(*args)
  81.     dp3_itss_scntitle_start_qw90y(*args)
  82.     @dp3_titlescreenskipmanager = DiamondandPlatinum3::IdleTitleScreenCutscene::SceneTitleSkipManager.new()
  83.   end
  84.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85.   # * Aliased Method: Update
  86.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87.   def update(*args)
  88.     dp3_itss_scntitle_update_qw90y(*args)
  89.     @dp3_titlescreenskipmanager.update()
  90.   end
  91. end
  92.  
  93.  
  94.  
  95.  
  96. #=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
  97. # **  New Class:   Scene Title Skip Manager
  98. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  99. # This class Manages the Skip Option for the Title Screen
  100. #~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  101. module DiamondandPlatinum3
  102.   module IdleTitleScreenCutscene
  103.     class SceneTitleSkipManager
  104.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105.       # * Derived Method: Object Initialisation
  106.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107.       def initialize()
  108.         @skip_timer = DPCore::TimeTracker.new(SkipTimer)
  109.       end
  110.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111.       # * New Method: Update
  112.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113.       def update
  114.         if InputCancel && has_input?()
  115.           @skip_timer.reset()
  116.         else
  117.           @skip_timer.update()
  118.           if @skip_timer.time_up?()
  119.             SceneManager.scene.fadeout_all()
  120.             DataManager.create_game_objects()
  121.             $game_map.setup(MapID)
  122.             $game_player.moveto(0, 0)
  123.             $game_map.autoplay()
  124.             $game_map.screen.start_fadeout(1)
  125.             SceneManager.goto(Scene_Map)
  126.           end
  127.         end
  128.       end
  129.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  130.       # * New Method: Has Input?
  131.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132.       def has_input?
  133.         return [:LEFT, :UP, :RIGHT, :DOWN, :A, :B, :C, :X, :Y, :Z, :L, :R,
  134.                 :SHIFT, :CTRL, :ALT, :F5, :F6, :F7, :F8, :F9 ].any? { |sym| Input.press?(sym) }
  135.       end
  136.     end
  137.   end
  138. end
  139.  
  140.  
  141.  
  142.  
  143. unless ($diamondandplatinum3scripts ||= {})[:TimeTracker]
  144.  
  145. #=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
  146. # **  New Class:   Time Tracker
  147. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  148. # Once initialised, this class keeps track of time in seconds.
  149. # All instances of the TimeTracker class are updated automatically if you
  150. # have chosen to allow themselves to be added to the list (true by default).
  151. #
  152. # Once initialised, simply call the ' time_up? ' method to see if the time
  153. # is up for this TimeTracker.
  154. # Call ' dispose ' once finished.
  155. #~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  156. ($diamondandplatinum3scripts ||= {})[:TimeTracker] = true
  157. #~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  158. module DPCore
  159.   class TimeTracker
  160.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  161.     # *+ Public Instance Variables
  162.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  163.     attr_reader :current_frame  # Current Frame the Tracker is on: Use to Reset Tracker.
  164.     attr_reader :seconds        # Seconds until TimeUp: Change to Increase/Decrease the Wait Time.
  165.     attr_reader :scenetype      # Scenetype: If not nil, this TimeTracker will only Update if SceneManager is in that Specified Scene.
  166.    
  167.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168.     # *- Private Static Variables
  169.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170.     @@timetracker_list = []     # Static Variable List/Array containing active instances of TimeTrackers
  171.  
  172.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  173.     # * New Method:   Object Initialisation
  174.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  175.     # Time:             How long (in seconds) until this TimeTracker has been successful
  176.     # Scene Class:      Which Scene Can this TimeTracker be updated in : nil by default, which means it can always be updated no matter what scene it is.
  177.     # Add Self To List: Add Self to the Automatic Update List? : false by default. If not true, you need to update the TimeTracker manually
  178.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179.     def initialize(time, scene_class = nil, add_self_to_list = false)
  180.       @current_time   = 0.0
  181.       @finish_time    = time.to_f
  182.       @scenetype      = scene_class
  183.       @time_up        = false
  184.      
  185.       @@timetracker_list.push(self) if add_self_to_list
  186.     end
  187.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188.     # * New Method:   Dispose
  189.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  190.     def dispose()
  191.       @@timetracker_list.reject! { |tracker| tracker == self }
  192.     end
  193.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  194.     # * New Method:   Update
  195.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196.     def update()
  197.       if !@time_up
  198.         @current_time  += (1.0 / Graphics.frame_rate)
  199.         @time_up        = (@current_time > @finish_time)
  200.         @current_time   =  @finish_time if @time_up
  201.       end
  202.     end
  203.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204.     # * New Method:   Reset
  205.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206.     def reset()
  207.       @current_time = 0.0
  208.       @time_up      = false
  209.     end
  210.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  211.     # * New Method:   Set Current Time
  212.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213.     def set_current_time(time)
  214.       @current_time = time
  215.       @time_up      = (@current_time > @finish_time)
  216.       @current_time =  @finish_time if @time_up
  217.     end
  218.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  219.     # * New Method:   Set Finish Time
  220.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221.     def set_finish_time(time)
  222.       @finish_time  = time
  223.       @time_up      = (@current_time > @finish_time)
  224.       @current_time =  @finish_time if @time_up
  225.     end
  226.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  227.     # * New Method:   Get Current Time (in seconds)
  228.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  229.     def get_current_time()
  230.       return @current_time
  231.     end
  232.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  233.     # * New Method:   Is Time Up?
  234.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  235.     def time_up?()
  236.       return @time_up
  237.     end
  238.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  239.     # * New Method:   Get Total Completion Percentage
  240.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  241.     def get_completion_percentage()
  242.       return (@current_time / @finish_time)
  243.     end
  244.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  245.     # * New Method:   Get TimeTracker List
  246.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  247.     def self.get_timetracker_list()
  248.       return @@timetracker_list
  249.     end
  250.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  251.     # * New Method:   Update TimeTrackers
  252.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  253.     def self.update_timetrackers()
  254.       @@timetracker_list.each do |tracker|
  255.         tracker.update() unless !tracker.scenetype.nil? &&
  256.                                   !SceneManager.scene_is?(tracker.scenetype)
  257.       end
  258.     end
  259.   end
  260. end
  261.  
  262. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement