#==============================================================================
#                       「クラシック選択肢」(ACE) ver1.0
#   製作者:奈々(なな)
#   へぷたなすくろーる http://heptanas.mamagoto.com/
#
#   ◇使用規約
#   使用される場合はスクリプト作成者として「奈々」を明記して下さい。
#   このスクリプトを改変したり、改変したものを配布するなどは自由ですが
#   その場合も元のスクリプトの作成者として名前は載せて下さい。
#   その他、詳しい利用規約はブログを参照して下さい。
#
#------------------------------------------------------------------------------
#
#   「選択肢の表示」を別枠ではなくメッセージウィンドウ内に配置します。
#   (特にスクリプトの設定をする必要はありません)
#   
#   「メッセージの表示」の直後に「選択肢の表示」を行うことで
#   顔グラフィックやウィンドウの設定を引き継ぐことができます。
#   (メッセージの文章を空欄にすれば、選択肢だけ表示することも可能です)
#   またウィンドウに収まる場合には、文章の下に選択肢が続けて表示されます。
#
#==============================================================================


#==============================================================================
# ■ Game_Message
#------------------------------------------------------------------------------
#  文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
# クラスのインスタンスは $game_message で参照されます。
#==============================================================================

class Game_Message
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :texts                    # 文章の配列(行単位)
end

#==============================================================================
# ■ Window_ChoiceList
#------------------------------------------------------------------------------
#  イベントコマンド[選択肢の表示]に使用するウィンドウです。
#==============================================================================

class Window_ChoiceList < Window_Command
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias cc_initialize initialize
  def initialize(message_window)
    cc_initialize(message_window)
    self.opacity = 0
    self.z  = @message_window.z + 1
  end
  #--------------------------------------------------------------------------
  # ● 入力処理の開始
  #--------------------------------------------------------------------------
  def start(y_mod)
    update_placement(y_mod)
    refresh
    select(0)
    open
    activate
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ位置の更新
  #--------------------------------------------------------------------------
  def update_placement(y_mod)
    self.width = @message_window.width - @message_window.new_line_x
    self.height = fitting_height($game_message.choices.size)
    self.x = @message_window.x + @message_window.new_line_x
    self.y = @message_window.y + y_mod
  end
end

#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  文章表示に使うメッセージウィンドウです。
#==============================================================================

class Window_Message < Window_Base
  #--------------------------------------------------------------------------
  # ● 選択肢の入力処理
  #--------------------------------------------------------------------------
  def input_choice
    if $game_message.texts == [""]
      @choice_window.start(0)
    elsif $game_message.texts.size + $game_message.choices.size > visible_line_number
      input_pause unless @pause_skip
      new_page("", {})
      @choice_window.start(0)
    else
      @choice_window.start($game_message.texts.size * line_height)
    end
    Fiber.yield while @choice_window.active
  end
end

#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 選択肢の表示
  #--------------------------------------------------------------------------
  def command_102
    wait_for_message
    $game_message.face_name = ""
    $game_message.face_index = 0
    $game_message.background = 0
    $game_message.position = 2
    $game_message.add("")
    setup_choices(@params)
    wait_for_message
  end
end