03-03-2008, 05:48 AM
Prompt for Overwrite Confirmation when Saving
by RPG Advocate
saved from Phylomortis.Com
by RPG Advocate
saved from Phylomortis.Com
Introduction
This script modifies the save system so that if the player attempts to save in a slot already occupied by a save file, the game will ask for confirmation before overwriting the save.
Demo
>Click<
Script
Save Overwrite Confirmation Prompt
Code:
# Prompt for Overwrite Confirmation when Saving
# by RPG Advocate
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This is a superclass for the save screen and load screen.
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias pfocws_main main
def main
pfocws_main
if self.is_a?(Scene_Save)
@confirm_window.dispose
@yes_no_window.dispose
end
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias pfocws_initialize initialize
def initialize
pfocws_initialize
# Create confirm window
@confirm_window = Window_Base.new(120, 188, 400, 64)
@confirm_window.contents = Bitmap.new(368, 32)
string = "Really overwrite this file?"
@confirm_window.contents.draw_text(4, 0, 368, 32, string)
@confirm_window.visible = false
@confirm_window.z = 1500
# Create Yes/No Window
@yes_no_window = Window_Command.new(100, ["Yes", "No"])
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@yes_no_window.x = 270
@yes_no_window.y = 252
@yes_no_window.z = 1500
@mode = 0
end
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
alias pfocws_on_decision on_decision
def on_decision(filename)
# If savegame already exists
if FileTest.exist?(filename)
# Show decision window
@confirm_window.visible = true
@yes_no_window.visible = true
@yes_no_window.active = true
@mode = 1
else
# The original call
pfocws_on_decision(filename)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @mode == 0
super
else
# Update windows
@help_window.update
@yes_no_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Hide the windows
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@mode = 0
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If overwrite/write permitted
if @yes_no_window.index == 0
filename = make_filename(@file_index)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open(filename, "wb")
write_save_data(file)
file.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
else
# Switch to menu screen
$scene = Scene_Menu.new(4)
end
else
# Hide the windows
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@mode = 0
end
end
end
end
end