查看: 2445|回复: 5

[已经解决] 如何改變Window_Message字的顏色

[复制链接]
梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
发表于 2016-5-31 23:34:03 | 显示全部楼层 |阅读模式

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

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

×
我想使所有的文字都是黑色,希望可以不透過每一個對話自加\c[]的方式來改
參考過 怎么更改标题画面以及菜单栏的字体颜色?
裡面提供了這樣的作法
自定義腳本
  1. class Window_Title < Window_Command
  2.   def normal_color
  3.     return Color.new(255, 255, 64, 255)#这里更改成你想要的颜色
  4.   end
  5. end
复制代码

在改換Title和存讀檔的字體顏色上我都成功更換了,只有遊戲裡的文字顯示我怎麼改都改不了

我想這個應該是關於Window_Message,所以我自定義一個 class Window_Msg < Window_Message 內容同上的東西
去Scene_Map把Window_Message換成Window_Msg,無效
所以我又嘗試去Window_Base改def normal_color制定的顏色
為了以防萬一,Window_Message裡的 self.contents.font.color = normal_color 我也改成了 self.contents.font.color = Color.new(0, 0, 0, 255)
我外掛的"文字顯示強化"也做了關於normal_color的改動

全局搜索過 "normal"和"Message"兩個關鍵字看過,沒有發現我認為會影響的地方有漏掉
所以想請問到底應該要改些什麼?

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
1788
在线时间
1313 小时
注册时间
2012-8-4
回帖
724
发表于 2016-6-1 14:56:33 | 显示全部楼层
#--------------------------------------------------------------------------
  # ● 获取文字色
  #     n : 文字色编号 (0~7)
  #--------------------------------------------------------------------------
  def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      normal_color
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取普通文字色
  #--------------------------------------------------------------------------
  def normal_color
    return Color.new(255, 255, 255, 255)
  end

点评

這是Window_Base裡對 normal_color的定義嗎?如果是那我已經嘗試過,無效。  发表于 2016-6-1 21:27
回复

使用道具 举报

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
 楼主| 发表于 2016-6-7 22:32:15 | 显示全部楼层
過了一個禮拜感覺可以再自頂一次0a0
回复

使用道具 举报

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-6-8 14:05:59 | 显示全部楼层
本帖最后由 cinderelmini 于 2016-6-9 13:57 编辑
  1. def normal_color; return Color.new(0, 0, 0); end
复制代码
这行放在【Window_Message】里面最后一个end之前任一空行。

请在默认工程里尝试,如果使用了其他相关的外挂脚本,最好提供相关内容,
默认工程里这样是没问题的,其他的窝是不知道了……
顺便放个饭粒: 对话框文字颜色.zip (201.15 KB, 下载次数: 53)

点评

默认工程并没有问题~  发表于 2016-6-9 13:58
還是沒有效果。無關乎 ; 的原因(這個腳本語言似乎不需要;)  发表于 2016-6-9 02:04

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
 楼主| 发表于 2016-6-9 21:25:41 | 显示全部楼层
本帖最后由 燕征 于 2016-6-9 21:30 编辑

應該確實是我外掛的"文字顯示強化"腳本影響的。

之前已經試著把裡面refresh用到normal_color的地方換成了Color.new(0, 0, 0, 255)
後面也有試著把
  1. def normal_color; return Color.new(0, 0, 0); end
复制代码
放進去,但是死活沒有反應
我看大大的範本確實是可以的,然後把用到的這個外掛放下去就打回原形

"文字顯示強化"連同變動以放入附上的工程中,下面另收外掛腳本
def normal_color; return Color.new(0, 0, 0); end在 line 8
refresh用到的self.contents.font.color = normal_color以註解方式在 line 57
改為self.contents.font.color = Color.new(0, 0, 0, 255)在line 58

文字顯示強化
  1. # ▼▲▼ XRXS 9. メッセージ表示フルグレードアップ ver..11 ▼▲▼
  2. # by 桜雅 在土, 和希, RaTTiE
  3. #==============================================================================
  4. # ■ Window_Message
  5. #==============================================================================
  6. class Window_Message < Window_Selectable
  7.   
  8.   def normal_color; return Color.new(0, 0, 0); end
  9.   
  10.   # 一文字ずつ描写
  11.   DEFAULT_TYPING_ENABLE = true                # falseにすると瞬間表示
  12.   #--------------------------------------------------------------------------
  13.   # ● オブジェクト初期化
  14.   #--------------------------------------------------------------------------
  15.   alias xrxs9_initialize initialize
  16.   def initialize
  17.     xrxs9_initialize
  18.     # 再生サウンド名がない場合は""とする
  19.     if $soundname_on_speak == nil then
  20.       $soundname_on_speak = ""
  21.     end
  22.     # 外字ファイルパス設定
  23.     $gaiji_file = "./Graphics/Gaiji/sample.png"
  24.     # 外字データ読み込み
  25.     if FileTest.exist?($gaiji_file)
  26.       @gaiji_cache = Bitmap.new($gaiji_file)
  27.     else
  28.       @gaigi_cache = nil
  29.     end
  30.     # 文字透過転送用バッファ
  31.     @opacity_text_buf = Bitmap.new(32, 32)
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● メッセージ終了処理
  35.   #--------------------------------------------------------------------------
  36.   alias xrxs9_terminate_message terminate_message
  37.   def terminate_message
  38.     if @name_window_frame != nil
  39.       @name_window_frame.dispose
  40.       @name_window_frame = nil
  41.     end
  42.     if @name_window_text  != nil
  43.       @name_window_text.dispose
  44.       @name_window_text  = nil
  45.     end
  46.     if @face != nil
  47.       @face.dispose
  48.     end
  49.     xrxs9_terminate_message
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● リフレッシュ
  53.   #--------------------------------------------------------------------------
  54.   def refresh
  55.     # 初期化
  56.     self.contents.clear
  57.     #self.contents.font.color = normal_color
  58.     self.contents.font.color = Color.new(0, 0, 0, 255)
  59.     self.contents.font.size  = Font.default_size
  60.     @x = @y = @max_x = @max_y = @indent = @lines = 0
  61.     @face_indent = 0
  62.     @opacity = 255
  63.     @cursor_width = 0
  64.     @write_speed = 0
  65.     @write_wait = 0
  66.     @mid_stop = false
  67.     @face_file = nil
  68.     if @face != nil
  69.       @face.dispose
  70.     end
  71.     # @popchar が -2 の場合、標準位置。-1の場合、文字センター。
  72.     # 0以上の場合 キャラポップ。0は主人公、1以降はイベント。
  73.     @popchar = -2
  74.     # 選択肢なら字下げを行う
  75.     if $game_temp.choice_start == 0
  76.       @x = 8
  77.     end
  78.     # 表示待ちのメッセージがある場合
  79.     if $game_temp.message_text != nil
  80.       @now_text = $game_temp.message_text
  81.       
  82.       # \Vを独自ルーチンに変更(追加部分)
  83.       @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  84.       
  85.       # 顔表示指定\Fがあるか?
  86.       if (/\A\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  87.         # ファイルチェック
  88.         if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  89.           # 顔グラを描画
  90.           @face_file = $1 + ".png"
  91.           if @face != nil
  92.             @face.dispose
  93.           end
  94.           @face = Sprite.new
  95.           @face.bitmap = RPG::Cache.picture(@face_file)
  96.           @face.opacity = 255
  97.           @face.x = self.x
  98.           @face.y = self.y + self.height - @face.bitmap.height
  99.           @face.z = 9999
  100.           #@face.zoom_x = 0.5 # 横向縮小为原来的一半
  101.           #@face.zoom_y = 0.5 # 纵向縮小为原来的一半
  102. #          self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  103.           @x = @face_indent = @face.bitmap.width
  104.           # 全行 128ピクセルのインデントを入れる。
  105.         end
  106.         @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  107.       end
  108.       # \nameがあるか?
  109.       name_window_set = false
  110.       if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  111.         # 値を設定
  112.         name_window_set = true
  113.         name_text = $1
  114.         # \name[]部分を削除
  115.         @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  116.       end
  117.       # ウィンドウ位置判定
  118.       if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  119.         @popchar = $1.to_i
  120.         if @popchar == -1
  121.           @x = @indent = 48
  122.           @y = 4
  123.         end
  124.         @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  125.       end
  126.       # 制御文字処理
  127.       begin
  128.       last_text = @now_text.clone
  129.       # \Vを独自ルーチンに変更(追加部分)
  130.       #@now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  131.       end until @now_text == last_text
  132.       @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  133.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  134.       end
  135.       # 便宜上、"\\\" を "\000" に変換
  136.       @now_text.gsub!(/\\\\/) { "\000" }
  137.       # "\\C" を "\001" に、"\\G" を "\002" に、
  138.       # "\\S" を "\003" に、"\\A" を "\004" に変換
  139.       @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  140.       @now_text.gsub!(/\\[Gg]/) { "\002" }
  141.       @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  142.       @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  143.       @now_text.gsub!(/\\[.]/) { "\005" }
  144.       @now_text.gsub!(/\\[|]/) { "\006" }
  145.       # 競合すると何かと気まずいので、\016以降を使用する
  146.       @now_text.gsub!(/\\[>]/) { "\016" }
  147.       @now_text.gsub!(/\\[<]/) { "\017" }
  148.       @now_text.gsub!(/\\[!]/) { "\020" }
  149.       @now_text.gsub!(/\\[~]/) { "\021" }
  150.       @now_text.gsub!(/\\[Ee]\[([0-9]+)\]/) { "\022[#{$1}]" }
  151.       # インデント設定(追加部分)
  152.       @now_text.gsub!(/\\[Ii]/) { "\023" }
  153.       # テキスト透過率指定(追加部分)
  154.       @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  155.       # テキストサイズ指定(追加部分)
  156.       @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  157.       # 空白挿入(追加部分)
  158.       @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  159.       # ルビ表示(追加部分)
  160.       @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "\027[#{$1}]" }
  161.       if @popchar >= 0
  162.         @text_save = @now_text.clone
  163.         @max_x = 0
  164.         @max_y = 4
  165.         for i in 0..3
  166.           line = @now_text.split(/\n/)[3-i]
  167.           @max_y -= 1 if line == nil and @max_y <= 4-i
  168.           next if line == nil
  169.           cx = contents.text_size(line).width
  170.           @max_x = cx if cx > @max_x
  171.         end
  172.         self.width = @max_x + 48 + @face_indent
  173.         self.height = (@max_y - 1) * 32 + 64
  174.       else
  175.         @max_x = self.width - 32 - @face_indent
  176.       end
  177.       # ここで一旦ウィンドウ位置更新
  178.       reset_window
  179.       # \nameがあるか?
  180.       if name_window_set
  181.         # オフセット位置
  182.         off_x =  0
  183.         off_y =  0
  184.         # 枠だけウィンドウの作成(余白を 2 に設定)
  185.         space = 2
  186.         x = self.x + off_x - space / 2
  187.         y = self.y + off_y - space / 2
  188.         w = self.contents.text_size(name_text).width + 8 + space
  189.         h = 26 + space
  190.         @name_window_frame = Window_Frame.new(x, y, w, h)
  191.         @name_window_frame.z = self.z + 1
  192.         # 擬似的な空中文字描写ウィンドウを作成
  193.         x = self.x + off_x + 4
  194.         y = self.y + off_y
  195.         @name_window_text  = Air_Text.new(x, y, name_text)
  196.         @name_window_text.z = self.z + 2
  197.       end
  198.     end
  199.     # ウィンドウを更新
  200.     reset_window
  201.     # 選択肢の場合
  202.     if $game_temp.choice_max > 0
  203.       @item_max = $game_temp.choice_max
  204.       self.active = true
  205.       self.index = 0
  206.     end
  207.     # 数値入力の場合
  208.     if $game_temp.num_input_variable_id > 0
  209.       digits_max = $game_temp.num_input_digits_max
  210.       number = $game_variables[$game_temp.num_input_variable_id]
  211.       @input_number_window = Window_InputNumber.new(digits_max)
  212.       @input_number_window.number = number
  213.       @input_number_window.x = self.x + 8
  214.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● フレーム更新
  219.   #--------------------------------------------------------------------------
  220.   def update
  221.     super
  222.     # フェードインの場合
  223.     if @fade_in
  224.       self.contents_opacity += 24
  225.       if @input_number_window != nil
  226.         @input_number_window.contents_opacity += 24
  227.       end
  228.       if self.contents_opacity == 255
  229.         @fade_in = false
  230.       end
  231.       return
  232.     end
  233.     @now_text = nil if @now_text == "" # 変換
  234.     # 表示待ちのメッセージがある場合
  235.     if @now_text != nil and @mid_stop == false
  236.       if @write_wait > 0
  237.         @write_wait -= 1
  238.         return
  239.       end
  240.       text_not_skip = DEFAULT_TYPING_ENABLE
  241.       while true
  242.         # 最大 x y の保存。
  243.         @max_x = @x if @max_x < @x
  244.         @max_y = @y if @max_y < @y
  245.         # c に 1 文字を取得 (文字が取得できなくなるまでループ)
  246.         if (c = @now_text.slice!(/./m)) != nil
  247.           # \\ の場合
  248.           if c == "\000"
  249.             # 本来の文字に戻す
  250.             c = "\"
  251.           end
  252.           # \C[n] の場合
  253.           if c == "\001"
  254.             # 文字色を変更
  255.             @now_text.sub!(/\[([0-9]+)\]/, "")
  256.             color = $1.to_i
  257.             if color >= 0 and color <= 7
  258.               self.contents.font.color = text_color(color)
  259.             end
  260.             # 次の文字へ
  261.             c = ""
  262.           end
  263.           # \G の場合
  264.           if c == "\002"
  265.             # ゴールドウィンドウを作成
  266.             if @gold_window == nil and @popchar <= 0
  267.               @gold_window = Window_Gold.new
  268.               @gold_window.x = 560 - @gold_window.width
  269.               if $game_temp.in_battle
  270.                 @gold_window.y = 192
  271.               else
  272.                 @gold_window.y = self.y >= 128 ? 32 : 384
  273.               end
  274.               @gold_window.opacity = self.opacity
  275.               @gold_window.back_opacity = self.back_opacity
  276.             end
  277.             # 次の文字へ
  278.             c = ""
  279.           end
  280.           # \S[n] の場合
  281.           if c == "\003"
  282.             # 文字色を変更
  283.             @now_text.sub!(/\[([0-9]+)\]/, "")
  284.             speed = $1.to_i
  285.             if speed >= 0 and speed <= 19
  286.               @write_speed = speed
  287.             end
  288.             # 次の文字へ
  289.             c = ""
  290.           end
  291.           # \A[soundname] の場合
  292.           if c == "\004"
  293.             # 再生ファイルを変更するための準備
  294.             @now_text.sub!(/\[(.*?)\]/, "")
  295.             buftxt = $1.dup.to_s
  296.             # 再生ファイル名に"/"があるか?
  297.             if buftxt.match(/\//) == nil and buftxt != "" then
  298.               # なければ"Audio/SE/"を結合する
  299.               $soundname_on_speak = "Audio/SE/" + buftxt
  300.             else
  301.               # あればそのままコピー
  302.               $soundname_on_speak = buftxt.dup
  303.             end
  304.             # 次の文字へ
  305.             c = ""
  306.           elsif c == "\004"
  307.             # 次の文字へ
  308.             c = ""
  309.           end
  310.           # \. の場合
  311.           if c == "\005"
  312.             @write_wait += 5
  313.             c = ""
  314.           end
  315.           # \| の場合
  316.           if c == "\006"
  317.             @write_wait += 20
  318.             c = ""
  319.           end
  320.           # \> の場合
  321.           if c == "\016"
  322.             text_not_skip = false
  323.             c = ""
  324.           end
  325.           # \<の場合
  326.           if c == "\017"
  327.             text_not_skip = true
  328.             c = ""
  329.           end
  330.           # \!の場合
  331.           if c == "\020"
  332.             @mid_stop = true
  333.             c = ""
  334.           end
  335.           # \~の場合
  336.           if c == "\021"
  337.             terminate_message
  338.             return
  339.           end
  340.           # \Iの場合(追加部分)
  341.           if c == "\023"
  342.             # 今の@xをインデント位置に設定
  343.             @indent = @x
  344.             c = ""
  345.           end
  346.           # \Oの場合(追加部分)
  347.           if c == "\024"
  348.             @now_text.sub!(/\[([0-9]+)\]/, "")
  349.             @opacity = $1.to_i
  350.             c = ""
  351.           end
  352.           # \Hの場合(追加部分)
  353.           if c == "\025"
  354.             @now_text.sub!(/\[([0-9]+)\]/, "")
  355.             self.contents.font.size = [[$1.to_i, 6].max, 32].min
  356.             c = ""
  357.           end
  358.           # \Bの場合(追加部分)
  359.           if c == "\026"
  360.             @now_text.sub!(/\[([0-9]+)\]/, "")
  361.             @x += $1.to_i
  362.             c = ""
  363.           end
  364.           # \Rの場合(追加部分)
  365.           if c == "\027"
  366.             @now_text.sub!(/\[(.*?)\]/, "")
  367.             # 文字を描画
  368.             @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  369.             # 文字描写のSEを演奏
  370.             if $soundname_on_speak != ""
  371.               Audio.se_play($soundname_on_speak)
  372.             end
  373.             c = ""
  374.           end
  375.           # アイコン描画用シーケンスの場合(追加部分)
  376.           if c == "\030"
  377.             # アイコンファイル名を取得
  378.             @now_text.sub!(/\[(.*?)\]/, "")
  379.             # アイコンを描画
  380.             self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  381.             # 文字描写のSEを演奏
  382.             if $soundname_on_speak != ""
  383.               Audio.se_play($soundname_on_speak)
  384.             end
  385.             @x += 24
  386.             # 次の文字へ
  387.             c = ""
  388.           end
  389.           # 改行文字の場合
  390.           if c == "\n"
  391.             # 選択肢ならカーソルの幅を更新
  392.             if @lines >= $game_temp.choice_start
  393.               @cursor_width = [@cursor_width, @max_x - @face_indent].max
  394.             end
  395.             # y に 1 を加算
  396.             @lines += 1
  397.             @y += 1
  398.             @x = 0 + @indent + @face_indent
  399.             # 選択肢なら字下げを行う
  400.             if @lines >= $game_temp.choice_start
  401.               @x = 8 + @indent + @face_indent
  402.             end
  403.             # 次の文字へ
  404.             c = ""
  405.           end
  406.           # 外字表示の場合
  407.           if c == "\022"
  408.             # []部分の除去
  409.             @now_text.sub!(/\[([0-9]+)\]/, "")
  410.             # 外字を表示
  411.             @x += gaiji_draw(4 + @x, @y * line_height + (line_height - self.contents.font.size), $1.to_i)
  412.             # 次の文字へ
  413.             c = ""
  414.           end
  415.           if c != ""
  416.             # 文字を描画
  417.             @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  418.             # 文字描写のSEを演奏
  419.             if $soundname_on_speak != "" then
  420.               Audio.se_play($soundname_on_speak)
  421.             end
  422.           end
  423.           # Bボタンが押された場合
  424.           if Input.press?(Input::B)
  425.             text_not_skip = false
  426.           end
  427.         else
  428.           text_not_skip = true
  429.           break
  430.         end
  431.         # 終了判定
  432.         if text_not_skip
  433.           break
  434.         end
  435.       end
  436.       @write_wait += @write_speed
  437.       return
  438.     end
  439.     # 数値入力中の場合
  440.     if @input_number_window != nil
  441.       @input_number_window.update
  442.       # 決定
  443.       if Input.trigger?(Input::C)
  444.         $game_system.se_play($data_system.decision_se)
  445.         $game_variables[$game_temp.num_input_variable_id] =
  446.           @input_number_window.number
  447.         $game_map.need_refresh = true
  448.         # 数値入力ウィンドウを解放
  449.         @input_number_window.dispose
  450.         @input_number_window = nil
  451.         terminate_message
  452.       end
  453.       return
  454.     end
  455.     # メッセージ表示中の場合
  456.     if @contents_showing
  457.       # 選択肢の表示中でなければポーズサインを表示
  458.       if $game_temp.choice_max == 0
  459.         self.pause = true
  460.       end
  461.       # キャンセル
  462.       if Input.trigger?(Input::B)
  463.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  464.           $game_system.se_play($data_system.cancel_se)
  465.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  466.           terminate_message
  467.         end
  468.       end
  469.       # 決定
  470.       if Input.trigger?(Input::C)
  471.         if $game_temp.choice_max > 0
  472.           $game_system.se_play($data_system.decision_se)
  473.           $game_temp.choice_proc.call(self.index)
  474.         end
  475.         if @mid_stop
  476.           @mid_stop = false
  477.           return
  478.         else
  479.           terminate_message
  480.         end
  481.       end
  482.       return
  483.     end
  484.     # フェードアウト中以外で表示待ちのメッセージか選択肢がある場合
  485.     if @fade_out == false and $game_temp.message_text != nil
  486.       @contents_showing = true
  487.       $game_temp.message_window_showing = true
  488.       refresh
  489.       Graphics.frame_reset
  490.       self.visible = true
  491.       self.contents_opacity = 0
  492.       if @input_number_window != nil
  493.         @input_number_window.contents_opacity = 0
  494.       end
  495.       @fade_in = true
  496.       return
  497.     end
  498.     # 表示すべきメッセージがないが、ウィンドウが可視状態の場合
  499.     if self.visible
  500.       @fade_out = true
  501.       self.opacity -= 48
  502.       if self.opacity == 0
  503.         self.visible = false
  504.         @fade_out = false
  505.         $game_temp.message_window_showing = false
  506.       end
  507.       return
  508.     end
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● キャラクターの取得
  512.   #     parameter : パラメータ
  513.   #--------------------------------------------------------------------------
  514.   def get_character(parameter)
  515.     # パラメータで分岐
  516.     case parameter
  517.     when 0  # プレイヤー
  518.       return $game_player
  519.     else  # 特定のイベント
  520.       events = $game_map.events
  521.       return events == nil ? nil : events[parameter]
  522.     end
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● ウィンドウの位置と不透明度の設定
  526.   #--------------------------------------------------------------------------
  527.   def reset_window
  528.     # 判定
  529.     if @popchar >= 0
  530.       events = $game_map.events
  531.       if events != nil
  532.         character = get_character(@popchar)
  533.         x = [[character.screen_x -  0 - self.width / 2, 4].max, 636 - self.width].min
  534.         y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  535.         self.x = x
  536.         self.y = y
  537.       end
  538.     elsif @popchar == -1
  539.       self.x = -4
  540.       self.y = -4
  541.       self.width = 648
  542.       self.height = 488
  543.     else
  544.       if $game_temp.in_battle
  545.         self.y = 16
  546.       else
  547.         case $game_system.message_position
  548.         when 0  # 上
  549.           self.y = 16
  550.         when 1  # 中
  551.           self.y = 160
  552.         when 2  # 下
  553.           self.y = 304
  554.         end
  555.         self.x = 80
  556.         if @face_file == nil
  557.           self.width = 480
  558.         else
  559.           self.width = 600
  560.           self.x -= 60
  561.         end
  562.         self.height = 160
  563.       end
  564.     end
  565.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  566.     if @face_file != nil
  567.       if @face != nil
  568.         @face.dispose
  569.       end
  570.           @face = Sprite.new
  571.           @face.bitmap = RPG::Cache.picture(@face_file)
  572.           @face.opacity = 255
  573.           @face.x = self.x
  574.           @face.y = self.y + self.height - @face.bitmap.height
  575.           @face.z = 9999
  576.           #@face.zoom_x = 0.5
  577.           #@face.zoom_y = 0.5
  578.     #  self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  579.     end
  580.     if @popchar == -1
  581.       self.opacity = 255
  582.       self.back_opacity = 0
  583.     elsif $game_system.message_frame == 0
  584.       self.opacity = 255
  585.       self.back_opacity = 160
  586.     else
  587.       self.opacity = 0
  588.       self.back_opacity = 160
  589.     end
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ● 外字描画
  593.   #--------------------------------------------------------------------------
  594.   # x   :x座標
  595.   # y   :y座標
  596.   # num  :外字番号
  597.   # 返り値:外字幅(@x増加値)
  598.   #--------------------------------------------------------------------------
  599.   def gaiji_draw(x, y, num)
  600.     # 外字データが存在しない場合は何もしない
  601.     if @gaiji_cache == nil
  602.       return 0
  603.     else
  604.       # 指定した外字がキャッシュ範囲を超えている場合は何もしない
  605.       if @gaiji_cache.width < num * 24
  606.         return 0
  607.       end
  608.       # 文字サイズを計算
  609.       if self.contents.font.size >= 20 and self.contents.font.size <= 24
  610.         size = 24
  611.       else
  612.         size = self.contents.font.size * 100 * 24 / 2200
  613.       end
  614.       # 外字データをstretch_bltで転送
  615.       self.contents.stretch_blt(Rect.new(x, y, size, size), @gaiji_cache, Rect.new(num * 24, 0, 24, 24))
  616.       # 文字描写のSEを演奏
  617.       if $soundname_on_speak != "" then
  618.         Audio.se_play($soundname_on_speak)
  619.       end
  620.       # 文字サイズを返す
  621.       return size
  622.     end
  623.   end
  624.   #--------------------------------------------------------------------------
  625.   # ● line_height
  626.   #--------------------------------------------------------------------------
  627.   # 返り値:行の高さ(@y増加値)を返します。
  628.   #--------------------------------------------------------------------------
  629.   def line_height
  630.     # 現状、選択肢等に対応ができない為、自動的に32を返します。
  631.     return 32
  632.     # 文字サイズを計算
  633.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  634.       return 32
  635.     else
  636.       return self.contents.font.size * 15 / 10
  637.     end
  638.   end
  639.   #--------------------------------------------------------------------------
  640.   # ● 透過文字描画
  641.   #--------------------------------------------------------------------------
  642.   # target :描画対象。Bitmapクラスを指定。
  643.   # x      :x座標
  644.   # y      :y座標
  645.   # str   :描画文字列
  646.   # opacity:透過率(0~255)
  647.   # 返り値 :文字幅(@x増加値)。
  648.   #--------------------------------------------------------------------------
  649.   def opacity_draw_text(target, x, y, str,opacity)
  650.     # heightとwidthを計算
  651.     height = target.font.size
  652.     width = target.text_size(str).width
  653.     # opacityに規定値以上の値が入っている場合は修正。
  654.     opacity = [[opacity, 0].max, 255].min
  655.     # opacityが255(透過なし)の場合は通常描画
  656.     if opacity == 255
  657.       target.draw_text(x, y, width, height, str)
  658.       return width
  659.     else
  660.       # 表示テキストのheight、widthがバッファサイズを上回る場合は
  661.       # バッファを再生成する。
  662.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  663.         @opacity_text_buf.dispose
  664.         @opacity_text_buf = Bitmap.new(width, height)
  665.       # そうでない場合はバッファクリア。
  666.       else
  667.         @opacity_text_buf.clear
  668.       end
  669.       # バッファに現在の文字サイズを反映
  670.       @opacity_text_buf.font.size = target.font.size
  671.       # バッファにテキスト描画
  672.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  673.       # バッファデータをtargetに転送
  674.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  675.       # 文字サイズを返す
  676.       return width
  677.     end
  678.   end
  679.   #--------------------------------------------------------------------------
  680.   # ● ルビ文字描画
  681.   #--------------------------------------------------------------------------
  682.   # target :描画対象。Bitmapクラスを指定。
  683.   # x      :x座標
  684.   # y      :y座標
  685.   # str   :描画文字列。本文,ルビの形式で入力。
  686.   #      ,区切りが2つ以上あった場合は自動的に無視される。
  687.   # opacity:透過率(0~255)
  688.   # 返り値 :文字幅(@x増加値)。
  689.   #--------------------------------------------------------------------------
  690.   def ruby_draw_text(target, x, y, str,opacity)
  691.     # フォントサイズをバックアップしておく
  692.     sizeback = target.font.size
  693.     # ルビサイズの計算
  694.     target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  695.     rubysize = [rubysize, 6].max
  696.    
  697.     # opacityに規定値以上の値が入っている場合は修正。
  698.     opacity = [[opacity, 0].max, 255].min
  699.     # strをsplitで分割し、split_sに格納
  700.     split_s = str.split(/,/)
  701.     # split_sがnilの場合は""にしておく(誤動作防止)
  702.     split_s[0] == nil ? split_s[0] = "" : nil
  703.     split_s[1] == nil ? split_s[1] = "" : nil
  704.     # heightとwidthを計算
  705.     height = sizeback + rubysize
  706.     width  = target.text_size(split_s[0]).width
  707.     # バッファ用の幅計算(ルビの幅が本文の幅を越える可能性がある為)
  708.     target.font.size = rubysize
  709.     ruby_width = target.text_size(split_s[1]).width
  710.     target.font.size = sizeback
  711.     buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  712.     # 本文の描画幅とルビの描画幅の差を1/2にして変数に格納(後で使用)
  713.     width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  714.     # opacityが255(透過なし)の場合は通常描画
  715.     if opacity == 255
  716.     # ルビの描画
  717.       target.font.size = rubysize
  718.       target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  719.       target.font.size = sizeback
  720.     # 本文の描画
  721.       target.draw_text(x, y, width, target.font.size, split_s[0])
  722.       return width
  723.     else
  724.       # 表示テキストのheight、widthがバッファサイズを上回る場合は
  725.       # バッファを再生成する。
  726.       if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  727.         @opacity_text_buf.dispose
  728.         @opacity_text_buf = Bitmap.new(buf_width, height)
  729.       # そうでない場合はバッファクリア。
  730.       else
  731.         @opacity_text_buf.clear
  732.       end
  733.       # バッファにテキスト描画
  734.       # ルビの描画
  735.       @opacity_text_buf.font.size = rubysize
  736.       @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  737.       @opacity_text_buf.font.size = sizeback
  738.       # 本文の描画
  739.       @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  740.       # ルビの幅が本文の幅を下回る場合
  741.       if sub_x >= 0
  742.         target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  743.       # ルビの幅が本文の幅を上回る場合
  744.       else
  745.         target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  746.       end
  747.       # 文字サイズを返す
  748.       return width
  749.     end
  750.   end
  751.   #--------------------------------------------------------------------------
  752.   # ● \V変換
  753.   #--------------------------------------------------------------------------
  754.   # option :オプション。無指定又は規定外の場合はindexのユーザ変数値を返す。
  755.   # index  :インデックス
  756.   # 返り値 :変換結果(アイコン表示用シーケンス込み)
  757.   #--------------------------------------------------------------------------
  758.   def convart_value(option, index)
  759.     # optionがnilの場合は""に直す(誤動作防止)
  760.     option == nil ? option = "" : nil
  761.     # optionはdowncaseしておく。
  762.     option.downcase!
  763.     # \030はアイコン表示用のシーケンス。\030[アイコンファイル名]で定義。
  764.     case option
  765.     when "i"
  766.       unless $data_items[index].name == nil
  767.         r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  768.       end
  769.     when "w"
  770.       unless $data_weapons[index].name == nil
  771.         r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  772.       end
  773.     when "a"
  774.       unless $data_armors[index].name == nil
  775.         r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  776.       end
  777.     when "s"
  778.       unless $data_skills[index].name == nil
  779.         r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  780.       end
  781.     else
  782.       r = $game_variables[index]
  783.     end
  784.     r == nil ? r = "" : nil
  785.     return r
  786.   end
  787.   #--------------------------------------------------------------------------
  788.   # ● 解放
  789.   #--------------------------------------------------------------------------
  790.   def dispose
  791.     terminate_message
  792.     # 外字キャッシュ開放
  793.     if @gaiji_cache != nil
  794.       unless @gaiji_cache.disposed?
  795.         @gaiji_cache.dispose
  796.       end
  797.     end
  798.     # 文字透過転送用バッファ開放
  799.     unless @opacity_text_buf.disposed?
  800.       @opacity_text_buf.dispose
  801.     end
  802.     $game_temp.message_window_showing = false
  803.     if @input_number_window != nil
  804.       @input_number_window.dispose
  805.     end
  806.     super
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # ● カーソルの矩形更新
  810.   #--------------------------------------------------------------------------
  811.   def update_cursor_rect
  812.     if @index >= 0
  813.       n = $game_temp.choice_start + @index
  814.       self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  815.     else
  816.       self.cursor_rect.empty
  817.     end
  818.   end
  819. end
  820. #==============================================================================
  821. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  822. #==============================================================================
  823. class Window_Frame < Window_Base
  824.   #--------------------------------------------------------------------------
  825.   # ● オブジェクト初期化
  826.   #--------------------------------------------------------------------------
  827.   def initialize(x, y, width, height)
  828.     super(x, y, width, height)
  829.     self.contents = nil
  830.     self.back_opacity = 160
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   # ● 解放
  834.   #--------------------------------------------------------------------------
  835.   def dispose
  836.     super
  837.   end
  838. end
  839. #==============================================================================
  840. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  841. #==============================================================================
  842. class Air_Text < Window_Base
  843.   #--------------------------------------------------------------------------
  844.   # ● オブジェクト初期化
  845.   #--------------------------------------------------------------------------
  846.   def initialize(x, y, designate_text)
  847.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  848.     self.opacity      = 0
  849.     self.back_opacity = 0
  850.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  851.     w = self.contents.width
  852.     h = self.contents.height
  853.     self.contents.draw_text(0, 0, w, h, designate_text)
  854.   end
  855.   #--------------------------------------------------------------------------
  856.   # ● 解放
  857.   #--------------------------------------------------------------------------
  858.   def dispose
  859.     self.contents.clear
  860.     super
  861.   end
  862. end
复制代码

對話框文字顏色.rar

196.47 KB, 下载次数: 43

回复

使用道具 举报

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-6-10 15:04:44 | 显示全部楼层
本帖最后由 cinderelmini 于 2016-6-12 15:13 编辑
燕征 发表于 2016-6-9 21:25
應該確實是我外掛的"文字顯示強化"腳本影響的。

之前已經試著把裡面refresh用到normal_color的地方換成了C ...


把重定义normal_color那句放进Window_Message类之后,
文字绘制强化脚本其他地方不用改,只改下面这个方法:
点击展开/收起
  1.   #--------------------------------------------------------------------------
  2.   # ● 透過文字描画
  3.   #--------------------------------------------------------------------------
  4.   # target :描画対象。Bitmapクラスを指定。
  5.   # x      :x座標
  6.   # y      :y座標
  7.   # str   :描画文字列
  8.   # opacity:透過率(0~255)
  9.   # 返り値 :文字幅(@x増加値)。
  10.   #--------------------------------------------------------------------------
  11.   def opacity_draw_text(target, x, y, str,opacity)
  12.     # heightとwidthを計算
  13.     target.font.color = normal_color  # 文字颜色
  14.     height = target.font.size
  15.     width = target.text_size(str).width
  16.     # opacityに規定値以上の値が入っている場合は修正。
  17.     opacity = [[opacity, 0].max, 255].min
  18.     # opacityが255(透過なし)の場合は通常描画
  19.     if opacity == 255
  20.       target.draw_text(x, y, width, height, str)
  21.       return width
  22.     else
  23.       # 表示テキストのheight、widthがバッファサイズを上回る場合は
  24.       # バッファを再生成する。
  25.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  26.         @opacity_text_buf.dispose
  27.         @opacity_text_buf = Bitmap.new(width, height)
  28.       # そうでない場合はバッファクリア。
  29.       else
  30.         @opacity_text_buf.clear
  31.       end
  32.       # バッファに現在の文字サイズを反映
  33.       @opacity_text_buf.font.size = target.font.size
  34.       @opacity_text_buf.font.color = target.font.color  # 文字颜色
  35.       # バッファにテキスト描画
  36.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  37.       # バッファデータをtargetに転送
  38.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  39.       # 文字サイズを返す
  40.       return width
  41.     end
  42.   end
复制代码

给上面这个方法加了两处文字颜色改变(行末有备注)

分割线


或者你可以在【文字顯示強化】里面的【reset_window】方法里找到:
  1. self.contents = Bitmap.new(self.width - 32, self.height - 32)
复制代码
然后在它下面加上:
  1. self.contents.font.color = normal_color
复制代码
因为这个窗口里的Bitmap实例对象self.contents在这里被重建了,
然后这个Bitmap里的Font的所有属性都是新的(也就是默认的,color是Color.new(255, 255, 255, 255)),
而这个方法在refresh方法内部使用,
且refresh设定Font字号和颜色的句子在方法开头,而reset_window在这之后,
所以导致前面设定的Font属性是无效的。

点评

了解!謝謝大大解說!  发表于 2016-6-12 18:25
见本楼分割线以下的部分。  发表于 2016-6-12 15:16
color提到的The default is (255,255,255,255).?但為何他不是直接使用繼承自Window_Message的normal_color而要特別再設定target的color?  发表于 2016-6-12 01:31
工程里按F1,点【索引】页,列表里找到【Font】打开,内容页里往下滚动,找到【color】说明……  发表于 2016-6-11 15:26
謝謝大大,這樣已經可以達成需求了。但想細問為何還要特別指定target顏色?原來不只定的話他難道就不是用默認的normal_color嗎?  发表于 2016-6-11 14:22
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部