#encoding:utf-8
=begin
*******************************************************************************************
* Save Slot Plus *
for RGSS3
Ver 1.02 2013.07.27
Author:魂(Lctseng),Bahamut Forum ID:play123
The original text published in: Bahamut RPG master Hara version
Reprint please keep this label
Home link:http://home.gamer.com.tw/homeindex.php?owner=play123
Summary:
Enhanced save file
This script modifies or redefines the following categories:
1.DataManager
2.Game_Party
3.Game_Interpreter
4.Window_SaveFile
5.Scene_File
6.Scene_Save
7.Scene_Load
Newly defined category:
1.Window_Save_Decision
2.Window_Load_Decision
Modules and global variables that can be modified:
1.Enable enhanced save:$Lctseng_Enable_SaveSlot_Plus
2.Enable event save:$Lctseng_Enable_Auto_Save
3.Show actor name:$Lctseng_SaveFileEX_Enable_Draw_Actor_Name
4.Other settings:Lctseng_Save_Plus_Settings
*******************************************************************************************
=end
$Lctseng_Enable_SaveSlot_Plus = true #Whether to enable the enhanced save
$Lctseng_Enable_Auto_Save = true #Whether to enable autosave feature
$Lctseng_SaveFileEX_Enable_Draw_Actor_Name = true #Whether to show actor name
module Lctseng_Save_Plus_Settings
MAX_SAVE_SLOT = 16 #Max savefiles, doesn't include autosave, can be 0 after autosave is enabled
NAME_OF_AUTO_SAVE_FILE = "Autosave" #The name for autosave file
THE_POSITION_OF_ACTOR_NAMES = 75 #Y coordinate when drawing actor name
end
#*******************************************************************************************
#
# DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
#
#*******************************************************************************************
#--------------------------------------------------------------------------
# ★ Record script information
#--------------------------------------------------------------------------
if !$lctseng_scripts
$lctseng_scripts = {}
end
$lctseng_scripts[:save_file_ex] = "1.02"
puts "Load script: Lctseng - saveslot_plus:#{$lctseng_scripts[:save_file_ex]}"
#encoding:utf-8
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
# All global variables used in the game are initialized here.
#==============================================================================
module DataManager
include Lctseng_Save_Plus_Settings
#--------------------------------------------------------------------------
# ● Number of savefiles - redefinition
#--------------------------------------------------------------------------
class << self
alias lctseng_savefile_max savefile_max
end
#--------------------------------------------------------------------------
def self.savefile_max
return $Lctseng_Enable_Auto_Save ? MAX_SAVE_SLOT + 1 : MAX_SAVE_SLOT
end
#--------------------------------------------------------------------------
# ● Real time format
#--------------------------------------------------------------------------
def self.gain_time_string
time = Time.new
return time.strftime("Year:%Y Month:%m Day:%d(%a) %X")
end
#--------------------------------------------------------------------------
# ● Create save header - redefinition
#--------------------------------------------------------------------------
class << self
alias lctseng_make_save_header make_save_header
end
#--------------------------------------------------------------------------
def self.make_save_header
header = {}
header[:characters] = $game_party.characters_for_savefile
header[:names] = $game_party.names_for_savefile
header[:playtime_s] = $game_system.playtime_s
header[:time_log] = gain_time_string
header[:map_name] = $game_map.display_name
header
end
end
#encoding:utf-8
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# Class that manages the team. Keep information about money and items.
# See $game_party for an example of this class.
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● Save file display - redefinition - face index
#--------------------------------------------------------------------------
alias lctseng_characters_for_savefile characters_for_savefile
#--------------------------------------------------------------------------
def characters_for_savefile
unless $Lctseng_Enable_SaveSlot_Plus
lctseng_characters_for_savefile
else
battle_members.collect do |actor|
[actor.face_name, actor.face_index]
end
end
end
#--------------------------------------------------------------------------
# ● Name used to display savefile
#--------------------------------------------------------------------------
def names_for_savefile
battle_members.collect do |actor|
actor.name#sprintf("Lv:%d",actor.level)
end
end
end
#encoding:utf-8
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
# Interpreter for scenes.
# Class used for Game_Map, Game_Troop, and Game_Event.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● Start autosave
#--------------------------------------------------------------------------
def excute_auto_save
DataManager.save_game(0) if $Lctseng_Enable_Auto_Save
end
end
#==============================================================================
# ■ Window_Save_Decision
#==============================================================================
class Window_Save_Decision < Window_HorzCommand
#--------------------------------------------------------------------------
# ● Initialization object
#--------------------------------------------------------------------------
def initialize(x = (Graphics.width - window_width )/2 , y= (Graphics.height / 2 ) -( line_height / 2 ) )
super(x, y)
self.z = 300
end
#--------------------------------------------------------------------------
# ● Window width
#--------------------------------------------------------------------------
def window_width
return 300
end
#--------------------------------------------------------------------------
# ● Window height
#--------------------------------------------------------------------------
def window_height
return 50
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def show?
return self.visible
end
#--------------------------------------------------------------------------
# ● Column length
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# ● Update scene
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# ● Create command
#--------------------------------------------------------------------------
def make_command_list
s=["Okay", "Cancel" ] #Command name
add_command( s[0] , :sr_ok)
add_command( s[1] , :sr_no)
end
end
#==============================================================================
# ■ Window_Load_Decision
#==============================================================================
class Window_Load_Decision < Window_HorzCommand
#--------------------------------------------------------------------------
# ● Initialization object
#--------------------------------------------------------------------------
def initialize(x = (Graphics.width - window_width) /2, y= (Graphics.height / 2 ) -( line_height / 2 ) )
super(x, y)
self.z = 300
end
#--------------------------------------------------------------------------
# ● Window width
#--------------------------------------------------------------------------
def window_width
return 300
end
#--------------------------------------------------------------------------
# ● Window height
#--------------------------------------------------------------------------
def window_height
return 50
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def show?
return self.visible
end
#--------------------------------------------------------------------------
# ● Column length
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# ● Update scene
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# ● Create command
#--------------------------------------------------------------------------
def make_command_list
s=["Okay", "Cancel" ] #Command name
add_command( s[0] , :lr_ok)
add_command( s[1] , :lr_no)
end
end
#encoding:utf-8
#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
# Window for displaying save files and load scene.
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● Refresh - redefinition
#--------------------------------------------------------------------------
alias lctseng_refresh refresh
#--------------------------------------------------------------------------
def refresh
unless $Lctseng_Enable_SaveSlot_Plus
contents.clear
change_color(normal_color)
if $Lctseng_Enable_Auto_Save
if @file_index==0
name = Lctseng_Save_Plus_Settings::NAME_OF_AUTO_SAVE_FILE
else
name = Vocab::File + " #{@file_index }"
end
else
name = Vocab::File + " #{@file_index +1}"
end
draw_text(4, 0, 200, line_height, name)
@name_width = text_size(name).width
draw_party_characters(152, 58)
draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
return
end
contents.clear
change_color(normal_color)
if $Lctseng_Enable_Auto_Save
if @file_index==0
name = Lctseng_Save_Plus_Settings::NAME_OF_AUTO_SAVE_FILE
else
name = Vocab::File + " #{@file_index }"
end
else
name = Vocab::File + " #{@file_index +1}"
end
draw_text(4, 0, 200, line_height, name)
@name_width = text_size(name).width
draw_party_faces(0, line_height + 5)
draw_party_names(0, line_height + Lctseng_Save_Plus_Settings::THE_POSITION_OF_ACTOR_NAMES) if $Lctseng_SaveFileEX_Enable_Draw_Actor_Name
draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
draw_time_log(0, 0 , contents.width - 4, 2)
draw_map_log(0, contents.height - line_height, contents.width - 4, 0)
end
#--------------------------------------------------------------------------
# ● Party's face
#--------------------------------------------------------------------------
def draw_party_faces(x, y)
header = DataManager.load_header(@file_index)
return unless header
header[:characters].each_with_index do |data, i|
draw_face(data[0], data[1], x + i * 100, y) rescue nil
end
end
#--------------------------------------------------------------------------
# ● Party's name
#--------------------------------------------------------------------------
def draw_party_names(x, y,width = 100)
header = DataManager.load_header(@file_index)
return unless header
return unless header[:names]
header[:names].each_with_index do |name, i|
draw_text( x + i * 100, y, width, line_height, name) rescue nil
end
end
#--------------------------------------------------------------------------
# ● Playtime - redefinition
#--------------------------------------------------------------------------
alias lctseng_draw_playtime draw_playtime
#--------------------------------------------------------------------------
def draw_playtime(x, y, width, align)
unless $Lctseng_Enable_SaveSlot_Plus
lctseng_draw_playtime(x, y, width, align)
return
end
header = DataManager.load_header(@file_index)
return unless header
draw_text(x, y, width, line_height,"Play time: " + header[:playtime_s], 2)
end
#--------------------------------------------------------------------------
# ● Real time display on file
#--------------------------------------------------------------------------
def draw_time_log(x, y, width, align)
header = DataManager.load_header(@file_index)
return unless header
draw_text(x, y, width, line_height, header[:time_log], align) rescue nil
end
#--------------------------------------------------------------------------
# ● Location appear on the save file
#--------------------------------------------------------------------------
def draw_map_log(x, y, width, align)
header = DataManager.load_header(@file_index)
return unless header
draw_text(x, y, width, line_height, "Location: " + header[:map_name], align) rescue nil
end
end
#encoding:utf-8
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# Parent class for save scene and load scene
#==============================================================================
class Scene_File < Scene_MenuBase
#--------------------------------------------------------------------------
# ● Start processing - redefinition
#--------------------------------------------------------------------------
alias lctseng_start start
#--------------------------------------------------------------------------
def start
lctseng_start
create_decision_windows
end
#--------------------------------------------------------------------------
# ● Number of saves at a time - redefinition
#--------------------------------------------------------------------------
alias lctseng_visible_max visible_max
#--------------------------------------------------------------------------
def visible_max
unless $Lctseng_Enable_SaveSlot_Plus
return lctseng_visible_max
end
return 2
end
#--------------------------------------------------------------------------
# ● Create confirmation windows
#--------------------------------------------------------------------------
def create_decision_windows
@save_decision = Window_Save_Decision.new
@load_decision = Window_Load_Decision.new
@save_decision.hide
@load_decision.hide
@save_decision.deactivate
@load_decision.deactivate
@save_decision.set_handler(:sr_ok ,method(:on_save_really_ok ))
@save_decision.set_handler(:sr_no ,method(:on_save_really_no ))
@load_decision.set_handler(:lr_ok ,method(:on_load_really_ok ))
@load_decision.set_handler(:lr_no ,method(:on_load_really_no ))
@load_decision.set_handler(:cancel ,method(:on_load_really_no ))
end
#--------------------------------------------------------------------------
# ● Check cancel - redefinition
#--------------------------------------------------------------------------
alias lctseng_on_savefile_cancel on_savefile_cancel
#--------------------------------------------------------------------------
def on_savefile_cancel
if @save_decision.active
on_save_really_no
elsif @load_decision.active
on_load_really_ok
else
lctseng_on_savefile_cancel
end
end
#--------------------------------------------------------------------------
# ● Update cursor - redefinition
#--------------------------------------------------------------------------
alias lctseng_saveEX_update_cursor update_cursor
#--------------------------------------------------------------------------
def update_cursor
if @save_decision.active || @load_decision.active
else
lctseng_saveEX_update_cursor
end
end
#--------------------------------------------------------------------------
# ● Check save
#--------------------------------------------------------------------------
def on_save_really_ok
end
#--------------------------------------------------------------------------
# ● No save
#--------------------------------------------------------------------------
def on_save_really_no
end
#--------------------------------------------------------------------------
# ● Confirm load
#--------------------------------------------------------------------------
def on_load_really_ok
end
#--------------------------------------------------------------------------
# ● Cancel load
#--------------------------------------------------------------------------
def on_load_really_no
end
end
#encoding:utf-8
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
# Check scene
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# ● Check save - redefinition
#--------------------------------------------------------------------------
alias lctseng_on_savefile_ok on_savefile_ok
#--------------------------------------------------------------------------
def on_savefile_ok
if @index == 0&&$Lctseng_Enable_Auto_Save
Sound.play_buzzer
return
end
@savefile_windows.each {|window| window.deactivate }
if Dir.glob(DataManager.make_filename(@index)).empty?
@save_decision.select(0)
else
@save_decision.select(1)
end
@save_decision.show
@save_decision.activate
Sound.play_ok
end
#--------------------------------------------------------------------------
# ● Save confirm
#--------------------------------------------------------------------------
def on_save_really_ok
@savefile_windows.each {|window| window.activate }
@save_decision.hide
@save_decision.deactivate
lctseng_on_savefile_ok
end
#--------------------------------------------------------------------------
# ● Save?
#--------------------------------------------------------------------------
def on_save_really_no
@savefile_windows.each {|window| window.activate }
@save_decision.hide
@save_decision.deactivate
Sound.play_cancel
end
#--------------------------------------------------------------------------
# ● Handling save - redefining
#--------------------------------------------------------------------------
alias lctseng_on_save_success on_save_success
#--------------------------------------------------------------------------
def on_save_success
Sound.play_save
@savefile_windows[@index].refresh#.each {|window| window.refresh }
end
end
#encoding:utf-8
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
# Load scene
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ★ Redefinition
#--------------------------------------------------------------------------
unless @lctseng_for_savefile_ex_alias
alias lctseng_for_savefile_ex_On_savefile_ok on_savefile_ok # file check
@lctseng_for_savefile_ex_alias = true
end
#--------------------------------------------------------------------------
# ● Save confimation
#--------------------------------------------------------------------------
def on_savefile_ok
@savefile_windows.each {|window| window.deactivate }
@load_decision.select(0)
@load_decision.show
@load_decision.activate
Sound.play_ok
end
#--------------------------------------------------------------------------
# ● Loaf confirmation
#--------------------------------------------------------------------------
def on_load_really_ok
@savefile_windows.each {|window| window.activate }
@load_decision.hide
@load_decision.deactivate
lctseng_for_savefile_ex_On_savefile_ok
end
#--------------------------------------------------------------------------
# ● Cancel load
#--------------------------------------------------------------------------
def on_load_really_no
@savefile_windows.each {|window| window.activate }
@load_decision.hide
@load_decision.deactivate
Sound.play_cancel
end
end