查看: 3865|回复: 4

[已经解决] 萌新问下有没有可能用开关来操纵选项

[复制链接]
梦石
0
星屑
1411
在线时间
215 小时
注册时间
2019-9-17
回帖
17
发表于 2019-10-4 22:04:27 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
例如:开启X开关时选项在A和B中增加选项C。由于文本量过于巨大,我不打算用分支事件一个一个做,请问有没有脚本可以完成这项作业?
梦石
0
星屑
2032
在线时间
200 小时
注册时间
2018-12-27
回帖
334
发表于 2019-10-4 22:56:50 | 显示全部楼层
脚本插入过多的结果就是容易崩溃和冲突,最好使用变量。就这样。
回复

使用道具 举报

梦石
0
星屑
17038
在线时间
6058 小时
注册时间
2011-7-18
回帖
152

开拓者

发表于 2019-10-4 23:33:19 | 显示全部楼层
本帖最后由 gqxastg 于 2019-10-5 14:27 编辑

推荐 木星ペンギン 的 選択肢拡張
脚本[pre lang="ruby"]=begin

▼ 選択肢拡張 ver. 3.5

RPGツクールVXAce用スクリプト

制作 : 木星ペンギン
URL  : http://woodpenguin.blog.fc2.com/

------------------------------------------------------------------------------
概要

□ 選択肢を連続して設定した場合、つなげて一つの選択肢にする機能の追加。
□ 条件を設定することで、その項目を表示しない機能の追加。
□ 選択肢のカーソル初期位置を指定する機能と
    現在のカーソル位置を変数に入れる機能の追加。

□ 選択肢ウィンドウの位置を一時的に変更する機能の追加。
□ 条件を設定することで、その項目を半透明にして選択不可にする機能の追加。
□ 選択肢毎にヘルプメッセージを表示できる機能の追加。

------------------------------------------------------------------------------
使い方

□ 選択肢の表示を続けて配置すると、一つの選択肢にまとめられます。
  ・「キャンセルの場合」の処理は、無効以外を設定したものが適用され、
     複数ある場合は後の選択肢のものが適用されます。
  
□ 選択肢の文章中に if(条件) と入れ、その条件が偽になると項目が表示されなくなります。
  ・条件は eval によって評価されます。(詳細は【組み込み関数】を参照)
  ・s でスイッチ、v で変数を参照できます。
  ・「キャンセルの場合」の項目が表示されない場合、無効と同じ処理をします。

□ 注釈に以下の文字列を入れることで、指定された変数の値が
    カーソルの初期位置になります。
  
    カーソル記憶(n)
   
      n : カーソル初期位置の入った変数番号
  
  ・選択肢のカーソルの位置が変更されるたびに、
    この変数に選択肢の番号が入れられるようになります。
  
□ 注釈に以下の文字列を入れることで、選択肢ウィンドウの表示位置を
   一時的に変更することが出来ます。
  
    選択肢位置(x, y[, row])
   
      x   : ウィンドウを表示する X 座標。
      y   : ウィンドウを表示する Y 座標。
      row : 選択肢を表示する最大行数。
            指定しない場合は、通常の最大行数を無視して
            すべての選択肢が表示されます。
  
□ 注釈に以下の文字列を入れることで、メッセージの下に選択肢を
   表示させます。
    [文章の表示]をこの後に実行してください。
  
    選択肢位置(メッセージ下)
   
□ 注釈に以下の文字列を入れることで、選択肢ウィンドウの背景が非表示になります。
  
    背景OFF
   
□ 選択肢の文章中に en(条件) と入れ、その条件が偽になると項目が半透明で表示されます。
  ・条件は eval によって評価されます。(詳細は【組み込み関数】を参照)
  ・s でスイッチ、v で変数を参照できます。
  ・「キャンセルの場合」の項目が半透明の場合、ブザーが鳴ります。
  
□ 各項目の下に、注釈で以下の文字列を入れると、続きの注釈を
    項目のヘルプメッセージとしてカーソルを合わせたときに標示することができます。
  
    選択肢ヘルプ
   
□ 詳細は下記のサイトを参照してください。

  http://woodpenguin.web.fc2.com/rgss3/choice_ex.html
  
=end
module WdTk
module ChoiceEX
#//////////////////////////////////////////////////////////////////////////////
#
# 設定項目
#
#//////////////////////////////////////////////////////////////////////////////
  #--------------------------------------------------------------------------
  # ● 選択肢の最大行数
  #     選択肢を表示するウィンドウの行数の最大数です。
  #     選択肢がこの数より小さければ、選択肢の数に合わせます。
  #--------------------------------------------------------------------------
  RowMax = 4
  
  #--------------------------------------------------------------------------
  # ● 選択肢ヘルプを読み取る文字列
  #--------------------------------------------------------------------------
  Help = "選択肢ヘルプ"
  
end

#//////////////////////////////////////////////////////////////////////////////
#
# 以降、変更する必要なし
#
#//////////////////////////////////////////////////////////////////////////////

  @material ||= []
  @material << :ChoiceEX
  def self.include?(sym)
    @material.include?(sym)
  end
  
end

#==============================================================================
# ■ Game_Message
#==============================================================================
class Game_Message
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  attr_accessor :choice_help              # 選択肢のヘルプ
  attr_accessor :choice_var_id            # 選択肢のカーソル位置を入れる変数ID
  attr_accessor :choice_background        # 選択肢ウィンドウ背景の表示状態
  attr_accessor :under_choice             # 選択肢をメッセージの下に表示
  #--------------------------------------------------------------------------
  # ○ クリア
  #--------------------------------------------------------------------------
  alias _wdtk_choice_clear clear
  def clear
    _wdtk_choice_clear
    @choice_x = @choice_y = nil
    @choice_row_max = WdTk::ChoiceEX::RowMax
    @choice_help = {}
    @choice_var_id = 0
    @choice_background = 0
    @under_choice = false
  end
end

#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ☆ 選択肢のセットアップ
  #--------------------------------------------------------------------------
  def setup_choices(params)
    add_choices(params, @index)
    $game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
  end
  #--------------------------------------------------------------------------
  # ● 選択肢の追加
  #--------------------------------------------------------------------------
  def add_choices(params, i, d = 0)
    params[0].each_with_index {|s, n| $game_message.choices[n + d] = s }
    $game_message.choice_cancel_type = params[1] + d if params[1] > 0
    indent = @list.indent
    loop do
      i += 1
      if @list.indent == indent
        case @list.code
        when 402 # [**] の場合
          get_help_texts(@list.parameters[0] + d, i + 1)
        when 404 # 分岐終了
          break
        end
      end
    end
    i += 1
    add_choices(@list.parameters, i, d + 5) if @list.code == 102
  end
  #--------------------------------------------------------------------------
  # ● ヘルプ用テキストの取得
  #--------------------------------------------------------------------------
  def get_help_texts(b, i)
    if @list.code == 108 && @list.parameters[0] == WdTk::ChoiceEX::Help
      $game_message.choice_help = []
      while @list[i + 1].code == 408
        i += 1
        $game_message.choice_help << @list.parameters[0]
      end
    end
  end
  #--------------------------------------------------------------------------
  # ◯ 注釈
  #--------------------------------------------------------------------------
  alias _wdtk_choice_command_108 command_108
  def command_108
    _wdtk_choice_command_108
    @comments.each do |comment|
      case comment
      when /選択肢位置\((\d+),\s*(\d+),?\s*(\d*)\)/
        $game_message.choice_x = $1.to_i
        $game_message.choice_y = $2.to_i
        $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
      when "選択肢位置(メッセージ下)"
        $game_message.under_choice = true
        $game_message.choice_background = 1
      when /カーソル記憶\((\d+)\)/
        $game_message.choice_var_id = $1.to_i
      when /背景(ON|OFF)/
        $game_message.choice_background = ($1 == "ON" ? 0 : 1)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 分岐終了の場合
  #--------------------------------------------------------------------------
  def command_404
    if next_event_code == 102
      @branch[@indent] -= 5 if @branch.include?(@indent)
      @index += 1
      command_skip
    end
  end
end

#==============================================================================
# ■ Window_ChoiceList
#==============================================================================
class Window_ChoiceList
  #--------------------------------------------------------------------------
  # ☆ 入力処理の開始
  #--------------------------------------------------------------------------
  def start
    return unless close?
    clear_command_list
    make_command_list
    if @list.empty?
      $game_message.choice_proc.call(-1)
      return
    end
    update_placement
    refresh
    select(0)
    if $game_message.choice_var_id > 0
      select_ext($game_variables[$game_message.choice_var_id])
    end
    open
    activate
  end
  #--------------------------------------------------------------------------
  # ☆ ウィンドウ位置の更新
  #--------------------------------------------------------------------------
  def update_placement
    self.width = [max_choice_width + 12, 96].max + padding * 2
    self.width = [width, Graphics.width].min
    n = [@list.size, $game_message.choice_row_max].min
    self.height = fitting_height(n)
    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
    self.x = $game_message.choice_x if $game_message.choice_x
    self.y = $game_message.choice_y if $game_message.choice_y
    self.z = $game_message.under_choice ? 210 : 100
  end
  #--------------------------------------------------------------------------
  # ☆ 選択肢の最大幅を取得
  #--------------------------------------------------------------------------
  def max_choice_width
    @list.collect {|com| text_ex_width(com[:name]) }.max || 0
  end
  #--------------------------------------------------------------------------
  # ● 制御文字つきテキストの幅を取得
  #--------------------------------------------------------------------------
  def text_ex_width(text)
    text2 = convert_escape_characters(text)
    icon_width = text2.scan(/\eI\[\d+\]/i).size * 24
    text2.gsub!(/\e(?:[\$\.\|\^!><\{\}\\]|[A-Z]+)(?:\[\d+\])?/i, "")
    text2.delete!("\e")
    text_size(text2).width + icon_width
  end
  #--------------------------------------------------------------------------
  # ☆ コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    $game_message.choices.each_with_index do |choice, i|
      next unless choice
      str = choice.dup
      next if str.slice!(/\s*if\(([^\)]+)\)/i) && !choice_eval($1)
      enable = !str.slice!(/\s*en\(([^\)]+)\)/i) || choice_eval($1)
      add_command(str, :choice, enable, i)
    end
  end
  #--------------------------------------------------------------------------
  # ○ 項目の描画
  #--------------------------------------------------------------------------
  alias _wdtk_choice_draw_item draw_item
  def draw_item(index)
    @choice_enabled = command_enabled?(index)
    _wdtk_choice_draw_item(index)
  end
  #--------------------------------------------------------------------------
  # ● テキスト描画色の変更
  #--------------------------------------------------------------------------
  def change_color(color, enabled = true)
    super(color, enabled && @choice_enabled)
  end
  #--------------------------------------------------------------------------
  # ☆ 決定ハンドラの呼び出し
  #--------------------------------------------------------------------------
  def call_ok_handler
    $game_message.choice_proc.call(current_ext)
    close
  end
  #--------------------------------------------------------------------------
  # ● キャンセルボタンが押されたときの処理
  #--------------------------------------------------------------------------
  def process_cancel
    return super if $game_message.choice_cancel_type % 5 == 0
    index = @list.index {|c| c[:ext] == $game_message.choice_cancel_type - 1 }
    return unless index
    return super if command_enabled?(index)
    Sound.play_buzzer
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウを閉じる
  #--------------------------------------------------------------------------
  def close
    @message_window.on_show_fast unless $game_message.choice_help.empty?
    super
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウ更新メソッドの呼び出し
  #--------------------------------------------------------------------------
  def call_update_help
    update_help if active && !$game_message.choice_help.empty?
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの更新
  #--------------------------------------------------------------------------
  def update_help
    @message_window.force_clear
    if $game_message.choice_help.include?(current_ext)
      $game_message.texts.replace($game_message.choice_help[current_ext])
    else
      $game_message.texts.clear
    end
  end
  #--------------------------------------------------------------------------
  # ● 分岐用
  #--------------------------------------------------------------------------
  def choice_eval(formula)
    s, v = $game_switches, $game_variables
    begin
      Kernel.eval(formula)
    rescue
      msgbox "以下の条件判定でエラーが出ました。\n\n", formula
      true
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    last_index = @index
    super
    if last_index != @index && $game_message.choice_var_id > 0
      $game_variables[$game_message.choice_var_id] = current_ext
    end
  end
end

#==============================================================================
# ■ Window_Message
#==============================================================================
class Window_Message
  #--------------------------------------------------------------------------
  # ○ ウィンドウ背景の更新
  #--------------------------------------------------------------------------
  alias _wdtk_choice_update_background update_background
  def update_background
    _wdtk_choice_update_background
    @choice_window.opacity = $game_message.choice_background == 0 ? 255 : 0
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ位置の更新
  #--------------------------------------------------------------------------
  alias _wdtk_choice_update_placement update_placement
  def update_placement
    _wdtk_choice_update_placement
    reset_under_choice
  end
  #--------------------------------------------------------------------------
  # ○ 改行文字の処理
  #--------------------------------------------------------------------------
  alias _wdtk_choice_process_new_line process_new_line
  def process_new_line(text, pos)
    if $game_message.under_choice
      $game_message.choice_y += pos[:height]
      ch = self.contents_height + self.y - $game_message.choice_y
      $game_message.choice_row_max = ch / line_height
    end
    _wdtk_choice_process_new_line(text, pos)
  end
  #--------------------------------------------------------------------------
  # ○ 改ページ処理
  #--------------------------------------------------------------------------
  alias _wdtk_choice_new_page new_page
  def new_page(text, pos)
    _wdtk_choice_new_page(text, pos)
    reset_under_choice
  end
  #--------------------------------------------------------------------------
  # ● 選択肢をメッセージ下に表示する際のリセット
  #--------------------------------------------------------------------------
  def reset_under_choice
    if $game_message.under_choice
      $game_message.choice_x = self.x + 16 + new_line_x
      $game_message.choice_y = self.y
      $game_message.choice_row_max = visible_line_number
    end
  end
  #--------------------------------------------------------------------------
  # ● 文章の標示を強制クリア
  #--------------------------------------------------------------------------
  def force_clear
    @gold_window.close
    @fiber = nil
    close
    if WdTk.include?(:MesEff)
      @character_sprites.each do |sprite, params|
        next if params.empty?
        sprite.bitmap.clear
        sprite.visible = false
        params.clear
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 文章を最後まで表示する
  #--------------------------------------------------------------------------
  def on_show_fast
    @show_fast = true
  end
end
[/pre]

插入后直接在显示选项里这么写
显示的文字 if(s[1])

就是只有1号开关打开时才显示该选项
把if换成en的话就是1号开关打开时候才能选择该选项,否则会半透明显示且无法选择

楼下给出汉化版带使用例了
我刚从作者官网把最新版3.5扒过来了 新修正了转义符导致的选项宽度获取错误

评分

参与人数 1星屑 +100 收起 理由
VIPArcher + 100 认可答案

查看全部评分

这里岚风·雷,任饭、PM理性粉、UT/DR原作粉、(Trans)Furry自萌,半吊子技术一枚_(:з」∠)_    游戏制作交流工(liao)作(tian)室欢迎来玩!
【无偿/有偿】RGSS3(VA)脚本定制 + 合作招募/同好交友    修正Firefox/火狐浏览器的代码框复制问题(油猴脚本)
Click→←Click
回复

使用道具 举报

梦石
1
星屑
14374
在线时间
2109 小时
注册时间
2017-9-28
回帖
607
发表于 2019-10-5 13:11:14 | 显示全部楼层
  1. =begin

  2. ▼ 选项拓展 ver. 3.4

  3. 仅用于 RPG Maker VXAce

  4. 制作 : 木星ペンギン
  5. URL  : http://woodpenguin.blog.fc2.com/

  6. ------------------------------------------------------------------------------
  7. 概要

  8.     添加功能:
  9. □ 合并两个连续选项为一个大选项。
  10. □ 选项显示条件功能,不符合显示条件的选项会被隐藏。
  11. □ 设定选项和指针的初始位置
  12.     当前指针的位置可以赋值于变量。

  13. □ 临时更改选项窗口的位置。
  14. □ 设定选项条件,不符合条件时,选项变成半透明且不可被选择。
  15. □ 各个选项都可以有相应的帮助信息。

  16. ------------------------------------------------------------------------------
  17. 使用方法

  18. □ 当两个选项连续排列时,它们会被合并为一个选项。
  19.   ? 合并后选项的「取消的时候」为最后一个选项的设定。
  20.   
  21. □ 如果在选项中填入 if(条件) 、且不满足条件时,该选项会被隐藏。
  22.   ?条件用 eval 进行判断。(详细参考【内建功能】)
  23.   ?s 代表开关、v 代表变量。
  24.   
  25.   例子:
  26.   if(s[1]&&s[2])
  27.   
  28.   if(v[1]==1)
  29.   
  30.   ?如果「取消的时候」的选项因为不符合显示条件而被隐藏,则用“无效”作为代替。
  31.   
  32. □ 在注释中填入以下字符串,指定某变量的值为指针的初始位置。
  33.   
  34.     记忆指针(n)
  35.    
  36.       n : 指针初始位置的变量
  37.   
  38.   ?每当选项的指针位置改变时,选项位置的数字会被存储于变量中。
  39.   
  40. □ 在注释中填入以下字符串,暂时改变选项的显示位置。
  41.   
  42.     选项位置(x, y[, row])
  43.    
  44.       x   : 选项窗口的x坐标。
  45.       y   : 选项窗口的y坐标。
  46.       row : 选项最大行数。
  47.             未设定时,会显示全部的选项。
  48.   
  49. □ 在注释中填入以下字符串,使选项显示在对话框的背后。
  50.     请在[显示文字]后面使用。
  51.   
  52.     选项位置(对话框后)
  53.    
  54. □ 在注释中填入以下字符串,则隐藏选项窗口的背景。
  55.   
  56.     背景OFF
  57.    
  58. □ 在选项中填入 en(条件) 、当不符合条件时,选项会变半透明。
  59.   ?条件用 eval 进行判断。(详细参考【内建功能】)
  60.   ?s[n] 代表条件是开启n号开关、v[n] 代表n号变量。
  61.   
  62.   例子:
  63.   en(s[1]&&s[2])
  64.   
  65.   en(v[1]==1)
  66.   
  67.   ?如果「取消的时候」的选项因为不符合显示条件而变半透明,则会播放蜂鸣声。
  68.   
  69. □ 各选项之下的注释中填入以下字符串,当移动到各选项中时,会显示选项的帮助文字。
  70.   
  71.     选项帮助
  72.      (内容)
  73.      
  74.      例如:
  75.      
  76.      选项帮助
  77.      可以住宿。
  78.    
  79. □ 请在以下网址中查看详细介绍。

  80.   http://woodpenguin.web.fc2.com/rgss3/choice_ex.html
  81.   
  82. =end
  83. module WdTk
  84. module ChoiceEX
  85. #//////////////////////////////////////////////////////////////////////////////
  86. #
  87. # 设定部分
  88. #
  89. #//////////////////////////////////////////////////////////////////////////////
  90.   #--------------------------------------------------------------------------
  91.   # ● 选项最大行数
  92.   #     如果选项数小于这个数字。
  93.   #     则选项最大数与选项数相同。
  94.   #--------------------------------------------------------------------------
  95.   RowMax = 4
  96.   
  97.   #--------------------------------------------------------------------------
  98.   # ● 读取选项帮助的开头文字
  99.   #--------------------------------------------------------------------------
  100.   Help = "选项帮助"
  101.   
  102. end

  103. #//////////////////////////////////////////////////////////////////////////////
  104. #
  105. # 以下部分、没有修改的必要
  106. #
  107. #//////////////////////////////////////////////////////////////////////////////

  108.   @material ||= []
  109.   @material << :ChoiceEX
  110.   def self.include?(sym)
  111.     @material.include?(sym)
  112.   end
  113.   
  114. end

  115. #==============================================================================
  116. # ■ Game_Message
  117. #==============================================================================
  118. class Game_Message
  119.   #--------------------------------------------------------------------------
  120.   # ● 公開インスタンス変数
  121.   #--------------------------------------------------------------------------
  122.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  123.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  124.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  125.   attr_accessor :choice_help              # 選択肢のヘルプ
  126.   attr_accessor :choice_var_id            # 選択肢のカーソル位置を入れる変数ID
  127.   attr_accessor :choice_background        # 選択肢ウィンドウ背景の表示状態
  128.   attr_accessor :under_choice             # 選択肢をメッセージの下に表示
  129.   #--------------------------------------------------------------------------
  130.   # ○ クリア
  131.   #--------------------------------------------------------------------------
  132.   alias _wdtk_choice_clear clear
  133.   def clear
  134.     _wdtk_choice_clear
  135.     @choice_x = @choice_y = nil
  136.     @choice_row_max = WdTk::ChoiceEX::RowMax
  137.     @choice_help = {}
  138.     @choice_var_id = 0
  139.     @choice_background = 0
  140.     @under_choice = false
  141.   end
  142. end

  143. #==============================================================================
  144. # ■ Game_Interpreter
  145. #==============================================================================
  146. class Game_Interpreter
  147.   #--------------------------------------------------------------------------
  148.   # ☆ 選択肢のセットアップ
  149.   #--------------------------------------------------------------------------
  150.   def setup_choices(params)
  151.     add_choices(params, @index)
  152.     $game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 選択肢の追加
  156.   #--------------------------------------------------------------------------
  157.   def add_choices(params, i, d = 0)
  158.     params[0].each_with_index {|s, n| $game_message.choices[n + d] = s }
  159.     $game_message.choice_cancel_type = params[1] + d if params[1] > 0
  160.     indent = @list[i].indent
  161.     loop do
  162.       i += 1
  163.       if @list[i].indent == indent
  164.         case @list[i].code
  165.         when 402 # [**] の場合
  166.           get_help_texts(@list[i].parameters[0] + d, i + 1)
  167.         when 404 # 分岐終了
  168.           break
  169.         end
  170.       end
  171.     end
  172.     i += 1
  173.     add_choices(@list[i].parameters, i, d + 5) if @list[i].code == 102
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● ヘルプ用テキストの取得
  177.   #--------------------------------------------------------------------------
  178.   def get_help_texts(b, i)
  179.     if @list[i].code == 108 && @list[i].parameters[0] == WdTk::ChoiceEX::Help
  180.       $game_message.choice_help[b] = []
  181.       while @list[i + 1].code == 408
  182.         i += 1
  183.         $game_message.choice_help[b] << @list[i].parameters[0]
  184.       end
  185.     end
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ? 注釈
  189.   #--------------------------------------------------------------------------
  190.   alias _wdtk_choice_command_108 command_108
  191.   def command_108
  192.     _wdtk_choice_command_108
  193.     @comments.each do |comment|
  194.       case comment
  195.       when /选项位置\((\d+),\s*(\d+),?\s*(\d*)\)/
  196.         $game_message.choice_x = $1.to_i
  197.         $game_message.choice_y = $2.to_i
  198.         $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
  199.       when "选项位置(对话框后)"
  200.         $game_message.under_choice = true
  201.         $game_message.choice_background = 1
  202.       when /记忆指针\((\d+)\)/
  203.         $game_message.choice_var_id = $1.to_i
  204.       when /背景(ON|OFF)/
  205.         $game_message.choice_background = ($1 == "ON" ? 0 : 1)
  206.       end
  207.     end
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ☆ 分岐終了の場合
  211.   #--------------------------------------------------------------------------
  212.   def command_404
  213.     if next_event_code == 102
  214.       @branch[@indent] -= 5 if @branch.include?(@indent)
  215.       @index += 1
  216.       command_skip
  217.     end
  218.   end
  219. end

  220. #==============================================================================
  221. # ■ Window_ChoiceList
  222. #==============================================================================
  223. class Window_ChoiceList
  224.   #--------------------------------------------------------------------------
  225.   # ☆ 入力処理の開始
  226.   #--------------------------------------------------------------------------
  227.   def start
  228.     return unless close?
  229.     clear_command_list
  230.     make_command_list
  231.     if @list.empty?
  232.       $game_message.choice_proc.call(-1)
  233.       return
  234.     end
  235.     update_placement
  236.     refresh
  237.     select(0)
  238.     if $game_message.choice_var_id > 0
  239.       select_ext($game_variables[$game_message.choice_var_id])
  240.     end
  241.     open
  242.     activate
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ☆ ウィンドウ位置の更新
  246.   #--------------------------------------------------------------------------
  247.   def update_placement
  248.     self.width = [max_choice_width + 12, 96].max + padding * 2
  249.     self.width = [width, Graphics.width].min
  250.     n = [@list.size, $game_message.choice_row_max].min
  251.     self.height = fitting_height(n)
  252.     self.x = Graphics.width - width
  253.     if @message_window.y >= Graphics.height / 2
  254.       self.y = @message_window.y - height
  255.     else
  256.       self.y = @message_window.y + @message_window.height
  257.     end
  258.     self.x = $game_message.choice_x if $game_message.choice_x
  259.     self.y = $game_message.choice_y if $game_message.choice_y
  260.     self.z = $game_message.under_choice ? 210 : 100
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ☆ 選択肢の最大幅を取得
  264.   #--------------------------------------------------------------------------
  265.   def max_choice_width
  266.     @list.collect {|com| text_size(com[:name]).width }.max || 0
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ☆ コマンドリストの作成
  270.   #--------------------------------------------------------------------------
  271.   def make_command_list
  272.     $game_message.choices.each_with_index do |choice, i|
  273.       next unless choice
  274.       str = choice.dup
  275.       next if str.slice!(/\s*if\(([^\)]+)\)/i) && !choice_eval($1)
  276.       enable = !str.slice!(/\s*en\(([^\)]+)\)/i) || choice_eval($1)
  277.       add_command(str, :choice, enable, i)
  278.     end
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ○ 項目の描画
  282.   #--------------------------------------------------------------------------
  283.   alias _wdtk_choice_draw_item draw_item
  284.   def draw_item(index)
  285.     @choice_enabled = command_enabled?(index)
  286.     _wdtk_choice_draw_item(index)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● テキスト描画色の変更
  290.   #--------------------------------------------------------------------------
  291.   def change_color(color, enabled = true)
  292.     super(color, enabled && @choice_enabled)
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ☆ 決定ハンドラの呼び出し
  296.   #--------------------------------------------------------------------------
  297.   def call_ok_handler
  298.     $game_message.choice_proc.call(current_ext)
  299.     close
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● キャンセルボタンが押されたときの処理
  303.   #--------------------------------------------------------------------------
  304.   def process_cancel
  305.     return super if $game_message.choice_cancel_type % 5 == 0
  306.     index = @list.index {|c| c[:ext] == $game_message.choice_cancel_type - 1 }
  307.     return unless index
  308.     return super if command_enabled?(index)
  309.     Sound.play_buzzer
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ● ウィンドウを閉じる
  313.   #--------------------------------------------------------------------------
  314.   def close
  315.     @message_window.on_show_fast unless $game_message.choice_help.empty?
  316.     super
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  320.   #--------------------------------------------------------------------------
  321.   def call_update_help
  322.     update_help if active && !$game_message.choice_help.empty?
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● ヘルプウィンドウの更新
  326.   #--------------------------------------------------------------------------
  327.   def update_help
  328.     @message_window.force_clear
  329.     if $game_message.choice_help.include?(current_ext)
  330.       $game_message.texts.replace($game_message.choice_help[current_ext])
  331.     else
  332.       $game_message.texts.clear
  333.     end
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 分岐用
  337.   #--------------------------------------------------------------------------
  338.   def choice_eval(formula)
  339.     s, v = $game_switches, $game_variables
  340.     begin
  341.       Kernel.eval(formula)
  342.     rescue
  343.       msgbox "以下条件判断发生错误。\n\n", formula
  344.       true
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● フレーム更新
  349.   #--------------------------------------------------------------------------
  350.   def update
  351.     last_index = @index
  352.     super
  353.     if last_index != @index && $game_message.choice_var_id > 0
  354.       $game_variables[$game_message.choice_var_id] = current_ext
  355.     end
  356.   end
  357. end

  358. #==============================================================================
  359. # ■ Window_Message
  360. #==============================================================================
  361. class Window_Message
  362.   #--------------------------------------------------------------------------
  363.   # ○ ウィンドウ背景の更新
  364.   #--------------------------------------------------------------------------
  365.   alias _wdtk_choice_update_background update_background
  366.   def update_background
  367.     _wdtk_choice_update_background
  368.     @choice_window.opacity = $game_message.choice_background == 0 ? 255 : 0
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ○ ウィンドウ位置の更新
  372.   #--------------------------------------------------------------------------
  373.   alias _wdtk_choice_update_placement update_placement
  374.   def update_placement
  375.     _wdtk_choice_update_placement
  376.     reset_under_choice
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ○ 改行文字の処理
  380.   #--------------------------------------------------------------------------
  381.   alias _wdtk_choice_process_new_line process_new_line
  382.   def process_new_line(text, pos)
  383.     if $game_message.under_choice
  384.       $game_message.choice_y += pos[:height]
  385.       ch = self.contents_height + self.y - $game_message.choice_y
  386.       $game_message.choice_row_max = ch / line_height
  387.     end
  388.     _wdtk_choice_process_new_line(text, pos)
  389.   end
  390.   #--------------------------------------------------------------------------
  391.   # ○ 改ページ処理
  392.   #--------------------------------------------------------------------------
  393.   alias _wdtk_choice_new_page new_page
  394.   def new_page(text, pos)
  395.     _wdtk_choice_new_page(text, pos)
  396.     reset_under_choice
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 選択肢をメッセージ下に表示する際のリセット
  400.   #--------------------------------------------------------------------------
  401.   def reset_under_choice
  402.     if $game_message.under_choice
  403.       $game_message.choice_x = self.x + 16 + new_line_x
  404.       $game_message.choice_y = self.y
  405.       $game_message.choice_row_max = visible_line_number
  406.     end
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● 文章の標示を強制クリア
  410.   #--------------------------------------------------------------------------
  411.   def force_clear
  412.     @gold_window.close
  413.     @fiber = nil
  414.     close
  415.     if WdTk.include?(:MesEff)
  416.       @character_sprites.each do |sprite, params|
  417.         next if params.empty?
  418.         sprite.bitmap.clear
  419.         sprite.visible = false
  420.         params.clear
  421.       end
  422.     end
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● 文章を最後まで表示する
  426.   #--------------------------------------------------------------------------
  427.   def on_show_fast
  428.     @show_fast = true
  429.   end
  430. end
复制代码
VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复 1 0

使用道具 举报

梦石
0
星屑
1411
在线时间
215 小时
注册时间
2019-9-17
回帖
17
 楼主| 发表于 2019-10-5 22:02:00 | 显示全部楼层
gqxastg 发表于 2019-10-4 23:33
推荐 木星ペンギン 的 選択肢拡張
[fold=脚本]=begin

谢谢dalao
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部