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

Project1

 找回密码
 注册会员
搜索
查看: 2319|回复: 4

[已经解决] 【已经自行解决】在使用了对话框脚本之后怎样改变字体...

[复制链接]

Lv2.观梦者

梦石
0
星屑
482
在线时间
67 小时
注册时间
2016-7-21
帖子
12
发表于 2019-5-3 01:12:13 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 coco1068 于 2019-5-11 00:57 编辑

RUBY 代码复制
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————
  4.  
  5. #——说明
  6.  
  7. #默认为一个字一个字的方式,如果需要一次全部显示,
  8. #请在游戏中使用脚本:$game_system.typing = true
  9.  
  10. #默认对话字没有声音,如果需要声音,
  11. #请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  12.  
  13. # 其他在对话中可以使用的功能:
  14.  
  15. # \n[1]:显示1号角色的姓名
  16.  
  17. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名
  18.  
  19. # \p[1]:对话框出现在1号事件的上方
  20. # \p[0]:主人公上方出现对话框
  21. #——————————————————使用\p功能后可以自动调整对话框大小
  22.  
  23. # \\:显示"\"这个符号
  24.  
  25. # \v[1] :显示变量1
  26.  
  27. # \v[a1] :显示防具1
  28.  
  29. # \v[w1] :显示武器1
  30.  
  31. # \v[i1] :显示物品1
  32.  
  33. # \v[s1] :显示特技1
  34.  
  35. # \c[1-8]:更改颜色
  36.  
  37. # \g:显示金钱窗口
  38.  
  39. # \a[SE文件名]:对话的时候播放SE
  40.  
  41. # \s[1-19]:更改弹字的速度
  42.  
  43. # \.   :停顿一刹那(1、2帧)
  44. # \|   :停顿片刻(20帧)
  45.  
  46. # \>   :文字不用打字方式
  47. # \<   :文字使用打字方式
  48.  
  49. # \!   :等待玩家按回车再继续
  50. # \~   :文字直接消失
  51.  
  52. # \I   :下一行从这个位置开始
  53.  
  54. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  55.  
  56. # \h[12]:改用12号字
  57.  
  58. # \b[50]:空50象素
  59.  
  60. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效
  61.  
  62. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  63. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
  64.  
  65. # \Lk:清除左边的图像
  66. # \Rk:清除右边的图像
  67.  
  68. #==============================================================================
  69. # ■ Game_System
  70. #------------------------------------------------------------------------------
  71. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  72. # $game_system 。
  73. #==============================================================================
  74.  
  75. class Game_System
  76.   attr_accessor :typing
  77.   attr_accessor :soundname_on_speak
  78.   alias carol3_ini initialize
  79.   def initialize
  80.     carol3_ini
  81.     @typing = true
  82.     @soundname_on_speak = nil
  83.   end
  84. end
  85. $加密 = true
  86. #==============================================================================
  87. # ■ Window_Message
  88. #------------------------------------------------------------------------------
  89. class Window_Message < Window_Selectable
  90.   #--------------------------------------------------------------------------
  91.   # ● 初始化状态
  92.   #--------------------------------------------------------------------------
  93.   def initialize
  94.     super(80, 304, 480, 160)
  95.     self.contents = Bitmap.new(width - 32, height - 32)
  96.     self.visible = false
  97.     self.z = 9998
  98.     @fade_in = false
  99.     @fade_out = false
  100.     @contents_showing = false
  101.     @cursor_width = 0
  102.     self.active = false
  103.     self.index = -1
  104.     if $game_system.soundname_on_speak == nil then
  105.       $game_system.soundname_on_speak = ""
  106.     end
  107.     @opacity_text_buf = Bitmap.new(32, 32)
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● 释放
  111.   #--------------------------------------------------------------------------
  112.   def dispose
  113.     terminate_message
  114.     $game_temp.message_window_showing = false
  115.     if @input_number_window != nil
  116.       @input_number_window.dispose
  117.     end
  118.     super
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 处理信息结束
  122.   #--------------------------------------------------------------------------
  123.   def terminate_message
  124.     self.active = false
  125.     self.pause = false
  126.     self.index = -1
  127.     self.contents.clear
  128.     # 清除显示中标志
  129.     @contents_showing = false
  130.     # 呼叫信息调用
  131.     if $game_temp.message_proc != nil
  132.       $game_temp.message_proc.call
  133.     end
  134.     # 清除文章、选择项、输入数值的相关变量
  135.     $game_temp.message_text = nil
  136.     $game_temp.message_proc = nil
  137.     $game_temp.choice_start = 99
  138.     $game_temp.choice_max = 0
  139.     $game_temp.choice_cancel_type = 0
  140.     $game_temp.choice_proc = nil
  141.     $game_temp.num_input_start = 99
  142.     $game_temp.num_input_variable_id = 0
  143.     $game_temp.num_input_digits_max = 0
  144.     # 开放金钱窗口
  145.     if @gold_window != nil
  146.       @gold_window.dispose
  147.       @gold_window = nil
  148.     end
  149.     if @name_window_frame != nil
  150.       @name_window_frame.dispose
  151.       @name_window_frame = nil
  152.     end
  153.     if @name_window_text != nil
  154.       @name_window_text.dispose
  155.       @name_window_text = nil
  156.     end
  157.     if @right_picture != nil and @right_keep == true
  158.       @right_picture.dispose
  159.     end   
  160.     if @left_picture != nil and @left_keep == true
  161.       @left_picture.dispose
  162.     end
  163.   end
  164.   def refresh
  165.     # 初期化
  166.     self.contents.clear
  167.     self.contents.font.color = normal_color
  168.     self.contents.font.size = Font.default_size
  169.     @x = @y = @max_x = @max_y = @indent = @lines = 0
  170.     @left_keep = @right_keep = false
  171.     @face_indent = 0
  172.     @opacity = 255
  173.     @cursor_width = 0
  174.     @write_speed = 0
  175.     @write_wait = 0
  176.     @mid_stop = false
  177.     @face_file = nil
  178.     @popchar = -2
  179.     if $game_temp.choice_start == 0
  180.       @x = 8
  181.     end
  182.     if $game_temp.message_text != nil
  183.       @now_text = $game_temp.message_text
  184.       #——头像设置
  185.       if (/\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  186.         @face_file = $1 + ".png"
  187.         @x = @face_indent = 128
  188.         if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  189.           self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  190.         end
  191.         @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  192.       end
  193.       #——左半身像设置
  194.       if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  195.         @face = "66rpg_" + $1 + "_h.png"
  196.         if $加密 == true
  197.           if @left_picture != nil
  198.             @left_picture.dispose
  199.           end
  200.           @left_picture = Sprite.new
  201.           @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  202.           @left_picture.y = 480-@left_picture.bitmap.height
  203.           @left_picture.x = 0
  204.           @left_picture.mirror = true
  205.           @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  206.         else         
  207.           if FileTest.exist?("Graphics/battlers/#{@face}")
  208.             if @left_picture != nil
  209.               @left_picture.dispose
  210.             end
  211.             @left_picture = Sprite.new
  212.             @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  213.             @left_picture.y = 480-@left_picture.bitmap.height
  214.             @left_picture.x = 0
  215.             @left_picture.mirror = true
  216.             @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  217.           end
  218.         end        
  219.       end
  220.       #——右半身像设置
  221.       if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  222.         @face = "66rpg_" + $1 + "_h.png"
  223.         if $加密 == true
  224.           if @right_picture != nil
  225.             @right_picture.dispose
  226.           end
  227.           @right_picture = Sprite.new
  228.           @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  229.           @right_picture.y = 440-@right_picture.bitmap.height
  230.           @right_picture.x = 640-@right_picture.bitmap.width
  231.           @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  232.         else
  233.           if FileTest.exist?("Graphics/battlers/#{@face}")
  234.             if @right_picture != nil
  235.               @right_picture.dispose
  236.             end
  237.             @right_picture = Sprite.new
  238.             @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  239.             @right_picture.y = 480-@right_picture.bitmap.height
  240.             @right_picture.x = 640-@right_picture.bitmap.width
  241.             @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  242.           end
  243.         end
  244.       end
  245.       if (/\\[Rr]k/.match(@now_text)) != nil
  246.         @right_keep = true
  247.         @now_text.sub!(/\\[Rr]k/) { "" }
  248.       end
  249.       if (/\\[Ll]k/.match(@now_text)) != nil
  250.         @left_keep = true
  251.         @now_text.sub!(/\\[Ll]k/) { "" }
  252.       end
  253.       # 显示人物姓名
  254.       name_window_set = false
  255.       if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  256.         name_window_set = true
  257.         name_text = $1
  258.         @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  259.       end
  260.  
  261.       # 文字位置的判定
  262.       if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  263.         @popchar = $1.to_i
  264.         if @popchar == -1
  265.           @x = @indent = 48
  266.           @y = 4
  267.         end
  268.         @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  269.       end
  270.  
  271.       # 开始
  272.       begin
  273.         last_text = @now_text.clone
  274.         @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  275.       end until @now_text == last_text
  276.       @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  277.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  278.     end
  279.     @now_text.gsub!(/\\\\/) { "\000" }
  280.     @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  281.     @now_text.gsub!(/\\[Gg]/) { "\002" }
  282.     @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  283.     @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  284.     @now_text.gsub!(/\\[.]/) { "\005" }
  285.     @now_text.gsub!(/\\[|]/) { "\006" }
  286.  
  287.     @now_text.gsub!(/\\[>]/) { "\016" }
  288.     @now_text.gsub!(/\\[<]/) { "\017" }
  289.     @now_text.gsub!(/\\[!]/) { "\020" }
  290.     @now_text.gsub!(/\\[~]/) { "\021" }
  291.  
  292.     @now_text.gsub!(/\\[Ii]/) { "\023" }
  293.     @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  294.     @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  295.     @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  296.     @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  297.     if @popchar >= 0
  298.       @text_save = @now_text.clone
  299.       @max_x = 0
  300.       @max_y = 4
  301.       for i in 0..3
  302.         line = @now_text.split(/\n/)[3-i]
  303.         @max_y -= 1 if line == nil and @max_y <= 4-i
  304.         next if line == nil
  305.         cx = contents.text_size(line).width
  306.         @max_x = cx if cx > @max_x
  307.       end
  308.       self.width = @max_x + 48 + @face_indent
  309.       self.height = (@max_y - 1) * 32 + 64
  310.     else
  311.       @max_x = self.width - 32 - @face_indent
  312.     end
  313.     reset_window
  314.       if name_window_set
  315.         off_x = 0
  316.         off_y = -40
  317.         space = 2
  318.         x = self.x + off_x - space / 2
  319.         y = self.y + off_y - space / 2
  320.         w = self.contents.text_size(name_text).width + 26 + space
  321.         h = 40 + space
  322.         @name_window_frame = Window_Frame.new(x, y, w, h)
  323.         @name_window_frame.z = self.z + 1
  324.         x = self.x + off_x + 4
  325.         y = self.y + off_y
  326.         @name_window_text = Air_Text.new(x+4, y+6, name_text)
  327.         @name_window_text.z = self.z + 2
  328.       end
  329.     end
  330.     reset_window
  331.     if $game_temp.choice_max > 0
  332.       @item_max = $game_temp.choice_max
  333.       self.active = true
  334.       self.index = 0
  335.     end
  336.     if $game_temp.num_input_variable_id > 0
  337.       digits_max = $game_temp.num_input_digits_max
  338.       number = $game_variables[$game_temp.num_input_variable_id]
  339.       @input_number_window = Window_InputNumber.new(digits_max)
  340.       @input_number_window.number = number
  341.       @input_number_window.x = self.x + 8
  342.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  343.     end
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● 更新
  347.   #--------------------------------------------------------------------------
  348.   def update
  349.     super
  350.     if @fade_in
  351.       self.contents_opacity += 24
  352.       if @input_number_window != nil
  353.         @input_number_window.contents_opacity += 24
  354.       end
  355.       if self.contents_opacity == 255
  356.         @fade_in = false
  357.       end
  358.       return
  359.     end
  360.     @now_text = nil if @now_text == ""
  361.  
  362.     if @now_text != nil and @mid_stop == false
  363.       if @write_wait > 0
  364.         @write_wait -= 1
  365.         return
  366.       end
  367.       text_not_skip = $game_system.typing
  368.       while true
  369.         @max_x = @x if @max_x < @x
  370.         @max_y = @y if @max_y < @y
  371.         if (c = @now_text.slice!(/./m)) != nil
  372.           if c == "\000"
  373.             c = "\\"
  374.           end
  375.           if c == "\001"
  376.             @now_text.sub!(/\[([0-9]+)\]/, "")
  377.             color = $1.to_i
  378.             if color >= 0 and color <= 7
  379.               self.contents.font.color = text_color(color)
  380.             end
  381.             c = ""
  382.           end
  383.           if c == "\002"
  384.             if @gold_window == nil and @popchar <= 0
  385.               @gold_window = Window_Gold.new
  386.               @gold_window.x = 560 - @gold_window.width
  387.               if $game_temp.in_battle
  388.                 @gold_window.y = 192
  389.               else
  390.                 @gold_window.y = self.y >= 128 ? 32 : 384
  391.               end
  392.               @gold_window.opacity = self.opacity
  393.               @gold_window.back_opacity = self.back_opacity
  394.             end
  395.             c = ""
  396.           end
  397.           if c == "\003"
  398.             @now_text.sub!(/\[([0-9]+)\]/, "")
  399.             speed = $1.to_i
  400.             if speed >= 0 and speed <= 19
  401.               @write_speed = speed
  402.             end
  403.             c = ""
  404.           end
  405.           if c == "\004"
  406.             @now_text.sub!(/\[(.*?)\]/, "")
  407.             buftxt = $1.dup.to_s
  408.             if buftxt.match(/\//) == nil and buftxt != "" then
  409.               $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  410.             else
  411.               $game_system.soundname_on_speak = buftxt.dup
  412.             end
  413.             c = ""
  414.           elsif c == "\004"
  415.             c = ""
  416.           end
  417.           if c == "\005"
  418.             @write_wait += 5
  419.             c = ""
  420.           end
  421.           if c == "\006"
  422.             @write_wait += 20
  423.             c = ""
  424.           end
  425.           if c == "\016"
  426.             text_not_skip = false
  427.             c = ""
  428.           end
  429.           if c == "\017"
  430.             text_not_skip = true
  431.             c = ""
  432.           end
  433.           if c == "\020"
  434.             @mid_stop = true
  435.             c = ""
  436.           end
  437.           if c == "\021"
  438.             terminate_message
  439.             return
  440.           end
  441.           if c == "\023"
  442.             @indent = @x
  443.             c = ""
  444.           end
  445.           if c == "\024"
  446.             @now_text.sub!(/\[([0-9]+)\]/, "")
  447.             @opacity = $1.to_i
  448.             c = ""
  449.           end
  450.           if c == "\025"
  451.             @now_text.sub!(/\[([0-9]+)\]/, "")
  452.             self.contents.font.size = [[$1.to_i, 6].max, 32].min
  453.             c = ""
  454.           end
  455.           if c == "\026"
  456.             @now_text.sub!(/\[([0-9]+)\]/, "")
  457.             @x += $1.to_i
  458.             c = ""
  459.           end
  460.           if c == "\027"
  461.             @now_text.sub!(/\[(.*?)\]/, "")
  462.             @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  463.             if $game_system.soundname_on_speak != ""
  464.               Audio.se_play($game_system.soundname_on_speak)
  465.             end
  466.             c = ""
  467.           end
  468.           if c == "\030"
  469.             @now_text.sub!(/\[(.*?)\]/, "")
  470.             self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  471.            if $game_system.soundname_on_speak != ""
  472.               Audio.se_play($game_system.soundname_on_speak)
  473.             end
  474.             @x += 24
  475.             c = ""
  476.           end
  477.           if c == "\n"
  478.             if @lines >= $game_temp.choice_start
  479.               @cursor_width = [@cursor_width, @max_x - @face_indent].max
  480.             end
  481.             @lines += 1
  482.             @y += 1
  483.             @x = 0 + @indent + @face_indent
  484.             if @lines >= $game_temp.choice_start
  485.               @x = 8 + @indent + @face_indent
  486.             end
  487.             c = ""
  488.           end
  489.           if c != ""
  490.             # 文字描画
  491.             @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  492.             if $game_system.soundname_on_speak != "" then
  493.             Audio.se_play($game_system.soundname_on_speak)
  494.             end
  495.           end
  496.           if Input.press?(Input::B)
  497.             text_not_skip = false
  498.           end
  499.         else
  500.           text_not_skip = true
  501.           break
  502.         end
  503.         # 終了判定
  504.         if text_not_skip
  505.           break
  506.         end
  507.       end
  508.       @write_wait += @write_speed
  509.       return
  510.     end
  511.     if @input_number_window != nil
  512.       @input_number_window.update
  513.       # 決定
  514.       if Input.trigger?(Input::C)
  515.         $game_system.se_play($data_system.decision_se)
  516.         $game_variables[$game_temp.num_input_variable_id] =
  517.         @input_number_window.number
  518.         $game_map.need_refresh = true
  519.         @input_number_window.dispose
  520.         @input_number_window = nil
  521.         terminate_message
  522.       end
  523.       return
  524.     end
  525.     if @contents_showing
  526.       if $game_temp.choice_max == 0
  527.         self.pause = true
  528.       end
  529.       # 取消
  530.       if Input.trigger?(Input::B)
  531.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  532.           $game_system.se_play($data_system.cancel_se)
  533.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  534.           terminate_message
  535.         end
  536.       end
  537.       # 決定
  538.       if Input.trigger?(Input::C)
  539.         if $game_temp.choice_max > 0
  540.           $game_system.se_play($data_system.decision_se)
  541.           $game_temp.choice_proc.call(self.index)
  542.         end
  543.         if @mid_stop
  544.           @mid_stop = false
  545.           return
  546.         else
  547.           terminate_message
  548.         end
  549.       end
  550.       return
  551.     end
  552.     if @fade_out == false and $game_temp.message_text != nil
  553.       @contents_showing = true
  554.       $game_temp.message_window_showing = true
  555.       refresh
  556.       Graphics.frame_reset
  557.       self.visible = true
  558.       self.contents_opacity = 0
  559.     if @input_number_window != nil
  560.       @input_number_window.contents_opacity = 0
  561.     end
  562.       @fade_in = true
  563.       return
  564.     end
  565.     if self.visible
  566.       @fade_out = true
  567.       self.opacity -= 48
  568.       if self.opacity == 0
  569.         self.visible = false
  570.         @fade_out = false
  571.         $game_temp.message_window_showing = false
  572.       end
  573.       return
  574.     end
  575.   end
  576.   #--------------------------------------------------------------------------
  577.   # ● 获得字符
  578.   #--------------------------------------------------------------------------
  579.   def get_character(parameter)
  580.     case parameter
  581.     when 0
  582.       return $game_player
  583.     else
  584.       events = $game_map.events
  585.       return events == nil ? nil : events[parameter]
  586.     end
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ● ウィンドウの位置と不透明度の設定
  590.   #--------------------------------------------------------------------------
  591.   def reset_window
  592.     # 判定
  593.     if @popchar >= 0
  594.       events = $game_map.events
  595.       if events != nil
  596.         character = get_character(@popchar)
  597.         x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  598.         y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  599.         self.x = x
  600.         self.y = y
  601.       end
  602.     elsif @popchar == -1
  603.       self.x = -4
  604.       self.y = -4
  605.       self.width = 648
  606.       self.height = 488
  607.     else
  608.       if $game_temp.in_battle
  609.         self.y = 16
  610.       else
  611.         case $game_system.message_position
  612.         when 0 # 上
  613.           self.y = 16
  614.         when 1 # 中
  615.           self.y = 160
  616.         when 2 # 下
  617.           self.y = 304
  618.         end
  619.         self.x = 80
  620.         if @face_file == nil
  621.           self.width = 480
  622.         else
  623.           self.width = 600
  624.           self.x -= 60
  625.         end
  626.         self.height = 160
  627.       end
  628.     end
  629.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  630.     if @face_file != nil
  631.       self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  632.     end
  633.     if @popchar == -1
  634.       self.opacity = 255
  635.       self.back_opacity = 0
  636.     elsif $game_system.message_frame == 0
  637.       self.opacity = 255
  638.       self.back_opacity = 200
  639.     else
  640.       self.opacity = 0
  641.       self.back_opacity = 200
  642.     end
  643.   end
  644.   #--------------------------------------------------------------------------
  645.   # ● line_height
  646.   #--------------------------------------------------------------------------
  647.   # 返回値:行高
  648.   #--------------------------------------------------------------------------
  649.   def line_height
  650.     return 32
  651.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  652.       return 32
  653.     else
  654.       return self.contents.font.size * 15 / 10
  655.     end
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 透過文字描画
  659.   #--------------------------------------------------------------------------
  660.   # target :描画対象。Bitmapクラスを指定。
  661.   # x :x座標
  662.   # y :y座標
  663.   # str  :描画文字列
  664.   # opacity:透過率(0~255)
  665.   # 返回値 :文字幅(@x増加値)。
  666.   #--------------------------------------------------------------------------
  667.   def opacity_draw_text(target, x, y, str,opacity)
  668.     height = target.font.size
  669.     width = target.text_size(str).width
  670.     opacity = [[opacity, 0].max, 255].min
  671.     if opacity == 255
  672.       target.draw_text(x, y, width, height, str)
  673.       return width
  674.     else
  675.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  676.         @opacity_text_buf.dispose
  677.         @opacity_text_buf = Bitmap.new(width, height)
  678.       else
  679.         @opacity_text_buf.clear
  680.       end
  681.       @opacity_text_buf.font.size = target.font.size
  682.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  683.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  684.     return width
  685.     end
  686.   end
  687.   def ruby_draw_text(target, x, y, str,opacity)
  688.     sizeback = target.font.size
  689.     target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  690.     rubysize = [rubysize, 6].max
  691.  
  692.     opacity = [[opacity, 0].max, 255].min
  693.     split_s = str.split(/,/)
  694.  
  695.     split_s[0] == nil ? split_s[0] = "" : nil
  696.     split_s[1] == nil ? split_s[1] = "" : nil
  697.  
  698.     height = sizeback + rubysize
  699.     width = target.text_size(split_s[0]).width
  700.  
  701.     target.font.size = rubysize
  702.     ruby_width = target.text_size(split_s[1]).width
  703.     target.font.size = sizeback
  704.  
  705.     buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  706.  
  707.     width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  708.  
  709.     if opacity == 255
  710.       target.font.size = rubysize
  711.       target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  712.       target.font.size = sizeback
  713.       target.draw_text(x, y, width, target.font.size, split_s[0])
  714.       return width
  715.     else
  716.       if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  717.         @opacity_text_buf.dispose
  718.         @opacity_text_buf = Bitmap.new(buf_width, height)
  719.       else
  720.         @opacity_text_buf.clear
  721.       end
  722.       @opacity_text_buf.font.size = rubysize
  723.       @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  724.       @opacity_text_buf.font.size = sizeback
  725.       @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  726.       if sub_x >= 0
  727.         target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  728.       else
  729.         target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  730.       end
  731.       return width
  732.     end
  733.   end
  734.   #--------------------------------------------------------------------------
  735.   # ● \V 变换
  736.   #--------------------------------------------------------------------------
  737.   def convart_value(option, index)
  738.     option == nil ? option = "" : nil
  739.     option.downcase!
  740.     case option
  741.       when "i"
  742.         unless $data_items[index].name == nil
  743.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  744.         end
  745.       when "w"
  746.         unless $data_weapons[index].name == nil
  747.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  748.         end
  749.       when "a"
  750.         unless $data_armors[index].name == nil
  751.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  752.         end
  753.       when "s"
  754.         unless $data_skills[index].name == nil
  755.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  756.         end
  757.       else
  758.       r = $game_variables[index]
  759.     end
  760.     r == nil ? r = "" : nil
  761.     return r
  762.   end
  763.   #--------------------------------------------------------------------------
  764.   # ● 解放
  765.   #--------------------------------------------------------------------------
  766.   def dispose
  767.     terminate_message
  768.     if @gaiji_cache != nil
  769.       unless @gaiji_cache.disposed?
  770.         @gaiji_cache.dispose
  771.       end
  772.     end
  773.     unless @opacity_text_buf.disposed?
  774.       @opacity_text_buf.dispose
  775.     end
  776.     $game_temp.message_window_showing = false
  777.     if @input_number_window != nil
  778.       @input_number_window.dispose
  779.     end
  780.     super
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 矩形更新
  784.   #--------------------------------------------------------------------------
  785.   def update_cursor_rect
  786.     if @index >= 0
  787.       n = $game_temp.choice_start + @index
  788.       self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  789.     else
  790.       self.cursor_rect.empty
  791.     end
  792.   end
  793. end
  794. #==============================================================================
  795. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  796. #==============================================================================
  797. class Window_Frame < Window_Base
  798.   #--------------------------------------------------------------------------
  799.   # ● オブジェクト初期化
  800.   #--------------------------------------------------------------------------
  801.   def initialize(x, y, width, height)
  802.     super(x, y, width, height)
  803.     self.contents = nil
  804.     self.back_opacity = 200
  805.   end
  806.   #--------------------------------------------------------------------------
  807.   # ● 解放
  808.   #--------------------------------------------------------------------------
  809.   def dispose
  810.     super
  811.     end
  812.   end
  813. #==============================================================================
  814. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  815. #==============================================================================
  816. class Air_Text < Window_Base
  817.   #--------------------------------------------------------------------------
  818.   # ● オブジェクト初期化
  819.   #--------------------------------------------------------------------------
  820.   def initialize(x, y, designate_text)
  821.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  822.     self.opacity = 0
  823.     self.back_opacity = 0
  824.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  825.     w = self.contents.width
  826.     h = self.contents.height
  827.     self.contents.draw_text(0, 0, w, h, designate_text)
  828.   end
  829.   #--------------------------------------------------------------------------
  830.   # ● 解放
  831.   #--------------------------------------------------------------------------
  832.   def dispose
  833.     self.contents.clear
  834.     super
  835.   end
  836. end


用的是这个对话框脚本,在有脚本的情况下字体颜色默认成了白色,可是我想实用黑色的默认颜色,已经改了Window_Base的
  1. #--------------------------------------------------------------------------
  2.   # ● 获取普通文字色
  3.   #--------------------------------------------------------------------------
  4.   def normal_color
  5.     return Color.new(0, 0, 0, 255)
  6.   end
复制代码

这一段,在没用脚本的情况下对话文字是黑色的,但是一加入对话框脚本对话的文字颜色又变回去白色,请问我还需要修改哪个地方???

Lv3.寻梦者

梦石
0
星屑
3710
在线时间
1960 小时
注册时间
2013-1-3
帖子
9525
发表于 2019-5-3 09:46:21 | 显示全部楼层
# \c[1-8]:更改颜色
在文本框里输入\c[i]更改颜色,i是数字,在Window_Base里有定义的
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
482
在线时间
67 小时
注册时间
2016-7-21
帖子
12
 楼主| 发表于 2019-5-3 18:58:47 | 显示全部楼层
紫英晓狼1130 发表于 2019-5-3 09:46
# \c[1-8]:更改颜色
在文本框里输入\c更改颜色,i是数字,在Window_Base里有定义的 ...

_(:з」∠)_我知道这样可以改,可是我想要默认就是黑色,不用每次都输入,而且这样输入只能改对话内容,然后出来的名字框还是白色字的
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3710
在线时间
1960 小时
注册时间
2013-1-3
帖子
9525
发表于 2019-5-4 10:31:15 | 显示全部楼层
coco1068 发表于 2019-5-3 18:58
_(:з」∠)_我知道这样可以改,可是我想要默认就是黑色,不用每次都输入,而且这样输入只能改对话内容, ...

在想变色的self.contents.draw_text之前加上self.contents.font.color = Color.new(x,x,x,255)
这样的话我感觉没法说的再详细了……
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
482
在线时间
67 小时
注册时间
2016-7-21
帖子
12
 楼主| 发表于 2019-5-8 02:26:51 | 显示全部楼层
紫英晓狼1130 发表于 2019-5-4 10:31
在想变色的self.contents.draw_text之前加上self.contents.font.color = Color.new(x,x,x,255)
这样的话 ...

Q A Q这个解决了姓名框的颜色了,但是内容默认的颜色还是没找到在哪里改
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 13:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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