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

Project1

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

[已经解决] 请教对话框里加字体的东西~

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
48 小时
注册时间
2010-8-26
帖子
68
跳转到指定楼层
1
发表于 2011-8-4 19:43:39 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 naibo456 于 2011-8-4 19:46 编辑

我想在66RPG的对话框加强脚本里加一个修改字体的脚本,比如f[1]就是楷体什么的,两个脚本我弄到了,可惜不能同时使用,望各位大侠给看看,把修改字体的脚本加到对话框脚本里,万分感谢~~~~~


附:66RPG的对话框加强脚本
  1. #——说明

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

  8. # 其他在对话中可以使用的功能:
  9.   
  10. #
  11. [1]:显示1号角色的姓名

  12. #
  13. ame[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名

  14. # p[1]:对话框出现在1号事件的上方
  15. # p[0]:主人公上方出现对话框
  16. #——————————————————使用p功能后可以自动调整对话框大小

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

  18. # c[1-8]:更改颜色

  19. # g:显示金钱窗口

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

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

  22. # .   :停顿一刹那(1、2帧)
  23. # |   :停顿片刻(20帧)

  24. # >   :文字不用打字方式
  25. # <   :文字使用打字方式

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

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

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

  30. # h[12]:改用12号字

  31. # [50]:空50象素

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

  33. # L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  34. # R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”

  35. # Lk:清除左边的图像
  36. # Rk:清除右边的图像

  37. #==============================================================================
  38. # ■ Window_Message
  39. #------------------------------------------------------------------------------
  40. class Window_Message < Window_Selectable
  41.   #--------------------------------------------------------------------------
  42.   # ● 初始化状态
  43.   #--------------------------------------------------------------------------
  44.   def initialize
  45.     super(80, 304, 480, 160)
  46.     self.contents = Bitmap.new(width - 32, height - 32)
  47.     self.visible = false
  48.     self.z = 9998
  49.     @fade_in = false
  50.     @fade_out = false
  51.     @contents_showing = false
  52.     @cursor_width = 0
  53.     self.active = false
  54.     self.index = -1
  55.     if $game_system.soundname_on_speak == nil then
  56.       $game_system.soundname_on_speak = ""
  57.     end
  58.     @opacity_text_buf = Bitmap.new(32, 32)
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 释放
  62.   #--------------------------------------------------------------------------
  63.   def dispose
  64.     terminate_message
  65.     $game_temp.message_window_showing = false
  66.     if @input_number_window != nil
  67.       @input_number_window.dispose
  68.     end
  69.     super
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 处理信息结束
  73.   #--------------------------------------------------------------------------
  74.   def terminate_message
  75.     self.active = false
  76.     self.pause = false
  77.     self.index = -1
  78.     self.contents.clear
  79.     # 清除显示中标志
  80.     @contents_showing = false
  81.     # 呼叫信息调用
  82.     if $game_temp.message_proc != nil
  83.       $game_temp.message_proc.call
  84.     end
  85.     # 清除文章、选择项、输入数值的相关变量
  86.     $game_temp.message_text = nil
  87.     $game_temp.message_proc = nil
  88.     $game_temp.choice_start = 99
  89.     $game_temp.choice_max = 0
  90.     $game_temp.choice_cancel_type = 0
  91.     $game_temp.choice_proc = nil
  92.     $game_temp.num_input_start = 99
  93.     $game_temp.num_input_variable_id = 0
  94.     $game_temp.num_input_digits_max = 0
  95.     # 开放金钱窗口
  96.     if @gold_window != nil
  97.       @gold_window.dispose
  98.       @gold_window = nil
  99.     end
  100.     if @name_window_frame != nil
  101.       @name_window_frame.dispose
  102.       @name_window_frame = nil
  103.     end
  104.     if @name_window_text != nil
  105.       @name_window_text.dispose
  106.       @name_window_text = nil
  107.     end
  108.     if @right_picture != nil and @right_keep == true
  109.       @right_picture.dispose
  110.     end   
  111.     if @left_picture != nil and @left_keep == true
  112.       @left_picture.dispose
  113.     end
  114.   end
  115.   def refresh
  116.     # 初期化
  117.     self.contents.clear
  118.     self.contents.font.color = normal_color
  119.     self.contents.font.size = Font.default_size
  120.     @x = @y = @max_x = @max_y = @indent = @lines = 0
  121.     @left_keep = @right_keep = false
  122.     @face_indent = 0
  123.     @opacity = 255
  124.     @cursor_width = 0
  125.     @write_speed = 0
  126.     @write_wait = 0
  127.     @mid_stop = false
  128.     @face_file = nil
  129.     @popchar = -2
  130.     if $game_temp.choice_start == 0
  131.       @x = 8
  132.     end
  133.     if $game_temp.message_text != nil
  134.       @now_text = $game_temp.message_text
  135.       #——头像设置
  136.       if (/\[Ff][(.+?)]/.match(@now_text))!=nil then
  137.         @face_file = $1 + ".png"
  138.         @x = @face_indent = 128
  139.         if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  140.           self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  141.         end
  142.         @now_text.gsub!(/\[Ff][(.*?)]/) { "" }
  143.       end
  144.       #——左半身像设置
  145.       if (/\[Ll][(.+?)]/.match(@now_text))!=nil then
  146.         @face = "66rpg_" + $1 + "_h.png"
  147.         if $加密 == true
  148.           if @left_picture != nil
  149.             @left_picture.dispose
  150.           end
  151.           @left_picture = Sprite.new
  152.           @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  153.           @left_picture.y = 480-@left_picture.bitmap.height
  154.           @left_picture.x = 0
  155.           @left_picture.mirror = true
  156.           @now_text.gsub!(/\[Ll][(.*?)]/) { "" }
  157.         else         
  158.           if FileTest.exist?("Graphics/battlers/#{@face}")
  159.             if @left_picture != nil
  160.               @left_picture.dispose
  161.             end
  162.             @left_picture = Sprite.new
  163.             @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  164.             @left_picture.y = 480-@left_picture.bitmap.height
  165.             @left_picture.x = 0
  166.             @left_picture.mirror = true
  167.             @now_text.gsub!(/\[Ll][(.*?)]/) { "" }
  168.           end
  169.         end        
  170.       end
  171.       #——右半身像设置
  172.       if (/\[Rr][(.+?)]/.match(@now_text))!=nil then
  173.         @face = "66rpg_" + $1 + "_h.png"
  174.         if $加密 == true
  175.           if @right_picture != nil
  176.             @right_picture.dispose
  177.           end
  178.           @right_picture = Sprite.new
  179.           @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  180.           @right_picture.y = 480-@right_picture.bitmap.height
  181.           @right_picture.x = 640-@right_picture.bitmap.width
  182.           @now_text.gsub!(/\[Rr][(.*?)]/) { "" }
  183.         else
  184.           if FileTest.exist?("Graphics/battlers/#{@face}")
  185.             if @right_picture != nil
  186.               @right_picture.dispose
  187.             end
  188.             @right_picture = Sprite.new
  189.             @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  190.             @right_picture.y = 480-@right_picture.bitmap.height
  191.             @right_picture.x = 640-@right_picture.bitmap.width
  192.             @now_text.gsub!(/\[Rr][(.*?)]/) { "" }
  193.           end
  194.         end
  195.       end
  196.       if (/\[Rr]k/.match(@now_text)) != nil
  197.         @right_keep = true
  198.         @now_text.sub!(/\[Rr]k/) { "" }
  199.       end
  200.       if (/\[Ll]k/.match(@now_text)) != nil
  201.         @left_keep = true
  202.         @now_text.sub!(/\[Ll]k/) { "" }
  203.       end
  204.       # 显示人物姓名
  205.       name_window_set = false
  206.       if (/\[Nn]ame[(.+?)]/.match(@now_text)) != nil
  207.         name_window_set = true
  208.         name_text = $1
  209.         @now_text.sub!(/\[Nn]ame[(.*?)]/) { "" }
  210.       end
  211.       
  212.       # 文字位置的判定
  213.       if (/\[Pp][([-1,0-9]+)]/.match(@now_text))!=nil then
  214.         @popchar = $1.to_i
  215.         if @popchar == -1
  216.           @x = @indent = 48
  217.           @y = 4
  218.         end
  219.         @now_text.gsub!(/\[Pp][([-1,0-9]+)]/) { "" }
  220.       end
  221.       
  222.       # 开始
  223.       begin
  224.         last_text = @now_text.clone
  225.         @now_text.gsub!(/\[Vv][([IiWwAaSs]?)([0-9]+)]/) { convart_value($1, $2.to_i) }
  226.       end until @now_text == last_text
  227.       @now_text.gsub!(/\[Nn][([0-9]+)]/) do
  228.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  229.     end
  230.     @now_text.gsub!(/\\/) { "\000" }
  231.     @now_text.gsub!(/\[Cc][([0-9]+)]/) { "\001[#{$1}]" }
  232.     @now_text.gsub!(/\[Gg]/) { "\002" }
  233.     @now_text.gsub!(/\[Ss][([0-9]+)]/) { "\003[#{$1}]" }
  234.     @now_text.gsub!(/\[Aa][(.*?)]/) { "\004[#{$1}]" }
  235.     @now_text.gsub!(/\[.]/) { "\005" }
  236.     @now_text.gsub!(/\[|]/) { "\006" }

  237.     @now_text.gsub!(/\[>]/) { "\016" }
  238.     @now_text.gsub!(/\[<]/) { "\017" }
  239.     @now_text.gsub!(/\[!]/) { "\020" }
  240.     @now_text.gsub!(/\[~]/) { "\021" }
  241.    
  242.     @now_text.gsub!(/\[Ii]/) { "\023" }
  243.     @now_text.gsub!(/\[Oo][([0-9]+)]/) { "\024[#{$1}]" }
  244.     @now_text.gsub!(/\[Hh][([0-9]+)]/) { "\025[#{$1}]" }
  245.     @now_text.gsub!(/\[Bb][([0-9]+)]/) { "\026[#{$1}]" }
  246.     @now_text.gsub!(/\[Kk][(.*?)]/) { "\027[#{$1}]" }
  247.     if @popchar >= 0
  248.       @text_save = @now_text.clone
  249.       @max_x = 0
  250.       @max_y = 4
  251.       for i in 0..3
  252.         line = @now_text.split(/
  253. /)[3-i]
  254.         @max_y -= 1 if line == nil and @max_y <= 4-i
  255.         next if line == nil
  256.         cx = contents.text_size(line).width
  257.         @max_x = cx if cx > @max_x
  258.       end
  259.       self.width = @max_x + 48 + @face_indent
  260.       self.height = (@max_y - 1) * 32 + 64
  261.     else
  262.       @max_x = self.width - 32 - @face_indent
  263.     end
  264.     reset_window
  265.       if name_window_set
  266.         off_x = 0
  267.         off_y = -40
  268.         space = 2
  269.         x = self.x + off_x - space / 2
  270.         y = self.y + off_y - space / 2
  271.         w = self.contents.text_size(name_text).width + 26 + space
  272.         h = 40 + space
  273.         @name_window_frame = Window_Frame.new(x, y, w, h)
  274.         @name_window_frame.z = self.z + 1
  275.         x = self.x + off_x + 4
  276.         y = self.y + off_y
  277.         @name_window_text = Air_Text.new(x+4, y+6, name_text)
  278.         @name_window_text.z = self.z + 2
  279.       end
  280.     end
  281.     reset_window
  282.     if $game_temp.choice_max > 0
  283.       @item_max = $game_temp.choice_max
  284.       self.active = true
  285.       self.index = 0
  286.     end
  287.     if $game_temp.num_input_variable_id > 0
  288.       digits_max = $game_temp.num_input_digits_max
  289.       number = $game_variables[$game_temp.num_input_variable_id]
  290.       @input_number_window = Window_InputNumber.new(digits_max)
  291.       @input_number_window.number = number
  292.       @input_number_window.x = self.x + 8
  293.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  294.     end
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 更新
  298.   #--------------------------------------------------------------------------
  299.   def update
  300.     super
  301.     if @fade_in
  302.       self.contents_opacity += 24
  303.       if @input_number_window != nil
  304.         @input_number_window.contents_opacity += 24
  305.       end
  306.       if self.contents_opacity == 255
  307.         @fade_in = false
  308.       end
  309.       return
  310.     end
  311.     @now_text = nil if @now_text == ""
  312.    
  313.     if @now_text != nil and @mid_stop == false
  314.       if @write_wait > 0
  315.         @write_wait -= 1
  316.         return
  317.       end
  318.       text_not_skip = $game_system.typing
  319.       while true
  320.         @max_x = @x if @max_x < @x
  321.         @max_y = @y if @max_y < @y
  322.         if (c = @now_text.slice!(/./m)) != nil
  323.           if c == "\000"
  324.             c = "\"
  325.           end
  326.           if c == "\001"
  327.             @now_text.sub!(/[([0-9]+)]/, "")
  328.             color = $1.to_i
  329.             if color >= 0 and color <= 7
  330.               self.contents.font.color = text_color(color)
  331.             end
  332.             c = ""
  333.           end
  334.           if c == "\002"
  335.             if @gold_window == nil and @popchar <= 0
  336.               @gold_window = Window_Gold.new
  337.               @gold_window.x = 560 - @gold_window.width
  338.               if $game_temp.in_battle
  339.                 @gold_window.y = 192
  340.               else
  341.                 @gold_window.y = self.y >= 128 ? 32 : 384
  342.               end
  343.               @gold_window.opacity = self.opacity
  344.               @gold_window.back_opacity = self.back_opacity
  345.             end
  346.             c = ""
  347.           end
  348.           if c == "\003"
  349.             @now_text.sub!(/[([0-9]+)]/, "")
  350.             speed = $1.to_i
  351.             if speed >= 0 and speed <= 19
  352.               @write_speed = speed
  353.             end
  354.             c = ""
  355.           end
  356.           if c == "\004"
  357.             @now_text.sub!(/[(.*?)]/, "")
  358.             buftxt = $1.dup.to_s
  359.             if buftxt.match(///) == nil and buftxt != "" then
  360.               $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  361.             else
  362.               $game_system.soundname_on_speak = buftxt.dup
  363.             end
  364.             c = ""
  365.           elsif c == "\004"
  366.             c = ""
  367.           end
  368.           if c == "\005"
  369.             @write_wait += 5
  370.             c = ""
  371.           end
  372.           if c == "\006"
  373.             @write_wait += 20
  374.             c = ""
  375.           end
  376.           if c == "\016"
  377.             text_not_skip = false
  378.             c = ""
  379.           end
  380.           if c == "\017"
  381.             text_not_skip = true
  382.             c = ""
  383.           end
  384.           if c == "\020"
  385.             @mid_stop = true
  386.             c = ""
  387.           end
  388.           if c == "\021"
  389.             terminate_message
  390.             return
  391.           end
  392.           if c == "\023"
  393.             @indent = @x
  394.             c = ""
  395.           end
  396.           if c == "\024"
  397.             @now_text.sub!(/[([0-9]+)]/, "")
  398.             @opacity = $1.to_i
  399.             c = ""
  400.           end
  401.           if c == "\025"
  402.             @now_text.sub!(/[([0-9]+)]/, "")
  403.             self.contents.font.size = [[$1.to_i, 6].max, 32].min
  404.             c = ""
  405.           end
  406.           if c == "\026"
  407.             @now_text.sub!(/[([0-9]+)]/, "")
  408.             @x += $1.to_i
  409.             c = ""
  410.           end
  411.           if c == "\027"
  412.             @now_text.sub!(/[(.*?)]/, "")
  413.             @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  414.             if $game_system.soundname_on_speak != ""
  415.               Audio.se_play($game_system.soundname_on_speak)
  416.             end
  417.             c = ""
  418.           end
  419.           if c == "\030"
  420.             @now_text.sub!(/[(.*?)]/, "")
  421.             self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  422.            if $game_system.soundname_on_speak != ""
  423.               Audio.se_play($game_system.soundname_on_speak)
  424.             end
  425.             @x += 24
  426.             c = ""
  427.           end
  428.           if c == "
  429. "
  430.             if @lines >= $game_temp.choice_start
  431.               @cursor_width = [@cursor_width, @max_x - @face_indent].max
  432.             end
  433.             @lines += 1
  434.             @y += 1
  435.             @x = 0 + @indent + @face_indent
  436.             if @lines >= $game_temp.choice_start
  437.               @x = 8 + @indent + @face_indent
  438.             end
  439.             c = ""
  440.           end
  441.           if c != ""
  442.             # 文字描画
  443.             @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  444.             if $game_system.soundname_on_speak != "" then
  445.             Audio.se_play($game_system.soundname_on_speak)
  446.             end
  447.           end
  448.           if Input.press?(Input::B)
  449.             text_not_skip = false
  450.           end
  451.         else
  452.           text_not_skip = true
  453.           break
  454.         end
  455.         # 終了判定
  456.         if text_not_skip
  457.           break
  458.         end
  459.       end
  460.       @write_wait += @write_speed
  461.       return
  462.     end
  463.     if @input_number_window != nil
  464.       @input_number_window.update
  465.       # 決定
  466.       if Input.trigger?(Input::C)
  467.         $game_system.se_play($data_system.decision_se)
  468.         $game_variables[$game_temp.num_input_variable_id] =
  469.         @input_number_window.number
  470.         $game_map.need_refresh = true
  471.         @input_number_window.dispose
  472.         @input_number_window = nil
  473.         terminate_message
  474.       end
  475.       return
  476.     end
  477.     if @contents_showing
  478.       if $game_temp.choice_max == 0
  479.         self.pause = true
  480.       end
  481.       # 取消
  482.       if Input.trigger?(Input::B)
  483.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  484.           $game_system.se_play($data_system.cancel_se)
  485.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  486.           terminate_message
  487.         end
  488.       end
  489.       # 決定
  490.       if Input.trigger?(Input::C)
  491.         if $game_temp.choice_max > 0
  492.           $game_system.se_play($data_system.decision_se)
  493.           $game_temp.choice_proc.call(self.index)
  494.         end
  495.         if @mid_stop
  496.           @mid_stop = false
  497.           return
  498.         else
  499.           terminate_message
  500.         end
  501.       end
  502.       return
  503.     end
  504.     if @fade_out == false and $game_temp.message_text != nil
  505.       @contents_showing = true
  506.       $game_temp.message_window_showing = true
  507.       refresh
  508.       Graphics.frame_reset
  509.       self.visible = true
  510.       self.contents_opacity = 0
  511.     if @input_number_window != nil
  512.       @input_number_window.contents_opacity = 0
  513.     end
  514.       @fade_in = true
  515.       return
  516.     end
  517.     if self.visible
  518.       @fade_out = true
  519.       self.opacity -= 48
  520.       if self.opacity == 0
  521.         self.visible = false
  522.         @fade_out = false
  523.         $game_temp.message_window_showing = false
  524.       end
  525.       return
  526.     end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # ● 获得字符
  530.   #--------------------------------------------------------------------------
  531.   def get_character(parameter)
  532.     case parameter
  533.     when 0
  534.       return $game_player
  535.     else
  536.       events = $game_map.events
  537.       return events == nil ? nil : events[parameter]
  538.     end
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ● ウィンドウの位置と不透明度の設定
  542.   #--------------------------------------------------------------------------
  543.   def reset_window
  544.     # 判定
  545.     if @popchar >= 0
  546.       events = $game_map.events
  547.       if events != nil
  548.         character = get_character(@popchar)
  549.         x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  550.         y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  551.         self.x = x
  552.         self.y = y
  553.       end
  554.     elsif @popchar == -1
  555.       self.x = -4
  556.       self.y = -4
  557.       self.width = 648
  558.       self.height = 488
  559.     else
  560.       if $game_temp.in_battle
  561.         self.y = 16
  562.       else
  563.         case $game_system.message_position
  564.         when 0 # 上
  565.           self.y = 16
  566.         when 1 # 中
  567.           self.y = 160
  568.         when 2 # 下
  569.           self.y = 304
  570.         end
  571.         self.x = 80
  572.         if @face_file == nil
  573.           self.width = 480
  574.         else
  575.           self.width = 600
  576.           self.x -= 60
  577.         end
  578.         self.height = 160
  579.       end
  580.     end
  581.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  582.     if @face_file != nil
  583.       self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  584.     end
  585.     if @popchar == -1
  586.       self.opacity = 255
  587.       self.back_opacity = 0
  588.     elsif $game_system.message_frame == 0
  589.       self.opacity = 255
  590.       self.back_opacity = 200
  591.     else
  592.       self.opacity = 0
  593.       self.back_opacity = 200
  594.     end
  595.   end
  596.   #--------------------------------------------------------------------------
  597.   # ● line_height
  598.   #--------------------------------------------------------------------------
  599.   # 返回値:行高
  600.   #--------------------------------------------------------------------------
  601.   def line_height
  602.     return 32
  603.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  604.       return 32
  605.     else
  606.       return self.contents.font.size * 15 / 10
  607.     end
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● 透過文字描画
  611.   #--------------------------------------------------------------------------
  612.   # target :描画対象。Bitmapクラスを指定。
  613.   # x :x座標
  614.   # y :y座標
  615.   # str  :描画文字列
  616.   # opacity:透過率(0~255)
  617.   # 返回値 :文字幅(@x増加値)。
  618.   #--------------------------------------------------------------------------
  619.   def opacity_draw_text(target, x, y, str,opacity)
  620.     height = target.font.size
  621.     width = target.text_size(str).width
  622.     opacity = [[opacity, 0].max, 255].min
  623.     if opacity == 255
  624.       target.draw_text(x, y, width, height, str)
  625.       return width
  626.     else
  627.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  628.         @opacity_text_buf.dispose
  629.         @opacity_text_buf = Bitmap.new(width, height)
  630.       else
  631.         @opacity_text_buf.clear
  632.       end
  633.       @opacity_text_buf.font.size = target.font.size
  634.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  635.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  636.     return width
  637.     end
  638.   end
  639.   def ruby_draw_text(target, x, y, str,opacity)
  640.     sizeback = target.font.size
  641.     target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  642.     rubysize = [rubysize, 6].max
  643.    
  644.     opacity = [[opacity, 0].max, 255].min
  645.     split_s = str.split(/,/)
  646.    
  647.     split_s[0] == nil ? split_s[0] = "" : nil
  648.     split_s[1] == nil ? split_s[1] = "" : nil
  649.    
  650.     height = sizeback + rubysize
  651.     width = target.text_size(split_s[0]).width
  652.    
  653.     target.font.size = rubysize
  654.     ruby_width = target.text_size(split_s[1]).width
  655.     target.font.size = sizeback
  656.    
  657.     buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  658.    
  659.     width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  660.    
  661.     if opacity == 255
  662.       target.font.size = rubysize
  663.       target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  664.       target.font.size = sizeback
  665.       target.draw_text(x, y, width, target.font.size, split_s[0])
  666.       return width
  667.     else
  668.       if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  669.         @opacity_text_buf.dispose
  670.         @opacity_text_buf = Bitmap.new(buf_width, height)
  671.       else
  672.         @opacity_text_buf.clear
  673.       end
  674.       @opacity_text_buf.font.size = rubysize
  675.       @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  676.       @opacity_text_buf.font.size = sizeback
  677.       @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  678.       if sub_x >= 0
  679.         target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  680.       else
  681.         target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  682.       end
  683.       return width
  684.     end
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # ● V 变换
  688.   #--------------------------------------------------------------------------
  689.   def convart_value(option, index)
  690.     option == nil ? option = "" : nil
  691.     option.downcase!
  692.     case option
  693.       when "i"
  694.         unless $data_items[index].name == nil
  695.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  696.         end
  697.       when "w"
  698.         unless $data_weapons[index].name == nil
  699.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  700.         end
  701.       when "a"
  702.         unless $data_armors[index].name == nil
  703.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  704.         end
  705.       when "s"
  706.         unless $data_skills[index].name == nil
  707.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  708.         end
  709.       else
  710.       r = $game_variables[index]
  711.     end
  712.     r == nil ? r = "" : nil
  713.     return r
  714.   end
  715.   #--------------------------------------------------------------------------
  716.   # ● 解放
  717.   #--------------------------------------------------------------------------
  718.   def dispose
  719.     terminate_message
  720.     if @gaiji_cache != nil
  721.       unless @gaiji_cache.disposed?
  722.         @gaiji_cache.dispose
  723.       end
  724.     end
  725.     unless @opacity_text_buf.disposed?
  726.       @opacity_text_buf.dispose
  727.     end
  728.     $game_temp.message_window_showing = false
  729.     if @input_number_window != nil
  730.       @input_number_window.dispose
  731.     end
  732.     super
  733.   end
  734.   #--------------------------------------------------------------------------
  735.   # ● 矩形更新
  736.   #--------------------------------------------------------------------------
  737.   def update_cursor_rect
  738.     if @index >= 0
  739.       n = $game_temp.choice_start + @index
  740.       self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  741.     else
  742.       self.cursor_rect.empty
  743.     end
  744.   end
  745. end
  746. #==============================================================================
  747. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  748. #==============================================================================
  749. class Window_Frame < Window_Base
  750.   #--------------------------------------------------------------------------
  751.   # ● オブジェクト初期化
  752.   #--------------------------------------------------------------------------
  753.   def initialize(x, y, width, height)
  754.     super(x, y, width, height)
  755.     self.contents = nil
  756.     self.back_opacity = 200
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # ● 解放
  760.   #--------------------------------------------------------------------------
  761.   def dispose
  762.     super
  763.     end
  764.   end
  765. #==============================================================================
  766. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  767. #==============================================================================
  768. class Air_Text < Window_Base
  769.   #--------------------------------------------------------------------------
  770.   # ● オブジェクト初期化
  771.   #--------------------------------------------------------------------------
  772.   def initialize(x, y, designate_text)
  773.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  774.     self.opacity = 0
  775.     self.back_opacity = 0
  776.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  777.     w = self.contents.width
  778.     h = self.contents.height
  779.     self.contents.draw_text(0, 0, w, h, designate_text)
  780.   end
  781.   #--------------------------------------------------------------------------
  782.   # ● 解放
  783.   #--------------------------------------------------------------------------
  784.   def dispose
  785.     self.contents.clear
  786.     super
  787.   end
  788. end
复制代码
和更改字体的脚本
  1. #==================================================================
  2. #   66RPG      对话使用第二字体
  3. #==================================================================
  4. #------------------------------------------------------------
  5. #这个脚本的念头是在论坛上问类似问题时,受simounF的回答,而启发的
  6. #
  7. #由于目前我对脚本的了解也只是皮毛,有不正确的地方,请大家给我指点一下喔
  8. #对此脚本有疑问请在bbs.66RPG.com给我站内短信吧……>_<   猫哥哥
  9. #==============================================================
  10. #
  11. #★使用方法★:将本脚本插入到main脚本之前。
  12. #           先设置下面的预处理内容,然后用f[n]来在对话里切换字体(默认的n=0~4)
  13. #          和整合的对话脚本可能有冲突,懂脚本的自己修改一下吧
  14. #
  15. #          f[1]回到默认
  16. #          f[2]使用第二字体
  17. #          f[3]使用第三字体
  18. #          f[4]使用第四字体
  19. #   ●注意,在未来对本脚本做修改的情况下,请不要使用n=1~4之外的数字
  20. #     比如f[0]或者f[9]等,否则必然出现脚本错误!!
  21. #
  22. #=================预先处理=======================
  23. #
  24. ###########①默认字体(如果修改了main或者Window_Base里的默认字体,把这里设置一下)-------
  25. #
  26. $cat_默认文字字体 ="黑体"    #默认的黑体
  27. $cat_默认字体大小 =22        #默认的22号
  28. $cat_默认字体颜色 = Color.new(255,255,255,255)   #默认用的白色
  29. #不懂怎么换颜色的菜鸟看这里:  ↑上面这个括号里,四个数值分别是(红,绿,蓝,透明度),取值范围是(0~255),想要什么颜色自己更该数值试试看吧。
  30. #
  31. ###########②第二字体的设置#########################
  32. $cat_使用的第二字体 ="楷体_GB2312"
  33. $cat_使用的第二字体大小 =22
  34. $cat_使用的第二字体颜色 = Color.new(255,55,55,255) #红
  35. ##################################################
  36. #
  37. ###########③第三字体的设置#########################
  38. $cat_使用的第三字体 ="宋体"
  39. $cat_使用的第三字体大小 =22
  40. $cat_使用的第三字体颜色 = Color.new(225,225,80,255) #黄
  41. ##################################################
  42. #
  43. ###########④第四字体的设置#########################
  44. $cat_使用的第四字体 ="华文行楷"
  45. $cat_使用的第四字体大小 =42
  46. $cat_使用的第四字体颜色 = Color.new(0,0,123,255) #蓝
  47. ######################################################
  48. #
  49. #----------定义部分-------------
  50. #——字体---
  51. class Window_Base
  52.   def font_style(n)
  53.    case n
  54.    when 1
  55.      return $cat_默认文字字体
  56.    when 2
  57.      return $cat_使用的第二字体
  58.    when 3
  59.      return $cat_使用的第三字体
  60.    when 4
  61.      return $cat_使用的第四字体
  62.    end
  63. end
  64. #---大小---
  65. def font_size(n)
  66.    case n
  67.    when 1
  68.      return $cat_默认字体大小
  69.    when 2
  70.      return $cat_使用的第二字体大小
  71.    when 3
  72.      return $cat_使用的第三字体大小
  73.    when 4
  74.      return $cat_使用的第四字体大小
  75.    end
  76. end
  77. #----颜色------
  78. def text_color2nd(n)
  79.    case n
  80.    when 1
  81.      return $cat_默认字体颜色
  82.    when 2
  83.      return $cat_使用的第二字体颜色
  84.    when 3
  85.      return $cat_使用的第三字体颜色
  86.    when 4
  87.      return $cat_使用的第四字体颜色
  88.    end
  89.   end
  90. end
  91. #----------重新定义刷新--------------------
  92. class Window_Message
  93.   
  94.   def refresh
  95.    self.contents.clear
  96. #======增添修改的部分=============================
  97.    self.contents.font.color = $cat_默认字体颜色  #
  98.    self.contents.font.name = $cat_默认文字字体   #
  99.    self.contents.font.size = $cat_默认字体大小   #
  100. #=================================================
  101.    
  102.    x = y = 0
  103.    @cursor_width = 0
  104.    # 到选择项的下一行字
  105.    if $game_temp.choice_start == 0
  106.      x = 8
  107.    end
  108.    # 有等待显示的文字的情况下
  109.    if $game_temp.message_text != nil
  110.      text = $game_temp.message_text
  111.      # 限制文字处理
  112.      begin
  113.        last_text = text.clone
  114.        text.gsub!(/\[Vv][([0-9]+)]/) { $game_variables[$1.to_i] }
  115.      end until text == last_text
  116.      text.gsub!(/\[Nn][([0-9]+)]/) do
  117.        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  118.      end
  119.      # 为了方便、将 "\\" 变换为 "\000"
  120.      text.gsub!(/\\/) { "\000" }
  121.      # "\C" 变为 "\001" に、"\G" 变为 "\002"
  122.      text.gsub!(/\[Cc][([0-9]+)]/) { "\001[#{$1}]" }
  123.      text.gsub!(/\[Gg]/) { "\002" }
  124.      
  125. #=====增添修改修改的部分================================
  126.      text.gsub!(/\[Ff][([0-9]+)]/) { "\003[#{$1}]" }#
  127. #=======================================================
  128.      
  129.      # c 获取 1 个字 (如果不能取得文字就循环)
  130.      while ((c = text.slice!(/./m)) != nil)
  131.        # \ 的情况下
  132.        if c == "\000"
  133.          # 还原为本来的文字
  134.          c = "\"
  135.        end
  136.        # C[n] 的情况下
  137.        if c == "\001"
  138.          # 更改文字色
  139.          text.sub!(/[([0-9]+)]/, "")
  140.          color = $1.to_i
  141.          if color >= 0 and color <= 7
  142.            self.contents.font.color = text_color(color)
  143.          end
  144.          # 下面的文字
  145.          next
  146.        end
  147.       
  148. #=========增添修改的部分============================================================
  149.               # F[n] 的情况下
  150.        if c == "\003"
  151.          # 更改文字字体
  152.          text.sub!(/[([0-9]+)]/, "")
  153.          style = $1.to_i
  154.          color2nd = $1.to_i
  155.          size = $1.to_i
  156.          if style >= 1 and style <= 4 # 4是字体最大的编号,增加字体要加大这个数字
  157.             color2nd >= 1 and color2nd <= 4 # 如果修改了上面的最大值,这里也要改
  158.             size >= 1 and size <= 4 # 如果修改了上面的最大值,这里也要改
  159.            self.contents.font.name = font_style(style)
  160.            self.contents.font.color = text_color2nd(color2nd)
  161.            self.contents.font.size = font_size(size)
  162.          end
  163.          # 下面的文字
  164.          next
  165.        end
  166. #=====================================================================
  167.       
  168.        # G 的情况下
  169.        if c == "\002"
  170.          # 生成金钱窗口
  171.          if @gold_window == nil
  172.            @gold_window = Window_Gold.new
  173.            @gold_window.x = 560 - @gold_window.width
  174.            if $game_temp.in_battle
  175.              @gold_window.y = 192
  176.            else
  177.              @gold_window.y = self.y >= 128 ? 32 : 384
  178.            end
  179.            @gold_window.opacity = self.opacity
  180.            @gold_window.back_opacity = self.back_opacity
  181.          end
  182.          # 下面的文字
  183.          next
  184.        end
  185.        # 另起一行文字的情况下
  186.        if c == "
  187. "
  188.          # 刷新选择项及光标的高
  189.          if y >= $game_temp.choice_start
  190.            @cursor_width = [@cursor_width, x].max
  191.          end
  192.          # y 加 1
  193.          y += 1
  194.          x = 0
  195.          # 移动到选择项的下一行
  196.          if y >= $game_temp.choice_start
  197.            x = 8
  198.          end
  199.          # 下面的文字
  200.          next
  201.        end
  202.        # 描绘文字
  203.        self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
  204.        # x 为要描绘文字的加法运算
  205.        x += self.contents.text_size(c).width
  206.      end
  207.    end
  208.    # 选择项的情况
  209.    if $game_temp.choice_max > 0
  210.      @item_max = $game_temp.choice_max
  211.      self.active = true
  212.      self.index = 0
  213.    end
  214.    # 输入数值的情况
  215.    if $game_temp.num_input_variable_id > 0
  216.      digits_max = $game_temp.num_input_digits_max
  217.      number = $game_variables[$game_temp.num_input_variable_id]
  218.      @input_number_window = Window_InputNumber.new(digits_max)
  219.      @input_number_window.number = number
  220.      @input_number_window.x = self.x + 8
  221.      @input_number_window.y = self.y + $game_temp.num_input_start * 32
  222.    end
  223. end
  224. end
复制代码
望各位高手大侠将这两个脚本合并一下~万分感谢~


naibo456于2011-8-4 22:00补充以下内容:
求助啊!
没有什么是做不到的!
前方的路如何?不走怎么知道!

Lv1.梦旅人

梦石
0
星屑
50
在线时间
248 小时
注册时间
2010-8-22
帖子
127
2
发表于 2011-8-5 10:04:43 | 只看该作者
本帖最后由 YamazakiRyusa 于 2011-8-5 10:19 编辑

加个条件分歧就可以了,等我做吧。


YamazakiRyusa于2011-8-5 10:18补充以下内容:
可以直接在事件中编个脚本写出来。

  1. Font.default_name = (["华文细黑" , "黑体"])
复制代码
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
48 小时
注册时间
2010-8-26
帖子
68
3
 楼主| 发表于 2011-8-5 12:25:00 | 只看该作者
嗯,这个很不错,但想在一句话中加入很多字体,又应该怎么办呢?
这个答案不错,先谢谢了!

但要是有有更好的就好了……


naibo456于2011-8-9 21:01补充以下内容:
这样也可以了,谢谢你!
没有什么是做不到的!
前方的路如何?不走怎么知道!
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-14 15:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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