设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2001|回复: 4
打印 上一主题 下一主题

[已经解决] 能不能让选项文字根据变量变化?

[复制链接]

Lv3.寻梦者

闇吼者の災悪眷族
不気味存在締造者

梦石
0
星屑
1366
在线时间
2881 小时
注册时间
2014-7-29
帖子
6491
跳转到指定楼层
1
发表于 2014-9-8 20:54:29 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
一言以概就是  让 显示选项 中选项文字可以跟随变量(以及其它方式)。

通过搜索还是发现有些人在求过这样一个功能,似乎有一个可行的回答但是是XP的还用到了一些脚本;

现阶段我个人需要的理想效果是让选项显示的文字成为变量值对应的 物品、装备的名字。

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21484
在线时间
9389 小时
注册时间
2012-6-19
帖子
7114

开拓者短篇九导演组冠军

2
发表于 2014-9-8 21:08:04 | 只看该作者

记得插入这个脚本:
https://rpg.blue/thread-233548-1-1.html

点评

原来可以直接用啊,,之前也试过,结果失败了。原来是我加的其它脚本让它失效了。  发表于 2014-9-8 21:37
选项内容本来就可以支持控制符。安安代发的这个脚本是解决了选项宽度计算的错误。  发表于 2014-9-8 21:35
脚本只是修正BUG而已,不放脚本也能用,就是选项框的大小会出问题  发表于 2014-9-8 21:32
啊嘞,测试怎么不行呢……难道是我放脚本的姿势不对么?  发表于 2014-9-8 21:31

评分

参与人数 2星屑 +6 梦石 +1 收起 理由
三途亚梦 + 6 认可答案
VIPArcher + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

闇吼者の災悪眷族
不気味存在締造者

梦石
0
星屑
1366
在线时间
2881 小时
注册时间
2014-7-29
帖子
6491
3
 楼主| 发表于 2014-9-8 21:56:46 | 只看该作者
认可答案。先结贴吧,我要解决的事情变成另外一件事了……
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22688
在线时间
8622 小时
注册时间
2011-12-31
帖子
3367
4
发表于 2014-9-9 00:10:55 | 只看该作者
本帖最后由 tseyik 于 2014-9-9 00:18 编辑


    選択肢文章中可用 if(条件) 、視条件真/偽決定項目表示与否。
    s 為開関。
    (例: if(s[3]) 開関番号 3  ON 之時項目表示)
    v 為変数。
    (例 : if(v[5] >= 4) 変数番号 5大於 4項目表示)
    and 或or也可使用。

下圖是使用例

  1. =begin

  2. ▼ 選択肢拡張 ver. 2.3

  3. RPGツクール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.   ・s でスイッチ、v で変数を参照できます。
  23.   ・「キャンセルの場合」の項目が表示されない場合、無効と同じ処理をします。

  24. □ 注釈に以下の文字列を入れることで、選択肢ウィンドウの表示位置を
  25.    一時的に変更することが出来ます。
  26.   
  27.     選択肢位置(x, y[, row])
  28.    
  29.       x   : ウィンドウを表示する X 座標。
  30.       y   : ウィンドウを表示する Y 座標。
  31.       row : 選択肢を表示する最大行数。
  32.             指定しない場合は、通常の最大行数を無視して
  33.             すべての選択肢が表示されます。
  34.   
  35. □ 選択肢の文章中に en(条件) と入れ、その条件が偽になると項目が半透明で表示されます。
  36.   
  37. □ 各項目の下に、注釈で以下の文字列を入れると、続きの文章を
  38.     項目のヘルプメッセージとしてカーソルを合わせたときに標示することができます。
  39.   
  40.     選択肢ヘルプ
  41.    
  42. □ 詳細は下記のサイトを参照してください。

  43.   http://woodpenguin.web.fc2.com/rgss3/choice_ex.html
  44.   
  45. =end
  46. module WdTk
  47. module ChoiceEX
  48. #//////////////////////////////////////////////////////////////////////////////
  49. #
  50. # 設定項目
  51. #
  52. #//////////////////////////////////////////////////////////////////////////////
  53.   #--------------------------------------------------------------------------
  54.   # ● 選択肢の最大行数
  55.   #     選択肢を表示するウィンドウの行数の最大数です。
  56.   #     選択肢がこの数より小さければ、選択肢の数に合わせます。
  57.   #--------------------------------------------------------------------------
  58.   RowMax = 4
  59.   
  60.   #--------------------------------------------------------------------------
  61.   # ● 選択肢の位置記憶
  62.   #     前回表示した選択肢と全く同じ内容の選択肢を表示する場合、
  63.   #     カーソルの初期位置を前回選んだ項目にする機能です。
  64.   #     false で無効化できます。
  65.   #--------------------------------------------------------------------------
  66.   Store = true
  67.   
  68.   #--------------------------------------------------------------------------
  69.   # ● 選択肢ヘルプを読み取る文字列
  70.   #--------------------------------------------------------------------------
  71.   Help = "選択肢ヘルプ"
  72.   
  73. end

  74. #//////////////////////////////////////////////////////////////////////////////
  75. #
  76. # 以降、変更する必要なし
  77. #
  78. #//////////////////////////////////////////////////////////////////////////////

  79.   @material ||= []
  80.   @material << :ChoiceEX
  81.   def self.include?(sym)
  82.     @material.include?(sym)
  83.   end
  84.   
  85. end

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

  92. class Game_Message
  93.   #--------------------------------------------------------------------------
  94.   # ● 公開インスタンス変数
  95.   #--------------------------------------------------------------------------
  96.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  97.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  98.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  99.   attr_accessor :choice_enables           # 選択肢の有効状態
  100.   attr_accessor :choice_help              # 選択肢のヘルプ
  101.   #--------------------------------------------------------------------------
  102.   # ○ クリア
  103.   #--------------------------------------------------------------------------
  104.   alias _wdtk_choice_clear clear
  105.   def clear
  106.     _wdtk_choice_clear
  107.     @choice_x = @choice_y = nil
  108.     @choice_row_max = WdTk::ChoiceEX::RowMax
  109.     @choice_enables = []
  110.     @choice_help = {}
  111.   end
  112. end

  113. #==============================================================================
  114. # ■ Game_Interpreter
  115. #==============================================================================
  116. class Game_Interpreter
  117.   #--------------------------------------------------------------------------
  118.   # ☆ 選択肢のセットアップ
  119.   #--------------------------------------------------------------------------
  120.   def setup_choices(params)
  121.     result = []
  122.     add_choices(params, @index, result)
  123.     $game_message.choice_enables = $game_message.choices.collect do |c|
  124.       !c.slice!(/\s*en\(([^\)]+)\)/i) || choice_eval($1)
  125.     end
  126.     unless $game_message.choices.empty?
  127.       m = result.index($game_message.choice_cancel_type - 1)
  128.       $game_message.choice_enables << (!m || $game_message.choice_enables[m])
  129.       result << $game_message.choice_cancel_type - 1
  130.       $game_message.choice_proc = Proc.new {|n| @branch[@indent] = result[n] }
  131.     else
  132.       @branch[@indent] = -1
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 選択肢の追加
  137.   #--------------------------------------------------------------------------
  138.   def add_choices(params, i, result, d = 0)
  139.     params[0].each_with_index do |s, n|
  140.       choice = s.dup
  141.       next if choice.slice!(/\s*if\(([^\)]+)\)/i) && !choice_eval($1)
  142.       $game_message.choices << choice
  143.       result << n + d
  144.     end
  145.     if params[1] == 5 || (params[1] > 0 && result.include?(params[1] + d - 1))
  146.       $game_message.choice_cancel_type = params[1] + d
  147.     end
  148.     indent = @list[i].indent
  149.     loop do
  150.       i += 1
  151.       if @list[i].indent == indent
  152.         case @list[i].code
  153.         when 402 # [**] の場合
  154.           m = result.index(@list[i].parameters[0] + d)
  155.           get_help_texts(m, i + 1) if m
  156.         when 404 # 分岐終了
  157.           break
  158.         end
  159.       end
  160.     end
  161.     i += 1
  162.     add_choices(@list[i].parameters, i, result, d + 5) if @list[i].code == 102
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 分岐用
  166.   #--------------------------------------------------------------------------
  167.   def choice_eval(formula)
  168.     s, v = $game_switches, $game_variables
  169.     begin
  170.       Kernel.eval(formula)
  171.     rescue
  172.       msgbox "以下の条件判定でエラーが出ました。\n\n", formula
  173.       true
  174.     end
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ● ヘルプ用テキストの取得
  178.   #--------------------------------------------------------------------------
  179.   def get_help_texts(b, i)
  180.     if @list[i].code == 108 && @list[i].parameters[0] == WdTk::ChoiceEX::Help
  181.       $game_message.choice_help[b] = []
  182.       loop do
  183.         i += 1
  184.         break if @list[i].code != 408
  185.         $game_message.choice_help[b] << @list[i].parameters[0]
  186.       end
  187.     end
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ◯ 注釈
  191.   #--------------------------------------------------------------------------
  192.   alias _wdtk_choice_command_108 command_108
  193.   def command_108
  194.     _wdtk_choice_command_108
  195.     @comments.each do |comment|
  196.       if comment =~ /選択肢位置\((\d+),\s*(\d+),?\s*(\d*)\)/
  197.         $game_message.choice_x = $1.to_i
  198.         $game_message.choice_y = $2.to_i
  199.         $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
  200.       end
  201.     end
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 分岐終了の場合
  205.   #--------------------------------------------------------------------------
  206.   def command_404
  207.     if next_event_code == 102
  208.       @branch[@indent] -= 5 if @branch.include?(@indent)
  209.       @index += 1
  210.       command_skip
  211. #~     else
  212. #~       @branch.delete(@indent)
  213.     end
  214.   end
  215. end

  216. #==============================================================================
  217. # ■ Window_ChoiceList
  218. #==============================================================================
  219. class Window_ChoiceList
  220.   #--------------------------------------------------------------------------
  221.   # ☆ 入力処理の開始
  222.   #--------------------------------------------------------------------------
  223.   def start
  224.     return unless close?
  225.     last_choices = @list.collect {|c| c[:name] }
  226.     update_placement
  227.     refresh
  228.     unless WdTk::ChoiceEX::Store && last_choices == $game_message.choices
  229.       select(0)
  230.     end
  231.     open
  232.     activate
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # ○ ウィンドウ位置の更新
  236.   #--------------------------------------------------------------------------
  237.   alias _wdtk_choice_update_placement update_placement
  238.   def update_placement
  239.     _wdtk_choice_update_placement
  240.     self.height = [height, fitting_height($game_message.choice_row_max)].min
  241.     if @message_window.y >= Graphics.height / 2
  242.       self.y = @message_window.y - height
  243.     else
  244.       self.y = @message_window.y + @message_window.height
  245.     end
  246.     self.x = $game_message.choice_x if $game_message.choice_x
  247.     self.y = $game_message.choice_y if $game_message.choice_y
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ☆ コマンドリストの作成
  251.   #--------------------------------------------------------------------------
  252.   def make_command_list
  253.     $game_message.choices.each_with_index do |choice, i|
  254.       add_command(choice, :choice, $game_message.choice_enables[i])
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ○ 項目の描画
  259.   #--------------------------------------------------------------------------
  260.   alias _wdtk_choice_draw_item draw_item
  261.   def draw_item(index)
  262.     @choice_enabled = command_enabled?(index)
  263.     _wdtk_choice_draw_item(index)
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● テキスト描画色の変更
  267.   #--------------------------------------------------------------------------
  268.   def change_color(color, enabled = true)
  269.     super(color, enabled && @choice_enabled)
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● キャンセルボタンが押されたときの処理
  273.   #--------------------------------------------------------------------------
  274.   def process_cancel
  275.     if $game_message.choice_enables[item_max]
  276.       super
  277.     else
  278.       Sound.play_buzzer
  279.     end
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ☆ キャンセルハンドラの呼び出し
  283.   #--------------------------------------------------------------------------
  284.   def call_cancel_handler
  285.     $game_message.choice_proc.call(item_max)
  286.     close
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● ウィンドウを閉じる
  290.   #--------------------------------------------------------------------------
  291.   def close
  292.     @message_window.on_show_fast unless $game_message.choice_help.empty?
  293.     super
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  297.   #--------------------------------------------------------------------------
  298.   def call_update_help
  299.     update_help if active && !$game_message.choice_help.empty?
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● ヘルプウィンドウの更新
  303.   #--------------------------------------------------------------------------
  304.   def update_help
  305.     @message_window.force_clear
  306.     if $game_message.choice_help.include?(index)
  307.       $game_message.texts.replace($game_message.choice_help[index])
  308.     else
  309.       $game_message.texts.clear
  310.     end
  311.   end
  312. end

  313. #==============================================================================
  314. # ■ Window_Message
  315. #==============================================================================
  316. class Window_Message
  317.   #--------------------------------------------------------------------------
  318.   # ● 文章の標示を強制クリア
  319.   #--------------------------------------------------------------------------
  320.   def force_clear
  321.     @gold_window.close
  322.     @fiber = nil
  323.     close
  324.     if WdTk.include?(:MesEff)
  325.       @character_sprites.each do |sprite, params|
  326.         next if params.empty?
  327.         sprite.bitmap.clear
  328.         sprite.visible = false
  329.         params.clear
  330.       end
  331.     end
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 文章を最後まで表示する
  335.   #--------------------------------------------------------------------------
  336.   def on_show_fast
  337.     @show_fast = true
  338.   end
  339. end
复制代码

点评

这个脚本我还真知道……虽然好用但是好像不大可能跟回想领域的方向键选项支混用就放弃了。  发表于 2014-9-9 00:33
看錯問題了,請無視這楼  发表于 2014-9-9 00:22
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22688
在线时间
8622 小时
注册时间
2011-12-31
帖子
3367
5
发表于 2014-9-9 10:12:08 | 只看该作者
RM在文本模式可用不同指令加上不同效果(如顔色、icon)
這個脚本就是把這指令拡張到其他地方
这个脚本允许你使用特殊的信息代码,在任何一个窗口,而不仅仅是信息窗口和帮助窗口。要添加一个图标旁边的菜单命令?这个脚本,你可以做的多。

版本歷程記錄

    < 版本 1.0 a > 2012.04.05-修正替換代碼的問題
    < 1.0 > 2012.01.05-原始版本
  1. #==============================================================================
  2. #    Global Text Codes [VXA]
  3. #    Version: 1.0a
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: April 5, 2012
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script allows you to use special message codes in any window, not
  10. #   just message windows and help windows. Want to add an icon next to the
  11. #   menu commands? With this script you can do that and more.
  12. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  13. #  Instructions:
  14. #
  15. #    Simply paste this script into its own slot above Main and below Materials
  16. #   and other custom scripts.
  17. #
  18. #    There are two settings for this script - automatic and manual. If set to
  19. #   automatic, then all you will need to do is put any of the special message
  20. #   codes in anything and they will automatically work. If set to manual, then
  21. #   you will also need to type the following code somewhere in the text field
  22. #   to activate it: \*
  23. #
  24. #    The following default codes are available:
  25. #
  26. # \c[n] - Set the colour of the text being drawn to the nth colour of the
  27. #     Windowskin palette. 0 is the normal color and 16 is the system color.
  28. # \i[n] - Draw icon with index n.
  29. # \p[n] - Draw the name of the actor in the xth position in the party. 1 is
  30. #     the party leader, 2 is the second member, etc.
  31. # \n[n] - Draw the name of the actor with ID n
  32. # \v[n] - Draw the value of variable with ID n.
  33. # \g - Draws the unit of currency.
  34. #
  35. #    Depending on whether you are using any custom message script, you may have
  36. #   additional message codes at your disposal. This script is mostly compatible
  37. #   with my ATS and every code except \x and ones related to message control
  38. #   will work.
  39. #==============================================================================

  40. $imported = {} unless $imported
  41. $imported[:MAGlobalTextCodes] = true
  42. #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  43. #  Editable Region
  44. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  45. #  MAGTC_MANUAL_CODES - If this is true, then you must put a \* code in any
  46. # field that you want to have codes interpreted in. Otherwise, codes will
  47. # always automatically be interpreted. The recommended value for this is true,
  48. # as the process for drawing text with codes is much slower than the process
  49. # for drawing text without codes.
  50. MAGTC_MANUAL_CODES = true
  51. #  MAGTC RCODES - This feature is designed to overcome the space limitations in
  52. # much of the database - since codes take so much of that space, it might be
  53. # difficult to write everything you want into one of those fields. This feature
  54. # permits you to write the term you want in to the following array, and then
  55. # access it in the database with the code \r[n], where n is the ID you assign
  56. # to the phrase in the following way:
  57. #
  58. #    n => "replacement",
  59. #
  60. # Please note that: it is =>, not =; the replacement must be within quotation
  61. # marks; and there must be a comma after every line. If using double quotation
  62. # marks ("", not ''), then you need to use two backslashes to access codes
  63. # instead of one (\\c[1], not \c[1]).
  64. #
  65. #  EXAMPLE:
  66. #   0 => "\\i[112]\\c[14]New Game\\c[0]",
  67. #
  68. #  Under the New Game field in the Terms of the Database, all I would then need
  69. # to put is:
  70. #    \*\r[0]
  71. #  and it would be the same as if I had put:
  72. #    \*\i[112]\c[14]New Game\c[0]
  73. MAGTC_RCODES = { # <- Do not touch
  74.   0 => "\\i[112]\\c[14]New Game\\c[0]", # Example
  75.   1 => "", # You can make as many of these as you want
  76.   2 => "\\i[40]Blood Hound",
  77. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  78. #  END Editable Region
  79. #//////////////////////////////////////////////////////////////////////////////
  80. }
  81. MAGTC_RCODES.default = ""

  82. #==============================================================================
  83. # ** Window_Base
  84. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  85. #  Summary of Changes:
  86. #    aliased methods - draw_text; convert_escape_characters; process_new_line;
  87. #      reset_font_settings
  88. #    new methods - magtc_align_x; magtc_test_process_escape_character;
  89. #      magtc_calc_line_width
  90. #==============================================================================

  91. class Window_Base
  92.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93.   # * Draw Text
  94.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95.   alias ma_gtc_drwtxt_3fs1 draw_text
  96.   def draw_text(*args, &block)
  97.     # Get the arguments
  98.     if args[0].is_a?(Rect)
  99.         x, y, w, h = args[0].x, args[0].y, args[0].width, args[0].height
  100.         text, align = *args[1, 2]
  101.       else
  102.         x, y, w, h, text, align = *args[0, 6]
  103.       end
  104.     align = 0 unless align
  105.     #  Draw normally if text is not a string, draw normally if the text is not
  106.     # long enough to hold a code, and draw normally when the script is set to
  107.     # manual and \* is included in the text
  108.       if !text.is_a?(String) || text.size < 2 || (MAGTC_MANUAL_CODES && text[/\\\*/].nil?)
  109.         ma_gtc_drwtxt_3fs1(*args, &block) # Run Original Method
  110.       else
  111.       @magtc_reset_font = contents.font.dup # Do not automatically reset font
  112.       @magtc_rect, @magtc_align = Rect.new(x, y, w, h), align
  113.       # Get first line of the text to test for alignment
  114.       @magtc_test_line = convert_escape_characters(text[/.*/])
  115.       y += [(h - calc_line_height(@magtc_test_line)) / 2, 0].max
  116.       # Draw text with message codes
  117.         draw_text_ex(magtc_align_x(x), y, text)
  118.       @magtc_reset_font = nil # Do not automatically reset font
  119.       @magtc_rect, @magtc_align = nil, nil # Reset Rect and Alignment
  120.       end
  121.   end
  122.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  123.   # * Convert Escape Characters
  124.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  125.   alias ma_gtc_convescchar_5tk9 convert_escape_characters
  126.   def convert_escape_characters(text, *args, &block)
  127.     # Remove \* codes
  128.     new_text = text.gsub(/\\\*/, "")
  129.     # Substitute for the R Codes
  130.     new_text.gsub!(/\\[Rr]\[(\d+)\]/) { MAGTC_RCODES[$1.to_i].to_s }
  131.     ma_gtc_convescchar_5tk9(new_text, *args, &block) # Call Original Method
  132.   end
  133.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134.   # * Reset Font Settings
  135.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  136.   alias magtc_resetfonts_4ga5 reset_font_settings
  137.   def reset_font_settings(*args, &block)
  138.     magtc_resetfonts_4ga5(*args, &block) # Call Original Method
  139.     contents.font = @magtc_reset_font if @magtc_reset_font
  140.   end
  141.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142.   # * Process New Line
  143.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144.   alias magtc_prcsnewl_5gn9 process_new_line
  145.   def process_new_line(text, pos, *args, &block)
  146.     magtc_prcsnewl_5gn9(text, pos, *args, &block) # Run Original Method
  147.     if @magtc_align && @magtc_rext
  148.       @magtc_test_line = text[/.*/] # Get new line
  149.       pos[:x] = magtc_align_x       # Get the correct x, depending on alignment
  150.     end
  151.   end
  152.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153.   # * Get Alignment X
  154.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  155.   def magtc_align_x(start_x = @magtc_rect.x)
  156.     return start_x unless (@magtc_rect && @magtc_align && @magtc_test_line) || @magtc_align != 0
  157.     tw = magtc_calc_line_width(@magtc_test_line)
  158.     case @magtc_align
  159.     when 1 then return start_x + ((@magtc_rect.width - tw) / 2)
  160.     when 2 then return start_x + (@magtc_rect.width - tw)
  161.     end
  162.     start_x
  163.   end
  164.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  165.   # * Calc Line Width
  166.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  167.   def magtc_calc_line_width(line)
  168.     # Remove all escape codes
  169.     line = line.clone
  170.     line.gsub!(/[\n\r\f]/, "")
  171.     real_contents = contents # Preserve Real Contents
  172.     # Create a dummy contents
  173.     self.contents = Bitmap.new(@magtc_rect.width, @magtc_rect.height)
  174.     reset_font_settings
  175.     pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
  176.     tw = 0
  177.     while line[/^(.*?)\e(.*)/]
  178.       tw += text_size($1).width
  179.       line = $2
  180.       # Remove all ancillaries to the code, like parameters
  181.       code = obtain_escape_code(line)
  182.       magtc_test_process_escape_character(code, line, pos)
  183.     end
  184.     #  Add width of remaining text, as well as the value of pos[:x] under the
  185.     # assumption that any additions to it are because the special code is
  186.     # replaced by something which requires space (like icons)
  187.     tw += text_size(line).width + pos[:x]
  188.     self.contents.dispose # Dispose dummy contents
  189.     self.contents = real_contents # Restore real contents
  190.     return tw
  191.   end
  192.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  193.   # * Test Process Escape Character
  194.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  195.   def magtc_test_process_escape_character(code, text, pos)
  196.     if $imported[:ATS_SpecialMessageCodes] && ['X', 'HL'].include?(code.upcase)
  197.       obtain_escape_param(text)
  198.       return
  199.     end
  200.     process_escape_character(code, text, pos)
  201.   end
  202. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-20 01:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表