Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- # Yanfly 6 - Overzeal Save Menu
- # --- Last Date Updated: 2011.10.26
- # --- Level: Normal
- # Requires: n/a
- #
- #==============================================================================
- $imported = {} if $imported == nil
- $imported["Y6-OZSaveMenu"] = true
- #==============================================================================
- # Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # o 2011.10.26 - Started Script and Finished.
- #
- #==============================================================================
- # Introduction
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This is Overzeal's special save menu! You can save, load, and even delete
- # saves from the menu itself. Note that this system doesn't use confirmation
- # choices for loading and saving because I think those are annoying.
- #
- #==============================================================================
- # Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- #
- # Save the chapter images under the Graphics\Pictures\ directory.
- #
- #==============================================================================
- # Compatibility
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Note: This script may not work with former Yanfly Engine scripts.
- # Use Yanfly Engine 6 scripts to work with this if available.
- #==============================================================================
- module Y6
- module SAVE
- #--------------------------------------------------------------------------
- # - Save Window Text -
- #--------------------------------------------------------------------------
- # These are the settings used for the save window text.
- #--------------------------------------------------------------------------
- SLOT = "Slot %d"
- MAX_SLOTS = 100
- NO_FILE_ICON = 73
- YES_FILE_ICON = 72
- SAVE_VOCAB = "Save"
- LOAD_VOCAB = "Load"
- DELETE_VOCAB = "Delete"
- DELETE_SOUND = "Drop"
- #--------------------------------------------------------------------------
- # - Chapter Settings -
- #--------------------------------------------------------------------------
- # Here, you can adjust the chapter settings that appear. Save images go
- # under Graphics\Pictures\ directory. For no-save settings, use chapter 0.
- #--------------------------------------------------------------------------
- CHAPTER_VARIABLE = 22
- CHAPTER_SETTINGS ={
- # ChapterNo. => ["Title", "ImageFilename"]
- 0 => ["------", "Game0"],
- 1 => ["Game 1: Hiding and Seeking", "Game1"],
- 2 => ["Game 2: Old Maid", "Game1"],
- 3 => ["Game 3: Cat's Cradle", "Game1"],
- 4 => ["Game 4: Candy Land", "Game1"],
- 5 => ["Game 5: Hopscotch", "Game1"],
- 6 => ["Game 6: Mother May I?", "Game1"],
- 7 => ["Game 7: Seven Up", "Game1"],
- 8 => ["Game 8: Hot and Cold", "Game1"],
- 9 => ["Game 9: Thumb War", "Game1"],
- 10 => ["Last Game: Follow the Leader", "Game1"],
- 11 => ["Post Game: Overzeal", "Game1"],
- } # Do not remove this.
- end # SAVE
- end # Y6
- #==============================================================================
- # Editting anything past this point may potentially result in causing computer
- # damage, incontinence, explosion of user's head, coma, death, and/or halitosis
- # so edit at your own risk.
- #==============================================================================
- #==============================================================================
- # ** Window_File_Small
- #==============================================================================
- class Window_File_Small < Window_Base
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, Graphics.width, 56)
- end
- #--------------------------------------------------------------------------
- # change
- #--------------------------------------------------------------------------
- def change(file_index, filename)
- @file_index = file_index
- @filename = filename
- load_gamedata
- refresh
- end
- #--------------------------------------------------------------------------
- # load_gamedata
- #--------------------------------------------------------------------------
- def load_gamedata
- @time_stamp = Time.at(0)
- @file_exist = FileTest.exist?(@filename)
- if @file_exist
- file = File.open(@filename, "r")
- @time_stamp = file.mtime
- begin
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_message = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- rescue
- @file_exist = false
- ensure
- file.close
- end
- end
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- contents.font.color = normal_color
- contents.font.color.alpha = @file_exist ? 255 : 128
- draw_file_icon
- draw_file_number
- draw_chapter_name
- draw_play_time
- end
- #--------------------------------------------------------------------------
- # draw_file_icon
- #--------------------------------------------------------------------------
- def draw_file_icon
- if @file_exist
- draw_icon(Y6::SAVE::YES_FILE_ICON, 0, 0)
- else
- draw_icon(Y6::SAVE::NO_FILE_ICON, 0, 0, false)
- end
- end
- #--------------------------------------------------------------------------
- # draw_file_number
- #--------------------------------------------------------------------------
- def draw_file_number
- text = sprintf(Y6::SAVE::SLOT, @file_index + 1)
- contents.draw_text(24, 0, 96, WLH, text)
- end
- #--------------------------------------------------------------------------
- # draw_chapter_name
- #--------------------------------------------------------------------------
- def draw_chapter_name
- if @file_exist
- chapter_number = [@game_variables[Y6::SAVE::CHAPTER_VARIABLE], 1].max
- text = Y6::SAVE::CHAPTER_SETTINGS[chapter_number][0]
- else
- text = Y6::SAVE::CHAPTER_SETTINGS[0][0]
- end
- contents.draw_text(120, 0, contents.width-240, WLH, text)
- end
- #--------------------------------------------------------------------------
- # draw_play_time
- #--------------------------------------------------------------------------
- def draw_play_time
- if @file_exist
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- time_string = sprintf("%d:%02d:%02d", hour, min, sec)
- else
- time_string = "0:00:00"
- end
- contents.draw_text(contents.width-120, 0, 120, WLH, time_string, 2)
- end
- end # Window_File_Small
- #==============================================================================
- # ** Window_File_Big
- #==============================================================================
- class Window_File_Big < Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :filename
- attr_accessor :file_exist
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(from_title)
- super(0, 0, Graphics.width, Graphics.height-56*4)
- @from_title = from_title
- @column_max = 3
- @item_max = 3
- self.index = @from_title ? 1 : 0
- end
- #--------------------------------------------------------------------------
- # change
- #--------------------------------------------------------------------------
- def change(file_index, filename)
- @file_index = file_index
- @filename = filename
- load_gamedata
- refresh
- end
- #--------------------------------------------------------------------------
- # load_gamedata
- #--------------------------------------------------------------------------
- def load_gamedata
- @time_stamp = Time.at(0)
- @file_exist = FileTest.exist?(@filename)
- if @file_exist
- file = File.open(@filename, "r")
- @time_stamp = file.mtime
- begin
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_message = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- rescue
- @file_exist = false
- ensure
- file.close
- end
- end
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- contents.font.color = normal_color
- contents.font.color.alpha = @file_exist ? 255 : 128
- draw_game_picture
- draw_file_icon
- draw_file_number
- draw_chapter_name
- draw_play_time
- draw_options
- end
- #--------------------------------------------------------------------------
- # draw_game_picture
- #--------------------------------------------------------------------------
- def draw_game_picture
- if @file_exist
- chapter_number = [@game_variables[Y6::SAVE::CHAPTER_VARIABLE], 1].max
- else
- chapter_number = 0
- end
- image = Y6::SAVE::CHAPTER_SETTINGS[chapter_number][1]
- bitmap = Cache.picture(image)
- rect = Rect.new(0, 0, contents.width, contents.height)
- contents.blt(0, 0, bitmap, rect)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # draw_file_icon
- #--------------------------------------------------------------------------
- def draw_file_icon
- if @file_exist
- draw_icon(Y6::SAVE::YES_FILE_ICON, 0, 0)
- else
- draw_icon(Y6::SAVE::NO_FILE_ICON, 0, 0, false)
- end
- end
- #--------------------------------------------------------------------------
- # draw_file_number
- #--------------------------------------------------------------------------
- def draw_file_number
- text = sprintf(Y6::SAVE::SLOT, @file_index + 1)
- contents.draw_text(24, 0, 96, WLH, text)
- end
- #--------------------------------------------------------------------------
- # draw_chapter_name
- #--------------------------------------------------------------------------
- def draw_chapter_name
- if @file_exist
- chapter_number = [@game_variables[Y6::SAVE::CHAPTER_VARIABLE], 1].max
- text = Y6::SAVE::CHAPTER_SETTINGS[chapter_number][0]
- else
- text = Y6::SAVE::CHAPTER_SETTINGS[0][0]
- end
- contents.draw_text(120, 0, contents.width-240, WLH, text)
- end
- #--------------------------------------------------------------------------
- # draw_play_time
- #--------------------------------------------------------------------------
- def draw_play_time
- if @file_exist
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- time_string = sprintf("%d:%02d:%02d", hour, min, sec)
- else
- time_string = "0:00:00"
- end
- contents.draw_text(contents.width-120, 0, 120, WLH, time_string, 2)
- end
- #--------------------------------------------------------------------------
- # draw_options
- #--------------------------------------------------------------------------
- def draw_options
- #---
- rect = item_rect(2)
- text = Y6::SAVE::DELETE_VOCAB
- contents.draw_text(rect, text, 1)
- #---
- rect = item_rect(1)
- text = Y6::SAVE::LOAD_VOCAB
- contents.draw_text(rect, text, 1)
- #---
- rect = item_rect(0)
- contents.font.color.alpha = @from_title ? 128 : 255
- text = Y6::SAVE::SAVE_VOCAB
- contents.draw_text(rect, text, 1)
- #---
- end
- #--------------------------------------------------------------------------
- # item_rect
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = contents.width/3 - 48
- rect.height = WLH
- rect.x = index * contents.width/3 + 24
- rect.y = contents.height - WLH
- return rect
- end
- end # Window_File_Big
- #==============================================================================
- # ** Scene_File
- #==============================================================================
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------
- # overwrite method: start
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- @index = @saving ? $game_temp.last_file_index : latest_file_index
- create_savefile_windows
- end
- #--------------------------------------------------------------------------
- # overwrite method: latest_file_index
- #--------------------------------------------------------------------------
- def latest_file_index
- index = 0
- latest_time = Time.at(0)
- for i in 1..Y6::SAVE::MAX_SLOTS
- file_name = make_filename(i - 1)
- next unless FileTest.exist?(file_name)
- file_time = File.mtime(file_name)
- if file_time > latest_time
- latest_time = file_time
- latest_index = i - 1
- index = latest_index
- end
- end
- return index
- end
- #--------------------------------------------------------------------------
- # overwrite method: terminate
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- dispose_item_windows
- end
- #--------------------------------------------------------------------------
- # overwrite method: update
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- organize_savefile_locations
- update_savefile_windows
- if Input.trigger?(Input::UP)
- Sound.play_cursor
- if @index == 0
- @index = Y6::SAVE::MAX_SLOTS - 1
- else
- @index = [@index - 1, 0].max
- end
- elsif Input.trigger?(Input::DOWN)
- Sound.play_cursor
- if @index == Y6::SAVE::MAX_SLOTS - 1
- @index = 0
- else
- @index = [@index + 1, Y6::SAVE::MAX_SLOTS - 1].min
- end
- elsif Input.repeat?(Input::UP)
- last_index = @index
- @index = [@index - 1, 0].max
- Sound.play_cursor if last_index != @index
- elsif Input.repeat?(Input::L)
- last_index = @index
- @index = [@index - 5, 0].max
- Sound.play_cursor if last_index != @index
- elsif Input.repeat?(Input::DOWN)
- last_index = @index
- @index = [@index + 1, Y6::SAVE::MAX_SLOTS - 1].min
- Sound.play_cursor if last_index != @index
- elsif Input.repeat?(Input::R)
- last_index = @index
- @index = [@index + 5, Y6::SAVE::MAX_SLOTS - 1].min
- Sound.play_cursor if last_index != @index
- elsif Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::C)
- command_input
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: create_savefile_windows
- #--------------------------------------------------------------------------
- def create_savefile_windows
- @savefile_windows = []
- for i in 0..3
- @savefile_windows.push(Window_File_Small.new)
- end
- @item_max = Y6::SAVE::MAX_SLOTS
- @savefile_big = Window_File_Big.new(@from_title)
- organize_savefile_locations
- update_savefile_windows
- end
- #--------------------------------------------------------------------------
- # overwrite method: dispose_item_windows
- #--------------------------------------------------------------------------
- def dispose_item_windows
- for window in @savefile_windows; window.dispose; end
- @savefile_big.dispose
- end
- #--------------------------------------------------------------------------
- # new method: update_savefile_windows
- #--------------------------------------------------------------------------
- def update_savefile_windows
- @savefile_big.update
- @savefile_windows[0].update
- @savefile_windows[1].update
- @savefile_windows[2].update
- @savefile_windows[3].update
- end
- #--------------------------------------------------------------------------
- # new method: organize_savefile_locations
- #--------------------------------------------------------------------------
- def organize_savefile_locations
- return if @last_index == @index
- @last_index = @index
- if @index == 0
- @savefile_big.y = 0
- @savefile_big.change(@index, make_filename(@index))
- @savefile_windows[0].y = Graphics.height-56*4
- @savefile_windows[0].change(@index+1, make_filename(@index+1))
- @savefile_windows[1].y = Graphics.height-56*3
- @savefile_windows[1].change(@index+2, make_filename(@index+2))
- @savefile_windows[2].y = Graphics.height-56*2
- @savefile_windows[2].change(@index+3, make_filename(@index+3))
- @savefile_windows[3].y = Graphics.height-56*1
- @savefile_windows[3].change(@index+4, make_filename(@index+4))
- elsif @index == 1
- @savefile_windows[0].y = 56*0
- @savefile_windows[0].change(@index-1, make_filename(@index-1))
- @savefile_big.y = 56*1
- @savefile_big.change(@index, make_filename(@index))
- @savefile_windows[1].y = Graphics.height-56*3
- @savefile_windows[1].change(@index+1, make_filename(@index+1))
- @savefile_windows[2].y = Graphics.height-56*2
- @savefile_windows[2].change(@index+2, make_filename(@index+2))
- @savefile_windows[3].y = Graphics.height-56*1
- @savefile_windows[3].change(@index+3, make_filename(@index+3))
- elsif @index == Y6::SAVE::MAX_SLOTS - 2
- @savefile_windows[0].y = 56*0
- @savefile_windows[0].change(@index-3, make_filename(@index-3))
- @savefile_windows[1].y = 56*1
- @savefile_windows[1].change(@index-2, make_filename(@index-2))
- @savefile_windows[2].y = 56*2
- @savefile_windows[2].change(@index-1, make_filename(@index-1))
- @savefile_big.y = 56*3
- @savefile_big.change(@index, make_filename(@index))
- @savefile_windows[3].y = Graphics.height-56*1
- @savefile_windows[3].change(@index+1, make_filename(@index+1))
- elsif @index == Y6::SAVE::MAX_SLOTS - 1
- @savefile_windows[0].y = 56*0
- @savefile_windows[0].change(@index-4, make_filename(@index-4))
- @savefile_windows[1].y = 56*1
- @savefile_windows[1].change(@index-3, make_filename(@index-3))
- @savefile_windows[2].y = 56*2
- @savefile_windows[2].change(@index-2, make_filename(@index-2))
- @savefile_windows[3].y = 56*3
- @savefile_windows[3].change(@index-1, make_filename(@index-1))
- @savefile_big.y = 56*4
- @savefile_big.change(@index, make_filename(@index))
- else
- @savefile_windows[0].y = 56*0
- @savefile_windows[0].change(@index-2, make_filename(@index-2))
- @savefile_windows[1].y = 56*1
- @savefile_windows[1].change(@index-1, make_filename(@index-1))
- @savefile_big.y = 56*2
- @savefile_big.change(@index, make_filename(@index))
- @savefile_windows[2].y = Graphics.height-56*2
- @savefile_windows[2].change(@index+1, make_filename(@index+1))
- @savefile_windows[3].y = Graphics.height-56*1
- @savefile_windows[3].change(@index+2, make_filename(@index+2))
- end
- end
- #--------------------------------------------------------------------------
- # new method: command_input
- #--------------------------------------------------------------------------
- def command_input
- case @savefile_big.index
- when 0 # Save
- if @from_title
- Sound.play_buzzer
- else
- Sound.play_save
- do_save
- end
- when 1 # Load
- if @savefile_big.file_exist
- Sound.play_load
- do_load
- else
- Sound.play_buzzer
- end
- else # Delete
- if @savefile_big.file_exist
- RPG::SE.new(Y6::SAVE::DELETE_SOUND, 100).play
- do_delete
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # overwrite method: do_save
- #--------------------------------------------------------------------------
- def do_save
- $game_temp.last_file_index = @index
- file = File.open(@savefile_big.filename, "wb")
- write_save_data(file)
- file.close
- @savefile_big.change(@index, make_filename(@index))
- end
- #--------------------------------------------------------------------------
- # overwrite method: do_load
- #--------------------------------------------------------------------------
- def do_load
- return unless FileTest.exist?(@savefile_big.filename)
- $game_temp.last_file_index = @index
- file = File.open(@savefile_big.filename, "rb")
- read_save_data(file)
- file.close
- $scene = Scene_Map.new
- RPG::BGM.fade(1500)
- Graphics.fadeout(60)
- @last_bgm.play
- @last_bgs.play
- end
- #--------------------------------------------------------------------------
- # overwrite method: do_delete
- #--------------------------------------------------------------------------
- def do_delete
- filename = @savefile_big.filename
- File.delete(filename) if FileTest.exist?(filename)
- @savefile_big.change(@index, make_filename(@index))
- end
- end # Scene_File
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================
Add Comment
Please, Sign In to add comment