Holy87

Logo Shower - ENG

Jul 23rd, 2015
352
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # LOGO SCENE
  3. #===============================================================================
  4. # Author: Holy87
  5. # Version: 1.2
  6. # User difficulty: ★★
  7. #-------------------------------------------------------------------------------
  8. # This script uses to show a serial of images at game's opening, like author's
  9. # signature/logo, messages, movies etc.
  10. # The script allows to:
  11. # ● Show so many images you want
  12. # ● Jump in any moment to title screen pressing Enter
  13. # ● Set for every image the transition timing and effects
  14. # ● Play title screen BGM from the logo scene
  15. # ● Play movies and SE
  16. # ● Automatically hide the logo if is a play test.
  17. #-------------------------------------------------------------------------------
  18. # Instructions:
  19. # Copy this script under materials and above the Main.
  20. # Images must be placed in the Graphics\Pictures folder. The images will be
  21. # automatically centered on the screen.
  22. #
  23. #-------------------------------------------------------------------------------
  24. # Compatibility:
  25. # Scene Manager -> alias of first_scene_class method.
  26. #-------------------------------------------------------------------------------
  27. module H87_logo_shower
  28. #===============================================================================
  29. # ** CONFIGURATION **
  30. #===============================================================================
  31.   Logos = {
  32.   # Insert here in the proprer order the images to show, how much time will be
  33.   # enndure (in frame) and if activate or not the transition effect
  34.   #type:  0-> Normal fade
  35.   #       1-> Normal zoom
  36.   #       2-> Horizontal zoom
  37.   #       3-> Vertical zoom
  38.   #       4-> Increspature
  39.  
  40.   # If you want to use a movie, you need only to insert the movie name
  41.   # (make sure that there are no pictures with the same name)
  42.  
  43.   # You can also insert a phrase instead of the name, and that will be shown
  44.   # like a picture
  45.   # You can go to a new line with the "|"" character
  46.  
  47.   #ID   Name         Timing     Type      SE
  48.   1 => ["Logo",       100,      0],
  49.   2 => ["Initial Logo|created by Holy87",       70,      1,    "Applause1"],
  50.   3 => ["Video"],
  51.   4 => ["Logo3",      150,      4],
  52.   } # do not remove!
  53.   # P.S. The timing start after the transition is ended.
  54.  
  55.   #Do you want to play the title screen music?
  56.   Play_music = true
  57.  
  58.   #Fade speed
  59.   Fade_time = 50
  60.  
  61.   #Fade timing of the last image
  62.   Final_fade = 80
  63.  
  64.   #Jump the logo screen when in test mode?
  65.   Jump_test = true
  66.  
  67.   #Do you want the black background or white?
  68.   White = false #true if do you want it white
  69.  
  70.   #Insert the font name for phrases:
  71.   Logo_Font = "Comic Sans MS"
  72.  
  73.  
  74.   #============================================================================
  75.   # ** END OF CONFIGURATION **
  76.   # Don't modify the script below if you don't know what you're doing.
  77.   #============================================================================
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. $imported = {} if $imported == nil
  91. $imported["H87_Logoshower"] = true
  92.   #--------------------------------------------------------------------------
  93.   # * returns the fade speed
  94.   #--------------------------------------------------------------------------
  95.   def fade_speed
  96.     return 255.0 / Fade_time
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # * returns the fade speed after the last image
  100.   #--------------------------------------------------------------------------
  101.   def final_fade_speed
  102.     return 255.0 / Final_fade
  103.   end
  104. end # modulo
  105.  
  106. #===============================================================================
  107. # ** Class Scene_Logo
  108. #===============================================================================
  109. class Scene_Logo < Scene_Base
  110.   include H87_logo_shower # <- module
  111.   #--------------------------------------------------------------------------
  112.   # * start
  113.   #--------------------------------------------------------------------------
  114.   def start
  115.     super
  116.     $logo_done = true               # flag that indicates the logo appeared
  117.     create_logo_graphic             # logo graphic creation
  118.     play_title_music if Play_music  # play title music
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # * logo graphic creation
  122.   #--------------------------------------------------------------------------
  123.   def create_logo_graphic
  124.     @logo_base = Sprite.new
  125.     @logo_base.opacity = 0
  126.     @logo_base.bitmap = new_base_bitmap
  127.     @logo_counter = 1               # counter
  128.     @time_counter = 0               # time_remaning
  129.     @logo = Sprite.new              # creation
  130.     change_logo                     # bitmap update
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * assignes the bitmap
  134.   #--------------------------------------------------------------------------
  135.   def new_base_bitmap
  136.     bitmap = Bitmap.new(Graphics.width, Graphics.height)
  137.     colore = Color.new(255,255,255)
  138.     bitmap.fill_rect(0,0,bitmap.width,bitmap.height,colore) if White
  139.     return bitmap
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # * Changes the logo and create a new bitmap
  143.   #--------------------------------------------------------------------------
  144.   def change_logo
  145.     if Logos[@logo_counter][1].nil?
  146.       Graphics.play_movie("Movies/"+Logos[@logo_counter][0])
  147.     else
  148.       RPG::SE.new(Logos[@logo_counter][3]).play if Logos[@logo_counter][3] != nil
  149.       initialize_logo_sprite
  150.       preset_logo
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * reinitialization of logo attributes
  155.   #--------------------------------------------------------------------------
  156.   def initialize_logo_sprite
  157.     @logo.bitmap = logo_bitmap(Logos[@logo_counter][0])
  158.     @logo.opacity = 0
  159.     @logo.ox = @logo.width/2      # l'origine è al centro
  160.     @logo.oy = @logo.height/2     # idem
  161.     @logo.x = Graphics.width / 2  # centra l'immagine
  162.     @logo.y = Graphics.height / 2 # idem
  163.     @speed = 0
  164.     @logo.zoom_x = 1
  165.     @logo.zoom_y = 1
  166.     @logo.wave_speed = 0
  167.     @logo.wave_length = 0
  168.   end    
  169.   #--------------------------------------------------------------------------
  170.   # * imposta l'inizio del logo a seconda del tipo di comparsa
  171.   #--------------------------------------------------------------------------
  172.   def preset_logo
  173.     case Logos[@logo_counter][2]    # caso
  174.     when 1
  175.       @speed = 0.002              # velocità zoom
  176.       @logo.zoom_x = 0.9          # proporzioni (solo del 10% più piccolo
  177.       @logo.zoom_y = 0.9          # idem
  178.     when 2
  179.       @speed = 0.01
  180.       @logo.zoom_x = 0
  181.     when 3
  182.       @speed = 0.01
  183.       @logo.zoom_y = 0
  184.     when 4
  185.       @speed = 1
  186.       @logo.wave_amp = 120
  187.       @logo.wave_length = 255
  188.       @logo.wave_speed = 360
  189.     end
  190.   end    
  191.   #--------------------------------------------------------------------------
  192.   # * restituisce la bitmap del logo
  193.   #--------------------------------------------------------------------------
  194.   def logo_bitmap(source)
  195.     begin
  196.       bitmap = Cache.picture(source)
  197.     rescue Errno::ENOENT
  198.       line_height = 40
  199.       text = source.split("|")
  200.       bitmap = Bitmap.new(Graphics.width, Graphics.height)
  201.       bitmap.font.color = White ? Color.new(0,0,0) : Color.new(255,255,255)
  202.       bitmap.font.outline = false
  203.       bitmap.font.size = 40
  204.       bitmap.font.name = Logo_Font
  205.       starting_line = (Graphics.height - text.size*line_height) / 2
  206.       for i in 0..text.size-1
  207.         bitmap.draw_text(0,starting_line,bitmap.width,line_height,text[i],1)
  208.         starting_line += line_height
  209.       end
  210.     end
  211.     return bitmap
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * sostituisce l'immagine con la prossima
  215.   #--------------------------------------------------------------------------
  216.   def next_logo
  217.     return if Logos[@logo_counter + 1] == nil
  218.     @logo_counter += 1
  219.     @time_counter = 0
  220.     change_logo
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * restituisce true se c'è un'altra immagine da mostrare
  224.   #--------------------------------------------------------------------------
  225.   def there_next?
  226.     return true if Logos[@logo_counter + 1] != nil
  227.     return false
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # * aggiornamento
  231.   #--------------------------------------------------------------------------
  232.   def update
  233.     super
  234.     jump_logo if Input.trigger?(:C) # aggiorna l'input
  235.     update_fade_logo                      # aggiorna l'animazione
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # * aggiorna l'animazione dell'immagine
  239.   #--------------------------------------------------------------------------
  240.   def update_fade_logo
  241.     @logo_base.opacity += 20
  242.     process_appear
  243.     process_fade
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # * processo di apparizione del logo
  247.   #--------------------------------------------------------------------------
  248.   def process_appear
  249.     case Logos[@logo_counter][2]
  250.     when 1
  251.       if @logo.zoom_x < 1
  252.         @logo.zoom_x += @speed
  253.         @logo.zoom_y += @speed
  254.       end
  255.     when 2
  256.       @logo.zoom_x += @speed if @logo.zoom_x < 1
  257.     when 3
  258.       @logo.zoom_y += @speed if @logo.zoom_y < 1
  259.     when 4
  260.       if @logo.wave_amp > 0
  261.         @logo.wave_amp -= @speed
  262.       end
  263.       @logo.update
  264.     end
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # * processo di scomparsa del logo
  268.   #--------------------------------------------------------------------------
  269.   def process_fade
  270.     if Logos[@logo_counter][1] != nil and @time_counter < Logos[@logo_counter][1] # attesa frame
  271.       @logo.opacity += fade_speed
  272.       if @logo.opacity >= 255
  273.         @time_counter += 1
  274.       end
  275.     else
  276.       if there_next?
  277.         @logo.opacity -= fade_speed
  278.       else
  279.         @logo.opacity -= final_fade_speed
  280.       end
  281.       if @logo.opacity == 0
  282.         if there_next?
  283.           next_logo
  284.         else
  285.           go_title
  286.         end
  287.       end
  288.     end
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * finalmente, vai alla schermata del titolo
  292.   #--------------------------------------------------------------------------
  293.   def go_title
  294.     SceneManager.goto(SceneManager.h87f_s_c)
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # * fine
  298.   #--------------------------------------------------------------------------
  299.   def terminate
  300.     @logo.opacity = 0
  301.     super
  302.     @logo_base.dispose
  303.     @logo.bitmap.dispose
  304.     @logo.dispose
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # * forza il title
  308.   #--------------------------------------------------------------------------
  309.   def jump_logo
  310.     loop do
  311.       @logo.opacity -= 30
  312.       Graphics.update
  313.       break if @logo.opacity == 0
  314.     end
  315.     go_title
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # * esegue la musica del titolo
  319.   #--------------------------------------------------------------------------
  320.   def play_title_music
  321.     $data_system.title_bgm.play
  322.     RPG::BGS.stop
  323.     RPG::ME.stop
  324.   end
  325. end # scene_logo
  326.  
  327. #===============================================================================
  328. # ** SceneManager
  329. #===============================================================================
  330. module SceneManager  
  331.   class << self; alias h87f_s_c first_scene_class; end
  332.   #--------------------------------------------------------------------------
  333.   # * modifica della schermata iniziale
  334.   #--------------------------------------------------------------------------
  335.   def self.first_scene_class
  336.     if $BTEST
  337.       return h87f_s_c
  338.     elsif $TEST and H87_logo_shower::Jump_test
  339.       return h87f_s_c
  340.     else
  341.       return Scene_Logo
  342.     end
  343.   end
  344. end #scenemanager
RAW Paste Data