地上の洞窟

どこにも行かず、液晶と「にらめっこ」し続ける人の物語。

【RGSS3】VX風選択肢

これが

Before

こうなる

After~なんということでしょう~

RPGツクールVXAce」のメッセージの選択肢を
一つ前の「RPGツクールVX」っぽい感じに戻します。

超昔に一度作ったけどクソみたいなコードだったので 今になって作り直した

更新履歴 内容
2023/08/21 ・空メッセージで選択肢を表示した場合
 ウィンドウが表示されない不具合の修正
・表示の微調整
2023/08/20 初版

→スクリプト一覧へ


スクリプト(ダブルクリックで全選択)↓

=begin =========================================================================
 ■ 「VX風選択肢」- VXChoiceList by 地上の洞窟
================================================================================

 選択肢の表示を「RPGツクール VX」っぽく改変するスクリプト。

================================================================================
 ■ 設定項目
=end #==========================================================================

module VXChoiceList
  
  
  # ADD_SPACE : 選択項目の頭に空白を追加
  # true → 実行する | false → 実行しない
  
  ADD_SPACE = true

  
  # FORCE_NEW_PAGE : 改ページを必ず行う
  # true → 実行する | false → 実行しない
  
  FORCE_NEW_PAGE = false


#==============================================================================
# ■ ここからソースコード
#==============================================================================

end

class Window_Message < Window_Base
  attr_reader :vxcl_t_height
  attr_reader :vxcl_c_height
  attr_reader :vxcl_new_page_flag

  alias vxcl_input_choice input_choice
  def input_choice
    unless $game_message.has_text?
      new_page("", {})
      open_and_wait
    end

    if VXChoiceList::FORCE_NEW_PAGE
      @vxcl_new_page_flag = true
    else
      # 現在のメッセージの高さ, 追加される選択肢の高さを計算
      # 改ページが必要か調べる
      @vxcl_t_height = $game_message.texts.map{|text| calc_line_height(text)}.inject(0, :+)
      @vxcl_c_height = $game_message.choices.map{|text| calc_line_height(text)}.inject(0, :+)
      @vxcl_new_page_flag = (@vxcl_t_height + @vxcl_c_height) > contents.height
    end

    text = convert_escape_characters(
      $game_message.choices.map{|text|
        VXChoiceList::ADD_SPACE ? "  #{text}\n" : "#{text}\n"
      }.join
    )

    pos = {
      :x => new_line_x,
      :y => @vxcl_new_page_flag ? 0 : @vxcl_t_height,
      :new_x => new_line_x,
      :height => calc_line_height(text)
    }

    process_new_page("", {}) if @vxcl_new_page_flag
    process_character(text.slice!(0, 1), text, pos) until text.empty?

    vxcl_input_choice
  end
end

class Window_ChoiceList < Window_Command
  def item_width
    width - ($game_message.face_name.empty? ? 40 : 140)
  end

  alias vxcl_update_placement update_placement
  def update_placement
    vxcl_update_placement
    
    # 配置をメッセージに重ねる
    self.width = @message_window.width
    self.x = @message_window.x + ($game_message.face_name.empty? ? 8 : 112)
    self.y = @message_window.y
    self.opacity = 0
    self.z = 250
    
    # 選択肢の位置をメッセージに合わせる
    self.y += @message_window.vxcl_t_height unless @message_window.vxcl_new_page_flag
  end

  def draw_item(index)
    # do nothing
  end
end