Project1

标题: 想在对话框上加个姓名框要如何写脚本 [打印本页]

作者: 矮矮人    时间: 2015-3-29 10:05
标题: 想在对话框上加个姓名框要如何写脚本

如图,想从左边改到右边
作者: 江户川洛奇    时间: 2015-3-29 10:23
RUBY 代码复制
  1. =begin
  2. 吹きだしウィンドウVXAce
  3.  
  4. 2011.12.25 tamura改造
  5. 2012年02月28日 改訂
  6.  
  7. ※このスクリプトは、ちいさな本屋様([url]http://xrxs.at-ninja.jp/[/url])
  8. が製作されたものをtamuraがACE用に改造した物です。
  9.  
  10. 原版:
  11.  ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
  12.  publish 2010/ 3/ 2
  13.  update  - 11/ 1/10a
  14.  
  15.  
  16. ※※警告※※
  17. 「立ち絵機能」をONにしている時に、立ち絵を表示せずに、ウィンドウ位置を
  18. 右か左に変更した時、テールのY座標がずれるようです。
  19. 原因は調査中です。立ち絵を表示しない時は、イベントコマンド「注釈」で、
  20. 「立ち絵表示 off」と記述して立ち絵機能をOFFにしておいてください。
  21.  
  22. ●機能一覧
  23. ?イベントコマンド「スクリプト」で、$win_x $win_yに値を入力すると、
  24.  ($win_x 、$win_y)の位置にウィンドウを表示する。画面左上が(0,0)。
  25.  
  26. ?キーボードのQ(装備画面で前のキャラに戻るボタン)を押すと、
  27.  ウィンドウが消える。Qか決定、キャンセルキーで元に戻る。
  28.  
  29. ?文章のどこでもいいので、以下の表記を行う。
  30. ? \name[] : []の中の文字を、ウィンドウ左上に小さく表示する。
  31.  
  32.  \h[-1] : プレーヤーの上にウィンドウをポップ。
  33.  \h[0] : 現在アクティブのイベントの上にウィンドウをポップ。
  34.  \h[1] : IDが1番のイベントの上にウィンドウをポップする。
  35.  hは大文字でもOK。
  36.  
  37. ウィンドウは通常の大きさのまま、テールだけ表示したい場合は、
  38.  \t[-2] : ウィンドウが上下に表示される時は、X座標をMINAS_TWE_X_POSで固定。
  39.            $win_x で左右に表示される時は、Y座標がウィンドウの中心やや下で固定。
  40.  \t[-3] : ウィンドウが上下に表示される時は、X座標をMINAS_THREE_X_POSで固定。
  41.            $win_x で左右に表示される時は、Y座標がウィンドウの中心やや下で固定。
  42.  \t[-1] : プレーヤーの上に向かってテール表示。
  43.  \t[0] : 現在アクティブのイベントに向かってテール表示。
  44.  \t[1] : IDが1番のイベントの上に向かってテール表示。
  45.  
  46.  \O[128] : 文字を透明にする。128はalphaの値で、0で透明、255で通常。
  47.  \D : 文字に影をつける
  48.  \hold : メッセージ表示の、最後の文章に限定。
  49.       メッセージが終わっても、ウィンドウを閉じずに残します。
  50.       他のメッセージが表示されて次へ送られる時に消えます。
  51.       なお、ホールドされているウィンドウは、Qボタンで消せません。
  52.  
  53.  
  54. ●その他
  55. ?ACEに標準装備されている機能は通常通り使用できます。
  56. ?A1殿([url]http://a1tktk.web.fc2.com/[/url])の立ち絵スクリプトに対応しています。
  57.  このスクリプトの上に「RGSS3用A1共通処理」
  58.  このスクリプトの下に「空メッセージでウィンドウを開かない」「立ち絵表示」を
  59.  配置して下さい。
  60.  残念ながら、「ネームウィンドウ」は使えません。上記\nameをお使いください。
  61. ※立ち絵を表示しない時は、注釈で「立ち絵表示 off」とした方が無難です。
  62. ?イベントの下から話しかけたら上へポップ、上から話しかけたら下へポップするという
  63.  機能を追加。カスタマイズポイントで POP_DIRECTION = ture と変更のこと。
  64.  
  65.  
  66. ●廃止機能 
  67. ?\Iがすでに使われているので、イタリック文字変換を廃止。
  68. ?スピード変更、改行、最後に入手したアイテムの表示を、ACE化にともない廃止。
  69.  
  70.  
  71. 【改訂履歴】
  72. 2012.01.10  ?ウィンドウを消したまま次のウィンドウを自動で表示すると、
  73.               ネームウィンドウが表示されるのを修正。
  74. 2012.01.11  ?ネームウィンドウが出しっぱなしになるのを修正。
  75. 2012.01.12  ?メニューを出してから決定ボタンを押すとネームウィンドウがでる不具合の修正。
  76. 2012.02.01 ?ネームウィンドウのオープン&クローズのタイミングを変更。
  77.       ?hold機能を追加。
  78. 2012.02.10 ?キャラポップした時、一行ずつしか表示されない不具合を修正。
  79. 2012.02.14 ?アイテム名などの文字数が正常に取得できなかったのを修正。
  80. 2012.02.21 ?話しかけられた方向によって、ポップ方向を変えられるようにした。
  81. 2012.02.25 ?すべてのシーン遷移の際はテールを破棄(イベント中でショップ起動など)
  82. 2012.02.28 ?エスケープ文字の処理が上手くいかない問題について暫定対策。
  83.  
  84. =end
  85.  
  86. #==============================================================================
  87. # カスタマイズポイント
  88. #==============================================================================
  89. #=begin
  90. class Window_Message < Window_Base
  91.   #
  92.   # 基本行数
  93.   #
  94.   MAX_LINE = 4
  95.   #
  96.   # \p[] - キャラポップの高さ
  97.   #
  98.   CHARPOP_HEIGHT = 40
  99.   #
  100.   # \name[] - 名前枠 X,Y座標
  101.   #
  102.   NAME_WINDOW_OFFSET_X =   0
  103.   NAME_WINDOW_OFFSET_Y = -24
  104.   #
  105.   #
  106.   MINAS_TWE_X_POS = 100 # $t[-2]のときの、テールのX座標。
  107.   MINAS_THREE_X_POS = 444 # $t[-3]のときの、テールのX座標。
  108.  
  109.   POP_DIRECTION = false #イベントの方向を考慮。
  110. end
  111. #==============================================================================
  112. # 参照機能
  113. #==============================================================================
  114. class Game_Temp
  115.   attr_accessor :last_gain_material
  116.   attr_accessor :last_gain_holder
  117. end
  118. #==============================================================================
  119. # フルグレードアップベース - 制御文字?基本機能
  120. #==============================================================================
  121. class Window_Message < Window_Base
  122.   attr_accessor :tail
  123.   #--------------------------------------------------------------------------
  124.   # ● 特殊文字の変換 + 準備
  125.   #     変換?消去してもいい部分を処理、フラグのセット。
  126.   #--------------------------------------------------------------------------
  127.   alias xrxsv2_convert_escape_characters convert_escape_characters
  128.   def convert_escape_characters(text)
  129.     #@textsが使いずらいので、ここで別変数に保管。
  130.     @all_texts = []
  131.     str = text.gsub(/\\/) { "\e" }
  132.     @all_texts = str.split("\n")
  133.  
  134.     # 初期化
  135.     contents.font.size   = Font.default_size
  136.     contents.font.bold   = Font.default_italic
  137.     contents.font.italic = Font.default_bold
  138.     contents.font.shadow = Font.default_shadow
  139.     @type_wait = 0
  140.     @line_widths = []
  141.     @line_aligns = []
  142.     self.pop_character = nil
  143.     # ウィンドウ保持指定\holdがあるか?
  144.     @window_hold = (text.gsub!(/\\hold/) { "" } != nil)
  145.     # \info
  146.     @info_mode = (text.gsub!(/\\info/) { "" } != nil)
  147.     # 改行削除指定\_があるか?
  148.     if (/\\_(.*?)\x00/.match(@text)) != nil
  149.       $game_message.choice_start -= 1
  150.       text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
  151.     end
  152.     # \name 判定
  153.     if text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  154.       name = $1
  155.       bitmap = @name_sprite.bitmap
  156.       w = [bitmap.text_size(name).width, 1].max
  157.       w = w + 32 ###SR
  158.       bitmap.dispose
  159.       @name_sprite.bitmap = Bitmap.new(w, 32)
  160.       bitmap = @name_sprite.bitmap
  161.       bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
  162.       @name_window.width = w + 16
  163.       @name_window.create_contents
  164.       @name_window.open if @name_window.openness == 0
  165.       if self.visible #名前だけ表示されるのを防止。
  166.         @name_window.visible = true
  167.         @name_sprite.visible = true
  168.       else
  169.         @name_window.visible = false
  170.         @name_sprite.visible = false
  171.       end
  172.     else
  173.       @name_window.visible = false
  174.       @name_sprite.visible = false
  175.       @name_sprite.bitmap.dispose
  176.       @name_sprite.bitmap = Bitmap.new(32,32)
  177.     end
  178.     $name = $1 #あれこれで使うので、ネームウィンドウに表示予定の名前を取得。
  179.     # キャラボップモード
  180.     if text.gsub!(/\\[Hh]\[-1\]/) { "" }
  181.       self.pop_character = -1
  182.     elsif text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "" }
  183.       self.pop_character = $1.to_i
  184.     elsif text.gsub!(/\\[Hh]/) { "" }
  185.       self.pop_character = 0
  186.     #テール表示モード
  187.     elsif text.gsub!(/\\[Tt]\[-1\]/) { "" }
  188.       self.tail_character = -1
  189.     elsif text.gsub!(/\\[Tt]\[-2\]/) { "" }
  190.       self.tail_character = -2
  191.     elsif text.gsub!(/\\[Tt]\[-3\]/) { "" }
  192.       self.tail_character = -3
  193.     elsif text.gsub!(/\\[Tt]\[([0-9]+)\]/) { "" }
  194.       self.tail_character = $1.to_i
  195.     elsif text.gsub!(/\\[Tt]/) { "" }
  196.       self.tail_character = 0
  197.     else
  198.       self.pop_character = nil
  199.     end
  200.  
  201.     # 制御文字処理
  202.     text = xrxsv2_convert_escape_characters(text)
  203.     text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\eS[#{$1}]" }
  204.     text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\eO[#{$1}]" }
  205.     text.gsub!(/\\last_holder/i) { "\e18" }
  206.     text.gsub!(/\\last_material/i) { "\e19" }
  207.     text.gsub!(/\\B/) { "\eB" }
  208.     text.gsub!(/\\D/) { "\eD" }
  209.     #text.gsub!(/\\n/) { "\n" }
  210.     #
  211.     # ライン情報の取得
  212.     rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
  213.       /\[([0-9]+)\]/,
  214.       "\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
  215.     lines = text.split("\x00")
  216.     @lines_max = lines.size
  217.     for i in 0...@lines_max
  218.       line = lines[i]
  219.       for rx in rxs
  220.         line.gsub!(rx) {""}
  221.       end
  222.       @line_aligns[i] =
  223.         line.sub!(/\\center/) {""} ? CENTER :
  224.         line.sub!(/\\right/)  {""} ? RIGHT :
  225.                                      AUTO
  226.       # 行の横幅の取得と設定
  227.       cx = text_width_no_escape(line,text) #test
  228.       #cx = contents.text_size(line,text).width
  229.       @line_widths[i] = cx
  230.     end
  231.     # 位置揃え制御文字の削除
  232.     text.gsub!(/\\center/) {""}
  233.     text.gsub!(/\\right/) {""}
  234.     # キャラポップ時のウィンドウリサイズ
  235.     reszie_window_for_pop
  236.  
  237.     del_tail # if @tail != nil
  238.     # $mes_id が空のときと戦闘中はふきだしを表示しない
  239.     if defined?($game_system.show_stand_picture) #立ち絵に対応。
  240.       $mes_id = -1 if $game_system.show_stand_picture == true
  241.     end
  242.     if $mes_id != nil and not $game_party.in_battle
  243.       # ふきだしのテールを描画
  244.       skin = "Window"
  245.       if @background == 0
  246.         #画像の準備
  247.         @tail = Sprite.new
  248.         @tail.visible = false
  249.         # 位置を取得
  250.         tale_pos = get_tale_pos
  251.         if $win_x != nil
  252.           if $win_x > 0
  253.             @tail.bitmap = Cache.system(skin + "-right")
  254.             @tail.x = tale_pos[0]
  255.             @tail.y = tale_pos[1]
  256.             @tail.z = self.z + 1
  257.           elsif  $win_x < 0
  258.             @tail.bitmap = Cache.system(skin + "-left")
  259.             @tail.x = tale_pos[0]
  260.             @tail.y = tale_pos[1]
  261.             @tail.z = self.z + 1
  262.           else
  263.             create_tail_up_under
  264.           end
  265.         else
  266.           create_tail_up_under
  267.         end
  268.         # エクストラスプライトに登録
  269.         @extra_sprites = [] if @extra_sprites.nil?
  270.         @extra_sprites.push(@tail) if @tail != nil
  271.         # 更新
  272.         update_tail
  273.       end
  274.     end
  275.  
  276.     open_and_wait #リサイズが終わった時点でウィンドウオープン。
  277.  
  278.     return text
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 文字の長さを取得する。エスケープ文字は含まない。
  282.   # line : 表示しようとしている全ての文字列。
  283.   # text : その列の文字。
  284.   #--------------------------------------------------------------------------
  285.   def text_width_no_escape(line , text_o)
  286.     add = 0
  287.     text = Marshal.load(Marshal.dump(text_o))
  288.     text.gsub!(/\ehold/) { "" }
  289.     text.gsub!(/\einfo/) { "" }
  290.     # 改行削除指定\_があるか?
  291.     if (/\\_(.*?)\x00/.match(@text)) != nil
  292.       $game_message.choice_start -= 1
  293.       text.gsub!(/\\_(.*?)\x00/) { "" }
  294.     end
  295.     # \name 判定
  296.     text.sub!(/\e[Nn]ame\[(.*?)\]/) { "" }
  297.     text.gsub!(/\e[Hh]\[-1\]/) { "" }
  298.     text.gsub!(/\e[Hh]\[([0-9]+)\]/) { "" }
  299.     text.gsub!(/\e[Hh]/) { "" }
  300.     text.gsub!(/\e[Tt]\[-1\]/) { "" }
  301.     text.gsub!(/\e[Tt]\[-2\]/) { "" }
  302.     text.gsub!(/\e[Tt]\[-3\]/) { "" }
  303.     text.gsub!(/\e[Tt]\[([0-9]+)\]/) { "" }
  304.     text.gsub!(/\e[Tt]/) { "" }
  305.     # 制御文字処理
  306.     text.gsub!(/\e[Ss]\[([0-9]+)\]/i) { "" }
  307.     text.gsub!(/\e[Oo]\[([0-9]+)\]/i) { "" }
  308.     text.gsub!(/\elast_holder/i) { "" }
  309.     text.gsub!(/\elast_material/i) { "" }
  310.     #text.gsub!(/\eV/) { "" } #変数に置き換える。
  311.     #text.gsub!(/\eN/) { "" } #名前へ置き換える。
  312.     #text.gsub!(/\eP/) { "" } #名前へ置き換える。
  313.     #text.gsub!(/\eG/) { "" } #金額へ置き換える。
  314.     #text.gsub!(/\eC/) { "" }
  315.     text.gsub!(/\eB/) { "" }
  316.     text.gsub!(/\eD/) { "" }
  317.     if text =~ /\eI/
  318.       loop do
  319.         if str = text.sub!(/\eI\[(\d+)\]/){ "" }
  320.           add += 24
  321.         else
  322.           break
  323.         end
  324.       end
  325.     end
  326.     #text.gsub!(/\\n/) { "\n" }
  327.     text.sub!(/\ecenter/) {""}
  328.     text.sub!(/\eright/)  {""}
  329.     text.gsub!(/\ecenter/) {""}
  330.     text.gsub!(/\eright/) {""}
  331.  
  332.     text = xrxsv2_convert_escape_characters(text)
  333.     basic_width = text_size(text).width + add
  334.     esc = text.scan(/\e(\S)/)
  335.     return ( basic_width - esc.size * (contents.font.size - 4) ) #\eの幅は20?
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 最も長い列の長さを調べる。エスケープ文字は含まない。
  339.   #--------------------------------------------------------------------------
  340.   def max_width
  341.     text_size = []
  342.     for i in 0 ... @all_texts.size
  343.       text_size.push text_width_no_escape(@all_texts[i],@all_texts[i]) + 20
  344.     end
  345.     return text_size.max
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 吹きだしテールが上か下の場合の画像を準備。
  349.   #--------------------------------------------------------------------------
  350.   def create_tail_up_under
  351.     skin = "Window"
  352.     tale_pos = get_tale_pos
  353.     case @position
  354.     when 0  # 上
  355.       @tail.bitmap = Cache.system(skin + "-top")
  356.       @tail.x = tale_pos[0]
  357.       @tail.y = tale_pos[1]
  358.       @tail.z = self.z + 1
  359.     when 1  # 中
  360.       @tail.dispose
  361.       @tail = nil
  362.     when 2  # 下
  363.       @tail.bitmap = Cache.system(skin + "-under")
  364.       @tail.x = tale_pos[0]
  365.       @tail.y = tale_pos[1]
  366.       @tail.z = self.z + 1
  367.     end
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 全テキストの処理
  371.   #--------------------------------------------------------------------------
  372.   def process_all_text
  373.     #open_and_wait #リサイズがあるので、すぐにウィンドウをオープンしない。
  374.     text = convert_escape_characters($game_message.all_text)
  375.     pos = {}
  376.     new_page(text, pos)
  377.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ● メッセージの更新 *
  381.   #--------------------------------------------------------------------------
  382.   def update_message
  383.     @wait_count = @type_wait
  384.     loop do
  385.       c = @text.slice!(/./m)
  386.       case update_message_type(c)
  387.       when 1
  388.         break
  389.       when 2
  390.         next
  391.       end
  392.       break unless @show_fast or @line_show_fast
  393.     end
  394.   end
  395.   ###SR###
  396.   alias window_message_update_show_fast_ams update_show_fast
  397.   def update_show_fast
  398.     @show_fast = true if Input.press?(:B)
  399.     window_message_update_show_fast_ams
  400.   end
  401.  
  402.   def input_pause
  403.     self.pause = true
  404.     wait(10)
  405.     Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) ||
  406.       Input.press?(:A)
  407.     Input.update
  408.     self.pause = false
  409.   end
  410.   ########
  411.   #--------------------------------------------------------------------------
  412.   # 一文字の描画 (返り値 1:break, 2:next)
  413.   #--------------------------------------------------------------------------
  414. #=begin
  415.   def process_escape_character(code, text, pos)
  416.     case code.upcase
  417.     when '$'
  418.       @gold_window.open
  419.     when '.'
  420.       wait(15)
  421.     when '|'
  422.       wait(60)
  423.     when '!'
  424.       input_pause
  425.     when '>'
  426.       @line_show_fast = true
  427.     when '<'
  428.       @line_show_fast = false
  429.     when '^'
  430.       @pause_skip = true
  431.     #when 'n'                      # 改行
  432.     #  new_line
  433.     #  max = MAX_LINE
  434.     #  max = 14 if self.pop_character != nil
  435.     #  if @line_count >= max      # 行数が最大のとき
  436.     #    unless @text.empty?           # さらに続きがあるなら
  437.     #      self.pause = true           # 入力待ちを入れる
  438.           #return 1
  439.     #    end
  440.     #  end
  441.     #when 'S'                       # \S[n]  (スピード変更)
  442.     #  text.sub!(/\[([0-9]+)\]/, "")
  443.     #  @type_wait = $1.to_i
  444.     #  return 2
  445.     when 'O'                       # \O 文字を透明にする。
  446.       text.sub!(/\[([0-9]+)\]/, "")
  447.       contents.font.color.alpha = $1.to_i
  448.       #return 2
  449.     when 'D' #\D 文字に影をつける
  450.       contents.font.shadow ^= true
  451.     #when '18'
  452.     #  name = ($game_temp.last_gain_holder.name rescue "")
  453.     #  update_message_type_draw_at(name)
  454.     #when '19'
  455.     #  item = ($game_temp.last_gain_material.item rescue nil)
  456.     #  draw_item_name(item, @contents_x, @contents_y)
  457.     #  @contents_x += 196
  458.     else
  459.       super
  460.     end
  461.  
  462.   end
  463. #=end
  464.   #--------------------------------------------------------------------------
  465.   # ● 改ページ処理
  466.   #--------------------------------------------------------------------------
  467.   alias xrxsv2_new_page new_page
  468.   def new_page(text, pos)
  469.     xrxsv2_new_page(text, pos)
  470.     update_charpop_window
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ● 改行位置の取得
  474.   #--------------------------------------------------------------------------
  475.   #def new_line_x
  476.   #  $game_message.face_name.empty? ? 0 : 112
  477.   #end
  478.   #--------------------------------------------------------------------------
  479.   # ● 改行処理
  480.   #--------------------------------------------------------------------------
  481.   alias xrxsv2_new_line_x new_line_x
  482.   def new_line
  483.     xrxsv2_new_line
  484.     set_align
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # 位置揃え
  488.   #--------------------------------------------------------------------------
  489.   def set_align
  490.     w = @line_widths[@line_count].to_i
  491.     a = @line_aligns[@line_count]
  492.     case a
  493.     when CENTER
  494.       @contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
  495.     when RIGHT
  496.       @contents_x = contents.width - w
  497.     end
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # ● ファイバーのメイン処理 ☆再定義
  501.   #--------------------------------------------------------------------------
  502.   def fiber_main
  503.     $game_message.visible = true
  504.     update_background
  505.     update_placement
  506.     loop do
  507.       process_all_text if $game_message.has_text?
  508.       process_input
  509.       $game_message.clear
  510.       @gold_window.close
  511.       process_hold #ホールドウィンドウの処理。
  512.       Fiber.yield
  513.       break unless text_continue?
  514.     end
  515.     close_and_wait
  516.     $game_message.visible = false
  517.     @fiber = nil
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # 定数
  521.   #--------------------------------------------------------------------------
  522.   AUTO   = 0
  523.   LEFT   = 1
  524.   CENTER = 2
  525.   RIGHT  = 3
  526. end
  527. #==============================================================================
  528. # アクティブイベント取得
  529. #==============================================================================
  530. class Game_Interpreter
  531.   attr_reader   :event_id
  532. end
  533.  
  534.  
  535. #==============================================================================
  536. # 各種機能の追加 - キャラポップ/ネーム/ホールド
  537. #==============================================================================
  538. class Window_Message < Window_Base
  539.   #--------------------------------------------------------------------------
  540.   # ● カーソルの更新 *
  541.   #--------------------------------------------------------------------------
  542.   def update_cursor
  543.     if @index >= 0
  544.       x = ($game_message.face_name.empty? ? 0 : 112)
  545.       y = ($game_message.choice_start + @index) * WLH - 1
  546.       w = contents.width - x
  547.       if self.pop_character != nil
  548.         x += 28
  549.         w -= 20
  550.       end
  551.       self.cursor_rect.set(x, y, w, WLH)
  552.     else
  553.       self.cursor_rect.empty
  554.     end
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # キャラクターの取得
  558.   #   parameter : パラメータ
  559.   #--------------------------------------------------------------------------
  560.   def get_character(parameter)
  561.     if parameter <= 0
  562.       $game_player
  563.     else
  564.       $game_map.events[parameter]
  565.     end
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # (メッセージ終了時)ホールドの処理
  569.   #--------------------------------------------------------------------------
  570.   def process_hold
  571.     if @window_hold
  572.       @held_windows.push(Window_Copy.new(self))
  573.       @held_windows.push(Window_Copy.new(@name_window))
  574.       @held_windows.push(Sprite_Copy.new(@name_sprite))
  575.       @held_windows.push(Sprite_Copy.new(@back_sprite))
  576.       for sprite in @extra_sprites
  577.         next if sprite.disposed?
  578.         @held_windows.push(Sprite_Copy.new(sprite))
  579.       end
  580.       @extra_sprites.clear
  581.       self.openness = 0
  582.       #@name_window.openness = 0
  583.       @back_sprite.visible = false
  584.     else
  585.       @held_windows.each {|object| object.dispose}
  586.       @held_windows.clear
  587.     end
  588.     #@name_window.close
  589.     #@name_sprite.visible = false
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # キャラポップ位置の設定と取得
  593.   #--------------------------------------------------------------------------
  594.   def pop_character=(character_id)
  595.     @pop_character = character_id
  596.   end
  597.   def pop_character
  598.     return @pop_character
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # キャラポップ時のウィンドウリサイズ
  602.   #--------------------------------------------------------------------------
  603.   def reszie_window_for_pop
  604.     #キャラポップ
  605.     if self.pop_character != nil
  606.       max_x = @line_widths.max.to_i
  607.       n  = max_x + 32
  608.       n += $game_message.face_name.empty? ? 0 : 122
  609.       m  = $game_message.face_name.empty? ? 0 : 96
  610.       w  = @name_sprite.bitmap.width
  611.       #self.width  = [n, w].max
  612.       self.width  = max_width
  613.       #self.height = [@lines_max * line_height, m].max + 32
  614.       self.height = [@all_texts.size * line_height, m].max + 32
  615.       create_contents
  616.       update_charpop_window
  617.     elsif @info_mode
  618.       @line_aligns[0] = CENTER
  619.       self.x = - 8
  620.       self.width = Graphics.width + 16
  621.       self.height = 56
  622.       create_contents
  623.     else
  624.       self.x = 0
  625.       self.width  = Graphics.width
  626.       self.height = MAX_LINE * line_height + 32
  627.       update_placement #位置情報修正。
  628.       create_contents
  629.     end
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 背景スプライトの作成
  633.   #--------------------------------------------------------------------------
  634.   alias xrxsv2_create_back_sprite create_back_sprite
  635.   def create_back_sprite
  636.     xrxsv2_create_back_sprite
  637.     @back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
  638.     @name_window = Window_Base.new(0,0,112,36)
  639.     @name_window.visible = false
  640.     @name_sprite = Sprite.new
  641.     @name_sprite.bitmap = Bitmap.new(32,32)
  642.     @name_sprite.visible = false
  643.     self.x = self.x
  644.     self.y = self.y
  645.     self.z = self.z
  646.     @held_windows = []
  647.     @extra_sprites = []
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ● 背景スプライトの解放
  651.   #--------------------------------------------------------------------------
  652.   alias xrxsv2_dispose_back_sprite dispose_back_sprite
  653.   def dispose_back_sprite
  654.     xrxsv2_dispose_back_sprite
  655.     @name_window.dispose if @name_window != nil #メニュー画面を出そうとするとエラー?
  656.     @name_sprite.dispose if @name_sprite != nil
  657.     for window in @held_windows
  658.       window.dispose
  659.     end
  660.   end
  661.   #--------------------------------------------------------------------------
  662.   # ● 背景スプライトの更新
  663.   #--------------------------------------------------------------------------
  664.   alias xrxsv2_update_back_sprite update_back_sprite
  665.   def update_back_sprite
  666.     @name_window.update
  667.     xrxsv2_update_back_sprite
  668.     update_charpop_window
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # ウィンドウの位置と不透明度の設定 (キャラポップ)
  672.   #--------------------------------------------------------------------------
  673.   def update_charpop_window
  674.     if self.pop_character
  675.       character = get_character(self.pop_character)
  676.       return if character == nil
  677.       # [X座標]
  678.       n = self.width / 2
  679.       n = [n, @name_skin.width + 16].max if @current_name != nil
  680.       w = @name_sprite.bitmap.width
  681.       x = character.screen_x - [[n, w].max, self.width - 32].min
  682.       # [Y座標]
  683.       if self.pop_character == 0 and POP_DIRECTION #イベントの方向を考慮。
  684.         if character.direction == 2 #下向き
  685.           @position = 0 #上にポップ
  686.         elsif character.direction == 8 #上向き
  687.           @position = 2 #下にポップ
  688.         end
  689.       end
  690.       case @position
  691.       when 0
  692.         y = character.screen_y - CHARPOP_HEIGHT - self.height
  693.       else
  694.         y = character.screen_y + 16
  695.       end
  696.       x_max = Graphics.width - 4 - self.width
  697.       x_min = 4
  698.       y_max = Graphics.height - self.height
  699.       y_min = 4
  700.       self.x = [[x, x_max].min, x_min].max
  701.       self.y = [[y, y_max].min, y_min].max
  702.     end
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # 位置の連動
  706.   #--------------------------------------------------------------------------
  707.   def x=(n)
  708.     super
  709.     if @name_window
  710.       @name_window.x = n + NAME_WINDOW_OFFSET_X
  711.       @name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
  712.     end
  713.   end
  714.   def y=(n)
  715.     super
  716.     if @name_window
  717.       @name_window.y = n + NAME_WINDOW_OFFSET_Y
  718.       @name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
  719.     end
  720.   end
  721.   def z=(n)
  722.     super
  723.     if @name_window
  724.       @name_window.z = n + 11#1 テールの上に表示されるので、Zを水増しする。
  725.       @name_sprite.z = n + 12#2
  726.     end
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● ファイバーのメイン処理
  730.   #--------------------------------------------------------------------------
  731.   def fiber_main_namewin
  732.     fiber_main_namewin_default
  733.     @name_window.openness = 0
  734.     @name_sprite.bitmap.clear
  735.     $name = ""
  736.   end
  737.   alias :fiber_main_namewin_default :fiber_main
  738.   alias :fiber_main :fiber_main_namewin
  739. end
  740. #==============================================================================
  741. # 伸縮対応
  742. #==============================================================================
  743. class Window_Message < Window_Base
  744.   #--------------------------------------------------------------------------
  745.   # ● ウィンドウの背景と位置の設定 [再定義]
  746.   #--------------------------------------------------------------------------
  747.   def reset_window
  748.     @background = $game_message.background
  749.     @position = $game_message.position
  750.     if @background == 0   # 通常ウィンドウ
  751.       self.opacity = 255
  752.     else                  # 背景を暗くする、透明にする
  753.       self.opacity = 0
  754.     end
  755.     case @position
  756.     when 0  # 上
  757.       self.y = 0
  758.       @gold_window.y = 360
  759.     when 1  # 中
  760.       self.y = (Graphics.height - self.height) / 2
  761.       @gold_window.y = 0
  762.     when 2  # 下
  763.       self.y = Graphics.height - self.height
  764.       @gold_window.y = 0
  765.     end
  766.   end
  767. end
  768. #==============================================================================
  769. # □ Window_Copy
  770. #------------------------------------------------------------------------------
  771. #   指定のウィンドウのコピーを作成します。
  772. #==============================================================================
  773. class Window_Copy < Window_Base
  774.   #--------------------------------------------------------------------------
  775.   # ○ オブジェクト初期化
  776.   #--------------------------------------------------------------------------
  777.   def initialize(window)
  778.     super(window.x, window.y, window.width, window.height)
  779.     self.contents = window.contents.dup unless window.contents.nil?
  780.     self.opacity = window.opacity
  781.     self.back_opacity = window.back_opacity
  782.     self.z = window.z - 3
  783.     self.visible = window.visible
  784.   end
  785. end
  786. #==============================================================================
  787. # □ Sprite_Copy
  788. #------------------------------------------------------------------------------
  789. #   指定のスプライトのコピーを作成します。
  790. #==============================================================================
  791. class Sprite_Copy < Sprite
  792.   #--------------------------------------------------------------------------
  793.   # ○ オブジェクト初期化
  794.   #--------------------------------------------------------------------------
  795.   def initialize(sprite)
  796.     super()
  797.     self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  798.     self.opacity = sprite.opacity
  799.     self.x = sprite.x
  800.     self.y = sprite.y
  801.     self.z = sprite.z - 3
  802.     self.ox = sprite.ox
  803.     self.oy = sprite.oy
  804.     self.zoom_x = sprite.zoom_x
  805.     self.visible = sprite.visible
  806.   end
  807. end
  808.  
  809.  
  810.  
  811. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  812. #■吹きだしテールの表示ルーチン。
  813. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  814. #==============================================================================
  815. # +++ 「+ふきだし表示」VX +++
  816. # by パラ犬  [url]http://2d6.parasite.jp/[/url]
  817. #      ×
  818. #    row       [url]http://xms.rdy.jp/[/url]
  819. #
  820. # publish 2010/ 3/ 2
  821. # update  -
  822. #
  823. #------------------------------------------------------------------------------
  824. #    ほぼどんなメッセージウィンドウに対しても後付け可能な「ふきだし表示」です。
  825. #  また、テール部分のみの自動追尾機能を持ちます。
  826. #   ふきだし表示をするには、
  827. #  テール用画像「Window-top」「Window-under」を
  828. #  「Graphics/System」フォルダにインポートしておく必要があります。
  829. #==============================================================================
  830. # ■ Window_Message
  831. #==============================================================================
  832. class Window_Message < Window_Base
  833.   #--------------------------------------------------------------------------
  834.   # ● メッセージの開始
  835.   #--------------------------------------------------------------------------
  836.   alias parashelf_update_all_windows update_all_windows
  837.   def update_all_windows
  838.     parashelf_update_all_windows
  839.     update_tail
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # クローズ [オーバーライド]
  843.   #--------------------------------------------------------------------------
  844.   def close
  845.     super
  846.     del_tail
  847.     @name_window.close if @name_window != nil #ネームウィンドウのクローズ動作。
  848.   end
  849.   #--------------------------------------------------------------------------
  850.   # ● 背景スプライトの更新
  851.   #--------------------------------------------------------------------------
  852.   alias parashelf_update_back_sprite update_back_sprite
  853.   def update_back_sprite
  854.     parashelf_update_back_sprite
  855.     update_tail
  856.   end
  857.   #--------------------------------------------------------------------------
  858.   # ○ フレーム更新 (ふきだしテールの更新)
  859.   #--------------------------------------------------------------------------
  860.   def update_tail
  861.     # ふきだしモードではイベントの動きに追従
  862.     if $mes_id != nil and @tail != nil
  863.       tale_pos = get_tale_pos
  864.       @tail.x = tale_pos[0]
  865.       @tail.y = tale_pos[1]
  866.       update_tail_bitmap
  867.     end
  868.   end
  869.   ##--------------------------------------------------------------------------
  870.   # ○ ふきだしテールの画像を更新。
  871.   #--------------------------------------------------------------------------
  872.   def update_tail_bitmap
  873.     skin = "Window"
  874.     if $win_x != nil
  875.       if $win_x > 0
  876.         @tail.bitmap = Cache.system(skin + "-right")
  877.       elsif  $win_x < 0
  878.         @tail.bitmap = Cache.system(skin + "-left")
  879.       else
  880.         case @position
  881.         when 0  # 上
  882.           @tail.bitmap = Cache.system(skin + "-top")
  883.         when 2  # 下
  884.           @tail.bitmap = Cache.system(skin + "-under")
  885.         end
  886.       end
  887.     else
  888.       case @position
  889.       when 0  # 上
  890.         @tail.bitmap = Cache.system(skin + "-top")
  891.       when 2  # 下
  892.         @tail.bitmap = Cache.system(skin + "-under")
  893.       end
  894.     end
  895.     # 可視状態
  896.     if self.visible == true
  897.       @tail.visible = self.openness == 255
  898.     else
  899.       @tail.visible = false
  900.     end
  901.   end
  902.   #--------------------------------------------------------------------------
  903.   # ○ テールの位置を計算
  904.   #--------------------------------------------------------------------------
  905.   def get_tale_pos
  906.     if defined?($game_system.show_stand_picture) #A1立ち絵スクリプトを入れている。
  907.       if $game_system.show_stand_picture #立ち絵on
  908.         pos = get_tale_pos_stand_pic
  909.       else
  910.         pos = get_tale_pos_normal
  911.       end
  912.     else
  913.       pos = get_tale_pos_normal
  914.     end
  915.     return pos
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # ○ テールの位置を計算/立ち絵使用時。※NAME_CHANGEの編集必須。
  919.   #--------------------------------------------------------------------------
  920.   def get_tale_pos_stand_pic
  921.     if $game_message.face_name != ""  and @tail != nil
  922.       name = A1_System::StandPicture::NAME_CHANGE[$game_message.face_name]
  923.       chara = name[$game_message.face_index][0]
  924.       if @stand_pic[chara] != nil #立ち絵無しの場合通常通り。
  925.         x = @stand_pic[chara].pic_sprite.x + @stand_pic[chara].pic_sprite.width / 2
  926.         y = get_tale_pos_normal_updown
  927.         update_tail_bitmap
  928.       else
  929.         return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。
  930.       end
  931.     else
  932.       return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。
  933.     end
  934.     return [x,y]
  935.   end
  936.   #--------------------------------------------------------------------------
  937.   # ○ テールの位置を計算/立ち絵未使用時。
  938.   #--------------------------------------------------------------------------
  939.   def get_tale_pos_normal
  940.     if $mes_id == (-2) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。
  941.       if $win_x != nil
  942.         if $win_x > 0
  943.           x = $win_x - @tail.width / 2
  944.           y = self.y + self.height / 2 - @tail.height / 2
  945.         elsif $win_x < 0
  946.           x = self.width - @tail.width / 2
  947.           y = self.y + self.height / 2 - @tail.height / 2
  948.         else
  949.           x = MINAS_TWE_X_POS
  950.           y = get_tale_pos_normal_updown
  951.         end
  952.       else
  953.         x = MINAS_TWE_X_POS
  954.         y = get_tale_pos_normal_updown
  955.       end
  956.     elsif $mes_id <= (-3) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。
  957.       if $win_x != nil
  958.         if $win_x > 0
  959.           x = $win_x - @tail.width / 2
  960.           y = self.y + self.height / 2
  961.         elsif $win_x < 0
  962.           x = self.width - @tail.width / 2
  963.           y = self.y + self.height / 2
  964.         else
  965.           x = MINAS_THREE_X_POS
  966.           y = get_tale_pos_normal_updown
  967.         end
  968.       else
  969.         x = MINAS_THREE_X_POS
  970.         y = get_tale_pos_normal_updown
  971.       end
  972.     else
  973.       character = get_character($mes_id)
  974.       #msgbox $mes_id
  975.       x = [[character.screen_x - 16, self.x].max, self.x + self.width - 32].min
  976.       if $win_x != nil
  977.         if $win_x > 0
  978.           x = $win_x - @tail.width / 2
  979.           y = character.screen_y
  980.         elsif $win_x < 0
  981.           x = self.width
  982.           y = character.screen_y
  983.         else
  984.           y = get_tale_pos_normal_updown
  985.         end
  986.       else
  987.         y = get_tale_pos_normal_updown
  988.       end
  989.     end
  990.     return [x, y]
  991.   end
  992.   #--------------------------------------------------------------------------
  993.   # ○ テールが上下の時、かつ[-2][-3]でない時のy座標の取得。
  994.   #--------------------------------------------------------------------------
  995.   def get_tale_pos_normal_updown
  996.     case @position
  997.     when 0
  998.       y = self.y + self.height - @tail.height / 2
  999.     else
  1000.       y = self.y - @tail.height / 2
  1001.     end
  1002.     return y
  1003.   end
  1004.   #--------------------------------------------------------------------------
  1005.   # ○ ふきだしを破棄
  1006.   #--------------------------------------------------------------------------
  1007.   def del_tail
  1008.     if @tail != nil
  1009.       @tail.dispose
  1010.       @tail = nil
  1011.     end
  1012.   end
  1013. end
  1014. #
  1015. # ▼▲▼ XRXS 9拡張CO-X. ふきだし自動設定 ▼▲▼
  1016. #==============================================================================
  1017. # ■ Window_Message
  1018. #==============================================================================
  1019. class Window_Message < Window_Base
  1020.   #--------------------------------------------------------------------------
  1021.   # ○ ポップキャラクターの設定
  1022.   #--------------------------------------------------------------------------
  1023.   def pop_character=(character_id)
  1024.     @pop_character = character_id
  1025.     $mes_id = character_id
  1026.   end
  1027.   #--------------------------------------------------------------------------
  1028.   # ○ テールキャラクターの設定
  1029.   #--------------------------------------------------------------------------
  1030.   def tail_character=(character_id)
  1031.     #@pop_character = character_id
  1032.     $mes_id = character_id
  1033.   end
  1034. end
  1035.  
  1036. #==============================================================================
  1037. # ■ Scene_Menu
  1038. #------------------------------------------------------------------------------
  1039. #  メニューを開いてからウィンドウが出るとネームウィンドウが表示される不具合修正。
  1040. #==============================================================================
  1041. #class Scene_Menu < Scene_MenuBase
  1042. #  def terminate_hukidasi_menyu
  1043. #    @name_window.openness = 0 if @name_window != nil
  1044. #    terminate_hukidasi_menyu_default
  1045. #  end
  1046. #  alias :terminate_hukidasi_menyu_default :terminate
  1047. #  alias :terminate :terminate_hukidasi_menyu
  1048. #end
  1049.  
  1050. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1051. #■ウィンドウ非表示ルーチン
  1052. #■吹きだしテールとネームウィンドウに対応。
  1053. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1054. #==============================================================================
  1055. # L(キーボードのQ)を押すと、メッセージウィンドウを表示?非表示
  1056. #==============================================================================
  1057. class Window_Message < Window_Base
  1058.   def update_winoff
  1059.     unless $game_party.in_battle #バトル中は無効。
  1060.       if Input.trigger?(Input::L)
  1061.         if self.visible == true
  1062.           self.visible = false
  1063.           @tail.visible = false if @tail != nil
  1064.         else
  1065.           self.visible = true
  1066.         end
  1067.         if @name_window != nil
  1068.           if @name_window.visible == false and $name != nil and $name != ""
  1069.             @name_window.visible = true
  1070.             @name_sprite.visible = true
  1071.           else
  1072.             @name_window.visible = false
  1073.             @name_sprite.visible = false
  1074.           end
  1075.         end
  1076.       elsif Input.trigger?(Input::C) or Input.trigger?(Input::B)
  1077.         self.visible = true if self.visible == false
  1078.         @tail.visible = true if @tail != nil and @tail.visible == false
  1079.         if @name_window != nil and $name != nil
  1080.           if $name != ""
  1081.             @name_window.visible = true
  1082.             @name_sprite.visible = true
  1083.           end
  1084.         end
  1085.       end
  1086.     end
  1087.     update_winoff_default
  1088.   end
  1089.   alias :update_winoff_default :update
  1090.   alias :update :update_winoff
  1091. end
  1092.  
  1093.  
  1094. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1095. #■ウィンドウ表示位置指定ルーチン
  1096. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1097. #===========================================================================
  1098. #イベントコマンド「スクリプト」を使い、
  1099. #$win_x=100 
  1100. #$win_y=100
  1101. #と入力すれば、ウィンドウを(100、100)の位置に表示します。
  1102. #使わない時は
  1103. #$win_x=nil
  1104. #などとnilを入力しておいてください。
  1105. #===========================================================================
  1106. class Window_Message < Window_Base
  1107.   #--------------------------------------------------------------------------
  1108.   # ● ウィンドウの背景と位置の設定 [再定義]
  1109.   #--------------------------------------------------------------------------
  1110.   def update_placement_position
  1111.     update_placement_position_default
  1112.     if $win_x != nil
  1113.       if $win_x > 0
  1114.         self.x = $win_x
  1115.         self.width -= $win_x
  1116.       else
  1117.         self.x = 0
  1118.         self.width += $win_x
  1119.       end
  1120.     end
  1121.     if $win_y != nil
  1122.       self.y = $win_y
  1123.     end
  1124.   end
  1125.   alias_method :update_placement_position_default, :update_placement
  1126.   alias_method :update_placement, :update_placement_position
  1127. end
  1128.  
  1129.  
  1130. #==============================================================================
  1131. # ■ SceneManager
  1132. #------------------------------------------------------------------------------
  1133. #  シーン遷移のさい、テールを破棄する。
  1134. #==============================================================================
  1135. module SceneManager
  1136.   #--------------------------------------------------------------------------
  1137.   # ● 呼び出し
  1138.   #--------------------------------------------------------------------------
  1139.   def self.call_sceman_hukidasi(scene_class)
  1140.     if defined?(self.scene.message_window)
  1141.       self.scene.message_window.del_tail if self.scene.message_window.tail != nil
  1142.     end
  1143.     @stack.push(@scene)
  1144.     [url=home.php?mod=space&uid=420706]@Scene[/url] = scene_class.new
  1145.   end
  1146.   #--------------------------------------------------------------------------
  1147.   # ● クラスメソッドのエイリアス
  1148.   #--------------------------------------------------------------------------
  1149.   class << self
  1150.     alias :call_sceman_hukidasi_default :call
  1151.     alias :call :call_sceman_hukidasi
  1152.   end
  1153. end
  1154.  
  1155. #==============================================================================
  1156. # ■ Scene_Map
  1157. #------------------------------------------------------------------------------
  1158. #  戦闘トランジションのさい、テールを破棄。
  1159. #==============================================================================
  1160. class Scene_Map < Scene_Base
  1161.   attr_accessor :message_window
  1162.   #--------------------------------------------------------------------------
  1163.   # ● 戦闘前トランジション実行
  1164.   #--------------------------------------------------------------------------
  1165.   def perform_battle_transition_hukidasi
  1166.     @message_window.del_tail #テールの破棄
  1167.     perform_battle_transition_hukidasi_default
  1168.   end
  1169.   alias_method :perform_battle_transition_hukidasi_default, :perform_battle_transition
  1170.   alias_method :perform_battle_transition, :perform_battle_transition_hukidasi
  1171. end


对话框里输入 \name[名字]

作者: tseyik    时间: 2015-3-29 11:02
本帖最后由 tseyik 于 2015-3-29 16:54 编辑

    #  Name Box:名字框位置
    #
    # \nb{text}   -在 namebox 顯示文本。
    # \nbl{text}  - namebox顯示在文字框左方
    # \nbr{text}  -右方
    # \nbt{text}  -上方
    # \nbb{text}  -下方
    # \nblt{text} - 左上
    # \nblb{text} -左下
    # \nbrt{text} -右上
    # \nbrb{text} -右下
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Message Size and Position:名字框,大小,位置(0 = 玩家; >0 = 事件)
    #
    # \fit   - Fits the window to this message (:paragraph_format must be false)
    # \e[n]  - Sets the text box in reference to character n(0 = 玩家; >0 = 事件)
    # \et[n] - Sets the text box above character n (0 = Player; >0 = Event)
    # \eb[n] - Sets the text box below character n (0 = Player; >0 = Event)
    # \el[n] - Sets the text box to the left of character n(0 = Player; >0 = Event)
    # \er[n] - Sets the text box to the right of character n(0 = Player; >0 = Event)
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Sound Effects:(音效)
    #
    # \lse - Turns the letter by letter SE on.
    # /lse - Turns the letter by letter SE off.
    # \pse - Turns the pause SE on.
    # /pse - Turns the pause SE off.
    # \fse - Turns the finish SE on.
    # /fse - Turns the finish SE off.
    # \tse - Turns the terminate SE on.
    # /tse - Turns the terminate SE off.
    # \pSE[file,x,y] - Play the "file" SE at volume x and pitch y
    # \pME[file,x,y] - Play the "file" ME at volume x and pitch y
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Other Effects:
    #
    # \pANIM[x,n] - Play the animation with ID n over character x
    # \pBLN[x,n] - Play the balloon with ID n over character x
    #=============================================================


  1.     #==============================================================================
  2.     #    ATS: Message Options [VXA]
  3.     #    Version: 1.0.7
  4.     #    Author: modern algebra (rmrk.net)
  5.     #    Date: 28 January 2013
  6.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7.     #  Description:
  8.     #
  9.     #    This script allows you to control a number of things about the message
  10.     #   window, such as its size and position. It also provides for scrolling
  11.     #   and review, and it includes the option to create a name window to identify
  12.     #   the speaker (or for any other use).
  13.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  14.     #  ATS Series:
  15.     #
  16.     #    This script is part of the Advanced Text System series of scripts. These
  17.     #   scripts are based off the Advanced Text System for RMVX, but since RMVX Ace
  18.     #   has a much more sensibly designed message system, it is no longer necessary
  19.     #   that it be one large script. For that reason, and responding to feedback on
  20.     #   the ATS, I have split the ATS into multiple different scripts so that you
  21.     #   only need to pick up the components for the features that you want. It is
  22.     #   therefore easier to customize and configure.
  23.     #
  24.     #    To find more scripts in the ATS Series, please visit:
  25.     #      http://rmrk.net/index.php/topic,44525.0.html
  26.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  27.     #  Instructions:
  28.     #
  29.     #    There are a lot of configuration options in this script, and I direct you
  30.     #   to the Editable Region at line 125 for detailed comments on what each does
  31.     #   Here, I will just list them:
  32.     #
  33.     #          :append_text                       :scrolling_on
  34.     #          :scroll_speed                      :pause_before_scroll
  35.     #          :scroll_by_page                    :scroll_review
  36.     #          :letter_sound_on                   :letter_se
  37.     #          :letters_per_se                    :random_pitch
  38.     #          :start_sound_on                    :start_se
  39.     #          :pause_sound_on                    :pause_se
  40.     #          :terminate_sound_on                :terminate_se
  41.     #          :finish_sound_on                   :finish_se
  42.     #          :message_windowskin                :message_dim_bg
  43.     #          :message_win_x                     :message_win_y
  44.     #          :character_size_offset             :do_not_obscure
  45.     #          :message_win_width                 :message_win_height
  46.     #          :message_win_padding               :fit_window_to_message
  47.     #          :fit_window_width_range            :fit_window_height_range
  48.     #          :name_win_min_width                :name_win_padding
  49.     #          :name_format                       :name_win_align
  50.     #          :name_win_x                        :name_win_y
  51.     #          :name_win_x_offset                 :name_win_y_offset
  52.     #
  53.     #    As with other ATS scripts, you can change the value of these options in
  54.     #   game with the following codes in a script call:
  55.     #
  56.     #      ats_next(:message_option, x)
  57.     #      ats_all(:message_option, x)
  58.     #
  59.     #   Where :message_option is the symbol you want and x is the value you want
  60.     #   to change it to. ats_next will only change it for the very next message,
  61.     #   while ats_all will change it for every message to follow.
  62.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  63.     #  List of Special Message Codes:
  64.     #
  65.     #    The following is a complete list of the message codes at your disposal.
  66.     #   Simply insert them into a Display Message command.
  67.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68.     #  Name Box:
  69.     #
  70.     # \nb{text}   - Shows the namebox with text displayed.
  71.     # \nbl{text}  - Shows the namebox left of the message with text displayed.
  72.     # \nbr{text}  - Shows the namebox right of the message with text displayed.
  73.     # \nbt{text}  - Shows the namebox above the message with text displayed.
  74.     # \nbb{text}  - Shows the namebox below the message with text displayed.
  75.     # \nblt{text} - Shows the namebox left and above with text displayed.
  76.     # \nblb{text} - Shows the namebox left and below with text displayed.
  77.     # \nbrt{text} - Shows the namebox right and above with text displayed.
  78.     # \nbrb{text} - Shows the namebox right and below with text displayed.
  79.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80.     #  Message Size and Position:
  81.     #
  82.     # \fit   - Fits the window to this message (:paragraph_format must be false)
  83.     # \e[n]  - Sets the text box in reference to character n(0 = Player; >0 = Event)
  84.     # \et[n] - Sets the text box above character n (0 = Player; >0 = Event)
  85.     # \eb[n] - Sets the text box below character n (0 = Player; >0 = Event)
  86.     # \el[n] - Sets the text box to the left of character n(0 = Player; >0 = Event)
  87.     # \er[n] - Sets the text box to the right of character n(0 = Player; >0 = Event)
  88.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  89.     #  Sound Effects:
  90.     #
  91.     # \lse - Turns the letter by letter SE on.
  92.     # /lse - Turns the letter by letter SE off.
  93.     # \pse - Turns the pause SE on.
  94.     # /pse - Turns the pause SE off.
  95.     # \fse - Turns the finish SE on.
  96.     # /fse - Turns the finish SE off.
  97.     # \tse - Turns the terminate SE on.
  98.     # /tse - Turns the terminate SE off.
  99.     # \pSE[file,x,y] - Play the "file" SE at volume x and pitch y
  100.     # \pME[file,x,y] - Play the "file" ME at volume x and pitch y
  101.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102.     #  Other Effects:
  103.     #
  104.     # \pANIM[x,n] - Play the animation with ID n over character x
  105.     # \pBLN[x,n] - Play the balloon with ID n over character x
  106.     #==============================================================================
  107.      
  108.     $imported = {} unless $imported
  109.     $imported[:ATS_MessageOptions] = true
  110.      
  111.     #==============================================================================
  112.     # ** Game_ATS
  113.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  114.     #  Summary of Changes:
  115.     #    new public instance variables - append_text; scrolling_on; scroll_speed;
  116.     #      pause_before_scroll; scroll_by_page; scroll_review; letter_sound_on;
  117.     #      letter_se; letters_per_se; random_pitch; start_sound_on; start_se;
  118.     #      pause_sound_on; pause_se; terminate_sound_on; terminate_se;
  119.     #      finish_sound_on; finish_se; message_windowskin; message_dim_bg;
  120.     #      message_win_x; message_win_y; character_size_offset; do_not_obscure;
  121.     #      message_win_width; message_win_height; message_win_padding;
  122.     #      fit_window_to_message; fit_window_width_range; fit_window_height_range;
  123.     #      name_win_min_width; name_win_padding; name_format; name_win_align;
  124.     #      name_win_x; name_win_y; name_win_x_offset; name_win_y_offset
  125.     #==============================================================================
  126.      
  127.     class Game_ATS
  128.       CONFIG ||= {}
  129.       CONFIG[:ats_message_options] = {
  130.               ats_message_options: true,
  131.         #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  132.         #  EDITABLE REGION
  133.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  134.         #  :append_text - Set this value to either true or false. If true, then any
  135.         # immediately subsequent display text event commands with the same settings
  136.         # will be joined together and they will show in the same message window if
  137.         # there is space. This option is primarily useful for message scrolling and
  138.         # oversized windows. If you are using ATS: Formatting, the value set in
  139.         # this script applies and the one set in ATS: Formatting does not.
  140.         append_text:           true,
  141.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  142.         # Scrolling
  143.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  144.         #  If :scrolling_on is false, then whenever a message ends, it will pause
  145.         # and create a new page. If :scrolling_on is true, then it will smoothly
  146.         # scroll instead, and you can choose whether to scroll line by line or
  147.         # by page. Practically, :append_text needs to be true for this feature to
  148.         # be useful.
  149.         scrolling_on:          true,
  150.           #  :scroll_speed - the pixels scrolled per frame when scrolling. If this
  151.           # is 0, then it will be instant.
  152.           scroll_speed:        2,
  153.           #  :pause_before_scroll - when this is true, the message will pause
  154.           # before the page (or line) scrolls.
  155.           pause_before_scroll: false,
  156.           #  :scroll_by_page - If this is true, then the message will scroll one
  157.           # whole page at a time. If it is false, it will scroll after each line.
  158.           scroll_by_page:      false,
  159.           #  :scroll_review - When this is true, then at each time the message
  160.           # pauses, the player can use the Up and Down directional keys to review
  161.           # the entire message
  162.           scroll_review:       true,
  163.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  164.         # Sound Effects
  165.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  166.         # Letter By Letter SE
  167.         #  :letter_sound_on - when this is true, the sound specified below will
  168.         # be played as letters are drawn, according to a chosen frequency.
  169.         letter_sound_on:       true,
  170.           #  :letter_se - This determines what sound effect is played when
  171.           # :letter_sound_on is true. You set it as an array, with the first entry
  172.           # being the filename as a string, and the other entries being integers
  173.           # representing the volume. EX: ["Cursor2", 60],
  174.           letter_se:           ["Cursor2"],
  175.           #  :letters_per_se - This determines how frequently :letter_se is played
  176.           # when :letter_sound_on is true. Basically, the number you put in the
  177.           # amount of letters that are drawn between each sound effect. If, for
  178.           # instance, it is 5, then 5 letters are drawn between playing the SE.
  179.           letters_per_se:      4,
  180.           #  :random_pitch - This range determines the pitch the sound effect is
  181.           # played at. It is in the form x...y and if x is equal to y, then the SE
  182.           # is always played at that pitch. If they are different, x must be less
  183.           # than y and each SE will play at a pitch randomly selected between the
  184.           # x and y. It is used to simulate changes of pitch in speech.
  185.           random_pitch:        100...100,
  186.         # Start SE
  187.         #  :start_sound_on - when this is true, the sound specified at :start_se
  188.         # will play whenever a message first opens.
  189.         start_sound_on:        false,
  190.           #  :start_se - This determines what sound effect is played when
  191.           # :start_sound_on is true. You set it as an array, with the first entry
  192.           # being the filename as a string, and the other entries being integers
  193.           # representing the volume and the pitch. EX: ["Chime2", 80, 50],
  194.           start_se:            ["Chime2"],
  195.         # Pause SE
  196.         #  :pause_sound_on - when this is true, the sound specified at :pause_se is
  197.         # played whenever a message pauses and waits for player input.
  198.         pause_sound_on:        false,
  199.           #  :pause_se - This determines what sound effect is played when
  200.           # :pause_sound_on is true. You set it as an array, with the first entry
  201.           # being the filename as a string, and the other entries being integers
  202.           # representing the volume and the pitch. EX: ["Decision2"],
  203.           pause_se:            ["Decision2"],
  204.         # Finish SE
  205.         #  :finish_sound_on - when this is true, the sound specified at :finish_se
  206.         # is played whenever a message finishes.
  207.         finish_sound_on:       false,
  208.           #  :finish_se - This determines what sound effect is played when
  209.           # :finish_sound_on is true. You set it as an array, with the first entry
  210.           # being the filename as a string, and the other entries being integers
  211.           # representing the volume and the pitch. EX: ["Chime1", 120],
  212.           finish_se:           ["Chime1"],
  213.         # Terminate SE
  214.         #  :terminate_sound_on - when this is true, the sound specified at
  215.         # :terminate_se is played whenever a message finishes.
  216.         terminate_sound_on:    false,
  217.           #  :terminate_se - This determines what sound effect is played when
  218.           # :terminate_sound_on is true. You set it as an array, with the first
  219.           # entry being the filename as a string, and the other entries being
  220.           # integers representing the volume and the pitch. EX: ["Cancel2"],
  221.           terminate_se:        ["Cancel2"],
  222.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  223.         # Message Window Settings
  224.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  225.         # Message Graphics
  226.         #  :message_windowskin - This sets the windowskin of the message window
  227.         # and all its related windows. The graphic chosen must be in the System
  228.         # folder of Graphics.
  229.         message_windowskin:    "Window",
  230.         #  :message_dim_bg - This feature allows you to replace the default dim
  231.         # background with an image of your choosing. Just set it to a filename. The
  232.         # graphic chosen must be in the System folder of Graphics
  233.         message_dim_bg:        "",
  234.         # Message Position
  235.         #  :message_win_x - This determines the x-coordinate of the message window.
  236.         # When set to -1, it is centred. When set to any other integer, it is
  237.         # directly set to that x-coordinate on the screen. This is completely
  238.         # overridden when you use message codes to set the message window in
  239.         # reference to a character.
  240.         message_win_x:         -1, # -1 = centred
  241.         #  :message_win_y - This determines the y-coordinate of the message window.
  242.         # When set to -1, it defaults to the position setting in the normal message
  243.         # window. When set to any other integer, it is directly set to that
  244.         # y-coordinate on the screen. This is completely overridden when you
  245.         # use message codes to set the message window in reference to a character.
  246.         message_win_y:         -1, # -1 = default to position
  247.         #  :character_size_offset - This feature is used when setting the message
  248.         # window's position in reference to a character, and it should be set to
  249.         # the size of the character (in the direction the window is being set). In
  250.         # other words, if setting a window to above or below the character, this
  251.         # should be set to the height of that character. If setting it to the left
  252.         # or right of a character, this should be set to the width of the character
  253.         character_size_offset: 32,
  254.         #  :do_not_obscure - This feature is only useful if :message_win_y is set
  255.         # to -1 and you are using the default position setting. Basically, if you
  256.         # put the ID of any character (0 is the player; otherwise the ID of the
  257.         # event you don't want to obscure) in this array, then the message window
  258.         # will be repositioned so as not to obscure that character. In other words,
  259.         # if you set this value to [0, 5], then the message window will never
  260.         # obscure either the player or the event with ID 5. So, if a message window
  261.         # is set to bottom, but drawing it at the bottom would cover the player,
  262.         # then the message window will instead be positioned to Top.
  263.         do_not_obscure:        [],
  264.         # Message Window Size
  265.         #  :message_win_width - This sets the width, in pixels, of the message
  266.         # window. It is overridden if :fit_window_to_message is true.
  267.         message_win_width:     544,
  268.         #  :message_win_height - This sets the height, in pixels, of the message
  269.         # window. A normal line of text is 24 pixels high. This value is overridden
  270.         # if :fit_window_to_message is true.
  271.         message_win_height:    120,
  272.         #  :message_win_padding - This value determines the size, in pixels, of the
  273.         # border of the message window
  274.         message_win_padding:   12,
  275.         #  :fit_window_to_message - when this is true, the message window's width
  276.         # will be fitted to the longest line and the message window's height will
  277.         # be set to include as many lines as possible. The sizes in both respects
  278.         # are limited by :fit_window_width_range and :fit_window_height_range. If
  279.         # you are using ATS: Formatting, then this feature will only work if
  280.         # :paragraph_format is off.
  281.         fit_window_to_message: false,
  282.           #  :fit_window_width_range - This is a range in the form x...y, where
  283.           # x must be less than y. x is the minimum width the window to which the
  284.           # window can be set when using :fit_window_to_message, while y is the
  285.           # maximum.
  286.           fit_window_width_range: 160...544,
  287.           #  :fit_window_height_range - This is a range in the form x...y, where
  288.           # x must be less than y. x is the minimum height the window to which the
  289.           # window can be set when using :fit_window_to_message, while y is the
  290.           # maximum.
  291.           fit_window_height_range: 72...144,
  292.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  293.         # Name Window Settings
  294.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  295.         # Name Window Size
  296.         #  :name_win_min_width - normally, the name window will be sized to fit
  297.         # whatever name is input in it. This value determines the minimum width
  298.         # that the name window can be, such that if the name is shorter, the
  299.         # name window will be set to this size.
  300.         name_win_min_width:    32,
  301.         #  :name_win_padding - this determines the size of the border of the name
  302.         # window. The default for most other windows is 12.
  303.         name_win_padding:      8,
  304.         # Name Format
  305.         #  :name_format - This allows you to set some default formatting for names.
  306.         # Basically, it is a string ('%s'), and the %s will be replaced by whatever
  307.         # name you set for the message. This allows you to use some special message
  308.         # codes for every name, without having to put it in. For instance, if you
  309.         # set this value to '\c[16]%s', then every name would automatically be set
  310.         # to colour 16.
  311.         name_format:          '%s',
  312.         #  :name_win_align - This sets the alignment of the name in the window.
  313.         # Since the window is normally sized to fit the name, this will generally
  314.         # only matter if the name is short enough to engage the :name_win_min_width
  315.         # or if there is more than one line in the name window.
  316.         name_win_align:       1,
  317.         # Name Position
  318.         #  :name_win_x - This sets the x-position of the name window. It can be set
  319.         # to either :l, :r, or an integer. If :l, it will be set flush with the left
  320.         # corners of the message window, offset by + :name_win_x_offset. If :r, it
  321.         # will be set flush with the right corners of the message window, offset
  322.         # by - :name_win_x_offset. If an integer, it will be directly set to that
  323.         # x-coordinate on the screen.
  324.         name_win_x:           :l,
  325.         #  :name_win_y - This sets the y-position of the name window. It can be set
  326.         # to either :t, :b, or an integer. If :t, it will be set flush with the top
  327.         # corners of the message window, offset by + :name_win_y_offset. If :b, it
  328.         # will be set flush with the bottom corners of the message window, offset
  329.         # by - :name_win_y_offset. If an integer, it will be directly set to that
  330.         # y-coordinate on the screen.
  331.         name_win_y:           :t,
  332.         #  :name_win_x_offset - this is the number of pixels offset when
  333.         # :name_win_x is set to :l or :r. When :l, it is added. When :r, it is
  334.         # subtracted.
  335.         name_win_x_offset:    8,
  336.         #  :name_win_y_offset - this is the number of pixels offset when
  337.         # :name_win_y is set to :t or :b. When :t, it is added. When :b, it is
  338.         # subtracted.
  339.         name_win_y_offset:    8,
  340.               #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  341.         #  END EDITABLE REGION
  342.         #////////////////////////////////////////////////////////////////////////
  343.       }
  344.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  345.       # * Public Instance Variables
  346.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  347.       CONFIG[:ats_formatting].delete(:append_text) if $imported[:ATS_Formatting]
  348.       CONFIG[:ats_message_options].keys.each { |key| attr_accessor key }
  349.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  350.       # * Overwrite SE methods
  351.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352.       [:letter_se, :start_se, :pause_se, :finish_se, :terminate_se].each { |method_name|
  353.         define_method(:"#{method_name}=") do |*args|
  354.           instance_variable_set(:"@#{method_name}", Game_ATS.set_sound_effect(*args))
  355.         end
  356.       }
  357.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  358.       # * Set Sound Effect
  359.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  360.       def self.set_sound_effect(settings)
  361.         return settings if settings.is_a?(RPG::SE)
  362.         settings = [settings] if settings.is_a?(String)
  363.         settings[1] = 80 if !settings[1]
  364.         RPG::SE.new(*settings)
  365.       end
  366.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  367.       # * Set Random Pitch
  368.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  369.       def random_pitch=(val)
  370.         @random_pitch = val.is_a?(Integer) ? letter_se.pitch..(letter_se.pitch + val) : val
  371.       end
  372.     end
  373.      
  374.     #==============================================================================
  375.     #  Initialize Common ATS Data if no other ATS script interpreted first
  376.     #==============================================================================
  377.      
  378.     if !$imported[:AdvancedTextSystem]
  379.       #============================================================================
  380.       # *** DataManager
  381.       #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  382.       #  Summary of Changes:
  383.       #    aliased method - create_game_objects; make_save_contents;
  384.       #      extract_save_contents
  385.       #============================================================================
  386.       module DataManager
  387.         class << self
  388.           alias modb_ats_crtgmobj_6yh7 create_game_objects
  389.           alias mlba_ats_mksave_5tg9 make_save_contents
  390.           alias ma_ats_extrcsvcon_8uj2 extract_save_contents
  391.         end
  392.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393.         # * Create Game Objects
  394.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  395.         def self.create_game_objects(*args, &block)
  396.           modb_ats_crtgmobj_6yh7(*args, &block)
  397.           $game_ats = Game_ATS.new
  398.           $game_ats.init_new_installs
  399.         end
  400.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  401.         # * Make Save Contents
  402.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403.         def self.make_save_contents(*args, &block)
  404.           contents = mlba_ats_mksave_5tg9(*args, &block)
  405.           contents[:ats] = $game_ats
  406.           contents
  407.         end
  408.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  409.         # * Extract Save Contents
  410.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  411.         def self.extract_save_contents(contents, *args, &block)
  412.           ma_ats_extrcsvcon_8uj2(contents, *args, &block)
  413.           $game_ats = contents[:ats] ? contents[:ats] : Game_ATS.new
  414.           $game_ats.init_new_installs
  415.         end
  416.       end
  417.      
  418.       #============================================================================
  419.       # ** Game_ATS
  420.       #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  421.       #  This class holds the default data for all scripts in the ATS series
  422.       #============================================================================
  423.      
  424.       class Game_ATS
  425.         def initialize; reset; end
  426.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  427.         # * Reset any or all installed ATS scripts
  428.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429.         def reset(script_name = nil)
  430.           if script_name.is_a? (Symbol) # If script to reset specified
  431.             CONFIG[script_name].each_pair { |key, value|
  432.               self.send("#{key}=".to_sym, value)
  433.               $game_message.send("#{key}=".to_sym, value)
  434.             }
  435.           else                          # Reset all ATS scripts
  436.             CONFIG.keys.each { |script| reset(script) }
  437.           end
  438.         end
  439.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  440.         # * Initialize any newly installed ATS scripts
  441.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  442.         def init_new_installs
  443.           CONFIG.keys.each { |script| reset(script) unless self.send(script) }
  444.         end
  445.       end
  446.      
  447.       #============================================================================
  448.       # ** Game_Message
  449.       #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  450.       #  Summary of Changes:
  451.       #    aliased method - clear
  452.       #============================================================================
  453.      
  454.       class Game_Message
  455.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  456.         # * Clear
  457.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  458.         alias mlb_ats_clrats_5tv1 clear
  459.         def clear(*args, &block)
  460.           mlb_ats_clrats_5tv1(*args, &block) # Run Original Method
  461.           return if !$game_ats
  462.           Game_ATS::CONFIG.values.each { |installed|
  463.             installed.keys.each { |key| self.send("#{key}=".to_sym, $game_ats.send(key)) }
  464.           }
  465.         end
  466.       end
  467.      
  468.       #============================================================================
  469.       # ** Game_Interpreter
  470.       #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  471.       #  Summary of Changes:
  472.       #    new methods - ats_all; ats_next
  473.       #============================================================================
  474.      
  475.       class Game_Interpreter
  476.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  477.         # * ATS All
  478.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  479.         def ats_all(sym, *args, &block)
  480.           $game_ats.send("#{sym}=".to_sym, *args, &block)
  481.           ats_next(sym, *args, &block)
  482.         end
  483.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484.         # * ATS Next
  485.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  486.         def ats_next(sym, *args, &block)
  487.           $game_message.send("#{sym}=".to_sym, *args, &block)
  488.         end
  489.       end
  490.     $imported[:AdvancedTextSystem] = true
  491.     end
  492.      
  493.     #==============================================================================
  494.     # ** Game_Message
  495.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  496.     #  Summary of Changes:
  497.     #    new attr_reader methods - show_on_character_id; show_on_character_pos
  498.     #    new attr_accessor methods - append_text; scrolling_on; scroll_speed;
  499.     #      pause_before_scroll; scroll_by_page; scroll_review; letter_sound_on;
  500.     #      letter_se; letters_per_se; random_pitch; start_sound_on; start_se;
  501.     #      pause_sound_on; pause_se; terminate_sound_on; terminate_se;
  502.     #      finish_sound_on; finish_se; message_windowskin; message_dim_bg;
  503.     #      message_win_x; message_win_y; character_size_offset; do_not_obscure;
  504.     #      message_win_width; message_win_height; message_win_padding;
  505.     #      fit_window_to_message; fit_window_width_range; fit_window_height_range;
  506.     #      name_win_min_width; name_win_padding; name_format; name_win_align;
  507.     #      name_win_x; name_win_y; name_win_x_offset; name_win_y_offset;
  508.     #      message_name
  509.     #    aliased method - clear; all_text
  510.     #    new methods - atsmo_play_sound?; atsmo_setup_name_window
  511.     #==============================================================================
  512.      
  513.     class Game_Message
  514.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  515.       # * Public Instance Variables
  516.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  517.       attr_reader :message_name
  518.       attr_reader :show_on_character_id
  519.       attr_reader :show_on_character_pos
  520.       Game_ATS::CONFIG[:ats_message_options].keys.each { |key| attr_accessor key }
  521.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  522.       # * Clear
  523.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  524.       alias maatsmo_cler_2yx7 clear
  525.       def clear(*args, &block)
  526.         @show_on_character_id = -1
  527.         @show_on_character_pos = :t
  528.         @message_name = nil
  529.         tso = @terminate_sound_on # Don't reset terminate sound
  530.         maatsmo_cler_2yx7(*args, &block) # Call Original Method
  531.         @terminate_sound_on = tso unless tso.nil?
  532.       end
  533.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  534.       # SE Definitions
  535.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  536.       [:letter, :start, :pause, :finish, :terminate].each { |method_name|
  537.         define_method(:"#{method_name}_se=") do |*args|
  538.           instance_variable_set(:"@#{method_name}_se", Game_ATS.set_sound_effect(*args))
  539.         end
  540.       }
  541.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  542.       # * Play Sound?
  543.       #    type : :letter, :start, :pause, :finish, or :terminate
  544.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  545.       def atsmo_play_sound?(type)
  546.         return instance_variable_get(:"@#{type}_sound_on") &&
  547.           !instance_variable_get(:"@#{type}_se").nil?
  548.       end
  549.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550.       # * Set Random Pitch
  551.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  552.       def random_pitch=(val)
  553.         @random_pitch = val.is_a?(Integer) ? letter_se.pitch..(letter_se.pitch + val) : val
  554.       end
  555.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556.       # * Set Name for Name Window
  557.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  558.       def message_name=(string)
  559.         @message_name = !@name_format.empty? ? sprintf(@name_format, string) : string
  560.       end
  561.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  562.       # * All Text
  563.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  564.       alias maatsmo_altx_7jv2 all_text
  565.       def all_text(*args, &block)
  566.         result = maatsmo_altx_7jv2(*args, &block) # Call Original Method
  567.         # Look for the Name Box Code
  568.         if result[/\\NB([LRTB]*)\{(.+?)\}/im]
  569.           atsmo_setup_name_window($2, $1)
  570.           result.gsub!(/\\NB([LRTB]*)\{(.+?)\}/im, "")
  571.         end
  572.         if result[/([\\\/])FIT/i]
  573.           @fit_window_to_message = $1 == "\\"
  574.           result.gsub!(/[\\\/]FIT/i, "")
  575.         end
  576.         if result[/\\E([LRTB]?)\[(\d+)\]/i]
  577.           @show_on_character_pos = $1.downcase.to_sym if !$1.empty?
  578.           @show_on_character_id = $2.to_i
  579.           # Don't show on character if the event referenced is nil
  580.           @show_on_character_id = -1 if show_on_character_id > 0 && !$game_map.events[show_on_character_id]
  581.           result.gsub!(/\\E[LRTB]?\[\d+\]/i, "")
  582.         end
  583.         result
  584.       end
  585.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  586.       # * Set Name
  587.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  588.       def atsmo_setup_name_window(name, pos)
  589.         self.message_name = name
  590.         pos.each_char {|letter|
  591.           val = letter.downcase.to_sym
  592.           case val
  593.           when :l, :r then self.name_win_x = val
  594.           when :t, :b then self.name_win_y = val
  595.           end
  596.         }
  597.       end
  598.     end
  599.      
  600.     #==============================================================================
  601.     # ** Game_Interpreter
  602.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  603.     #  Summary of Changes:
  604.     #    aliased methods - command_101; next_event_code
  605.     #    new method - maatsf_same_message_conditions?
  606.     #==============================================================================
  607.      
  608.     if !$imported[:ATS_Formatting]
  609.       class Game_Interpreter
  610.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  611.         # * Display Text Message
  612.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  613.         alias maatsf_disptext_3jf5 command_101
  614.         def command_101(*args, &block)
  615.           @ats_appending_text = $game_message.append_text
  616.           maatsf_disptext_3jf5(*args, &block) # Call Original Method
  617.           @ats_appending_text = false
  618.         end
  619.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  620.         # * Next Event Code
  621.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  622.         alias maatsf_nexcode_5rq9 next_event_code
  623.         def next_event_code(*args, &block)
  624.           result = maatsf_nexcode_5rq9(*args, &block) # Call Original Method
  625.           if @ats_appending_text && result == 101
  626.             if maats_same_message_conditions?(@index + 1)
  627.               @index += 1
  628.               result = next_event_code(*args, &block)
  629.             end
  630.           end
  631.           result
  632.         end
  633.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  634.         # * Same Message Conditions?
  635.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  636.         def maats_same_message_conditions?(list_index)
  637.           n_params = @list[list_index].parameters
  638.           if ($imported[:MA_CompositeGraphics] || $imported[:ATS_FaceOptions]) &&
  639.             @list[list_index + 1] && @list[list_index + 1].parameters[0][/^\\([AP])F\[(\d+)\]/i]
  640.             param = $2.to_i
  641.             actor = ($1 == 'A') ? $game_actors[param] : $game_party.members[param - 1]
  642.             return (actor.face_name == $game_message.face_name &&
  643.               actor.face_index == $game_message.face_index &&
  644.               n_params[2] == $game_message.background && n_params[3] == $game_message.position)
  645.           end
  646.           n_params[0] == $game_message.face_name && n_params[1] == $game_message.face_index &&
  647.             n_params[2] == $game_message.background && n_params[3] == $game_message.position
  648.         end
  649.       end
  650.     end
  651.      
  652.     unless $imported[:"MA_ParagraphFormat_1.0.1"] # Overwrite if earlier version
  653.       #============================================================================
  654.       # ** MA_Window_ParagraphFormat
  655.       #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  656.       #  This module inserts into Window_Base and provides a method to format the
  657.       # strings so as to go to the next line if it exceeds a set limit. This is
  658.       # designed to work with draw_text_ex, and a string formatted by this method
  659.       # should go through that, not draw_text.
  660.       #============================================================================
  661.      
  662.       module MA_Window_ParagraphFormat
  663.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  664.         # * Calc Line Width
  665.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  666.         def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
  667.           return tw if line.nil?
  668.           line = line.clone
  669.           unless contents_dummy
  670.             real_contents = contents # Preserve Real Contents
  671.             # Create a dummy contents
  672.             self.contents = Bitmap.new(contents_width, 24)
  673.             reset_font_settings
  674.           end
  675.           pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
  676.           test = @atsf_testing
  677.           @atsf_testing = true # This
  678.           while line[/^(.*?)\e(.*)/]
  679.             tw += text_size($1).width
  680.             line = $2
  681.             # Remove all ancillaries to the code, like parameters
  682.             code = obtain_escape_code(line)
  683.             # If direct setting of x, reset tw.
  684.             tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
  685.               ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
  686.             #  If I need to do something special on the basis that it is testing,
  687.             # alias process_escape_character and differentiate using @atsf_testing
  688.             process_escape_character(code, line, pos)
  689.           end
  690.           @atsf_testing = test
  691.           #  Add width of remaining text, as well as the value of pos[:x] under the
  692.           # assumption that any additions to it are because the special code is
  693.           # replaced by something which requires space (like icons)
  694.           tw += text_size(line).width + pos[:x]
  695.           unless contents_dummy
  696.             contents.dispose # Dispose dummy contents
  697.             self.contents = real_contents # Restore real contents
  698.           end
  699.           return tw
  700.         end
  701.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  702.         # * Format Paragraph
  703.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  704.         def mapf_format_paragraph(text, max_width = contents_width)
  705.           text = text.clone
  706.           #  Create a Dummy Contents - I wanted to boost compatibility by using the
  707.           # default process method for escape codes. It may have the opposite effect,
  708.           # for some :(
  709.           real_contents = contents # Preserve Real Contents
  710.           self.contents = Bitmap.new(contents_width, 24)
  711.           reset_font_settings
  712.           paragraph = ""
  713.           while !text.empty?
  714.             oline, nline, tw = mapf_format_by_line(text.clone, max_width)
  715.             # Replace old line with the new one
  716.             text.sub!(/#{Regexp.escape(oline)}/m, nline)
  717.             paragraph += text.slice!(/.*?(\n|$)/)
  718.             text.lstrip!
  719.           end
  720.           contents.dispose # Dispose dummy contents
  721.           self.contents = real_contents # Restore real contents
  722.           return paragraph
  723.         end
  724.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  725.         # * Format By Line
  726.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  727.         def mapf_format_by_line(text, max_width = contents_width)
  728.           oline, nline, tw = "", "", 0
  729.           loop do
  730.             #  Format each word until reach the width limit
  731.             oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
  732.             return oline, nline, tw if done
  733.           end
  734.         end
  735.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  736.         # * Format By Word
  737.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  738.         def mapf_format_by_word(text, line, tw, max_width)
  739.           return line, line, tw, true if text.nil? || text.empty?
  740.           # Extract next word
  741.           if text.sub!(/([ \t\r\f]*)(\S*)([\n\f]?)/, "") != nil
  742.             prespace, word, line_end = $1, $2, $3
  743.             ntw = mapf_calc_line_width(word, tw, true)
  744.             pw = contents.text_size(prespace).width
  745.             if (pw + ntw >= max_width)
  746.               # Insert
  747.               if line.empty?
  748.                 # If one word takes entire line
  749.                 return prespace + word, word + "\n", ntw, true
  750.               else
  751.                 return line + prespace + word, line + "\n" + word, tw, true
  752.               end
  753.             else
  754.               line += prespace + word
  755.               tw = pw + ntw
  756.               # If the line is force ended, then end
  757.               return line, line, tw, true if !line_end.empty?
  758.             end
  759.           else
  760.             return line, line, tw, true
  761.           end
  762.           return line, line, tw, false
  763.         end
  764.       end
  765.      
  766.       class Window_Base
  767.         include MA_Window_ParagraphFormat unless $imported[:"MA_ParagraphFormat_1.0"]
  768.       end
  769.      
  770.       $imported[:"MA_ParagraphFormat_1.0"] = true
  771.       $imported[:"MA_ParagraphFormat_1.0.1"] = true
  772.     end
  773.      
  774.     #==============================================================================
  775.     # *** MA Window ATS Message Options
  776.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  777.     #  This module mixes in with Window_Message and the Name window
  778.     #==============================================================================
  779.      
  780.     module MA_Window_ATS_MessageOptions
  781.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  782.       # * Resize
  783.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  784.       def resize(w, h)
  785.         if w != self.width || h != self.height
  786.           self.width = w
  787.           self.height = h
  788.           create_contents
  789.         end
  790.       end
  791.     end
  792.      
  793.     #==============================================================================
  794.     # ** Window_ATS_Name
  795.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  796.     #  This window shows a single message to identify the speaker of a message.
  797.     #==============================================================================
  798.      
  799.     class Window_ATS_Name < Window_Base
  800.       include MA_Window_ATS_MessageOptions
  801.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  802.       # * Object Initialization
  803.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  804.       def initialize(message_window)
  805.         @message_window = message_window
  806.         super(0, 0, $game_message.name_win_min_width, line_height + standard_padding*2)
  807.         @current_windowskin = windowskin
  808.         update_placement
  809.         self.visible = false
  810.         self.z = @message_window.z + 1
  811.       end
  812.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  813.       # * Frame Update
  814.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  815.       def update(*args, &block)
  816.         super(*args, &block)
  817.         if $game_message.message_name.nil?
  818.           self.visible = false
  819.         else
  820.           self.openness = @message_window.openness
  821.           self.visible = @message_window.visible
  822.           self.opacity = @message_window.opacity
  823.           self.back_opacity = @message_window.back_opacity
  824.           set_text($game_message.message_name)
  825.         end
  826.       end
  827.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  828.       # * Update Placement
  829.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  830.       def update_placement
  831.         set_x_position
  832.         set_y_position
  833.         update_padding
  834.       end
  835.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  836.       # * Set X Position
  837.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  838.       def set_x_position
  839.         self.x = case $game_message.name_win_x
  840.         when :l then @message_window.x + $game_message.name_win_x_offset
  841.         when :r then @message_window.x + @message_window.width - self.width - $game_message.name_win_x_offset
  842.         else $game_message.name_win_x
  843.         end
  844.       end
  845.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  846.       # * Set y Position
  847.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  848.       def set_y_position
  849.         case $game_message.name_win_y
  850.         when :t
  851.           self.y = @message_window.y - self.height + $game_message.name_win_y_offset
  852.           self.y = @message_window.y + @message_window.height - $game_message.name_win_y_offset if self.y < 0
  853.         when :b
  854.           self.y = @message_window.y + @message_window.height - $game_message.name_win_y_offset
  855.           self.y = @message_window.y - self.height + $game_message.name_win_y_offset if self.y + self.height > Graphics.height
  856.         else
  857.           self.y = $game_message.name_win_y
  858.         end
  859.       end
  860.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  861.       # * Refresh
  862.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  863.       def refresh
  864.         contents.clear
  865.         align = $game_message.name_win_align
  866.         if align > 0
  867.           y = 0
  868.           for line in convert_escape_characters(@text.clone).split(/\n/)
  869.             tw = mapf_calc_line_width(line)
  870.             x = align*((contents_width - tw) / 2)
  871.             draw_text_ex(x, y, line)
  872.             y += calc_line_height(line)
  873.           end
  874.         else
  875.           draw_text_ex(0, 0, @text)
  876.         end
  877.       end
  878.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  879.       # * Set Text
  880.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  881.       def set_text(text)
  882.         if text.is_a?(String) && (@text != text || $game_message.name_win_min_width > contents.width)
  883.           @text = text
  884.           resize(*calc_window_size_by_text(text)) unless text.empty?
  885.           update_placement
  886.           refresh
  887.         end
  888.       end
  889.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  890.       # * Calculate Width and Height
  891.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  892.       def calc_window_size_by_text(text)
  893.         text = convert_escape_characters(text.clone)
  894.         # Calculate width and height of window
  895.         fit_w = $game_message.name_win_min_width
  896.         h = standard_padding*2
  897.         text.split(/\n/).each { |line|
  898.           h += calc_line_height(line)
  899.           tw = mapf_calc_line_width(line)
  900.           fit_w = tw if tw > fit_w
  901.         }
  902.         w = [fit_w + (standard_padding*2), Graphics.width].min
  903.         return w, h
  904.       end
  905.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  906.       # * Standard Padding
  907.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  908.       def standard_padding
  909.         $game_message.name_win_padding
  910.       end
  911.     end
  912.      
  913.     #==============================================================================
  914.     # ** Window_Message
  915.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  916.     #  Summary of Changes:
  917.     #    aliased methods - initialize; create_all_windows; update_all_windows;
  918.     #      update_placement; convert_escape_characters
  919.     #    new method - maatsmo_convert_escape_characters; atsmo_update_placement_x;
  920.     #      atsmo_update_placement_y; atsmo_update_placement_w;
  921.     #      atsmo_update_placement_h;
  922.     #    overwritten method - process_new_line; standard padding;
  923.     #==============================================================================
  924.      
  925.     class Window_Message
  926.       include MA_Window_ATS_MessageOptions
  927.       IS_ATSF_ABOVE = $imported[:ATS_Formatting] # Check if Formatting installed
  928.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  929.       # * Object Initialization
  930.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  931.       alias maatsmo_initz_2uq7 initialize
  932.       def initialize(*args, &block)
  933.         @maatsmo_lblse_char_count = 0
  934.         @scroll_review_max_oy = 0
  935.         @atsmo_all_windows = []
  936.         maatsmo_initz_2uq7(*args, &block) # Call Original Method
  937.         @atsmo_old_windowskin = self.windowskin
  938.       end
  939.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  940.       # * Create All Windows
  941.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  942.       alias maatsmo_creatalwins_2jf4 create_all_windows
  943.       def create_all_windows(*args, &block)
  944.         @atsmo_all_windows.clear
  945.         maatsmo_creatalwins_2jf4(*args, &block) # Call Original Method
  946.         @atsmo_name_window = Window_ATS_Name.new(self)
  947.         @atsmo_all_windows.push(@gold_window, @choice_window, @number_window,
  948.           @item_window, @atsmo_name_window)
  949.       end
  950.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  951.       # * Create Back Bitmap
  952.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  953.       alias maatsmo_cretebbmp_3gl5 create_back_bitmap
  954.       def create_back_bitmap(*args, &block)
  955.         @back_bitmap.dispose if @back_bitmap && !@back_bitmap.disposed?
  956.         if $game_message.message_dim_bg.empty?
  957.           maatsmo_cretebbmp_3gl5(*args, &block)
  958.         else
  959.           @back_bitmap = Bitmap.new(width, height)
  960.           bbmp = Cache.system($game_message.message_dim_bg)
  961.           @back_bitmap.stretch_blt(@back_bitmap.rect, bbmp, bbmp.rect)
  962.         end
  963.         @back_sprite.bitmap = @back_bitmap if @back_sprite
  964.         @current_bbmp = $game_message.message_dim_bg
  965.       end
  966.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  967.       # * Standard Padding
  968.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  969.       def standard_padding
  970.         $game_message.message_win_padding # Get padding
  971.       end
  972.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  973.       # * Update All Windows
  974.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975.       alias maatsmo_updtallwin_8ih4 update_all_windows
  976.       def update_all_windows(*args, &block)
  977.         maatsmo_updtallwin_8ih4(*args, &block) # Call Original Method
  978.         @atsmo_name_window.update
  979.       end
  980.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  981.       # * Free All Windows
  982.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  983.       alias maatsmo_dispallwins_4bx9 dispose_all_windows
  984.       def dispose_all_windows(*args, &block)
  985.         maatsmo_dispallwins_4bx9(*args, &block) # Call Original Method
  986.         @atsmo_name_window.dispose
  987.       end
  988.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  989.       # * Update Windowskins
  990.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  991.       def atsmo_update_windowskin
  992.         new_wskin = Cache.system($game_message.message_windowskin)
  993.         # If windowskin is new and exists
  994.         if new_wskin != self.windowskin && new_wskin.width > 32
  995.           ([self] + @atsmo_all_windows).each { |win| win.windowskin = new_wskin }
  996.           @atsmo_name_window.set_text("") # Clear to redraw in right colour
  997.         end
  998.       end
  999.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1000.       # * Update Placement
  1001.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1002.       alias maatsmo_updplacem_3yg5 update_placement
  1003.       def update_placement(*args, &block)
  1004.         # Resize window
  1005.         resize(atsmo_update_placement_w, atsmo_update_placement_h)
  1006.         # Set X Position
  1007.         self.x = atsmo_update_placement_x
  1008.         # Set Y Position
  1009.         self.y = atsmo_update_placement_y(*args, &block) # Original Method, essentially
  1010.         update_padding
  1011.         @atsmo_name_window.update_placement
  1012.         create_back_bitmap if @current_bbmp != $game_message.message_dim_bg
  1013.       end
  1014.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1015.       # * Update X Position
  1016.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1017.       def atsmo_update_placement_x
  1018.         # Show on Character
  1019.         return show_on_character_x if $game_message.show_on_character_id >= 0
  1020.         # If not showing on character
  1021.         return $game_message.message_win_x == -1 ? # Centre or else direct set
  1022.           (Graphics.width - self.width) / 2 : $game_message.message_win_x
  1023.       end
  1024.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1025.       # * Update X in reference to character
  1026.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1027.       def show_on_character_x
  1028.         character = atsmo_get_character($game_message.show_on_character_id)
  1029.         x = case $game_message.show_on_character_pos
  1030.         when :t, :b then character.screen_x - (self.width / 2)
  1031.         when :l then character.screen_x - self.width - ($game_message.character_size_offset / 2)
  1032.         when :r then character.screen_x + ($game_message.character_size_offset / 2)
  1033.         else character.screen_x
  1034.         end
  1035.         [[x, Graphics.width - self.width].min, 0].max
  1036.       end
  1037.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1038.       # * Update Y Position
  1039.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1040.       def atsmo_update_placement_y(*args, &block)
  1041.         # Show on Character
  1042.         return show_on_character_y if $game_message.show_on_character_id >= 0
  1043.         # If not showing on a character
  1044.         if $game_message.message_win_y == -1
  1045.           do_not_obscure_characters unless $game_message.do_not_obscure.empty?
  1046.           maatsmo_updplacem_3yg5(*args, &block) # Call Original Method
  1047.           return self.y
  1048.         else
  1049.           @gold_window.y = $game_message.message_win_y > @gold_window.height ? 0 :
  1050.             Graphics.height - @gold_window.height
  1051.           return $game_message.message_win_y
  1052.         end
  1053.       end
  1054.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1055.       # * Update Y in reference to character
  1056.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1057.       def show_on_character_y
  1058.         character = atsmo_get_character($game_message.show_on_character_id)
  1059.         y = case $game_message.show_on_character_pos
  1060.         when :l, :r then character.screen_y - (($game_message.character_size_offset + self.height) / 2)
  1061.         when :t then character.screen_y - $game_message.character_size_offset - self.height
  1062.         when :b then character.screen_y
  1063.         end
  1064.         [[y, Graphics.height - self.height].min, 0].max
  1065.       end
  1066.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1067.       # * Update Message Window Width
  1068.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1069.       def atsmo_update_placement_w
  1070.         $game_message.message_win_width == -1 ? Graphics.width : $game_message.message_win_width
  1071.       end
  1072.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1073.       # * Update Message Window Height
  1074.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1075.       def atsmo_update_placement_h
  1076.         $game_message.message_win_height
  1077.       end
  1078.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1079.       # * Do Not Obstruct Characters
  1080.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1081.       def do_not_obscure_characters
  1082.         obscured = [0, 0, 0]
  1083.         positions = [2, 0, 1]
  1084.         positions.unshift(positions.delete($game_message.position))
  1085.         chosen_pos = positions[0]
  1086.         positions.each { |pos|
  1087.           y = ((Graphics.height - self.height) / 2)*pos
  1088.           range1 = y..(y + self.height)
  1089.           $game_message.do_not_obscure.each { |id|
  1090.             char = atsmo_get_character(id)
  1091.             next if char.nil?
  1092.             range2 = (char.screen_y - $game_message.character_size_offset)..char.screen_y
  1093.             obscured[pos] += 1 if range1 === range2.first || range2 === range1.first
  1094.           }
  1095.           chosen_pos = pos if obscured[pos] < obscured[chosen_pos]
  1096.         }
  1097.         $game_message.position = chosen_pos
  1098.       end
  1099.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1100.       # * Get Character
  1101.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1102.       def atsmo_get_character(id)
  1103.         id == 0 ? $game_player : $game_map.events[id]
  1104.       end
  1105.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1106.       # * Process All Text
  1107.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1108.       alias maatsmo_procsalltx_6fw2 process_all_text
  1109.       def process_all_text(*args, &block)
  1110.         # Play Start SE
  1111.         $game_message.start_se.play if $game_message.atsmo_play_sound?(:start)
  1112.         fit_window_to_message(convert_escape_characters($game_message.all_text.dup))
  1113.         atsmo_update_windowskin
  1114.         update_placement
  1115.         maatsmo_procsalltx_6fw2(*args, &block) # Call Original Method
  1116.         # Play Finish SE
  1117.         $game_message.finish_se.play if $game_message.atsmo_play_sound?(:finish)
  1118.       end
  1119.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1120.       # * Input Processing
  1121.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1122.       alias maatsmo_proceinpt_3rf6 process_input
  1123.       def process_input(*args, &block)
  1124.         # Don't play Pause Sound if Finish Sound played
  1125.         $game_message.pause_sound_on = false if $game_message.atsmo_play_sound?(:finish)
  1126.         maatsmo_proceinpt_3rf6(*args, &block)
  1127.       end
  1128.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1129.       # * Close Window and Wait for It to Fully Close
  1130.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1131.       alias maatsmo_closewat_4dr9 close_and_wait
  1132.       def close_and_wait(*args, &block)
  1133.         # Play Terminate SE
  1134.         $game_message.terminate_se.play if $game_message.atsmo_play_sound?(:terminate)
  1135.         $game_message.terminate_sound_on = $game_ats.terminate_sound_on
  1136.         maatsmo_closewat_4dr9(*args, &block) # Call Original Method
  1137.       end
  1138.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1139.       # * New Page
  1140.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1141.       alias maatsmo_newpge_3rj8 new_page
  1142.       def new_page(*args, &block)
  1143.         # Reset Contents size
  1144.         create_contents if contents.height > contents_height
  1145.         self.oy = 0
  1146.         maatsmo_newpge_3rj8(*args, &block) # Call Original Method
  1147.       end
  1148.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1149.       # * Convert Escape Characters
  1150.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1151.       if instance_methods(false).include?(:convert_escape_characters)
  1152.         # If convert_escape_characters already defined in Window_Message, just alias
  1153.         alias maatsmo_cnvrscchrc_7yc3 convert_escape_characters
  1154.         def convert_escape_characters(*args, &block)
  1155.           maatsmo_convert_escape_characters(maatsmo_cnvrscchrc_7yc3(*args, &block))
  1156.         end
  1157.       else
  1158.         # If convert_escape_characters undefined in Window_Message, call super method
  1159.         def convert_escape_characters(*args, &block)
  1160.           maatsmo_convert_escape_characters(super(*args, &block))
  1161.         end
  1162.       end
  1163.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1164.       # * ATS MO Convert Escape Characters
  1165.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1166.       def maatsmo_convert_escape_characters(text)
  1167.         # Sound Effects
  1168.         text.gsub!(/\eP_?([MS]E)\[\s*\"?([^\",\]]+)\"?(.*?)\]/i) { "\ePLAYSOUND\[#{$1.upcase},\"#{$2}\"#{$3.gsub(/ /, "")}\]" }
  1169.         text.gsub!(/\eP_?(ANIM|BLN)\[\s*(\d+)[\s,:;]*(\d+)\s*\]/i) { "\eANIMATION\[#{$1.upcase == "ANIM" ? 0 : 1},#{$2},#{$3}\]" }
  1170.         letter_ary = ["L", "P", "F", "T"]
  1171.         # Turn Sound Effects on or off
  1172.         text.gsub!(/([\e\/])([LPFT])SE/i) {
  1173.           num = ($1 == "\e" ? 0 : 1) + (2*letter_ary.index($2.upcase))
  1174.           "\eATSMOSE\[#{num}\]" }
  1175.         return text
  1176.       end
  1177.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1178.       # * Process Escape Character
  1179.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1180.       alias maatasmo_procescchar_2ia4 process_escape_character
  1181.       def process_escape_character(code, text, *args, &block) # (code, text, pos)
  1182.         case code.upcase
  1183.         when 'ATSMOSE'
  1184.           param = obtain_escape_param(text)
  1185.           return if @atsf_testing
  1186.           case param / 2
  1187.           when 0 then $game_message.letter_sound_on = (param == 0)    # Letter Sound
  1188.           when 1 then $game_message.pause_sound_on = (param == 2)     # Pause Sound
  1189.           when 2 then $game_message.finish_sound_on = (param == 4)    # Finish Sound
  1190.           when 3 then $game_message.terminate_sound_on = (param == 6) # Terminate Sound
  1191.           end
  1192.         when 'PLAYSOUND'
  1193.           return unless text.slice!(/^\[([MS]E),\"(.+?)\",?(\d*),?(\d*)\]/i)
  1194.          return if @atsf_testing
  1195.          RPG.const_get($1.to_sym).new($2, $3.empty? ? 80 : $3.to_i, $4.empty? ? 100 : $4.to_i).play
  1196.        when 'ANIMATION'
  1197.          return unless text.slice!(/^\[(\d+),(\d+),(\d+)\]/)
  1198.          return if @atsf_testing
  1199.          character = atsmo_get_character($2.to_i)
  1200.          if character
  1201.            case $1.to_i
  1202.            when 0 then character.animation_id = $3.to_i
  1203.            when 1 then character.balloon_id = $3.to_i
  1204.            end
  1205.          end
  1206.        else
  1207.          maatasmo_procescchar_2ia4(code, text, *args, &block) # Run Original Method
  1208.        end
  1209.      end
  1210.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1211.      # * Process Normal Character
  1212.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1213.      alias maatsmo_prcssnrmlch_3kz8 process_normal_character
  1214.      def process_normal_character(c, pos, *args, &block)
  1215.        maatsmo_prcssnrmlch_3kz8(c, pos, *args, &block) # Call Original Method
  1216.        # Play SE if not showing fast and the letter sound is on
  1217.        maatsmo_play_letter_by_letter_se if $game_message.atsmo_play_sound?(:letter) &&
  1218.          !@show_fast && !@line_show_fast
  1219.      end
  1220.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1221.      # * New Line Character Processing
  1222.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1223.      alias maatsmo_procnewlin_3jd8 process_new_line
  1224.      def process_new_line(text, pos, *args)
  1225.        if $game_message.scrolling_on # If using scrolling
  1226.          @line_show_fast = false
  1227.          super
  1228.          if $imported[:ATS_Formatting] && IS_ATSF_ABOVE
  1229.            maatsf_paragraph_new_line(method(:maatsmo_process_new_line_scroll), text, pos)
  1230.          else
  1231.            maatsmo_process_new_line_scroll(text, pos)
  1232.          end
  1233.        else # Not using scrolling, so no need to interfere with this method
  1234.          maatsmo_procnewlin_3jd8(text, pos, *args) # Call Original Method
  1235.        end
  1236.      end
  1237.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1238.      # * New Line Character Processing when scrolling
  1239.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1240.      def maatsmo_process_new_line_scroll(text, pos)
  1241.        if need_new_page?(text, pos)
  1242.          # Only pause if demanded
  1243.          input_pause if $game_message.pause_before_scroll && !@pause_skip
  1244.          scroll_h = !$game_message.scroll_by_page ? pos[:y] + pos[:height] : # Line
  1245.            contents.height + (pos[:y] - self.oy) # Page
  1246.          atsmo_scroll_page(text, pos, scroll_h)
  1247.          @show_fast = false # Don't speed through entire message
  1248.        end
  1249.      end
  1250.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1251.      # * Wait / Wait for One Character / Process Input
  1252.      #``````````````````````````````````````````````````````````````````````````
  1253.      # Do not permit these to run when testing
  1254.      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1255.      [:wait, :wait_for_one_character].each { |meth|
  1256.        alias_method(:"maatsmo_#{meth}_6hb1", meth)
  1257.         define_method(meth) do |*args|
  1258.           send(:"maatsmo_#{meth}_6hb1", *args) unless @atsf_testing
  1259.         end
  1260.       }
  1261.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1262.       # * Input Pause
  1263.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1264.       alias maatsmo_inppuse_3kx5 input_pause
  1265.       def input_pause(*args, &block)
  1266.         return if @atsf_testing
  1267.         # Play Pause SE
  1268.         $game_message.pause_se.play if $game_message.atsmo_play_sound?(:pause) # Play
  1269.         if $game_message.scroll_review && self.oy > 0
  1270.           # If scroll review, need to overwrite this method
  1271.           self.pause = true
  1272.           wait(10)
  1273.           @scroll_review_max_oy = contents.height - contents_height
  1274.           until Input.trigger?(:B) || Input.trigger?(:C)
  1275.             update_scroll_review
  1276.             Fiber.yield
  1277.           end
  1278.           self.oy = @scroll_review_max_oy
  1279.           Input.update
  1280.           self.pause = false
  1281.         else
  1282.           maatsmo_inppuse_3kx5(*args, &block) # Call Original Method
  1283.         end
  1284.       end
  1285.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1286.       # * Play Letter By Letter SE
  1287.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1288.       def maatsmo_play_letter_by_letter_se
  1289.         # If drawn enough letters to play the SE
  1290.         if @maatsmo_lblse_char_count >= $game_message.letters_per_se
  1291.           @maatsmo_lblse_char_count = 0
  1292.           $game_message.letter_se.pitch = $game_message.random_pitch.first
  1293.           unless $game_message.random_pitch.first >= $game_message.random_pitch.last
  1294.             # Randomize pitch
  1295.             $game_message.letter_se.pitch += rand($game_message.random_pitch.last - $game_message.random_pitch.first)
  1296.           end
  1297.           $game_message.letter_se.play # Play Letter by Letter SE
  1298.         else
  1299.           @maatsmo_lblse_char_count += 1 # Advance character count
  1300.         end
  1301.       end
  1302.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1303.       # * Resize Contents
  1304.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1305.       def resize_contents(w, h)
  1306.         bmp = contents # Save old contents
  1307.         self.contents = Bitmap.new(w, h)
  1308.         self.contents.font = bmp.font.dup
  1309.         self.contents.blt(0, 0, bmp, bmp.rect) # Draw old contents onto new
  1310.         bmp.dispose
  1311.       end
  1312.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1313.       # * Fit Window to Message
  1314.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1315.       def fit_window_to_message(text)
  1316.         # Fit window to message if longes
  1317.         if !($imported[:ATS_Formatting] && $game_message.paragraph_format) &&
  1318.           $game_message.fit_window_to_message
  1319.           w, h = 0, 0
  1320.           for line in text.split(/[\n\r]+/)
  1321.             lw = mapf_calc_line_width(line) + new_line_x
  1322.             w = lw if lw > w
  1323.             h += calc_line_height(line)
  1324.           end
  1325.           $game_message.message_win_width = [$game_message.fit_window_width_range.last,
  1326.             [w + (standard_padding*2), $game_message.fit_window_width_range.first].max].min
  1327.           $game_message.message_win_height = [$game_message.fit_window_height_range.last,
  1328.             [h + (standard_padding*2), $game_message.fit_window_height_range.first].max].min
  1329.         end
  1330.       end
  1331.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1332.       # * Scroll to Next Line
  1333.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1334.       def atsmo_scroll_page(text, pos, height)
  1335.         resize_contents(contents.width, height)
  1336.         goal_oy = contents.height - contents_height
  1337.         if $game_message.scroll_speed <= 0
  1338.           self.oy = goal_oy # Instant scroll
  1339.         else
  1340.           until self.oy == goal_oy # Scroll until goal reached
  1341.             self.oy += [$game_message.scroll_speed, goal_oy - self.oy].min
  1342.             Fiber.yield
  1343.           end
  1344.         end
  1345.       end
  1346.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1347.       # * Update Scroll Review
  1348.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1349.       def update_scroll_review
  1350.         if Input.press?(:UP)
  1351.           self.oy -= [4, self.oy].min
  1352.         elsif Input.press?(:DOWN) # self.oy = contents.height - contents_height
  1353.           self.oy += [4, @scroll_review_max_oy - self.oy].min
  1354.         end
  1355.       end
  1356.     end
  1357.      
  1358.     #==============================================================================
  1359.     # ** Window_ChoiceList
  1360.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1361.     #  Summary of Changes:
  1362.     #    aliased method - update_placement
  1363.     #==============================================================================
  1364.      
  1365.     class Window_ChoiceList
  1366.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1367.       # * Update Window Position
  1368.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1369.       alias maatsmo_updplace_3ib6 update_placement
  1370.       def update_placement(*args, &block)
  1371.         maatsmo_updplace_3ib6(*args, &block) # Call original method
  1372.         if !$imported[:ATS_AdvancedChoices]
  1373.           self.x = @message_window.x
  1374.           self.x += @message_window.width - self.width unless $game_message.name_win_x == :r
  1375.         end
  1376.       end
  1377.     end

复制代码

作者: 矮矮人    时间: 2015-3-29 11:07
谢谢上面各位,我去试下
作者: 291144925    时间: 2015-4-5 15:08
楼楼!你右边那个图的脚本分享下吧{:2_281:},就是姓名框写着少女,的那个脚本!
作者: 291144925    时间: 2015-4-5 15:10
tseyik 发表于 2015-3-29 11:02
#  Name Box:名字框位置
    #
    # \nb{text}   -在 namebox 顯示文本。

大大!脚本怎么这么长?一千多行,另外我复制了这个脚本,但是不知道怎么用,还是没显示姓名框!
求大大救我,我是新手蛋子!
作者: tseyik    时间: 2015-4-5 15:57
本帖最后由 tseyik 于 2015-4-5 16:10 编辑
291144925 发表于 2015-4-5 15:10
大大!脚本怎么这么长?一千多行,另外我复制了这个脚本,但是不知道怎么用,还是没显示姓名框!{:5_158: ...


    # \nb{text}   -在 namebox 顯示文本。
    # \nbl{text}  - namebox顯示在文字框左方
    # \nbr{text}  -右方
    # \nbt{text}  -上方
    # \nbb{text}  -下方
    # \nblt{text} - 左上
    # \nblb{text} -左下
    # \nbrt{text} -右上
    # \nbrb{text} -右下
不是寫得清清楚楚麼?



作者: 18021392442    时间: 2015-4-5 16:31
  1. #用法
  2. #事件中加入
  3. #脚本
  4. #@name_window = Window_Name.new
  5. #@name_window.set_text("路人甲")
  6. #显示文字 “”
  7. #脚本
  8. #@name_window.dispose
  9. class Window_Name < Window_Base
  10.   #--------------------------------------------------------------------------
  11.   # ● 初始化对象
  12.   #--------------------------------------------------------------------------
  13.   def initialize(line_number = 1)
  14.     super(0,250, 120, fitting_height(line_number))
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 设置内容
  18.   #--------------------------------------------------------------------------
  19.   def set_text(text)
  20.     if text != @text
  21.       @text = text
  22.       refresh
  23.       show
  24.     end
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 清除
  28.   #--------------------------------------------------------------------------
  29.   def clear
  30.     set_text("")
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 刷新
  34.   #--------------------------------------------------------------------------
  35.   def refresh
  36.     contents.clear
  37.     draw_text_ex(4, 0, @text)
  38.   end
复制代码

作者: 18021392442    时间: 2015-4-5 16:36
C:\Users\Administrator\Desktop\QQ.png
作者: 291144925    时间: 2015-4-5 17:03
tseyik 发表于 2015-4-5 15:57
# \nb{text}   -在 namebox 顯示文本。
    # \nbl{text}  - namebox顯示在文字框左方
    # \nbr{te ...

谢谢亲爱的!
作者: zxc123a4s5d6    时间: 2015-4-5 23:11
tseyik 发表于 2015-3-29 11:02
#  Name Box:名字框位置
    #
    # \nb{text}   -在 namebox 顯示文本。

用这个脚本后连续同一个人的对话会自动整合为一个对话框,怎么解决?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1