查看: 2757|回复: 1

[我要悬赏] 【已解决】找人帮我把对话加强脚本里的皮肤给换了

[复制链接]
梦石
0
星屑
292
在线时间
68 小时
注册时间
2022-11-22
回帖
9
发表于 2022-12-22 19:03:49 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 jinae2022 于 2023-1-13 23:20 编辑

首先我用了这个对话加强的脚本,对比fuki的气泡对话框,功能上比较强一些,但是我更喜欢fuki的那种气泡样式,更贴合游戏。有偿求人帮我把fuki的气泡对话框移植到我用的这个对话加强脚本里。
[fold=以下是我现在用的对话脚本]
  1. #==============================================================================
  2. # 本脚本来自https://rpg.blue,使用和转载请保留此信息
  3. #------------------------------------------------------------------------------
  4. # 原版:趙雲
  5. # 重制:RyanBern  2015.08.24
  6. #------------------------------------------------------------------------------

  7. #==============================================================================
  8. # 设置区域(其他参数的调节请看这里)
  9. #==============================================================================
  10. module RB
  11. end
  12. module RB::Mes_Config
  13.   # 打开 XX 号开关后,关闭打字效果
  14.   No_Typing = 31
  15.   # 打开 XX 号开关后,按下[空格键]可以瞬间显示全部文字
  16.   Write_Skip = 32
  17.   # 打开 XX 号开关后,屏蔽加强对话框(使用默认对话框)
  18.   Mes_Disabled = 33
  19.   # 主角名字字符缩写
  20.   Regex_Player_Name = /pn(\d+)/
  21.   # 主角姓名框底色(RGBA)
  22.   Name_Bar_Color = Color.new(36, 64, 127, 80)
  23.   # 字体大小
  24.   Size = 18
  25.   # 对话框窗口皮肤(不写为和系统皮肤相同)
  26.   Mes_Windowskin = ""
  27.   # 最大行数(初值为 4,尽量不要修改,如果考虑合并选择项和连行,可以设置为 6 以上)
  28.   # 此最大行数仅在 \p 指令下有效,如果不使用 \p 指令那么对话框还是 4 行的高度
  29.   Max_Lines = 8
  30.   # 画面宽度和高度(width / height)
  31.   # 此设置一般不需要更改,当使用分辨率扩张脚本时,将如下的值改成你游戏的分辨率即可。
  32.   Graphics_Width = 640
  33.   Graphics_Height = 480
  34.   # 打开 XX 号开关后,对话自动结束(不用按下 C 键)
  35.   Auto_Terminate = 34
  36.   # 打开 XX 号开关后,按下 CTRL 可以高速跳过对话
  37.   Text_Skip_Fast = 35
  38.   # 打开 XX 号开关后,自动调节对话框使其不会挡住说话者
  39.   Auto_Adjust_Mes_Pos = 36
  40.   # 对话自动结束延迟(单位:帧)
  41.   Auto_Terminate_Frame = 10
  42.   # 打开 XX 号开关后,对话框不会有淡入淡出效果
  43.   No_Fade = 37
  44.   # 头像组:横向单元数
  45.   Face_Group_W = 4
  46.   # 头像组:纵向单元数
  47.   Face_Group_H = 2  
  48.   # 默认姓名文字颜色(和系统默认编号一致)
  49.   Name_Color_Default = 6
  50.   # 快捷指令,定义后,可以直接在文本框中输入快捷指令
  51.   # 定义方式为 快捷指令 => 完整指令 ,使用方式为 \sc[快捷指令]
  52.   # 注意,指令中通常包含反斜线'\',因此需要使用单引号的字符串,
  53.   # 或者用"\"进行转义。下面是一个例子:
  54.   # 这样定义后,输入\sc[pn1]就等效为 \name[pn1]\r[L1]\p[-1]
  55.   Shortcuts = {
  56.     #'pn1' => '\name[pn1]\r[L1]\p[-1]'
  57.   }
  58.   # 高级快捷指令定义,类似于宏展开,需要借助正则表达式(高级用户使用)
  59.   Shortcuts_Regexp = {
  60.     /\\pn1/ => '\name[pn1]\r[L1]\p[-1]',
  61.     /\\[Rr]ed\[(.*?)\]/m => '\c[2]\1\c[0]',
  62.     /\\[Cc]ol\[(\d+)\]\{(.*?)\}/m => '\c[\1]\2\c[0]',
  63.   }
  64. end
  65. #==============================================================================
  66. # RPG::Cache
  67. #------------------------------------------------------------------------------
  68. # RPG::Cache 追加定义
  69. #==============================================================================
  70. module RPG::Cache
  71.   def self.face(filename)
  72.     self.load_bitmap("Graphics/Faces/", filename)
  73.   end
  74. end

  75. #==============================================================================
  76. # ■ Game_System
  77. #------------------------------------------------------------------------------
  78. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  79. # $game_system 。
  80. #==============================================================================

  81. class Game_System
  82.   attr_accessor :soundname_on_speak
  83.   alias carol3_ini initialize
  84.   def initialize
  85.     carol3_ini
  86.     @soundname_on_speak = nil
  87.   end
  88. end

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

  867.   
  868.   def opacity_draw_text(target, x, y, str,opacity)
  869.     height = target.font.size
  870.     width = target.text_size(str).width
  871.     opacity = [[opacity, 0].max, 255].min
  872.     if opacity == 255
  873.       target.draw_text(x, y, width, height, str)
  874.       return width
  875.     else
  876.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  877.         @opacity_text_buf.dispose
  878.         @opacity_text_buf = Bitmap.new(width, height)
  879.       else
  880.         @opacity_text_buf.clear
  881.       end
  882.       @opacity_text_buf.font.size = target.font.size
  883.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  884.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  885.     return width
  886.     end
  887.   end
  888.   #--------------------------------------------------------------------------
  889.   # ● \V 变换
  890.   #--------------------------------------------------------------------------
  891.   # option : 选项,'i'物品,'w'武器,'a'防具,'s'技能
  892.   # index  : 数据库的索引
  893.   #--------------------------------------------------------------------------
  894.   def convart_value(option, index)
  895.     option == nil ? option = "" : nil
  896.     option.downcase!
  897.     case option
  898.       when "i"
  899.         unless $data_items[index].name == nil
  900.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  901.         end
  902.       when "w"
  903.         unless $data_weapons[index].name == nil
  904.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  905.         end
  906.       when "a"
  907.         unless $data_armors[index].name == nil
  908.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  909.         end
  910.       when "s"
  911.         unless $data_skills[index].name == nil
  912.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  913.         end
  914.       else
  915.       r = $game_variables[index]
  916.     end
  917.     r == nil ? r = "" : nil
  918.     return r
  919.   end
  920.   #--------------------------------------------------------------------------
  921.   # ● 释放
  922.   #--------------------------------------------------------------------------
  923.   def dispose
  924.     terminate_message
  925.     unless @opacity_text_buf.disposed?
  926.       @opacity_text_buf.dispose
  927.     end
  928.     $game_temp.message_window_showing = false
  929.     if @input_number_window != nil
  930.       @input_number_window.dispose
  931.     end
  932.     super
  933.   end
  934.   #--------------------------------------------------------------------------
  935.   # ● 刷新光标矩形
  936.   #--------------------------------------------------------------------------
  937.   def update_cursor_rect
  938.     if @index >= 0
  939.       n = $game_temp.choice_start + @index
  940.       self.cursor_rect.set(4 + @indent + @face_indent, n * line_height, @cursor_width, line_height)
  941.     else
  942.       self.cursor_rect.empty
  943.     end
  944.   end
  945.   #--------------------------------------------------------------------------
  946.   # ● 设置不透明度(所有组件)
  947.   #--------------------------------------------------------------------------
  948.   def all_opa=(opa)
  949.     opa = [255, [opa, 0].max].min
  950.     @all_opa = opa
  951.     if $game_system.message_frame == 0
  952.       self.opacity = opa
  953.       @k_tale.opacity = opa if @k_tale
  954.     else
  955.       self.opacity = 0
  956.       @k_tale.opacity = 0 if @k_tale
  957.     end
  958.     self.contents_opacity = opa
  959.     @gold_window.opacity = opa if @gold_window
  960.     @name_window_text.contents_opacity = opa if @name_window_text
  961.     @right_picture.opacity = opa if @right_picture
  962.     @left_picture.opacity = opa if @left_picture
  963.     @bar.opacity = opa if @bar
  964.   end
  965.   #--------------------------------------------------------------------------
  966.   # ● 获取不透明度(所有组件)
  967.   #--------------------------------------------------------------------------
  968.   def all_opa
  969.     @all_opa
  970.   end
  971. end
  972. #==============================================================================
  973. # ■ Air_Text
  974. #------------------------------------------------------------------------------
  975. #   空气文字,借助窗口显示文字,但是不显示窗口载体。
  976. #==============================================================================
  977. class Air_Text < Window_Base
  978.   #--------------------------------------------------------------------------
  979.   # ● 对象初始化
  980.   #--------------------------------------------------------------------------
  981.   def initialize(x, y, designate_text, color)
  982.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  983.     self.opacity = 0
  984.     self.back_opacity = 0
  985.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  986.     self.contents.font.size = 20
  987.     self.contents.font.color = color
  988.     w = self.contents.width
  989.     h = self.contents.height
  990.     self.contents.draw_text(0, 0, w, h, designate_text)
  991.   end
  992.   

  993.   #--------------------------------------------------------------------------
  994.   # ● 释放
  995.   #--------------------------------------------------------------------------
  996.   def dispose
  997.     self.contents.clear
  998.     super
  999.   end
  1000. end

  1001. class Interpreter
  1002.   include RB::Mes_Config
  1003.   #--------------------------------------------------------------------------
  1004.   # ● 显示文章
  1005.   #--------------------------------------------------------------------------
  1006.   def command_101
  1007.     # 另外的文章已经设置过 message_text 的情况下
  1008.     if $game_temp.message_text != nil
  1009.       # 结束
  1010.       return false
  1011.     end
  1012.     # 设置信息结束后待机和返回调用标志
  1013.     @message_waiting = true
  1014.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  1015.     # message_text 设置为 1 行
  1016.     # check whether \+ exists
  1017.     append = /\\\+$/ =~ @list[@index].parameters[0]
  1018.     line = @list[@index].parameters[0].sub(/\\\+$/, "")
  1019.     $game_temp.message_text = line + "\n"
  1020.     line_count = 1
  1021.     # 循环
  1022.     loop do
  1023.       # 下一个事件指令为文章两行以上的情况
  1024.       if @list[@index+1].code == 401 || @list[@index+1].code == 101 && append
  1025.         append = /\\\+$/ =~ @list[@index+1].parameters[0]
  1026.         line = @list[@index+1].parameters[0].sub(/\\\+$/, "")
  1027.         # message_text 添加到第 2 行以下
  1028.         $game_temp.message_text += line + "\n"
  1029.         line_count += 1
  1030.       # 事件指令不在文章两行以下的情况
  1031.       else
  1032.         # 下一个事件指令为显示选择项的情况下
  1033.         if @list[@index+1].code == 102
  1034.           # 如果选择项能收纳在画面里
  1035.           if @list[@index+1].parameters[0].size <= Max_Lines - line_count
  1036.             # 推进索引
  1037.             @index += 1
  1038.             # 设置选择项
  1039.             $game_temp.choice_start = line_count
  1040.             setup_choices(@list[@index].parameters)
  1041.           end
  1042.         # 下一个事件指令为处理输入数值的情况下
  1043.         elsif @list[@index+1].code == 103
  1044.           # 如果数值输入窗口能收纳在画面里
  1045.           if line_count < Max_Lines
  1046.             # 推进索引
  1047.             @index += 1
  1048.             # 设置输入数值
  1049.             $game_temp.num_input_start = line_count
  1050.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  1051.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  1052.           end
  1053.         end
  1054.         # 继续
  1055.         return true
  1056.       end
  1057.       # 推进索引
  1058.       @index += 1
  1059.     end
  1060.   end
  1061. end

  1062. class Scene_Map
  1063.   include RB::Mes_Config
  1064.   alias rb_update_20160408 update
  1065.   def update
  1066.     if @rb_mes_disabled != $game_switches[Mes_Disabled]
  1067.       @rb_mes_disabled = $game_switches[Mes_Disabled]
  1068.       @message_window.dispose if @message_window != nil
  1069.       @message_window = @rb_mes_disabled ? Window_Message.new : Window_Message_RB.new
  1070.     end
  1071.     rb_update_20160408
  1072.   end
  1073. end

  1074. class Scene_Battle
  1075.   include RB::Mes_Config
  1076.   alias rb_update_20160408 update
  1077.   def update
  1078.     if @rb_mes_disabled != $game_switches[Mes_Disabled]
  1079.       @rb_mes_disabled = $game_switches[Mes_Disabled]
  1080.       @message_window.dispose if @message_window != nil
  1081.       @message_window = @rb_mes_disabled ? Window_Message.new : Window_Message_RB.new
  1082.     end
  1083.     rb_update_20160408
  1084.   end
  1085. end


  1086. #==============================================================================
  1087. # 本脚本来自https://rpg.blue,使用和转载请保留此信息
  1088. #==============================================================================
复制代码

[/fold]


[fold=以下是fuki的气泡对话框脚本]
  1. #==============================================================================
  2. # ■ Fuki_v6_Setup
  3. #------------------------------------------------------------------------------
  4. #    Fuki对话框优化版 v6 参数设置
  5. #==============================================================================

  6. module Fuki_v6_Setup
  7.    
  8.   #--------------------------------------------------------------------------
  9.   # ● 外观
  10.   #--------------------------------------------------------------------------
  11.   
  12.     # 窗口透明度
  13.     FUKI_OPACITY = 255         # 呼出对话框
  14.     MES_OPACITY  = 160         # 默认信息窗口
  15.    
  16.     # 角色高度尺寸
  17.     CHARACTOR_HEIGHT = 50
  18.    
  19.     # 呼出对话框的相对位置(纵坐标)
  20.     POP_SHIFT_TOP = 0          # 表示位置为上的时候
  21.     POP_SHIFT_UNDER = -4       # 表示位置为下的时候
  22.    
  23.     # 信息的表示速度(数字越小速度越快,0为瞬间表示)
  24.     # 游戏中可以随时用数字代入 $MES_SPEED 来改变消息表示速度。
  25.     MES_SPEED = 1
  26.    
  27.     # 名称修饰符(一对)(此处参考 沉影不器 的VX版对话框加强)
  28.     NAME_SYMBOL = "【】"
  29.    
  30.     # 名称颜色
  31.     NAME_COLOR = 7
  32.   
  33.   #--------------------------------------------------------------------------
  34.   # ● 功能( true / false )
  35.   #--------------------------------------------------------------------------
  36.    
  37.     # 是否显示尾巴
  38.     TAIL_SHOW = true
  39.    
  40.     # 是否播放打字音效
  41.     $play_voice = true
  42.    
  43.     # $MES_SPEED不为0时,是否可以用确定键快速显示对话
  44.     ENABLE_SKIP = true

  45.     # 窗口表示时是否根据画面大小自动改变窗口出现的位置
  46.     POS_FIX = true
  47.    
  48.   #--------------------------------------------------------------------------
  49.   # ● 字体
  50.   #--------------------------------------------------------------------------
  51.   
  52.     # 预设字体组
  53.     FONT_ARRAY = ["黑体", "宋体", "仿宋"]
  54.    
  55.     # 默认字号【已知BUG,当默认字号不为20时会导致各种奇怪问题……暂未修正】
  56.     MES_FONT_SIZE = 20
  57.    
  58.     # 默认字体颜色
  59.     FUKI_COLOR = Color.new(0, 0, 0, 255)
  60.   
  61.   #--------------------------------------------------------------------------
  62.   # ● 目录
  63.   #--------------------------------------------------------------------------
  64.   
  65.     # 呼出对话框用Skin名称(自动在 Graphics\Windowskins 内搜索)
  66.     FUKI_SKIN_NAME = "Window"
  67.    
  68.     # 设定头像图片保存目录
  69.     FACE_PIC_DIR = "Graphics/Faces/"

  70.   #--------------------------------------------------------------------------
  71.   # ● 头像对应表
  72.   #--------------------------------------------------------------------------
  73.   #    如果不想使用角色名字直接作为头像文件名
  74.   #    可在这里重新设定角色名字与文件名的对应关系
  75.   #
  76.   #  (这功能怎么用我自己也没搞明白……大家无视吧 by 各种压力的猫君)
  77.   #--------------------------------------------------------------------------
  78.   
  79.     NAME_TABLE = {"玩家"=>"维斯特"}
  80.    
  81. end
  82. #==============================================================================
  83.   
  84. "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
  85. "┃        自定义内容到此结束,以下内容切勿随意修改        ┃"
  86. "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"

  87. #==============================================================================
  88. # ● 初始化全局变量并定义chat方法
  89. #==============================================================================
  90. $mes_id   = nil
  91. $mes_name = ""
  92. def chat(id = nil,name = "")
  93.   $mes_id = id
  94.   $mes_name = name
  95. end

  96. #==============================================================================
  97. # ■ Game_Temp
  98. #==============================================================================

  99. class Game_Temp
  100.   #--------------------------------------------------------------------------
  101.   # ● 定义实例变量
  102.   #--------------------------------------------------------------------------
  103.   attr_accessor:namebmp      # 记录角色名字和头像文件名对应关系
  104.   #--------------------------------------------------------------------------
  105.   # ● 初始化对像
  106.   #--------------------------------------------------------------------------
  107.   alias initialize_fuki initialize
  108.   def initialize
  109.     initialize_fuki
  110.     @namebmp = Fuki_v6_Setup::NAME_TABLE
  111.   end
  112. end

  113. #==============================================================================
  114. # ■ Window_InputNumber
  115. #==============================================================================

  116. class Window_InputNumber < Window_Base
  117.   #--------------------------------------------------------------------------
  118.   # ● 初始化对像
  119.   #     digits_max : 位数
  120.   #--------------------------------------------------------------------------
  121.   def initialize(digits_max)
  122.     @digits_max = digits_max
  123.     @number = 0
  124.     # 从数字的幅度计算(假定与 0~9 等幅)光标的幅度
  125.     dummy_bitmap = Bitmap.new(Fuki_v6_Setup::MES_FONT_SIZE, Fuki_v6_Setup::MES_FONT_SIZE)
  126.     @cursor_width = dummy_bitmap.text_size("0").width + 8
  127.     dummy_bitmap.dispose
  128.     super(0, 0, @cursor_width * @digits_max + 32, 64)
  129.     self.contents = Bitmap.new(width - 32, height - 32)
  130.     self.contents.font.size = Fuki_v6_Setup::MES_FONT_SIZE
  131.     self.contents.font.color = Fuki_v6_Setup::FUKI_COLOR
  132.     self.z += 9999
  133.     self.opacity = 0
  134.     @index = 0
  135.     refresh
  136.     update_cursor_rect
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 更新光标矩形
  140.   #--------------------------------------------------------------------------
  141.   def update_cursor_rect
  142.     self.cursor_rect.set(@index * @cursor_width-4, 0, @cursor_width, Fuki_v6_Setup::MES_FONT_SIZE + 4)
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 刷新
  146.   #--------------------------------------------------------------------------
  147.   def refresh
  148.     self.contents.clear
  149.     s = sprintf("%0*d", @digits_max, @number)
  150.     for i in 0...@digits_max
  151.       self.contents.draw_text(i * @cursor_width, 0, 24, Fuki_v6_Setup::MES_FONT_SIZE + 4, s[i,1])
  152.     end
  153.   end
  154. end

  155. #==============================================================================
  156. # ■ Window_Message
  157. #==============================================================================

  158. class Window_Message < Window_Selectable
  159.   
  160.   #--------------------------------------------------------------------------
  161.   # ● 初始化状态
  162.   #--------------------------------------------------------------------------
  163.   def initialize
  164.     super(80, 304, 480, 160)
  165.     self.contents = Bitmap.new(width - 32, height - 32)
  166.     self.contents.font.color = text_color(0)
  167.     self.visible = false
  168.     self.z = 9998
  169.     @fade_in = false
  170.     @fade_out = false
  171.     @contents_showing = false
  172.     @cursor_width = 0
  173.     self.active = false
  174.     self.index = -1
  175.     @w = 0
  176.     @h = 0
  177.     @wait = 0
  178.     @dx = 0
  179.     @dy = 0
  180.     $MES_SPEED = Fuki_v6_Setup::MES_SPEED
  181.     #------------------------
  182.     # ★ 特殊时期中断标志
  183.     #------------------------
  184.     @no_term_stop = false
  185.     @save_x = 0
  186.     @save_y = 0
  187.     @old_text_info = []
  188.     @show_right = false
  189.     @show_name  = false
  190.     @face_width = 0
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ○ 决定窗口尺寸并生成窗口
  194.   #--------------------------------------------------------------------------
  195.   def refresh_create
  196.     unless @no_term_stop
  197.       @pic_skin.dispose if @pic_skin != nil
  198.       if $game_temp.message_text.include?(":")
  199.         if $game_temp.message_text.include?("@r")
  200.           @show_right = true
  201.           $game_temp.message_text.sub!(/\@r/, "")
  202.         end
  203.         @show_name = true
  204.         # 添加名称修饰符
  205.         unless Fuki_v6_Setup::NAME_SYMBOL.empty?
  206.           $game_temp.message_text = '\c[' + Fuki_v6_Setup::NAME_COLOR.to_s + ']' + Fuki_v6_Setup::NAME_SYMBOL[0,Fuki_v6_Setup::NAME_SYMBOL.size/2] + $game_temp.message_text
  207.           $game_temp.message_text.sub!(/\:/, Fuki_v6_Setup::NAME_SYMBOL[Fuki_v6_Setup::NAME_SYMBOL.size/2,Fuki_v6_Setup::NAME_SYMBOL.size/2] + '\c[0]')
  208.         end
  209.       end
  210.       self.contents.clear
  211.       self.contents.font.color = normal_color
  212.       # 取得窗口尺寸
  213.       get_windowsize
  214.       w = @w + 40
  215.       h = @h * (self.contents.font.size + 4) + 30
  216.       h = 64 if h < 64
  217.       # 生成呼出窗口
  218.       set_fukidasi(self.x, self.y, w, h)
  219.       draw_msg_face
  220.       create_backbmp
  221.     end
  222.     # 初始化信息表示使用的变量
  223.     @dx = @save_x
  224.     @dx += @face_width unless @show_right
  225.     @dy = @save_y
  226.     @cursor_width = 0
  227.     @contents_drawing = true
  228.     # 瞬间表示的情况下
  229.     if $MES_SPEED == 0
  230.       # 循环信息描绘处理
  231.       while $game_temp.message_text != ""
  232.         draw_massage
  233.       end
  234.       draw_opt_text
  235.       @contents_showing_end = true
  236.       @contents_drawing = false
  237.     else
  238.       # 一个一个描绘文字
  239.       refresh_drawtext
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ○ 一个一个描绘文字
  244.   #--------------------------------------------------------------------------
  245.   def refresh_drawtext
  246.     # 当按下确定键的时候直接显示剩余的全部文字
  247.     if Input.trigger?(Input::C) and Fuki_v6_Setup::ENABLE_SKIP
  248.       # 循环信息描绘处理
  249.       while $game_temp.message_text != ""
  250.         draw_massage
  251.       end
  252.       draw_opt_text
  253.       @contents_showing_end = true
  254.       @contents_drawing = false
  255.     elsif $game_temp.message_text != ""
  256.       if @wait > 0
  257.         @wait -= 1
  258.       elsif @wait == 0
  259.         # 描绘处理
  260.         draw_massage
  261.         @wait = $MES_SPEED
  262.       end
  263.     else
  264.       draw_opt_text
  265.       @contents_showing_end = true
  266.       @contents_drawing = false
  267.     end
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ○ 取得窗口尺寸
  271.   #--------------------------------------------------------------------------
  272.   def get_windowsize
  273.     get_face_width($mes_name)
  274.     x = y = 0
  275.     @h = @w = 0
  276.     @cursor_width = 0
  277.     # 有选择项的话,处理字的缩进
  278.     if $game_temp.choice_start == 0
  279.       x = 16
  280.     end
  281.     # 有等待显示的文字的情况下
  282.     if $game_temp.message_text != nil
  283.     text = $game_temp.message_text.clone
  284.       # 限制文字处理
  285.       begin
  286.         last_text = text.clone
  287.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  288.       end until text == last_text
  289.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  290.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  291.       end
  292.       text.gsub!(/\\\\/)                 { "\x00" }
  293.       text.gsub!(/\\[Cc]\[([0-9]+)\]/)   { "\x01" }
  294.       text.gsub!(/\\[Gg]/)               { "\x02" }
  295.       text.gsub!(/\\[Ss]\[([0-9]+)\]/)   { "\x03" + $data_skills[$1.to_i].name }
  296.       text.gsub!(/\\[Ii]\[([0-9]+)\]/)   { "\x04" + $data_items[$1.to_i].name }
  297.       text.gsub!(/\\[Ww]\[([0-9]+)\]/)   { "\x05" + $data_weapons[$1.to_i].name }
  298.       text.gsub!(/\\[Aa]\[([0-9]+)\]/)   { "\x06" + $data_armors[$1.to_i].name }
  299.       text.gsub!(/\\[Rr]\[([0-9]+)\]/)   { "\x10" + $game_actors[$1.to_i].name }
  300.       # c 获取 1 个字 (如果不能取得文字就循环)
  301.       while ((c = text.slice!(/./m)) != nil)
  302.         if c == "\x00"
  303.           c = "\"
  304.         end
  305.         if c == "\x01" or c == "\x02"
  306.           next
  307.         end
  308.         if c == "\x03" or c == "\x04" or c == "\x05" or c == "\x06" or c == "\x010"
  309.           c = "   "
  310.         end
  311.         if c == "\n"
  312.           # y 累加 1
  313.           y += 1
  314.           # 取得纵横尺寸
  315.           @h = y
  316.           @w = x > @w ? x : @w
  317.           if y >= $game_temp.choice_start
  318.             @w = x + Fuki_v6_Setup::MES_FONT_SIZE > @w ? x + Fuki_v6_Setup::MES_FONT_SIZE : @w
  319.           end
  320.           x = 0
  321.           x = Fuki_v6_Setup::MES_FONT_SIZE if y >= $game_temp.choice_start
  322.           # 下面的文字
  323.           next
  324.         end
  325.         # x 为要描绘文字的宽度加法运算
  326.         x += self.contents.text_size(c).width
  327.       end
  328.     end
  329.     # 输入数值的情况
  330.     if $game_temp.num_input_variable_id > 0
  331.       digits_max = $game_temp.num_input_digits_max
  332.       number = $game_variables[$game_temp.num_input_variable_id]
  333.       @h += 1
  334.       x = digits_max * self.contents.font.size + 16
  335.       @w = x > @w ? x : @w
  336.     end
  337.     @w += @face_width
  338.     @w = 128 if @w < 128
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ○ 描绘信息处理
  342.   #--------------------------------------------------------------------------
  343.   def draw_massage
  344.     # 有等待显示的文字的情况下
  345.     if $game_temp.message_text != nil or @old_text_info != nil
  346.       text = $game_temp.message_text
  347.       # 限制文字处理
  348.       begin
  349.         last_text = text.clone
  350.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  351.       end until text == last_text
  352.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  353.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  354.       end
  355.       text.gsub!(/\\\\/)                 { "\x00" }
  356.       text.gsub!(/\\[Cc]\[([0-9]+)\]/)   { "\x01[#{$1}]" }
  357.       text.gsub!(/\\[Gg]/)               { "\x02" }
  358.       text.gsub!(/\\[Ss]\[([0-9]+)\]/)   { "\x03[#{$1}]" }
  359.       text.gsub!(/\\[Ii]\[([0-9]+)\]/)   { "\x04[#{$1}]" }
  360.       text.gsub!(/\\[Ww]\[([0-9]+)\]/)   { "\x05[#{$1}]" }
  361.       text.gsub!(/\\[Aa]\[([0-9]+)\]/)   { "\x06[#{$1}]" }
  362.       text.gsub!(/\\[Oo]\[([0-9]+)\]/)   { "\x07[#{$1}]" }
  363.       text.gsub!(/\\[Qq]/)               { "\x08" }
  364.       text.gsub!(/\\[Ff]\[([0-9]+)\]/)   { "\x09[#{$1}]" }
  365.       text.gsub!(/\\[Rr]\[([0-9]+)\]/)   { "\x10[#{$1}]" }
  366.       # c 获取 1 个字
  367.       c = text.slice!(/./m)
  368.       # 默认对话框采用默认颜色
  369.       self.contents.font.color = normal_color if $mes_id == nil
  370.       # 选择项的情况
  371.       if @dy >= $game_temp.choice_start
  372.         # 处理字的缩进
  373.         @dx = Fuki_v6_Setup::MES_FONT_SIZE
  374.         @dx += @face_width unless @show_right
  375.         @dx += Fuki_v6_Setup::MES_FONT_SIZE if @show_name
  376.         # 描绘文字
  377.         self.contents.draw_text(@dx, 24 * @dy, 24, 24, c)
  378.         # x 为要描绘文字宽度的加法运算
  379.         @dx += self.contents.text_size(c).width
  380.         # 循环
  381.         while ((c = text.slice!(/./m)) != "\n")
  382.           # 描绘文字
  383.           self.contents.draw_text(@dx, 24 * @dy, 24, 24, c)
  384.           # x 为要描绘文字宽度的加法运算
  385.           @dx += self.contents.text_size(c).width
  386.         end
  387.         if c == "\n"
  388.           # 更新光标宽度
  389.           @cursor_width = [@cursor_width, @dx - @face_width].max
  390.           # dy 累加 1
  391.           @dy += 1
  392.         end
  393.         return
  394.       end
  395.       case c
  396.       when "\x00"
  397.         c = "\"            
  398.       when "\x01"                  
  399.         text.sub!(/\[([0-9]+)\]/, "")
  400.         color = $1.to_i
  401.         self.contents.font.color = text_color(color)
  402.       when "\x02"
  403.         @contents_showing_end = true
  404.         @contents_drawing = false
  405.         terminate_messageX
  406.         @save_x = @dx
  407.         @save_y = @dy
  408.       when "\x03"
  409.         text.sub!(/\[([0-9]+)\]/, "")
  410.         last_character
  411.         draw_icon($data_skills[$1.to_i], 4 + @dx, 24 * @dy)
  412.         @dx += self.contents.text_size("   ").width
  413.       when "\x04"
  414.         text.sub!(/\[([0-9]+)\]/, "")
  415.         last_character
  416.         draw_icon($data_items[$1.to_i], 4 + @dx, 24 * @dy)
  417.         @dx += self.contents.text_size("   ").width
  418.       when "\x05"
  419.         text.sub!(/\[([0-9]+)\]/, "")
  420.         last_character
  421.         draw_icon($data_weapons[$1.to_i], 4 + @dx, 24 * @dy)
  422.         @dx += self.contents.text_size("   ").width
  423.       when "\x06"
  424.         text.sub!(/\[([0-9]+)\]/, "")
  425.         last_character
  426.         draw_icon($data_armors[$1.to_i], 4 + @dx, 24 * @dy)
  427.         @dx += self.contents.text_size("   ").width
  428.       when "\x07"
  429.         text.sub!(/\[([0-9]+)\]/, "")
  430.         self.contents.font.color.alpha = $1.to_i
  431.       when "\x08"
  432.         text.sub!(/\[([0-9]+)\]/, "")
  433.         $play_voice = !$play_voice
  434.       when "\x09"
  435.         text.sub!(/\[([0-9]+)\]/, "")
  436.         self.contents.font.name = Fuki_v6_Setup::FONT_ARRAY[$1.to_i]
  437.       when "\x10"
  438.         text.sub!(/\[([0-9]+)\]/, "")
  439.         last_character
  440.         draw_actor_graphic($game_actors[$1.to_i], 4 + @dx, 24 * @dy)
  441.         @dx += self.contents.text_size("   ").width
  442.       when "\n"
  443.         @dy += 1
  444.         @dx = 0
  445.         @dx += @face_width unless @show_right
  446.         @dx += Fuki_v6_Setup::MES_FONT_SIZE if @show_name
  447.         last_character
  448.       else
  449.         last_character
  450.         size_zy = 6  # 设定文字动态增大幅度
  451.         if c != nil
  452.           self.contents.font.size = Fuki_v6_Setup::MES_FONT_SIZE
  453.           font_size = self.contents.font.size += size_zy
  454.           @old_text_info.push(@dx , @dy , font_size, self.contents.font.color.clone, c)
  455.           self.contents.draw_text(4 + @dx, (font_size + 4 - size_zy) * @dy - size_zy / 2, font_size, font_size, c)
  456.           self.contents.font.size -= size_zy
  457.           Audio.se_play("Audio/SE/Voice", 90, 100) if $play_voice and c != " "
  458.           @dx += self.contents.text_size(c).width
  459.         end
  460.       end
  461.     end
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ○ 完成上一个字符的描绘
  465.   #--------------------------------------------------------------------------
  466.   def last_character
  467.     size_zy = 6  # 设定文字动态增大幅度
  468.     unless @old_text_info == []
  469.       self.contents.fill_rect (4 + @old_text_info[0], (@old_text_info[2]+ 4 - size_zy) * @old_text_info[1] - size_zy / 2, @old_text_info[2], @old_text_info[2], Color.new(0,0,0,0))
  470.       color = self.contents.font.color.clone
  471.       self.contents.font.color = @old_text_info[3].clone
  472.       self.contents.font.size = @old_text_info[2] -= size_zy
  473.       self.contents.draw_text(4 + @old_text_info[0], (@old_text_info[2] + 4) * @old_text_info[1], @old_text_info[2], @old_text_info[2], @old_text_info[4])
  474.       self.contents.font.color = color
  475.       @old_text_info = []
  476.     end
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ○ 选择项和输入数值的情况下
  480.   #--------------------------------------------------------------------------
  481.   def draw_opt_text
  482.     # 选择项的情况下
  483.     if $game_temp.choice_max > 0
  484.       @item_max = $game_temp.choice_max
  485.       self.active = true
  486.       self.index = 0
  487.     end
  488.     # 输入数值的情况下
  489.     if $game_temp.num_input_variable_id > 0
  490.       digits_max = $game_temp.num_input_digits_max
  491.       number = $game_variables[$game_temp.num_input_variable_id]
  492.       @input_number_window = Window_InputNumber.new(digits_max)
  493.       @input_number_window.number = number
  494.       @input_number_window.x = self.x + @face_width + Fuki_v6_Setup::MES_FONT_SIZE + 8
  495.       @input_number_window.y = self.y + $game_temp.num_input_start * (Fuki_v6_Setup::MES_FONT_SIZE + 2)
  496.     end
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # ○ 生成背景图片
  500.   #--------------------------------------------------------------------------
  501.   def create_backbmp
  502.     @pic_skin.dispose if @pic_skin != nil
  503.     @pic_skin = Sprite.new
  504.     @pic_skin.opacity = 0 unless @no_term_stop
  505.     @pic_skin.bitmap = Bitmap.new(self.width + 32, self.height + 32)
  506.     @pic_skin.x = self.x + 2
  507.     @pic_skin.y = self.y + 2
  508.     @pic_skin.z = self.z
  509.     bitmap = RPG::Cache.windowskin(Fuki_v6_Setup::FUKI_SKIN_NAME)
  510.     rect = Rect.new(0, 0, 32, 32)
  511.     @pic_skin.bitmap.blt(0, 0, bitmap, rect)
  512.     rect = Rect.new(96, 0, 32, 32)
  513.     @pic_skin.bitmap.blt(self.width-32, 0, bitmap, rect)
  514.     rect = Rect.new(0, 96, 32, 32)
  515.     @pic_skin.bitmap.blt(0, self.height-32, bitmap, rect)
  516.     rect = Rect.new(96, 96, 32, 32)
  517.     @pic_skin.bitmap.blt(self.width-32, self.height-32, bitmap, rect)
  518.     rect = Rect.new(0, 32, 32, 32)
  519.     @pic_skin.bitmap.stretch_blt(Rect.new(0, 32, 32, self.height - 64), bitmap, rect)
  520.     rect = Rect.new(96, 32, 32, 32)
  521.     @pic_skin.bitmap.stretch_blt(Rect.new(self.width-32,32,32,self.height-64), bitmap, rect)
  522.     rect = Rect.new(32, 0, 32, 32)
  523.     @pic_skin.bitmap.stretch_blt(Rect.new(32,0,self.width-64,self.height-32), bitmap, rect)
  524.     # 如果尾巴在底端的话,更改底边描绘方式以修正阴影
  525.     if @message_position == 0 and @tale != nil
  526.       # 乱七八糟的三个计算变量
  527.       above_tale_x = @tale.x - self.x + 14
  528.       above_tale_width1 = @tale.x - self.x - 16 - 2
  529.       above_tale_width2 = self.width - above_tale_width1 - 32 - 64
  530.       # 中部(尾巴上方)
  531.       rect = Rect.new(32, 96, 32, 16)
  532.       @pic_skin.bitmap.stretch_blt(Rect.new(above_tale_x , self.height-32, 32, 24), bitmap, rect)
  533.       # 左半部
  534.       rect = Rect.new(32, 96, 32, 32)
  535.       @pic_skin.bitmap.stretch_blt(Rect.new(32, self.height-32, above_tale_width1, 32), bitmap, rect)
  536.       # 右半部
  537.       @pic_skin.bitmap.stretch_blt(Rect.new(32+above_tale_x, self.height-32, above_tale_width2, 32), bitmap, rect)
  538.       bitmap.dispose
  539.     else # 除此之外的情况保留原来的底边描绘方式
  540.       rect = Rect.new(32, 96, 32, 32)
  541.       @pic_skin.bitmap.stretch_blt(Rect.new(32,self.height-32,self.width-64,32), bitmap, rect)
  542.       bitmap.dispose
  543.     end
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ○ 设置呼出对话框
  547.   #--------------------------------------------------------------------------
  548.   def set_fukidasi(x, y, width, height)
  549.     begin
  550.       self.pause = false # 不显示暂停标志
  551.       pos = get_fuki_pos(width, height) # 取得对话框位置
  552.       x = pos[0]
  553.       y = pos[1]
  554.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
  555.       self.x = x
  556.       self.y = y
  557.       self.height = height
  558.       self.width = width
  559.       unless @no_term_stop
  560.         self.contents.dispose
  561.         self.contents = Bitmap.new(width - 32, height - 32)
  562.         self.back_opacity = Fuki_v6_Setup::FUKI_OPACITY
  563.         self.contents.clear
  564.         self.contents.font.color = Color.new(0, 0, 0, 255)
  565.         self.contents.font.size = Fuki_v6_Setup::MES_FONT_SIZE
  566.       end
  567.       if $game_system.message_frame == 0
  568.         tale_pos = get_tale_pos
  569.         @tale = Sprite.new
  570.         @tale.bitmap = Bitmap.new(64, 32)
  571.         if Fuki_v6_Setup::TAIL_SHOW
  572.           case @message_position
  573.           when 0  # 上
  574.             bitmap = RPG::Cache.windowskin(Fuki_v6_Setup::FUKI_SKIN_NAME)
  575.             rect = Rect.new(32, 32, 64, 32)
  576.             @tale.bitmap.blt(0, 0, bitmap, rect)
  577.             bitmap.dispose
  578.             @tale.x = tale_pos[0]
  579.             @tale.x += 8 if @tale.x < 64
  580.             if @tale.x > 640 - 64
  581.               @tale.mirror = true
  582.               @tale.x -= 64
  583.             end
  584.             @tale.y = tale_pos[1]
  585.             @tale.z = self.z + 1
  586.           when 1  # 中
  587.             @tale.dispose
  588.             @tale = nil
  589.           when 2  # 下
  590.             bitmap = RPG::Cache.windowskin(Fuki_v6_Setup::FUKI_SKIN_NAME)
  591.             rect = Rect.new(32, 64, 64, 32)
  592.             @tale.bitmap.blt(0, 0, bitmap, rect)
  593.             bitmap.dispose
  594.             @tale.x = tale_pos[0]
  595.             @tale.x += 8 if @tale.x < 64
  596.             if @tale.x > 640 - 64
  597.               @tale.mirror = true
  598.               @tale.x -= 64
  599.             end
  600.             @tale.y = tale_pos[1]
  601.             @tale.z = self.z# + 1
  602.           end
  603.         end
  604.       end
  605.     rescue
  606.       del_fukidasi
  607.       reset_window(width, height)
  608.     end
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ○ 计算呼出对话框的位置
  612.   #--------------------------------------------------------------------------
  613.   def get_fuki_pos(width, height)
  614.     # 取得角色
  615.     @character = get_character($mes_id)
  616.     if @character == nil
  617.       # 角色不存在的情况下使用默认信息框
  618.       
  619.       del_fukidasi
  620.       reset_window(width, height)
  621.       return
  622.     end
  623.     # 处理坐标
  624.     x = (@character.real_x - $game_map.display_x + 64) * 32 / 128 - (width / 2)
  625.     # 为尽量显示在画面内而移动横坐标
  626.     if x + width > 640
  627.       x = 640 - width
  628.     elsif x < 0
  629.       x = 0
  630.     end
  631.     # 决定窗口位置
  632.     case $game_system.message_position
  633.     when 0  # 上
  634.       y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - Fuki_v6_Setup::CHARACTOR_HEIGHT + Fuki_v6_Setup::POP_SHIFT_TOP
  635.     when 1  # 中
  636.       x = (640 - width) / 2
  637.       y = (480 - height) / 2
  638.     when 2  # 下
  639.       y =  (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + Fuki_v6_Setup::POP_SHIFT_UNDER
  640.     end
  641.     # 纪录文章显示位置
  642.     @message_position = $game_system.message_position
  643.     if Fuki_v6_Setup::POS_FIX
  644.       case @message_position
  645.       when 0  # 上
  646.         if y <= 0
  647.           @message_position = 2
  648.           y =  (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + Fuki_v6_Setup::POP_SHIFT_UNDER
  649.         end
  650.       when 2  # 下
  651.         if y + height >= 480
  652.           @message_position = 0
  653.           y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - Fuki_v6_Setup::CHARACTOR_HEIGHT + Fuki_v6_Setup::POP_SHIFT_TOP
  654.         end
  655.       end
  656.     end
  657.     return [x, y]
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # ○ 计算尾部图标的位置
  661.   #--------------------------------------------------------------------------
  662.   def get_tale_pos
  663.     case @message_position
  664.     when 0  # 上
  665.       # 处理坐标
  666.       x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 8
  667.       y = self.y + self.height - 6
  668.     when 1  # 中
  669.       x = nil
  670.       y = nil
  671.     when 2  # 下
  672.       # 处理坐标
  673.       x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 8
  674.       y = self.y - 18
  675.     end
  676.     return [x, y]
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # ○ 设置角色半身像窗口
  680.   #--------------------------------------------------------------------------
  681.   def draw_msg_face
  682.     @face_sprite.dispose if @face_sprite != nil
  683.     # $mes_name为空时不显示
  684.     if $mes_name == nil or $mes_name == ""
  685.       return
  686.     else
  687.       # 设定变量
  688.       mes_name = $mes_name
  689.       if $game_temp.namebmp[mes_name] == nil
  690.         sFile = Fuki_v6_Setup::FACE_PIC_DIR + mes_name
  691.       else
  692.         sFile = Fuki_v6_Setup::FACE_PIC_DIR + $game_temp.namebmp[mes_name]
  693.       end
  694.       bitmap = Bitmap.new(sFile)
  695.       @pic_width = bitmap.width
  696.       @pic_height = bitmap.height
  697.       @face_sprite = Sprite.new
  698.       @face_sprite.x = self.x + 26
  699.       @face_sprite.x = self.x + self.width - @pic_width - 26 if @show_right
  700.       @face_sprite.y = self.y + self.height - @pic_height - 6
  701.       @face_sprite.bitmap = bitmap
  702.       @face_sprite.z = self.z + 3
  703.       @face_sprite.mirror = @show_right
  704.       @face_sprite.opacity = 0
  705.     end
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # ○ 释放呼出对话框
  709.   #--------------------------------------------------------------------------
  710.   def del_fukidasi
  711.     self.opacity = 0
  712.     self.x = 80
  713.     self.width = 480
  714.     self.height = 160
  715.     self.contents.dispose
  716.     self.contents = Bitmap.new(width - 32, height - 32)
  717.     self.pause = true
  718.     if @tale != nil
  719.       @tale.dispose
  720.       @tale = nil
  721.     end
  722.   end
  723.   #--------------------------------------------------------------------------
  724.   # ○ 取得角色
  725.   #     parameter : 参数
  726.   #--------------------------------------------------------------------------
  727.   def get_character(parameter)
  728.     # 参数分歧
  729.     case parameter
  730.     when nil
  731.       return events == nil
  732.     when -1  # 玩家
  733.       return $game_player
  734.     when 0   # 该事件
  735.       events = $game_map.events
  736.       # 循环 (地图事件)
  737.       for event in $game_map.events.values
  738.         # 如果找到了启动中的事件
  739.         if event.starting
  740.           @event_id = event.id
  741.         end
  742.       end
  743.       return events == nil ? nil : events[@event_id]
  744.     else     # 特定事件
  745.       events = $game_map.events
  746.       return events == nil ? nil : events[parameter]
  747.     end
  748.   end
  749.   #--------------------------------------------------------------------------
  750.   # ● 设定窗口位置和不透明度
  751.   #--------------------------------------------------------------------------
  752.   def reset_window(width = nil, height = nil)
  753.     if $game_temp.in_battle
  754.       self.y = 16
  755.     else
  756.       case $game_system.message_position
  757.       when 0  # 上
  758.         self.y = 16
  759.       when 1  # 中
  760.         if height != nil and width != nil
  761.           self.y = (480 - height) / 2 - 32
  762.           self.x = (640 - width) / 2
  763.           self.width = width
  764.           self.height = height
  765.           self.contents.dispose
  766.           self.contents = Bitmap.new(width - 32, height - 32)
  767.         else
  768.           self.y = 160
  769.         end
  770.       when 2  # 下
  771.         self.y = 304
  772.       end
  773.     end
  774.     self.opacity = 0
  775.     self.back_opacity = Fuki_v6_Setup::MES_OPACITY
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # ● 刷新画面
  779.   #--------------------------------------------------------------------------
  780.   def update
  781.     if $tale_need_dispose
  782.       del_fukidasi
  783.       $tale_need_dispose = false
  784.     end
  785.     super
  786.     update_fuki                 # 呼出模式下跟随事件移动
  787.     if @fade_in                 # 渐变的情况下
  788.       self.contents_opacity += 24
  789.       @pic_skin.opacity += 20
  790.       if @tale != nil
  791.         @face_sprite.opacity += 24 if @face_sprite != nil and !@face_sprite.disposed?
  792.         @tale.opacity += 20
  793.       end
  794.       @input_number_window.contents_opacity += 24 if @input_number_window != nil
  795.       @fade_in = false if self.contents_opacity == 255
  796.       return
  797.     end
  798.     if @contents_drawing        # 显示信息中的情况下
  799.       refresh_drawtext
  800.       return
  801.     end
  802.     update_input_number_window  # 输入数值的情况下
  803.     if @contents_showing_end    # 显示信息结束的情况下
  804.       if $game_temp.choice_max == 0 and @tale == nil
  805.         self.pause = true
  806.       else
  807.         self.pause = false
  808.       end
  809.       update_choose
  810.       return
  811.     end
  812.     if @fade_out == false and $game_temp.message_text != nil # 在渐变以外的状态下
  813.       @contents_showing = true
  814.       $game_temp.message_window_showing = true
  815.       reset_window
  816.       refresh_create
  817.       if @no_term_stop
  818.         self.visible = true        
  819.       else
  820.         @tale.opacity = 0 if @tale != nil
  821.         Graphics.frame_reset
  822.         self.visible = true
  823.         self.contents_opacity = 0
  824.         @input_number_window.contents_opacity = 0 if @input_number_window != nil
  825.         @fade_in = true
  826.       end
  827.       return
  828.     end
  829.     unless @no_term_stop # 没有可以显示的信息、但是窗口为可见的情况下
  830.       if self.visible
  831.         @fade_out = true
  832.         self.opacity -= 48
  833.         @face_sprite.opacity -= 48 if @face_sprite != nil and !@face_sprite.disposed?
  834.         @pic_skin.opacity -= 48 if @pic_skin != nil and !@pic_skin.disposed?
  835.         @tale.opacity -= 48 if @tale != nil and !@tale.disposed?
  836.         if (@face_sprite == nil) or @face_sprite.disposed? or (@face_sprite.opacity == 0)
  837.           self.visible = false
  838.           @face_sprite.dispose if @face_sprite != nil
  839.           @pic_skin.dispose
  840.           @fade_out = false
  841.           $game_temp.message_window_showing = false
  842.         end
  843.         return
  844.       end
  845.     else
  846.       $game_temp.message_window_showing = false   
  847.     end
  848.   end
  849.   #--------------------------------------------------------------------------
  850.   # ● 释放
  851.   #--------------------------------------------------------------------------
  852.   def dispose
  853.     terminate_message
  854.     $game_temp.message_window_showing = false
  855.     @input_number_window.dispose if @input_number_window != nil
  856.     super
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # ● 信息结束处理
  860.   #--------------------------------------------------------------------------
  861.   def terminate_message
  862.     self.active = false
  863.     self.pause = false
  864.     self.index = -1
  865.     self.contents.clear
  866.     # 清除显示中标志
  867.     @contents_showing = false
  868.     @contents_showing_end = false
  869.     $mes_name = ""
  870.     # 呼叫信息调用
  871.     $game_temp.message_proc.call if $game_temp.message_proc != nil
  872.     # 清除文章、选择项、输入数值的相关变量
  873.     $game_temp.message_text = nil
  874.     $game_temp.message_proc = nil
  875.     $game_temp.choice_start = 99
  876.     $game_temp.choice_max = 0
  877.     $game_temp.choice_cancel_type = 0
  878.     $game_temp.choice_proc = nil
  879.     $game_temp.num_input_start = 99
  880.     $game_temp.num_input_variable_id = 0
  881.     $game_temp.num_input_digits_max = 0
  882.     # 释放金钱窗口
  883.     if @gold_window != nil
  884.       @gold_window.dispose
  885.       @gold_window = nil
  886.     end
  887.     @no_term_stop = false
  888.     @save_x = 0
  889.     @save_y = 0
  890.     @show_right = false
  891.     @show_name  = false
  892.     @face_width = 0
  893.     $tale_need_dispose = true if @tale != nil
  894.   end
  895.   #--------------------------------------------------------------------------
  896.   # ● ★信息结束处理★
  897.   #--------------------------------------------------------------------------
  898.   def terminate_messageX
  899.     self.active = false
  900.     self.pause = false
  901.     self.index = -1
  902.     # 清除显示中标志
  903.     @contents_showing = false
  904.     @contents_showing_end = false
  905.     # 呼叫信息调用
  906.     $game_temp.message_proc.call if $game_temp.message_proc != nil
  907.     # 清除文章、选择项、输入数值的相关变量
  908.     $game_temp.message_text = nil
  909.     $game_temp.message_proc = nil
  910.     @no_term_stop = true
  911.     @show_right = false
  912.     @show_name  = false
  913.     @face_width = 0
  914.   end
  915.   #--------------------------------------------------------------------------
  916.   # ● 刷新光标矩形
  917.   #--------------------------------------------------------------------------
  918.   def update_cursor_rect
  919.     if @index >= 0
  920.       n = $game_temp.choice_start + @index
  921.       self.cursor_rect.set(Fuki_v6_Setup::MES_FONT_SIZE / 2, n * (Fuki_v6_Setup::MES_FONT_SIZE + 4), @cursor_width, Fuki_v6_Setup::MES_FONT_SIZE + 4)
  922.       self.cursor_rect.x += @face_width unless @show_right
  923.       self.cursor_rect.x += Fuki_v6_Setup::MES_FONT_SIZE / 2 if @show_name
  924.     else
  925.       self.cursor_rect.empty
  926.     end
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # ● 获取文字颜色色
  930.   #     n : 文字颜色编号 (0~31)
  931.   #--------------------------------------------------------------------------
  932.   def text_color(n)
  933.     return normal_color if n > 31
  934.     x = (n % 8) * 16
  935.     y = 128 + (n / 8) * 16
  936.     return RPG::Cache.windowskin(Fuki_v6_Setup::FUKI_SKIN_NAME).get_pixel(x, y)
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # ● 取得普通文字色
  940.   #--------------------------------------------------------------------------
  941.   def normal_color
  942.     nil_color = Color.new(0,0,0,255)
  943.     return Fuki_v6_Setup::FUKI_COLOR if Fuki_v6_Setup::FUKI_COLOR != nil_color
  944.     return nil_color
  945.   end
  946.   #--------------------------------------------------------------------------
  947.   # ● 获取头像宽度
  948.   #--------------------------------------------------------------------------
  949.   def get_face_width(face_name)
  950.     return if $mes_name == ""
  951.     filename = Fuki_v6_Setup::FACE_PIC_DIR + face_name
  952.     bitmap = Bitmap.new(filename)
  953.     @face_width = bitmap.width + Fuki_v6_Setup::MES_FONT_SIZE
  954.     bitmap.dispose
  955.   end
  956.   #--------------------------------------------------------------------------
  957.   # ● 描绘物品
  958.   #     item : 物品
  959.   #--------------------------------------------------------------------------
  960.   def draw_icon(item, x, y)
  961.     return if item == nil
  962.     bitmap = RPG::Cache.icon(item.icon_name)
  963.     self.contents.blt(x + 4, y, bitmap, Rect.new(0, 0, 24, 24))
  964.     color = self.contents.font.color.clone
  965.     self.contents.font.color = text_color(1)
  966.     self.contents.draw_text(x + 28, y, self.contents.text_size(item.name).width + 5, 24, item.name)
  967.     self.contents.font.color = color
  968.     @dx += self.contents.text_size(item.name).width
  969.   end
  970.   #--------------------------------------------------------------------------
  971.   # ● 图形的描绘
  972.   #     actor : 角色
  973.   #     x     : 描画目标 X 坐标
  974.   #     y     : 描画目标 Y 坐标
  975.   #--------------------------------------------------------------------------
  976.   def draw_actor_graphic(actor, x, y)
  977.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  978.     cw = bitmap.width / 4
  979.     ch = bitmap.height / 4
  980.     src_rect = Rect.new(0, 0, cw, ch)
  981.     self.contents.blt(x, y - 4, bitmap, src_rect)
  982.     color = self.contents.font.color.clone
  983.     self.contents.font.color = text_color(1)
  984.     self.contents.draw_text(x + 32, y, self.contents.text_size(actor.name).width + 5, 24, actor.name)
  985.     self.contents.font.color = color
  986.     @dx += self.contents.text_size(actor.name).width
  987.   end
  988.   #--------------------------------------------------------------------------
  989.   # ● 刷新呼出对话框
  990.   #--------------------------------------------------------------------------
  991.   def update_fuki
  992.     if @tale != nil
  993.       pos = get_fuki_pos(self.width, self.height)
  994.       self.x = pos[0]
  995.       self.y = pos[1]
  996.       tale_pos = get_tale_pos
  997.       @tale.mirror = false
  998.       @tale.x = tale_pos[0]
  999.       @tale.x += 8 if @tale.x < 64
  1000.       if @tale.x > 640 - 64
  1001.         @tale.mirror = true
  1002.         @tale.x -= 64
  1003.       end
  1004.       @tale.y = tale_pos[1]
  1005.       @pic_skin.x = self.x + 2
  1006.       @pic_skin.y = self.y + 2
  1007.       if @face_sprite != nil and !@face_sprite.disposed?
  1008.         @face_sprite.x = self.x + 26
  1009.         @face_sprite.x = self.x + self.width - @pic_width - 26 if @show_right
  1010.         @face_sprite.y = self.y + self.height - @pic_height - 6
  1011.       end
  1012.     end
  1013.   end
  1014.   #--------------------------------------------------------------------------
  1015.   # ● 刷新数字输入框
  1016.   #--------------------------------------------------------------------------
  1017.   def update_input_number_window
  1018.     if @input_number_window != nil
  1019.       @input_number_window.update
  1020.       # 确定
  1021.       if Input.trigger?(Input::C)
  1022.         $game_system.se_play($data_system.decision_se)
  1023.         $game_variables[$game_temp.num_input_variable_id] = @input_number_window.number
  1024.         # 释放输入数值窗口
  1025.         @input_number_window.dispose
  1026.         @input_number_window = nil
  1027.         $game_map.need_refresh = true
  1028.         terminate_message
  1029.       end
  1030.       return
  1031.     end
  1032.   end
  1033.   #--------------------------------------------------------------------------
  1034.   # ● 刷新选择输入
  1035.   #--------------------------------------------------------------------------
  1036.   def update_choose
  1037.     if Input.trigger?(Input::B)
  1038.       if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  1039.         $game_system.se_play($data_system.cancel_se)
  1040.         $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  1041.         terminate_message
  1042.       end
  1043.     end
  1044.     if Input.trigger?(Input::C)
  1045.       if $game_temp.choice_max > 0
  1046.         $game_system.se_play($data_system.decision_se)
  1047.         $game_temp.choice_proc.call(self.index)
  1048.       end
  1049.       terminate_message
  1050.     end
  1051.   end
  1052. end
复制代码
[/fold]



这是fuki的范例工程
Fuki对话框优化版 v6.zip (270.79 KB, 下载次数: 2)

这里fuki

这里fuki

这是对话加强

这是对话加强
梦石
0
星屑
292
在线时间
68 小时
注册时间
2022-11-22
回帖
9
 楼主| 发表于 2022-12-25 02:33:44 | 显示全部楼层
等大佬看我一眼
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部