220 lines
8.5 KiB
Ruby
220 lines
8.5 KiB
Ruby
#==============================================================================
|
|
# ■ Window_ShopSell
|
|
#------------------------------------------------------------------------------
|
|
# ショップ画面で、売却のために所持アイテムの一覧を表示するウィンドウです。
|
|
#==============================================================================
|
|
|
|
class Window_ShopSell < Window_ItemList
|
|
#--------------------------------------------------------------------------
|
|
# ● オブジェクト初期化
|
|
#--------------------------------------------------------------------------
|
|
alias sell_initialize initialize
|
|
def initialize(x, y, width, height)
|
|
sell_initialize(x, y, width, height)
|
|
@page_index = 0
|
|
@category_list = category_set
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ カテゴリのセット
|
|
#--------------------------------------------------------------------------
|
|
def category_set
|
|
[:item, :weapon, :armor, :rune]
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ カテゴリの切り替え
|
|
#--------------------------------------------------------------------------
|
|
def category_change
|
|
@category = category
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ カテゴリの取得
|
|
#--------------------------------------------------------------------------
|
|
def category
|
|
@category_list[@page_index]
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ 最大ページ数の取得
|
|
#--------------------------------------------------------------------------
|
|
def page_max
|
|
@category_list.size
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ ページの変更
|
|
#--------------------------------------------------------------------------
|
|
def page_index(page_index)
|
|
@page_index += page_index
|
|
@page_index = 0 if @page_index > page_max - 1
|
|
@page_index = page_max - 1 if @page_index < 0
|
|
category_change
|
|
refresh
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ Xボタンが押されたときの処理
|
|
#--------------------------------------------------------------------------
|
|
def process_x
|
|
Sound.play_cursor
|
|
Input.update
|
|
deactivate
|
|
call_x_handler
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ Yボタンが押されたときの処理
|
|
#--------------------------------------------------------------------------
|
|
def process_y
|
|
Sound.play_cursor
|
|
Input.update
|
|
deactivate
|
|
call_y_handler
|
|
end
|
|
end
|
|
|
|
#==============================================================================
|
|
# ■ Window_ItemCategory
|
|
#------------------------------------------------------------------------------
|
|
# アイテム画面またはショップ画面で、通常アイテムや装備品の分類を選択するウィ
|
|
# ンドウです。
|
|
#==============================================================================
|
|
|
|
class Window_SellCategory < Window_Base
|
|
#--------------------------------------------------------------------------
|
|
# ○ 公開インスタンス変数
|
|
#--------------------------------------------------------------------------
|
|
attr_reader :item_window
|
|
#--------------------------------------------------------------------------
|
|
# ○ オブジェクト初期化
|
|
#--------------------------------------------------------------------------
|
|
def initialize(x, y)
|
|
super(x, y, window_width, window_height)
|
|
@category = :none
|
|
refresh
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ ウィンドウ高さの取得
|
|
#--------------------------------------------------------------------------
|
|
def window_height
|
|
fitting_height(1)
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ ウィンドウ幅の取得
|
|
#--------------------------------------------------------------------------
|
|
def window_width
|
|
Graphics.width
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ カテゴリの設定
|
|
#--------------------------------------------------------------------------
|
|
def category=(category)
|
|
return if @category == category
|
|
@category = category
|
|
refresh
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ カテゴリの名前を取得
|
|
#--------------------------------------------------------------------------
|
|
def category_name
|
|
case @category
|
|
when :item ; Vocab::item
|
|
when :weapon ; Vocab::weapon
|
|
when :armor ; Vocab::armor
|
|
when :rune ; Vocab::rune
|
|
else ; ""
|
|
end
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ フレーム更新
|
|
#--------------------------------------------------------------------------
|
|
def update
|
|
super
|
|
self.category = @item_window.category if @item_window
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ アイテムウィンドウの設定
|
|
#--------------------------------------------------------------------------
|
|
def item_window=(item_window)
|
|
@item_window = item_window
|
|
update
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ○ リフレッシュ
|
|
#--------------------------------------------------------------------------
|
|
def refresh
|
|
contents.clear
|
|
change_color(system_color)
|
|
draw_text(4, 0, 24 * 5, line_height, "#{category_name}", 1)
|
|
change_color(normal_color)
|
|
draw_text(124, 0, window_width - 124, line_height, "#{key_button("A")}、#{key_button("S")}で売却アイテムの種類を切り替え")
|
|
end
|
|
end
|
|
|
|
#==============================================================================
|
|
# ■ Scene_Shop
|
|
#------------------------------------------------------------------------------
|
|
# ショップ画面の処理を行うクラスです。
|
|
#==============================================================================
|
|
|
|
class Scene_Shop < Scene_MenuBase
|
|
#--------------------------------------------------------------------------
|
|
# ● カテゴリウィンドウの作成
|
|
#--------------------------------------------------------------------------
|
|
def create_category_window
|
|
wy = @dummy_window.y
|
|
@category_window = Window_SellCategory.new(0, wy)
|
|
@category_window.viewport = @viewport
|
|
@category_window.hide
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ● 売却ウィンドウのアクティブ化
|
|
#--------------------------------------------------------------------------
|
|
def activate_sell_window
|
|
@category_window.show
|
|
@dummy_window.hide
|
|
@sell_window.category_change
|
|
@sell_window.refresh
|
|
@sell_window.show.activate
|
|
@category_window.refresh
|
|
@status_window.hide
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ● コマンド[売却する]
|
|
#--------------------------------------------------------------------------
|
|
def command_sell
|
|
activate_sell_window
|
|
@sell_window.select(0)
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ● 売却[キャンセル]
|
|
#--------------------------------------------------------------------------
|
|
def on_sell_cancel
|
|
@command_window.activate
|
|
@dummy_window.show
|
|
@sell_window.hide.unselect
|
|
@status_window.item = nil
|
|
@category_window.hide
|
|
@help_window.clear
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ● 売却ウィンドウの作成
|
|
#--------------------------------------------------------------------------
|
|
alias sell_ex_create_sell_window create_sell_window
|
|
def create_sell_window
|
|
sell_ex_create_sell_window
|
|
@sell_window.set_handler(:x_change, method(:prev_category))
|
|
@sell_window.set_handler(:y_change, method(:next_category))
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ●
|
|
#--------------------------------------------------------------------------
|
|
def prev_category
|
|
@sell_window.page_index(-1)
|
|
@sell_window.select(0)
|
|
@sell_window.activate
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# ●
|
|
#--------------------------------------------------------------------------
|
|
def next_category
|
|
@sell_window.page_index(1)
|
|
@sell_window.select(0)
|
|
@sell_window.activate
|
|
end
|
|
end
|