查看: 1122|回复: 0

[已经过期] 如何设置fuki对话框中显示姓名位置的背景图?

[复制链接]
梦石
0
星屑
55
在线时间
36 小时
注册时间
2013-12-15
回帖
7
发表于 2016-8-22 19:48:17 | 显示全部楼层 |阅读模式

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

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

×
插件代码见后
目标是将姓名位置的背景从那个系统默认改成自己设置的PNG
试过skin插件失败,CACHE命令也不行
求指教
  1. =begin
  2. 吹きだしウィンドウVXAce

  3. 2011.12.25 tamura改造
  4. 2012年02月28日 改訂

  5. ※このスクリプトは、ちいさな本屋様([url]http://xrxs.at-ninja.jp/[/url])
  6. が製作されたものをtamuraがACE用に改造した物です。

  7. 原版:
  8. ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
  9. publish 2010/ 3/ 2
  10. update  - 11/ 1/10a


  11. ※※警告※※
  12. 「立ち絵機能」をONにしている時に、立ち絵を表示せずに、ウィンドウ位置を
  13. 右か左に変更した時、テールのY座標がずれるようです。
  14. 原因は調査中です。立ち絵を表示しない時は、イベントコマンド「注釈」で、
  15. 「立ち絵表示 off」と記述して立ち絵機能をOFFにしておいてください。

  16. ●機能一覧
  17. ?イベントコマンド「スクリプト」で、$win_x $win_yに値を入力すると、
  18.  ($win_x 、$win_y)の位置にウィンドウを表示する。画面左上が(0,0)。

  19. ?キーボードのQ(装備画面で前のキャラに戻るボタン)を押すと、
  20.  ウィンドウが消える。Qか決定、キャンセルキーで元に戻る。

  21. ?文章のどこでもいいので、以下の表記を行う。
  22. ? \name[] : []の中の文字を、ウィンドウ左上に小さく表示する。

  23. \h[-1] : プレーヤーの上にウィンドウをポップ。
  24. \h[0] : 現在アクティブのイベントの上にウィンドウをポップ。
  25. \h[1] : IDが1番のイベントの上にウィンドウをポップする。
  26. hは大文字でもOK。

  27. ウィンドウは通常の大きさのまま、テールだけ表示したい場合は、
  28. \t[-2] : ウィンドウが上下に表示される時は、X座標をMINAS_TWE_X_POSで固定。
  29.            $win_x で左右に表示される時は、Y座標がウィンドウの中心やや下で固定。
  30. \t[-3] : ウィンドウが上下に表示される時は、X座標をMINAS_THREE_X_POSで固定。
  31.            $win_x で左右に表示される時は、Y座標がウィンドウの中心やや下で固定。
  32. \t[-1] : プレーヤーの上に向かってテール表示。
  33. \t[0] : 現在アクティブのイベントに向かってテール表示。
  34. \t[1] : IDが1番のイベントの上に向かってテール表示。

  35. \O[128] : 文字を透明にする。128はalphaの値で、0で透明、255で通常。
  36. \D : 文字に影をつける
  37. \hold : メッセージ表示の、最後の文章に限定。
  38.      メッセージが終わっても、ウィンドウを閉じずに残します。
  39.      他のメッセージが表示されて次へ送られる時に消えます。
  40.      なお、ホールドされているウィンドウは、Qボタンで消せません。


  41. ●その他
  42. ?ACEに標準装備されている機能は通常通り使用できます。
  43. ?A1殿([url]http://a1tktk.web.fc2.com/[/url])の立ち絵スクリプトに対応しています。
  44.  このスクリプトの上に「RGSS3用A1共通処理」
  45.  このスクリプトの下に「空メッセージでウィンドウを開かない」「立ち絵表示」を
  46.  配置して下さい。
  47.  残念ながら、「ネームウィンドウ」は使えません。上記\nameをお使いください。
  48. ※立ち絵を表示しない時は、注釈で「立ち絵表示 off」とした方が無難です。
  49. ?イベントの下から話しかけたら上へポップ、上から話しかけたら下へポップするという
  50.  機能を追加。カスタマイズポイントで POP_DIRECTION = ture と変更のこと。


  51. ●廃止機能 
  52. ?\Iがすでに使われているので、イタリック文字変換を廃止。
  53. ?スピード変更、改行、最後に入手したアイテムの表示を、ACE化にともない廃止。


  54. 【改訂履歴】
  55. 2012.01.10  ?ウィンドウを消したまま次のウィンドウを自動で表示すると、
  56.               ネームウィンドウが表示されるのを修正。
  57. 2012.01.11  ?ネームウィンドウが出しっぱなしになるのを修正。
  58. 2012.01.12  ?メニューを出してから決定ボタンを押すとネームウィンドウがでる不具合の修正。
  59. 2012.02.01 ?ネームウィンドウのオープン&クローズのタイミングを変更。
  60.       ?hold機能を追加。
  61. 2012.02.10 ?キャラポップした時、一行ずつしか表示されない不具合を修正。
  62. 2012.02.14 ?アイテム名などの文字数が正常に取得できなかったのを修正。
  63. 2012.02.21 ?話しかけられた方向によって、ポップ方向を変えられるようにした。
  64. 2012.02.25 ?すべてのシーン遷移の際はテールを破棄(イベント中でショップ起動など)
  65. 2012.02.28 ?エスケープ文字の処理が上手くいかない問題について暫定対策。

  66. =end

  67. #==============================================================================
  68. # カスタマイズポイント
  69. #==============================================================================
  70. #=begin
  71. class Window_Message < Window_Base
  72.   #
  73.   # 基本行数
  74.   #
  75.   MAX_LINE = 4
  76.   #
  77.   # \p[] - キャラポップの高さ
  78.   #
  79.   CHARPOP_HEIGHT = 40
  80.   #
  81.   # \name[] - 名前枠 X,Y座標
  82.   #
  83.   NAME_WINDOW_OFFSET_X =   0
  84.   NAME_WINDOW_OFFSET_Y = -24
  85.   #
  86.   #
  87.   MINAS_TWE_X_POS = 100 # $t[-2]のときの、テールのX座標。
  88.   MINAS_THREE_X_POS = 444 # $t[-3]のときの、テールのX座標。

  89.   POP_DIRECTION = false #イベントの方向を考慮。
  90. end
  91. #==============================================================================
  92. # 参照機能
  93. #==============================================================================
  94. class Game_Temp
  95.   attr_accessor :last_gain_material
  96.   attr_accessor :last_gain_holder
  97. end
  98. #==============================================================================
  99. # フルグレードアップベース - 制御文字?基本機能
  100. #==============================================================================
  101. class Window_Message < Window_Base
  102.   attr_accessor :tail
  103.   #--------------------------------------------------------------------------
  104.   # ● 特殊文字の変換 + 準備
  105.   #     変換?消去してもいい部分を処理、フラグのセット。
  106.   #--------------------------------------------------------------------------
  107.   alias xrxsv2_convert_escape_characters convert_escape_characters
  108.   def convert_escape_characters(text)
  109.     #@textsが使いずらいので、ここで別変数に保管。
  110.     @all_texts = []
  111.     str = text.gsub(/\\/) { "\e" }
  112.     @all_texts = str.split("\n")

  113.     # 初期化
  114.     contents.font.size   = Font.default_size
  115.     contents.font.bold   = Font.default_italic
  116.     contents.font.italic = Font.default_bold
  117.     contents.font.shadow = Font.default_shadow
  118.     @type_wait = 0
  119.     @line_widths = []
  120.     @line_aligns = []
  121.     self.pop_character = nil
  122.     # ウィンドウ保持指定\holdがあるか?
  123.     @window_hold = (text.gsub!(/\\hold/) { "" } != nil)
  124.     # \info
  125.     @info_mode = (text.gsub!(/\\info/) { "" } != nil)
  126.     # 改行削除指定\_があるか?
  127.     if (/\\_(.*?)\x00/.match(@text)) != nil
  128.       $game_message.choice_start -= 1
  129.       text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
  130.     end
  131.     # \name 判定
  132.     if text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  133.       name = $1
  134.       bitmap = @name_sprite.bitmap
  135.       w = [bitmap.text_size(name).width, 1].max
  136.       bitmap.dispose
  137.       @name_sprite.bitmap = Bitmap.new(w, 32)
  138.       bitmap = @name_sprite.bitmap
  139.       bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
  140.       @name_window.width = w + 16
  141.       @name_window.create_contents
  142.       @name_window.open if @name_window.openness == 0
  143.       if self.visible #名前だけ表示されるのを防止。
  144.         @name_window.visible = true
  145.         @name_sprite.visible = true
  146.       else
  147.         @name_window.visible = false
  148.         @name_sprite.visible = false
  149.       end
  150.     else
  151.       @name_window.visible = false
  152.       @name_sprite.visible = false
  153.       @name_sprite.bitmap.dispose
  154.       @name_sprite.bitmap = Bitmap.new(32,32)
  155.     end
  156.     $name = $1 #あれこれで使うので、ネームウィンドウに表示予定の名前を取得。
  157.     # キャラボップモード
  158.     if text.gsub!(/\\[Hh]\[-1\]/) { "" }
  159.       self.pop_character = -1
  160.     elsif text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "" }
  161.       self.pop_character = $1.to_i
  162.     elsif text.gsub!(/\\[Hh]/) { "" }
  163.       self.pop_character = 0
  164.     #テール表示モード
  165.     elsif text.gsub!(/\\[Tt]\[-1\]/) { "" }
  166.       self.tail_character = -1
  167.     elsif text.gsub!(/\\[Tt]\[-2\]/) { "" }
  168.       self.tail_character = -2
  169.     elsif text.gsub!(/\\[Tt]\[-3\]/) { "" }
  170.       self.tail_character = -3
  171.     elsif text.gsub!(/\\[Tt]\[([0-9]+)\]/) { "" }
  172.       self.tail_character = $1.to_i
  173.     elsif text.gsub!(/\\[Tt]/) { "" }
  174.       self.tail_character = 0
  175.     else
  176.       self.pop_character = nil
  177.     end

  178.     # 制御文字処理
  179.     text = xrxsv2_convert_escape_characters(text)
  180.     text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\eS[#{$1}]" }
  181.     text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\eO[#{$1}]" }
  182.     text.gsub!(/\\last_holder/i) { "\e18" }
  183.     text.gsub!(/\\last_material/i) { "\e19" }
  184.     text.gsub!(/\\B/) { "\eB" }
  185.     text.gsub!(/\\D/) { "\eD" }
  186.     #text.gsub!(/\\n/) { "\n" }
  187.     #
  188.     # ライン情報の取得
  189.     rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
  190.       /\[([0-9]+)\]/,
  191.       "\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
  192.     lines = text.split("\x00")
  193.     @lines_max = lines.size
  194.     for i in 0...@lines_max
  195.       line = lines[i]
  196.       for rx in rxs
  197.         line.gsub!(rx) {""}
  198.       end
  199.       @line_aligns[i] =
  200.         line.sub!(/\\center/) {""} ? CENTER :
  201.         line.sub!(/\\right/)  {""} ? RIGHT :
  202.                                      AUTO
  203.       # 行の横幅の取得と設定
  204.       cx = text_width_no_escape(line,text) #test
  205.       #cx = contents.text_size(line,text).width
  206.       @line_widths[i] = cx
  207.     end
  208.     # 位置揃え制御文字の削除
  209.     text.gsub!(/\\center/) {""}
  210.     text.gsub!(/\\right/) {""}
  211.     # キャラポップ時のウィンドウリサイズ
  212.     reszie_window_for_pop

  213.     del_tail # if @tail != nil
  214.     # $mes_id が空のときと戦闘中はふきだしを表示しない
  215.     if defined?($game_system.show_stand_picture) #立ち絵に対応。
  216.       $mes_id = -1 if $game_system.show_stand_picture == true
  217.     end
  218.     if $mes_id != nil and not $game_party.in_battle
  219.       # ふきだしのテールを描画
  220.       skin = "Window"
  221.       if @background == 0
  222.         #画像の準備
  223.         @tail = Sprite.new
  224.         @tail.visible = false
  225.         # 位置を取得
  226.         tale_pos = get_tale_pos
  227.         if $win_x != nil
  228.           if $win_x > 0
  229.             @tail.bitmap = Cache.system(skin + "-right")
  230.             @tail.x = tale_pos[0]
  231.             @tail.y = tale_pos[1]
  232.             @tail.z = self.z + 1
  233.           elsif  $win_x < 0
  234.             @tail.bitmap = Cache.system(skin + "-left")
  235.             @tail.x = tale_pos[0]
  236.             @tail.y = tale_pos[1]
  237.             @tail.z = self.z + 1
  238.           else
  239.             create_tail_up_under
  240.           end
  241.         else
  242.           create_tail_up_under
  243.         end
  244.         # エクストラスプライトに登録
  245.         @extra_sprites = [] if @extra_sprites.nil?
  246.         @extra_sprites.push(@tail) if @tail != nil
  247.         # 更新
  248.         update_tail
  249.       end
  250.     end

  251.     open_and_wait #リサイズが終わった時点でウィンドウオープン。

  252.     return text
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 文字の長さを取得する。エスケープ文字は含まない。
  256.   # line : 表示しようとしている全ての文字列。
  257.   # text : その列の文字。
  258.   #--------------------------------------------------------------------------
  259.   def text_width_no_escape(line , text_o)
  260.     add = 0
  261.     text = Marshal.load(Marshal.dump(text_o))
  262.     text.gsub!(/\ehold/) { "" }
  263.     text.gsub!(/\einfo/) { "" }
  264.     # 改行削除指定\_があるか?
  265.     if (/\\_(.*?)\x00/.match(@text)) != nil
  266.       $game_message.choice_start -= 1
  267.       text.gsub!(/\\_(.*?)\x00/) { "" }
  268.     end
  269.     # \name 判定
  270.     text.sub!(/\e[Nn]ame\[(.*?)\]/) { "" }
  271.     text.gsub!(/\e[Hh]\[-1\]/) { "" }
  272.     text.gsub!(/\e[Hh]\[([0-9]+)\]/) { "" }
  273.     text.gsub!(/\e[Hh]/) { "" }
  274.     text.gsub!(/\e[Tt]\[-1\]/) { "" }
  275.     text.gsub!(/\e[Tt]\[-2\]/) { "" }
  276.     text.gsub!(/\e[Tt]\[-3\]/) { "" }
  277.     text.gsub!(/\e[Tt]\[([0-9]+)\]/) { "" }
  278.     text.gsub!(/\e[Tt]/) { "" }
  279.     # 制御文字処理
  280.     text.gsub!(/\e[Ss]\[([0-9]+)\]/i) { "" }
  281.     text.gsub!(/\e[Oo]\[([0-9]+)\]/i) { "" }
  282.     text.gsub!(/\elast_holder/i) { "" }
  283.     text.gsub!(/\elast_material/i) { "" }
  284.     #text.gsub!(/\eV/) { "" } #変数に置き換える。
  285.     #text.gsub!(/\eN/) { "" } #名前へ置き換える。
  286.     #text.gsub!(/\eP/) { "" } #名前へ置き換える。
  287.     #text.gsub!(/\eG/) { "" } #金額へ置き換える。
  288.     #text.gsub!(/\eC/) { "" }
  289.     text.gsub!(/\eB/) { "" }
  290.     text.gsub!(/\eD/) { "" }
  291.     if text =~ /\eI/
  292.       loop do
  293.         if str = text.sub!(/\eI\[(\d+)\]/){ "" }
  294.           add += 24
  295.         else
  296.           break
  297.         end
  298.       end
  299.     end
  300.     #text.gsub!(/\\n/) { "\n" }
  301.     text.sub!(/\ecenter/) {""}
  302.     text.sub!(/\eright/)  {""}
  303.     text.gsub!(/\ecenter/) {""}
  304.     text.gsub!(/\eright/) {""}

  305.     text = xrxsv2_convert_escape_characters(text)
  306.     basic_width = text_size(text).width + add
  307.     esc = text.scan(/\e(\S)/)
  308.     return ( basic_width - esc.size * (contents.font.size - 4) ) #\eの幅は20?
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 最も長い列の長さを調べる。エスケープ文字は含まない。
  312.   #--------------------------------------------------------------------------
  313.   def max_width
  314.     text_size = []
  315.     for i in 0 ... @all_texts.size
  316.       text_size.push text_width_no_escape(@all_texts[i],@all_texts[i]) + 20
  317.     end
  318.     return text_size.max
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● 吹きだしテールが上か下の場合の画像を準備。
  322.   #--------------------------------------------------------------------------
  323.   def create_tail_up_under
  324.     skin = "Window"
  325.     tale_pos = get_tale_pos
  326.     case @position
  327.     when 0  # 上
  328.       @tail.bitmap = Cache.system(skin + "-top")
  329.       @tail.x = tale_pos[0]
  330.       @tail.y = tale_pos[1]
  331.       @tail.z = self.z + 1
  332.     when 1  # 中
  333.       @tail.dispose
  334.       @tail = nil
  335.     when 2  # 下
  336.       @tail.bitmap = Cache.system(skin + "-under")
  337.       @tail.x = tale_pos[0]
  338.       @tail.y = tale_pos[1]
  339.       @tail.z = self.z + 1
  340.     end
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 全テキストの処理
  344.   #--------------------------------------------------------------------------
  345.   def process_all_text
  346.     #open_and_wait #リサイズがあるので、すぐにウィンドウをオープンしない。
  347.     text = convert_escape_characters($game_message.all_text)
  348.     pos = {}
  349.     new_page(text, pos)
  350.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● メッセージの更新 *
  354.   #--------------------------------------------------------------------------
  355.   def update_message
  356.     @wait_count = @type_wait
  357.     loop do
  358.       c = @text.slice!(/./m)
  359.       case update_message_type(c)
  360.       when 1
  361.         break
  362.       when 2
  363.         next
  364.       end
  365.       break unless @show_fast or @line_show_fast
  366.     end
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # 一文字の描画 (返り値 1:break, 2:next)
  370.   #--------------------------------------------------------------------------
  371. #=begin
  372.   def process_escape_character(code, text, pos)
  373.     case code.upcase
  374.     when '$'
  375.       @gold_window.open
  376.     when '.'
  377.       wait(15)
  378.     when '|'
  379.       wait(60)
  380.     when '!'
  381.       input_pause
  382.     when '>'
  383.       @line_show_fast = true
  384.     when '<'
  385.       @line_show_fast = false
  386.     when '^'
  387.       @pause_skip = true
  388.     #when 'n'                      # 改行
  389.     #  new_line
  390.     #  max = MAX_LINE
  391.     #  max = 14 if self.pop_character != nil
  392.     #  if @line_count >= max      # 行数が最大のとき
  393.     #    unless @text.empty?           # さらに続きがあるなら
  394.     #      self.pause = true           # 入力待ちを入れる
  395.           #return 1
  396.     #    end
  397.     #  end
  398.     #when 'S'                       # \S[n]  (スピード変更)
  399.     #  text.sub!(/\[([0-9]+)\]/, "")
  400.     #  @type_wait = $1.to_i
  401.     #  return 2
  402.     when 'O'                       # \O 文字を透明にする。
  403.       text.sub!(/\[([0-9]+)\]/, "")
  404.       contents.font.color.alpha = $1.to_i
  405.       #return 2
  406.     when 'D' #\D 文字に影をつける
  407.       contents.font.shadow ^= true
  408.     #when '18'
  409.     #  name = ($game_temp.last_gain_holder.name rescue "")
  410.     #  update_message_type_draw_at(name)
  411.     #when '19'
  412.     #  item = ($game_temp.last_gain_material.item rescue nil)
  413.     #  draw_item_name(item, @contents_x, @contents_y)
  414.     #  @contents_x += 196
  415.     else
  416.       super
  417.     end

  418.   end
  419. #=end
  420.   #--------------------------------------------------------------------------
  421.   # ● 改ページ処理
  422.   #--------------------------------------------------------------------------
  423.   alias xrxsv2_new_page new_page
  424.   def new_page(text, pos)
  425.     xrxsv2_new_page(text, pos)
  426.     update_charpop_window
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ● 改行位置の取得
  430.   #--------------------------------------------------------------------------
  431.   #def new_line_x
  432.   #  $game_message.face_name.empty? ? 0 : 112
  433.   #end
  434.   #--------------------------------------------------------------------------
  435.   # ● 改行処理
  436.   #--------------------------------------------------------------------------
  437.   alias xrxsv2_new_line_x new_line_x
  438.   def new_line
  439.     xrxsv2_new_line
  440.     set_align
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # 位置揃え
  444.   #--------------------------------------------------------------------------
  445.   def set_align
  446.     w = @line_widths[@line_count].to_i
  447.     a = @line_aligns[@line_count]
  448.     case a
  449.     when CENTER
  450.       @contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
  451.     when RIGHT
  452.       @contents_x = contents.width - w
  453.     end
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● ファイバーのメイン処理 ☆再定義
  457.   #--------------------------------------------------------------------------
  458.   def fiber_main
  459.     $game_message.visible = true
  460.     update_background
  461.     update_placement
  462.     loop do
  463.       process_all_text if $game_message.has_text?
  464.       process_input
  465.       $game_message.clear
  466.       @gold_window.close
  467.       process_hold #ホールドウィンドウの処理。
  468.       Fiber.yield
  469.       break unless text_continue?
  470.     end
  471.     close_and_wait
  472.     $game_message.visible = false
  473.     @fiber = nil
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # 定数
  477.   #--------------------------------------------------------------------------
  478.   AUTO   = 0
  479.   LEFT   = 1
  480.   CENTER = 2
  481.   RIGHT  = 3
  482. end
  483. #==============================================================================
  484. # アクティブイベント取得
  485. #==============================================================================
  486. class Game_Interpreter
  487.   attr_reader   :event_id
  488. end


  489. #==============================================================================
  490. # 各種機能の追加 - キャラポップ/ネーム/ホールド
  491. #==============================================================================
  492. class Window_Message < Window_Base
  493.   #--------------------------------------------------------------------------
  494.   # ● カーソルの更新 *
  495.   #--------------------------------------------------------------------------
  496.   def update_cursor
  497.     if @index >= 0
  498.       x = ($game_message.face_name.empty? ? 0 : 112)
  499.       y = ($game_message.choice_start + @index) * WLH - 1
  500.       w = contents.width - x
  501.       if self.pop_character != nil
  502.         x += 28
  503.         w -= 20
  504.       end
  505.       self.cursor_rect.set(x, y, w, WLH)
  506.     else
  507.       self.cursor_rect.empty
  508.     end
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # キャラクターの取得
  512.   #   parameter : パラメータ
  513.   #--------------------------------------------------------------------------
  514.   def get_character(parameter)
  515.     # パラメータで分岐
  516.     case parameter
  517.     when -1  # プレイヤー
  518.       return $game_player
  519.     when 0  # 現在アクティブなイベント
  520.       id = $game_map.interpreter.event_id
  521.       events = $game_map.events
  522.       return events == nil ? nil : events[id]
  523.     else  # 特定のイベント
  524.       events = $game_map.events
  525.       return events == nil ? nil : events[parameter]
  526.     end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # (メッセージ終了時)ホールドの処理
  530.   #--------------------------------------------------------------------------
  531.   def process_hold
  532.     if @window_hold
  533.       @held_windows.push(Window_Copy.new(self))
  534.       @held_windows.push(Window_Copy.new(@name_window))
  535.       @held_windows.push(Sprite_Copy.new(@name_sprite))
  536.       @held_windows.push(Sprite_Copy.new(@back_sprite))
  537.       for sprite in @extra_sprites
  538.         next if sprite.disposed?
  539.         @held_windows.push(Sprite_Copy.new(sprite))
  540.       end
  541.       @extra_sprites.clear
  542.       self.openness = 0
  543.       #@name_window.openness = 0
  544.       @back_sprite.visible = false
  545.     else
  546.       @held_windows.each {|object| object.dispose}
  547.       @held_windows.clear
  548.     end
  549.     #@name_window.close
  550.     #@name_sprite.visible = false
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # キャラポップ位置の設定と取得
  554.   #--------------------------------------------------------------------------
  555.   def pop_character=(character_id)
  556.     @pop_character = character_id
  557.   end
  558.   def pop_character
  559.     return @pop_character
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # キャラポップ時のウィンドウリサイズ
  563.   #--------------------------------------------------------------------------
  564.   def reszie_window_for_pop
  565.     #キャラポップ
  566.     if self.pop_character != nil
  567.       max_x = @line_widths.max.to_i
  568.       n  = max_x + 32
  569.       n += $game_message.face_name.empty? ? 0 : 122
  570.       m  = $game_message.face_name.empty? ? 0 : 96
  571.       w  = @name_sprite.bitmap.width
  572.       #self.width  = [n, w].max
  573.       self.width  = max_width
  574.       #self.height = [@lines_max * line_height, m].max + 32
  575.       self.height = [@all_texts.size * line_height, m].max + 32
  576.       create_contents
  577.       update_charpop_window
  578.     elsif @info_mode
  579.       @line_aligns[0] = CENTER
  580.       self.x = - 8
  581.       self.width = Graphics.width + 16
  582.       self.height = 56
  583.       create_contents
  584.     else
  585.       self.x = 0
  586.       self.width  = Graphics.width
  587.       self.height = MAX_LINE * line_height + 32
  588.       update_placement #位置情報修正。
  589.       create_contents
  590.     end
  591.   end
  592.   #--------------------------------------------------------------------------
  593.   # ● 背景スプライトの作成
  594.   #--------------------------------------------------------------------------
  595.   alias xrxsv2_create_back_sprite create_back_sprite
  596.   def create_back_sprite
  597.     xrxsv2_create_back_sprite
  598.     @back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
  599.     @name_window = Window_Base.new(0,0,112,36)
  600.     @name_window.visible = false
  601.     @name_sprite = Sprite.new
  602.     @name_sprite.bitmap = Bitmap.new(32,32)
  603.     @name_sprite.visible = false
  604.     self.x = self.x
  605.     self.y = self.y
  606.     self.z = self.z
  607.     @held_windows = []
  608.     @extra_sprites = []
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● 背景スプライトの解放
  612.   #--------------------------------------------------------------------------
  613.   alias xrxsv2_dispose_back_sprite dispose_back_sprite
  614.   def dispose_back_sprite
  615.     xrxsv2_dispose_back_sprite
  616.     @name_window.dispose if @name_window != nil #メニュー画面を出そうとするとエラー?
  617.     @name_sprite.dispose if @name_sprite != nil
  618.     for window in @held_windows
  619.       window.dispose
  620.     end
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ● 背景スプライトの更新
  624.   #--------------------------------------------------------------------------
  625.   alias xrxsv2_update_back_sprite update_back_sprite
  626.   def update_back_sprite
  627.     @name_window.update
  628.     xrxsv2_update_back_sprite
  629.     update_charpop_window
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ウィンドウの位置と不透明度の設定 (キャラポップ)
  633.   #--------------------------------------------------------------------------
  634.   def update_charpop_window
  635.     if self.pop_character
  636.       character = get_character(self.pop_character)
  637.       return if character == nil
  638.       # [X座標]
  639.       n = self.width / 2
  640.       n = [n, @name_skin.width + 16].max if @current_name != nil
  641.       w = @name_sprite.bitmap.width
  642.       x = character.screen_x - [[n, w].max, self.width - 32].min
  643.       # [Y座標]
  644.       if self.pop_character == 0 and POP_DIRECTION #イベントの方向を考慮。
  645.         if character.direction == 2 #下向き
  646.           @position = 0 #上にポップ
  647.         elsif character.direction == 8 #上向き
  648.           @position = 2 #下にポップ
  649.         end
  650.       end
  651.       case @position
  652.       when 0
  653.         y = character.screen_y - CHARPOP_HEIGHT - self.height
  654.       else
  655.         y = character.screen_y + 16
  656.       end
  657.       x_max = Graphics.width - 4 - self.width
  658.       x_min = 4
  659.       y_max = Graphics.height - self.height
  660.       y_min = 4
  661.       self.x = [[x, x_max].min, x_min].max
  662.       self.y = [[y, y_max].min, y_min].max
  663.     end
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # 位置の連動
  667.   #--------------------------------------------------------------------------
  668.   def x=(n)
  669.     super
  670.     if @name_window
  671.       @name_window.x = n + NAME_WINDOW_OFFSET_X
  672.       @name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
  673.     end
  674.   end
  675.   def y=(n)
  676.     super
  677.     if @name_window
  678.       @name_window.y = n + NAME_WINDOW_OFFSET_Y
  679.       @name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
  680.     end
  681.   end
  682.   def z=(n)
  683.     super
  684.     if @name_window
  685.       @name_window.z = n + 11#1 テールの上に表示されるので、Zを水増しする。
  686.       @name_sprite.z = n + 12#2
  687.     end
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● ファイバーのメイン処理
  691.   #--------------------------------------------------------------------------
  692.   def fiber_main_namewin
  693.     fiber_main_namewin_default
  694.     @name_window.openness = 0
  695.     @name_sprite.bitmap.clear
  696.     $name = ""
  697.   end
  698.   alias :fiber_main_namewin_default :fiber_main
  699.   alias :fiber_main :fiber_main_namewin
  700. end
  701. #==============================================================================
  702. # 伸縮対応
  703. #==============================================================================
  704. class Window_Message < Window_Base
  705.   #--------------------------------------------------------------------------
  706.   # ● ウィンドウの背景と位置の設定 [再定義]
  707.   #--------------------------------------------------------------------------
  708.   def reset_window
  709.     @background = $game_message.background
  710.     @position = $game_message.position
  711.     if @background == 0   # 通常ウィンドウ
  712.       self.opacity = 255
  713.     else                  # 背景を暗くする、透明にする
  714.       self.opacity = 0
  715.     end
  716.     case @position
  717.     when 0  # 上
  718.       self.y = 0
  719.       @gold_window.y = 360
  720.     when 1  # 中
  721.       self.y = (Graphics.height - self.height) / 2
  722.       @gold_window.y = 0
  723.     when 2  # 下
  724.       self.y = Graphics.height - self.height
  725.       @gold_window.y = 0
  726.     end
  727.   end
  728. end
  729. #==============================================================================
  730. # □ Window_Copy
  731. #------------------------------------------------------------------------------
  732. #   指定のウィンドウのコピーを作成します。
  733. #==============================================================================
  734. class Window_Copy < Window_Base
  735.   #--------------------------------------------------------------------------
  736.   # ○ オブジェクト初期化
  737.   #--------------------------------------------------------------------------
  738.   def initialize(window)
  739.     super(window.x, window.y, window.width, window.height)
  740.     self.contents = window.contents.dup unless window.contents.nil?
  741.     self.opacity = window.opacity
  742.     self.back_opacity = window.back_opacity
  743.     self.z = window.z - 3
  744.     self.visible = window.visible
  745.   end
  746. end
  747. #==============================================================================
  748. # □ Sprite_Copy
  749. #------------------------------------------------------------------------------
  750. #   指定のスプライトのコピーを作成します。
  751. #==============================================================================
  752. class Sprite_Copy < Sprite
  753.   #--------------------------------------------------------------------------
  754.   # ○ オブジェクト初期化
  755.   #--------------------------------------------------------------------------
  756.   def initialize(sprite)
  757.     super()
  758.     self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  759.     self.opacity = sprite.opacity
  760.     self.x = sprite.x
  761.     self.y = sprite.y
  762.     self.z = sprite.z - 3
  763.     self.ox = sprite.ox
  764.     self.oy = sprite.oy
  765.     self.zoom_x = sprite.zoom_x
  766.     self.visible = sprite.visible
  767.   end
  768. end



  769. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  770. #■吹きだしテールの表示ルーチン。
  771. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  772. #==============================================================================
  773. # +++ 「+ふきだし表示」VX +++
  774. # by パラ犬  [url]http://2d6.parasite.jp/[/url]
  775. #      ×
  776. #    row       [url]http://xms.rdy.jp/[/url]
  777. #
  778. # publish 2010/ 3/ 2
  779. # update  -
  780. #
  781. #------------------------------------------------------------------------------
  782. #    ほぼどんなメッセージウィンドウに対しても後付け可能な「ふきだし表示」です。
  783. #  また、テール部分のみの自動追尾機能を持ちます。
  784. #   ふきだし表示をするには、
  785. #  テール用画像「Window-top」「Window-under」を
  786. #  「Graphics/System」フォルダにインポートしておく必要があります。
  787. #==============================================================================
  788. # ■ Window_Message
  789. #==============================================================================
  790. class Window_Message < Window_Base
  791.   #--------------------------------------------------------------------------
  792.   # ● メッセージの開始
  793.   #--------------------------------------------------------------------------
  794.   alias parashelf_update_all_windows update_all_windows
  795.   def update_all_windows
  796.     parashelf_update_all_windows
  797.     update_tail
  798.   end
  799.   #--------------------------------------------------------------------------
  800.   # クローズ [オーバーライド]
  801.   #--------------------------------------------------------------------------
  802.   def close
  803.     super
  804.     del_tail
  805.     @name_window.close if @name_window != nil #ネームウィンドウのクローズ動作。
  806.   end
  807.   #--------------------------------------------------------------------------
  808.   # ● 背景スプライトの更新
  809.   #--------------------------------------------------------------------------
  810.   alias parashelf_update_back_sprite update_back_sprite
  811.   def update_back_sprite
  812.     parashelf_update_back_sprite
  813.     update_tail
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ○ フレーム更新 (ふきだしテールの更新)
  817.   #--------------------------------------------------------------------------
  818.   def update_tail
  819.     # ふきだしモードではイベントの動きに追従
  820.     if $mes_id != nil and @tail != nil
  821.       tale_pos = get_tale_pos
  822.       @tail.x = tale_pos[0]
  823.       @tail.y = tale_pos[1]
  824.       update_tail_bitmap
  825.     end
  826.   end
  827.   ##--------------------------------------------------------------------------
  828.   # ○ ふきだしテールの画像を更新。
  829.   #--------------------------------------------------------------------------
  830.   def update_tail_bitmap
  831.     skin = "Window"
  832.     if $win_x != nil
  833.       if $win_x > 0
  834.         @tail.bitmap = Cache.system(skin + "-right")
  835.       elsif  $win_x < 0
  836.         @tail.bitmap = Cache.system(skin + "-left")
  837.       else
  838.         case @position
  839.         when 0  # 上
  840.           @tail.bitmap = Cache.system(skin + "-top")
  841.         when 2  # 下
  842.           @tail.bitmap = Cache.system(skin + "-under")
  843.         end
  844.       end
  845.     else
  846.       case @position
  847.       when 0  # 上
  848.         @tail.bitmap = Cache.system(skin + "-top")
  849.       when 2  # 下
  850.         @tail.bitmap = Cache.system(skin + "-under")
  851.       end
  852.     end
  853.     # 可視状態
  854.     if self.visible == true
  855.       @tail.visible = self.openness == 255
  856.     else
  857.       @tail.visible = false
  858.     end
  859.   end
  860.   #--------------------------------------------------------------------------
  861.   # ○ テールの位置を計算
  862.   #--------------------------------------------------------------------------
  863.   def get_tale_pos
  864.     if defined?($game_system.show_stand_picture) #A1立ち絵スクリプトを入れている。
  865.       if $game_system.show_stand_picture #立ち絵on
  866.         pos = get_tale_pos_stand_pic
  867.       else
  868.         pos = get_tale_pos_normal
  869.       end
  870.     else
  871.       pos = get_tale_pos_normal
  872.     end
  873.     return pos
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # ○ テールの位置を計算/立ち絵使用時。※NAME_CHANGEの編集必須。
  877.   #--------------------------------------------------------------------------
  878.   def get_tale_pos_stand_pic
  879.     if $game_message.face_name != ""  and @tail != nil
  880.       name = A1_System::StandPicture::NAME_CHANGE[$game_message.face_name]
  881.       chara = name[$game_message.face_index][0]
  882.       if @stand_pic[chara] != nil #立ち絵無しの場合通常通り。
  883.         x = @stand_pic[chara].pic_sprite.x + @stand_pic[chara].pic_sprite.width / 2
  884.         y = get_tale_pos_normal_updown
  885.         update_tail_bitmap
  886.       else
  887.         return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。
  888.       end
  889.     else
  890.       return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。
  891.     end
  892.     return [x,y]
  893.   end
  894.   #--------------------------------------------------------------------------
  895.   # ○ テールの位置を計算/立ち絵未使用時。
  896.   #--------------------------------------------------------------------------
  897.   def get_tale_pos_normal
  898.     if $mes_id == (-2) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。
  899.       if $win_x != nil
  900.         if $win_x > 0
  901.           x = $win_x - @tail.width / 2
  902.           y = self.y + self.height / 2 - @tail.height / 2
  903.         elsif $win_x < 0
  904.           x = self.width - @tail.width / 2
  905.           y = self.y + self.height / 2 - @tail.height / 2
  906.         else
  907.           x = MINAS_TWE_X_POS
  908.           y = get_tale_pos_normal_updown
  909.         end
  910.       else
  911.         x = MINAS_TWE_X_POS
  912.         y = get_tale_pos_normal_updown
  913.       end
  914.     elsif $mes_id <= (-3) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。
  915.       if $win_x != nil
  916.         if $win_x > 0
  917.           x = $win_x - @tail.width / 2
  918.           y = self.y + self.height / 2
  919.         elsif $win_x < 0
  920.           x = self.width - @tail.width / 2
  921.           y = self.y + self.height / 2
  922.         else
  923.           x = MINAS_THREE_X_POS
  924.           y = get_tale_pos_normal_updown
  925.         end
  926.       else
  927.         x = MINAS_THREE_X_POS
  928.         y = get_tale_pos_normal_updown
  929.       end
  930.     else
  931.       character = get_character($mes_id)
  932.       x = [[character.screen_x - 16, self.x].max, self.x + self.width - 32].min
  933.       if $win_x != nil
  934.         if $win_x > 0
  935.           x = $win_x - @tail.width / 2
  936.           y = character.screen_y
  937.         elsif $win_x < 0
  938.           x = self.width
  939.           y = character.screen_y
  940.         else
  941.           y = get_tale_pos_normal_updown
  942.         end
  943.       else
  944.         y = get_tale_pos_normal_updown
  945.       end
  946.     end
  947.     return [x, y]
  948.   end
  949.   #--------------------------------------------------------------------------
  950.   # ○ テールが上下の時、かつ[-2][-3]でない時のy座標の取得。
  951.   #--------------------------------------------------------------------------
  952.   def get_tale_pos_normal_updown
  953.     case @position
  954.     when 0
  955.       y = self.y + self.height - @tail.height / 2
  956.     else
  957.       y = self.y - @tail.height / 2
  958.     end
  959.     return y
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # ○ ふきだしを破棄
  963.   #--------------------------------------------------------------------------
  964.   def del_tail
  965.     if @tail != nil
  966.       @tail.dispose
  967.       @tail = nil
  968.     end
  969.   end
  970. end
  971. #
  972. # ▼▲▼ XRXS 9拡張CO-X. ふきだし自動設定 ▼▲▼
  973. #==============================================================================
  974. # ■ Window_Message
  975. #==============================================================================
  976. class Window_Message < Window_Base
  977.   #--------------------------------------------------------------------------
  978.   # ○ ポップキャラクターの設定
  979.   #--------------------------------------------------------------------------
  980.   def pop_character=(character_id)
  981.     @pop_character = character_id
  982.     $mes_id = character_id
  983.   end
  984.   #--------------------------------------------------------------------------
  985.   # ○ テールキャラクターの設定
  986.   #--------------------------------------------------------------------------
  987.   def tail_character=(character_id)
  988.     #@pop_character = character_id
  989.     $mes_id = character_id
  990.   end
  991. end

  992. #==============================================================================
  993. # ■ Scene_Menu
  994. #------------------------------------------------------------------------------
  995. #  メニューを開いてからウィンドウが出るとネームウィンドウが表示される不具合修正。
  996. #==============================================================================
  997. #class Scene_Menu < Scene_MenuBase
  998. #  def terminate_hukidasi_menyu
  999. #    @name_window.openness = 0 if @name_window != nil
  1000. #    terminate_hukidasi_menyu_default
  1001. #  end
  1002. #  alias :terminate_hukidasi_menyu_default :terminate
  1003. #  alias :terminate :terminate_hukidasi_menyu
  1004. #end

  1005. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1006. #■ウィンドウ非表示ルーチン
  1007. #■吹きだしテールとネームウィンドウに対応。
  1008. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1009. #==============================================================================
  1010. # L(キーボードのQ)を押すと、メッセージウィンドウを表示?非表示
  1011. #==============================================================================
  1012. class Window_Message < Window_Base
  1013.   def update_winoff
  1014.     unless $game_party.in_battle #バトル中は無効。
  1015.       if Input.trigger?(Input::L)
  1016.         if self.visible == true
  1017.           self.visible = false
  1018.           @tail.visible = false if @tail != nil
  1019.         else
  1020.           self.visible = true
  1021.         end
  1022.         if @name_window != nil
  1023.           if @name_window.visible == false and $name != nil and $name != ""
  1024.             @name_window.visible = true
  1025.             @name_sprite.visible = true
  1026.           else
  1027.             @name_window.visible = false
  1028.             @name_sprite.visible = false
  1029.           end
  1030.         end
  1031.       elsif Input.trigger?(Input::C) or Input.trigger?(Input::B)
  1032.         self.visible = true if self.visible == false
  1033.         @tail.visible = true if @tail != nil and @tail.visible == false
  1034.         if @name_window != nil and $name != nil
  1035.           if $name != ""
  1036.             @name_window.visible = true
  1037.             @name_sprite.visible = true
  1038.           end
  1039.         end
  1040.       end
  1041.     end
  1042.     update_winoff_default
  1043.   end
  1044.   alias :update_winoff_default :update
  1045.   alias :update :update_winoff
  1046. end


  1047. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1048. #■ウィンドウ表示位置指定ルーチン
  1049. #■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
  1050. #===========================================================================
  1051. #イベントコマンド「スクリプト」を使い、
  1052. #$win_x=100 
  1053. #$win_y=100
  1054. #と入力すれば、ウィンドウを(100、100)の位置に表示します。
  1055. #使わない時は
  1056. #$win_x=nil
  1057. #などとnilを入力しておいてください。
  1058. #===========================================================================
  1059. class Window_Message < Window_Base
  1060.   #--------------------------------------------------------------------------
  1061.   # ● ウィンドウの背景と位置の設定 [再定義]
  1062.   #--------------------------------------------------------------------------
  1063.   def update_placement_position
  1064.     update_placement_position_default
  1065.     if $win_x != nil
  1066.       if $win_x > 0
  1067.         self.x = $win_x
  1068.         self.width -= $win_x
  1069.       else
  1070.         self.x = 0
  1071.         self.width += $win_x
  1072.       end
  1073.     end
  1074.     if $win_y != nil
  1075.       self.y = $win_y
  1076.     end
  1077.   end
  1078.   alias_method :update_placement_position_default, :update_placement
  1079.   alias_method :update_placement, :update_placement_position
  1080. end


  1081. #==============================================================================
  1082. # ■ SceneManager
  1083. #------------------------------------------------------------------------------
  1084. #  シーン遷移のさい、テールを破棄する。
  1085. #==============================================================================
  1086. module SceneManager
  1087.   #--------------------------------------------------------------------------
  1088.   # ● 呼び出し
  1089.   #--------------------------------------------------------------------------
  1090.   def self.call_sceman_hukidasi(scene_class)
  1091.     if defined?(self.scene.message_window)
  1092.       self.scene.message_window.del_tail if self.scene.message_window.tail != nil
  1093.     end
  1094.     @stack.push(@scene)
  1095.     [url=home.php?mod=space&uid=420706]@Scene[/url] = scene_class.new
  1096.   end
  1097.   #--------------------------------------------------------------------------
  1098.   # ● クラスメソッドのエイリアス
  1099.   #--------------------------------------------------------------------------
  1100.   class << self
  1101.     alias :call_sceman_hukidasi_default :call
  1102.     alias :call :call_sceman_hukidasi
  1103.   end
  1104. end

  1105. #==============================================================================
  1106. # ■ Scene_Map
  1107. #------------------------------------------------------------------------------
  1108. #  戦闘トランジションのさい、テールを破棄。
  1109. #==============================================================================
  1110. class Scene_Map < Scene_Base
  1111.   attr_accessor :message_window
  1112.   #--------------------------------------------------------------------------
  1113.   # ● 戦闘前トランジション実行
  1114.   #--------------------------------------------------------------------------
  1115.   def perform_battle_transition_hukidasi
  1116.     @message_window.del_tail #テールの破棄
  1117.     perform_battle_transition_hukidasi_default
  1118.   end
  1119.   alias_method :perform_battle_transition_hukidasi_default, :perform_battle_transition
  1120.   alias_method :perform_battle_transition, :perform_battle_transition_hukidasi
  1121. end
复制代码

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

本版积分规则

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

在本版发帖返回顶部