[XP] Advanced Title Screen

Started by ForeverZer0, March 17, 2010, 05:41:35 pm

Previous topic - Next topic

ForeverZer0

March 17, 2010, 05:41:35 pm Last Edit: May 15, 2011, 11:51:10 am by Baraka
Advanced Title Screen
Authors: ForeverZer0
Version: 2.0
Type: Title Add-On
Key Term: Title / Save / Load / GameOver Add-on



Introduction

This system will allow you alter the title screen and add some different effects that are not normally available.



Features


  • Animated Title
  • Different loop types
  • Easy display of picture on screen and/or over animation
  • Random Title Screen each load
  • Transition Effect on loading saved games
  • Weather/Fog Effects
  • BGS and SFX
  • Easy scene linking
  • Add text to window



Screenshots

Attempt at catching full animation in three screenshots. You'll get the idea, though.
Frame 1: ShowHide

Frame 2: ShowHide

Frame 3: ShowHide



Demo

I used low quality graphics for the demo to keep the filesize down, but you can still see what it is capable of.
Demo Link


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Zer0 Advanced Title
# Author: ForeverZer0
# Version: 2.0
# Date: 10.03.2010
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Version History
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  Version 1.0 (3.14.2010)
#  - Original write
#
#  Version 1.1 (3.18.2010)
#  - Fixed a bug that would crash the game if you tried to return to the Title
#    Screen from the load screen when using the Load Transition.
#
#  Version 1.2 (3.21.2010)
#  - Added a part to pre-cache all the bitmaps before the animation begins,
#    which should drastically reduce the possibility of lagging.
#
#  Version 2.0 (10.03.2010)
#  - Totally re-written from scratch.
#  - Eliminated the unprofessional 'flicker' that would occur if the database
#    had an image defined for the title graphic.
#  - Improved performance, compatibility, overview, and configurability.
#  - Added Features:
#     - More options to how animations operate, with easier configuration.
#     - Added scene linker to easily add new commands to the title window.
#     - Added config to work with custom save systems.
#     - Add option to display text on the background.
#     - Window appearance can now be easily changed.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Compatibility:
#   - Should be compatible with just about anything other than scripts that
#     add animation, etc. to the Title screen
#   - Compatible with SDK
#
# Explanation:
#   This system will allow you alter the title screen and add some different
#   effects that are not normally available.
#
# Features:
#   - Animated Title
#   - Easy display of picture on screen and/or over animation
#   - Random Title Screen each load
#   - Transition Effect on loading saved games
#   - Weather/Fog Effects
#   - BGS and SFX
#   - Window configuration.
#
# Instructions:
#  - All the below configurable values can be set to nil to disable the feature
#    with the exception of SAVE_DATA. It is already configured to the default
#    system so leave it alone if you are not using a custom save system.
#  - If using the animated title, all pictures need to be named exactly the
#    the same, but have a different number at the end. The numbers should be
#    consecutive and in the order that the animation should follow. The first
#    image should be 0. (Ex. pic0, pic1, pic2, pic3, etc.)
#  - Configuration is below. Individual explanation for the settings is in
#    their respective sections. All Graphics, Fogs, SFX, BGS, etc. that you use
#    need to be in their normal folders.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

 $zer0_adv_title = 2.0

#===============================================================================
# ** Scene_Title
#===============================================================================

class Scene_Title
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#                           BEGIN CONFIGURATION
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

 ANIMATED = ['Globe ', 40, 4]
 # ['FILENAME', NUMBER_IMAGES, SPEED]
  ANIMATION_TYPE = 0
  # 0 = Do not loop. Run through images and stop on last one.
  # 1 = Changes back to first image after running course, then repeats.
  # 2 = Cycles backwards to the first image after running course, then repeats.
  # 3 = Continually shift through all the files in "Titles" folder randomly.
  CHANGE_SE = nil
  # ['FILENAME', VOLUME, PITCH]
  # Sound effect played when the image changes.
 
 RANDOM_BACKGROUNDS = true
 # Uses a random image for the title each load if ANIMATED is nil. There is no
 # need to configure the graphics. Any/all images from the "Titles" folder will
 # be used.
 
 WEATHER = nil # [1, 20]
 # [TYPE, POWER]
 # Weather effect to be used on title screen.

 FOG = nil # ['001-Fog01', 0, 2, -2, 3, 60]
 # ['FILENAME', HUE, X-SPEED, Y-SPEED, ZOOM, OPACITY]
 # Fog to be displayed on the title screen.

 BGS = nil # ['032-Switch01', 100, 100]
 # ['FILENAME', VOLUME, PITCH]
 # Background sound to be played during title.
 
 PIC = ['Title Pic', 0, 0, 3001, 0, true, 2]
 # ['NAME', X, Y, Z, OPACITY, FADE-IN?, FADE-IN SPEED]
 # Picture to be displayed on title screen.
   
 SAVE_DATA = ['Save', '.rxdata', 4, '']
 # ['SAVENAMES', 'SAVE_EXTENSION', SAVE_NUMBER, SAVE_DIRECTORY]
 # If you are using a custom save system that alters the name of the save files,
 # extension, or number of possible save files, configure this to match.
 # DO NOT SET THIS VALUE TO NIL!
 
 LOAD_OUT = ['010-Random02', 60, 40]
 LOAD_IN = ['012-Random04', 60, 40]
 # ['TRANSITION NAME', DURATION, VAGUE]
 # Transitions used from the load screen, and when game starts. Can use both or
 # only one.
 
 TEXT = ["Zer0 Advanced Title v.#$zer0_adv_title", 8, 460, 'Arial Black', 18]
 # ['STRING', X, Y, FONTNAME, FONTSIZE]
 # Have text be displayed on the images such as the version number, etc.
  TEXT_COLOR = Color.new(255, 113, 12, 255)
  # [RED, GREEN, BLUE, ALPHA]
  # Color used for the text if being used. White is default.
 
 WINDOW_DATA = [512, 352, 255, 128, false]
 # [X, Y, OPACITY, WIDTH, SHOW_WINDOWSKIN?]
 # Coordinates used for the main window. Default settings will be used if nil.
 COMMANDS = ['New Game', 'Continue', 'Options']
 # Strings used for the commands on the title screen. Omitting the third item
 # in the array will also effectively get rid of the "Shutdown" option that
 # many do not like for its uselessness.
 
 def _SCENE_LINK(command_index)
   # Configure here any scenes you would like to link to the Title screen. You
   # must first configure the name of the command in COMMANDS. After that, just
   # fill in the name of the scene for the proper index. Any command index left
   # undefined will be assumed to be a 'Shutdown' option.
   
   # ex.   when 2 then Scene_MyOptions
   
   # Will make the third command (index starts at 0) start the defined scene.
   # Do not configue anything for index 0 or 1. It will not work. They are
   # reserved for 'New Game' and 'Continue'.
   
   return case command_index
   when 2 then Scene_End
   end
 end
 
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#                           END CONFIGURATION
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 
 def main
   # If battle test
   if $BTEST
     battle_test
     return
   end
   # Load database
   $data_actors        = load_data('Data/Actors.rxdata')
   $data_classes       = load_data('Data/Classes.rxdata')
   $data_skills        = load_data('Data/Skills.rxdata')
   $data_items         = load_data('Data/Items.rxdata')
   $data_weapons       = load_data('Data/Weapons.rxdata')
   $data_armors        = load_data('Data/Armors.rxdata')
   $data_enemies       = load_data('Data/Enemies.rxdata')
   $data_troops        = load_data('Data/Troops.rxdata')
   $data_states        = load_data('Data/States.rxdata')
   $data_animations    = load_data('Data/Animations.rxdata')
   $data_tilesets      = load_data('Data/Tilesets.rxdata')
   $data_common_events = load_data('Data/CommonEvents.rxdata')
   $data_system        = load_data('Data/System.rxdata')
   # Create an instance of Game_System and a few other instance variables
   $game_system, @sprites, @bitmaps = Game_System.new, [], []
   # Create list of filenames of images found in Titles directory.
   @files = Dir.entries('Graphics/Titles').find_all {|file|
     ['.png', '.jpg'].include?(File.extname(file)) }
   # Play BGS if defined.
   # Stop playing ME and BGS (for when returning to title from game)
   Audio.me_stop
   if BGS != nil
     $game_system.bgs_play(RPG::AudioFile.new(BGS[0], BGS[1], BGS[2]))
   end
   # Play title BGM
   $game_system.bgm_play($data_system.title_bgm)
   # Prepare bitmap(s) for the backgound graphic.
   if ANIMATED != nil
     if ANIMATION_TYPE != 3
       (0...ANIMATED[1]).each {|i|
         # Pre-cache the graphics now to prevent lag during animation.
         @bitmaps[i] = RPG::Cache.title("#{ANIMATED[0]}#{i}") }
     else
       @files.each {|file| @bitmaps.push(RPG::Cache.title(file)) }
     end
     @count, @index, @reverse = 0, 0, false
     # Create the audio file for later use if needed.
     if CHANGE_SE != nil
       @se = RPG::AudioFile.new(CHANGE_SE[0], CHANGE_SE[1], CHANGE_SE[2])
     end
   elsif RANDOM_BACKGROUNDS
     # Cache a random image from the array.
     @bitmaps.push(RPG::Cache.title(@files[rand(@files.size)]))
   else
     # Else use the bitmap defined in the database.
     @bitmaps.push(RPG::Cache.title($data_system.title_name))
   end
   # Create weather sprite if needed.
   if WEATHER != nil
     @weather = RPG::Weather.new
     @weather.type, @weather.max = WEATHER[0], WEATHER[1]
     @sprites.push(@weather)
   end
   # Create Fog sprite if needed.
   if FOG != nil
     @fog = Plane.new
     @fog.bitmap = RPG::Cache.fog(FOG[0], FOG[1])
     @fog.z, @fog.opacity = 3000, FOG[5]
     @fog.zoom_x = @fog.zoom_y = FOG[4]
   end
   # Create picture graphic if needed.
   if PIC != nil
     @picture = Sprite.new
     @picture.bitmap = RPG::Cache.picture(PIC[0])
     @picture.x, @picture.y, @picture.z = PIC[1], PIC[2], PIC[3]
     @picture.opacity = PIC[4]
     @sprites.push(@picture)
   end
   # Draw text on background image(s) if configured.
   if TEXT != nil
     @bitmaps.each {|bitmap|
       bitmap.font.name, bitmap.font.size = TEXT[3], TEXT[4]
       if TEXT_COLOR.is_a?(Color)
         bitmap.font.color = TEXT_COLOR
       end
       bitmap.draw_text(TEXT[1], TEXT[2], 640, TEXT[4]+8, TEXT[0])
     }
   end
   # Set graphic to background.
   @background = Sprite.new
   @background.bitmap = @bitmaps[0]
   # Create command window.
   commands = COMMANDS == nil ? ['New Game', 'Continue', 'Shutdown'] : COMMANDS
   if WINDOW_DATA != nil
     @command_window = Window_Command.new(WINDOW_DATA[3], commands)
     @command_window.back_opacity = WINDOW_DATA[2]
     @command_window.x, @command_window.y = WINDOW_DATA[0], WINDOW_DATA[1]
     unless WINDOW_DATA[4]
       @command_window.opacity = 0
     end
   else
     @command_window = Window_Command.new(192, commands)
     @command_window.y, @command_window.back_opacity = 288, 160
     @command_window.x = 320 - @command_window.width / 2
   end
   # Determine if any save files exist.
   filenames = []
   (1..SAVE_DATA[2]).each {|i|
     filenames.push("#{SAVE_DATA[3]}#{SAVE_DATA[0]}#{i}#{SAVE_DATA[1]}") }
   @continue_enabled = filenames.any? {|filename| File.exist?(filename) }
   # Disable 'Continue' if no save files are found.
   if @continue_enabled
     @command_window.index = 1
   else
     @command_window.disable_item(1)
   end
   @sprites.push(@command_window, @background)
   # Transition the graphics.
   Graphics.transition
   # Main loop
   loop { Graphics.update; Input.update; update; break if $scene != self }
   # Prepare for transition.
   Graphics.freeze
   Audio.bgs_stop
   # Dispose the bitmaps, sprites, etc.
   (@sprites + @bitmaps).each {|object| object.dispose }
   @fog.dispose if @fog != nil
   # Clear Cache to free the graphics from the memory.
   RPG::Cache.clear
 end
 #-----------------------------------------------------------------------------
 def update
   # Update the sprites.
   @sprites.each {|sprite| sprite.update }
   # Scroll fog if needed.
   if @fog != nil
     @fog.ox += FOG[2]
     @fog.oy += FOG[3]
   end
   # Update picture if needed.
   if @picture != nil && @picture.opacity != 255 && PIC[5]
     @picture.opacity += PIC[6]
   end
   # Update animation if needed.
   if ANIMATED != nil
     @count += 1
     if @count == ANIMATED[2]
       case ANIMATION_TYPE
       when 0 # No looping
         @index += 1
       when 1 # Re-Start
         @index = (@index + 1) % ANIMATED[1]
       when 2 # Reverse Cycle
         @index += @reverse ? -1 : 1
         # Change reverse flag when needed.
         if @index == 0
           @reverse = false
         elsif @index == ANIMATED[1]
           @reverse = true
         end
       when 3 # Random Image
         old = @index
         @index = rand(@bitmaps.size)
         # Ensure images don't repeat consecutively.
         @index += 1 if old == @index
       end
       # Make sure bitmap index stays within permissible range.
       @index = [[@index, 0].max, ANIMATED[1]-1].min
       # Alter the image to the new bitmap.
       @background.bitmap = @bitmaps[@index]
       # Play the change SE if needed.
       if @se != nil
         $game_system.se_play(@se)
       end
       # Reset count.
       @count = 0
     end
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @command_window.index
     when 0 then command_new_game
     when 1 then command_continue
     else
       scene = _SCENE_LINK(@command_window.index)
       scene == nil ? command_shutdown : $scene = scene.new
     end
   end
 end
end

#===============================================================================
# ** Scene_Load
#===============================================================================

class Scene_Load < Scene_File
 
 alias zer0_adv_title_main main
 def main
   zer0_adv_title_main
   # Only if next scene is Scene_Map.
   if $scene.is_a?(Scene_Map)
     # Set data in local variables.
     tran_out, tran_in = Scene_Title::LOAD_OUT, Scene_Title::LOAD_IN
     folder = 'Graphics/Transitions/'
     # Play "out" transition if so configured.
     if tran_out != nil
       Graphics.transition(tran_out[1], folder + tran_out[0], tran_out[2])
       Graphics.freeze
     end
     # Play "in" transition if so configured.
     if tran_in != nil
       # Create an instance of the map sprite.
       map = Spriteset_Map.new
       Graphics.transition(tran_in[1], folder + tran_in[0], tran_in[2])
       Graphics.freeze
       # Dispose sprite.
       map.dispose
     end
   end
 end
end



Instructions

In the script.


Compatibility

Compatible with SDK.


Credits and Thanks


  • ForeverZer0, for writing the script
  • SephirothSpawn, for the idea



Author's Notes

Hope you enjoy. Be sure to credit if you use it in your game.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

WhiteRose

Nice script, Zer0.
And phew! It's SDK compatible. I was really worried for a moment there. :V

ForeverZer0

Version has now been updated to 1.2

Changes Made:
- Fixed a bug that crash the game if you attempted to exit the load screen and return to the title.
- Added a section to pre-cache all the graphics if using the Animated Title. This should pretty
  much eliminate any lag during the animation.

The demo hasn't been updated with the changes, so use the script in the spoiler, if you just want to make
the edits yourself, here they are:


Place this somewhere in the initialize method of Scene_Title

    
     if Z::Animated_Title
      (0..@last_pic).each {|i|RPG::Cache.title("Animated/#{Z::Title_Data[0]}#{i}")}
    end


Under Scene_Load replace:

    if Z::Load_Game_Transition


with

    if Z::Load_Game_Transition && $scene.is_a?(Scene_Map) 


That should take care of any known bugs. If anybody finds any more, I'll be happy to fix them.

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ForeverZer0

* Updates to 2.0 *

Totally re-wrote the script from scratch. Much easier to configure now, and has higher compatibility with other scripts. I added compatibility for custom save-systems to have the "Continue" option read the data correctly and be selectable or not, and have it check for a custom number of save files.

The script itself is much more efficient, with better sprite/bitmap handling and a better update method.
A new feature that has been added is the Scene_Linker, which will allow you to link custom scenes to the command window in a matter of seconds, as well as eliminate the "Shutdown" option that, if you are like me, find completely useless since there is that nice little X in the corner you can click at any time to do that.

Also added a simple method to add text to screen, which is not too hard for someone who knows how to script, but I am sure many will find useful.

If anyone has any bugs/issues/suggestions, be sure to post them here so they can be addressed.
Enjoy!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Dweller

I uptated to the new version and all is working fine on my game.

I wondered if is posible to have 2 images animated at the same time?. Example
Spoiler: ShowHide
Image 1 = Background picture (can do with your advanced title screen script), Image 2 = animated picture (can do with your advanced title screen script), Image 3 = animated picture.
Dwellercoc
Spoiler: ShowHide

ForeverZer0

I'm sure I can include it in the next update.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Dweller

Dwellercoc
Spoiler: ShowHide

Dweller

ForeverZer0  are you planning to update this script before next December?
Dwellercoc
Spoiler: ShowHide

ForeverZer0

Quote from: Dweller on October 24, 2010, 06:58:42 pm
ForeverZer0  are you planning to update this script before next December?


I was aiming for July of 2012.

I'll get to it sometime here. Forgot about it to be honest.

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Dweller

Forgotten, thanks anyway.

(I moved to MOG_Animated Title Sofia V1.1 by Moghunterr)
Dwellercoc
Spoiler: ShowHide

ForeverZer0

I apologize for not focusing all my attention on an update for you.

I moved to MOG_Animated Title Sofia V1.1 by Moghunterr as well, thogh I fail to see the relevance of saying this. I gain/lose nothing if you use this or not.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Dweller

October 25, 2010, 02:54:21 pm #11 Last Edit: October 25, 2010, 02:57:24 pm by Dweller
Quote from: ForeverZer0 on October 25, 2010, 12:03:10 pm
I apologize for not focusing all my attention on an update for you.


You said "Forgot about it to be honest", so I decide to move to other script (that actually do what I was looking for), but not was my intention to offend you, sorry if I did.

QuoteI moved to MOG_Animated Title Sofia V1.1 by Moghunterr as well, thogh I fail to see the relevance of saying this. I gain/lose nothing if you use this or not.


But may someone is interested like me on this feature, for that reason I mentioned MOG_Animated Title (not for hurt your vanity)


Dwellercoc
Spoiler: ShowHide

ForeverZer0

Nothing about being vain, man. I'm anything but. I may have interpreted your message wrong, but you  seem like you expected me to hurry up and alter the script solely for you. "The next update" means the next time I update the script, not "I will drop everything and write it now". I try to focus on one script at a time. When I finish the one I am working on, I try to go back and make edits to ones that are already released before starting the next new one. I have nothing vested into scripting, I do it simply to pass time, and I refuse to feel stressed or pressured that I have to hurry up to make a customization for someone. That defeats the purpose for which I write scripts. And lets not get it twisted, that little line about Mog's script was meant to be a little jab to me. I take offense to it, but not in the manner that it was intended. The idea behind it that you even felt the compulsion to say it is what irritates me.

Sorry if I'm being an asshole. I'm in a bad mood today.  >:(
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Dweller

Quote from: ForeverZer0 on October 25, 2010, 04:41:02 pm
Sorry if I'm being an asshole. I'm in a bad mood today.  >:(


np, I understand your point of view if you thougth that I was "requiring" you to do this ( I respect people who shares his works for free like you).
Dwellercoc
Spoiler: ShowHide

ForeverZer0

Sorry for the rant. To answer your original question before I went off on a tangent, I should get to this by by the end of the week if you are still interested. It was going to be a featue in the latest version, but I did not know if it would be needed, since a single picture with the individual pictures placed on it strategically can be created for the same effect, and still achieve "multiple" pics, though I see the drawback of not being able to have them behave independently of each other with oopacity changes, etc.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Dweller

Quote from: ForeverZer0 on October 26, 2010, 12:05:09 pm
Sorry for the rant. To answer your original question before I went off on a tangent, I should get to this by by the end of the week if you are still interested. It was going to be a featue in the latest version, but I did not know if it would be needed, since a single picture with the individual pictures placed on it strategically can be created for the same effect, and still achieve "multiple" pics, though I see the drawback of not being able to have them behave independently of each other with oopacity changes, etc.


Please donĀ“t change your shedule for me, I can manage with Moghunterr script to do what I looking for. Thanks for the offer.                                                     
Dwellercoc
Spoiler: ShowHide