sacred-ritual-academy/Scripts/Window_EquipSlot.rb
2025-03-18 19:45:34 -05:00

110 lines
4.8 KiB
Ruby

#==============================================================================
# ■ Window_EquipSlot
#------------------------------------------------------------------------------
#  装備画面で、アクターが現在装備しているアイテムを表示するウィンドウです。
#==============================================================================
class Window_EquipSlot < Window_Selectable
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :status_window # ステータスウィンドウ
attr_reader :item_window # アイテムウィンドウ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width)
super(x, y, width, window_height)
@actor = nil
refresh
end
#--------------------------------------------------------------------------
# ● ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
fitting_height(visible_line_number)
end
#--------------------------------------------------------------------------
# ● 表示行数の取得
#--------------------------------------------------------------------------
def visible_line_number
return 5
end
#--------------------------------------------------------------------------
# ● アクターの設定
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
@item_window.slot_id = index if @item_window
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@actor ? @actor.equip_slots.size : 0
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
@actor ? @actor.equips[index] : nil
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
return unless @actor
rect = item_rect_for_text(index)
change_color(system_color, enable?(index))
draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
draw_item_name(@actor.equips[index], rect.x + 92, rect.y, enable?(index))
end
#--------------------------------------------------------------------------
# ● 装備スロットの名前を取得
#--------------------------------------------------------------------------
def slot_name(index)
@actor ? Vocab::etype(@actor.equip_slots[index]) : ""
end
#--------------------------------------------------------------------------
# ● 装備スロットを許可状態で表示するかどうか
#--------------------------------------------------------------------------
def enable?(index)
@actor ? @actor.equip_change_ok?(index) : false
end
#--------------------------------------------------------------------------
# ● 選択項目の有効状態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(index)
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの設定
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
call_update_help
end
#--------------------------------------------------------------------------
# ● アイテムウィンドウの設定
#--------------------------------------------------------------------------
def item_window=(item_window)
@item_window = item_window
update
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
super
@help_window.set_item(item) if @help_window
@status_window.set_temp_actor(nil) if @status_window
end
end