Galv’s Ace Save Engine Confirmation Add-on

Requires Yanfly’s Ace Save Engine script
Put the below script after Yanfly’s in the script list.

#-------------------------------------------------------------------------------
# Yanfly's Ace Save Engine - Confirmation Add-on
# Requires Yanfly's Ace Save Engine. Includes New Game Plus add-on confirm.
# by GALV
# Put this script after Yanfly's Save Engine script
# Last updated 2014-04-03 - Fixed bug where loading greater than 9 save file
# index crashes the game
#-------------------------------------------------------------------------------
  
module YEA
  module SAVE
    CONFIRM_DELETE = "Delete this save file?"
    CONFIRM_SAVE = "Overwrite this save file?"
    CONFIRM_LOAD = "Load this save file?"
  
    CONFIRM_NEW_GAME_PLUS = "Restart this game?"  # For Yanfly's 'New Game Plus'
  end
end
  
class Scene_File < Scene_MenuBase
  
  alias galv_yf_save_scene_file create_all_windows
  def create_all_windows
    galv_yf_save_scene_file
    create_confirm_window
  end
  
  def create_confirm_window
    @confirm_window = Window_Confirm.new
    @confirm_window.help_window = @help_window
    @confirm_window.hide.deactivate
    @confirm_window.set_handler(:ok, method(:on_confirm_ok))
    @confirm_window.set_handler(:cancel, method(:on_confirm_cancel))
  end
  
  def on_confirm_ok
    case @confirm_window.current_symbol
    when :on_confirm_ok
      case @action_window.current_symbol
      when :load; on_action_confirmed_load
      when :save; do_save; refresh_windows
      when :delete; do_delete; refresh_windows
      when :new_game_plus; on_action_ngp_confirmed
      end
    when :on_confirm_cancel
      on_confirm_cancel
    end
    @action_window.activate
    @confirm_window.hide.deactivate
  end
  
  def on_confirm_cancel
    @action_window.activate
    @confirm_window.hide.deactivate
  end
  
  def on_action_load
    n = @file_window.index >= 9 ? "" : "0"
    if SceneManager.scene_is?(Scene_Load)
      if DataManager.load_game(@file_window.index)
        on_load_success
      else
        Sound.play_buzzer
      end
    #elsif !Dir.glob('Save0' + (@file_window.index + 1).to_s + '.rvdata2').empty?
    elsif !Dir.glob('Save'+ n + (@file_window.index + 1).to_s + '.rvdata2').empty?
      confirm_choice
    else
      Sound.play_buzzer
    end
  end
  
if $imported["YEA-NewGame+"]
  def on_action_ngp
    confirm_choice
  end
  
  def on_action_ngp_confirmed
    Sound.play_load
    DataManager.setup_new_game_plus(@file_window.index)
    fadeout_all
    $game_system.on_after_load
    SceneManager.goto(Scene_Map)
  end
end
  
  def on_action_confirmed_load
    if DataManager.load_game(@file_window.index)
      on_load_success
    end
  end
  
  def on_load_success
    Sound.play_load
    fadeout_all
    $game_system.on_after_load
    SceneManager.goto(Scene_Map)
  end
  
  def confirm_choice
    @action_window.deactivate
    @confirm_window.select(0)
    @confirm_window.show.activate
    case @action_window.current_symbol
    when :load; @help_window.set_text(YEA::SAVE::CONFIRM_LOAD)
    when :save; @help_window.set_text(YEA::SAVE::CONFIRM_SAVE)
    when :delete; @help_window.set_text(YEA::SAVE::CONFIRM_DELETE)
    when :new_game_plus; @help_window.set_text(YEA::SAVE::CONFIRM_NEW_GAME_PLUS)
    end
  end
  
  def on_action_save
    header = DataManager.load_header(@file_window.index)
    if header.nil?
      do_save
      refresh_windows
    else
      confirm_choice
    end
  end
  
  def do_save
    @action_window.activate
    if DataManager.save_game(@file_window.index)
      on_save_success
    else
      Sound.play_buzzer
    end
  end
  
  def on_action_delete
    confirm_choice
  end
  
  def do_delete
    @action_window.activate
    DataManager.delete_save_file(@file_window.index)
    on_delete_success
    refresh_windows
  end
  
end # Scene_File
  
class Window_Confirm < Window_Command
  def initialize
    super(0, 0)
    self.back_opacity = 255
    update_position
  end
  
  def window_width
    return 200
  end
  
  def update_position
    self.x = (Graphics.width - width) / 2
    self.y = Graphics.height / 2
  end
  
  def update_help; end
  
  def make_command_list
    add_command("Yes", :on_confirm_ok)
    add_command("No", :on_confirm_cancel)
  end
  
end # Window_Confirm < Window_Command

15 thoughts on “Galv’s Ace Save Engine Confirmation Add-on

  1. DONY says:

    may I request? Can you make a feature for this script to be able to bring existing images or pictures by difolder system folder id, example: picture-1.png to map No. 1, so if the player save games on the docket no 1 it will display the image also picture-1 . png

  2. Deathmask97 says:

    I love you so much for this script<3

  3. shadowblack says:

    Hello.

    I’ve encountered an odd problem with this script. Here’s what I know:
    1) New project with just 2 scripts:
    – Yanfly Engine Ace – Ace Save Engine v1.03
    – Yanfly’s Ace Save Engine – Confirmation Add-on (this script)
    And yes, the scripts are ordered just like that – Save Engine first, Confirmation Add-on second.
    2) Settings for Yanfly’s script:
    MAX_FILES = 99
    SLOT_NAME = “File %s”
    3) I start a new game. Creating saves and Deleting saves works just fine. However, Loading saves during gameplay works ONLY if the save is numbered 9 or less. If the save is numbered 10, 11, 12, 13, 14, etc. and I try to load it during gameplay I get the buzzer sound and the game stops responding. Loading the same save from the main menu works fine
    4) If I remove the Confirmation Add-on loading starts working fine during game play

    Any ideas what could be the problem and how to fix it?

  4. tinyclementiny says:

    I would like to thank you for this useful script. However, I do think it would be even better if it could also be used when screenshot features for YEA Save Engine are present. (By these I mean Tsukihime’s Map Screenshot + Gambit’s Save Game Screenshot scripts that add a picture of current location to the save file.) After reordering these for a while, it seems that as long as your script is placed above the screenshot scripts, it works just fine EXCEPT for the save confirmation (which just doesn’t appear – the saves happen the normal way). I know this may be a request, but I hope that maybe you will consider it at some point. And even if you don’t with this one, keep it up with scripting; some of your scripts are seriously awesome! :)

  5. Marcus.B says:

    Its telling me stack level to deep then sends me to the end of the script.
    Whats it mean?

  6. Fallun says:

    You’re a legend galv<3

  7. Rochelle says:

    hello, we have our “pause” in our game and it works only once you press the “ALT” key the game will pause and it will display a “PAUSE” picture but the SE does not stop and but if you didn’t, it will not pause the game.

    So what we need is your magnificent help on making our game pause automatically and display “PAUSE” picture, then pause the SE when the rpg project window is not active or when the player switch on other window. But when the window is active, it will continue the game.

    • Galv says:

      I’m sorry, I do not know what you mean and do not currently have time to do free requests at the moment. (Also, this page is for help with the save engine add on script).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s