Save and Load Menu in APIs
v1.0
By: Berka
v1.0
By: Berka
Introduction
This script is perfectly useless, but I enjoyed creating it.
It allows the management of backups with the default Windows' Load/Save system
Features
- Check if the file already exists
- Saves can leave the project's directory.
Screenshots

Demo
none.
Script
RMVX
Spoiler
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Sauvegarde WindowsÂ
- # par berka v 1.0 rgss2
- # http://www.rpgmakervx-fr.com
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Place it above main
- # in an event, "call a script" command
- # save : open the save dialog
- # load : open the load dialog
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- module Berka
- module ChargApi
- $LOAD_PATH<<'./'
- Filtre=["Save",".rvdata"]
- Charger="Load a file"
- Sauver="Save the Game"
- Conf="The file %s already exists, replace it ?"
- ConfTitre="Confirmation"
- Ret="Scene_Map"
- end
- end
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- def handle
- h=Win32API.new('kernel32','GetPrivateProfileString','pppplp','l')
- h.call("Game","Title","",t="\0"*256,256,"./Game.ini")
- Win32API.new('user32','FindWindow','pp','i').call("RGSS Player",t.delete!("\0"))
- end
- include Berka::ChargApi
- class Game_Interpreter;def list_clr;@list=nil;end;end
- def load
- ret,filtre="\0"*1024,"#{Filtre[0]}(*#{Filtre[1]})\0*#{Filtre[1]}\0\0"
- arg=[76,handle,0,filtre,0,0,1,ret,ret.size,0,0,0,Charger,
- 0x800|0x1000|4,0,0,".",0,0,0,].pack("I3pI3pI4pIS2pI3")
- return if Win32API.new('comdlg32','GetOpenFileName','p','i').call(arg)==0
- Scene_File.new(false,false,true).read_save_data(f=File.open(ret.rstrip,"rb"))
- f.close;$scene=eval("$scene=#{Ret}.new")
- end
- def save
- ret,filtre="\0"*1024,"#{Filtre[0]}(*#{Filtre[1]})\0*#{Filtre[1]}\0\0"
- arg=[76,handle,0,filtre,0,0,1,ret,ret.size,0,0,0,Sauver,
- 4|0x1000|0x80000,0,0,".",0,0,0].pack("I3pI3pI4pIS2pI3")
- return if Win32API.new('comdlg32','GetSaveFileName','p','i').call(arg)==0
- save if !(confirm?(ret.rstrip)if FileTest.exist?(ret.rstrip))
- $game_map.interpreter.list_clr
- Scene_File.new(true,false,true).write_save_data(f=File.open(ret.rstrip,"wb"))
- f.close;$scene=eval("$scene=#{Ret}.new")
- end
- def confirm?(f)
- t=sprintf(Conf,f.split("\\")[-1].gsub(Filtre[1],""))
- Win32API.new('user32','MessageBox','lppl','i').call(0,t,ConfTitre,36)==6
- end
Expand to see the code.
RMXP
Spoiler
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Sauvegarde Windows
- # par berka v 1.0 rgss1
- # http://www.rpgmakervx-fr.com
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Place it above main
- # in an event, "call a script" command
- # save : open the save dialog
- # load : open the load dialog
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- module Berka
- module ChargApi
- $LOAD_PATH<<'./'
- Filtre=["Save",".rxdata"]
- Charger="Load a file"
- Sauver="Save the Game"
- Conf="The file %s already exists, replace it ?"
- ConfTitre="Confirmation"
- Ret="Scene_Map"
- end
- end
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- def handle
- h=Win32API.new('kernel32','GetPrivateProfileString','pppplp','l')
- h.call("Game","Title","",t="\0"*256,256,"./Game.ini")
- Win32API.new('user32','FindWindow','pp','i').call("RGSS Player",t.delete!("\0"))
- end
- class Interpreter;def list_clr;@list=nil;end;end
- def load
- ret,filtre="\0"*1024,"#{Berka::ChargApi::Filtre[0]}(
- *#{Berka::ChargApi::Filtre[1]})\0*#{Berka::ChargApi::Filtre[1]}\0\0"
- arg=[76,handle,0,filtre,0,0,1,ret,ret.size,0,0,0,Berka::ChargApi::Charger,
- 0x800|0x1000|4,0,0,".",0,0,0,].pack("I3pI3pI4pIS2pI3")
- return if Win32API.new('comdlg32','GetOpenFileName','p','i').call(arg)==0
- Scene_Load.new.read_save_data(f=File.open(ret.rstrip,"rb"))
- f.close;$scene=eval("$scene=#{Berka::ChargApi::Ret}.new")
- end
- def save
- ret,filtre="\0"*1024,"#{Berka::ChargApi::Filtre[0]}(
- *#{Berka::ChargApi::Filtre[1]})\0*#{Berka::ChargApi::Filtre[1]}\0\0"
- arg=[76,handle,0,filtre,0,0,1,ret,ret.size,0,0,0,Berka::ChargApi::Sauver,
- 4|0x1000|0x80000,0,0,".",0,0,0].pack("I3pI3pI4pIS2pI3")
- return if Win32API.new('comdlg32','GetSaveFileName','p','i').call(arg)==0
- save if !(confirm?(ret.rstrip)if FileTest.exist?(ret.rstrip))
- $game_system.map_interpreter.list_clr
- Scene_Save.new.write_save_data(f=File.open(ret.rstrip,"wb"))
- f.close;$scene=eval("$scene=#{Berka::ChargApi::Ret}.new")
- end
- def confirm?(f)
- t=sprintf(Berka::ChargApi::Conf,f.split("\\")[-1].gsub(Berka::ChargApi::Filtre[1],""))
- Win32API.new('user32','MessageBox','lppl','i').call(0,t,Berka::ChargApi::ConfTitre,36)==6
- end
Expand to see the code.
Instructions
In an Event, 'call a script' command:
Quote:
save
to save the gameQuote:
load
to load the gameFAQ
Place the script above main
Compatibility
I really don't know!
Credits and Thanks
Msdn
Terms and Conditions
Free for using, but I need credits. Do not post this script anywhere without my permission !
enjoy !
berka