#============================================================================== # ■ Window_ChoiceList #------------------------------------------------------------------------------ #  イベントコマンド[選択肢の表示]に使用するウィンドウです。 #============================================================================== class Window_ChoiceList < Window_Command #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(message_window) @message_window = message_window super(0, 0) self.openness = 0 deactivate end #-------------------------------------------------------------------------- # ● 入力処理の開始 #-------------------------------------------------------------------------- def start update_placement refresh select(0) open activate end #-------------------------------------------------------------------------- # ● ウィンドウ位置の更新 #-------------------------------------------------------------------------- def update_placement self.width = [max_choice_width + 12, 96].max + padding * 2 self.width = [width, Graphics.width].min self.height = fitting_height($game_message.choices.size) self.x = Graphics.width - width if @message_window.y >= Graphics.height / 2 self.y = @message_window.y - height else self.y = @message_window.y + @message_window.height end end #-------------------------------------------------------------------------- # ● 選択肢の最大幅を取得 #-------------------------------------------------------------------------- def max_choice_width $game_message.choices.collect {|s| text_size(s).width }.max end #-------------------------------------------------------------------------- # ● ウィンドウ内容の高さを計算 #-------------------------------------------------------------------------- def contents_height item_max * item_height end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list $game_message.choices.each do |choice| add_command(choice, :choice) end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect_for_text(index) draw_text_ex(rect.x, rect.y, command_name(index)) end #-------------------------------------------------------------------------- # ● キャンセル処理の有効状態を取得 #-------------------------------------------------------------------------- def cancel_enabled? $game_message.choice_cancel_type > 0 end #-------------------------------------------------------------------------- # ● 決定ハンドラの呼び出し #-------------------------------------------------------------------------- def call_ok_handler $game_message.choice_proc.call(index) close end #-------------------------------------------------------------------------- # ● キャンセルハンドラの呼び出し #-------------------------------------------------------------------------- def call_cancel_handler $game_message.choice_proc.call($game_message.choice_cancel_type - 1) close end end