Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Quasi
- module Title
- #=========================================================================
- # ** Quasi Title v 1.0
- #=========================================================================
- # Splash Screen Settings
- # + Optional multiple Splash Screens
- #=========================================================================
- # Instructions:
- # Part 1. Splash Set up
- # Step 1 Turn on/off
- # SPLASH_SHOW = true or false, false skips splash screen
- #--------------------------------------------------------------------------
- SPLASH_SHOW = false
- #--------------------------------------------------------------------------
- # Step 2 Making splashes
- # Add values to the hash below
- # Setup:
- # 'filename' => [duration,:effect,setting1,setting2,skip?,audio],
- # **^All hash values should have a comma at the end unless it's the final one!^**
- #
- # filename - The name of the image inside Graphics/Titles1
- # duration - Time to wait before moving to next splash. 60 = 1 sec,
- # runs after effect is finished
- #
- # :effect - :slide Slides image into setting2
- # :spin Spins image until it reaches angle from setting1
- # :zoom Zooms into value from setting1, best for larger pictures.
- # :zoom2 Begins with an initial zoom and zooms out to normal size
- # :fade Fades in
- # :flash Flashes
- #
- # settings1 - Depends on effect
- # when effect is :slide
- # - setting1 is :vert or :horz
- # when effect is :spin
- # - setting1 is the angle to spin to, any number, 360 = 1 spin
- # when effect is :zoom
- # - setting1 is how much to zoom in, 100 = 2x, 50 = 1.5x
- # when effect is :zoom2
- # - same as above
- # when effect is :fade
- # - doesn't use this, can be left blank or with a 0
- # when effect is :flash
- # - setting1 is the duration of the flash
- #
- # settings2 - Depends on effect
- # when effect is :slide
- # - setting2 is an array [pos, speed, from?]
- # pos for :vert, the X to stop at, for :horz, the Y to stop at
- # speed the speed to scroll
- # from? is true or false
- # true = slide from Top or Right
- # false = slide from Left or Bottom
- # when effect is :spin
- # - settings2 is the speed of the spin
- # when effect is :zoom
- # - setting2 is the speed of the zoom
- # when effect is :zoom2
- # - same as above
- # when effect is :fade
- # - setting2 is the speed of the fade
- # when effect is :flash
- # - setting2 is an array [red,green,blue,alpha]
- # all values range from - 255, alpha is optional, default 255
- #
- # skip? - If you can skip splash with Confirm key, true or false
- # audio - *Optional, can be left out*
- # is an array [type, audioname, volume, pitch]
- # type is :ME, :BGM, :SE, BGS
- #
- # Can play a movie too! (Can't skip)
- # for a movie use:
- # 'filename' => :movie,
- #--------------------------------------------------------------------------
- SPLASH = {
- # Put values in here between { and }
- # Few Examples: (won't work unless you have images with those names)
- #
- # 'disclaimer' => [120,:slide,:vert,[Graphics.height/2,30,false],false,[:ME,'Victory1',80,100]],
- # 'sponsor' => [180,:spin,360,5,true,[:BGM,'Dungeon5',100,100]],
- # 'splash' => [180,:zoom,60,1,true,[:BGM,'Theme4',100,100]]
- }
- #--------------------------------------------------------------------------
- # Part 2 Set up Title Screen
- # Step 1. Turn on/off Custom Title
- # If set to false, it will run the default title screen settings instead.
- #--------------------------------------------------------------------------
- TITLE_SHOW = true
- #--------------------------------------------------------------------------
- # Step 2. Making the Title Screen
- # Insert the values inside the hash, between { and }
- # Images are layered! the image you want at the very top should be
- # at the bottom of the list!
- # Setup:
- # 'filename' => [type, effect,settings, position(optional)],
- #
- # filename - Name of the image inside Graphics/Titles2
- # type - :trans or anything else
- # :trans uses transiton effects (From Splash settings!)
- # :trans setup is similiar to Splash setup, but has :trans instead of duration!
- # anything else, uses looping effects
- #
- # effect - if using :trans, these effects do not work/work the same!
- # :slidehorz slides horzontally, repeatly
- # :slidevert slides vertically, repeatly
- # :slidedia slides horzontally+vertically, repeatly
- # :spin spins nonstop
- # :wave wavey effect
- # :color changes to color then back to orginal
- # :flash flashes
- # :expand zooms in/out then back to orginal size
- # :frame splites image into frames and animates
- #
- # settings - An array, values varry on effect
- # when :slidehorz [speed, x]
- # when :slidevert [speed, y]
- # when :slidedia [speed, x, y]
- # when :spin [speed, x]
- # when :wave [amp, length, speed]
- # amp is the wave amplitude and length is the wave frequency,
- # speed is the speed of the wave, default 360, larger = faster
- # when :color [duration, [red,green,blue,alpha], repeat?(true or false)]
- # when :flash [duration, red,green,blue,alpha]
- # when :expand [speed, zoomx, zoomy]
- # for zoomx/zoomy use values like 1.5 being 50%, 2 = 100% 0.5 = -50%
- # when :frame [time between?,split direction, frames]
- # time between? number of frames until it changes to next frame
- # split direction :horz or :vert (which way to splite the frames)
- # frames number of frames, 1+
- #
- # position - Optional, images are centered by default
- # [x,y,center orgin?(true or false)]
- #--------------------------------------------------------------------------
- TITLE_OVERLAY = {
- # Put values in here between { and }
- # Few Examples: (won't work unless you have images with those names)
- #
- #'fog' => [:loop,:slidehorz,[3,5]],
- #'edge' => [:loop,:spin,[5,1]],
- #'logo' => [:loop,:color,[120,[150,150,150,180],true]] < last one doesn't have comma!
- }
- #--------------------------------------------------------------------------
- # Part 3 Setting up commands
- # Step 1 Turn commands images on/off
- # true or false
- # Images must be 2 frames oriented vertically, width/height can be any size
- # 1st frame is when command is inactive/disabled
- # 2nd frame is when command is selected
- #--------------------------------------------------------------------------
- TITLE_CMDS_IMGS = true
- #--------------------------------------------------------------------------
- # Step 2 Make Commands
- # This still needs to be here if TITLE_CMDS_IMGS is false
- # Setup:
- # :commandname => [:method, ['Name',x,y],scene(only for custom!)]
- #
- # :commandname - :newgame, :continue, :custom or :exit
- # :method -:command_continue, :command_newgame, :command_q_custom, :command_shutdown
- # with scripting you can make your own methods inside scene_title~
- # 'Name' - Name to display in the command box, also the name of the image inside
- # Graphics/Titles1
- # x - x for the image (doesn't use if TITLE_CMDS_IMGS is false)
- # y - y for the image (doesn't use if TITLE_CMDS_IMGS is false)
- # scene - ONLY IF USING :command_q_custom for the method!!!
- # Runs the scene when command is selected.
- #--------------------------------------------------------------------------
- TITLE_CMDS = {
- :newgame => [:command_new_game, ['New Game',170,250]],
- :continue => [:command_continue, ['Continue',170,280]],
- :custom => [:command_q_custom, ['Gameover',170,310],Scene_Gameover],
- :exit => [:command_shutdown, ['Quit',170,340]]
- }
- #--------------------------------------------------------------------------
- # Step 3 Commands Effects
- # ONLY IF TITLE_CMDS_IMGS = true!
- # setup:
- # TITLE_CMD_EFX = [:effct, [settings]]
- # The commented out effects are other possible examples
- # (Other effects don't work well for this)
- #--------------------------------------------------------------------------
- #TITLE_CMD_EFX = [:color,[60,[255,255,255,90],true]]
- #TITLE_CMD_EFX = [:wave,[5,200,600]]
- TITLE_CMD_EFX = [:expand,[150,1.2,1.2]]
- #TITLE_CMD_EFX = nil # No effect
- #--------------------------------------------------------------------------
- # Step 4 Cursor
- # ONLY IF TITLE_CMDS_IMGS = true!
- # TITLE_CURSOR = true or false
- # true if you want to use a cursor image
- # CURSOR = ['filename', frames, split]
- # filename => name of cursor image inside Graphics/System
- # frames => number of frames
- # split => :horz or :vert
- #--------------------------------------------------------------------------
- TITLE_CURSOR = true
- CURSOR = ['cursor',3,:vert]
- end
- end
- #==============================================================================#
- # By Quasi (http://quasixi.wordpress.com/)
- # - 3/16/14
- #==============================================================================#
- # ** Stop! Do not edit anything below, unless you know what you **
- # ** are doing! **
- #==============================================================================#
- if !$imported["Quasi_Core"].nil?
- Quasi.version(1.01,"Quasi_Title")
- if !$quasi["Quasi_Title"]
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # This class performs the title screen processing.
- #==============================================================================
- class Scene_Title < Scene_Base
- include Quasi
- alias quasi_title_create_bg create_background
- alias quasi_title_d_foreground dispose_foreground
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- SceneManager.clear
- Graphics.freeze
- @splashon = Quasi::Title::SPLASH_SHOW
- create_splash if @splashon
- normal_start if !@splashon
- end
- #--------------------------------------------------------------------------
- # * Makes splash images
- #--------------------------------------------------------------------------
- def create_splash(key=nil)
- if key.nil?
- key = []
- Quasi::Title::SPLASH.each_key {|k| key.push(k)}
- key = key[0]
- end
- @q_splash = Quasi::Title::SPLASH[key]
- if @q_splash2.nil?
- @q_splash2 = []
- for i in 0...Quasi::Title::SPLASH.length
- @q_splash2.push(false)
- end
- end
- @wait = 0
- if @q_splash != :movie
- if @q_splash[5].is_a?(Array)
- case @q_splash[5][0]
- when :BGM
- Audio.bgm_play('Audio/BGM/'+@q_splash[5][1], @q_splash[5][2], @q_splash[5][3]) rescue nil
- when :BGS
- Audio.bgs_play('Audio/BGS/'+@q_splash[5][1], @q_splash[5][2], @q_splash[5][3]) rescue nil
- when :SE
- Audio.se_play('Audio/SE/'+@q_splash[5][1], @q_splash[5][2], @q_splash[5][3]) rescue nil
- when :ME
- Audio.me_play('Audio/ME/'+@q_splash[5][1], @q_splash[5][2], @q_splash[5][3]) rescue nil
- end
- end
- @splash = Sprite.new
- @splash.bitmap = Cache.title1(key)
- @splash.opacity = 0 if @q_splash[1] == :fade
- if @q_splash[1] == :zoom2
- @splash.zoom_x += (@q_splash[2] / 100.0)
- @splash.zoom_y += (@q_splash[2] / 100.0)
- end
- center_sprite(@splash)
- if @q_splash[1] == :slide
- if @q_splash[2] == :horz
- @splash.x=(@q_splash[3][2] ? Graphics.width + (@splash.width/2) : (@splash.width/2)* -1 )
- else
- @splash.y=(@q_splash[3][2] ? Graphics.height + (@splash.height/2) : (@splash.height/2)* -1 )
- end
- end
- else
- @spmovie = key
- end
- Quasi.efx=true
- @csplash = 0 if @csplash.nil?
- end
- #--------------------------------------------------------------------------
- # * Reordered update
- #--------------------------------------------------------------------------
- def update
- super
- update_splash if @splashon
- update_title if @titleon
- update_commands if @cmdson
- end
- #--------------------------------------------------------------------------
- # * Runs splash effects / settings
- #--------------------------------------------------------------------------
- def update_splash
- if @spmovie.nil?
- sprite_efx_trans(@splash, @q_splash)
- if @q_splash[4] == true
- if Input.trigger?(:C) or Input.trigger?(:B)
- @qtefx = false
- @wait = @q_splash[0]
- end
- end
- return if @qtefx
- if @wait > @q_splash[0]
- hide_splash
- else
- @wait += 1
- end
- else
- Graphics.play_movie("Movies/"+@spmovie)
- next_splash
- end
- end
- #--------------------------------------------------------------------------
- # * Checks for next splash
- #--------------------------------------------------------------------------
- def next_splash
- dispose_splash(@csplash) if @splash
- end_movie(@csplash) if @spmovie
- if @csplash != (Quasi::Title::SPLASH.length-1)
- @csplash += 1
- key = []
- Quasi::Title::SPLASH.each_key{|k| key.push(k)}
- create_splash(key[@csplash])
- else
- normal_start
- end
- end
- #--------------------------------------------------------------------------
- # * Dispose Splash images
- #--------------------------------------------------------------------------
- def dispose_splash(n=0)
- @q_splash2[n] = true
- @splash.bitmap.dispose
- @splash.dispose
- end
- #--------------------------------------------------------------------------
- # * End Movie
- #--------------------------------------------------------------------------
- def end_movie(n=0)
- @q_splash2[n] = true
- @spmovie = nil
- end
- #--------------------------------------------------------------------------
- # * Exit Transition
- # Fades out current splash then runs next
- #--------------------------------------------------------------------------
- def hide_splash
- if @splash.opacity > 0
- @splash.opacity -= 10
- else
- if @q_splash[5].is_a?(Array)
- case @q_splash[5][0]
- when :BGM
- Audio.bgm_stop
- when :BGS
- Audio.bgs_stop
- when :SE
- Audio.se_stop
- when :ME
- Audio.me_stop
- end
- end
- next_splash
- end
- end
- #--------------------------------------------------------------------------
- # * Old Start Method
- #--------------------------------------------------------------------------
- def normal_start
- @splashon = false
- @titleon = Quasi::Title::TITLE_SHOW
- create_background
- create_foreground if !@titleon
- create_command_window
- play_title_music
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- if @titleon
- @sprite1 = Sprite.new
- @sprite1.bitmap = Cache.title1($data_system.title1_name)
- @sprite2 = {}
- Quasi::Title::TITLE_OVERLAY.each do |key,value|
- sefx = [:expand,:spin, :color, :wave, :flash, :frame]
- @z2 = 1 if @z2.nil?
- @z2 += 1
- @sprite2[key] = Plane.new
- @sprite2[key] = Sprite.new if sefx.include?(value[1])
- @sprite2[key] = Sprite.new if value[0] == :trans
- @sprite2[key].bitmap = Cache.title2(key) rescue nil
- @sprite2[key].z = 1 + @z2
- @sprite2[key].opacity = 0 if [:frame].include?(value[1])
- v = value[0] == :trans ? value[4] : value[3]
- if v.nil?
- center_sprite(@sprite2[key]) if sefx.include?(value[1])
- else
- @sprite2[key].x = v[0]
- @sprite2[key].y = v[1]
- if v[2]
- @sprite2[key].ox = @sprite2[key].width / 2
- @sprite2[key].oy = @sprite2[key].height / 2
- end
- end
- end
- center_sprite(@sprite1)
- else
- quasi_title_create_bg
- end
- end
- #--------------------------------------------------------------------------
- # * Runs Title effects
- #--------------------------------------------------------------------------
- def update_title
- Quasi::Title::TITLE_OVERLAY.each_key do |key|
- k = Quasi::Title::TITLE_OVERLAY[key]
- nk = k.clone
- nk.delete_at(0)
- sprite_efx_trans(@sprite2[key], k) if k[0] == :trans
- sprite_efx(@sprite2[key], nk) if k[0] != :trans
- end
- end
- #--------------------------------------------------------------------------
- # * Free Background
- #--------------------------------------------------------------------------
- def dispose_background
- @sprite1.bitmap.dispose
- @sprite1.dispose
- @sprite2.each_key{|s| @sprite2[s].bitmap.dispose; @sprite2[s].dispose} if @titleon == true
- @sprite3.each_key{|s| @sprite3[s].bitmap.dispose; @sprite3[s].dispose} if @cmdson == true
- return if @cursor.nil?
- @cursor.bitmap.dispose
- @cursor.dispose
- end
- #--------------------------------------------------------------------------
- # * Free Foreground
- #--------------------------------------------------------------------------
- def dispose_foreground
- quasi_title_d_foreground if !@titleon
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- def create_command_window
- # Create window + New commands
- @cmdson = Quasi::Title::TITLE_CMDS_IMGS
- @command_window = Window_TitleCommand.new
- @index = -1
- @cmd = Quasi::Title::TITLE_CMDS
- # Puts commands into command window
- @cmd.each_key do |key|
- @command_window.set_handler(key, method(@cmd[key][0]))
- end
- # Creates sprites if imgs is true
- if @cmdson
- @sprite3 = {}
- @cmd.each_key do |key|
- sprite3_reset(key)
- end
- # Hides command window
- @command_window.hide
- # Creates cursor if cursor is true
- if Quasi::Title::TITLE_CURSOR
- @cursor = Sprite.new
- @cursor.bitmap = Cache.system(Quasi::Title::CURSOR[0]) rescue nil
- draw_qsprite(@cursor, Quasi::Title::CURSOR[2], Quasi::Title::CURSOR[1], 0)
- @cursor.z = 4
- end
- end
- @custom = []
- @cmd.each_key {|key| @custom.push(key)}
- end
- def sprite3_reset(key)
- sefx = [:expand,:spin]
- @sprite3[key].dispose if !@sprite3[key].nil?
- @sprite3[key] = Sprite.new
- @sprite3[key].bitmap = Cache.title1(@cmd[key][1][0]) rescue nil
- draw_qsprite(@sprite3[key],:vert,2,0)
- @sprite3[key].z = 5
- @sprite3[key].x = @cmd[key][1][1]
- @sprite3[key].y = @cmd[key][1][2]
- return if !Quasi::Title::TITLE_CMD_EFX.is_a?(Array)
- if sefx.include?(Quasi::Title::TITLE_CMD_EFX[0])
- @sprite3[key].ox = @sprite3[key].width / 2
- @sprite3[key].oy = @sprite3[key].height / 2
- @sprite3[key].x += @sprite3[key].ox
- @sprite3[key].y += @sprite3[key].oy
- end
- end
- #--------------------------------------------------------------------------
- # * Updates Selected Command IMG
- # Only runs if index changed.
- #--------------------------------------------------------------------------
- def update_commands
- update_cursor
- return if @sprite3.nil?
- if Quasi::Title::TITLE_CMD_EFX.is_a?(Array)
- @custom.each_index do |i|
- key = @custom[i]
- if i == @index
- sprite_efx(@sprite3[key],Quasi::Title::TITLE_CMD_EFX)
- else
- sprite3_reset(key)
- end
- end
- end
- return if @index == @command_window.index
- @index = @command_window.index
- @custom.each_index do |i|
- key = @custom[i]
- if i == @index
- enable = key == :continue ? (@command_window.continue_enabled ? 1 : 0) : 1
- draw_qsprite(@sprite3[key],:vert,2,enable)
- if Quasi::Title::TITLE_CURSOR
- sefx = [:expand,:spin]
- @cursor.x = @sprite3[key].x
- @cursor.y = @sprite3[key].y + (@sprite3[key].height/4)
- return if !Quasi::Title::TITLE_CMD_EFX.is_a?(Array)
- if sefx.include?(Quasi::Title::TITLE_CMD_EFX[0])
- @cursor.x -= @sprite3[key].ox
- @cursor.y -= @sprite3[key].oy
- end
- end
- else
- draw_qsprite(@sprite3[key],:vert,2,0)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Loops cursor through it's frames if Cursor is turned on
- #--------------------------------------------------------------------------
- def update_cursor
- return unless Quasi::Title::TITLE_CURSOR
- @c = 0 if @c.nil?
- @wait = 0 if @wait.nil?
- if @wait > 10
- if @c < 2
- @c += 1
- draw_qsprite(@cursor, Quasi::Title::CURSOR[2], Quasi::Title::CURSOR[1], @c)
- else
- @c = 0
- draw_qsprite(@cursor, Quasi::Title::CURSOR[2], Quasi::Title::CURSOR[1], @c)
- end
- @wait = 0
- else
- @wait += 1
- end
- end
- #--------------------------------------------------------------------------
- # * Custom Command Call
- #--------------------------------------------------------------------------
- def command_q_custom
- i = @command_window.index
- SceneManager.goto(@cmd[@custom[i]][2])
- end
- end
- #==============================================================================
- # ** Window_TitleCommand
- #------------------------------------------------------------------------------
- # This window is for selecting New Game/Continue on the title screen.
- #==============================================================================
- class Window_TitleCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Create Command List
- # ** Remade
- #--------------------------------------------------------------------------
- def make_command_list
- cmd = Quasi::Title::TITLE_CMDS
- cmd.each_key do |key|
- if key == :continue
- add_command(cmd[key][1][0],key, continue_enabled)
- else
- add_command(cmd[key][1][0],key)
- end
- end
- end
- end
- end
- else
- msgbox_p "[Quasi_Title] needs [Quasi Core] in order to run."
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement