查看: 3958|回复: 4

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

[复制链接]
梦石
0
星屑
1461
在线时间
219 小时
注册时间
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
星屑
17289
在线时间
6068 小时
注册时间
2011-7-18
回帖
153

开拓者

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

推荐 木星ペンギン 的 選択肢拡張
脚本
  1. =begin

  2. ▼ 選択肢拡張 ver. 3.5

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

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

  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.     カーソルの初期位置になります。
  27.   
  28.     カーソル記憶(n)
  29.    
  30.       n : カーソル初期位置の入った変数番号
  31.   
  32.   ・選択肢のカーソルの位置が変更されるたびに、
  33.     この変数に選択肢の番号が入れられるようになります。
  34.   
  35. □ 注釈に以下の文字列を入れることで、選択肢ウィンドウの表示位置を
  36.    一時的に変更することが出来ます。
  37.   
  38.     選択肢位置(x, y[, row])
  39.    
  40.       x   : ウィンドウを表示する X 座標。
  41.       y   : ウィンドウを表示する Y 座標。
  42.       row : 選択肢を表示する最大行数。
  43.             指定しない場合は、通常の最大行数を無視して
  44.             すべての選択肢が表示されます。
  45.   
  46. □ 注釈に以下の文字列を入れることで、メッセージの下に選択肢を
  47.    表示させます。
  48.     [文章の表示]をこの後に実行してください。
  49.   
  50.     選択肢位置(メッセージ下)
  51.    
  52. □ 注釈に以下の文字列を入れることで、選択肢ウィンドウの背景が非表示になります。
  53.   
  54.     背景OFF
  55.    
  56. □ 選択肢の文章中に en(条件) と入れ、その条件が偽になると項目が半透明で表示されます。
  57.   ・条件は eval によって評価されます。(詳細は【組み込み関数】を参照)
  58.   ・s でスイッチ、v で変数を参照できます。
  59.   ・「キャンセルの場合」の項目が半透明の場合、ブザーが鳴ります。
  60.   
  61. □ 各項目の下に、注釈で以下の文字列を入れると、続きの注釈を
  62.     項目のヘルプメッセージとしてカーソルを合わせたときに標示することができます。
  63.   
  64.     選択肢ヘルプ
  65.    
  66. □ 詳細は下記のサイトを参照してください。

  67.   [url]http://woodpenguin.web.fc2.com/rgss3/choice_ex.html[/url]
  68.   
  69. =end
  70. module WdTk
  71. module ChoiceEX
  72. #//////////////////////////////////////////////////////////////////////////////
  73. #
  74. # 設定項目
  75. #
  76. #//////////////////////////////////////////////////////////////////////////////
  77.   #--------------------------------------------------------------------------
  78.   # ● 選択肢の最大行数
  79.   #     選択肢を表示するウィンドウの行数の最大数です。
  80.   #     選択肢がこの数より小さければ、選択肢の数に合わせます。
  81.   #--------------------------------------------------------------------------
  82.   RowMax = 4
  83.   
  84.   #--------------------------------------------------------------------------
  85.   # ● 選択肢ヘルプを読み取る文字列
  86.   #--------------------------------------------------------------------------
  87.   Help = "選択肢ヘルプ"
  88.   
  89. end

  90. #//////////////////////////////////////////////////////////////////////////////
  91. #
  92. # 以降、変更する必要なし
  93. #
  94. #//////////////////////////////////////////////////////////////////////////////

  95.   @material ||= []
  96.   @material << :ChoiceEX
  97.   def self.include?(sym)
  98.     @material.include?(sym)
  99.   end
  100.   
  101. end

  102. #==============================================================================
  103. # ■ Game_Message
  104. #==============================================================================
  105. class Game_Message
  106.   #--------------------------------------------------------------------------
  107.   # ● 公開インスタンス変数
  108.   #--------------------------------------------------------------------------
  109.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  110.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  111.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  112.   attr_accessor :choice_help              # 選択肢のヘルプ
  113.   attr_accessor :choice_var_id            # 選択肢のカーソル位置を入れる変数ID
  114.   attr_accessor :choice_background        # 選択肢ウィンドウ背景の表示状態
  115.   attr_accessor :under_choice             # 選択肢をメッセージの下に表示
  116.   #--------------------------------------------------------------------------
  117.   # ○ クリア
  118.   #--------------------------------------------------------------------------
  119.   alias _wdtk_choice_clear clear
  120.   def clear
  121.     _wdtk_choice_clear
  122.     @choice_x = @choice_y = nil
  123.     @choice_row_max = WdTk::ChoiceEX::RowMax
  124.     @choice_help = {}
  125.     @choice_var_id = 0
  126.     @choice_background = 0
  127.     @under_choice = false
  128.   end
  129. end

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

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

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

插入后直接在显示选项里这么写
显示的文字 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
星屑
14389
在线时间
2110 小时
注册时间
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
星屑
1461
在线时间
219 小时
注册时间
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.

在本版发帖返回顶部