rebf-gaiden/Scripts/Window_SaveFile.rb
2025-04-26 17:06:34 -05:00

69 lines
2.9 KiB
Ruby

#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
#  セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :selected # 選択状態
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# index : セーブファイルのインデックス
#--------------------------------------------------------------------------
def initialize(height, index)
super(0, index * height, Graphics.width, height)
@file_index = index
refresh
@selected = false
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(normal_color)
name = Vocab::File + " #{@file_index + 1}"
draw_text(4, 0, 200, line_height, name)
@name_width = text_size(name).width
draw_party_characters(152, 58)
draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
end
#--------------------------------------------------------------------------
# ● パーティキャラの描画
#--------------------------------------------------------------------------
def draw_party_characters(x, y)
header = DataManager.load_header(@file_index)
return unless header
header[:characters].each_with_index do |data, i|
draw_character(data[0], data[1], x + i * 48, y)
end
end
#--------------------------------------------------------------------------
# ● プレイ時間の描画
#--------------------------------------------------------------------------
def draw_playtime(x, y, width, align)
header = DataManager.load_header(@file_index)
return unless header
draw_text(x, y, width, line_height, header[:playtime_s], 2)
end
#--------------------------------------------------------------------------
# ● 選択状態の設定
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor
end
#--------------------------------------------------------------------------
# ● カーソルの更新
#--------------------------------------------------------------------------
def update_cursor
if @selected
cursor_rect.set(0, 0, @name_width + 8, line_height)
else
cursor_rect.empty
end
end
end