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

Project1

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

[已经过期] 求問怎麼把這腳本的選擇項移動到中間選擇?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
755
在线时间
1 小时
注册时间
2015-4-1
帖子
3
跳转到指定楼层
1
发表于 2015-4-3 21:09:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
新手表示改了Window_Command內沒有效果
所以才求問,請高手支招。

RUBY 代码复制
  1. #==============================================================================
  2. # ■ [VX] 对话框加强版
  3. #    [VX] Window_message Plus
  4. #----------------------------------------------------------------------------
  5. # 此脚本可代替官方 Window_Message 全脚本
  6. #----------------------------------------------------------------------------
  7. # 使用说明:
  8. #
  9. #   ⑴ 对话框第一行输入引号内文字"名称:",脚本会把名称提取出来美化显示
  10. #      例如"张三:",显示为"【张三】" ,美化符可在参数设定中修改
  11. #
  12. #   ⑵ 默认头像在左边显示
  13. #      当您需要右边显示时,在第一行输入的名称时加"\r"(大小写不限)
  14. #      例: "拉尔夫\r:"
  15. #          请注意此时头像将进行左右翻转显示
  16. #
  17. #   ⑶ 在对话中更改字体的方法:
  18. #       \f[sX]:更改字号为X
  19. #       \f[nX]:更改字体名称为"预设字体库"第X号字体(预设字体库请看参数设定)
  20. #              更改字体名称失败(无指定字体或字体损坏)时,启用游戏默认字体
  21. #       \f[cX]:更改字色为第X号颜色 (text_color中的定义)
  22. #       \f[c#FF0000]:使用16进制指定字体颜色,如本句表示红色
  23. #       \f[aX]:更改字体附加效果为第X号效果
  24. #       附加样式列表:
  25. #         X=0 :无附加; X=1 :阴影字; X=2 :粗体字;
  26. #         X=4 :斜体字; X=8 :描边字; X=16:发光字
  27. #              叠加效果即数字相加,示例: 3:阴影+粗体  14:粗体+斜体+描边
  28. #              注意!此三种效果互斥: 阴影/描边/发光
  29. #
  30. #   ⑷ 在对话中显示(技能 物品 武器 防具)图标和名称的方法:
  31. #       \s[X]: 显示第X号技能图标和名称
  32. #       \i[X]: 显示第X号物品图标和名称
  33. #       \w[X]: 显示第X号武器图标和名称
  34. #       \a[X]: 显示第X号防具图标和名称
  35. #
  36. #   ⑸ 在对话中更改文字不透明度的方法:
  37. #       \o[X]: 把文字不透明度更改为X (取值范围在0~255)
  38. #
  39. #   ⑹ 指定时间后自动关闭对话框的方法:
  40. #       \x[X]: 对话框将在X帧后自动关闭
  41. #       \x:    省略参数时,将于AutoClose帧后自动关闭(AutoClose值在参数设定中)
  42. #
  43. #   ⑺ 调整文字显示速度的方法:
  44. #       \p[X]: 文字在X帧后显示
  45. #
  46. #   ⑻ 对话中更换对话框皮肤(或直接使用图片)的方法:
  47. #       \b[X]: 更改字体名称为"预设样式库"第X号样式 (预设样式库请看参数设定)
  48. #              注: vx对话框可使用Window皮肤或直接使用图片,请配合事件页设定
  49. #
  50. #      素材格式和命名规则:
  51. #       在对应的Window皮肤或对话框图片的文件名后+"_pause",做为自定义暂停标记
  52. #       的名称,并和对应皮肤或图片文件放在一起.
  53. #
  54. #   ⑼ 启用头像动态显示的方法:
  55. #       \e[X]: 设定头像动态显示的值为X
  56. #       X=0 :关闭动态效果; X=1 :水平趋中; X=2 :渐显
  57. #
  58. #   ⑽ 在对话中更换头像:
  59. #       \@[X]: 设定头像索引号为X X值范围0-7
  60. #              可更改的仅是索引号,头像文件名称不可改 主要用于对话中换表情
  61. #
  62. #   ⑾ 输入文章时设定冻结字符和注释字符:
  63. #       #[XX]: 字符串XX被冻结,不受转义等影响直接显示
  64. #       #<XX>: 字符串XX被当作注释,显示文章时不出现
  65. #------------------------------------------------------------------------------
  66. # 素材要求:
  67. #
  68. #   ① 采用vx默认头像素材(Graphics\Faces)的格式
  69. #      即每个素材文件由2行4列共8格头像组成
  70. #
  71. #   ② 要求所有头像朝向一致(默认是正面偏右)
  72. #
  73. #   ③ 自定义暂停标记的素材采用横向多帧格式,每帧图片大小一致
  74. #      注意: 帧数在脚本参数中设定.
  75. #      在对应的Window皮肤或对话框图片的文件名后+"_pause",做为自定义暂停标记
  76. #      的名称,并和对应皮肤或图片文件放在一起.
  77. #------------------------------------------------------------------------------
  78. # 合并功能附加说明:
  79. #
  80. #   ① 对话框合并
  81. #      头像、背景、位置等相同的上下两段对话都会被合并成一段对话;
  82. #      如果要打断合并,请在两段对话之间加个非对话框的执行项,比如空注释.
  83. #
  84. #   ② 选择项合并
  85. #      当前选项组满4项,且取消设定不为"分歧",且下一个执行项也是选择组,就合并;
  86. #      取消键的规定: 如果有"分歧",必须设定在最后一个选项组,其它不限.
  87. #                    合并后最多只有一个取消设定,多个设定时,仅最后一个有效.
  88. #----------------------------------------------------------------------------
  89. #    更新作者: 沉影不器
  90. #    许可协议: FSL
  91. #    项目版本: 1.09.1031
  92. #    引用网址: [url]http://rpg.blue/thread-158161-1-1.html[/url]
  93. #----------------------------------------------------------------------------
  94. #    - *1.09.1031* (2010-10-31) By 沉影不器
  95. #      *新增 指定被冻结的字符串
  96. #      *新增 允许字符串做为注释
  97. #
  98. #    - *1.08.1030* (2010-10-30) By 沉影不器
  99. #      *新增 对话中更改头像
  100. #      *新增 允许指定16进制颜色为字色
  101. #      *修改 取消对话中切换[是否独立显示选项窗体]的开关
  102. #
  103. #    - *1.07.1029* (2010-10-29) By 沉影不器
  104. #      *优化 重写合并选择项的功能,大幅降低冲突
  105. #
  106. #    - *1.06.1026* (2010-10-26) By 沉影不器
  107. #      *修改 头像在右的控制符改为"\r"(大小写不限)
  108. #      *优化 改变字体失败时使用默认字体
  109. #      *新增 允许独立显示选项窗体
  110. #      *新增 合并多个事件页选项(突破4选项上限)
  111. #
  112. #    - *1.05.1007* (2010-10-07) By 沉影不器
  113. #      *修复 冒号被脚本占用而无法显示
  114. #      *优化 预处理部分数据
  115. #      *新增 自定义暂停标记
  116. #      *新增 全局和局部字速调整
  117. #      *新增 支持滚动显示多行对话内容
  118. #      *新增 显示动画功能(数据库动画/心情动画)
  119. #
  120. #    - *1.04.0207* (2009-02-07) By 沉影不器
  121. #      *新增 字体附加效果:发光字
  122. #      *新增 更换对话皮肤功能
  123. #      *新增 头像动态显现功能
  124. #
  125. #    - *1.03.1107* (2008-11-07) By 沉影不器
  126. #      *优化 字体附加效果的叠加方法
  127. #      *新增 字体附加效果:斜体字
  128. #
  129. #    - *1.02.1023* (2008-10-23) By 沉影不器
  130. #      *修复 自动关闭对话框时可能存在的关闭延后生效
  131. #      *新增 字体附加效果:无效果、阴影字、粗体字、描边字
  132. #      *新增 更改字体无效时,使用游戏默认字体
  133. #
  134. #    - *1.01.0911* (2008-09-11) By 沉影不器
  135. #      *新增 更改字体功能
  136. #      *新增 显示(技能 物品 武器 防具)图标和名称
  137. #      *新增 更改文字不透明度
  138. #      *新增 自动关闭对话框
  139. #
  140. #    - *1.00.0831* (2008-08-31) By 沉影不器
  141. #      *初版
  142. #==============================================================================
  143. $fscript = {} if $fscript == nil
  144. $fscript["Window_message_Plus"] = "1.09.1031"
  145. #----------------------------------------------------------------------------
  146. # ▼ 通用配置模块
  147. #----------------------------------------------------------------------------
  148. module FSL
  149.   module Window_message_Plus
  150.     ## 对话框的预设样式库(其中"Window"和"MessageBack"是vx默认样式)
  151.     Msg_StyleLib = {0=>["Window","Sinicism"],   ## Window皮肤
  152.                     1=>["MessageBack","Black"]} ## 图片皮肤
  153.  
  154.     ## 字体参数
  155.     Font_Lib = ["黑体", "仿宋_GB2312", "幼圆"]  ## 预设字体库
  156.     Font_Space = 4                              ## 字间距
  157.     EdgeColor = 15                              ## 描边颜色
  158.     GlowColor = 10                              ## 发光颜色
  159.  
  160.     ## 名称条参数
  161.     Name_Symbol = "【】"         ## 为名称添加的修饰符(一对)
  162.     Name_SpaceX = 6              ## 名称条宽度缩进值
  163.     Name_SpaceY = 6              ## 名称与对话内容之间的附加距离
  164.     Name_FontIndex = 0           ## 名称文字字体在预设字体库中的序号
  165.     Name_FontSize = 18           ## 名称文字字号
  166.     Name_FontColor = 16          ## 名称文字颜色
  167.     Name_FontAdj = 1             ## 名称文字附加效果
  168.     NameBar_Color = 0            ## 名称背景条颜色
  169.     NameBar_Opacity = 64         ## 名称背景条透明度
  170.  
  171.     ## 头像参数
  172.     Face_Enter = 0               ## 头像显示模式
  173.     Face_EnterRate = 12          ## 头像进入画面的时间   
  174.     Face_AdjX = 10                ## 头像横坐标微调
  175.     Face_AdjY = -6               ## 头像纵坐标微调
  176.     Face_Align = 2               ## 头像垂直对齐方式
  177.                                  ## 0:顶端对齐; 1:居中对齐; 2:底端对齐
  178.  
  179.     ## 对话框参数
  180.     Msg_FontName = 1             ## 对话文字字体在预设字体库中的序号
  181.     Msg_FontSize = 16            ## 对话文字字号
  182.     Msg_FontColor = 0            ## 对话文字颜色
  183.     Msg_FontPlus = 1             ## 对话文字附加效果
  184.  
  185.     ## 全局功能参数
  186.     FastShow = true              ## 确定键快速显示文字
  187.     AutoClose = 80               ## 默认自动关闭时间(以帧计时)
  188.     GlobalSpeed = 0              ## 改变全局文字延时(以帧计时)
  189.  
  190.     ## 自定义暂停标记
  191.     Pause_Custom = 3    ## 位置(0:不使用 1:底边居中 2:右下角 3:跟随文字)
  192.     Pause_AdjX = -2     ## X坐标微调
  193.     Pause_AdjY = -2     ## Y坐标微调
  194.     Pause_AniCyc = 6    ## 动画周期
  195.     Pause_AniFrm = 4    ## 动画帧数
  196.  
  197.     ## 对话和选择项合并
  198.     MultiLinesWait = 30 ## 滚动显示对话的等待时间(0表示禁止合并多段对话)
  199.     Choice_Strip = true ## 是否单独显示选项窗体
  200.                         ## 注: 选择项合并功能仅在单独显示的选项窗体生效
  201.     Choice_MaxLines = 4 ## 选项窗体的最大行数(0表示禁止合并多段选择项)
  202.                         ## 注: 本参数仅在单独显示选项窗体时生效
  203.   end
  204. end
  205. #==============================================================================
  206. # ■ Window_Message
  207. #==============================================================================
  208. class Window_Message < Window_Selectable
  209.   include FSL::Window_message_Plus
  210.   #--------------------------------------------------------------------------
  211.   # ● 常量
  212.   #--------------------------------------------------------------------------
  213.   MAX_LINE = 4                            # 最大行数
  214.   #--------------------------------------------------------------------------
  215.   # ◎ 初始化对象
  216.   #--------------------------------------------------------------------------
  217.   def initialize
  218.     h = [Name_FontSize,Msg_FontSize].max + Name_SpaceY +
  219.          (Msg_FontSize+Font_Space)*(MAX_LINE-1) + 34
  220.     y = Graphics.height - h
  221.     super(0, y, Graphics.width, h)
  222.     self.z = 200
  223.     self.active = false
  224.     self.index = -1
  225.     self.openness = 0
  226.     @opening = false            # 窗体正在打开的标志
  227.     @closing = false            # 窗体正在关闭的标志
  228.     @text = nil                 # 已经没有可显示的文章
  229.     @contents_x = 0             # 下一条文字描绘的 X 坐标
  230.     @contents_y = 0             # 下一条文字描绘的 Y 坐标
  231.     @line_count = 0             # 现在描绘的行数
  232.     @wait_count = 0             # 等待计数
  233.     @background = 0             # 背景类型
  234.     @position = 2               # 显示位置
  235.     @show_fast = false          # 快速显示标志
  236.     @line_show_fast = false     # 以行为单位快速显示
  237.     @pause_skip = false         # 省略等待输入标志
  238.     ## 冻结字符池
  239.     @frozen_char = []
  240.     ## 显示名称
  241.     @show_name = false
  242.     ## 自定义暂停标记
  243.     @custom_pause = false if Pause_Custom > 0
  244.     ## 多行对话框标记
  245.     @multi_lines = false
  246.     ## 字体附加效果
  247.     @font_adj = Msg_FontPlus
  248.     create_gold_window
  249.     create_number_input_window
  250.     create_back_sprite
  251.     ## 头像左右判断
  252.     @show_right = false
  253.     ## 头像宽度
  254.     @face_width = 0
  255.     ## 生成自定义暂停标记
  256.     create_custom_pause
  257.     ## 生成名称背景条
  258.     create_namebar_sprite
  259.     ## 生成头像
  260.     create_face_sprite
  261.     ## 修改默认字体
  262.     contents.font = default_font
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● 释放
  266.   #--------------------------------------------------------------------------
  267.   def dispose
  268.     super
  269.     dispose_gold_window
  270.     dispose_number_input_window
  271.     dispose_back_sprite
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # ◎ 更新画面
  275.   #--------------------------------------------------------------------------
  276.   def update
  277.     super
  278.     update_gold_window
  279.     update_number_input_window
  280.     update_back_sprite
  281.     update_show_fast
  282.     ## 更新自定义暂停标记
  283.     update_custom_pause
  284.     unless @opening or @closing             # 除窗体关闭以外
  285.       if @wait_count > 0                    # 文章内等待中
  286.         @wait_count -= 1
  287.       elsif @multi_lines
  288.         scroll_line
  289.       elsif custom_pause                    # 等待文章翻页待机中
  290.         input_pause
  291.       elsif self.active || @choice         ## 正在输入选择项
  292.         input_choice
  293.       elsif @number_input_window.visible    # 正在输入数值
  294.         input_number
  295.       elsif @text != nil                    # 还有剩余的文章
  296.         update_message                        # 更新消息
  297.       elsif continue?                       # 继续的情况
  298.         start_message                         # 开始消息
  299.         open                                  # 打开窗体
  300.         $game_message.visible = true
  301.       else                                  # 不继续的情况
  302.         close                                 # 关闭窗体
  303.         $game_message.visible = @closing
  304.       end
  305.     end
  306.     ## 头像动态显现
  307.     if @face_sprite.visible
  308.       ## 水平趋中
  309.       result =  @face_x <=> @face_sprite.x
  310.       x_enter = [(@face_x - @face_sprite.x).abs,Face_EnterRate].min
  311.       @face_sprite.x += x_enter if result > 0
  312.       @face_sprite.x -= x_enter if result < 0
  313.       ## 渐显
  314.       @face_sprite.opacity += Face_EnterRate if @face_sprite.opacity < 255
  315.     end
  316.     ## 自动关闭对话框
  317.     if @auto_close != nil
  318.       if @auto_close > 0
  319.         @auto_close -= 1
  320.       else
  321.         terminate_message
  322.       end
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ◎ 生成所持金窗体
  327.   #--------------------------------------------------------------------------
  328.   def create_gold_window
  329.     @gold_window = Window_Gold.new(384, 0)
  330.     @gold_window.openness = 0
  331.     ## 统一字体
  332.     @gold_window.contents.font = default_font
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ◎ 生成数值输入窗体
  336.   #--------------------------------------------------------------------------
  337.   def create_number_input_window
  338.     @number_input_window = Window_NumberInput.new
  339.     @number_input_window.visible = false
  340.     ## 统一字体
  341.     @number_input_window.contents.font = default_font
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # ● 生成背景活动块
  345.   #--------------------------------------------------------------------------
  346.   def create_back_sprite
  347.     @back_sprite = Sprite.new
  348.     @back_sprite.bitmap = Cache.system("MessageBack")
  349.     @back_sprite.visible = (@background == 1)
  350.     @back_sprite.z = 190
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● 释放所持金窗体
  354.   #--------------------------------------------------------------------------
  355.   def dispose_gold_window
  356.     @gold_window.dispose
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 释放数值输入窗体
  360.   #--------------------------------------------------------------------------
  361.   def dispose_number_input_window
  362.     @number_input_window.dispose
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 释放背景活动块
  366.   #--------------------------------------------------------------------------
  367.   def dispose_back_sprite
  368.     @back_sprite.dispose
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● 更新所持金窗体
  372.   #--------------------------------------------------------------------------
  373.   def update_gold_window
  374.     @gold_window.update
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 更新数值输入窗体
  378.   #--------------------------------------------------------------------------
  379.   def update_number_input_window
  380.     @number_input_window.update
  381.   end
  382.   #--------------------------------------------------------------------------
  383.   # ● 更新背景活动块
  384.   #--------------------------------------------------------------------------
  385.   def update_back_sprite
  386.     @back_sprite.visible = (@background == 1)
  387.     @back_sprite.y = y - 16
  388.     @back_sprite.opacity = openness
  389.     @back_sprite.update
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ◎ 更新快速显示标志
  393.   #--------------------------------------------------------------------------
  394.   def update_show_fast
  395.     if custom_pause or self.openness < 255
  396.       @show_fast = false
  397.     elsif Input.trigger?(Input::C)
  398.       if FastShow ## 快速显示文字
  399.         @show_fast = true
  400.         @wait_count = 0
  401.       end
  402.     elsif not Input.press?(Input::C)
  403.       @show_fast = false
  404.     end
  405.     if @show_fast and @wait_count > 0
  406.       @wait_count -= 1
  407.     end
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● 判断下一消息继续显示
  411.   #--------------------------------------------------------------------------
  412.   def continue?
  413.     return true if $game_message.num_input_variable_id > 0
  414.     return false if $game_message.texts.empty?
  415.     if self.openness > 0 and not $game_temp.in_battle
  416.       return false if @background != $game_message.background
  417.       return false if @position != $game_message.position
  418.     end
  419.     return true
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   # ◎ 开始显示消息
  423.   #--------------------------------------------------------------------------
  424.   def start_message
  425.     ## 重设窗体背景与位置
  426.     reset_window
  427.     ## 还原头像左右判断
  428.     @show_right = false
  429.     ## 暂存消息
  430.     temp_texts = []
  431.     $game_message.texts.each do |text|
  432.       tmp = text.clone
  433.       ## 判断对话框皮肤
  434.       if tmp.sub!(/\\B\[(\d+)\]/i) { "" }
  435.         filename = Msg_StyleLib[@background][$1.to_i]
  436.         if @background == 0
  437.           self.windowskin = Cache.system(filename)
  438.           if Pause_Custom>0 && !@pause_sprite.nil? && !@pause_sprite.disposed?
  439.             @pause_sprite.bitmap = Cache.system(filename + "_pause")
  440.           end
  441.         else
  442.           @back_sprite.bitmap = Cache.system(filename)
  443.           if Pause_Custom>0 && !@pause_sprite.nil? && !@pause_sprite.disposed?
  444.             @pause_sprite.bitmap = Cache.system(filename + "_pause")
  445.           end
  446.         end
  447.         ## 开始自定义暂停标记动画
  448.         @pause_aniindex = -1
  449.       end
  450.       ## 判断头像显现
  451.       @face_enter = $1.to_i if tmp.sub!(/\\E\[(\d+)\]/i) { "" }
  452.       temp_texts.push(tmp)
  453.     end
  454.     ## 判断头像方向
  455.     if !temp_texts[0].nil? and temp_texts[0].sub!(/\\R/i){ "" }
  456.       @show_right = true
  457.     end
  458.     ## 判断名称
  459.     if temp_texts[0] != nil and temp_texts[0] =~ /[::]/
  460.       if temp_texts[0] =~ /\\[::]/
  461.         ## 忽略名称的处理
  462.         temp_texts[0].sub!(/\\:/)  { ":" }
  463.         temp_texts[0].sub!(/\\:/) { ":" }
  464.       else
  465.         ## 去冒号加修饰符(可选)
  466.         unless Name_Symbol.empty?
  467.           temp_texts[0].sub!(/[::]/) { "" }
  468.           temp_texts[0] = Name_Symbol[0,Name_Symbol.size/2] +
  469.           temp_texts[0] + Name_Symbol[Name_Symbol.size/2,Name_Symbol.size/2]
  470.         end
  471.         ## 设定文字颜色
  472.         temp_texts[0] = "\\C[#{Name_FontColor}]" +
  473.         temp_texts[0] + "\\C[#{Msg_FontColor}]"
  474.         ## 设定文字字体
  475.         temp_texts[0] = "\\F[N#{Name_FontIndex}]" +
  476.         temp_texts[0] + "\\F[N#{Msg_FontName}]"
  477.         ## 设定文字大小
  478.         temp_texts[0] = "\\F[S#{Name_FontSize}]" +
  479.         temp_texts[0] + "\\F[S#{Msg_FontSize}]"
  480.         ## 设定文字附加效果
  481.         temp_texts[0] = "\\F[A#{Name_FontAdj}]" +
  482.         temp_texts[0] + "\\F[A#{Msg_FontPlus}]"
  483.         ## 显示名称背景条
  484.         show_namebar_sprite
  485.       end
  486.     end
  487.     @text = ""
  488.     for i in 0...temp_texts.size
  489.       @text += "  " if i >= $game_message.choice_start
  490.       @text += temp_texts[i].clone + "\x00"
  491.     end
  492.     @item_max = $game_message.choice_max
  493.     convert_special_characters
  494.     new_page
  495.   end
  496.   #--------------------------------------------------------------------------
  497.   # ◎ 更换页面处理
  498.   #--------------------------------------------------------------------------
  499.   def new_page
  500.     contents.clear
  501.     ## 初始化文字描绘起点
  502.     @contents_x = 0
  503.     ## 除名称外文字右移1字符
  504.     @contents_x += Msg_FontSize+Font_Space unless @show_name
  505.     if $game_message.face_name.empty?
  506.       @face_sprite.bitmap.clear
  507.     else
  508.       name = $game_message.face_name
  509.       index = $game_message.face_index
  510.       ## 获取头像宽度
  511.       set_face_width(name)
  512.       ## 计算文字横坐标起始
  513.       @contents_x += @face_width-16 unless @show_right
  514.       draw_msg_face(name, index)
  515.       ## 头像进入画面
  516.       face_in
  517.     end
  518.     @contents_y = 0
  519.     @line_count = 0
  520.     @show_fast = false
  521.     @line_show_fast = false
  522.     @pause_skip = false
  523.     contents.font.color = text_color(0)
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ◎ 换行处理
  527.   #--------------------------------------------------------------------------
  528.   def new_line
  529.     ## 提前处理自定义暂停标记
  530.     set_custom_pause_pos
  531.     @contents_x = 0
  532.     unless $game_message.face_name.empty?
  533.       ## 头像显示在左时
  534.       @contents_x = @face_width-16 unless @show_right
  535.     end
  536.     ## 除名称外文字右移1字符
  537.     @contents_x += (Msg_FontSize+Font_Space)
  538.     ## 显示名称之后,对话内容下移 Name_SpaceY
  539.     @contents_y += Name_SpaceY if @line_count == 0 and @show_name
  540.     ## 以字号为新间距
  541.     @contents_y += (Msg_FontSize+Font_Space)
  542.     @line_count += 1
  543.     @line_show_fast = false
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ◎ 特殊文字变换
  547.   #--------------------------------------------------------------------------
  548.   def convert_special_characters
  549.     ## 特定字符处理
  550.     @text.gsub!(/#\[(.*?)\]/)    {@frozen_char.push($1); "\xff"}
  551.     @text.gsub!(/#\<(.*?)\>/)    {""}
  552.     ## 默认控制符
  553.     @text.gsub!(/\\V\[(\d+)\]/i) {$game_variables[$1.to_i]}
  554.     @text.gsub!(/\\V\[(\d+)\]/i) {$game_variables[$1.to_i]}
  555.     @text.gsub!(/\\N\[(\d+)\]/i) {$game_actors[$1.to_i].name}
  556.     @text.gsub!(/\\C\[(\d+)\]/i) {"\x01[#{$1}]"}
  557.     @text.gsub!(/\\G/)           {"\x02"}
  558.     @text.gsub!(/\\\./)          {"\x03"}
  559.     @text.gsub!(/\\\|/)          {"\x04"}
  560.     @text.gsub!(/\\!/)           {"\x05"}
  561.     @text.gsub!(/\\>/)           {"\x06"}
  562.     @text.gsub!(/\\</)           {"\x07"}
  563.     @text.gsub!(/\\\^/)          {"\x08"}
  564.     @text.gsub!(/\\\\/)          {"\\"}
  565.     ## 更改不透明度
  566.     @text.gsub!(/\\O\[(\d+)\]/i) {"\x09[#{$1}]"}
  567.     ## 显示数据库元素
  568.     @text.gsub!(/\\S\[(\d+)\]/i) {"\x0a[#{$1}]" + $data_skills[$1.to_i].name}
  569.     @text.gsub!(/\\I\[(\d+)\]/i) {"\x0b[#{$1}]" + $data_items[$1.to_i].name}
  570.     @text.gsub!(/\\W\[(\d+)\]/i) {"\x0c[#{$1}]" + $data_weapons[$1.to_i].name}
  571.     @text.gsub!(/\\A\[(\d+)\]/i) {"\x0d[#{$1}]" + $data_armors[$1.to_i].name}
  572.     ## 更改字体
  573.     @text.gsub!(/\\F\[S(\d+)\]/i){"\x0e[#{$1}]"}
  574.     @text.gsub!(/\\F\[N(\d+)\]/i){"\x0f[#{$1}]"}
  575.     @text.gsub!(/\\F\[C(\d+)\]/i){"\x01[#{$1}]"}
  576.     ## 16进制颜色
  577.     @text.gsub!(/\\F\[C\#([a-f0-9]+)\]/i) {"\x10[#{$1}]"}
  578.     ## 字体附加效果
  579.     @text.gsub!(/\\F\[A(\d+)\]/i){"\x11[#{$1}]"}
  580.     ## 自动关闭
  581.     @text.gsub!(/\\X\[(\d+)\]/i) {"\x12[#{$1}]"}
  582.     @text.gsub!(/\\X/i)          {"\x13"}
  583.     ## 字速控制
  584.     @text.gsub!(/\\P\[(\d+)\]/i) {"\x14[#{$1}]"}
  585.     ## 提取动画对象和 ID
  586.     @text.gsub!(/\\A\[(\S+)\,(\d+)\]/i) {"\x15[#{$1},#{$2}]"}
  587.     @text.gsub!(/\\B\[(\S+)\,(\d+)\]/i) {"\x16[#{$1},#{$2}]"}
  588.     ## 切换头像index
  589.     @text.gsub!(/\\@\[(\d+)\]/)  {"\x17[#{$1}]"}
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ◎ 设置窗体背景与位置
  593.   #--------------------------------------------------------------------------
  594.   def reset_window
  595.     @background = $game_message.background
  596.     @position = $game_message.position
  597.     if @background == 0   # 普通窗体
  598.       self.opacity = 255
  599.     else                  # 背景变暗、透明
  600.       self.opacity = 0
  601.     end
  602.     case @position
  603.     when 0  # 上
  604.       fh = get_face_height($game_message.face_name)
  605.       self.y = fh - self.height - Face_AdjY
  606.       self.y = 0 if self.y < 0
  607.       @gold_window.y = 360
  608.     when 1  # 中
  609.       self.y = (Graphics.height-self.height)/2
  610.       @gold_window.y = 0
  611.     when 2  # 下
  612.       self.y = Graphics.height-self.height
  613.       @gold_window.y = 0
  614.     end
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # ◎ 消息结束
  618.   #--------------------------------------------------------------------------
  619.   def terminate_message
  620.     ## 选项窗体
  621.     Choice_Strip ? @choice = false : self.active = false
  622.     self.custom_pause = false
  623.     self.index = -1
  624.     @gold_window.close
  625.     @number_input_window.active = false
  626.     @number_input_window.visible = false
  627.     $game_message.main_proc.call if $game_message.main_proc != nil
  628.     $game_message.clear
  629.     ## 还原自动关闭
  630.     @auto_close = nil
  631.     ## 处理名称背景条和头像
  632.     @show_name = false
  633.     @namebar_sprite.visible = false
  634.     @face_sprite.visible = false
  635.     @face_sprite.bitmap.clear
  636.   end
  637.   #--------------------------------------------------------------------------
  638.   # ◎ 更新消息
  639.   #--------------------------------------------------------------------------
  640.   def update_message
  641.     loop do
  642.       c = @text.slice!(/./m)            # 获取下一条文字
  643.       case c
  644.       when nil                          # 没有可以显示的文字
  645.         finish_message                  # 更新结束
  646.         break
  647.       when "\x00"                       # 换行
  648.         new_line
  649.         if @line_count >= MAX_LINE      # 行数为最大时
  650.           unless @text.empty?           # 如果还有增加则继续
  651.             ## 等待滚动
  652.             @wait_count = MultiLinesWait
  653.             @multi_lines = true
  654.             break
  655.           end
  656.         end
  657.       when "\x01"                       # \C[n]  (更改文字色)
  658.         @text.sub!(/\[([0-9]+)\]/, "")
  659.         contents.font.color = text_color($1.to_i)
  660.         next
  661.       when "\x02"                       # \G  (显示所持金)
  662.         @gold_window.refresh
  663.         @gold_window.open
  664.       when "\x03"                       # \.  (等待 1/4 秒)
  665.         @wait_count = 15
  666.         break
  667.       when "\x04"                       # \|  (等待 1 秒)
  668.         @wait_count = 60
  669.         break
  670.       when "\x05"                       # \!  (等待输入)
  671.         self.custom_pause = true
  672.         break
  673.       when "\x06"                       # \>  (瞬间显示 ON)
  674.         @line_show_fast = true
  675.       when "\x07"                       # \<  (瞬间显示 OFF)
  676.         @line_show_fast = false
  677.       when "\x08"                       # \^  (不等待输入)
  678.         @pause_skip = true
  679.       ## 更改不透明度的情况下
  680.       when "\x09"
  681.         @text.sub!(/\[(\d+)\]/, "")
  682.         contents.font.color.alpha = $1.to_i
  683.       ## 显示技能情况下
  684.       when "\x0a"
  685.         @text.sub!(/\[(\d+)\]/, "")
  686.         draw_icon($data_skills[$1.to_i].icon_index, @contents_x, @contents_y)
  687.         ## 横坐标增加图标宽度
  688.         @contents_x += 24
  689.       ## 显示物品情况下
  690.       when "\x0b"
  691.         @text.sub!(/\[(\d+)\]/, "")
  692.         draw_icon($data_items[$1.to_i].icon_index, @contents_x, @contents_y)
  693.         ## 横坐标增加图标宽度
  694.         @contents_x += 24
  695.       ## 显示武器情况下
  696.       when "\x0c"
  697.         @text.sub!(/\[(\d+)\]/, "")
  698.         draw_icon($data_weapons[$1.to_i].icon_index, @contents_x, @contents_y)
  699.         ## 横坐标增加图标宽度
  700.         @contents_x += 24
  701.       ## 显示防具情况下
  702.       when "\x0d"
  703.         @text.sub!(/\[(\d+)\]/, "")
  704.         draw_icon($data_armors[$1.to_i].icon_index, @contents_x, @contents_y)
  705.         ## 横坐标增加图标宽度
  706.         @contents_x += 24
  707.       ## 更改字体的情况下
  708.       when "\x0e"
  709.         @text.sub!(/\[(\d+)\]/, "")
  710.         contents.font.size = $1.to_i
  711.       when "\x0f"
  712.         @text.sub!(/\[(\d+)\]/, "")
  713.         name = Font_Lib[$1.to_i]
  714.         contents.font.name = Font.exist?(name) ? name : Font.default_name
  715.       ## 16进制颜色
  716.       when "\x10"
  717.         @text.sub!(/\[(\w+)\]/, "")
  718.         r,g,b = $1.scan(/../)
  719.         contents.font.color = Color.new(r.hex, g.hex, b.hex)
  720.       ## 字体附加效果
  721.       when "\x11"
  722.         @text.sub!(/\[(\d+)\]/, "")
  723.         ## 获取字体附加效果
  724.         @font_adj = $1.to_i
  725.       ## 自动关闭对话框的情况下
  726.       when "\x12"
  727.         @text.sub!(/\[(\d+)\]/, "")
  728.         @auto_close = $1.to_i
  729.       when "\x13"
  730.         @auto_close = AutoClose
  731.       ## \P[n] (字速)
  732.       when "\x14"
  733.         @text.sub!(/\[(\d+)\]/, "")
  734.         ## 获取字体显示速度
  735.         @speed = $1.to_i
  736.       ## 显示角色动画
  737.       when "\x15"
  738.         @text.sub!(/\[(\S+)\,(\d+)\]/, "")
  739.         character = interpreter.get_character($1.to_i)
  740.         character.animation_id = $2.to_i unless character.nil?
  741.         next
  742.       ## 显示心情动画
  743.       when "\x16"
  744.         @text.sub!(/\[(\S+)\,(\d+)\]/, "")
  745.         character = interpreter.get_character($1.to_i)
  746.         character.balloon_id = $2.to_i unless character.nil?
  747.         next
  748.       ## 换头像
  749.       when "\x17"
  750.         @text.sub!(/\[(\d+)\]/, "")
  751.         name  = $game_message.face_name
  752.         index = $game_message.face_index = $1.to_i
  753.         draw_msg_face(name, index)
  754.       ## 选择项
  755.       when "\x18"
  756.         finish_message
  757.         break
  758.       ## 特定字符处理
  759.       when "\xff"
  760.         @text.insert(0, @frozen_char.shift)
  761.       else
  762.         ## 字速控制
  763.         @wait_count = GlobalSpeed
  764.         @wait_count = @speed if @speed != nil
  765.         h = contents.font.size + Font_Space
  766.         ## 字体附加效果
  767.         if @font_adj & 1 != 0
  768.           contents.font.shadow = true
  769.         else
  770.           contents.font.shadow = false
  771.         end
  772.         if @font_adj & 2 != 0
  773.           contents.font.bold = true
  774.         else
  775.           contents.font.bold = false
  776.         end
  777.         if @font_adj & 4 != 0
  778.           contents.font.italic = true
  779.         else
  780.           contents.font.italic = false
  781.         end
  782.         if @font_adj & 8 != 0     ## 描边字
  783.           color = text_color(EdgeColor)
  784.           contents.draw_edge_text(@contents_x,@contents_y,h,h,c,0,color)
  785.         elsif @font_adj & 16 != 0 ## 发光字
  786.           color = text_color(GlowColor)
  787.           contents.draw_glow_text(@contents_x,@contents_y,h,h,c,0,color)
  788.         else                      ## 普通字
  789.           contents.draw_text(@contents_x, @contents_y, h, h, c)
  790.         end
  791.         c_width = contents.text_size(c).width
  792.         @contents_x += c_width
  793.       end
  794.       break unless @show_fast or @line_show_fast
  795.     end
  796.   end
  797.   #--------------------------------------------------------------------------
  798.   # ◎ 消息更新结束
  799.   #--------------------------------------------------------------------------
  800.   def finish_message
  801.     if $game_message.choice_max > 0
  802.       start_choice
  803.     elsif $game_message.num_input_variable_id > 0
  804.       start_number_input
  805.     elsif @pause_skip
  806.       terminate_message
  807.     else
  808.       self.custom_pause = true
  809.     end
  810.     @wait_count = 10
  811.     @text = nil
  812.     ## 临时字速还原
  813.     @speed = nil
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ◎ 开始选择项
  817.   #--------------------------------------------------------------------------
  818.   def start_choice
  819.     if Choice_Strip
  820.       @choice = true
  821.       width = 0
  822.       commands = []
  823.       for i in $game_message.choice_start+1 ...$game_message.texts.size
  824.         commands.push $game_message.texts[i]
  825.         iw = contents.text_size($game_message.texts[i]).width
  826.         width = iw if width < iw
  827.       end
  828.       ## 计算高度
  829.       if commands.size > Choice_MaxLines
  830.         row_max = Choice_MaxLines
  831.       else
  832.         row_max = commands.size
  833.       end
  834.       @choice_window = Window_Command.new(width+42, commands, 1, row_max)
  835.       @choice_window.contents.font = default_font
  836.       @choice_window.refresh
  837.       ## 计算坐标
  838.       if @show_right
  839.         @choice_window.x = self.x
  840.       else
  841.         @choice_window.x = self.x + self.width - @choice_window.width
  842.       end
  843.       if @position == 0
  844.         @choice_window.y = self.y + self.height
  845.       else
  846.         @choice_window.y = self.y - @choice_window.height
  847.       end
  848.     else
  849.       self.active = true
  850.       self.index = 0
  851.     end
  852.   end
  853.   #--------------------------------------------------------------------------
  854.   # ◎ 开始输入数值
  855.   #--------------------------------------------------------------------------
  856.   def start_number_input
  857.     digits_max = $game_message.num_input_digits_max
  858.     number = $game_variables[$game_message.num_input_variable_id]
  859.     @number_input_window.digits_max = digits_max
  860.     @number_input_window.number = number
  861.     if $game_message.face_name.empty?
  862.       @number_input_window.x = x
  863.     else
  864.       ## 代入头像宽度
  865.       @number_input_window.x = @show_right ? x : x + @face_width
  866.     end
  867.     @number_input_window.y = y + @contents_y
  868.     @number_input_window.active = true
  869.     @number_input_window.visible = true
  870.     @number_input_window.update
  871.   end
  872.   #--------------------------------------------------------------------------
  873.   # ◎ 更新光标 ###可能仍须增加判断
  874.   #--------------------------------------------------------------------------
  875.   def update_cursor
  876.     if @index >= 0
  877.       if $game_message.face_name.empty?
  878.         x = 0
  879.         y = ($game_message.choice_start+@index)*(Msg_FontSize+Font_Space)
  880.         width = contents.width
  881.       else
  882.         x = @show_right ? 0 : @face_width
  883.         y = ($game_message.choice_start+@index)*(Msg_FontSize+Font_Space) +
  884.              Name_SpaceY
  885.         width = contents.width - @face_width
  886.       end
  887.       self.cursor_rect.set(x, y, width, (Msg_FontSize+Font_Space))
  888.     else
  889.       self.cursor_rect.empty
  890.     end
  891.   end
  892.   #--------------------------------------------------------------------------
  893.   # ◎ 文章显示输入处理
  894.   #--------------------------------------------------------------------------
  895.   def input_pause
  896.     if Input.trigger?(Input::C) or Input.trigger?(Input::B)
  897.       ## 还原自定义暂停标记
  898.       self.custom_pause = false
  899.       if @text != nil and not @text.empty?
  900.         new_page if @line_count >= MAX_LINE
  901.       else
  902.         terminate_message
  903.       end
  904.     end
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # ◎ 选择项输入处理
  908.   #--------------------------------------------------------------------------
  909.   def input_choice
  910.     if Input.trigger?(Input::B)
  911.       if $game_message.choice_cancel_type > 0
  912.         Sound.play_cancel
  913.         $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
  914.         terminate_message
  915.       end
  916.     elsif Input.trigger?(Input::C)
  917.       Sound.play_decision
  918.       ## 获取相应index
  919.       index = Choice_Strip ? @choice_window.index : self.index
  920.       $game_message.choice_proc.call(index)
  921.       terminate_message
  922.     end
  923.     ## 刷新选项窗体
  924.     return unless Choice_Strip
  925.     if @choice
  926.       @choice_window.update
  927.     else
  928.       @choice_window.dispose
  929.       @choice_window = nil
  930.     end
  931.   end
  932.   #--------------------------------------------------------------------------
  933.   # ● 数值输入处理
  934.   #--------------------------------------------------------------------------
  935.   def input_number
  936.     if Input.trigger?(Input::C)
  937.       Sound.play_decision
  938.       $game_variables[$game_message.num_input_variable_id] =
  939.         @number_input_window.number
  940.       $game_map.need_refresh = true
  941.       terminate_message
  942.     end
  943.   end
  944.   #--------------------------------------------------------------------------
  945.   # ○ 生成名称背景条
  946.   #--------------------------------------------------------------------------
  947.   def create_namebar_sprite
  948.     @namebar_sprite = Sprite.new
  949.     @namebar_sprite.bitmap = Bitmap.new(width-Name_SpaceX, Name_FontSize+4)
  950.     ## 可视性
  951.     @namebar_sprite.visible = false
  952.     ## 准备参数
  953.     rect = Rect.new(Name_SpaceX,0,@namebar_sprite.width,@namebar_sprite.height)
  954.     color1 = text_color(NameBar_Color)
  955.     color2 = text_color(NameBar_Color)
  956.     color1.alpha = NameBar_Opacity
  957.     color2.alpha = 0
  958.     ## 描绘渐变条
  959.     @namebar_sprite.bitmap.gradient_fill_rect(rect, color1, color2)
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # ○ 显示名称背景条
  963.   #--------------------------------------------------------------------------
  964.   def show_namebar_sprite
  965.     @show_name = true
  966.     return if @background == 1
  967.     ## 坐标跟随
  968.     @namebar_sprite.x = self.x
  969.     @namebar_sprite.y = self.y + 16 - 1
  970.     @namebar_sprite.z = self.z + 1
  971.     ## 可视性
  972.     @namebar_sprite.visible = true
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # ○ 生成头像
  976.   #--------------------------------------------------------------------------
  977.   def create_face_sprite
  978.     @face_sprite = Sprite.new
  979.     @face_sprite.bitmap = Bitmap.new(1,1)
  980.     @face_sprite.z = self.z + 2
  981.     @face_sprite.visible = false
  982.     @old_name = ""                        # 判断头像是否改变
  983.     @old_index = 0                        # 判断头像是否改变
  984.     @face_enter = Face_Enter              # 头像显示模式
  985.   end
  986.   #--------------------------------------------------------------------------
  987.   # ○ 描绘头像
  988.   #     face_name  : 头像图像文件名
  989.   #     face_index : 头像图像索引
  990.   #--------------------------------------------------------------------------
  991.   def draw_msg_face(face_name, face_index)
  992.     bitmap = Cache.face(face_name)
  993.     width = bitmap.width / 4
  994.     height = bitmap.height / 2
  995.     rect = Rect.new(0, 0, 0, 0)
  996.     rect.x = face_index % 4 * width
  997.     rect.y = face_index / 4 * height
  998.     rect.width = width
  999.     rect.height = height
  1000.     @face_sprite.bitmap = Bitmap.new(width, height)
  1001.     @face_sprite.bitmap.blt(0, 0, bitmap, rect)
  1002.     @face_sprite.mirror = @show_right
  1003.   end
  1004.   #--------------------------------------------------------------------------
  1005.   # ○ 设定头像宽度
  1006.   #     face_name  : 头像图像文件名
  1007.   #--------------------------------------------------------------------------
  1008.   def set_face_width(face_name)
  1009.     bitmap = Cache.face(face_name)
  1010.     @face_width = bitmap.width / 4
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # ○ 获取头像高度
  1014.   #     face_name  : 头像图像文件名
  1015.   #--------------------------------------------------------------------------
  1016.   def get_face_height(face_name)
  1017.     bitmap = Cache.face(face_name)
  1018.     return bitmap.height / 2
  1019.   end
  1020.   #--------------------------------------------------------------------------
  1021.   # ○ 头像进入画面
  1022.   #--------------------------------------------------------------------------
  1023.   def face_in
  1024.     fw = @face_sprite.width
  1025.     fh = @face_sprite.height
  1026.     ## 水平坐标
  1027.     if @show_right
  1028.       @face_x = self.width - fw - Face_AdjX
  1029.     else
  1030.       @face_x = self.x + Face_AdjX
  1031.     end
  1032.     @face_sprite.x = @face_x
  1033.     ## 垂直坐标
  1034.     case Face_Align
  1035.     when 0
  1036.       @face_sprite.y = self.y + Face_AdjY
  1037.     when 1
  1038.       @face_sprite.y = self.y + (self.height - fh) / 2
  1039.     when 2
  1040.       @face_sprite.y = self.y + (self.height - fh) + Face_AdjY
  1041.     end
  1042.     case @face_enter
  1043.     when 1 ## 水平趋中时
  1044.       @face_sprite.x += (@show_right ? fw : -fw)
  1045.     when 2 ## 渐显时
  1046.       @face_sprite.opacity = 0
  1047.     end
  1048.     ## 可视性
  1049.     @face_sprite.visible = true
  1050.   end
  1051.   #--------------------------------------------------------------------------
  1052.   # ○ 生成自定义暂停标记
  1053.   #--------------------------------------------------------------------------
  1054.   def create_custom_pause
  1055.     return if Pause_Custom == 0
  1056.     @pause_sprite = Sprite.new
  1057.     @pause_sprite.visible = false
  1058.     @pause_sprite.z = self.z + 3
  1059.     @pause_sprite.bitmap = Cache.system("Window_pause")
  1060.     @pause_aniindex = -1
  1061.     @pause_anispeed = 0
  1062.   end
  1063.   #--------------------------------------------------------------------------
  1064.   # ○ 获取暂停标记
  1065.   #--------------------------------------------------------------------------
  1066.   def custom_pause
  1067.     return @custom_pause
  1068.   end
  1069.   #--------------------------------------------------------------------------
  1070.   # ○ 更改暂停标记
  1071.   #--------------------------------------------------------------------------
  1072.   def custom_pause=(val)
  1073.     @custom_pause = val
  1074.     self.pause = val if Pause_Custom == 0
  1075.   end
  1076.   #--------------------------------------------------------------------------
  1077.   # ○ 更新暂停标记
  1078.   #--------------------------------------------------------------------------
  1079.   def update_custom_pause
  1080.     return if Pause_Custom == 0
  1081.     @pause_sprite.visible = @custom_pause
  1082.     @pause_sprite.visible = false if @pause_aniindex == -1
  1083.     return if !@custom_pause
  1084.     if @pause_anispeed > 0
  1085.       @pause_anispeed -= 1
  1086.     else
  1087.       @pause_aniindex = (@pause_aniindex + 1) % Pause_AniFrm
  1088.       pw = @pause_sprite.bitmap.width / Pause_AniFrm
  1089.       ph = @pause_sprite.bitmap.height
  1090.       @pause_sprite.src_rect.set(@pause_aniindex*pw, 0, pw, ph)
  1091.       @pause_anispeed = Pause_AniCyc
  1092.     end
  1093.   end
  1094.   #--------------------------------------------------------------------------
  1095.   # ○ 设定暂停标记坐标
  1096.   #--------------------------------------------------------------------------
  1097.   def set_custom_pause_pos
  1098.     return if Pause_Custom == 0
  1099.     pw = @pause_sprite.bitmap.width / Pause_AniFrm
  1100.     ph = @pause_sprite.bitmap.height
  1101.     case Pause_Custom
  1102.     when 1 ## 底边居中
  1103.       @pause_sprite.x = self.x + (self.width - pw)/2
  1104.       @pause_sprite.y = self.y + self.height - ph
  1105.     when 2 ## 右下角
  1106.       @pause_sprite.x = self.x + self.width - pw
  1107.       @pause_sprite.y = self.y + self.height - ph
  1108.       @pause_sprite.x -= @face_width if @show_right
  1109.     when 3 ## 文字后
  1110.       @pause_sprite.x = self.x + @contents_x + Msg_FontSize + Font_Space
  1111.       @pause_sprite.y = self.y + @contents_y + Msg_FontSize + Font_Space
  1112.     end
  1113.     @pause_sprite.x += Pause_AdjX
  1114.     @pause_sprite.y += Pause_AdjY
  1115.   end
  1116.   #--------------------------------------------------------------------------
  1117.   # ○ 滚动换行
  1118.   #--------------------------------------------------------------------------
  1119.   def scroll_line
  1120.     w = self.width - 32
  1121.     hm = Msg_FontSize + Font_Space
  1122.     if @show_name
  1123.       l = MAX_LINE - 2
  1124.       hn = Name_FontSize + Font_Space + Name_SpaceY
  1125.       rect = Rect.new(0, hn+hm, w, hm*l)
  1126.     else
  1127.       l = MAX_LINE - 1
  1128.       hn = 0
  1129.       rect = Rect.new(0, hm, w, hm*l)
  1130.     end
  1131.     ## 复制位图
  1132.     buff = Bitmap.new(w, hm*l)
  1133.     buff.blt(0, 0, contents, rect)
  1134.     ## 描绘位图
  1135.     contents.clear_rect Rect.new(0, hn, w, hm*l+hm)
  1136.     contents.blt 0, hn, buff, Rect.new(0, 0, w, hm*l)
  1137.     buff.dispose
  1138.     @contents_y -= Msg_FontSize + Font_Space
  1139.     @multi_lines = false
  1140.   end
  1141.   #--------------------------------------------------------------------------
  1142.   # ○ 默认字体
  1143.   #--------------------------------------------------------------------------
  1144.   def default_font
  1145.     font = Font.new(Font.default_name, Msg_FontSize)
  1146.     font.shadow = Font.default_shadow
  1147.     font.italic = Font.default_italic
  1148.     font.color = text_color(Msg_FontColor)
  1149.     font.bold = Font.default_bold
  1150.     return font
  1151.   end
  1152.   #--------------------------------------------------------------------------
  1153.   # ○ 当前解释器
  1154.   #--------------------------------------------------------------------------
  1155.   def interpreter
  1156.     if $game_temp.in_battle
  1157.       return $game_troop.interpreter
  1158.     else
  1159.       return $game_map.interpreter
  1160.     end
  1161.   end
  1162. end
  1163. #==============================================================================
  1164. # ■ Window_Command
  1165. #==============================================================================
  1166. class Window_Command < Window_Selectable
  1167.   #--------------------------------------------------------------------------
  1168.   # ◎ 初始化
  1169.   #     width      : 窗口宽
  1170.   #     commands   : 命令字符串列表
  1171.   #     column_max : 列数 (2 以上横向选择)
  1172.   #     row_max    : 行数 (0:与命令数一致)
  1173.   #     spacing    : 项目横向的空白空间
  1174.   #--------------------------------------------------------------------------
  1175.   def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  1176.     line_max = (commands.size + column_max - 1) / column_max
  1177.     row_max = line_max if row_max == 0
  1178.     super(0, 0, width, [line_max,row_max].max * WLH + 32, spacing)
  1179.     @commands = commands
  1180.     @item_max = commands.size
  1181.     @column_max = column_max
  1182.     refresh
  1183.     self.index = 0
  1184.     self.height = row_max * WLH + 32
  1185.   end
  1186. end
  1187. #==============================================================================
  1188. # ■ Game_Interpreter
  1189. #==============================================================================
  1190. class Game_Interpreter
  1191.   #--------------------------------------------------------------------------
  1192.   # ◎ 设置事件
  1193.   #     list     : 执行内容
  1194.   #     event_id : 事件 ID
  1195.   #--------------------------------------------------------------------------
  1196.   alias msg_plus_setup setup
  1197.   def setup(list, event_id = 0)
  1198.     msg_plus_setup(list, event_id)
  1199.     ## 获取执行列表
  1200.     @list = Marshal.load(Marshal.dump list)
  1201.   end
  1202.   #--------------------------------------------------------------------------
  1203.   # ◎ 显示文章
  1204.   #--------------------------------------------------------------------------
  1205.   def command_101
  1206.     unless $game_message.busy
  1207.       $game_message.face_name = @params[0]
  1208.       $game_message.face_index = @params[1]
  1209.       $game_message.background = @params[2]
  1210.       $game_message.position = @params[3]
  1211.       @index += 1
  1212.       loop do
  1213.         case @list[@index].code
  1214.         when 101 ## 对话设定
  1215.           multi_lines? ? @index += 1 : break
  1216.         when 401 ## 对话数据
  1217.           $game_message.texts.push(@list[@index].parameters[0])
  1218.           @index += 1
  1219.         else
  1220.           break
  1221.         end
  1222.       end
  1223.       if @list[@index].code == 102          # 显示选择项
  1224.         setup_choices(@list[@index].parameters)
  1225.       elsif @list[@index].code == 103       # 处理数值输入
  1226.         setup_num_input(@list[@index].parameters)
  1227.       end
  1228.       set_message_waiting                   # 消息待机状态
  1229.     end
  1230.     return false
  1231.   end
  1232.   #--------------------------------------------------------------------------
  1233.   # ◎ 设置选择项
  1234.   #--------------------------------------------------------------------------
  1235.   def setup_choices(params)
  1236.     if FSL::Window_message_Plus::Choice_Strip &&
  1237.        FSL::Window_message_Plus::Choice_MaxLines > 0
  1238.       ## 备重建
  1239.       @modify = []
  1240.       @delete = []
  1241.       @cancel = 0
  1242.       ## 获取合并后的command
  1243.       command = @list[@index].clone
  1244.       command.parameters = connect_choice(@index), @cancel
  1245.       ## 消息参数
  1246.       $game_message.choice_start = $game_message.texts.size
  1247.       $game_message.choice_max = command.parameters[0].size
  1248.       $game_message.texts.push "\x18"
  1249.       command.parameters[0].each{|s| $game_message.texts.push(s)}
  1250.       ## 重建数据
  1251.       @modify.each_index do |i|
  1252.         key,value = @modify[i].is_a?(Array) ? @modify[i] : [@modify[i],i]
  1253.         @list[key].parameters[0] = value
  1254.       end
  1255.       @delete.reverse.each{|i| @list[i,1] = nil}
  1256.       @list.insert(@index, command)
  1257.       $game_message.choice_cancel_type = @cancel
  1258.       $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
  1259.       ## 推进
  1260.       @index += 1
  1261.     else
  1262.       ## 默认情况
  1263.       if $game_message.texts.size <= 4 - params[0].size
  1264.         $game_message.choice_start = $game_message.texts.size
  1265.         $game_message.choice_max = params[0].size
  1266.         for s in params[0]
  1267.           $game_message.texts.push(s)
  1268.         end
  1269.         $game_message.choice_cancel_type = params[1]
  1270.         $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
  1271.         @index += 1
  1272.       end
  1273.     end
  1274.   end
  1275.   #--------------------------------------------------------------------------
  1276.   # ◎ 取消的情况下
  1277.   #--------------------------------------------------------------------------
  1278.   alias msg_plus_command_403 command_403
  1279.   def command_403
  1280.     ## 合并选项时
  1281.     if !@params[0].nil? && @branch[@indent] == @params[0] - 1
  1282.       @branch.delete(@indent)
  1283.       return true
  1284.     end
  1285.     msg_plus_command_403
  1286.   end
  1287.   #--------------------------------------------------------------------------
  1288.   # ## 合并选项
  1289.   #--------------------------------------------------------------------------
  1290.   def connect_choice(index, result=[])
  1291.     params = @list[index].parameters
  1292.     indent = @list[index].indent
  1293.     ## 取消项
  1294.     @cancel = result.size + params[1] if params[1] > 0
  1295.     params[0].each{|s| result.push(s)}
  1296.     @delete.push(index) ## 102
  1297.     index = next_choice(index)
  1298.     ## 判断合并的条件 选项:满4项;取消:非分歧
  1299.     if index && params[0].size == 4 && params[1] < 5
  1300.       @delete.push(index-1) ## 404
  1301.       connect_choice(index, result)
  1302.     else
  1303.       return result
  1304.     end
  1305.   end
  1306.   #--------------------------------------------------------------------------
  1307.   # ## 下个选项
  1308.   #--------------------------------------------------------------------------
  1309.   def next_choice(index)
  1310.     params = @list[index].parameters
  1311.     indent = @list[index].indent
  1312.     until @list[index+1].nil?
  1313.       index += 1
  1314.       if indent == @list[index].indent
  1315.         case @list[index].code
  1316.         when 402
  1317.           @modify.push(index)
  1318.         when 403
  1319.           @modify.push([index,@cancel])
  1320.         when 404
  1321.           ## 判断合并的条件 下一个同级执行项102
  1322.           return @list[index+1].code == 102 ? index+1 : nil
  1323.         end
  1324.       end
  1325.     end
  1326.   end
  1327.   #--------------------------------------------------------------------------
  1328.   # ○ 多行模式?
  1329.   #--------------------------------------------------------------------------
  1330.   def multi_lines?
  1331.     return false if FSL::Window_message_Plus::MultiLinesWait <= 0
  1332.     return false if $game_message.face_name != @list[@index].parameters[0]
  1333.     return false if $game_message.face_index != @list[@index].parameters[1]
  1334.     return false if $game_message.background != @list[@index].parameters[2]
  1335.     return false if $game_message.position != @list[@index].parameters[3]
  1336.     return true
  1337.   end
  1338.   #--------------------------------------------------------------------------
  1339.   # ○ 心情图标扩展
  1340.   #     character_id: 角色 ID (-1 为角色、0 为本事件、除此之外为事件 ID)
  1341.   #     balloon_id  : 心情动画 ID (从1开始)
  1342.   #--------------------------------------------------------------------------
  1343.   def balloon_extend(character_id, balloon_id)
  1344.     character = get_character(character_id)
  1345.     if character != nil
  1346.       character.balloon_id = balloon_id
  1347.     end
  1348.     return true
  1349.   end
  1350. end
  1351. #==============================================================================
  1352. # ■ Bitmap
  1353. #==============================================================================
  1354. class Bitmap
  1355.   #--------------------------------------------------------------------------
  1356.   # ○ 描边字
  1357.   #--------------------------------------------------------------------------
  1358.   def draw_edge_text(x, y, width, height, str, align = 0, color = nil)
  1359.     font_backup = self.font.clone
  1360.     self.font.color.set(color.red,color.green,color.blue) if color
  1361.     self.font.shadow = false
  1362.     # 描绘边缘
  1363.     self.draw_text(x-1, y-1, width, height, str, align)
  1364.     self.draw_text(x-1, y+1, width, height, str, align)
  1365.     self.draw_text(x+1, y-1, width, height, str, align)
  1366.     self.draw_text(x+1, y+1, width, height, str, align)
  1367.     self.draw_text(x, y-1, width, height, str, align)
  1368.     self.draw_text(x, y+1, width, height, str, align)
  1369.     self.draw_text(x-1, y, width, height, str, align)
  1370.     self.draw_text(x+1, y, width, height, str, align)
  1371.     # 描绘主文字
  1372.     self.font.color = font_backup.color
  1373.     self.draw_text(x, y, width, height, str, align)
  1374.     # 还原默认字体
  1375.     self.font = font_backup
  1376.   end
  1377.   #--------------------------------------------------------------------------
  1378.   # ○ 发光字
  1379.   #--------------------------------------------------------------------------
  1380.   def draw_glow_text(x, y, width, height, str, align = 0, color = nil)
  1381.     buff = Bitmap.new(width, height)
  1382.     buff.font = self.font.clone
  1383.     buff.font.shadow = false
  1384.     buff.font.color.set(color.red,color.green,color.blue) if color
  1385.     # 描绘边缘
  1386.     buff.draw_text(-1, -1, width, height, str, align)
  1387.     buff.draw_text(-1, 1, width, height, str, align)
  1388.     buff.draw_text(1, -1, width, height, str, align)
  1389.     buff.draw_text(1, 1, width, height, str, align)
  1390.     buff.draw_text(0, -1, width, height, str, align)
  1391.     buff.draw_text(0, 1, width, height, str, align)
  1392.     buff.draw_text(0-1, 0, width, height, str, align)
  1393.     buff.draw_text(1, 0, width, height, str, align)
  1394.     buff.blur
  1395.     # 描绘主文字
  1396.     buff.font.color = self.font.color
  1397.     buff.draw_text(0, 0, width, height, str, align)
  1398.     self.blt(x, y, buff, Rect.new(0, 0, width, height))
  1399.     buff.dispose
  1400.   end
  1401.   #--------------------------------------------------------------------------
  1402.   # ○ 多层字
  1403.   #--------------------------------------------------------------------------
  1404.   def draw_sedimentary_text(x, y, width, height, str, align = 0, *color)
  1405.     color.unshift font.color
  1406.     sheet = (font.size.to_f / color.size).ceil
  1407.     buff = Bitmap.new(width, sheet)
  1408.     buff.font = font.clone
  1409.     max = (height - font.size)/2 > 0 ? (height - font.size)/2 : 0
  1410.     min = buff.font.size < height ? buff.font.size : height
  1411.     color.each_index do |i|
  1412.       buff.clear
  1413.       buff.font.color = color[i]
  1414.       buff.draw_text(0, -i*sheet, width, min, str, align)
  1415.       blt(x, y+i*sheet+max, buff, Rect.new(0, 0, width, sheet))
  1416.       break if i*sheet >= height
  1417.     end
  1418.   end
  1419. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-14 13:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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