查看: 5868|回复: 3

[已经解决] 臉圖使用方式

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

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

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

×
一般使用臉圖使用方式都是 \f[檔名]

想知道裡面的檔名用這兩種方式替代為何失去作用?

設一個變數,值為檔名:    $game_variables[n] = "檔名"

1.  用   \v[n]                                代入 :   \f[\v[n]]
2.  用   #{$game_variables[n]}    代入 :   \f[#{$game_variables[n]}]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2016-4-26 12:24:29 | 显示全部楼层
应该是这个对话脚本没有在得出\v[n]= "檔名"后再算 \f,而是直接\f[\v[n]]

点评

\f不是默认系统的指令,是插件脚本后加的,而\n是。这是两个不同的人写的不同的脚本在同一个对话框中使用  发表于 2016-4-26 19:26
但\n[\v[n]]是可以正常使用,得到角色名稱的  发表于 2016-4-26 16:23
回复

使用道具 举报

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
 楼主| 发表于 2016-4-27 01:12:39 | 显示全部楼层
不管是 \v[] 還是\n[] 等,都在我外加來的腳本重新定義了
我使用的聽說是一個廣為人知和使用的"文字顯示強化"腳本(by   桜雅 在土, 和希, RaTTiE)

涉及 \f[]  的部分是在 77-99行
腳本第77-99行
  1.       # 顔表示指定\Fがあるか?
  2.       if (/\A\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  3.         # ファイルチェック
  4.         if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  5.           # 顔グラを描画
  6.           @face_file = $1 + ".png"
  7.           if @face != nil
  8.             @face.dispose
  9.           end
  10.           @face = Sprite.new
  11.           @face.bitmap = RPG::Cache.picture(@face_file)
  12.           @face.opacity = 255
  13.           @face.x = self.x
  14.           @face.y = self.y + self.height - @face.bitmap.height
  15.           @face.z = 9999
  16.           #@face.zoom_x = 0.5 # 横向縮小为原来的一半
  17.           #@face.zoom_y = 0.5 # 纵向縮小为原来的一半
  18. #          self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  19.           @x = @face_indent = @face.bitmap.width
  20.           # 全行 128ピクセルのインデントを入れる。
  21.         end
  22.         @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  23.       end
复制代码

那這樣我想這裡因為正規表示法的解析,放在\f[]裡的東西我看不太懂  (.+?)
  1. /\A\\[Ff]\[(.+?)\]/.match(@now_text)
复制代码

應該就是(.+?)不知道解讀成什麼了,如果這邊是 \v[n]他不會去使用之後\v[n]的解讀
但上一行我仍不敢確定就是原因了──雖然假如他是,我還是不知道這邊正規表示法該寫什麼
因為之後提到的 $1 看起來簡直是憑空出現的(我全文搜索過,他第一次出現就是在上面單獨抽出來的第4行,整份的第80行)
而它代表的就是檔名,不知道跟上面的正則表達有什麼關係

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

使用道具 举报

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
 楼主| 发表于 2016-4-27 01:55:40 | 显示全部楼层
針對 \v[n] 的解法已解出
將122行對 \v[] 的轉換 往前放到 76行之後就可以順利辨別
本來我看不懂的正則表示  (.+?)  我推測是裡面不管什麼反正他就照吃,重要的是後面的  .match(@now_text)
122行對\v[]的轉換在78行之後,所以她啥都不知道大概是正常的

但我自己對於(.+?)為何這樣就匹配的上還是感到奇怪拉
假設現在設定長這樣: \f[\v[n]],\v[n] = "test"
(/+?) 我覺得這時應該是 \v[n],而match裡的@now_text已經解析為 test,還是不匹配呀?
  1. if (/\A\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
复制代码
我看起來他也沒有要他們相等的意思,只是想知道他不是nil就往後執行,但理論上這回傳的不是 true就是false吧?於是一定會進去if裡
然後就碰上了我百思不得其解的 $1部分

雖然其中一個解了並且最主要是我想要的東西可以做出來了,但這個解裡面又有好多問題
以及#{$game_variables[n]} 還是無解
希望可以知道得明白點比較安心

点评

決定先結帖,大概有興趣的大大有機會會往下解答的(?)  发表于 2016-4-28 01:55
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部