#===================================================================
# Ultimate Fake Loading Bar
# By arevulopapo
# May 11 2007
#
# This script displays a fake loading screen before the title.
#
#
# Setup:
# Put this script above the "main", go in the script "main" and change:
# $scene = Scene_Title.new
# by
# $scene = Scene_Loading_Bar.new
#
# Settings:
#
#LOADING_SPEED controls the speed of loading.
#
#BAR_FILL_TYPE select what will fill the bar.
#
# 1 - Use only one color to fill the bar.
# 2 - Transition of color that occurs throughout the bar.
# 3 - color transition smaller.
# 4 - an image ( "Graphics / Pictures / bar" any extension) used to fill the bar.
#
#BAR_FRAME_TYPE select the type of frame (outline):
#
# 1 - initial frame
# 2 - a picture ( "Graphics / Pictures / frame", any extension) which will be shown
# 3 - no frame
#
#BAR_BACK_TYPE select the background (bottom) bar:
#
# 1 - nothing
# 2 - a picture ( "Graphics / Pictures / back", any extension) which will be shown
#
#FILE_LISTING (true / false) true = shows that files are being loaded, false = do not show.
#
#BEEP (true / false) will play (or not) a sound ( "Audio / SE / beep, any extension)
#when the end of the loading
#
#BACKGROUND selects the bottom of the screen:
#
# 1 - the title screen
# 2 - a picture ( "Graphics / Pictures / splash", any extension)
# 3 - no background (black background)
#
# NOTE:
# Any image used to create bars / frames must 544x32 in size.
#===================================================================
LOADING_SPEED = 4
BAR_FILL_TYPE = 1
BAR_FRAME_TYPE = 1
BAR_BACK_TYPE = 1
FILE_LISTING = true
BEEP = false
BACKGROUND = 1
COLOR_1 = Color.new(255,64,64,255)
COLOR_2 = Color.new(128,255,64,255)
COLOR_3 = Color.new(16,16,16,255)
#===================================================================
# Window
#===================================================================
class Window_Loading_Bar < Window_Base
#=================================================================
attr_reader :finish_flag
#=================================================================
def initialize()
super(0, 384, 640, 64)
self.contents = Bitmap.new(608, 32)
self.contents.font.size = 16
self.windowskin = nil
@finish_flag = false
@bar_fill = 0
@file = 0
@flags = [0,0,0]
@speed = LOADING_SPEED
refresh
end
#=================================================================
def refresh
self.contents.clear
step = rand(@speed)
unless (@bar_fill + step) > 544
@bar_fill += step
else
@finish_flag = true
end
#===============================================================
# Draw background bar
#===============================================================
case BAR_BACK_TYPE
when 1
self.contents.fill_rect(32, 0, 544, 32, COLOR_3)
when 2
self.contents.blt(32, 0, RPG::Cache.picture('back.png'), Rect.new(0,0,544,32))
end
#===============================================================
# Draw main bar
#===============================================================
case BAR_FILL_TYPE
when 1
self.contents.fill_rect(32, 0, @bar_fill, 32, COLOR_1)
when 2
r = COLOR_1.red + (COLOR_2.red - COLOR_1.red)*@bar_fill/544
g = COLOR_1.green + (COLOR_2.green - COLOR_1.green)*@bar_fill/544
b = COLOR_1.blue + (COLOR_2.blue - COLOR_1.blue)*@bar_fill/544
a = COLOR_1.alpha + (COLOR_2.alpha - COLOR_1.alpha)*@bar_fill/544
self.contents.fill_rect(32, 0, @bar_fill, 32, Color.new(r,g,b,a))
when 3
for i in 0..@bar_fill - 1
r = COLOR_1.red + (COLOR_2.red - COLOR_1.red)*i/544
g = COLOR_1.green + (COLOR_2.green - COLOR_1.green)*i/544
b = COLOR_1.blue + (COLOR_2.blue - COLOR_1.blue)*i/544
a = COLOR_1.alpha + (COLOR_2.alpha - COLOR_1.alpha)*i/544
self.contents.fill_rect(32+i, 0, 1, 32, Color.new(r,g,b,a))
end
when 4
self.contents.blt(32, 0, RPG::Cache.picture('bar.png'), Rect.new(0,0,@bar_fill,32))
end
#===============================================================
# Draw surrounding rectangle
#===============================================================
case BAR_FRAME_TYPE
when 1
self.contents.fill_rect(32, 0, 544, 5, Color.new(64,64,64))
self.contents.fill_rect(32, 0, 5, 32, Color.new(64,64,64))
self.contents.fill_rect(571, 0, 5, 32, Color.new(64,64,64))
self.contents.fill_rect(32, 27, 544, 5, Color.new(64,64,64))
self.contents.fill_rect(33, 1, 542, 3, Color.new(128,128,128))
self.contents.fill_rect(33, 28, 542, 3, Color.new(128,128,128))
self.contents.fill_rect(33, 1, 3, 30, Color.new(128,128,128))
self.contents.fill_rect(572, 1, 3, 30, Color.new(128,128,128))
self.contents.fill_rect(34, 2, 540, 1, Color.new(192,192,192))
self.contents.fill_rect(34, 29, 540, 1, Color.new(192,192,192))
self.contents.fill_rect(573, 2, 1, 28, Color.new(192,192,192))
self.contents.fill_rect(34, 2, 1, 28, Color.new(192,192,192))
when 2
self.contents.blt(32, 0, RPG::Cache.picture('frame.png'), Rect.new(0,0,544,32))
end
#===============================================================
# Make array of filenames
#===============================================================
files_root = Dir.entries(".")
files_data = (files_root.include?("Data") ? Dir.entries("Data")+Dir.entries(".") : [])
files_graphics = (files_root.include?("Graphics") ? Dir.entries("Graphics")+Dir.entries("Graphics/Animations")+Dir.entries("Graphics/Autotiles")+Dir.entries("Graphics/Battlebacks")+Dir.entries("Graphics/Battlers")+Dir.entries("Graphics/Characters")+Dir.entries("Graphics/Fogs")+Dir.entries("Graphics/Gameovers")+Dir.entries("Graphics/Icons")+Dir.entries("Graphics/Panoramas")+Dir.entries("Graphics/Pictures")+Dir.entries("Graphics/Tilesets")+Dir.entries("Graphics/Titles")+Dir.entries("Graphics/Transitions")+Dir.entries("Graphics/Windowskins") : [])
files_audio = (files_root.include?("Audio") ? Dir.entries("Audio")+Dir.entries("Audio/BGM")+Dir.entries("Audio/BGS")+Dir.entries("Audio/SE")+Dir.entries("Audio/ME") : [])
if @flags[0] == 0
if @file < files_data.size
text = "Data/" + files_data[@file]
else
@flags[0] = 1
@file = 0
return
end
elsif @flags[1] == 0
if @file < files_graphics.size
text = "Graphics/" + files_graphics[@file]
else
@flags[1] = 1
@file = 0
return
end
elsif @flags[2] == 0
if @file < files_audio.size
text = "Audio/" + files_audio[@file]
else
@flags[2] = 1
@file = 0
return
end
else
text = "RGSS102E.DLL"
@speed += 1
end
#===============================================================
# Draw the filenames loaded
#===============================================================
self.contents.draw_text(192,0,608,32,"Loading file: " + text,0) if FILE_LISTING
@file += 1
end
#=================================================================
end
#===================================================================
# Scene
#===================================================================
class Scene_Loading_Bar
#=================================================================
def main
$data_system = load_data("Data/System.rxdata")
$game_system = Game_System.new
@sprite = Sprite.new
case BACKGROUND
when 1
bitmap = RPG::Cache.title($data_system.title_name)
when 2
bitmap = RPG::Cache.picture("splash")
when 3
bitmap = RPG::Cache.picture("")
end
@sprite.bitmap = bitmap
@loading_bar = Window_Loading_Bar.new
Graphics.transition
loop do
Graphics.update
@loading_bar.refresh
if @loading_bar.finish_flag == true
$scene = Scene_Title.new
Audio.se_play("Audio/SE/System01", 100, 100) if BEEP
end
if $scene != self
break
end
end
Graphics.freeze
@loading_bar.dispose
@sprite.bitmap.dispose
@sprite.dispose
end
#=================================================================
end