#encoding:utf-8
#==============================================================================
# ■ 薄雾年代记 —— 存档公开版 by LBQ v0.2
#------------------------------------------------------------------------------
# 只是一个笨蛋存档读档界面罢了
#==============================================================================
$imported||={}
$imported[:mcr_save] = '0.2'
module MCR
module Save
CHAPTER_NUM = 1 #章节数用变量 0对应的是第一章 1是第二章 2是第三章
end
end
module DataManager
#--------------------------------------------------------------------------
# ● 生成存档的头数据
#--------------------------------------------------------------------------
def self.make_save_header
header = {}
header[:characters] = $game_party.characters_for_savefile
header[:playtime_s] = $game_system.playtime_s
header[:variables] = $game_variables
header
end
end
class Sprite
#blt(x, y, src_bitmap, src_rect[, opacity])
def paste(bitmap)
sb = bitmap
a = 0
b = 0
src_rect = Rect.new(a,b,sb.width,sb.height)
self.bitmap.blt(a,b,sb,src_rect)
bitmap.dispose
end
end
class Part_Save
include MCR::Save
def initialize(index)
@index = index
@delegates = []
@sprite = Sprite.new
@delegates << @sprite
@sprite.bitmap = Cache.system("save#{index+1}")
@number = Sprite_Number.new(play_time_s)
@delegates << @number
@empty_file = Sprite.new
if does_not_exist
@empty_file.bitmap = Cache.system("empty_file")
else
@sprite.paste Cache.system("chapter#{self.variables[CHAPTER_NUM]+1}")
end
unselected
end
def recreate_sprite
index = @index
@sprite.bitmap = Cache.system("save#{index+1}")
if does_not_exist
@sprite.paste Cache.system("empty_file")
else
@sprite.paste Cache.system("chapter#{self.variables[CHAPTER_NUM]+1}")
end
end
def play_time_s
return "00:00" if does_not_exist
return header[:playtime_s].split(":")[0..1].join(':')
end
def does_not_exist
!header
end
def variables
return if does_not_exist
return header[:variables]
end
def dispose
@empty_file.dispose
@sprite.dispose
@sprite=nil
@number.dispose
@empty_file.dispose
end
def header
return DataManager.load_header(@index)
end
def selected?
@selected
end
def update
if @selected
@delegates.each do |d|
d.opacity = [@sprite.opacity+12,255].min
end
else
@delegates.each do |d|
d.opacity = [@sprite.opacity-12,150].max
end
end
@empty_file.y = @sprite.y
end
def selected
@selected = true
#self.opacity = 255
end
def unselected
@selected = false
#self.opacity = 180
end
def method_missing(id,*args,&block)
sended = false
@delegates.each do |d|
if d.respond_to? id
sended = true
d.send id,*args,&block
end
end
unless sended
super
end
end
end
module Scene_EasyLoad_Plugin
def easy_load(index)
DataManager.load_game(index)
Sound.play_load
fadeout_all
$game_system.on_after_load
SceneManager.goto(Scene_Map)
end
end
class Scene_Base
include Scene_EasyLoad_Plugin
end
class Scene_File < Scene_MenuBase
public_instance_methods(false).each do |m|
undef_method m
end
#--------------------------------------------------------------------------
# ● 释放背景
#--------------------------------------------------------------------------
def dispose_background
@bg.dispose
end
def start
super
@main_timer = 0
methods.each do |m|
if m.to_s.include? 'create_'
send m
end
end
post_create
@start_fade_out = false
end
def terminate
super
terminate_all_sprites
end
def terminate_all_sprites
@parts.each(&:dispose)
end
def post_create
@parts[0].selected
end
def return_scene
return
@start_fade_out = true
end
def create_background
@bg = Plane.new
@bg.bitmap = Cache.system('bg')
@bg.oy =330
end
def create_header
@header = Sprite.new
@header.z = 10
@header.bitmap = Cache.system('save_header')
end
def create_parts
@parts = []
@parts[0] = Part_Save.new(0)
@parts[0].y = 50
@parts[1] = Part_Save.new(1)
@parts[1].y = 180
end
def create_mask
@mask = Sprite.new
w = Graphics.width
h = Graphics.height
@mask.bitmap = Bitmap.new w, h
@mask.bitmap.fill_rect(0,0,w,h,Color.new(0,0,0))
@mask.z = 999
end
def update
@main_timer += 1
methods.each do |m|
if m.to_s.include? 'update_'
send m
end
end
deal_with_mask_fade if @start_fade_out
end
def deal_with_mask_fade
@mask.opacity +=8
if @mask.opacity >=255
fadeout_all
SceneManager.return
end
end
#--------------------------------------------------------------------------
# ● 获取渐变速度
#--------------------------------------------------------------------------
def transition_speed
return 20
end
def update_input
if Input.trigger? :UP
i_am_going_to_select = @parts[current_selected_index - 1]
if i_am_going_to_select && current_selected_index!=0
current_selected.unselected
i_am_going_to_select.selected
Sound.play_cursor
else
Sound.play_buzzer
end
end
if Input.trigger? :DOWN
i_am_going_to_select = @parts[current_selected_index + 1]
if i_am_going_to_select
current_selected.unselected
i_am_going_to_select.selected
Sound.play_cursor
else
Sound.play_buzzer
end
end
if Input.trigger? :C
deal_with_on_ok
end
if Input.trigger? :B
Sound.play_cancel
SceneManager.return
end
end
def update_background
@bg.ox += 1 if @main_timer % 2 == 0
end
def update_mask
@mask.opacity -= 4
end
def current_selected
return @parts.select{|p|p.selected?}[0]
end
def current_selected_index
return @parts.index current_selected
end
def update_parts
@parts.each(&:update)
end
end
class Scene_Save < Scene_File
def deal_with_on_ok
DataManager.save_game(current_selected_index)
Sound.play_save
SceneManager.return
end
end
class Scene_Load < Scene_File
def deal_with_on_ok
if current_selected.does_not_exist
Sound.play_buzzer
return
end
easy_load(current_selected_index)
end
end
module Cache
class << self
def number(name)
load_bitmap("Graphics/Numbers/", name)
end
end
end
class Sprite_Number < Sprite
INDENT = [123,97]
def initialize(text)
super(nil)
@text = text
refresh
end
DIC = {
':' => 'colon'
}
def text=(x)
@text = x
refresh
end
def text
return @text
end
def refresh
self.bitmap = Bitmap.new(Graphics.width,Graphics.height)
deal_with_text
end
def deal_with_text
cursor = INDENT[0]
@text.each_char do |c|
if DIC[c]
c = DIC[c]
cursor+=3
end
new_bitmap = Cache.number(c)
a = cursor
b = INDENT[1]
sb = new_bitmap
sr = Rect.new(0,0,sb.width,sb.height)
self.bitmap.blt(a,b,sb,sr)
cursor += sb.width*0.75
sb.dispose
end # each
end
end
class Scene_Number < Scene_Base
def start
super
@timer = 0
@sprite = Sprite_Number.new($game_system.playtime_s)
end
def update
super
@timer += 1
if @timer %60==0
@sprite.text= $game_system.playtime_s
end
end
end
class Scene_Menu
#--------------------------------------------------------------------------
# ● 执行进入场景时的渐变
#--------------------------------------------------------------------------
def perform_transition
if Graphics.brightness == 0
Graphics.transition(0)
fadein(30)
else
super
end
end
end