楼主: RyanBern

[原创发布] 【重制】66RPG对话加强 - 211012

[复制链接]
梦石
0
星屑
10
在线时间
0 小时
注册时间
2022-8-8
回帖
3
发表于 2022-8-8 12:32:26 | 显示全部楼层
好怀旧呀……经典6R通用对话加强
回复

使用道具 举报

梦石
24
星屑
8942
在线时间
248 小时
注册时间
2020-12-4
回帖
259

极短24获奖极短23获奖极短22获奖

发表于 2022-8-12 00:08:37 | 显示全部楼层
前几天使用的时候,发现了一个连按小BUG
就是 如果启动了 【空格显示全部对话】
在与【决定建】触发的事件的NPC对话的时候,第一句话一定会全部显示(应该是出现连续判定了)

建议给552 行之后update里的空格判定加一个@wait_count变量判定吧,然后每次对话框初始化一下@wait_count~~ 避免偶尔出现的连按情况
if @wait_count <= 0
    # [空格键]跳过描绘
    if $game_switches[Write_Skip] && Input.trigger?(Input::C)
      @write_skip = true
    end
else
@wait_count -= 1
end

点评

然后,能不能添加一个功能 : \p[-2] 显示在当前事件上方;这样复制事件的时候就不用一个个改\p[]了~~ (^ 6 ^)  发表于 2022-8-16 11:31

评分

参与人数 1星屑 +20 收起 理由
RyanBern + 20 我很赞同

查看全部评分

回复

使用道具 举报

梦石
24
星屑
8942
在线时间
248 小时
注册时间
2020-12-4
回帖
259

极短24获奖极短23获奖极短22获奖

发表于 2022-8-16 13:08:14 | 显示全部楼层
冒昧地连个帖~~~

我加了一个 \p[x] 的功能    就是对话的时候,会自动识别当前事件,将对话框显示在当前事件上面
这样一来,就方便事件的复制了!(偷懒是第一生产力)
小测试了一下,目前能正常运行——应该是有一些BUG的....毕竟"x"是字符串,可能有些地方的判定还是整数没改过来

修改的部分我用 # ●●●【p[x]】   标注了,方便返工修改

添加 \p[x 功能]
  1. #==============================================================================
  2. # 本脚本来自[url]https://rpg.blue[/url],使用和转载请保留此信息
  3. #------------------------------------------------------------------------------
  4. # 原版:趙雲
  5. # 重制:RyanBern  2015.08.24
  6. #------------------------------------------------------------------------------
  7. # 更新记录:
  8. #     2015.09.06    少许BUG修复,附加战斗场景对话效果
  9. #     2015.11.05    修复临时更改字号功能
  10. #     2015.11.13    增加更改姓名颜色的功能,修复显示 BUG
  11. #     2016.01.19    增加大型半身像对话框设置,快捷方式设置,高级快捷方式设置
  12. #     2016.05.10    增加对话框开关,打开指定开关时暂时屏蔽本对话加强窗口
  13. #                   增加\f[头像]的功能,可以显示正方形的说话者头像
  14. #     2016.08.26    简化代码,增加自动对话功能,高速跳过对话功能
  15. #     2016.11.05    增加自动调节文字位置的功能,当对话框太靠近屏幕上方或者下方
  16. #                   时,脚本会更换成另外一个显示的方向。
  17. #     2017.01.11    增加连行功能和兼容 VA 的头像组功能
  18. #     2021.10.12    修复淡入淡出不正常的 BUG
  19. #                   数值输入对话框现在会在打字结束后显示(而不是一开始就显示出来)
  20. #                   \> 和 \< 的功能可以使用了
  21. #                   增加一个开关,控制对话框淡入淡出效果
  22. #==============================================================================

  23. #——说明

  24. # 使用时,要在Graphics文件夹下新建一个名为Faces的文件夹,用于存储头像
  25. # 对话框的窗口素材可不必和系统窗口相同,请将对话框窗口素材放到
  26. # Graphics/Windowskins文件夹下,并附上两个气泡箭头素材,用于指向说话者,
  27. # 命名规则为“对话框窗口素材名-top”和“对话框窗口素材名-under”
  28. # 然后在本脚本的设置区域修改。

  29. # 默认为一个字一个字的方式,如果需要一次全部显示,
  30. # 请打开特定开关(默认为 21 号)

  31. # 打开开关(默认为 22 号)后,对话时按下[空格键]可以瞬间显示全部对话。

  32. # 打卡开关(默认为 23 号)后,屏蔽加强对话框,将使用 XP 默认对话框。

  33. # 打开开关(默认为 24 号)后,对话框可以在对话显示完毕后自动消失,适合制作
  34. # 场景 CG,需要进行选择或数字输入的情况不会自动消失。此外在文本框中使用\t[数字]
  35. # 也可达到相似效果,不过作用范围仅限本次对话框。

  36. # 打开开关(默认为 25 号)后,按下 CTRL 键可以快速跳过对话,需要进行选择或者数字
  37. # 输入的情况不会跳过。

  38. # 打开开关(默认为 26 号)后,对话框的位置会自动调节,使其不会遮挡说话者

  39. # 打开开关(默认为 27 号)后,对话框显示和消失时将不会有淡入淡出效果。

  40. # 默认对话字没有声音,如果需要声音,
  41. # 请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  42. # 我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音

  43. #------------------------------------------------------------------------------

  44. # 其他在对话中可以使用的功能(部分功能在关闭打字效果时无效):

  45. # \n[1]:显示1号角色的姓名

  46. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名
  47. # \nc[0-7]:更改姓名框颜色

  48. # 非战斗时,\p功能可以自动调整对话框位置
  49. # \p[1] :对话框出现在1号事件的上方
  50. # \p[0] :主人公上方出现对话框
  51. # \p[-1]:对话框出现在屏幕下方,这种特殊类型的对话框在有大型半身像时使用

  52. # \p[x]:出现在当前的事件的位置,新添加的功能!

  53. #——————————————————使用\p功能后可以自动调整对话框大小
  54. # 使用\p功能后,使用事件指令[更改文章选项]可更改对话框的位置
  55. #   [上] :对话框出现在说话者上方
  56. #   [下] :对话框出现在说话者下方
  57. #   [中] :对话框出现在屏幕正中
  58. # 战斗时,\p功能有所变化
  59. # \p[1]:对话框出现在ID为1的角色战斗图附近(这个角色必须是队伍中的成员)
  60. # \p[1001]:对话框出现在Index为1的敌人战斗图附近--也就是说敌人的位置从
  61. #           1001开始算起,1002则是代表Index为2的敌人。
  62. # 战斗时使用\p指令+[更改文章选项]依然是有效的,但是如果不使用\p指令,那么
  63. # 对话框则会一直出现在屏幕正上方。

  64. # \\:显示""这个符号

  65. # \v[1] :显示变量1

  66. # \v[a1] :显示防具1

  67. # \v[w1] :显示武器1

  68. # \v[i1] :显示物品1

  69. # \v[s1] :显示特技1

  70. # \ic[001-Weapon01] : 显示图标"001-Weapon01.png"

  71. # \c[0-7]:更改颜色

  72. # \g:显示金钱窗口

  73. # \a[SE文件名]:对话的时候播放SE

  74. # \s[0-19]:更改弹字的速度,数值越小描绘越快(超过 19 时设置无效)

  75. # \.   :停顿一刹那(5帧,不包含描绘时的自然停顿)
  76. # \|   :停顿片刻(20帧,不包含描绘时的自然停顿)

  77. # \>   :文字不用打字方式
  78. # \<   :文字使用打字方式

  79. # \!   :等待玩家按回车再继续
  80. # \~   :文字直接消失

  81. # \I   :下一行从这个位置开始

  82. # \o[123]:文字透明度改为123,模拟将死之人(汗)

  83. # \h[12]:改用12号字

  84. # \b[50]:空50象素

  85. # \t[20]:对话显示完毕后等待 20 帧自动消失

  86. # \L[001]:在左边显示半身像"Graphics/Faces/001.png",并左右镜像反转
  87. # \R[001]:在右边显示半身像"Graphics/Faces/001.png"
  88. # \f[001]:在左边显示正方形头像"Graphics/Faces/001.png"
  89. # 注:不推荐同时使用显示半身像的功能和显示头像的功能。显示的头像图片大小
  90. #     不得超过 120x120,如果图片超过这个大小,图片将会被放缩
  91. # \gf[001, 0]:在左边显示正方形头像组"Graphics/Faces/001.png"的第一个
  92. # 注:头像组排序方式默认如下(先数第一行,再数第二行,可调节每行的头像个数)
  93. #  -----------------
  94. #  | 0 | 1 | 2 | 3 |
  95. #  -----------------
  96. #  | 4 | 5 | 6 | 7 |
  97. #  -----------------

  98. # \+:必须放在每一行的末尾,表示连行,它将合并下一个【显示文章】指令(需要
  99. #     在下面的设置区域调节 Max_Lines 以保证文字能正常显示出来)

  100. #==============================================================================
  101. # 设置区域(其他参数的调节请看这里)
  102. #==============================================================================
  103. module RB
  104. end
  105. module RB::Mes_Config
  106.   # 打开 XX 号开关后,关闭打字效果
  107.   No_Typing = 8
  108.   # 打开 XX 号开关后,按下[空格键]可以瞬间显示全部文字
  109.   Write_Skip = 9
  110.   # 打开 XX 号开关后,屏蔽加强对话框(使用默认对话框)
  111.   Mes_Disabled = 10
  112.   # 打开 XX 号开关后,对话自动结束(不用按下 C 键)
  113.   Auto_Terminate = 11
  114.   # 打开 XX 号开关后,按下 CTRL 可以高速跳过对话
  115.   Text_Skip_Fast = 12
  116.   # 打开 XX 号开关后,自动调节对话框使其不会挡住说话者
  117.   Auto_Adjust_Mes_Pos = 13
  118.   # 打开 XX 号开关后,对话框不会有淡入淡出效果
  119.   No_Fade = 14

  120.   # 主角名字字符缩写
  121.   Regex_Player_Name = /pn(\d+)/
  122.   # 主角姓名框底色(RGBA)
  123.   Name_Bar_Color = Color.new(255, 255, 255, 180)
  124.   # 字体大小
  125.   Size = 18
  126.   # 对话框窗口皮肤(不写为和系统皮肤相同)
  127.   Mes_Windowskin = ""
  128.   # 最大行数(初值为 4,尽量不要修改,如果考虑合并选择项和连行,可以设置为 6 以上)
  129.   # 此最大行数仅在 \p 指令下有效,如果不使用 \p 指令那么对话框还是 4 行的高度
  130.   Max_Lines = 8
  131.   # 画面宽度和高度(width / height)
  132.   # 此设置一般不需要更改,当使用分辨率扩张脚本时,将如下的值改成你游戏的分辨率即可。
  133.   Graphics_Width = 640
  134.   Graphics_Height = 480
  135.   # 对话自动结束延迟(单位:帧)
  136.   Auto_Terminate_Frame = 10
  137.   # 头像组:横向单元数
  138.   Face_Group_W = 4
  139.   # 头像组:纵向单元数
  140.   Face_Group_H = 2  
  141.   # 默认姓名文字颜色(和系统默认编号一致)
  142.   Name_Color_Default = 18
  143.   # 快捷指令,定义后,可以直接在文本框中输入快捷指令
  144.   # 定义方式为 快捷指令 => 完整指令 ,使用方式为 \sc[快捷指令]
  145.   # 注意,指令中通常包含反斜线'\',因此需要使用单引号的字符串,
  146.   # 或者用"\"进行转义。下面是一个例子:
  147.   # 这样定义后,输入\sc[pn1]就等效为 \name[pn1]\r[L1]\p[-1]
  148.   Shortcuts = {
  149.     #'pn1' => '\name[pn1]\r[L1]\p[-1]'
  150.   }
  151.   # 高级快捷指令定义,类似于宏展开,需要借助正则表达式(高级用户使用)
  152.   Shortcuts_Regexp = {
  153.     /\\pn1/ => '\name[pn1]\r[L1]\p[-1]',
  154.     /\\[Rr]ed\[(.*?)\]/m => '\c[2]\1\c[0]',
  155.     /\\[Cc]ol\[(\d+)\]\{(.*?)\}/m => '\c[\1]\2\c[0]',
  156.   }
  157. end
  158. #==============================================================================
  159. # RPG::Cache
  160. #------------------------------------------------------------------------------
  161. # RPG::Cache 追加定义
  162. #==============================================================================
  163. module RPG::Cache
  164.   def self.face(filename)
  165.     self.load_bitmap("Graphics/Faces/", filename)
  166.   end
  167. end

  168. #==============================================================================
  169. # ■ Game_System
  170. #------------------------------------------------------------------------------
  171. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  172. # $game_system 。
  173. #==============================================================================

  174. class Game_System
  175.   attr_accessor :soundname_on_speak
  176.   alias carol3_ini initialize
  177.   def initialize
  178.     carol3_ini
  179.     @soundname_on_speak = nil
  180.   end
  181. end

  182. #==============================================================================
  183. # ■ Window_Message
  184. #------------------------------------------------------------------------------
  185. #   修改的对话框类。
  186. #==============================================================================
  187. class Window_Message_RB < Window_Selectable
  188.   include RB::Mes_Config
  189.   # 定义经过变换后不可见的字符,描绘结束后直接描绘下一个字符,不进入下一帧
  190.   Invisible_Chars = [
  191.     "\001", "\003", "\n", "\023", "\024", "\025", "\076"]
  192.   #--------------------------------------------------------------------------
  193.   # ● 初始化状态
  194.   #--------------------------------------------------------------------------
  195.   def initialize
  196.     super(80, 304, 480, 160)
  197.     self.contents = Bitmap.new(1, 1)
  198.     self.visible = false
  199.     self.z = 9998
  200.     @fade_in = false
  201.     @fade_out = false
  202.     @contents_showing = false
  203.     @write_skip = false
  204.     @text_skip = false
  205.     @cursor_width = 0
  206.     @face_h = 0
  207.     self.active = false
  208.     self.index = -1
  209.     if $game_system.soundname_on_speak == nil then
  210.       $game_system.soundname_on_speak = ""
  211.     end
  212.     self.windowskin = RPG::Cache.windowskin(Mes_Windowskin) if Mes_Windowskin != ""
  213.     @opacity_text_buf = Bitmap.new(32, 32)
  214.     @all_opa = 0;
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 释放
  218.   #--------------------------------------------------------------------------
  219.   def dispose
  220.     terminate_message
  221.     $game_temp.message_window_showing = false
  222.     if @input_number_window != nil
  223.       @input_number_window.dispose
  224.     end
  225.     super
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● 处理信息结束
  229.   #--------------------------------------------------------------------------
  230.   def terminate_message
  231.     self.active = false
  232.     self.pause = false
  233.     self.index = -1
  234.     self.contents.clear
  235.     # 清除显示中标志
  236.     @contents_showing = false
  237.     # 呼叫信息调用
  238.     if $game_temp.message_proc != nil
  239.       $game_temp.message_proc.call
  240.     end
  241.     # 清除文章、选择项、输入数值的相关变量
  242.     $game_temp.message_text = nil
  243.     $game_temp.message_proc = nil
  244.     $game_temp.choice_start = 99
  245.     $game_temp.choice_max = 0
  246.     $game_temp.choice_cancel_type = 0
  247.     $game_temp.choice_proc = nil
  248.     $game_temp.num_input_start = 99
  249.     $game_temp.num_input_variable_id = 0
  250.     $game_temp.num_input_digits_max = 0
  251.     # 清除头像(由于是 RPG::Cache 所以无需释放)
  252.     @face_bitmap = nil
  253.     @face_group_bitmap = nil
  254.     @face_ok = false
  255.     # 清除跳过标志
  256.     @write_skip = false
  257.     @text_skip = false
  258.     # 释放金钱窗口
  259.     if @gold_window != nil
  260.       @gold_window.dispose
  261.       @gold_window = nil
  262.     end
  263.     # 释放姓名窗口
  264.     if @name_window_text != nil
  265.       @name_window_text.dispose
  266.       @name_window_text = nil
  267.     end
  268.     # 释放右侧立绘
  269.     if @right_picture != nil
  270.       @right_picture.dispose
  271.       @right_picture = nil
  272.     end   
  273.     # 释放左侧立绘
  274.     if @left_picture != nil
  275.       @left_picture.dispose
  276.       @left_picture = nil
  277.     end
  278.     # 释放姓名蓝条
  279.     if @bar != nil
  280.       @bar.bitmap.dispose
  281.       @bar.dispose
  282.       @bar = nil
  283.     end
  284.     # 释放气泡图标
  285.     if @k_tale != nil
  286.       @k_tale.dispose
  287.       @k_tale = nil
  288.     end
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 刷新
  292.   #--------------------------------------------------------------------------
  293.   def refresh
  294.     # 初期化
  295.     @x = @y = @max_x = @max_y = @indent = @lines = 0
  296.     @face_indent = 0
  297.     @opacity = 255
  298.     @cursor_width = 0
  299.     @write_speed = 0
  300.     @write_wait = 0
  301.     @mid_stop = false
  302.     @popchar = -2
  303.     @auto_terminate = -1
  304.     if $game_temp.choice_start == 0
  305.       @x = 8
  306.     end
  307.     if $game_temp.message_text != nil
  308.       @now_text = $game_temp.message_text
  309.       # \` 预处理
  310.       @now_text.gsub!(/\\`/){ "\077" }
  311.       # `foo` 预处理
  312.       @protected = @now_text.scan(/`(.+?)`/m).flatten
  313.       @now_text.gsub!(/`(.+?)`/m){ "\076" }
  314.       # Shortcuts 预处理
  315.       @now_text.gsub!(/\\sc\[(.*?)\]/) { Shortcuts[$1] || "" }
  316.       # Shortcuts_Regexp 预处理
  317.       Shortcuts_Regexp.each_pair do |regex, str|
  318.         @now_text.gsub!(regex, str)
  319.       end
  320.       # 头像设置
  321.       if (/\\[Ff]\[(.+?)\]/.match(@now_text)) != nil
  322.         @face_bitmap = RPG::Cache.face($1)
  323.         @x = @face_indent = [128, @face_bitmap.width + 4].min
  324.         @now_text.gsub!(/\\[Ff]\[(.+?)\]/) { "" }
  325.       end
  326.       # 头像组设置
  327.       if (/\\[Gg]f\[(.+?)\s*,\s*(\d+)\]/).match(@now_text) != nil
  328.         @face_group_bitmap = RPG::Cache.face($1)
  329.         idx = $2.to_i
  330.         ix, iy = idx % Face_Group_W, idx / Face_Group_W
  331.         w, h = @face_group_bitmap.width / Face_Group_W, @face_group_bitmap.height / Face_Group_H
  332.         @face_bitmap = Bitmap.new(w, h)
  333.         @face_bitmap.blt(0, 0, @face_group_bitmap, Rect.new(ix * w, iy * h, w, h))
  334.         @x = @face_indent = [128, @face_bitmap.width + 4].min
  335.         @now_text.gsub!(/\\[Gg]f\[(.+?)\s*,\s*(\d+)\]/) { "" }
  336.       end
  337.       #——左半身像设置
  338.       if (/\\[Ll]\[(.+?)\]/.match(@now_text)) != nil then
  339.         @face = $1
  340.         if @left_picture != nil
  341.           @left_picture.dispose
  342.         end
  343.         @left_picture = Sprite.new
  344.         @left_picture.bitmap = RPG::Cache.face(@face)
  345.         @left_picture.mirror = true
  346.         @x = @face_indent = @left_picture.bitmap.width
  347.         @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  348.       end
  349.       #——右半身像设置
  350.       if (/\\[Rr]\[(.+?)\]/.match(@now_text)) != nil then
  351.         @face = $1
  352.         if @right_picture != nil
  353.           @right_picture.dispose
  354.         end
  355.         @right_picture = Sprite.new
  356.         @right_picture.bitmap = RPG::Cache.face(@face)
  357.         @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  358.       end
  359.       # 显示人物姓名
  360.       name_window_set = false
  361.       if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  362.         name_window_set = true
  363.         name_text = $1
  364.         if Regex_Player_Name =~ name_text
  365.           name_text = $game_actors[$1.to_i].name
  366.         end
  367.         @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  368.       end
  369.       # 人物姓名颜色
  370.       name_color = text_color(Name_Color_Default)
  371.       if (/\\[Nn]c\[(\d+)\]/.match(@now_text)) != nil
  372.         name_color = text_color($1.to_i)
  373.         @now_text.sub!(/\\[Nn]c\[(\d+)\]/) { "" }
  374.       end
  375.       # 文字位置的判定 ●●●【p[x]】
  376.       if (/\\[Pp]\[([x,-1,0-9]+)\]/.match(@now_text)) != nil then
  377.         if $1 != "x"
  378.           @popchar = $1.to_i
  379.         else
  380.           @popchar = $1 # ●●●【p[x]】
  381.         end
  382.         @now_text.gsub!(/\\[Pp]\[([x,-1,0-9]+)\]/) { "" } #●●●【p[x]】
  383.       end
  384.       # 自动结束判定
  385.       @auto_terminate = Auto_Terminate_Frame if $game_switches[Auto_Terminate]
  386.       if (/\\[Tt]\[(\d+)\]/).match(@now_text)
  387.         @auto_terminate = $1.to_i
  388.         @now_text.gsub!(/\\[Tt]\[(\d+)\]/) { "" }
  389.       end
  390.       # 开始替换文字(\v)
  391.       begin
  392.         last_text = @now_text.clone
  393.         @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  394.       end until @now_text == last_text
  395.       # 替换控制码
  396.       @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  397.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  398.       end
  399.       @now_text.gsub!(/\\\\/) { "\000" }
  400.       @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  401.       @now_text.gsub!(/\\[Gg]/) { "\002" }
  402.       @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  403.       @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  404.       @now_text.gsub!(/\\[.]/) { "\005" }
  405.       @now_text.gsub!(/\\[|]/) { "\006" }
  406.       @now_text.gsub!(/\\[Ii]c\[(.*?)\]/) { "\030[#{$1}] "}
  407.       @now_text.gsub!(/\\[>]/) { "\016" }
  408.       @now_text.gsub!(/\\[<]/) { "\017" }
  409.       @now_text.gsub!(/\\[!]/) { "\020" }
  410.       @now_text.gsub!(/\\[~]/) { "\021" }
  411.       @now_text.gsub!(/\\[Ii]/) { "\023" }
  412.       @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  413.       @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  414.       @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  415.       # 根据 \p 的不同设置对话框大小 ●●●【p[x]】
  416.       if @popchar == "x" or @popchar >= 0 # \p 的情况下自动调节
  417.         @text_save = @now_text.clone
  418.         process_real_text
  419.         @max_x = name_window_set ? contents.text_size(name_text).width : 0
  420.         @max_y = Max_Lines
  421.         for i in 0...Max_Lines
  422.           line = @text_save.split(/\n/)[Max_Lines-i-1]
  423.           @max_y -= 1 if line == nil && @max_y <= Max_Lines - i
  424.           next if line == nil
  425.           contents.font.size = Size
  426.           cx = contents.text_size(line).width
  427.           @max_x = cx if cx > @max_x
  428.         end
  429.         if @right_picture != nil && !@right_picture.disposed?
  430.           self.width = @max_x + 48 + @face_indent + @right_picture.bitmap.width
  431.         else
  432.           self.width = @max_x + 48 + @face_indent
  433.         end
  434.         @face_h = @face_bitmap == nil ? 0 : [120, @face_bitmap.height].min
  435.         if $game_temp.num_input_variable_id > 0
  436.           self.height = [(@max_y - 1) * line_height + 96, @face_h + 32].max
  437.         else
  438.           self.height = [(@max_y - 1) * line_height + 64, @face_h + 32].max
  439.         end
  440.         # 生成气泡图标
  441.         @k_tale = Sprite.new
  442.       elsif @popchar == -1
  443.         line_count = @now_text.split(/\n/).size
  444.         line_count = [Max_Lines , [line_count, 4].max].min
  445.         self.width = Graphics_Width
  446.         self.height = [64 + line_height * (line_count - 1), @face_h + 32].max
  447.         @max_x = self.width - 32 - @face_indent
  448.       else
  449.         self.width = Graphics_Width * 0.6
  450.         self.height = 64 + line_height * 3
  451.         @max_x = self.width - 32 - @face_indent
  452.       end
  453.       # 如果设置了姓名框
  454.       if name_window_set
  455.         off_x = 0
  456.         off_y = -40
  457.         space = 2
  458.         x = self.x + off_x - space / 2
  459.         y = self.y + off_y - space / 2
  460.         w = self.contents.text_size(name_text).width + 26 + space
  461.         h = 40 + space
  462.         x = self.x + off_x + 4
  463.         y = self.y + off_y
  464.         @name_window_text = Air_Text.new(self.x + @face_indent+4+8, self.y+16, name_text, name_color)
  465.         @name_window_text.z = self.z + 2
  466.         @bar = Sprite.new
  467.         @bar.bitmap = Bitmap.new(self.width, 24)
  468.         face_cut = @face_bitmap == nil ? 0 : @face_indent + 2
  469.         @bar.x = self.x + 8 + face_cut
  470.         @bar.y = self.y + 16
  471.         @bar.z = self.z + 2
  472.         @bar.bitmap.fill_rect(0,0,self.width-16-face_cut,24, Name_Bar_Color)
  473.       end
  474.       # 一切设置完毕后,创建 contents
  475.       if self.contents != nil
  476.         self.contents.dispose
  477.         self.contents = nil
  478.       end
  479.       self.contents = Bitmap.new(width - 32, height - 32)
  480.       self.contents.font.color = normal_color
  481.       self.contents.font.size = Size
  482.     end
  483.     # 如果选择项被设置
  484.     if $game_temp.choice_max > 0
  485.       @item_max = $game_temp.choice_max
  486.       self.active = true
  487.       self.index = 0
  488.     end
  489.     # 如果数值输入被设置
  490.     if $game_temp.num_input_variable_id > 0
  491.       digits_max = $game_temp.num_input_digits_max
  492.       number = $game_variables[$game_temp.num_input_variable_id]
  493.       @input_number_window = Window_InputNumber.new(digits_max)
  494.       @input_number_window.number = number
  495.       @input_number_window.visible = false
  496.     end
  497.     # 设置背景不透明度
  498.     self.back_opacity = 200
  499.     # 更新窗口位置
  500.     update_window_pos
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● 更新
  504.   #--------------------------------------------------------------------------
  505.   def update
  506.     super
  507.     # 使用默认窗口外观的情况下,如果窗口的外关被变更了、再设置
  508.     if $game_system.windowskin_name != @windowskin_name && Mes_Windowskin == ""
  509.       @windowskin_name = $game_system.windowskin_name
  510.       self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  511.     end
  512.     # 地图中实时更新位置
  513.     if @k_tale != nil && @k_tale.visible && !$game_temp.in_battle
  514.       update_window_pos
  515.     end
  516.     # [空格键]跳过描绘
  517.     if $game_switches[Write_Skip] && Input.trigger?(Input::C)
  518.       @write_skip = true
  519.     end
  520.     # CTRL 高速跳过对话
  521.     if $game_switches[Text_Skip_Fast] && Input.trigger?(Input::CTRL)
  522.       # 选择项或数字输入时无法高速跳过
  523.       if $game_temp.choice_max > 0 || @input_number_window != nil
  524.         @write_skip = true
  525.       else
  526.         @text_skip = true
  527.       end
  528.     end
  529.     # 描绘头像
  530.     if @face_bitmap != nil && !@face_ok
  531.       face_real_w = [120, @face_bitmap.width].min
  532.       face_real_h = [120, @face_bitmap.height].min
  533.       self.contents.stretch_blt(Rect.new(0, 0, face_real_w, face_real_h), @face_bitmap, Rect.new(0, 0, @face_bitmap.width, @face_bitmap.height))
  534.       @face_ok = true
  535.     end
  536.     # 淡入中的情况下
  537.     if @fade_in
  538.       self.all_opa += 64
  539.       if self.all_opa >= 255
  540.         @fade_in = false
  541.       end
  542.       return
  543.     end
  544.     @now_text = nil if @now_text == ""
  545.     # 逐个描绘文字
  546.     if @now_text != nil && @mid_stop == false && !@text_skip
  547.       @write_wait = 0 if @write_skip
  548.       if @write_wait > 0
  549.         @write_wait -= 1
  550.         return
  551.       end
  552.       tmp_text_skip = false
  553.       while true
  554.         @max_x = @x if @max_x < @x
  555.         @max_y = @y if @max_y < @y
  556.         # 处理字符
  557.         if (c = @now_text.slice!(/./m)) != nil
  558.           is_c_invisible = Invisible_Chars.include?(c)
  559.           # \\的情况下
  560.           if c == "\000"
  561.             c = "\"
  562.           end
  563.           # \c的情况下
  564.           if c == "\001"
  565.             @now_text.sub!(/\[([0-9]+)\]/, "")
  566.             color = $1.to_i
  567.             if color >= 0 and color <= 30
  568.               self.contents.font.color = text_color(color)
  569.             end
  570.             c = ""
  571.           end
  572.           # \g的情况下
  573.           if c == "\002"
  574.             if @gold_window == nil && @popchar != "x" and @popchar <= 0 # ●●●【p[x]】
  575.               @gold_window = Window_Gold.new
  576.               @gold_window.x = 560 - @gold_window.width
  577.               if $game_temp.in_battle
  578.                 @gold_window.y = 192
  579.               else
  580.                 @gold_window.y = self.y >= 128 ? 32 : 384
  581.               end
  582.               @gold_window.opacity = self.opacity
  583.               @gold_window.back_opacity = self.back_opacity
  584.             end
  585.             c = ""
  586.           end
  587.           # \s的情况下
  588.           if c == "\003"
  589.             @now_text.sub!(/\[([0-9]+)\]/, "")
  590.             speed = $1.to_i
  591.             if speed >= 0 and speed <= 19
  592.               @write_speed = speed
  593.             end
  594.             c = ""
  595.           end
  596.           # \a的情况下
  597.           if c == "\004"
  598.             @now_text.sub!(/\[(.*?)\]/, "")
  599.             se_filename = "Audio/SE/#{$1}"
  600.             if FileTest.exist?(se_filename)
  601.               Audio.se_play(se_filename)
  602.             end
  603.             c = ""
  604.           end
  605.           # \.的情况下
  606.           if c == "\005"
  607.             @write_wait += 5
  608.             c = ""
  609.           end
  610.           # \|的情况下
  611.           if c == "\006"
  612.             @write_wait += 20
  613.             c = ""
  614.           end
  615.           # \>的情况下
  616.           if c == "\016"
  617.             tmp_text_skip = true
  618.             c = ""
  619.           end
  620.           # \<的情况下
  621.           if c == "\017"
  622.             tmp_text_skip = false
  623.             c = ""
  624.           end
  625.           # \!的情况下
  626.           if c == "\020"
  627.             # 当有其他跳过绘制功能的输入时,\! 无效
  628.             @mid_stop = true if !@write_skip
  629.             c = ""
  630.           end
  631.           # \~的情况下
  632.           if c == "\021"
  633.             terminate_message
  634.             return
  635.           end
  636.           # \i的情况下
  637.           if c == "\023"
  638.             @indent = @x
  639.             c = ""
  640.           end
  641.           # \o的情况下
  642.           if c == "\024"
  643.             @now_text.sub!(/\[([0-9]+)\]/, "")
  644.             @opacity = $1.to_i
  645.             c = ""
  646.           end
  647.           # \h的情况下
  648.           if c == "\025"
  649.             @now_text.sub!(/\[([0-9]+)\]/, "")
  650.             self.contents.font.size = [[$1.to_i, 6].max, 32].min
  651.             c = ""
  652.           end
  653.           # \b的情况下
  654.           if c == "\026"
  655.             @now_text.sub!(/\[([0-9]+)\]/, "")
  656.             @x += $1.to_i
  657.             c = ""
  658.           end
  659.           # 图标的情况
  660.           if c == "\030"
  661.             @now_text.sub!(/\[(.*?)\]/, "")
  662.             self.contents.blt(@x , @y * line_height + (line_height - 24) / 2, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  663.             if $game_system.soundname_on_speak != ""
  664.               Audio.se_play($game_system.soundname_on_speak)
  665.             end
  666.             @x += 24
  667.             c = ""
  668.           end
  669.           # 另起一行的情况下
  670.           if c == "\n"
  671.             if @lines >= $game_temp.choice_start
  672.               @cursor_width = [@cursor_width, @max_x - @face_indent].max
  673.             end
  674.             @lines += 1
  675.             @y += 1
  676.             @x = 0 + @indent + @face_indent
  677.             if @lines >= $game_temp.choice_start
  678.               @x = 8 + @indent + @face_indent
  679.             end
  680.             c = ""
  681.           end
  682.           # \` 的情况下
  683.           if c == "\077"
  684.             c = "`"
  685.           end
  686.           # `foo` 的情况下
  687.           if c == "\076"
  688.             @now_text = @protected.shift + @now_text
  689.             c = ""
  690.           end
  691.           if c != ""
  692.             # 文字描画
  693.             @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size) / 2, c, @opacity)
  694.             if $game_system.soundname_on_speak != "" then
  695.               Audio.se_play($game_system.soundname_on_speak)
  696.             end
  697.           end
  698.         else
  699.           break
  700.         end
  701.         # 当 c 包含实际内容时才进行下一次绘制
  702.         # 否则会绘制一个空字符,产生若干卡顿
  703.         if !$game_switches[No_Typing] && !@write_skip && !is_c_invisible && !tmp_text_skip
  704.           break
  705.         end
  706.       end
  707.       @write_wait += @write_speed
  708.       return
  709.     end
  710.     # 数值输入的处理
  711.     if @input_number_window != nil
  712.       @input_number_window.visible = true
  713.       @input_number_window.update
  714.       # 确认
  715.       if Input.trigger?(Input::C)
  716.         $game_system.se_play($data_system.decision_se)
  717.         $game_variables[$game_temp.num_input_variable_id] =
  718.           @input_number_window.number
  719.         $game_map.need_refresh = true
  720.         @input_number_window.dispose
  721.         @input_number_window = nil
  722.         terminate_message
  723.       end
  724.       return
  725.     end
  726.     # 跳过对话
  727.     if @text_skip
  728.       @now_text = nil
  729.       terminate_message
  730.       return
  731.     end
  732.     # 文章显示中的情况下
  733.     if @contents_showing
  734.       if $game_temp.choice_max == 0
  735.         self.pause = true
  736.       end
  737.       # auto terminate
  738.       if $game_temp.choice_max == 0 && @auto_terminate > 0
  739.         @auto_terminate -= 1
  740.         if @auto_terminate == 0
  741.           terminate_message
  742.         end
  743.         return
  744.       end
  745.       # 取消
  746.       if Input.trigger?(Input::B)
  747.         if $game_temp.choice_max > 0 && $game_temp.choice_cancel_type > 0
  748.           $game_system.se_play($data_system.cancel_se)
  749.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  750.           terminate_message
  751.         end
  752.       end
  753.       # 确定
  754.       if Input.trigger?(Input::C)
  755.         if @mid_stop
  756.           @mid_stop = false
  757.           return
  758.         else
  759.           if $game_temp.choice_max > 0
  760.             $game_system.se_play($data_system.decision_se)
  761.             $game_temp.choice_proc.call(self.index)
  762.           end
  763.           terminate_message
  764.         end
  765.       end
  766.       return
  767.     end
  768.     if self.visible
  769.       if $game_switches[No_Fade]
  770.         $game_temp.message_window_showing = false
  771.         self.visible = false
  772.       else # 4 帧淡出
  773.         @fade_out = true
  774.         self.opacity -= 64
  775.         if self.opacity == 0
  776.           self.visible = false
  777.           @fade_out = false
  778.           $game_temp.message_window_showing = false
  779.         end
  780.       end
  781.       return
  782.     end
  783.     if @fade_out == false and $game_temp.message_text != nil
  784.       @contents_showing = true
  785.       $game_temp.message_window_showing = true
  786.       refresh
  787.       Graphics.frame_reset
  788.       self.visible = true
  789.       if $game_switches[No_Fade]
  790.         self.all_opa = 255
  791.       else
  792.         self.all_opa = 0
  793.         @fade_in = true
  794.       end
  795.       return
  796.     end
  797.   end
  798.   #--------------------------------------------------------------------------
  799.   # ● 预览实际描绘内容(计算窗口宽用)
  800.   #--------------------------------------------------------------------------
  801.   #    实际对 @text_save 进行操作
  802.   #    此方法用于去除某些控制码引起窗口过长的影响
  803.   #--------------------------------------------------------------------------
  804.   def process_real_text
  805.     return if @text_save.nil?
  806.     regex = /[\001-\006\016\017\020\021\024](\[.*?\]){0,1}/
  807.     regex30 = /\030\[.*?\]/
  808.     @text_save.gsub!(regex, "")
  809.     @text_save.gsub!(regex30, "   ")
  810.   end
  811.   #--------------------------------------------------------------------------
  812.   # ● 获得角色(\p功能)
  813.   #--------------------------------------------------------------------------
  814.   def get_character(parameter)
  815.     case parameter
  816.     when 0
  817.       return $game_player
  818.     else
  819.       events = $game_map.events
  820.       return events == nil ? nil : events[parameter]
  821.     end
  822.   end
  823.   #--------------------------------------------------------------------------
  824.   # ● 获得战斗者(\p功能,此功能仅在战斗中有效)
  825.   #--------------------------------------------------------------------------
  826.   #    parameter : 1-999 表示主角 ID,1001-1008 表示索引为1-8的各个敌人
  827.   #--------------------------------------------------------------------------
  828.   def get_battler(parameter)
  829.     if parameter < 1000
  830.       return $game_actors[parameter]
  831.     else
  832.       return $game_troop.enemies[parameter - 1001]
  833.     end
  834.   end
  835.   #--------------------------------------------------------------------------
  836.   # ● 计算 y 偏移量(\p功能,这是考虑到不同战斗图/行走图的高度不同)
  837.   #--------------------------------------------------------------------------
  838.   #    character : 角色/战斗者
  839.   #--------------------------------------------------------------------------
  840.   def process_y_shift(character)
  841.     rate = character.is_a?(Game_Battler) ? 1 : 4
  842.     bmp = character.is_a?(Game_Battler) ?
  843.       RPG::Cache.battler(character.battler_name, character.battler_hue) :
  844.       RPG::Cache.character(character.character_name, character.character_hue)
  845.     return bmp.height / rate + 16
  846.   end
  847.   #--------------------------------------------------------------------------
  848.   # ● 更新窗口位置(所有组件)
  849.   #--------------------------------------------------------------------------
  850.   def update_window_pos
  851.     # 如果使用了 \p 设置位置 ●●●【p[x]】 添加了 获取当前对话的事件character
  852.     if @popchar == "x" or @popchar >= 0
  853.       # 原有的 !
  854.       if @popchar != "x"
  855.         character = $game_temp.in_battle ? get_battler(@popchar) : get_character(@popchar)
  856.       end
  857.       # 获取当前事件 ●●●【p[x]】
  858.       if @popchar == "x"
  859.         if $对话_触发的事件 != nil
  860.           character = $对话_触发的事件
  861.         else
  862.           character = get_character(0)
  863.         end
  864.       end

  865.       final_pos = $game_system.message_position
  866.       if character != nil
  867.         x = [[character.screen_x - self.width / 2, 4].max, Graphics_Width - 4 - self.width].min
  868.         # adjust final_pos automatically when it is enabled
  869.         # ignore the case when pos == 1
  870.         if $game_switches[Auto_Adjust_Mes_Pos] && final_pos != 1
  871.           # try default mes_pos first
  872.           temp_y = final_pos == 2 ? [character.screen_y + 16, 4].max :
  873.             character.screen_y - process_y_shift(character) - self.height
  874.          
  875.           # set pos == 0 if temp_y exceeds the boundary of the screen
  876.           final_pos = 0 if temp_y > Graphics_Height - 4 - self.height && final_pos == 2
  877.           final_pos = 2 if temp_y < 4 && final_pos == 0
  878.         end
  879.         if final_pos == 2
  880.           y = [[character.screen_y + 16, 4].max, Graphics_Height - 4 - self.height].min
  881.         elsif final_pos == 0
  882.           y = [[character.screen_y - process_y_shift(character) - self.height, 4].max, Graphics_Height - 4 - self.height].min
  883.         else
  884.           x = (Graphics_Width - self.width) / 2
  885.           y = (Graphics_Height - self.height) / 2
  886.         end
  887.         self.x = x
  888.         self.y = y
  889.         # 设置气泡图标
  890.         if @k_tale != nil
  891.           @k_tale.x = character.is_a?(Game_Character) ?
  892.             ( character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 16 :
  893.             character.screen_x
  894.           k_tale_filename = Mes_Windowskin == "" ? $game_system.windowskin_name : Mes_Windowskin
  895.           suffix = final_pos == 2 ? "-under" : "-top"
  896.           # reload @k_tale's bitmap
  897.           @k_tale.bitmap = RPG::Cache.windowskin(k_tale_filename + suffix)
  898.           if final_pos == 2
  899.             @k_tale.y = self.y - 16
  900.           elsif final_pos == 0
  901.             @k_tale.y = self.y + self.height - 16
  902.           else
  903.             @k_tale.visible = false
  904.           end
  905.           @k_tale.z = 9999
  906.         end
  907.       end
  908.     elsif @popchar == -1
  909.       self.x = 0
  910.       self.y = Graphics_Height - self.height
  911.     else # 无 \p 的情况下
  912.       self.x = (Graphics_Width - self.width) / 2
  913.       # 处于战斗中时
  914.       if $game_temp.in_battle
  915.         self.y = 16
  916.       else
  917.         # 显示文章位置的分支
  918.         case $game_system.message_position
  919.         when 0 # 上
  920.           self.y = 16
  921.         when 1 # 中
  922.           self.y = (Graphics_Height - self.height) / 2
  923.         when 2 # 下
  924.           self.y = (Graphics_Height - self.height - 16)
  925.         end
  926.       end
  927.     end # of @popchar >= 0
  928.     # 设置左侧立绘
  929.     if @left_picture != nil and !@left_picture.disposed?
  930.       @left_picture.x = self.x + 8
  931.       @left_picture.y = self.y - @left_picture.bitmap.height + self.height - 8
  932.       @left_picture.z = self.z + 4
  933.     end
  934.     # 设置右侧立绘
  935.     if @right_picture != nil and !@right_picture.disposed?
  936.       @right_picture.x = self.x + self.width - @right_picture.bitmap.width - 8
  937.       @right_picture.y = self.y - @right_picture.bitmap.height + self.height - 8
  938.       @right_picture.z = self.z + 4
  939.     end
  940.     # 设置姓名空气文字坐标
  941.     if @name_window_text != nil
  942.       @name_window_text.x = self.x + @face_indent - 4
  943.       @name_window_text.y = self.y
  944.     end
  945.     # 设置姓名蓝条坐标
  946.     if @bar != nil
  947.       face_cut = @face_bitmap == nil ? 0 : @face_indent + 2
  948.       @bar.x = self.x + 8 + face_cut
  949.       @bar.y = self.y + 16
  950.     end
  951.     # 设置数字处理
  952.     if @input_number_window != nil
  953.       @input_number_window.x = self.x + @face_indent
  954.       @input_number_window.y = self.y + 8 + $game_temp.num_input_start * line_height
  955.     end
  956.   end
  957.   #--------------------------------------------------------------------------
  958.   # ● line_height
  959.   #--------------------------------------------------------------------------
  960.   # 返回值 : 行高
  961.   #--------------------------------------------------------------------------
  962.   def line_height
  963.     return [[Size * 15 / 10, 18].max, 32].min
  964.   end
  965.   #--------------------------------------------------------------------------
  966.   # ● 文字描画
  967.   #--------------------------------------------------------------------------
  968.   # target :描绘的目标 bitmap 对象
  969.   # x      :x 坐标
  970.   # y      :y 坐标
  971.   # str   :描绘的文字
  972.   # opacity:不透明度(0~255)
  973.   # 返回值 :文字宽度(@x 的增加值)。
  974.   #--------------------------------------------------------------------------
  975.   def opacity_draw_text(target, x, y, str,opacity)
  976.     height = target.font.size
  977.     width = target.text_size(str).width
  978.     opacity = [[opacity, 0].max, 255].min
  979.     if opacity == 255
  980.       target.draw_text(x, y, width, height, str)
  981.       return width
  982.     else
  983.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  984.         @opacity_text_buf.dispose
  985.         @opacity_text_buf = Bitmap.new(width, height)
  986.       else
  987.         @opacity_text_buf.clear
  988.       end
  989.       @opacity_text_buf.font.size = target.font.size
  990.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  991.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  992.     return width
  993.     end
  994.   end
  995.   #--------------------------------------------------------------------------
  996.   # ● \V 变换
  997.   #--------------------------------------------------------------------------
  998.   # option : 选项,'i'物品,'w'武器,'a'防具,'s'技能
  999.   # index  : 数据库的索引
  1000.   #--------------------------------------------------------------------------
  1001.   def convart_value(option, index)
  1002.     option == nil ? option = "" : nil
  1003.     option.downcase!
  1004.     case option
  1005.       when "i"
  1006.         unless $data_items[index].name == nil
  1007.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  1008.         end
  1009.       when "w"
  1010.         unless $data_weapons[index].name == nil
  1011.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  1012.         end
  1013.       when "a"
  1014.         unless $data_armors[index].name == nil
  1015.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  1016.         end
  1017.       when "s"
  1018.         unless $data_skills[index].name == nil
  1019.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  1020.         end
  1021.       else
  1022.       r = $game_variables[index]
  1023.     end
  1024.     r == nil ? r = "" : nil
  1025.     return r
  1026.   end
  1027.   #--------------------------------------------------------------------------
  1028.   # ● 释放
  1029.   #--------------------------------------------------------------------------
  1030.   def dispose
  1031.     terminate_message
  1032.     unless @opacity_text_buf.disposed?
  1033.       @opacity_text_buf.dispose
  1034.     end
  1035.     $game_temp.message_window_showing = false
  1036.     if @input_number_window != nil
  1037.       @input_number_window.dispose
  1038.     end
  1039.     super
  1040.   end
  1041.   #--------------------------------------------------------------------------
  1042.   # ● 刷新光标矩形
  1043.   #--------------------------------------------------------------------------
  1044.   def update_cursor_rect
  1045.     if @index >= 0
  1046.       n = $game_temp.choice_start + @index
  1047.       self.cursor_rect.set(4 + @indent + @face_indent, n * line_height, @cursor_width, line_height)
  1048.     else
  1049.       self.cursor_rect.empty
  1050.     end
  1051.   end
  1052.   #--------------------------------------------------------------------------
  1053.   # ● 设置不透明度(所有组件)
  1054.   #--------------------------------------------------------------------------
  1055.   def all_opa=(opa)
  1056.     opa = [255, [opa, 0].max].min
  1057.     @all_opa = opa
  1058.     if $game_system.message_frame == 0
  1059.       self.opacity = opa
  1060.       @k_tale.opacity = opa if @k_tale
  1061.     else
  1062.       self.opacity = 0
  1063.       @k_tale.opacity = 0 if @k_tale
  1064.     end
  1065.     self.contents_opacity = opa
  1066.     @gold_window.opacity = opa if @gold_window
  1067.     @name_window_text.contents_opacity = opa if @name_window_text
  1068.     @right_picture.opacity = opa if @right_picture
  1069.     @left_picture.opacity = opa if @left_picture
  1070.     @bar.opacity = opa if @bar
  1071.   end
  1072.   #--------------------------------------------------------------------------
  1073.   # ● 获取不透明度(所有组件)
  1074.   #--------------------------------------------------------------------------
  1075.   def all_opa
  1076.     @all_opa
  1077.   end
  1078. end
  1079. #==============================================================================
  1080. # ■ Air_Text
  1081. #------------------------------------------------------------------------------
  1082. #   空气文字,借助窗口显示文字,但是不显示窗口载体。
  1083. #==============================================================================
  1084. class Air_Text < Window_Base
  1085.   #--------------------------------------------------------------------------
  1086.   # ● 对象初始化
  1087.   #--------------------------------------------------------------------------
  1088.   def initialize(x, y, designate_text, color)
  1089.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  1090.     self.opacity = 0
  1091.     self.back_opacity = 0
  1092.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  1093.     self.contents.font.size = 20
  1094.     self.contents.font.color = color
  1095.     w = self.contents.width
  1096.     h = self.contents.height
  1097.     self.contents.draw_text(0, 0, w, h, designate_text)
  1098.   end
  1099.   #--------------------------------------------------------------------------
  1100.   # ● 释放
  1101.   #--------------------------------------------------------------------------
  1102.   def dispose
  1103.     self.contents.clear
  1104.     super
  1105.   end
  1106. end

  1107. class Interpreter
  1108.   include RB::Mes_Config
  1109.   #--------------------------------------------------------------------------
  1110.   # ● 显示文章
  1111.   #--------------------------------------------------------------------------
  1112.   def command_101
  1113.     # 另外的文章已经设置过 message_text 的情况下
  1114.     if $game_temp.message_text != nil
  1115.       # 结束
  1116.       return false
  1117.     end
  1118.     # 设置信息结束后待机和返回调用标志
  1119.     @message_waiting = true
  1120.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  1121.     # message_text 设置为 1 行
  1122.     # check whether \+ exists
  1123.     append = /\\\+$/ =~ @list[@index].parameters[0]
  1124.     line = @list[@index].parameters[0].sub(/\\\+$/, "")
  1125.     $game_temp.message_text = line + "\n"
  1126.     line_count = 1
  1127.     # 循环
  1128.     loop do
  1129.       # 下一个事件指令为文章两行以上的情况
  1130.       if @list[@index+1].code == 401 || @list[@index+1].code == 101 && append
  1131.         append = /\\\+$/ =~ @list[@index+1].parameters[0]
  1132.         line = @list[@index+1].parameters[0].sub(/\\\+$/, "")
  1133.         # message_text 添加到第 2 行以下
  1134.         $game_temp.message_text += line + "\n"
  1135.         line_count += 1
  1136.       # 事件指令不在文章两行以下的情况
  1137.       else
  1138.         # 下一个事件指令为显示选择项的情况下
  1139.         if @list[@index+1].code == 102
  1140.           # 如果选择项能收纳在画面里
  1141.           if @list[@index+1].parameters[0].size <= Max_Lines - line_count
  1142.             # 推进索引
  1143.             @index += 1
  1144.             # 设置选择项
  1145.             $game_temp.choice_start = line_count
  1146.             setup_choices(@list[@index].parameters)
  1147.           end
  1148.         # 下一个事件指令为处理输入数值的情况下
  1149.         elsif @list[@index+1].code == 103
  1150.           # 如果数值输入窗口能收纳在画面里
  1151.           if line_count < Max_Lines
  1152.             # 推进索引
  1153.             @index += 1
  1154.             # 设置输入数值
  1155.             $game_temp.num_input_start = line_count
  1156.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  1157.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  1158.           end
  1159.         end
  1160.         # 继续
  1161.         return true
  1162.       end
  1163.       # 推进索引
  1164.       @index += 1
  1165.     end
  1166.   end
  1167. end

  1168. class Scene_Map
  1169.   include RB::Mes_Config
  1170.   alias rb_update_20160408 update
  1171.   def update
  1172.     if @rb_mes_disabled != $game_switches[Mes_Disabled]
  1173.       @rb_mes_disabled = $game_switches[Mes_Disabled]
  1174.       @message_window.dispose if @message_window != nil
  1175.       @message_window = @rb_mes_disabled ? Window_Message.new : Window_Message_RB.new
  1176.     end
  1177.     rb_update_20160408
  1178.   end
  1179. end

  1180. class Scene_Battle
  1181.   include RB::Mes_Config
  1182.   alias rb_update_20160408 update
  1183.   def update
  1184.     if @rb_mes_disabled != $game_switches[Mes_Disabled]
  1185.       @rb_mes_disabled = $game_switches[Mes_Disabled]
  1186.       @message_window.dispose if @message_window != nil
  1187.       @message_window = @rb_mes_disabled ? Window_Message.new : Window_Message_RB.new
  1188.     end
  1189.     rb_update_20160408
  1190.   end
  1191. end


  1192. #==============================================================================
  1193. # 本脚本来自[url]https://rpg.blue[/url],使用和转载请保留此信息
  1194. #==============================================================================

  1195. # 用于获取当前对话事件的对象
  1196. class Interpreter
  1197.   def get_event_now_for_对话
  1198.     # 获取地图上的所有事件
  1199.     events = $game_map.events
  1200.     if events == nil
  1201.       event_now = nil
  1202.     else
  1203.       event_now = events[@event_id]
  1204.     end
  1205.     # 如果触发的事件对象发生了改变,则初始化临时变量
  1206.     # ===========================================
  1207.     if $对话_触发的事件  != event_now
  1208.       # 将坐标的全局变量变为默认
  1209.       $对话_触发的事件  = nil
  1210.     end
  1211.     # ===========================================
  1212.     # $对话_触发的事件  用于记录对话的事件character对象
  1213.     if event_now != nil
  1214.       $对话_触发的事件  = event_now
  1215.     else
  1216.       $对话_触发的事件  = nil
  1217.     end
  1218.   end

  1219.   alias command_101_获取位置 command_101
  1220.   def command_101
  1221.     get_event_now_for_对话
  1222.     command_101_获取位置
  1223.   end
  1224. end
复制代码
回复

使用道具 举报

梦石
0
星屑
292
在线时间
68 小时
注册时间
2022-11-22
回帖
9
发表于 2022-12-22 18:45:39 | 显示全部楼层
怎么办,好喜欢这个脚本的功能,唯一美中不足的就是气泡框的样式,要是能像fuki或是月夜响荡曲里面的气泡样式就更好了。
回复

使用道具 举报

梦石
0
星屑
10
在线时间
0 小时
注册时间
2022-12-28
回帖
1
发表于 2022-12-28 12:12:50 | 显示全部楼层
感谢楼主
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部