- =begin 
- 吹きだしウィンドウVXAce 
-   
- 2011.12.25 tamura改造 
- 2012年02月28日 改訂 
-   
- ※このスクリプトは、ちいさな本屋様([url]http://xrxs.at-ninja.jp/[/url]) 
- が製作されたものをtamuraがACE用に改造した物です。 
-   
- 原版: 
-  ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽ 
-  publish 2010/ 3/ 2 
-  update  - 11/ 1/10a 
-   
-   
- ※※警告※※ 
- 「立ち絵機能」をONにしている時に、立ち絵を表示せずに、ウィンドウ位置を 
- 右か左に変更した時、テールのY座標がずれるようです。 
- 原因は調査中です。立ち絵を表示しない時は、イベントコマンド「注釈」で、 
- 「立ち絵表示 off」と記述して立ち絵機能をOFFにしておいてください。 
-   
- ●機能一覧 
- ?イベントコマンド「スクリプト」で、$win_x $win_yに値を入力すると、 
-  ($win_x 、$win_y)の位置にウィンドウを表示する。画面左上が(0,0)。 
-   
- ?キーボードのQ(装備画面で前のキャラに戻るボタン)を押すと、 
-  ウィンドウが消える。Qか決定、キャンセルキーで元に戻る。 
-   
- ?文章のどこでもいいので、以下の表記を行う。 
- ? \name[] : []の中の文字を、ウィンドウ左上に小さく表示する。 
-   
-  \h[-1] : プレーヤーの上にウィンドウをポップ。 
-  \h[0] : 現在アクティブのイベントの上にウィンドウをポップ。 
-  \h[1] : IDが1番のイベントの上にウィンドウをポップする。 
-  hは大文字でもOK。 
-   
- ウィンドウは通常の大きさのまま、テールだけ表示したい場合は、 
-  \t[-2] : ウィンドウが上下に表示される時は、X座標をMINAS_TWE_X_POSで固定。 
-            $win_x で左右に表示される時は、Y座標がウィンドウの中心やや下で固定。 
-  \t[-3] : ウィンドウが上下に表示される時は、X座標をMINAS_THREE_X_POSで固定。 
-            $win_x で左右に表示される時は、Y座標がウィンドウの中心やや下で固定。 
-  \t[-1] : プレーヤーの上に向かってテール表示。 
-  \t[0] : 現在アクティブのイベントに向かってテール表示。 
-  \t[1] : IDが1番のイベントの上に向かってテール表示。 
-   
-  \O[128] : 文字を透明にする。128はalphaの値で、0で透明、255で通常。 
-  \D : 文字に影をつける 
-  \hold : メッセージ表示の、最後の文章に限定。 
-       メッセージが終わっても、ウィンドウを閉じずに残します。 
-       他のメッセージが表示されて次へ送られる時に消えます。 
-       なお、ホールドされているウィンドウは、Qボタンで消せません。 
-   
-   
- ●その他 
- ?ACEに標準装備されている機能は通常通り使用できます。 
- ?A1殿([url]http://a1tktk.web.fc2.com/[/url])の立ち絵スクリプトに対応しています。 
-  このスクリプトの上に「RGSS3用A1共通処理」 
-  このスクリプトの下に「空メッセージでウィンドウを開かない」「立ち絵表示」を 
-  配置して下さい。 
-  残念ながら、「ネームウィンドウ」は使えません。上記\nameをお使いください。 
- ※立ち絵を表示しない時は、注釈で「立ち絵表示 off」とした方が無難です。 
- ?イベントの下から話しかけたら上へポップ、上から話しかけたら下へポップするという 
-  機能を追加。カスタマイズポイントで POP_DIRECTION = ture と変更のこと。 
-   
-   
- ●廃止機能  
- ?\Iがすでに使われているので、イタリック文字変換を廃止。 
- ?スピード変更、改行、最後に入手したアイテムの表示を、ACE化にともない廃止。 
-   
-   
- 【改訂履歴】 
- 2012.01.10  ?ウィンドウを消したまま次のウィンドウを自動で表示すると、 
-               ネームウィンドウが表示されるのを修正。 
- 2012.01.11  ?ネームウィンドウが出しっぱなしになるのを修正。 
- 2012.01.12  ?メニューを出してから決定ボタンを押すとネームウィンドウがでる不具合の修正。 
- 2012.02.01 ?ネームウィンドウのオープン&クローズのタイミングを変更。 
-       ?hold機能を追加。 
- 2012.02.10 ?キャラポップした時、一行ずつしか表示されない不具合を修正。 
- 2012.02.14 ?アイテム名などの文字数が正常に取得できなかったのを修正。 
- 2012.02.21 ?話しかけられた方向によって、ポップ方向を変えられるようにした。 
- 2012.02.25 ?すべてのシーン遷移の際はテールを破棄(イベント中でショップ起動など) 
- 2012.02.28 ?エスケープ文字の処理が上手くいかない問題について暫定対策。 
-   
- =end 
-   
- #============================================================================== 
- # カスタマイズポイント 
- #============================================================================== 
- #=begin 
- class Window_Message < Window_Base 
-   # 
-   # 基本行数 
-   # 
-   MAX_LINE = 4 
-   # 
-   # \p[] - キャラポップの高さ 
-   # 
-   CHARPOP_HEIGHT = 40 
-   # 
-   # \name[] - 名前枠 X,Y座標 
-   # 
-   NAME_WINDOW_OFFSET_X =   0 
-   NAME_WINDOW_OFFSET_Y = -24 
-   # 
-   # 
-   MINAS_TWE_X_POS = 100 # $t[-2]のときの、テールのX座標。 
-   MINAS_THREE_X_POS = 444 # $t[-3]のときの、テールのX座標。 
-   
-   POP_DIRECTION = false #イベントの方向を考慮。 
- end 
- #============================================================================== 
- # 参照機能 
- #============================================================================== 
- class Game_Temp 
-   attr_accessor :last_gain_material 
-   attr_accessor :last_gain_holder 
- end 
- #============================================================================== 
- # フルグレードアップベース - 制御文字?基本機能 
- #============================================================================== 
- class Window_Message < Window_Base 
-   attr_accessor :tail 
-   #-------------------------------------------------------------------------- 
-   # ● 特殊文字の変換 + 準備 
-   #     変換?消去してもいい部分を処理、フラグのセット。 
-   #-------------------------------------------------------------------------- 
-   alias xrxsv2_convert_escape_characters convert_escape_characters 
-   def convert_escape_characters(text) 
-     #@textsが使いずらいので、ここで別変数に保管。 
-     @all_texts = [] 
-     str = text.gsub(/\\/) { "\e" } 
-     @all_texts = str.split("\n") 
-   
-     # 初期化 
-     contents.font.size   = Font.default_size 
-     contents.font.bold   = Font.default_italic 
-     contents.font.italic = Font.default_bold 
-     contents.font.shadow = Font.default_shadow 
-     @type_wait = 0 
-     @line_widths = [] 
-     @line_aligns = [] 
-     self.pop_character = nil 
-     # ウィンドウ保持指定\holdがあるか? 
-     @window_hold = (text.gsub!(/\\hold/) { "" } != nil) 
-     # \info 
-     @info_mode = (text.gsub!(/\\info/) { "" } != nil) 
-     # 改行削除指定\_があるか? 
-     if (/\\_(.*?)\x00/.match(@text)) != nil 
-       $game_message.choice_start -= 1 
-       text.gsub!(/\\_(.*?)\x00/) { $1.to_s } 
-     end 
-     # \name 判定 
-     if text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" } 
-       name = $1 
-       bitmap = @name_sprite.bitmap 
-       w = [bitmap.text_size(name).width, 1].max 
-       w = w + 32 ###SR 
-       bitmap.dispose 
-       @name_sprite.bitmap = Bitmap.new(w, 32) 
-       bitmap = @name_sprite.bitmap 
-       bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name) 
-       @name_window.width = w + 16 
-       @name_window.create_contents 
-       @name_window.open if @name_window.openness == 0 
-       if self.visible #名前だけ表示されるのを防止。 
-         @name_window.visible = true 
-         @name_sprite.visible = true 
-       else 
-         @name_window.visible = false 
-         @name_sprite.visible = false 
-       end 
-     else 
-       @name_window.visible = false 
-       @name_sprite.visible = false 
-       @name_sprite.bitmap.dispose 
-       @name_sprite.bitmap = Bitmap.new(32,32) 
-     end 
-     $name = $1 #あれこれで使うので、ネームウィンドウに表示予定の名前を取得。 
-     # キャラボップモード 
-     if text.gsub!(/\\[Hh]\[-1\]/) { "" } 
-       self.pop_character = -1 
-     elsif text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "" } 
-       self.pop_character = $1.to_i 
-     elsif text.gsub!(/\\[Hh]/) { "" } 
-       self.pop_character = 0 
-     #テール表示モード 
-     elsif text.gsub!(/\\[Tt]\[-1\]/) { "" } 
-       self.tail_character = -1 
-     elsif text.gsub!(/\\[Tt]\[-2\]/) { "" } 
-       self.tail_character = -2 
-     elsif text.gsub!(/\\[Tt]\[-3\]/) { "" } 
-       self.tail_character = -3 
-     elsif text.gsub!(/\\[Tt]\[([0-9]+)\]/) { "" } 
-       self.tail_character = $1.to_i 
-     elsif text.gsub!(/\\[Tt]/) { "" } 
-       self.tail_character = 0 
-     else 
-       self.pop_character = nil 
-     end 
-   
-     # 制御文字処理 
-     text = xrxsv2_convert_escape_characters(text) 
-     text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\eS[#{$1}]" } 
-     text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\eO[#{$1}]" } 
-     text.gsub!(/\\last_holder/i) { "\e18" } 
-     text.gsub!(/\\last_material/i) { "\e19" } 
-     text.gsub!(/\\B/) { "\eB" } 
-     text.gsub!(/\\D/) { "\eD" } 
-     #text.gsub!(/\\n/) { "\n" } 
-     # 
-     # ライン情報の取得 
-     rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08", 
-       /\[([0-9]+)\]/, 
-       "\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"] 
-     lines = text.split("\x00") 
-     @lines_max = lines.size 
-     for i in 0...@lines_max 
-       line = lines[i] 
-       for rx in rxs 
-         line.gsub!(rx) {""} 
-       end 
-       @line_aligns[i] = 
-         line.sub!(/\\center/) {""} ? CENTER : 
-         line.sub!(/\\right/)  {""} ? RIGHT : 
-                                      AUTO 
-       # 行の横幅の取得と設定 
-       cx = text_width_no_escape(line,text) #test 
-       #cx = contents.text_size(line,text).width 
-       @line_widths[i] = cx 
-     end 
-     # 位置揃え制御文字の削除 
-     text.gsub!(/\\center/) {""} 
-     text.gsub!(/\\right/) {""} 
-     # キャラポップ時のウィンドウリサイズ 
-     reszie_window_for_pop 
-   
-     del_tail # if @tail != nil 
-     # $mes_id が空のときと戦闘中はふきだしを表示しない 
-     if defined?($game_system.show_stand_picture) #立ち絵に対応。 
-       $mes_id = -1 if $game_system.show_stand_picture == true 
-     end 
-     if $mes_id != nil and not $game_party.in_battle 
-       # ふきだしのテールを描画 
-       skin = "Window" 
-       if @background == 0 
-         #画像の準備 
-         @tail = Sprite.new 
-         @tail.visible = false 
-         # 位置を取得 
-         tale_pos = get_tale_pos 
-         if $win_x != nil 
-           if $win_x > 0 
-             @tail.bitmap = Cache.system(skin + "-right") 
-             @tail.x = tale_pos[0] 
-             @tail.y = tale_pos[1] 
-             @tail.z = self.z + 1 
-           elsif  $win_x < 0 
-             @tail.bitmap = Cache.system(skin + "-left") 
-             @tail.x = tale_pos[0] 
-             @tail.y = tale_pos[1] 
-             @tail.z = self.z + 1 
-           else 
-             create_tail_up_under 
-           end 
-         else 
-           create_tail_up_under 
-         end 
-         # エクストラスプライトに登録 
-         @extra_sprites = [] if @extra_sprites.nil? 
-         @extra_sprites.push(@tail) if @tail != nil 
-         # 更新 
-         update_tail 
-       end 
-     end 
-   
-     open_and_wait #リサイズが終わった時点でウィンドウオープン。 
-   
-     return text 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 文字の長さを取得する。エスケープ文字は含まない。 
-   # line : 表示しようとしている全ての文字列。 
-   # text : その列の文字。 
-   #-------------------------------------------------------------------------- 
-   def text_width_no_escape(line , text_o) 
-     add = 0 
-     text = Marshal.load(Marshal.dump(text_o)) 
-     text.gsub!(/\ehold/) { "" } 
-     text.gsub!(/\einfo/) { "" } 
-     # 改行削除指定\_があるか? 
-     if (/\\_(.*?)\x00/.match(@text)) != nil 
-       $game_message.choice_start -= 1 
-       text.gsub!(/\\_(.*?)\x00/) { "" } 
-     end 
-     # \name 判定 
-     text.sub!(/\e[Nn]ame\[(.*?)\]/) { "" } 
-     text.gsub!(/\e[Hh]\[-1\]/) { "" } 
-     text.gsub!(/\e[Hh]\[([0-9]+)\]/) { "" } 
-     text.gsub!(/\e[Hh]/) { "" } 
-     text.gsub!(/\e[Tt]\[-1\]/) { "" } 
-     text.gsub!(/\e[Tt]\[-2\]/) { "" } 
-     text.gsub!(/\e[Tt]\[-3\]/) { "" } 
-     text.gsub!(/\e[Tt]\[([0-9]+)\]/) { "" } 
-     text.gsub!(/\e[Tt]/) { "" } 
-     # 制御文字処理 
-     text.gsub!(/\e[Ss]\[([0-9]+)\]/i) { "" } 
-     text.gsub!(/\e[Oo]\[([0-9]+)\]/i) { "" } 
-     text.gsub!(/\elast_holder/i) { "" } 
-     text.gsub!(/\elast_material/i) { "" } 
-     #text.gsub!(/\eV/) { "" } #変数に置き換える。 
-     #text.gsub!(/\eN/) { "" } #名前へ置き換える。 
-     #text.gsub!(/\eP/) { "" } #名前へ置き換える。 
-     #text.gsub!(/\eG/) { "" } #金額へ置き換える。 
-     #text.gsub!(/\eC/) { "" } 
-     text.gsub!(/\eB/) { "" } 
-     text.gsub!(/\eD/) { "" } 
-     if text =~ /\eI/ 
-       loop do 
-         if str = text.sub!(/\eI\[(\d+)\]/){ "" } 
-           add += 24 
-         else 
-           break 
-         end 
-       end 
-     end 
-     #text.gsub!(/\\n/) { "\n" } 
-     text.sub!(/\ecenter/) {""} 
-     text.sub!(/\eright/)  {""} 
-     text.gsub!(/\ecenter/) {""} 
-     text.gsub!(/\eright/) {""} 
-   
-     text = xrxsv2_convert_escape_characters(text) 
-     basic_width = text_size(text).width + add 
-     esc = text.scan(/\e(\S)/) 
-     return ( basic_width - esc.size * (contents.font.size - 4) ) #\eの幅は20? 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 最も長い列の長さを調べる。エスケープ文字は含まない。 
-   #-------------------------------------------------------------------------- 
-   def max_width 
-     text_size = [] 
-     for i in 0 ... @all_texts.size 
-       text_size.push text_width_no_escape(@all_texts[i],@all_texts[i]) + 20 
-     end 
-     return text_size.max 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 吹きだしテールが上か下の場合の画像を準備。 
-   #-------------------------------------------------------------------------- 
-   def create_tail_up_under 
-     skin = "Window" 
-     tale_pos = get_tale_pos 
-     case @position 
-     when 0  # 上 
-       @tail.bitmap = Cache.system(skin + "-top") 
-       @tail.x = tale_pos[0] 
-       @tail.y = tale_pos[1] 
-       @tail.z = self.z + 1 
-     when 1  # 中 
-       @tail.dispose 
-       @tail = nil 
-     when 2  # 下 
-       @tail.bitmap = Cache.system(skin + "-under") 
-       @tail.x = tale_pos[0] 
-       @tail.y = tale_pos[1] 
-       @tail.z = self.z + 1 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 全テキストの処理 
-   #-------------------------------------------------------------------------- 
-   def process_all_text 
-     #open_and_wait #リサイズがあるので、すぐにウィンドウをオープンしない。 
-     text = convert_escape_characters($game_message.all_text) 
-     pos = {} 
-     new_page(text, pos) 
-     process_character(text.slice!(0, 1), text, pos) until text.empty? 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● メッセージの更新 * 
-   #-------------------------------------------------------------------------- 
-   def update_message 
-     @wait_count = @type_wait 
-     loop do 
-       c = @text.slice!(/./m) 
-       case update_message_type(c) 
-       when 1 
-         break 
-       when 2 
-         next 
-       end 
-       break unless @show_fast or @line_show_fast 
-     end 
-   end 
-   ###SR### 
-   alias window_message_update_show_fast_ams update_show_fast 
-   def update_show_fast 
-     @show_fast = true if Input.press?(:B) 
-     window_message_update_show_fast_ams 
-   end 
-   
-   def input_pause 
-     self.pause = true 
-     wait(10) 
-     Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || 
-       Input.press?(:A) 
-     Input.update 
-     self.pause = false 
-   end 
-   ######## 
-   #-------------------------------------------------------------------------- 
-   # 一文字の描画 (返り値 1:break, 2:next) 
-   #-------------------------------------------------------------------------- 
- #=begin 
-   def process_escape_character(code, text, pos) 
-     case code.upcase 
-     when '$' 
-       @gold_window.open 
-     when '.' 
-       wait(15) 
-     when '|' 
-       wait(60) 
-     when '!' 
-       input_pause 
-     when '>' 
-       @line_show_fast = true 
-     when '<' 
-       @line_show_fast = false 
-     when '^' 
-       @pause_skip = true 
-     #when 'n'                      # 改行 
-     #  new_line 
-     #  max = MAX_LINE 
-     #  max = 14 if self.pop_character != nil 
-     #  if @line_count >= max      # 行数が最大のとき 
-     #    unless @text.empty?           # さらに続きがあるなら 
-     #      self.pause = true           # 入力待ちを入れる 
-           #return 1 
-     #    end 
-     #  end 
-     #when 'S'                       # \S[n]  (スピード変更) 
-     #  text.sub!(/\[([0-9]+)\]/, "") 
-     #  @type_wait = $1.to_i 
-     #  return 2 
-     when 'O'                       # \O 文字を透明にする。 
-       text.sub!(/\[([0-9]+)\]/, "") 
-       contents.font.color.alpha = $1.to_i 
-       #return 2 
-     when 'D' #\D 文字に影をつける 
-       contents.font.shadow ^= true 
-     #when '18' 
-     #  name = ($game_temp.last_gain_holder.name rescue "") 
-     #  update_message_type_draw_at(name) 
-     #when '19' 
-     #  item = ($game_temp.last_gain_material.item rescue nil) 
-     #  draw_item_name(item, @contents_x, @contents_y) 
-     #  @contents_x += 196 
-     else 
-       super 
-     end 
-   
-   end 
- #=end 
-   #-------------------------------------------------------------------------- 
-   # ● 改ページ処理 
-   #-------------------------------------------------------------------------- 
-   alias xrxsv2_new_page new_page 
-   def new_page(text, pos) 
-     xrxsv2_new_page(text, pos) 
-     update_charpop_window 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 改行位置の取得 
-   #-------------------------------------------------------------------------- 
-   #def new_line_x 
-   #  $game_message.face_name.empty? ? 0 : 112 
-   #end 
-   #-------------------------------------------------------------------------- 
-   # ● 改行処理 
-   #-------------------------------------------------------------------------- 
-   alias xrxsv2_new_line_x new_line_x 
-   def new_line 
-     xrxsv2_new_line 
-     set_align 
-   end 
-   #-------------------------------------------------------------------------- 
-   # 位置揃え 
-   #-------------------------------------------------------------------------- 
-   def set_align 
-     w = @line_widths[@line_count].to_i 
-     a = @line_aligns[@line_count] 
-     case a 
-     when CENTER 
-       @contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2 
-     when RIGHT 
-       @contents_x = contents.width - w 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● ファイバーのメイン処理 ☆再定義 
-   #-------------------------------------------------------------------------- 
-   def fiber_main 
-     $game_message.visible = true 
-     update_background 
-     update_placement 
-     loop do 
-       process_all_text if $game_message.has_text? 
-       process_input 
-       $game_message.clear 
-       @gold_window.close 
-       process_hold #ホールドウィンドウの処理。 
-       Fiber.yield 
-       break unless text_continue? 
-     end 
-     close_and_wait 
-     $game_message.visible = false 
-     @fiber = nil 
-   end 
-   #-------------------------------------------------------------------------- 
-   # 定数 
-   #-------------------------------------------------------------------------- 
-   AUTO   = 0 
-   LEFT   = 1 
-   CENTER = 2 
-   RIGHT  = 3 
- end 
- #============================================================================== 
- # アクティブイベント取得 
- #============================================================================== 
- class Game_Interpreter 
-   attr_reader   :event_id 
- end 
-   
-   
- #============================================================================== 
- # 各種機能の追加 - キャラポップ/ネーム/ホールド 
- #============================================================================== 
- class Window_Message < Window_Base 
-   #-------------------------------------------------------------------------- 
-   # ● カーソルの更新 * 
-   #-------------------------------------------------------------------------- 
-   def update_cursor 
-     if [url=home.php?mod=space&uid=370741]@Index[/url] >= 0 
-       x = ($game_message.face_name.empty? ? 0 : 112) 
-       y = ($game_message.choice_start + @index) * WLH - 1 
-       w = contents.width - x 
-       if self.pop_character != nil 
-         x += 28 
-         w -= 20 
-       end 
-       self.cursor_rect.set(x, y, w, WLH) 
-     else 
-       self.cursor_rect.empty 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # キャラクターの取得 
-   #   parameter : パラメータ 
-   #-------------------------------------------------------------------------- 
-   def get_character(parameter) 
-     if parameter <= 0 
-       $game_player 
-     else 
-       $game_map.events[parameter] 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # (メッセージ終了時)ホールドの処理 
-   #-------------------------------------------------------------------------- 
-   def process_hold 
-     if @window_hold 
-       @held_windows.push(Window_Copy.new(self)) 
-       @held_windows.push(Window_Copy.new(@name_window)) 
-       @held_windows.push(Sprite_Copy.new(@name_sprite)) 
-       @held_windows.push(Sprite_Copy.new(@back_sprite)) 
-       for sprite in @extra_sprites 
-         next if sprite.disposed? 
-         @held_windows.push(Sprite_Copy.new(sprite)) 
-       end 
-       @extra_sprites.clear 
-       self.openness = 0 
-       #@name_window.openness = 0 
-       @back_sprite.visible = false 
-     else 
-       @held_windows.each {|object| object.dispose} 
-       @held_windows.clear 
-     end 
-     #@name_window.close 
-     #@name_sprite.visible = false 
-   end 
-   #-------------------------------------------------------------------------- 
-   # キャラポップ位置の設定と取得 
-   #-------------------------------------------------------------------------- 
-   def pop_character=(character_id) 
-     @pop_character = character_id 
-   end 
-   def pop_character 
-     return @pop_character 
-   end 
-   #-------------------------------------------------------------------------- 
-   # キャラポップ時のウィンドウリサイズ 
-   #-------------------------------------------------------------------------- 
-   def reszie_window_for_pop 
-     #キャラポップ 
-     if self.pop_character != nil 
-       max_x = @line_widths.max.to_i 
-       n  = max_x + 32 
-       n += $game_message.face_name.empty? ? 0 : 122 
-       m  = $game_message.face_name.empty? ? 0 : 96 
-       w  = @name_sprite.bitmap.width 
-       #self.width  = [n, w].max 
-       self.width  = max_width 
-       #self.height = [@lines_max * line_height, m].max + 32 
-       self.height = [@all_texts.size * line_height, m].max + 32 
-       create_contents 
-       update_charpop_window 
-     elsif @info_mode 
-       @line_aligns[0] = CENTER 
-       self.x = - 8 
-       self.width = Graphics.width + 16 
-       self.height = 56 
-       create_contents 
-     else 
-       self.x = 0 
-       self.width  = Graphics.width 
-       self.height = MAX_LINE * line_height + 32 
-       update_placement #位置情報修正。 
-       create_contents 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 背景スプライトの作成 
-   #-------------------------------------------------------------------------- 
-   alias xrxsv2_create_back_sprite create_back_sprite 
-   def create_back_sprite 
-     xrxsv2_create_back_sprite 
-     @back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width 
-     @name_window = Window_Base.new(0,0,112,36) 
-     @name_window.visible = false 
-     @name_sprite = Sprite.new 
-     @name_sprite.bitmap = Bitmap.new(32,32) 
-     @name_sprite.visible = false 
-     self.x = self.x 
-     self.y = self.y 
-     self.z = self.z 
-     @held_windows = [] 
-     @extra_sprites = [] 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 背景スプライトの解放 
-   #-------------------------------------------------------------------------- 
-   alias xrxsv2_dispose_back_sprite dispose_back_sprite 
-   def dispose_back_sprite 
-     xrxsv2_dispose_back_sprite 
-     @name_window.dispose if @name_window != nil #メニュー画面を出そうとするとエラー? 
-     @name_sprite.dispose if @name_sprite != nil  
-     for window in @held_windows 
-       window.dispose 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 背景スプライトの更新 
-   #-------------------------------------------------------------------------- 
-   alias xrxsv2_update_back_sprite update_back_sprite 
-   def update_back_sprite 
-     @name_window.update 
-     xrxsv2_update_back_sprite 
-     update_charpop_window 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ウィンドウの位置と不透明度の設定 (キャラポップ) 
-   #-------------------------------------------------------------------------- 
-   def update_charpop_window 
-     if self.pop_character 
-       character = get_character(self.pop_character) 
-       return if character == nil 
-       # [X座標] 
-       n = self.width / 2 
-       n = [n, @name_skin.width + 16].max if @current_name != nil 
-       w = @name_sprite.bitmap.width 
-       x = character.screen_x - [[n, w].max, self.width - 32].min 
-       # [Y座標] 
-       if self.pop_character == 0 and POP_DIRECTION #イベントの方向を考慮。 
-         if character.direction == 2 #下向き 
-           @position = 0 #上にポップ 
-         elsif character.direction == 8 #上向き 
-           @position = 2 #下にポップ 
-         end 
-       end 
-       case @position 
-       when 0 
-         y = character.screen_y - CHARPOP_HEIGHT - self.height 
-       else 
-         y = character.screen_y + 16 
-       end 
-       x_max = Graphics.width - 4 - self.width  
-       x_min = 4 
-       y_max = Graphics.height - self.height 
-       y_min = 4 
-       self.x = [[x, x_max].min, x_min].max 
-       self.y = [[y, y_max].min, y_min].max 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # 位置の連動 
-   #-------------------------------------------------------------------------- 
-   def x=(n) 
-     super 
-     if @name_window 
-       @name_window.x = n + NAME_WINDOW_OFFSET_X 
-       @name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8 
-     end 
-   end 
-   def y=(n) 
-     super 
-     if @name_window 
-       @name_window.y = n + NAME_WINDOW_OFFSET_Y 
-       @name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2 
-     end 
-   end 
-   def z=(n) 
-     super 
-     if @name_window 
-       @name_window.z = n + 11#1 テールの上に表示されるので、Zを水増しする。 
-       @name_sprite.z = n + 12#2 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● ファイバーのメイン処理 
-   #-------------------------------------------------------------------------- 
-   def fiber_main_namewin 
-     fiber_main_namewin_default 
-     @name_window.openness = 0 
-     @name_sprite.bitmap.clear 
-     $name = "" 
-   end 
-   alias :fiber_main_namewin_default :fiber_main 
-   alias :fiber_main :fiber_main_namewin 
- end 
- #============================================================================== 
- # 伸縮対応 
- #============================================================================== 
- class Window_Message < Window_Base 
-   #-------------------------------------------------------------------------- 
-   # ● ウィンドウの背景と位置の設定 [再定義] 
-   #-------------------------------------------------------------------------- 
-   def reset_window 
-     @background = $game_message.background 
-     @position = $game_message.position 
-     if @background == 0   # 通常ウィンドウ 
-       self.opacity = 255 
-     else                  # 背景を暗くする、透明にする 
-       self.opacity = 0 
-     end 
-     case @position 
-     when 0  # 上 
-       self.y = 0 
-       @gold_window.y = 360 
-     when 1  # 中 
-       self.y = (Graphics.height - self.height) / 2 
-       @gold_window.y = 0 
-     when 2  # 下 
-       self.y = Graphics.height - self.height 
-       @gold_window.y = 0 
-     end 
-   end 
- end 
- #============================================================================== 
- # □ Window_Copy 
- #------------------------------------------------------------------------------ 
- #   指定のウィンドウのコピーを作成します。 
- #============================================================================== 
- class Window_Copy < Window_Base 
-   #-------------------------------------------------------------------------- 
-   # ○ オブジェクト初期化 
-   #-------------------------------------------------------------------------- 
-   def initialize(window) 
-     super(window.x, window.y, window.width, window.height) 
-     self.contents = window.contents.dup unless window.contents.nil? 
-     self.opacity = window.opacity 
-     self.back_opacity = window.back_opacity 
-     self.z = window.z - 3 
-     self.visible = window.visible 
-   end 
- end 
- #============================================================================== 
- # □ Sprite_Copy 
- #------------------------------------------------------------------------------ 
- #   指定のスプライトのコピーを作成します。 
- #============================================================================== 
- class Sprite_Copy < Sprite 
-   #-------------------------------------------------------------------------- 
-   # ○ オブジェクト初期化 
-   #-------------------------------------------------------------------------- 
-   def initialize(sprite) 
-     super() 
-     self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil? 
-     self.opacity = sprite.opacity 
-     self.x = sprite.x 
-     self.y = sprite.y 
-     self.z = sprite.z - 3 
-     self.ox = sprite.ox 
-     self.oy = sprite.oy 
-     self.zoom_x = sprite.zoom_x 
-     self.visible = sprite.visible 
-   end 
- end 
-   
-   
-   
- #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□ 
- #■吹きだしテールの表示ルーチン。 
- #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□ 
- #============================================================================== 
- # +++ 「+ふきだし表示」VX +++  
- # by パラ犬  [url]http://2d6.parasite.jp/[/url] 
- #      × 
- #    row       [url]http://xms.rdy.jp/[/url] 
- # 
- # publish 2010/ 3/ 2 
- # update  - 
- # 
- #------------------------------------------------------------------------------ 
- #    ほぼどんなメッセージウィンドウに対しても後付け可能な「ふきだし表示」です。 
- #  また、テール部分のみの自動追尾機能を持ちます。 
- #   ふきだし表示をするには、 
- #  テール用画像「Window-top」「Window-under」を 
- #  「Graphics/System」フォルダにインポートしておく必要があります。 
- #============================================================================== 
- # ■ Window_Message 
- #============================================================================== 
- class Window_Message < Window_Base 
-   #-------------------------------------------------------------------------- 
-   # ● メッセージの開始 
-   #-------------------------------------------------------------------------- 
-   alias parashelf_update_all_windows update_all_windows 
-   def update_all_windows 
-     parashelf_update_all_windows 
-     update_tail 
-   end 
-   #-------------------------------------------------------------------------- 
-   # クローズ [オーバーライド] 
-   #-------------------------------------------------------------------------- 
-   def close 
-     super 
-     del_tail 
-     @name_window.close if @name_window != nil #ネームウィンドウのクローズ動作。 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● 背景スプライトの更新 
-   #-------------------------------------------------------------------------- 
-   alias parashelf_update_back_sprite update_back_sprite 
-   def update_back_sprite 
-     parashelf_update_back_sprite 
-     update_tail 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ フレーム更新 (ふきだしテールの更新) 
-   #-------------------------------------------------------------------------- 
-   def update_tail 
-     # ふきだしモードではイベントの動きに追従 
-     if $mes_id != nil and @tail != nil 
-       tale_pos = get_tale_pos 
-       @tail.x = tale_pos[0] 
-       @tail.y = tale_pos[1] 
-       update_tail_bitmap 
-     end 
-   end 
-   ##-------------------------------------------------------------------------- 
-   # ○ ふきだしテールの画像を更新。 
-   #-------------------------------------------------------------------------- 
-   def update_tail_bitmap 
-     skin = "Window" 
-     if $win_x != nil 
-       if $win_x > 0 
-         @tail.bitmap = Cache.system(skin + "-right") 
-       elsif  $win_x < 0 
-         @tail.bitmap = Cache.system(skin + "-left") 
-       else 
-         case @position 
-         when 0  # 上 
-           @tail.bitmap = Cache.system(skin + "-top") 
-         when 2  # 下 
-           @tail.bitmap = Cache.system(skin + "-under") 
-         end 
-       end 
-     else 
-       case @position 
-       when 0  # 上 
-         @tail.bitmap = Cache.system(skin + "-top") 
-       when 2  # 下 
-         @tail.bitmap = Cache.system(skin + "-under") 
-       end 
-     end 
-     # 可視状態 
-     if self.visible == true 
-       @tail.visible = self.openness == 255 
-     else 
-       @tail.visible = false 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ テールの位置を計算 
-   #-------------------------------------------------------------------------- 
-   def get_tale_pos 
-     if defined?($game_system.show_stand_picture) #A1立ち絵スクリプトを入れている。 
-       if $game_system.show_stand_picture #立ち絵on 
-         pos = get_tale_pos_stand_pic 
-       else 
-         pos = get_tale_pos_normal 
-       end 
-     else 
-       pos = get_tale_pos_normal 
-     end 
-     return pos 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ テールの位置を計算/立ち絵使用時。※NAME_CHANGEの編集必須。 
-   #-------------------------------------------------------------------------- 
-   def get_tale_pos_stand_pic 
-     if $game_message.face_name != ""  and @tail != nil 
-       name = A1_System::StandPicture::NAME_CHANGE[$game_message.face_name] 
-       chara = name[$game_message.face_index][0] 
-       if @stand_pic[chara] != nil #立ち絵無しの場合通常通り。 
-         x = @stand_pic[chara].pic_sprite.x + @stand_pic[chara].pic_sprite.width / 2 
-         y = get_tale_pos_normal_updown 
-         update_tail_bitmap 
-       else 
-         return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。 
-       end 
-     else 
-       return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。 
-     end 
-     return [x,y] 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ テールの位置を計算/立ち絵未使用時。 
-   #-------------------------------------------------------------------------- 
-   def get_tale_pos_normal 
-     if $mes_id == (-2) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。 
-       if $win_x != nil 
-         if $win_x > 0 
-           x = $win_x - @tail.width / 2 
-           y = self.y + self.height / 2 - @tail.height / 2 
-         elsif $win_x < 0 
-           x = self.width - @tail.width / 2 
-           y = self.y + self.height / 2 - @tail.height / 2 
-         else 
-           x = MINAS_TWE_X_POS 
-           y = get_tale_pos_normal_updown 
-         end 
-       else 
-         x = MINAS_TWE_X_POS 
-         y = get_tale_pos_normal_updown 
-       end 
-     elsif $mes_id <= (-3) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。 
-       if $win_x != nil 
-         if $win_x > 0 
-           x = $win_x - @tail.width / 2 
-           y = self.y + self.height / 2 
-         elsif $win_x < 0 
-           x = self.width - @tail.width / 2 
-           y = self.y + self.height / 2 
-         else 
-           x = MINAS_THREE_X_POS 
-           y = get_tale_pos_normal_updown 
-         end 
-       else 
-         x = MINAS_THREE_X_POS 
-         y = get_tale_pos_normal_updown 
-       end 
-     else 
-       character = get_character($mes_id) 
-       #msgbox $mes_id 
-       x = [[character.screen_x - 16, self.x].max, self.x + self.width - 32].min 
-       if $win_x != nil 
-         if $win_x > 0 
-           x = $win_x - @tail.width / 2 
-           y = character.screen_y 
-         elsif $win_x < 0 
-           x = self.width 
-           y = character.screen_y 
-         else 
-           y = get_tale_pos_normal_updown 
-         end 
-       else 
-         y = get_tale_pos_normal_updown 
-       end 
-     end 
-     return [x, y] 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ テールが上下の時、かつ[-2][-3]でない時のy座標の取得。 
-   #-------------------------------------------------------------------------- 
-   def get_tale_pos_normal_updown 
-     case @position 
-     when 0 
-       y = self.y + self.height - @tail.height / 2 
-     else 
-       y = self.y - @tail.height / 2 
-     end 
-     return y 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ ふきだしを破棄 
-   #-------------------------------------------------------------------------- 
-   def del_tail 
-     if @tail != nil 
-       @tail.dispose 
-       @tail = nil 
-     end 
-   end 
- end 
- # 
- # ▼▲▼ XRXS 9拡張CO-X. ふきだし自動設定 ▼▲▼ 
- #============================================================================== 
- # ■ Window_Message 
- #============================================================================== 
- class Window_Message < Window_Base 
-   #-------------------------------------------------------------------------- 
-   # ○ ポップキャラクターの設定 
-   #-------------------------------------------------------------------------- 
-   def pop_character=(character_id) 
-     @pop_character = character_id 
-     $mes_id = character_id 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ テールキャラクターの設定 
-   #-------------------------------------------------------------------------- 
-   def tail_character=(character_id) 
-     #@pop_character = character_id 
-     $mes_id = character_id 
-   end 
- end 
-   
- #============================================================================== 
- # ■ Scene_Menu 
- #------------------------------------------------------------------------------ 
- #  メニューを開いてからウィンドウが出るとネームウィンドウが表示される不具合修正。 
- #============================================================================== 
- #class Scene_Menu < Scene_MenuBase 
- #  def terminate_hukidasi_menyu 
- #    @name_window.openness = 0 if @name_window != nil 
- #    terminate_hukidasi_menyu_default 
- #  end 
- #  alias :terminate_hukidasi_menyu_default :terminate 
- #  alias :terminate :terminate_hukidasi_menyu 
- #end 
-   
- #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□ 
- #■ウィンドウ非表示ルーチン 
- #■吹きだしテールとネームウィンドウに対応。 
- #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□ 
- #============================================================================== 
- # L(キーボードのQ)を押すと、メッセージウィンドウを表示?非表示 
- #============================================================================== 
- class Window_Message < Window_Base 
-   def update_winoff 
-     unless $game_party.in_battle #バトル中は無効。 
-       if Input.trigger?(Input::L) 
-         if self.visible == true 
-           self.visible = false 
-           @tail.visible = false if @tail != nil 
-         else 
-           self.visible = true 
-         end 
-         if @name_window != nil 
-           if @name_window.visible == false and $name != nil and $name != "" 
-             @name_window.visible = true 
-             @name_sprite.visible = true 
-           else 
-             @name_window.visible = false 
-             @name_sprite.visible = false 
-           end 
-         end 
-       elsif Input.trigger?(Input::C) or Input.trigger?(Input::B) 
-         self.visible = true if self.visible == false 
-         @tail.visible = true if @tail != nil and @tail.visible == false 
-         if @name_window != nil and $name != nil 
-           if $name != "" 
-             @name_window.visible = true 
-             @name_sprite.visible = true 
-           end 
-         end 
-       end 
-     end 
-     update_winoff_default 
-   end 
-   alias :update_winoff_default :update 
-   alias :update :update_winoff 
- end 
-   
-   
- #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□ 
- #■ウィンドウ表示位置指定ルーチン 
- #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□ 
- #=========================================================================== 
- #イベントコマンド「スクリプト」を使い、 
- #$win_x=100  
- #$win_y=100 
- #と入力すれば、ウィンドウを(100、100)の位置に表示します。 
- #使わない時は 
- #$win_x=nil 
- #などとnilを入力しておいてください。 
- #=========================================================================== 
- class Window_Message < Window_Base 
-   #-------------------------------------------------------------------------- 
-   # ● ウィンドウの背景と位置の設定 [再定義] 
-   #-------------------------------------------------------------------------- 
-   def update_placement_position 
-     update_placement_position_default 
-     if $win_x != nil 
-       if $win_x > 0 
-         self.x = $win_x 
-         self.width -= $win_x 
-       else 
-         self.x = 0 
-         self.width += $win_x 
-       end 
-     end 
-     if $win_y != nil 
-       self.y = $win_y 
-     end 
-   end 
-   alias_method :update_placement_position_default, :update_placement 
-   alias_method :update_placement, :update_placement_position 
- end 
-   
-   
- #============================================================================== 
- # ■ SceneManager 
- #------------------------------------------------------------------------------ 
- #  シーン遷移のさい、テールを破棄する。 
- #============================================================================== 
- module SceneManager 
-   #-------------------------------------------------------------------------- 
-   # ● 呼び出し 
-   #-------------------------------------------------------------------------- 
-   def self.call_sceman_hukidasi(scene_class) 
-     if defined?(self.scene.message_window) 
-       self.scene.message_window.del_tail if self.scene.message_window.tail != nil 
-     end 
-     @stack.push(@scene) 
-     [url=home.php?mod=space&uid=420706]@Scene[/url] = scene_class.new 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● クラスメソッドのエイリアス 
-   #-------------------------------------------------------------------------- 
-   class << self 
-     alias :call_sceman_hukidasi_default :call 
-     alias :call :call_sceman_hukidasi 
-   end 
- end 
-   
- #============================================================================== 
- # ■ Scene_Map 
- #------------------------------------------------------------------------------ 
- #  戦闘トランジションのさい、テールを破棄。 
- #============================================================================== 
- class Scene_Map < Scene_Base 
-   attr_accessor :message_window 
-   #-------------------------------------------------------------------------- 
-   # ● 戦闘前トランジション実行 
-   #-------------------------------------------------------------------------- 
-   def perform_battle_transition_hukidasi 
-     @message_window.del_tail #テールの破棄 
-     perform_battle_transition_hukidasi_default 
-   end 
-   alias_method :perform_battle_transition_hukidasi_default, :perform_battle_transition 
-   alias_method :perform_battle_transition, :perform_battle_transition_hukidasi 
- end