查看: 2670|回复: 1

[已经解决] 关于“重制版,对话加强“的字体大小

[复制链接]
梦石
6
星屑
3071
在线时间
1825 小时
注册时间
2014-8-20
回帖
233

开拓者剧作品鉴家

发表于 2015-11-2 20:32:11 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 真_真空 于 2015-11-4 13:02 编辑

\h[数字]并不能调整字体大小= =
1.png
2.png
脚本
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #------------------------------------------------------------------------------
  4. # 原版:趙雲
  5. # 重制:RyanBern  2015.08.24
  6. #------------------------------------------------------------------------------
  7. # 更新记录:
  8. #     2015.09.06    少许BUG修复,附加战斗场景对话效果
  9. #==============================================================================

  10. #——说明

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

  16. # 默认为一个字一个字的方式,如果需要一次全部显示,
  17. # 请在游戏中使用脚本:$game_system.typing = true
  18.       
  19. # 默认对话字没有声音,如果需要声音,
  20. # 请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  21. # 我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音

  22. # 其他在对话中可以使用的功能:
  23.   
  24. # \n[1]:显示1号角色的姓名

  25. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名

  26. # 非战斗时,\p功能可以自动调整对话框位置
  27. # \p[1]:对话框出现在1号事件的上方
  28. # \p[0]:主人公上方出现对话框
  29. #——————————————————使用\p功能后可以自动调整对话框大小
  30. # 使用\p功能后,使用事件指令[更改文章选项]可更改对话框的位置
  31. #   [上] :对话框出现在说话者上方
  32. #   [下] :对话框出现在说话者下方
  33. #   [中] :对话框出现在屏幕正中
  34. # 战斗时,\p功能有所变化
  35. # \p[1]:对话框出现在ID为1的角色战斗图附近(这个角色必须是队伍中的成员)
  36. # \p[1001]:对话框出现在Index为1的敌人战斗图附近--也就是说敌人的位置从
  37. #           1001开始算起,1002则是代表Index为2的敌人。
  38. # 战斗时使用\p指令+[更改文章选项]依然是有效的,但是如果不使用\p指令,那么
  39. # 对话框则会一直出现在屏幕正上方。

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

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

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

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

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

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

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

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

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

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

  50. # \s[1-19]:更改弹字的速度

  51. # \.   :停顿一刹那(1、2帧)
  52. # \|   :停顿片刻(20帧)

  53. # \>   :文字不用打字方式
  54. # \<   :文字使用打字方式

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

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

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

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

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

  61. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效

  62. # \L[001]:在左边显示图片“Graphics/Faces/001.png”,并左右镜像反转
  63. # \R[001]:在右边显示图片“Graphics/Faces/001.png”

  64. # \Lk:清除左边的图像
  65. # \Rk:清除右边的图像

  66. #==============================================================================
  67. # ■ Game_System
  68. #------------------------------------------------------------------------------
  69. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  70. # $game_system 。
  71. #==============================================================================

  72. class Game_System
  73.   attr_accessor :typing
  74.   attr_accessor :soundname_on_speak
  75.   alias carol3_ini initialize
  76.   def initialize
  77.     carol3_ini
  78.     @typing = true
  79.     @soundname_on_speak = nil
  80.   end
  81. end
  82. $加密 = true
  83. $refresh = {}
  84. #==============================================================================
  85. # ■ Window_Message
  86. #------------------------------------------------------------------------------
  87. #   修改的对话框类。
  88. #==============================================================================
  89. class Window_Message < Window_Selectable
  90.   # 主角名字字符缩写
  91.   Regex_Player_Name = /pn(\d+)/
  92.   # 字体大小
  93.   Size = 18
  94.   # 对话框窗口皮肤(不写为和系统皮肤相同)
  95.   Mes_Windowskin = "001-Blue01"
  96.   #--------------------------------------------------------------------------
  97.   # ● 初始化状态
  98.   #--------------------------------------------------------------------------
  99.   def initialize
  100.     super(80, 304, 480, 160)
  101.     self.contents = Bitmap.new(width - 32, height - 32)
  102.     self.visible = false
  103.     self.z = 9998
  104.     @fade_in = false
  105.     @fade_out = false
  106.     @contents_showing = false
  107.     @cursor_width = 0
  108.     self.active = false
  109.     self.index = -1
  110.     if $game_system.soundname_on_speak == nil then
  111.       $game_system.soundname_on_speak = ""
  112.     end
  113.     self.windowskin = RPG::Cache.windowskin(Mes_Windowskin) if Mes_Windowskin != ""
  114.     @opacity_text_buf = Bitmap.new(32, 32)
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 释放
  118.   #--------------------------------------------------------------------------
  119.   def dispose
  120.     terminate_message
  121.     $game_temp.message_window_showing = false
  122.     if @input_number_window != nil
  123.       @input_number_window.dispose
  124.     end
  125.     super
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 处理信息结束
  129.   #--------------------------------------------------------------------------
  130.   def terminate_message
  131.     $refresh["mess"] = false
  132.     self.active = false
  133.     self.pause = false
  134.     self.index = -1
  135.     self.contents.clear
  136.     # 清除显示中标志
  137.     @contents_showing = false
  138.     # 呼叫信息调用
  139.     if $game_temp.message_proc != nil
  140.       $game_temp.message_proc.call
  141.     end
  142.     # 清除文章、选择项、输入数值的相关变量
  143.     $game_temp.message_text = nil
  144.     $game_temp.message_proc = nil
  145.     $game_temp.choice_start = 99
  146.     $game_temp.choice_max = 0
  147.     $game_temp.choice_cancel_type = 0
  148.     $game_temp.choice_proc = nil
  149.     $game_temp.num_input_start = 99
  150.     $game_temp.num_input_variable_id = 0
  151.     $game_temp.num_input_digits_max = 0
  152.     # 释放金钱窗口
  153.     if @gold_window != nil
  154.       @gold_window.dispose
  155.       @gold_window = nil
  156.     end
  157.     # 释放姓名窗口
  158.     if @name_window_text != nil
  159.       @name_window_text.dispose
  160.       @name_window_text = nil
  161.     end
  162.     # 释放右侧立绘
  163.     if @right_picture != nil and @right_keep == true
  164.       @right_picture.dispose
  165.       @right_picture = nil
  166.     end   
  167.     # 释放左侧立绘
  168.     if @left_picture != nil and @left_keep == true
  169.       @left_picture.dispose
  170.       @left_picture = nil
  171.     end
  172.     # 释放姓名蓝条
  173.     if @bar != nil
  174.       @bar.bitmap.dispose
  175.       @bar.dispose
  176.       @bar = nil
  177.     end
  178.     # 释放气泡图标
  179.     if @k_tale != nil
  180.       @k_tale.dispose
  181.       @k_tale = nil
  182.     end
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 刷新
  186.   #--------------------------------------------------------------------------
  187.   def refresh
  188.     $refresh["mess"] = true
  189.     # 初期化
  190.     self.contents.clear
  191.     self.contents.font.color = normal_color
  192.     self.contents.font.size = Size
  193.     @x = @y = @max_x = @max_y = @indent = @lines = 0
  194.     @left_keep = @right_keep = false
  195.     @face_indent = 0
  196.     @opacity = 255
  197.     @cursor_width = 0
  198.     @write_speed = 0
  199.     @write_wait = 0
  200.     @mid_stop = false
  201.     @popchar = -2
  202.     if $game_temp.choice_start == 0
  203.       @x = 8
  204.     end
  205.     if $game_temp.message_text != nil
  206.       @now_text = $game_temp.message_text
  207.       #——左半身像设置
  208.       if (/\\[Ll]\[(.+?)\]/.match(@now_text)) != nil then
  209.         [url=home.php?mod=space&uid=84331]@face[/url] = $1
  210.         if $加密 == true
  211.           if @left_picture != nil
  212.             @left_picture.dispose
  213.           end
  214.           @left_picture = Sprite.new
  215.           @left_picture.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  216.           @left_picture.y = 480 - @left_picture.bitmap.height
  217.           @left_picture.x = 0
  218.           @left_picture.mirror = true
  219.           @x = @face_indent = @left_picture.bitmap.width
  220.           @left_keep = true
  221.           @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  222.         else         
  223.           if FileTest.exist?("Graphics/Faces/#{@face}")
  224.             if @left_picture != nil
  225.               @left_picture.dispose
  226.             end
  227.             @left_picture = Sprite.new
  228.             @left_picture.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  229.             @left_picture.y = 480 - @left_picture.bitmap.height
  230.             @left_picture.x = 0
  231.             @left_picture.mirror = true
  232.             @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  233.           end
  234.         end        
  235.       end
  236.       #——右半身像设置
  237.       if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  238.         @face = $1
  239.         if $加密 == true
  240.           if @right_picture != nil
  241.             @right_picture.dispose
  242.           end
  243.           @right_picture = Sprite.new
  244.           @right_picture.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  245.           @right_picture.y = 480 - @right_picture.bitmap.height
  246.           @right_picture.x = 640 - @right_picture.bitmap.width
  247.           @right_keep = true
  248.           @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  249.         else
  250.           if FileTest.exist?("Graphics/Faces/#{@face}")
  251.             if @right_picture != nil
  252.               @right_picture.dispose
  253.             end
  254.             @right_picture = Sprite.new
  255.             @right_picture.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  256.             @right_picture.y = 480 - @right_picture.bitmap.height
  257.             @right_picture.x = 640 - @right_picture.bitmap.width
  258.             @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  259.           end
  260.         end
  261.       end
  262.       #——清除右半身像
  263.       if (/\\[Rr]k/.match(@now_text)) != nil
  264.         @right_keep = true
  265.         @now_text.sub!(/\\[Rr]k/) { "" }
  266.       end
  267.       #——清除做半身像
  268.       if (/\\[Ll]k/.match(@now_text)) != nil
  269.         @left_keep = true
  270.         @now_text.sub!(/\\[Ll]k/) { "" }
  271.       end
  272.       # 显示人物姓名
  273.       name_window_set = false
  274.       if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  275.         name_window_set = true
  276.         name_text = $1
  277.         if Regex_Player_Name =~ name_text
  278.           name_text = $game_actors[$1.to_i].name
  279.         end
  280.         @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  281.       end
  282.       # 文字位置的判定
  283.       if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text)) != nil then
  284.         @popchar = $1.to_i
  285.         if @popchar == -1
  286.           @x = @indent = 48
  287.           @y = 4
  288.         end
  289.         @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  290.       end
  291.       # 开始替换文字(\v)
  292.       begin
  293.         last_text = @now_text.clone
  294.         @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  295.       end until @now_text == last_text
  296.       # 替换控制码
  297.       @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  298.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  299.       end
  300.       @now_text.gsub!(/\\\\/) { "\000" }
  301.       @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  302.       @now_text.gsub!(/\\[Gg]/) { "\002" }
  303.       @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  304.       @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  305.       @now_text.gsub!(/\\[.]/) { "\005" }
  306.       @now_text.gsub!(/\\[|]/) { "\006" }
  307.       @now_text.gsub!(/\\[Ii]c\[(.*?)\]/) { "\030[#{$1}] "}
  308.       @now_text.gsub!(/\\[>]/) { "\016" }
  309.       @now_text.gsub!(/\\[<]/) { "\017" }
  310.       @now_text.gsub!(/\\[!]/) { "\020" }
  311.       @now_text.gsub!(/\\[~]/) { "\021" }
  312.       @now_text.gsub!(/\\[Ii]/) { "\023" }
  313.       @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  314.       @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  315.       @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  316.       @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  317.       # \p 的情况下调整文字大小
  318.       if @popchar >= 0
  319.         @text_save = @now_text.clone
  320.         process_real_text
  321.         @max_x = name_window_set ? contents.text_size(name_text).width : 0
  322.         @max_y = 4
  323.         for i in 0..3
  324.           line = @text_save.split(/\n/)[3-i]
  325.           @max_y -= 1 if line == nil && @max_y <= 4 - i
  326.           next if line == nil
  327.           contents.font.size = Size
  328.           cx = contents.text_size(line).width
  329.           @max_x = cx if cx > @max_x
  330.         end
  331.         if @right_picture != nil && !@right_picture.disposed?
  332.           self.width = @max_x + 48 + @face_indent + @right_picture.bitmap.width
  333.         else
  334.           self.width = @max_x + 48 + @face_indent
  335.         end
  336.         if $game_temp.num_input_variable_id > 0
  337.           self.height = (@max_y - 1) * 20 + 96 + 8
  338.         else
  339.           self.height = (@max_y - 1) * 20 + 64
  340.         end
  341.       else
  342.         @max_x = self.width - 32 - @face_indent
  343.       end
  344.       reset_window
  345.       # 如果设置了姓名框
  346.       if name_window_set
  347.         off_x = 0
  348.         off_y = -40
  349.         space = 2
  350.         x = self.x + off_x - space / 2
  351.         y = self.y + off_y - space / 2
  352.         w = self.contents.text_size(name_text).width + 26 + space
  353.         h = 40 + space
  354.         x = self.x + off_x + 4
  355.         y = self.y + off_y
  356.         @name_window_text = Air_Text.new(self.x + @face_indent+4+8, self.y+16, name_text)
  357.         @name_window_text.z = self.z + 2
  358.         @bar = Sprite.new
  359.         @bar.bitmap = Bitmap.new(self.width, 24)
  360.         @bar.x = self.x + 8
  361.         @bar.y = self.y + 16
  362.         @bar.z = self.z + 2
  363.         @bar.bitmap.fill_rect(0,0,self.width-16,24,Color.new(120,180,250,80))
  364.       end
  365.     end
  366.     reset_window
  367.     # 如果选择项被设置
  368.     if $game_temp.choice_max > 0
  369.       @item_max = $game_temp.choice_max
  370.       self.active = true
  371.       self.index = 0
  372.     end
  373.     # 如果数值输入被设置
  374.     if $game_temp.num_input_variable_id > 0
  375.       digits_max = $game_temp.num_input_digits_max
  376.       number = $game_variables[$game_temp.num_input_variable_id]
  377.       @input_number_window = Window_InputNumber.new(digits_max)
  378.       @input_number_window.number = number
  379.       @input_number_window.x = self.x + @face_indent
  380.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  381.     end
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # ● 更新
  385.   #--------------------------------------------------------------------------
  386.   def update
  387.     super
  388.     # 使用默认窗口外观的情况下,如果窗口的外关被变更了、再设置
  389.     if $game_system.windowskin_name != @windowskin_name && Mes_Windowskin == ""
  390.       @windowskin_name = $game_system.windowskin_name
  391.       self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  392.     end
  393.     # 如果设置了气泡图标
  394.     if @k_tale != nil && @k_tale.visible && !$game_temp.in_battle
  395.       character = get_character(@popchar)
  396.       x = [[character.screen_x - self.width / 2, 4].max, 636 - self.width].min
  397.       if $game_system.message_position == 2
  398.         y = [[character.screen_y + 16, 4].max, 476 - self.height].min
  399.       elsif $game_system.message_position == 0
  400.         y = [[character.screen_y - process_y_shift(character) - self.height, 4].max, 476 - self.height].min
  401.       end
  402.       self.x = x
  403.       self.y = y
  404.       # 设置气泡图标坐标
  405.       @k_tale.x = ( character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 16
  406.       if $game_system.message_position == 2
  407.         @k_tale.y = self.y - 16
  408.       elsif $game_system.message_position == 0
  409.         @k_tale.y = self.y + self.height - 16
  410.       end
  411.       # 设置左侧立绘坐标
  412.       if @left_picture != nil and !@left_picture.disposed?
  413.         @left_picture.x = x + 8
  414.         @left_picture.y = y - @left_picture.bitmap.height + self.height - 8
  415.       end
  416.       # 设置右侧立绘坐标
  417.       if @right_picture != nil and !@right_picture.disposed?
  418.         @right_picture.x = x+[email]self.width-@right_picture.bitmap.width[/email]-8
  419.         @right_picture.y = y - @right_picture.bitmap.height + self.height - 8
  420.       end
  421.       # 设置姓名空气文字坐标
  422.       if @name_window_text != nil
  423.         @name_window_text.x = self.x + @face_indent - 4
  424.         @name_window_text.y = self.y
  425.       end
  426.       # 设置姓名蓝条坐标
  427.       if @bar != nil
  428.         @bar.x = self.x + 8
  429.         @bar.y = self.y + 16
  430.       end
  431.     end
  432.     # 淡入中的情况下
  433.     if @fade_in
  434.       self.contents_opacity += 24
  435.       if @input_number_window != nil
  436.         @input_number_window.contents_opacity += 24
  437.       end
  438.       if self.contents_opacity == 255
  439.         @fade_in = false
  440.       end
  441.       return
  442.     end
  443.     @now_text = nil if @now_text == ""
  444.     # 逐个描绘文字
  445.     if @now_text != nil and @mid_stop == false
  446.       if @write_wait > 0
  447.         @write_wait -= 1
  448.         return
  449.       end
  450.       text_not_skip = $game_system.typing
  451.       while true
  452.         @max_x = @x if @max_x < @x
  453.         @max_y = @y if @max_y < @y
  454.         # 处理字符
  455.         if (c = @now_text.slice!(/./m)) != nil
  456.           # \\的情况下
  457.           if c == "\000"
  458.             c = "\"
  459.           end
  460.           # \c的情况下
  461.           if c == "\001"
  462.             @now_text.sub!(/\[([0-9]+)\]/, "")
  463.             color = $1.to_i
  464.             if color >= 0 and color <= 7
  465.               self.contents.font.color = text_color(color)
  466.             end
  467.             c = ""
  468.           end
  469.           # \g的情况下
  470.           if c == "\002"
  471.             if @gold_window == nil && @popchar <= 0
  472.               @gold_window = Window_Gold.new
  473.               @gold_window.x = 560 - @gold_window.width
  474.               if $game_temp.in_battle
  475.                 @gold_window.y = 192
  476.               else
  477.                 @gold_window.y = self.y >= 128 ? 32 : 384
  478.               end
  479.               @gold_window.opacity = self.opacity
  480.               @gold_window.back_opacity = self.back_opacity
  481.             end
  482.             c = ""
  483.           end
  484.           # \s的情况下
  485.           if c == "\003"
  486.             @now_text.sub!(/\[([0-9]+)\]/, "")
  487.             speed = $1.to_i
  488.             if speed >= 0 and speed <= 19
  489.               @write_speed = speed
  490.             end
  491.             c = ""
  492.           end
  493.           # \a的情况下
  494.           if c == "\004"
  495.             @now_text.sub!(/\[(.*?)\]/, "")
  496.             buftxt = $1.dup.to_s
  497.             if buftxt.match(/\//) == nil && buftxt != "" then
  498.               $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  499.             else
  500.               $game_system.soundname_on_speak = buftxt.dup
  501.             end
  502.             c = ""
  503.           end
  504.           # \.的情况下
  505.           if c == "\005"
  506.             @write_wait += 5
  507.             c = ""
  508.           end
  509.           # \|的情况下
  510.           if c == "\006"
  511.             @write_wait += 20
  512.             c = ""
  513.           end
  514.           # \>的情况下
  515.           if c == "\016"
  516.             text_not_skip = false
  517.             c = ""
  518.           end
  519.           # \<的情况下
  520.           if c == "\017"
  521.             text_not_skip = true
  522.             c = ""
  523.           end
  524.           # \!的情况下
  525.           if c == "\020"
  526.             @mid_stop = true
  527.             c = ""
  528.           end
  529.           # \~的情况下
  530.           if c == "\021"
  531.             terminate_message
  532.             return
  533.           end
  534.           # \i的情况下
  535.           if c == "\023"
  536.             @indent = @x
  537.             c = ""
  538.           end
  539.           # \o的情况下
  540.           if c == "\024"
  541.             @now_text.sub!(/\[([0-9]+)\]/, "")
  542.             @opacity = $1.to_i
  543.             c = ""
  544.           end
  545.           # \h的情况下
  546.           if c == "\025"
  547.             @now_text.sub!(/\[([0-9]+)\]/, "")
  548.             self.contents.font.size = [[$1.to_i, 6].max, 32].min
  549.             c = ""
  550.           end
  551.           # \b的情况下
  552.           if c == "\026"
  553.             @now_text.sub!(/\[([0-9]+)\]/, "")
  554.             @x += $1.to_i
  555.             c = ""
  556.           end
  557.           # \k的情况下
  558.           if c == "\027"
  559.             @now_text.sub!(/\[(.*?)\]/, "")
  560.             @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  561.             if $game_system.soundname_on_speak != ""
  562.               Audio.se_play($game_system.soundname_on_speak)
  563.             end
  564.             c = ""
  565.           end
  566.           # 图标的情况
  567.           if c == "\030"
  568.             @now_text.sub!(/\[(.*?)\]/, "")
  569.             self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  570.             if $game_system.soundname_on_speak != ""
  571.               Audio.se_play($game_system.soundname_on_speak)
  572.             end
  573.             @x += 24
  574.             c = ""
  575.           end
  576.           # 另起一行的情况下
  577.           if c == "\n"
  578.             if @lines >= $game_temp.choice_start
  579.               @cursor_width = [@cursor_width, @max_x - @face_indent].max
  580.             end
  581.             @lines += 1
  582.             @y += 1
  583.             @x = 0 + @indent + @face_indent
  584.             if @lines >= $game_temp.choice_start
  585.               @x = 8 + @indent + @face_indent
  586.             end
  587.             c = ""
  588.           end
  589.           if c != ""
  590.             # 文字描画
  591.             self.contents.font.size = Size
  592.             @x += opacity_draw_text(self.contents, @x, 8+@y * line_height + (line_height - self.contents.font.size), c, @opacity)
  593.             if $game_system.soundname_on_speak != "" then
  594.               Audio.se_play($game_system.soundname_on_speak)
  595.             end
  596.           end
  597.           if Input.press?(Input::B)
  598.             text_not_skip = false
  599.           end
  600.         else
  601.           text_not_skip = true
  602.           break
  603.         end
  604.         # 終了判定
  605.         if text_not_skip
  606.           break
  607.         end
  608.       end
  609.       @write_wait += @write_speed
  610.       return
  611.     end
  612.     # 数值输入的处理
  613.     if @input_number_window != nil
  614.       @input_number_window.update
  615.       # 确认
  616.       if Input.trigger?(Input::C)
  617.         $game_system.se_play($data_system.decision_se)
  618.         $game_variables[$game_temp.num_input_variable_id] =
  619.           @input_number_window.number
  620.         $game_map.need_refresh = true
  621.         @input_number_window.dispose
  622.         @input_number_window = nil
  623.         terminate_message
  624.       end
  625.       return
  626.     end
  627.     # 文章显示中的情况下
  628.     if @contents_showing
  629.       if $game_temp.choice_max == 0
  630.         self.pause = true
  631.       end
  632.       # 取消
  633.       if Input.trigger?(Input::B)
  634.         if $game_temp.choice_max > 0 && $game_temp.choice_cancel_type > 0
  635.           $game_system.se_play($data_system.cancel_se)
  636.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  637.           terminate_message
  638.         end
  639.       end
  640.       # 确定
  641.       if Input.trigger?(Input::C)
  642.         # 释放气泡图标
  643.         if @k_tale != nil  
  644.           @k_tale.dispose
  645.           @k_tale = nil
  646.         end
  647.         if $game_temp.choice_max > 0
  648.           $game_system.se_play($data_system.decision_se)
  649.           $game_temp.choice_proc.call(self.index)
  650.         end
  651.         if @mid_stop
  652.           @mid_stop = false
  653.           return
  654.         else
  655.           terminate_message
  656.         end
  657.       end
  658.       return
  659.     end
  660.     if @fade_out == false and $game_temp.message_text != nil
  661.       @contents_showing = true
  662.       $game_temp.message_window_showing = true
  663.       refresh
  664.       Graphics.frame_reset
  665.       self.visible = true
  666.       self.contents_opacity = 0
  667.       if @input_number_window != nil
  668.         @input_number_window.contents_opacity = 0
  669.       end
  670.       @fade_in = true
  671.       return
  672.     end
  673.     if self.visible
  674.       @fade_out = true
  675.       self.opacity -= 48
  676.       if self.opacity == 0
  677.         self.visible = false
  678.         @fade_out = false
  679.         $game_temp.message_window_showing = false
  680.       end
  681.       return
  682.     end
  683.   end
  684.   #--------------------------------------------------------------------------
  685.   # ● 预览实际描绘内容(计算窗口宽用)
  686.   #--------------------------------------------------------------------------
  687.   #    实际对 @text_save 进行操作
  688.   #    此方法用于去除某些控制码引起窗口过长的影响
  689.   #--------------------------------------------------------------------------
  690.   def process_real_text
  691.     return if @text_save.nil?
  692.     regex = /[\001-\006\016\017\020\021\024](\[.*?\]){0,1}/
  693.     regex30 = /\030\[.*?\]/
  694.     @text_save.gsub!(regex, "")
  695.     @text_save.gsub!(regex30, "   ")
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ● 获得角色(\p功能)
  699.   #--------------------------------------------------------------------------
  700.   def get_character(parameter)
  701.     case parameter
  702.     when 0
  703.       return $game_player
  704.     else
  705.       events = $game_map.events
  706.       return events == nil ? nil : events[parameter]
  707.     end
  708.   end
  709.   #--------------------------------------------------------------------------
  710.   # ● 获得战斗者(\p功能,此功能仅在战斗中有效)
  711.   #--------------------------------------------------------------------------
  712.   #    parameter : 1-999 表示主角 ID,1001-1008 表示索引为1-8的各个敌人
  713.   #--------------------------------------------------------------------------
  714.   def get_battler(parameter)
  715.     if parameter < 1000
  716.       return $game_actors[parameter]
  717.     else
  718.       return $game_troop.enemies[parameter - 1001]
  719.     end
  720.   end
  721.   #--------------------------------------------------------------------------
  722.   # ● 计算 y 偏移量(\p功能,这是考虑到不同战斗图/行走图的高度不同)
  723.   #--------------------------------------------------------------------------
  724.   #    character : 角色/战斗者
  725.   #--------------------------------------------------------------------------
  726.   def process_y_shift(character)
  727.     rate = character.is_a?(Game_Battler) ? 1 : 4
  728.     bmp = character.is_a?(Game_Battler) ?
  729.       RPG::Cache.battler(character.battler_name, character.battler_hue) :
  730.       RPG::Cache.character(character.character_name, character.character_hue)
  731.     return bmp.height / rate + 16
  732.   end
  733.   #--------------------------------------------------------------------------
  734.   # ● 重置窗口(位置,不透明度)
  735.   #--------------------------------------------------------------------------
  736.   def reset_window
  737.     # 判定
  738.     if @k_tale != nil  
  739.       @k_tale.dispose
  740.       @k_tale = nil
  741.     end
  742.     # 如果使用了 \p 设置位置
  743.     if @popchar >= 0
  744.       character = $game_temp.in_battle ? get_battler(@popchar) : get_character(@popchar)
  745.       if character != nil
  746.         x = [[character.screen_x - self.width / 2, 4].max, 636 - self.width].min
  747.         if $game_system.message_position == 2
  748.           y = [[character.screen_y + 16, 4].max, 476 - self.height].min
  749.         elsif $game_system.message_position == 0
  750.           y = [[character.screen_y - process_y_shift(character) - self.height, 4].max, 476 - self.height].min
  751.         else
  752.           x = 320 - self.width / 2
  753.           y = 240 - self.height / 2
  754.         end
  755.         self.x = x
  756.         self.y = y
  757.         # 设置气泡图标
  758.         @k_tale = Sprite.new
  759.         k_tale_filename = Mes_Windowskin == "" ? $game_system.windowskin_name : Mes_Windowskin
  760.         suffix = $game_system.message_position == 2 ? "-under" : "-top"
  761.         @k_tale.bitmap = RPG::Cache.windowskin(k_tale_filename + suffix)
  762.         @k_tale.x = character.is_a?(Game_Character) ?
  763.           ( character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 16 :
  764.           character.screen_x
  765.         if $game_system.message_position == 2
  766.           @k_tale.y = self.y - 16
  767.         elsif $game_system.message_position == 0
  768.           @k_tale.y = self.y + self.height - 16
  769.         else
  770.           @k_tale.visible = false
  771.         end
  772.         @k_tale.z = 9999
  773.         # 设置左侧立绘
  774.         if @left_picture != nil and !@left_picture.disposed?
  775.           @left_picture.x = x + 8
  776.           @left_picture.y = y - @left_picture.bitmap.height + self.height - 8
  777.           @left_picture.z += self.z
  778.         end
  779.         # 设置右侧立绘
  780.         if @right_picture != nil and !@right_picture.disposed?
  781.           @right_picture.x = x+[email]self.width-@right_picture.bitmap.width[/email]-8
  782.           @right_picture.y = y - @right_picture.bitmap.height + self.height - 8
  783.           @right_picture.z += self.z
  784.         end
  785.       end
  786.     elsif @popchar == -1
  787.       self.x = -4
  788.       self.y = -4
  789.       self.width = 648
  790.       self.height = 488
  791.     else # 无 \p 的情况下
  792.       # 处于战斗中时
  793.       if $game_temp.in_battle
  794.         self.y = 16
  795.       else
  796.         # 显示文章位置的分支
  797.         case $game_system.message_position
  798.         when 0 # 上
  799.           self.y = 16
  800.         when 1 # 中
  801.           self.y = 160
  802.         when 2 # 下
  803.           self.y = 304
  804.         end
  805.       end
  806.       self.width = 480 * 0.8
  807.       self.height = 160 * 0.8
  808.       self.x = 320 - self.width / 2
  809.       # 设置左侧立绘
  810.       if @left_picture != nil and !@left_picture.disposed?
  811.         @left_picture.x = self.x + 8
  812.         @left_picture.y = self.y - @left_picture.bitmap.height + self.height - 8
  813.         @left_picture.z += self.z
  814.       end
  815.       # 设置右侧立绘
  816.       if @right_picture != nil and !@right_picture.disposed?
  817.         @right_picture.x = self.x + self.width - @right_picture.bitmap.width - 8
  818.         @right_picture.y = self.y - @right_picture.bitmap.height + self.height - 8
  819.         @right_picture.z += self.z
  820.       end
  821.     end # of @popchar >= 0
  822.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  823.     # 设置不透明度
  824.     if @popchar == -1
  825.       self.opacity = 255
  826.       self.back_opacity = 0
  827.     elsif $game_system.message_frame == 0
  828.       self.opacity = 255
  829.       self.back_opacity = 200
  830.     else
  831.       self.opacity = 0
  832.       self.back_opacity = 200
  833.     end
  834.   end
  835.   #--------------------------------------------------------------------------
  836.   # ● line_height
  837.   #--------------------------------------------------------------------------
  838.   # 返回值 : 行高
  839.   #--------------------------------------------------------------------------
  840.   def line_height
  841.     return 20
  842.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  843.       return 20
  844.     else
  845.       return self.contents.font.size * 15 / 10
  846.     end
  847.   end
  848.   #--------------------------------------------------------------------------
  849.   # ● 文字描画
  850.   #--------------------------------------------------------------------------
  851.   # target :描绘的目标 bitmap 对象
  852.   # x      :x 坐标
  853.   # y      :y 坐标
  854.   # str   :描绘的文字
  855.   # opacity:不透明度(0~255)
  856.   # 返回值 :文字宽度(@x 的增加值)。
  857.   #--------------------------------------------------------------------------
  858.   def opacity_draw_text(target, x, y, str,opacity)
  859.     height = target.font.size
  860.     width = target.text_size(str).width
  861.     opacity = [[opacity, 0].max, 255].min
  862.     if opacity == 255
  863.       target.draw_text(x, y, width, height, str)
  864.       return width
  865.     else
  866.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  867.         @opacity_text_buf.dispose
  868.         @opacity_text_buf = Bitmap.new(width, height)
  869.       else
  870.         @opacity_text_buf.clear
  871.       end
  872.       @opacity_text_buf.font.size = target.font.size
  873.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  874.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  875.     return width
  876.     end
  877.   end
  878.   def ruby_draw_text(target, x, y, str, opacity)
  879.     sizeback = target.font.size
  880.     target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  881.     rubysize = [rubysize, 6].max
  882.     opacity = [[opacity, 0].max, 255].min
  883.     split_s = str.split(/,/)
  884.     split_s[0] == nil ? split_s[0] = "" : nil
  885.     split_s[1] == nil ? split_s[1] = "" : nil
  886.     height = sizeback + rubysize
  887.     width = target.text_size(split_s[0]).width
  888.     target.font.size = rubysize
  889.     ruby_width = target.text_size(split_s[1]).width
  890.     target.font.size = sizeback
  891.     buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  892.     width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  893.     if opacity == 255
  894.       target.font.size = rubysize
  895.       target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  896.       target.font.size = sizeback
  897.       target.draw_text(x, y, width, target.font.size, split_s[0])
  898.       return width
  899.     else
  900.       if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  901.         @opacity_text_buf.dispose
  902.         @opacity_text_buf = Bitmap.new(buf_width, height)
  903.       else
  904.         @opacity_text_buf.clear
  905.       end
  906.       @opacity_text_buf.font.size = rubysize
  907.       @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  908.       @opacity_text_buf.font.size = sizeback
  909.       @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  910.       if sub_x >= 0
  911.         target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  912.       else
  913.         target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  914.       end
  915.       return width
  916.     end
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ● \V 变换
  920.   #--------------------------------------------------------------------------
  921.   # option : 选项,'i'物品,'w'武器,'a'防具,'s'技能
  922.   # index  : 数据库的索引
  923.   #--------------------------------------------------------------------------
  924.   def convart_value(option, index)
  925.     option == nil ? option = "" : nil
  926.     option.downcase!
  927.     case option
  928.       when "i"
  929.         unless $data_items[index].name == nil
  930.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  931.         end
  932.       when "w"
  933.         unless $data_weapons[index].name == nil
  934.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  935.         end
  936.       when "a"
  937.         unless $data_armors[index].name == nil
  938.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  939.         end
  940.       when "s"
  941.         unless $data_skills[index].name == nil
  942.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  943.         end
  944.       else
  945.       r = $game_variables[index]
  946.     end
  947.     r == nil ? r = "" : nil
  948.     return r
  949.   end
  950.   #--------------------------------------------------------------------------
  951.   # ● 释放
  952.   #--------------------------------------------------------------------------
  953.   def dispose
  954.     terminate_message
  955.     unless @opacity_text_buf.disposed?
  956.       @opacity_text_buf.dispose
  957.     end
  958.     $game_temp.message_window_showing = false
  959.     if @input_number_window != nil
  960.       @input_number_window.dispose
  961.     end
  962.     super
  963.   end
  964.   #--------------------------------------------------------------------------
  965.   # ● 刷新光标矩形
  966.   #--------------------------------------------------------------------------
  967.   def update_cursor_rect
  968.     if @index >= 0
  969.       n = $game_temp.choice_start + @index
  970.       self.cursor_rect.set(4 + @indent + @face_indent, n * 20 + 10, @cursor_width, 20)
  971.     else
  972.       self.cursor_rect.empty
  973.     end
  974.   end
  975. end
  976. #==============================================================================
  977. # ■ Air_Text
  978. #------------------------------------------------------------------------------
  979. #   空气文字,借助窗口显示文字,但是不显示窗口载体。
  980. #==============================================================================
  981. class Air_Text < Window_Base
  982.   #--------------------------------------------------------------------------
  983.   # ● 对象初始化
  984.   #--------------------------------------------------------------------------
  985.   def initialize(x, y, designate_text)
  986.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  987.     self.opacity = 0
  988.     self.back_opacity = 0
  989.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  990.     self.contents.font.size = 20
  991.     w = self.contents.width
  992.     h = self.contents.height
  993.     self.contents.draw_text(0, 0, w, h, designate_text)
  994.   end
  995.   #--------------------------------------------------------------------------
  996.   # ● 释放
  997.   #--------------------------------------------------------------------------
  998.   def dispose
  999.     self.contents.clear
  1000.     super
  1001.   end
  1002. end

  1003. #==============================================================================
  1004. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1005. #==============================================================================
复制代码
  
@RyanBern  

评分

参与人数 2星屑 +36 收起 理由
RyanBern + 35 手动认可奖励
欧买歌 + 1 你应该@RyanBern 我帮你@会被删帖的,自己@.

查看全部评分

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2015-11-5 23:47:20 | 显示全部楼层
已经修复。请到发布帖重新复制脚本。

点评

多谢~  发表于 2015-11-6 19:06

评分

参与人数 1星屑 +10 收起 理由
真_真空 + 10 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部