[Sauvegarde]Plus de slot de sauvegarde...

La section pour les scripts de RPG Maker XP !

[Sauvegarde]Plus de slot de sauvegarde...

Message par Benjamin » 17 Mai 2007, 20:17

Auteur : RPG Advocate

Remarques : Testé et fonctionnel.

Fonctions : Vous pouvez augmentez le nombre de slot de sauvegarde autant que vous voulez ( ex : 90 sauvegarde).

class Scene_File
SAVEFILE_MAX = 99
# -------------------
def initialize(help_text)
@help_text = help_text
end
# -------------------
def main
@help_window = Window_Help.new
@help_window.set_text(@help_text)
@savefile_windows = []
@cursor_displace = 0
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))
end
@file_index = 0
@savefile_windows[@file_index].selected = true
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
for i in @savefile_windows
i.dispose
end
end
# -------------------
def update
@help_window.update
for i in @savefile_windows
i.update
end
if Input.trigger?(Input::C)
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
end
if Input.trigger?(Input::B)
on_cancel
return
end
if Input.repeat?(Input::DOWN)
if Input.trigger?(Input::DOWN) or @file_index < SAVEFILE_MAX - 1
if @file_index == SAVEFILE_MAX - 1
$game_system.se_play($data_system.buzzer_se)
return
end
@cursor_displace += 1
if @cursor_displace == 4
@cursor_displace = 3
for i in @savefile_windows
i.dispose
end
@savefile_windows = []
for i in 0..3
f = i - 2 + @file_index
name = make_filename(f)
@savefile_windows.push(Window_SaveFile.new(f, name, i))
@savefile_windows[i].selected = false
end
end
$game_system.se_play($data_system.cursor_se)
@file_index = (@file_index + 1)
if @file_index == SAVEFILE_MAX
@file_index = SAVEFILE_MAX - 1
end
for i in 0..3
@savefile_windows[i].selected = false
end
@savefile_windows[@cursor_displace].selected = true
return
end
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @file_index > 0
if @file_index == 0
$game_system.se_play($data_system.buzzer_se)
return
end
@cursor_displace -= 1
if @cursor_displace == -1
@cursor_displace = 0
for i in @savefile_windows
i.dispose
end
@savefile_windows = []
for i in 0..3
f = i - 1 + @file_index
name = make_filename(f)
@savefile_windows.push(Window_SaveFile.new(f, name, i))
@savefile_windows[i].selected = false
end
end
$game_system.se_play($data_system.cursor_se)
@file_index = (@file_index - 1)
if @file_index == -1
@file_index = 0
end
for i in 0..3
@savefile_windows[i].selected = false
end
@savefile_windows[@cursor_displace].selected = true
return
end
end
end
# -------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
# -------------------
end [/color]


Remplacez le script " Window_SaveFile " par le code ci dessous.

[color=green]#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
#  セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。
#==============================================================================

class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :filename # ファイル名
attr_reader :selected # 選択状態
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# file_index : セーブファイルのインデックス (0~3)
# filename : ファイル名
#--------------------------------------------------------------------------
def initialize(file_index, filename, position)
y = 64 + position * 104
super(0, y, 640, 104)
self.contents = Bitmap.new(width - 32, height - 32)
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end

#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
name = "Slot #{@file_index + 1}"
self.contents.font.color = normal_color
name = "File #{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
# セーブファイルが存在する場合
if @file_exist
# キャラクターを描画
for i in 0...@characters.size
bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 300 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 68 - ch, bitmap, src_rect)
end
# プレイ時間を描画
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 8, 600, 32, time_string, 2)
# タイムスタンプを描画
self.contents.font.color = normal_color
time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
self.contents.draw_text(4, 40, 600, 32, time_string, 2)
end
end
#--------------------------------------------------------------------------
# ● 選択状態の設定
# selected : 新しい選択状態 (true=選択 false=非選択)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
if @selected
self.cursor_rect.set(0, 0, @name_width + 8, 32)
else
self.cursor_rect.empty
end
end
end

Installation : Ouvrez l'éditeur de script et remplacez le script " Scene_File " par le code ci dessous.

Pour changer le nombre de sauvegarde renseignez la variable

SAVEFILE_MAX se trouvant à la ligne 2 :
SAVEFILE_MAX = 99
Dernière édition par Benjamin le 18 Mai 2007, 10:40, édité 4 fois.
Avatar de l’utilisateur
Benjamin
Membre d'honneur
Membre d'honneur
 
Message(s) : 667
Inscription : 22 Déc 2006, 15:02
Localisation : Belgique

Message par Amathlog » 18 Mai 2007, 08:56

Cool pleins de nouveaux scripts !
Sinon j'ai regarder ton script et je l'ai tester (on sait jamais ! :) )
Et quand je lance le jeu ça me met syntax error a cette ligne :
ligne 155 : @total_sec = @frame_count / Graphics.frame_rate
Avatar de l’utilisateur
Amathlog
Modérateur
Modérateur
 
Message(s) : 1510
Inscription : 14 Jan 2007, 19:53
Meilleurs scores: 2

Message par Benjamin » 18 Mai 2007, 10:35

C'est bon j'ai compris, en fait le script était en 2 partie, masi la ou je l'ai trouvé, il était dans le même balise code, j'edit tout de suite.
Avatar de l’utilisateur
Benjamin
Membre d'honneur
Membre d'honneur
 
Message(s) : 667
Inscription : 22 Déc 2006, 15:02
Localisation : Belgique

Message par Amathlog » 18 Mai 2007, 10:41

Cool !
Tant mieux que tu as trouvé !
Bonne chance pour la suite !
Avatar de l’utilisateur
Amathlog
Modérateur
Modérateur
 
Message(s) : 1510
Inscription : 14 Jan 2007, 19:53
Meilleurs scores: 2


Retour vers Scripts (RGSS)

Qui est en ligne ?

Utilisateur(s) parcourant ce forum : Aucun utilisateur inscrit et 2 invité(s)

cron