# データベース (マップ名) $data_mapinfos ||= load_data("Data/MapInfos.rvdata") class Game_System #-------------------------------------------------------------------------- # ● 拡張セーブデータ #-------------------------------------------------------------------------- def save_data return @save_data ||= {} end end class Scene_File #-------------------------------------------------------------------------- # ● セーブの実行 #-------------------------------------------------------------------------- alias _ori_do_save do_save def do_save $game_system.save_data[:map_id] = $game_map.map_id $game_system.save_data[:level] = $game_party.members.map {|a| a.level } $game_system.save_data[:gold] = $game_party.gold _ori_do_save end end class Window_SaveCommand < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 72, 160, 344) @commands = Array.new(13) {|i| sprintf("ファイル %03d", i + 1) } @item_max = @commands.size create_contents refresh self.index = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 # enabled : 有効フラグ。false のとき半透明で描画 #-------------------------------------------------------------------------- def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]) end end class Window_SaveFile #-------------------------------------------------------------------------- # ● オブジェクト初期化 # file_index : セーブファイルのインデックス # filename : ファイル名 #-------------------------------------------------------------------------- def initialize(file_index, filename) super(160, 0, 384, 416) self.visible = false @file_index = file_index @filename = filename load_gamedata end #-------------------------------------------------------------------------- # ● ウィンドウの可視状態の設定 # value : 可視状態 #-------------------------------------------------------------------------- def visible=(value) super if value && !@painted refresh @painted = true end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear draw_file_number(4, 0, 144) if @file_exist draw_file_time(148, 0, 196) draw_map_graphic(0, 36, 352) draw_map_name(4, 264, 344) draw_party_characters(16, 348) draw_playtime(4, 360, 188) draw_gold(200, 360, 148) end end end class Window_SaveFile #-------------------------------------------------------------------------- # ● ファイル番号の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_file_number(x, y, width) self.contents.font.color = normal_color name = Vocab::File + " #{@file_index + 1}" self.contents.draw_text(x, y, width, WLH, name) end #-------------------------------------------------------------------------- # ● 保存時間の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_file_time(x, y, width) text = @time_stamp.strftime("%m/%d %X") self.contents.font.color = normal_color self.contents.draw_text(x, y, width, WLH, text, 2) end #-------------------------------------------------------------------------- # ● マップ画像の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_map_graphic(x, y, width) map_id = @game_system.save_data[:map_id] return if map_id == nil bitmap = Cache.picture(sprintf("MAP%03d", map_id)) self.contents.blt(x, y, bitmap, bitmap.rect) end #-------------------------------------------------------------------------- # ● マップ名の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_map_name(x, y, width) map_id = @game_system.save_data[:map_id] return if map_id == nil self.contents.font.color = system_color self.contents.draw_text(x, y, width, WLH, "マップ名") self.contents.font.color = normal_color self.contents.draw_text(x, y, width, WLH, $data_mapinfos[map_id].name, 2) end #-------------------------------------------------------------------------- # ● パーティキャラの描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_party_characters(x, y) for i in 0...@characters.size name = @characters[i][0] index = @characters[i][1] dx = x + i * 88 draw_character(name, index, dx, y) next unless @game_system.save_data[:level] draw_actor_level(dx + 20, y - WLH, @game_system.save_data[:level][i]) end end #-------------------------------------------------------------------------- # ● レベルの描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # level : レベル #-------------------------------------------------------------------------- def draw_actor_level(x, y, level) self.contents.font.color = system_color self.contents.draw_text(x, y, 24, WLH, Vocab::level_a) self.contents.font.color = normal_color self.contents.draw_text(x + 20, y, 24, WLH, level, 2) end #-------------------------------------------------------------------------- # ● プレイ時間の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_playtime(x, y, width) 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 = system_color self.contents.draw_text(x, y, width, WLH, "プレイ時間") self.contents.font.color = normal_color self.contents.draw_text(x, y, width, WLH, time_string, 2) end #-------------------------------------------------------------------------- # ● 所持金の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_gold(x, y, width) self.contents.font.color = system_color self.contents.draw_text(x, y, width, WLH, "所持金") draw_currency_value(@game_system.save_data[:gold], x, y, width) end end class Scene_File #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @title_window = Window_Base.new(0, 0, 160, 72) @title_window.contents.font.size = 26 @command_window = Window_SaveCommand.new create_savefile_windows if @saving @command_window.index = $game_temp.last_file_index @title_window.contents.draw_text(0, 0, 128, 40, "セーブ", 1) else @command_window.index = self.latest_file_index @title_window.contents.draw_text(0, 0, 128, 40, "ロード", 1) end @savefile_windows[@command_window.index].visible = true end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @title_window.dispose @command_window.dispose dispose_savefile_windows end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super last_index = @command_window.index update_menu_background @title_window.update @command_window.update update_savefile_windows if @command_window.index != last_index @savefile_windows[last_index].visible = false @savefile_windows[@command_window.index].visible = true end @index = @command_window.index update_savefile_selection end #-------------------------------------------------------------------------- # ● セーブファイルウィンドウの作成 #-------------------------------------------------------------------------- def create_savefile_windows @savefile_windows = Array.new(@command_window.item_max) do |i| Window_SaveFile.new(i, make_filename(i)) end end #-------------------------------------------------------------------------- # ● セーブファイルウィンドウの解放 #-------------------------------------------------------------------------- def dispose_savefile_windows for window in @savefile_windows window.dispose end end #-------------------------------------------------------------------------- # ● セーブファイル選択の更新 #-------------------------------------------------------------------------- def update_savefile_selection if Input.trigger?(Input::C) determine_savefile elsif Input.trigger?(Input::B) Sound.play_cancel return_scene end end end