#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆2ペインå¼ã‚»ãƒ¼ãƒ– ï¼ KGC_2PaneSaveâ—†
#_/----------------------------------------------------------------------------
#_/ 2ペインå¼ã®ã‚»ãƒ¼ãƒ–ç”»é¢ã‚’作æˆã—ã¾ã™ã€‚
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ ã‚«ã‚¹ã‚¿ãƒžã‚¤ã‚ºé …ç›® ★
#==============================================================================
module KGC
# ◆ページ数
# 1 ページã«ã¤ãセーブファイル 4 個。
# 多ã™ãŽã‚‹ã¨ã‚»ãƒ¼ãƒ–/ãƒãƒ¼ãƒ‰ç”»é¢ã®è¡¨ç¤ºãŒé…ããªã‚Šã¾ã™ã€‚
# ※必㚠1 以上を指定ã—ã¦ãã ã•ã„。
TPS_PAGE_NUMBER = 2
# ◆ファイル番å·æ›¸å¼
# ã€{i}..ファイル番å·ã€‘
TPS_FILE_INDEX_FORMAT = "Data {i}"
# ◆メンãƒãƒ¼ãƒªã‚¹ãƒˆã®åˆ—æ•°(1~4)
# 5 以上ã«ã™ã‚‹ã¨è¡¨ç¤ºãŒè¢«ã‚Šã¾ã™ã€‚
TPS_MEMBER_COLS = 3
# ◆控ãˆãƒ¡ãƒ³ãƒãƒ¼ã‚‚æç”»
# ≪多人数パーティ≫導入時ã®ã¿æœ‰åŠ¹ã€‚
TPS_DRAW_ALL_MEMBER = true
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["2PaneSave"] = true
$imported["FrameShadowText"] = true
#==============================================================================
# â– Window_SaveFile
#==============================================================================
class Window_SaveFile < Window_Base
attr_accessor :destination
#--------------------------------------------------------------------------
# ◠オブジェクトåˆæœŸåŒ–
# file_index : セーブファイルã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹
# filename : ファイルå
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(file_index * 160, 64, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Tahoma"
self.contents.font.size = 19
@file_index = file_index
@filename = "Saves/Data #{@file_index + 1}.sav"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@frame_count = Marshal.load(file)
unless @frame_count.is_a?(Integer)
@frame_count = Marshal.load(file)
end
9.times { |i| # ä¸è¦ãªç®‡æ‰€ã‚’èªã¿é£›ã°ã™
Marshal.load(file)
}
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@destination = self.x
@selected = false
end
#--------------------------------------------------------------------------
# ◠リフレッシュ
#--------------------------------------------------------------------------
def refresh
# MapInfo.rxdata ã‚’ãƒãƒ¼ãƒ‰
mapinfo = load_data("Data/MapInfos.rxdata")
self.contents.clear
# ファイル番å·ã‚’æç”»
self.contents.font.color = system_color
name = KGC::TPS_FILE_INDEX_FORMAT.dup
name.gsub!(/{i}/) { "#{@file_index + 1}" }
self.contents.draw_text(4, 0, 120, 32, name)
@name_width = contents.text_size(name).width
# セーブファイルãŒå˜åœ¨ã™ã‚‹å ´åˆ
if @file_exist
# プレイ時間をæç”»
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, 32, 120, 32, time_string)
end
end
#--------------------------------------------------------------------------
# ◠フレーム更新
#--------------------------------------------------------------------------
def update
super
# ウィンドウ移動
if self.x != @destination
if (self.x - @destination).abs < 12
self.x = @destination
else
dist = (@destination - self.x) / 8
if dist < 0
dist = [dist, -12].min
else
dist = [dist, 12].max
end
self.x += dist
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# â– Window_SaveFileInfo
#------------------------------------------------------------------------------
#  ファイルã®æƒ…å ±ã‚’è¡¨ç¤ºã™ã‚‹ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã§ã™ã€‚
#==============================================================================
class Window_SaveFileInfo < Window_Base
#--------------------------------------------------------------------------
# ◠オブジェクトåˆæœŸåŒ–
#--------------------------------------------------------------------------
def initialize
super(0, 160, 640, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 19
end
#--------------------------------------------------------------------------
# ◠リフレッシュ
# file_index : セーブファイルã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹
#--------------------------------------------------------------------------
def refresh(file_index)
if @file_index == file_index
return
end
self.contents.clear
@file_index = file_index
filename = "Saves/Data #{file_index + 1}.sav"
if FileTest.exist?(filename)
self.contents.font.color = normal_color
self.contents.font.name = Font.default_name
self.contents.font.size = 19
self.contents.font.bold = Font.default_bold
draw_file_info(filename)
else
self.contents.font.color = disabled_color
self.contents.font.name = "Tahoma"
self.contents.font.size = 19
self.contents.font.bold = true
self.contents.draw_text(0, 112, 640, 64, "- NO DATA -", 1)
end
end
#--------------------------------------------------------------------------
# â— ãƒ•ã‚¡ã‚¤ãƒ«æƒ…å ±æç”»
# filename : 対象ファイルå
#--------------------------------------------------------------------------
def draw_file_info(filename)
self.contents.font.name = "Tahoma"
self.contents.font.size = 19
file = File.open(filename, "r")
time_stamp = file.mtime
frame_count = Marshal.load(file)
unless frame_count.is_a?(Integer)
frame_count = Marshal.load(file)
end
game_system = Marshal.load(file)
game_switches = Marshal.load(file)
game_variables = Marshal.load(file)
game_self_switches = Marshal.load(file)
game_screen = Marshal.load(file)
game_actors = Marshal.load(file)
game_party = Marshal.load(file)
game_troop = Marshal.load(file)
game_map = Marshal.load(file)
total_sec = frame_count / Graphics.frame_rate
file.close
# ã‚ャラクターをæç”»
actors = game_party.actors
if $imported["LargeParty"] && !KGC::TPS_DRAW_ALL_MEMBER
actors = game_party.battle_actors
end
actors.each_with_index { |actor, i|
x = i / 5 * (608 / KGC::TPS_MEMBER_COLS)
y = i % 5 * 48
out = dead = false
if $imported["LargeParty"] && !game_party.battle_actors.include?(actor)
out = true
elsif actor.dead?
dead = true
end
image = RPG::Cache.character(actor.character_name, actor.character_hue)
rect = Rect.new(0, 0, image.width >> 2, image.height >> 2)
self.contents.blt(x, y, image, rect, out ? 128 : 255)
self.contents.font.color = dead ? knockout_color : normal_color
self.contents.draw_text(x + 40, y, 108, 24, actor.name)
self.contents.font.color = system_color
self.contents.draw_text(x + 40, y + 24, 32, 24, "Lv.")
self.contents.font.color = normal_color
self.contents.draw_text(x + 72, y + 24, 64, 24, actor.level.to_s)
}
# プレイ時間をæç”»
hour = total_sec / 3600
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(480, 240, 48, 24, "Time: ")
self.contents.font.color = normal_color
self.contents.draw_text(528, 240, 80, 24, time_string, 2)
# タイムスタンプをæç”»
time_string = time_stamp.strftime("%Y/%m/%d %H:%M")
self.contents.draw_text(448, 264, 160, 24, time_string, 2)
# ã‚»ãƒ¼ãƒ–å ´æ‰€ãƒ»ä»»å‹™ã‚’æç”»
if $imported["PlaceMission"]
mapinfo = load_data("Data/MapInfos.rxdata")
place = ""
# マップåãŒç„¡ã„å ´åˆ
if game_system.place == nil || game_system.place == ""
# マップåã‚’å–å¾—
place = mapinfo[game_map.map_id].name
else
place = game_system.place
end
self.contents.font.color = system_color
cx = self.contents.text_size("Save in which slot?").width
self.contents.draw_text(4, 240, cx, 24, "Save in which slot?")
self.contents.font.color = normal_color
self.contents.draw_text(8 + cx, 240, 596 - cx, 24, place)
self.contents.font.color = system_color
cx = self.contents.text_size("Duty").width
self.contents.draw_text(4, 264, cx, 24, "Duty")
self.contents.font.color = normal_color
self.contents.draw_text(8 + cx, 264, 596 - cx, 24, game_system.mission)
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# â– Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ◠フレーム更新
#--------------------------------------------------------------------------
alias update_KGC_2PaneSave update
def update
# コンティニュー判定
unless @continue_checked
found = false
(KGC::TPS_PAGE_NUMBER * 4).times { |i|
if FileTest.exist?("Saves/Data #{i+1}.sav")
found = true
break
end
}
# セーブファイルãŒè¦‹ä»˜ã‹ã£ãŸå ´åˆ
if found
# カーソルをコンティニューã«åˆã‚ã›ã‚‹
@command_window.index = 1
end
@continue_checked = true
end
update_KGC_2PaneSave
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# â– Scene_File
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# ◠メイン処ç†
#--------------------------------------------------------------------------
def main
@file_number = KGC::TPS_PAGE_NUMBER * 4
create_sprites
# 最後ã«æ“作ã—ãŸãƒ•ã‚¡ã‚¤ãƒ«ã‚’é¸æŠž
@file_index = $game_temp.last_file_index
@savefile_windows[@file_index].selected = true
@index_x = @file_index % 4
@top_position = 0
(@file_index / 4).times { |i|
@top_position -= 160 * 4
}
@scroll = 0
# ウィンドウ移動
move_window(true)
@info_window.refresh(@file_index)
# トランジション実行
Graphics.transition
# メインループ
loop {
Graphics.update
Input.update
update
if $scene != self
break
end
}
# トランジション準備
Graphics.freeze
dispose_sprites
end
#--------------------------------------------------------------------------
# ◠スプライト生æˆ
#--------------------------------------------------------------------------
def create_sprites
# ヘルプウィンドウ作æˆ
@help_window = Window_Help.new
@help_window.set_text(@help_text)
# セーブファイルウィンドウ作æˆ
@savefile_windows = []
@file_number.times { |i|
@savefile_windows << Window_SaveFile.new(i, make_filename(i))
}
# æƒ…å ±ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ä½œæˆ
@info_window = Window_SaveFileInfo.new
# ナビゲートウィンドウ作æˆ
if KGC::TPS_PAGE_NUMBER > 1
@navi_window = []
@navi_sprite = []
2.times { |i|
@navi_window[i] = Window_Base.new(0, 140, 80, 36)
@navi_window[i].back_opacity = 160
@navi_window[i].z = 1000
@navi_sprite[i] = Sprite.new
@navi_sprite[i].bitmap = Bitmap.new(64, 24)
@navi_sprite[i].bitmap.font.size = 19
@navi_sprite[i].y = 144
@navi_sprite[i].z = 1001
}
@navi_sprite[0].bitmap.draw_text(0, 0, 64, 24, "Previous", 1)
@navi_sprite[0].x = 8
@navi_sprite[1].bitmap.draw_text(0, 0, 64, 24, "Next", 1)
@navi_window[1].x = 560
@navi_sprite[1].x = 568
end
# ウィンドウåŠé€æ˜ŽåŒ–
window_alpha if $imported["MenuAlter"] && KGC::MA_MENU_TRANSPARENT
end
#--------------------------------------------------------------------------
# â— ã‚¹ãƒ—ãƒ©ã‚¤ãƒˆç ´æ£„
#--------------------------------------------------------------------------
def dispose_sprites
# ãƒŠãƒ“ã‚²ãƒ¼ãƒˆã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ç ´æ£„
if KGC::TPS_PAGE_NUMBER > 1
2.times { |i|
@navi_window[i].dispose
@navi_sprite[i].bitmap.dispose
@navi_sprite[i].bitmap = nil
@navi_sprite[i].dispose
@navi_window[i] = @navi_sprite[i] = nil
}
end
# ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ç ´æ£„
@help_window.dispose
@help_window = nil
@savefile_windows.each_index { |i|
@savefile_windows[i].dispose
@savefile_windows[i] = nil
}
@info_window.dispose
@info_window = nil
# ã‚¹ãƒ—ãƒ©ã‚¤ãƒˆã‚»ãƒƒãƒˆç ´æ£„
if @spriteset != nil
@spriteset.dispose
@spriteset = nil
end
end
#--------------------------------------------------------------------------
# ◠フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@savefile_windows.each { |w|
w.update
}
# C ボタン
if Input.trigger?(Input::C)
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
# B ボタン
elsif Input.trigger?(Input::B)
on_cancel
return
# →
elsif Input.repeat?(Input::RIGHT)
# →ã®æŠ¼ä¸‹çŠ¶æ…‹ãŒãƒªãƒ”ートã§ãªã„å ´åˆã‹ã€
# ã¾ãŸã¯ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ãŒãƒ•ã‚¡ã‚¤ãƒ«å€‹æ•°ã‚ˆã‚Šå‰ã®å ´åˆ
if Input.trigger?(Input::RIGHT) || @file_index < @file_number - 1
# カーソル SE ã‚’æ¼”å¥
$game_system.se_play($data_system.cursor_se)
# カーソルをå³ã«ç§»å‹•
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % @file_number
@savefile_windows[@file_index].selected = true
@index_x += 1
self.move_window
return
end
# â†
elsif Input.repeat?(Input::LEFT)
# â†ã®æŠ¼ä¸‹çŠ¶æ…‹ãŒãƒªãƒ”ートã§ãªã„å ´åˆã‹ã€
# ã¾ãŸã¯ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ãŒ 0 より後ã‚ã®å ´åˆ
if Input.trigger?(Input::LEFT) || @file_index > 0
# カーソル SE ã‚’æ¼”å¥
$game_system.se_play($data_system.cursor_se)
# カーソルを左ã«ç§»å‹•
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + @file_number - 1) % @file_number
@savefile_windows[@file_index].selected = true
@index_x -= 1
self.move_window
return
end
# ↓ã¾ãŸã¯R
elsif Input.repeat?(Input::DOWN) || Input.repeat?(Input::R)
# ↓,R ã®æŠ¼ä¸‹çŠ¶æ…‹ãŒãƒªãƒ”ートã§ãªã„å ´åˆ
if Input.trigger?(Input::DOWN) || Input.trigger?(Input::R)
# カーソル SE ã‚’æ¼”å¥
$game_system.se_play($data_system.cursor_se)
# カーソルをå³ã«ç§»å‹•
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 4) % @file_number
@savefile_windows[@file_index].selected = true
@scroll = 1
self.move_window
return
end
# ↑ã¾ãŸã¯L
elsif Input.repeat?(Input::UP) || Input.repeat?(Input::L)
# ↑,L ã®æŠ¼ä¸‹çŠ¶æ…‹ãŒãƒªãƒ”ートã§ãªã„å ´åˆ
if Input.trigger?(Input::UP) || Input.trigger?(Input::L)
# カーソル SE ã‚’æ¼”å¥
$game_system.se_play($data_system.cursor_se)
# カーソルを左ã«ç§»å‹•
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + @file_number - 4) % @file_number
@savefile_windows[@file_index].selected = true
@scroll = -1
self.move_window
return
end
end
@info_window.refresh(@file_index)
end
#--------------------------------------------------------------------------
# ◠セーブウィンドウã®ç§»å‹•
# force : 強制移動
#--------------------------------------------------------------------------
def move_window(force = false)
if !force
# 普通ã«ã‚«ãƒ¼ã‚½ãƒ«ç§»å‹•ã—ãŸå ´åˆ
if @scroll == 0 && @index_x >= 0 && @index_x <= 3
return
end
if @index_x == 4 || @scroll == 1 # å³ã«ã‚¹ã‚¯ãƒãƒ¼ãƒ«
if @file_index <= 3 # 左端ã«ç§»å‹•
@top_position = 0
else # ページ移動
@top_position -= 160 * 4
end
@index_x = 0 if @scroll == 0
elsif @index_x == -1 || @scroll == -1 # å·¦ã«ã‚¹ã‚¯ãƒãƒ¼ãƒ«
if @file_index >= @file_number - 4 # å³ç«¯ã«ç§»å‹•
@top_position = (@file_number - 4) * -160
else # 通常移動
@top_position += 160 * 4
end
@index_x = 3 if @scroll == 0
end
@scroll = 0
@file_number.times { |i|
@savefile_windows[i].destination = @top_position + 160 * i
}
else
@file_number.times { |i|
@savefile_windows[i].x = @savefile_windows[i].destination =
@top_position + 160 * i
}
end
end
#--------------------------------------------------------------------------
# ◠ウィンドウåŠé€æ˜ŽåŒ–
#--------------------------------------------------------------------------
def window_alpha
# [Scene_Save]ã§å†å®šç¾©
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# â– Scene_Save
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# ◠ウィンドウåŠé€æ˜ŽåŒ–
#--------------------------------------------------------------------------
def window_alpha
# スプライトセット作æˆ
@spriteset = Spriteset_Map.new
# å„ウィンドウをåŠé€æ˜ŽåŒ–
@help_window.back_opacity = 160
@savefile_windows.each { |w|
w.back_opacity = 160
}
@info_window.back_opacity = 160
end
#--------------------------------------------------------------------------
# ◠セーブデータã®æ›¸ãè¾¼ã¿
# file : 書ãè¾¼ã¿ç”¨ãƒ•ã‚¡ã‚¤ãƒ«ã‚ªãƒ–ジェクト (オープン済ã¿)
#--------------------------------------------------------------------------
def write_save_data(file)
# セーブファイルæ画用ã®ã‚ャラクターデータを作æˆ
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.battler_name, actor.battler_hue])
end
# セーブファイルæ画用ã®ã‚ャラクターデータを書ã込む
Marshal.dump(characters, file)
# プレイ時間計測用ã®ãƒ•ãƒ¬ãƒ¼ãƒ カウントを書ã込む
Marshal.dump(Graphics.frame_count, file)
# セーブ回数を 1 増やã™
$game_system.save_count += 1
# マジックナンãƒãƒ¼ã‚’ä¿å˜ã™ã‚‹
# (エディタã§ä¿å˜ã™ã‚‹ãŸã³ã«ãƒ©ãƒ³ãƒ€ãƒ ãªå€¤ã«æ›¸ãæ›ãˆã‚‰ã‚Œã‚‹)
$game_system.magic_number = $data_system.magic_number
# å„種ゲームオブジェクトを書ã込む
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# â– Scene_Load
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ◠オブジェクトåˆæœŸåŒ–
#--------------------------------------------------------------------------
def initialize
# テンãƒãƒ©ãƒªã‚ªãƒ–ジェクトをå†ä½œæˆ
$game_temp = Game_Temp.new
# タイムスタンプãŒæœ€æ–°ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’é¸æŠž
$game_temp.last_file_index = 0
latest_time = Time.at(0)
(KGC::TPS_PAGE_NUMBER * 4).times { |i|
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
}
super("Load Which Data?")
end
end