设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1862|回复: 0
打印 上一主题 下一主题

[已经解决] 「立ち絵表示」和「吹きだしウィンドウ」同时使用

[复制链接]

Lv1.梦旅人

梦石
0
星屑
48
在线时间
331 小时
注册时间
2012-5-4
帖子
158
跳转到指定楼层
1
发表于 2012-12-26 21:08:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 wshzya 于 2013-3-17 12:54 编辑

RT,要同时使用「吹きだしウィンドウ」(对话泡泡)脚本和「空メッセージでウィンドウを開かない」「立ち絵表示」时,怎么呼出立绘图片呢?还要新设一个文件夹?


「吹きだしウィンドウ」
  1. =begin
  2. 吹きだしウィンドウVXAce

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

  5. ※このスクリプトは、ちいさな本屋様(http://xrxs.at-ninja.jp/)
  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」的記述、可把立ち絵機能関閉。

  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號的事件出現對話窗口。
  26. H可用大文字。

  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事件對話吹出位置表示。

  35. \O[128] : 文字透明。[]内是alpha値、0透明、255通常。
  36. \D : 文字影有
  37. \hold : 最後的文章限定。信息結束,不關上窗口。
  38.       其他的信息被表示時消失。
  39.       被鎖定的窗,不能用Q按鈕消去。

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


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


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

  65. =end

  66. #==============================================================================
  67. # カスタマイズポイント
  68. #==============================================================================
  69. #=begin
  70. class Window_Message < Window_Base
  71.   #
  72.   # 基本行数
  73.   #
  74.   MAX_LINE = 4
  75.   #
  76.   # \p[] - キャラポップの高さ
  77.   #
  78.   CHARPOP_HEIGHT = 40
  79.   #
  80.   # \name[] - 名前枠 X,Y座標
  81.   #
  82.   NAME_WINDOW_OFFSET_X =   0
  83.   NAME_WINDOW_OFFSET_Y = -24
  84.   #
  85.   #
  86.   MINAS_TWE_X_POS = 100 # $t[-2]のときの、テールのX座標。
  87.   MINAS_THREE_X_POS = 444 # $t[-3]のときの、テールのX座標。
  88.   
  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.     # 初期化
  115.     contents.font.size   = Font.default_size
  116.     contents.font.bold   = Font.default_italic
  117.     contents.font.italic = Font.default_bold
  118.     contents.font.shadow = Font.default_shadow
  119.     @type_wait = 0
  120.     @line_widths = []
  121.     @line_aligns = []
  122.     self.pop_character = nil
  123.     # ウィンドウ保持指定\holdがあるか?
  124.     @window_hold = (text.gsub!(/\\hold/) { "" } != nil)
  125.     # \info
  126.     @info_mode = (text.gsub!(/\\info/) { "" } != nil)
  127.     # 改行削除指定\_があるか?
  128.     if (/\\_(.*?)\x00/.match(@text)) != nil
  129.       $game_message.choice_start -= 1
  130.       text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
  131.     end
  132.     # \name 判定
  133.     if text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  134.       name = $1
  135.       bitmap = @name_sprite.bitmap
  136.       w = [bitmap.text_size(name).width, 1].max
  137.       bitmap.dispose
  138.       @name_sprite.bitmap = Bitmap.new(w, 32)
  139.       bitmap = @name_sprite.bitmap
  140.       bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
  141.       @name_window.width = w + 16
  142.       @name_window.create_contents
  143.       @name_window.open if @name_window.openness == 0
  144.       if self.visible #名前だけ表示されるのを防止。
  145.         @name_window.visible = true
  146.         @name_sprite.visible = true
  147.       else
  148.         @name_window.visible = false
  149.         @name_sprite.visible = false
  150.       end
  151.     else
  152.       @name_window.visible = false
  153.       @name_sprite.visible = false
  154.       @name_sprite.bitmap.dispose
  155.       @name_sprite.bitmap = Bitmap.new(32,32)
  156.     end
  157.     $name = $1 #あれこれで使うので、ネームウィンドウに表示予定の名前を取得。
  158.     # キャラボップモード
  159.     if text.gsub!(/\\[Hh]\[-1\]/) { "" }
  160.       self.pop_character = -1
  161.     elsif text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "" }
  162.       self.pop_character = $1.to_i
  163.     elsif text.gsub!(/\\[Hh]/) { "" }
  164.       self.pop_character = 0
  165.     #テール表示モード
  166.     elsif text.gsub!(/\\[Tt]\[-1\]/) { "" }
  167.       self.tail_character = -1
  168.     elsif text.gsub!(/\\[Tt]\[-2\]/) { "" }
  169.       self.tail_character = -2
  170.     elsif text.gsub!(/\\[Tt]\[-3\]/) { "" }
  171.       self.tail_character = -3
  172.     elsif text.gsub!(/\\[Tt]\[([0-9]+)\]/) { "" }
  173.       self.tail_character = $1.to_i
  174.     elsif text.gsub!(/\\[Tt]/) { "" }
  175.       self.tail_character = 0
  176.     else
  177.       self.pop_character = nil
  178.     end
  179.    
  180.     # 制御文字処理
  181.     text = xrxsv2_convert_escape_characters(text)
  182.     text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\eS[#{$1}]" }
  183.     text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\eO[#{$1}]" }
  184.     text.gsub!(/\\last_holder/i) { "\e18" }
  185.     text.gsub!(/\\last_material/i) { "\e19" }
  186.     text.gsub!(/\\B/) { "\eB" }
  187.     text.gsub!(/\\D/) { "\eD" }
  188.     #text.gsub!(/\\n/) { "\n" }
  189.     #
  190.     # ライン情報の取得
  191.     rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
  192.       /\[([0-9]+)\]/,
  193.       "\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
  194.     lines = text.split("\x00")
  195.     @lines_max = lines.size
  196.     for i in 0...@lines_max
  197.       line = lines[i]
  198.       for rx in rxs
  199.         line.gsub!(rx) {""}
  200.       end
  201.       @line_aligns[i] =
  202.         line.sub!(/\\center/) {""} ? CENTER :
  203.         line.sub!(/\\right/)  {""} ? RIGHT :
  204.                                      AUTO
  205.       # 行の横幅の取得と設定
  206.       cx = text_width_no_escape(line,text) #test
  207.       #cx = contents.text_size(line,text).width
  208.       @line_widths[i] = cx
  209.     end
  210.     # 位置揃え制御文字の削除
  211.     text.gsub!(/\\center/) {""}
  212.     text.gsub!(/\\right/) {""}
  213.     # キャラポップ時のウィンドウリサイズ
  214.     reszie_window_for_pop
  215.    
  216.     del_tail # if @tail != nil
  217.     # $mes_id が空のときと戦闘中はふきだしを表示しない
  218.     if defined?($game_system.show_stand_picture) #立ち絵に対応。
  219.       $mes_id = -1 if $game_system.show_stand_picture == true
  220.     end
  221.     if $mes_id != nil and not $game_party.in_battle
  222.       # ふきだしのテールを描画
  223.       skin = "Window"
  224.       if @background == 0
  225.         #画像の準備
  226.         @tail = Sprite.new
  227.         @tail.visible = false
  228.         # 位置を取得
  229.         tale_pos = get_tale_pos
  230.         if $win_x != nil
  231.           if $win_x > 0
  232.             @tail.bitmap = Cache.system(skin + "-right")
  233.             @tail.x = tale_pos[0]
  234.             @tail.y = tale_pos[1]
  235.             @tail.z = self.z + 1
  236.           elsif  $win_x < 0
  237.             @tail.bitmap = Cache.system(skin + "-left")
  238.             @tail.x = tale_pos[0]
  239.             @tail.y = tale_pos[1]
  240.             @tail.z = self.z + 1
  241.           else
  242.             create_tail_up_under
  243.           end
  244.         else
  245.           create_tail_up_under
  246.         end
  247.         # エクストラスプライトに登録
  248.         @extra_sprites = [] if @extra_sprites.nil?
  249.         @extra_sprites.push(@tail) if @tail != nil
  250.         # 更新
  251.         update_tail
  252.       end
  253.     end

  254.     open_and_wait #リサイズが終わった時点でウィンドウオープン。
  255.    
  256.     return text
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 文字の長さを取得する。エスケープ文字は含まない。
  260.   # line : 表示しようとしている全ての文字列。
  261.   # text : その列の文字。
  262.   #--------------------------------------------------------------------------
  263.   def text_width_no_escape(line , text_o)
  264.     add = 0
  265.     text = Marshal.load(Marshal.dump(text_o))
  266.     text.gsub!(/\ehold/) { "" }
  267.     text.gsub!(/\einfo/) { "" }
  268.     # 改行削除指定\_があるか?
  269.     if (/\\_(.*?)\x00/.match(@text)) != nil
  270.       $game_message.choice_start -= 1
  271.       text.gsub!(/\\_(.*?)\x00/) { "" }
  272.     end
  273.     # \name 判定
  274.     text.sub!(/\e[Nn]ame\[(.*?)\]/) { "" }
  275.     text.gsub!(/\e[Hh]\[-1\]/) { "" }
  276.     text.gsub!(/\e[Hh]\[([0-9]+)\]/) { "" }
  277.     text.gsub!(/\e[Hh]/) { "" }
  278.     text.gsub!(/\e[Tt]\[-1\]/) { "" }
  279.     text.gsub!(/\e[Tt]\[-2\]/) { "" }
  280.     text.gsub!(/\e[Tt]\[-3\]/) { "" }
  281.     text.gsub!(/\e[Tt]\[([0-9]+)\]/) { "" }
  282.     text.gsub!(/\e[Tt]/) { "" }
  283.     # 制御文字処理
  284.     text.gsub!(/\e[Ss]\[([0-9]+)\]/i) { "" }
  285.     text.gsub!(/\e[Oo]\[([0-9]+)\]/i) { "" }
  286.     text.gsub!(/\elast_holder/i) { "" }
  287.     text.gsub!(/\elast_material/i) { "" }
  288.     #text.gsub!(/\eV/) { "" } #変数に置き換える。
  289.     #text.gsub!(/\eN/) { "" } #名前へ置き換える。
  290.     #text.gsub!(/\eP/) { "" } #名前へ置き換える。
  291.     #text.gsub!(/\eG/) { "" } #金額へ置き換える。
  292.     #text.gsub!(/\eC/) { "" }
  293.     text.gsub!(/\eB/) { "" }
  294.     text.gsub!(/\eD/) { "" }
  295.     if text =~ /\eI/
  296.       loop do
  297.         if str = text.sub!(/\eI\[(\d+)\]/){ "" }
  298.           add += 24
  299.         else
  300.           break
  301.         end
  302.       end
  303.     end
  304.     #text.gsub!(/\\n/) { "\n" }
  305.     text.sub!(/\ecenter/) {""}
  306.     text.sub!(/\eright/)  {""}
  307.     text.gsub!(/\ecenter/) {""}
  308.     text.gsub!(/\eright/) {""}
  309.    
  310.     text = xrxsv2_convert_escape_characters(text)
  311.     basic_width = text_size(text).width + add
  312.     esc = text.scan(/\e(\S)/)
  313.     return ( basic_width - esc.size * (contents.font.size - 4) ) #\eの幅は20?
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 最も長い列の長さを調べる。エスケープ文字は含まない。
  317.   #--------------------------------------------------------------------------
  318.   def max_width
  319.     text_size = []
  320.     for i in 0 ... @all_texts.size
  321.       text_size.push text_width_no_escape(@all_texts[i],@all_texts[i]) + 20
  322.     end
  323.     return text_size.max
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 吹きだしテールが上か下の場合の画像を準備。
  327.   #--------------------------------------------------------------------------
  328.   def create_tail_up_under
  329.     skin = "Window"
  330.     tale_pos = get_tale_pos
  331.     case @position
  332.     when 0  # 上
  333.       @tail.bitmap = Cache.system(skin + "-top")
  334.       @tail.x = tale_pos[0]
  335.       @tail.y = tale_pos[1]
  336.       @tail.z = self.z + 1
  337.     when 1  # 中
  338.       @tail.dispose
  339.       @tail = nil
  340.     when 2  # 下
  341.       @tail.bitmap = Cache.system(skin + "-under")
  342.       @tail.x = tale_pos[0]
  343.       @tail.y = tale_pos[1]
  344.       @tail.z = self.z + 1
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 全テキストの処理
  349.   #--------------------------------------------------------------------------
  350.   def process_all_text
  351.     #open_and_wait #リサイズがあるので、すぐにウィンドウをオープンしない。
  352.     text = convert_escape_characters($game_message.all_text)
  353.     pos = {}
  354.     new_page(text, pos)
  355.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● メッセージの更新 *
  359.   #--------------------------------------------------------------------------
  360.   def update_message
  361.     @wait_count = @type_wait
  362.     loop do
  363.       c = @text.slice!(/./m)
  364.       case update_message_type(c)
  365.       when 1
  366.         break
  367.       when 2
  368.         next
  369.       end
  370.       break unless @show_fast or @line_show_fast
  371.     end
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # 一文字の描画 (返り値 1:break, 2:next)
  375.   #--------------------------------------------------------------------------
  376. #=begin
  377.   def process_escape_character(code, text, pos)
  378.     case code.upcase
  379.     when '$'
  380.       @gold_window.open
  381.     when '.'
  382.       wait(15)
  383.     when '|'
  384.       wait(60)
  385.     when '!'
  386.       input_pause
  387.     when '>'
  388.       @line_show_fast = true
  389.     when '<'
  390.       @line_show_fast = false
  391.     when '^'
  392.       @pause_skip = true
  393.     #when 'n'                      # 改行
  394.     #  new_line
  395.     #  max = MAX_LINE
  396.     #  max = 14 if self.pop_character != nil
  397.     #  if @line_count >= max      # 行数が最大のとき
  398.     #    unless @text.empty?           # さらに続きがあるなら
  399.     #      self.pause = true           # 入力待ちを入れる
  400.           #return 1
  401.     #    end
  402.     #  end
  403.     #when 'S'                       # \S[n]  (スピード変更)
  404.     #  text.sub!(/\[([0-9]+)\]/, "")
  405.     #  @type_wait = $1.to_i
  406.     #  return 2
  407.     when 'O'                       # \O 文字を透明にする。
  408.       text.sub!(/\[([0-9]+)\]/, "")
  409.       contents.font.color.alpha = $1.to_i
  410.       #return 2
  411.     when 'D' #\D 文字に影をつける
  412.       contents.font.shadow ^= true
  413.     #when '18'
  414.     #  name = ($game_temp.last_gain_holder.name rescue "")
  415.     #  update_message_type_draw_at(name)
  416.     #when '19'
  417.     #  item = ($game_temp.last_gain_material.item rescue nil)
  418.     #  draw_item_name(item, @contents_x, @contents_y)
  419.     #  @contents_x += 196
  420.     else
  421.       super
  422.     end
  423.         
  424.   end
  425. #=end
  426.   #--------------------------------------------------------------------------
  427.   # ● 改ページ処理
  428.   #--------------------------------------------------------------------------
  429.   alias xrxsv2_new_page new_page
  430.   def new_page(text, pos)
  431.     xrxsv2_new_page(text, pos)
  432.     update_charpop_window
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● 改行位置の取得
  436.   #--------------------------------------------------------------------------
  437.   #def new_line_x
  438.   #  $game_message.face_name.empty? ? 0 : 112
  439.   #end
  440.   #--------------------------------------------------------------------------
  441.   # ● 改行処理
  442.   #--------------------------------------------------------------------------
  443.   alias xrxsv2_new_line_x new_line_x
  444.   def new_line
  445.     xrxsv2_new_line
  446.     set_align
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   # 位置揃え
  450.   #--------------------------------------------------------------------------
  451.   def set_align
  452.     w = @line_widths[@line_count].to_i
  453.     a = @line_aligns[@line_count]
  454.     case a
  455.     when CENTER
  456.       @contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
  457.     when RIGHT
  458.       @contents_x = contents.width - w
  459.     end
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● ファイバーのメイン処理 ☆再定義
  463.   #--------------------------------------------------------------------------
  464.   def fiber_main
  465.     $game_message.visible = true
  466.     update_background
  467.     update_placement
  468.     loop do
  469.       process_all_text if $game_message.has_text?
  470.       process_input
  471.       $game_message.clear
  472.       @gold_window.close
  473.       process_hold #ホールドウィンドウの処理。
  474.       Fiber.yield
  475.       break unless text_continue?
  476.     end
  477.     close_and_wait
  478.     $game_message.visible = false
  479.     @fiber = nil
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # 定数
  483.   #--------------------------------------------------------------------------
  484.   AUTO   = 0
  485.   LEFT   = 1
  486.   CENTER = 2
  487.   RIGHT  = 3
  488. end
  489. #==============================================================================
  490. # アクティブイベント取得
  491. #==============================================================================
  492. class Game_Interpreter
  493.   attr_reader   :event_id
  494. end


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



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

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

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


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


  1087. #==============================================================================
  1088. # ■ SceneManager
  1089. #------------------------------------------------------------------------------
  1090. #  シーン遷移のさい、テールを破棄する。
  1091. #==============================================================================
  1092. module SceneManager
  1093.   #--------------------------------------------------------------------------
  1094.   # ● 呼び出し
  1095.   #--------------------------------------------------------------------------
  1096.   def self.call_sceman_hukidasi(scene_class)
  1097.     if defined?(self.scene.message_window)
  1098.       self.scene.message_window.del_tail if self.scene.message_window.tail != nil
  1099.     end
  1100.     @stack.push(@scene)
  1101.     @scene = scene_class.new
  1102.   end
  1103.   #--------------------------------------------------------------------------
  1104.   # ● クラスメソッドのエイリアス
  1105.   #--------------------------------------------------------------------------
  1106.   class << self
  1107.     alias :call_sceman_hukidasi_default :call
  1108.     alias :call :call_sceman_hukidasi
  1109.   end
  1110. end

  1111. #==============================================================================
  1112. # ■ Scene_Map
  1113. #------------------------------------------------------------------------------
  1114. #  戦闘トランジションのさい、テールを破棄。
  1115. #==============================================================================
  1116. class Scene_Map < Scene_Base
  1117.   attr_accessor :message_window
  1118.   #--------------------------------------------------------------------------
  1119.   # ● 戦闘前トランジション実行
  1120.   #--------------------------------------------------------------------------
  1121.   def perform_battle_transition_hukidasi
  1122.     @message_window.del_tail #テールの破棄
  1123.     perform_battle_transition_hukidasi_default
  1124.   end
  1125.   alias_method :perform_battle_transition_hukidasi_default, :perform_battle_transition
  1126.   alias_method :perform_battle_transition, :perform_battle_transition_hukidasi
  1127. end
复制代码
「空メッセージでウィンドウを開かない」和「立ち絵表示」,本来是三个,不过「ネームウィンドウ」不能共用
  1. #===========================================================================
  2. # ◆ A1 Scripts ◆
  3. #    空メッセージでウィンドウを開かない(RGSS3)
  4. #
  5. # バージョン   : 1.00 (2011/12/15)
  6. # 作者         : A1
  7. # URL     : http://a1tktk.web.fc2.com/
  8. #---------------------------------------------------------------------------
  9. # 機能:
  10. # ・空メッセージやメッセージに出さないコマンドのみの文章の時
  11. #  メッセージウィンドウを開かないようにします
  12. #---------------------------------------------------------------------------
  13. # 更新履歴   :2011/12/15 Ver1.00 リリース
  14. #---------------------------------------------------------------------------
  15. # 設置場所      
  16. #    再定義メソッドのため、なるべく上の方
  17. #
  18. # 必要スクリプト
  19. #    なし
  20. #---------------------------------------------------------------------------
  21. # 使い方
  22. # このスクリプトを導入することで適用されます
  23. #==============================================================================
  24. $imported ||= {}
  25. $imported["A1_EmptyMassage"] = true
  26. #==============================================================================
  27. # ■ Window_Message
  28. #------------------------------------------------------------------------------
  29. #  文章表示に使うメッセージウィンドウです。
  30. #==============================================================================

  31. class Window_Message < Window_Base
  32.   #--------------------------------------------------------------------------
  33.   # ★ 全テキストの処理
  34.   #--------------------------------------------------------------------------
  35.   def process_all_text
  36.     text = convert_escape_characters($game_message.all_text)
  37.     pos = {}
  38.     new_page(text, pos)
  39.     open_and_wait if chk_text(text.clone)
  40.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ○ 文章のチェック
  44.   #--------------------------------------------------------------------------
  45.   def chk_text(text)
  46.     text.gsub!(/\e.+\[.+\]/,"")
  47.     text.gsub!(/\e\^/,"")
  48.     text.gsub!(/\n/,"")
  49.     return false if text.empty?
  50.     return true
  51.   end
  52. end
复制代码
  1. #===========================================================================
  2. # ◆ A1 Scripts ◆
  3. #    立ち絵表示(RGSS3)
  4. #
  5. # バージョン   : 1.10 (2011/12/15)
  6. # 作者         : A1
  7. # URL     : http://a1tktk.web.fc2.com/
  8. #---------------------------------------------------------------------------
  9. # 機能:
  10. # ・「ピクチャの表示」などを使わなくても立ち絵を表示・非表示・移動します
  11. #---------------------------------------------------------------------------
  12. # 更新履歴   :2011/12/15 Ver1.00 リリース
  13. #---------------------------------------------------------------------------
  14. # 設置場所      
  15. #  RGSS3用A1共通スクリプトより下
  16. #    (ネームウィンドウ以下)
  17. #
  18. # 必要スクリプト
  19. #    RGSS3用A1共通処理
  20. #---------------------------------------------------------------------------
  21. # 使い方
  22. #  顔グラフィックに対応した立ち絵を
  23. #  Picturesフォルダにインポートすれば機能します
  24. #
  25. #  対応する立ち絵のファイル名は
  26. #  [顔グラフィックファイル名]_[顔グラフィックスインデックス]_[0 or 1]
  27. #  
  28. #  例:顔グラフィック Actor1 のIndex 0 (ラルフ) の場合
  29. #    Actor1_0_0 が対応立ち絵になります
  30. #    Actor1_0_1 があれば口パクします
  31. #
  32. #  立ち絵表示フラグをOnにすると、立ち絵が表示されるようになります
  33. #  立ち絵表示フラグの番号は設定項目で設定できます
  34. #
  35. # 名前の置き換え
  36. #  設定項目の「名前の置き換え」を設定することで
  37. #  顔グラフィックファイル名と、表示する立ちグラフィックの関連付けができます
  38. #
  39. #  例1(1つの顔グラフィックファイルを複数キャラで使用する場合)
  40. #   "Actor1"  =>  [["ラルフ",0],["アリシア",0],nil,nil,
  41. #                    nil,         nil,          nil,nil],
  42. #
  43. #   顔グラフィックファイル「Actor1」のIndex0を表示した際
  44. #   ラルフ_0_0 が対応立ち絵になります
  45. #   ラルフ_0_1 があれば口パクします
  46. #
  47. #   「Actor1」のIndex1を表示した際は
  48. #   アリシア_0_0 が対応立ち絵になります
  49. #   アリシア_0_1 があれば口パクします
  50. #
  51. #  例2(複数の顔グラフィックファイルを1キャラで使用する場合)
  52. #   "ラルフ"     => [["ラルフ",0]]  (省略可能)
  53. #   "ラルフ_ex"  => [["ラルフ",1]]
  54. #
  55. #   顔グラフィックファイル「ラルフ」「ラルフ_ex」に対応した
  56. #   全ての立ち絵を、「ラルフ」の立ち絵として扱います
  57. #---------------------------------------------------------------------------
  58. # 追加文章中コマンド
  59. #
  60. #  \TURN[direction]              翻转图片
  61. #                                direction = 向きを指定します (L or R)
  62. #
  63. #                                L : 元の立ち絵を反転させます
  64. #                                R : 反転を元の立ち絵に戻します
  65. #                                使用例:\TURN[L]
  66. #
  67. #  \RETURN[duration]             立ち絵を所定の位置に戻します
  68. #                                duration = 移動完了までの時間(フレーム)
  69. #
  70. #  \ERASE                        立ち絵を消去します
  71. #
  72. #  \SHOW                         消去した立ち絵を表示させます
  73. #
  74. #  \TONE[duration,red,green,blue,gray]
  75. #                                立ち絵の色調を変更します
  76. #                                duration = 色調変更完了までの時間(フレーム)
  77. #                                red      = 色調の赤要素
  78. #                                green    = 色調の緑要素
  79. #                                blue     = 色調の青要素
  80. #                                gray     = 色調のグレー要素(省略可)
  81. #
  82. #  \MV[x,y,duration]             立ち絵を移動します(絶対座標)
  83. #                                x        = 移動先のx座標
  84. #                                y        = 移動先のy座標
  85. #                                duration = 移動完了までの時間(フレーム)
  86. #
  87. #  \MVA[x,y,duration]            立ち絵を移動します(相対座標)
  88. #                                x        = x方向の移動距離
  89. #                                y        = y方向の移動距離
  90. #                                duration = 移動完了までの時間(フレーム)
  91. #
  92. #  \OP[opacity,duration]         立ち絵の透明度を変更します
  93. #                                opacity  = 透明度
  94. #                                duration = 透明度変更完了までの時間(フレーム)
  95. #
  96. #
  97. #  \BYE[direction,duration]      立ち絵を画面外に移動させます
  98. #                                direction = 向きを指定します (L or R or D)
  99. #                                duration  = 移動完了までの時間(フレーム)
  100. #
  101. #                                L : 画面左に退場します
  102. #                                R : 画面右に退場します
  103. #                                D : 画面下に退場します
  104. #                                使用例:\BYE[L,60]
  105. #==============================================================================
  106. $imported ||= {}
  107. $imported["A1_Stand_Picture"] = true
  108. if $imported["A1_Common_Script"]
  109. #==============================================================================
  110. # ■ 設定項目
  111. #==============================================================================
  112. module A1_System::StandPicture
  113.   
  114.   # 名前の置き換え
  115.   NAME_CHANGE = {
  116.   
  117.     "吕@八健将_1"  =>  [["高顺",0],["高顺",0],nil,nil,
  118.                     nil,         nil,          nil,nil],
  119.   }
  120.   
  121. end
  122. #==============================================================================
  123. # ■ Window_Message
  124. #------------------------------------------------------------------------------
  125. #  文章表示に使うメッセージウィンドウです。
  126. #==============================================================================

  127. class Window_Message < Window_Base
  128.   #--------------------------------------------------------------------------
  129.   # ○ 定数
  130.   #--------------------------------------------------------------------------
  131.   LEFT  = 0
  132.   RIGHT = 1
  133.   BYE_DURATION = 30
  134.   MOVE_DURATION = 30
  135.   #--------------------------------------------------------------------------
  136.   # ☆ オブジェクト初期化
  137.   #--------------------------------------------------------------------------
  138.   alias a1_stand_picture_window_message_initialize initialize
  139.   def initialize
  140.     @stand_pic = {}
  141.     @show_pos = []
  142.     @prev_name = ""
  143.     @pre_message = false
  144.     a1_stand_picture_window_message_initialize
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ☆ 改ページ処理
  148.   #--------------------------------------------------------------------------
  149.   alias a1_stand_picture_window_message_new_page new_page
  150.   def new_page(text, pos)
  151.    
  152.     file_name = $game_message.face_name
  153.     file_index = $game_message.face_index
  154.    
  155.     file_info = find_name(file_name, file_index)
  156.     name = file_info[0]
  157.     index = file_info[1]
  158.    
  159.     # 顔グラフィックがない
  160.     if name.empty?
  161.       
  162.       # 従来の改ページ処理
  163.       a1_stand_picture_window_message_new_page(text, pos)
  164.       return
  165.       
  166.     # 顔グラフィックがある
  167.     else
  168.       
  169.       # 立ち絵作成(新顔なら表示)
  170.       new_face = false
  171.       new_face = create_stand_pic(file_name, name, index) if @stand_pic[name] == nil
  172.       
  173.       # 立ち絵がない
  174.       unless stand_pic_enable?(name)
  175.         
  176.         # 従来の改ページ処理
  177.         a1_stand_picture_window_message_new_page(text, pos)
  178.         return
  179.       end
  180.     end
  181.    
  182.     unless new_face
  183.       if show_pos(name) > -1
  184.         # 顔グラフィック変更
  185.         @stand_pic[name].change_face(file_name, index)
  186.         
  187.       elsif @show_pos.size == 2
  188.         change_character(file_name, name, index)
  189.         
  190.       else
  191.         create_stand_pic(file_name, name, index)
  192.       end
  193.     end
  194.     # 顔グラフィックスを一度emptyにする
  195.     $game_message.face_name = "" if @stand_pic[name].enable_bitmap?(index)
  196.     # 従来の改ページ処理
  197.     a1_stand_picture_window_message_new_page(text, pos)
  198.     # 顔グラフィックスを戻す
  199.     $game_message.face_name = file_name
  200.     # 直前に話した名前を入れる
  201.     @prev_name = name
  202.    
  203.     if $imported["A1_Name_Window"]
  204.       
  205.       pos = show_pos(name)
  206.       
  207.       unless stand_pic_enable?(name)
  208.         show_name_window(file_name, file_index, 0)
  209.         
  210.       else
  211.         bitmap_width = @stand_pic[name].pic_sprite.bitmap.width
  212.         
  213.         x = bitmap_width / 2 if pos == 0
  214.         x = Graphics.width - bitmap_width / 2 if pos == 1
  215.         
  216.         show_name_window(file_name, file_index, x, 0)
  217.       end
  218.     end
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ☆ 改行処理
  222.   #--------------------------------------------------------------------------
  223.   alias a1_stand_picture_window_message_new_line_x new_line_x
  224.   def new_line_x
  225.    
  226.     file_name = $game_message.face_name
  227.     file_index = $game_message.face_index
  228.    
  229.     file_info = find_name(file_name, file_index)
  230.     name = file_info[0]
  231.     index = file_info[1]
  232.    
  233.     # 顔グラフィックがない
  234.     if name.empty?
  235.       
  236.       # 従来の改行処理
  237.       return a1_stand_picture_window_message_new_line_x
  238.     end
  239.    
  240.     # 立ち絵がない
  241.     unless stand_pic_enable?(name)
  242.       
  243.       # 従来の改行処理
  244.       return a1_stand_picture_window_message_new_line_x
  245.     end
  246.    
  247.     # 顔グラフィックスを一度emptyにする
  248.     $game_message.face_name = "" if @stand_pic[name].enable_bitmap?(index)
  249.     # 従来の改行処理
  250.     ret = a1_stand_picture_window_message_new_line_x
  251.     # 顔グラフィックスを戻す
  252.     $game_message.face_name = file_name
  253.    
  254.     return ret
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # ○ 立ち絵作成
  258.   #--------------------------------------------------------------------------
  259.   def create_stand_pic(file_name, name, index, duration = MOVE_DURATION)
  260.    
  261.     @stand_pic[name] = Game_StandPic.new(name, index)
  262.    
  263.     return if @stand_pic[name].pic_sprite == nil
  264.     return unless $game_system.show_stand_picture
  265.    
  266.     if @show_pos.size == 0
  267.       pos = LEFT
  268.       @show_pos[0] = name
  269.       
  270.     elsif @show_pos.size == 1
  271.       pos = RIGHT
  272.       @show_pos[1] = name
  273.    
  274.     else
  275.       change_character(file_name, name, index)
  276.       return true
  277.     end
  278.    
  279.     @stand_pic[name].show(file_name, pos,index, duration)
  280.     return true
  281.    
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ○ 表示する立ち絵の変更
  285.   #--------------------------------------------------------------------------
  286.   def change_character(file_name, name, index, duration = MOVE_DURATION)
  287.    
  288.     return if @stand_pic[name].pic_sprite == nil
  289.     return unless $game_system.show_stand_picture
  290.    
  291.     no_index = no_prev_index
  292.     no_prev_name = @show_pos[no_index]
  293.    
  294.     case no_index
  295.     when 0
  296.       @stand_pic[no_prev_name].bye("L",BYE_DURATION) if stand_pic_enable?(no_prev_name)
  297.       pos = LEFT
  298.       @show_pos[0] = name
  299.       
  300.     when 1
  301.       @stand_pic[no_prev_name].bye("R",BYE_DURATION) if stand_pic_enable?(no_prev_name)
  302.       pos = RIGHT
  303.       @show_pos[1] = name
  304.     end
  305.     @stand_pic[name].show(file_name, pos,index, duration) if stand_pic_enable?(name)
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ○ 直前に話していないIndexを取得
  309.   #--------------------------------------------------------------------------
  310.   def no_prev_index
  311.     return 0 if @show_pos[0] != @prev_name
  312.     return 1 if @show_pos[1] != @prev_name
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ○ 表示されているか調べる
  316.   #--------------------------------------------------------------------------
  317.   def show_pos(name)
  318.     return 0 if @show_pos[0] == name
  319.     return 1 if @show_pos[1] == name
  320.     return -1
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ☆ フレーム更新
  324.   #--------------------------------------------------------------------------
  325.   alias a1_stand_pic_window_message_update update
  326.   def update
  327.     update_stand_pic
  328.     a1_stand_pic_window_message_update
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # ○ 立ち絵のアップデート
  332.   #--------------------------------------------------------------------------
  333.   def update_stand_pic
  334.     for name in @stand_pic.keys
  335.       @stand_pic[name].update
  336.     end
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ○ 文章のチェック
  340.   #--------------------------------------------------------------------------
  341.   alias a1_stand_pic_wm_chk_text chk_text
  342.   def chk_text(text)
  343.     text.gsub!(/\eERASE/,"")
  344.     text.gsub!(/\eSHOW/,"")
  345.     return a1_stand_pic_wm_chk_text(text)
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ☆ 制御文字の処理
  349.   #     code : 制御文字の本体部分(「\C[1]」なら「C」)
  350.   #     text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
  351.   #     pos  : 描画位置 {:x, :y, :new_x, :height}
  352.   #--------------------------------------------------------------------------
  353.   alias a1_stand_pic_wm_process_escape_character process_escape_character
  354.   def process_escape_character(code, text, pos)
  355.    
  356.     file_name = $game_message.face_name
  357.     file_index = $game_message.face_index
  358.    
  359.     file_info = find_name(file_name, file_index)
  360.     name = file_info[0]
  361.     index = file_info[1]
  362.    
  363.     case code.upcase
  364.     when 'TURN'
  365.       text.slice!(/\[(.)\]/) rescue 0
  366.       if stand_bitmap_enable?(name, index)
  367.         case $1
  368.         when 'L'
  369.           @stand_pic[name].pic_sprite.mirror = true
  370.         when 'R'
  371.           @stand_pic[name].pic_sprite.mirror = false
  372.         end
  373.       end
  374.       return true
  375.       
  376.     when 'RETURN'
  377.       text.slice!(/\[(\d+)\]/) rescue 0
  378.       if stand_bitmap_enable?(name, index)
  379.         index = show_pos(name)
  380.         return if index == -1
  381.         duration = $1.to_i
  382.         @stand_pic[name].return_pos(index, duration)
  383.       end
  384.       
  385.     when 'SHOW'
  386.       if stand_bitmap_enable?(name, index)
  387.         return if @stand_pic[name].pic_sprite == nil or name.empty?
  388.         @stand_pic[name].pic_sprite.visible = true
  389.       end
  390.       
  391.     when 'ERASE'
  392.       if stand_bitmap_enable?(name, index)
  393.         return if @stand_pic[name].pic_sprite == nil or name.empty?
  394.         @stand_pic[name].pic_sprite.visible = false
  395.       end
  396.       
  397.     when 'TONE'
  398.       text.slice!(/\[(.+)\]/) rescue 0
  399.       if stand_bitmap_enable?(name, index)
  400.         params = $1.to_s.split(",")
  401.         duration = params[0].to_i
  402.         red   = $a1_common.minus_to_i(params[1])
  403.         green = $a1_common.minus_to_i(params[2])
  404.         blue  = $a1_common.minus_to_i(params[3])
  405.         gray  = $a1_common.minus_to_i(params[4]) unless params[4] == nil
  406.         if gray == nil
  407.           tone = Tone.new(red, green, blue)
  408.         else
  409.           tone = Tone.new(red, green, blue, gray)
  410.         end
  411.         @stand_pic[name].start_tone_change(tone, duration)
  412.       end
  413.       
  414.     when 'MV'
  415.       text.slice!(/\[([-]*\d+)[,]([-]*\d+)[,](\d+)\]/) rescue 0
  416.       if stand_bitmap_enable?(name, index)
  417.         x = $a1_common.minus_to_i($1)
  418.         y = $a1_common.minus_to_i($2)
  419.         duration = $3.to_i
  420.         @stand_pic[name].move(x, y, duration)
  421.       end
  422.       
  423.     when 'MVA'
  424.       text.slice!(/\[([-]*\d+)[,]([-]*\d+)[,](\d+)\]/) rescue 0
  425.       if stand_bitmap_enable?(name, index)
  426.         x = $a1_common.minus_to_i($1)
  427.         y = $a1_common.minus_to_i($2)
  428.         duration = $3.to_i
  429.         @stand_pic[name].move_plus(x, y, duration)
  430.       end
  431.       
  432.     when 'OP'
  433.       text.slice!(/\[(\d+)[,](\d+)\]/) rescue 0
  434.       if stand_bitmap_enable?(name, index)
  435.         @stand_pic[name].change_opacity($1.to_i,$2.to_i)
  436.       end
  437.       
  438.     when 'BYE'
  439.       text.slice!(/^\[(.)[,](\d+)\]/) rescue 0
  440.       if stand_bitmap_enable?(name, index)
  441.         @show_pos.delete_at(show_pos(name))
  442.         @stand_pic[name].bye($1,$2.to_i)
  443.       end
  444.       
  445.     else
  446.       a1_stand_pic_wm_process_escape_character(code, text, pos)
  447.     end
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ☆ 通常文字の処理
  451.   #--------------------------------------------------------------------------
  452.   alias a1_stand_pic_wm_process_normal_character process_normal_character
  453.   def process_normal_character(c, pos)
  454.    
  455.     file_name = $game_message.face_name
  456.     file_index = $game_message.face_index
  457.    
  458.     file_info = find_name(file_name, file_index)
  459.     name = file_info[0]
  460.     index = file_info[1]
  461.    
  462.     if stand_bitmap_enable?(name, index)
  463.       @stand_pic[name].mouth_move
  464.     end
  465.     a1_stand_pic_wm_process_normal_character(c, pos)
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # ○ 立ち絵が有効?
  469.   #--------------------------------------------------------------------------
  470.   def stand_pic_enable?(name)
  471.     return false if name.empty?
  472.     return false if @stand_pic[name] == nil
  473.     return false if @stand_pic[name].pic_sprite == nil
  474.     return false unless $game_system.show_stand_picture
  475.     return true
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ○ ビットマップが有効?
  479.   #--------------------------------------------------------------------------
  480.   def stand_bitmap_enable?(name, index)
  481.     return false if name.empty?
  482.     return false if @stand_pic[name].pic_sprite == nil
  483.     return false unless @stand_pic[name].enable_bitmap?(index)
  484.     return false unless $game_system.show_stand_picture
  485.     return true
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ☆ 解放
  489.   #--------------------------------------------------------------------------
  490.   alias a1_stand_pic_window_message_dispose dispose
  491.   def dispose
  492.     a1_stand_pic_window_message_dispose
  493.     dispose_stand_picture
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ○ 立ち絵の解放
  497.   #--------------------------------------------------------------------------
  498.   def dispose_stand_picture
  499.     for name in @stand_pic.keys
  500.       @stand_pic[name].erase
  501.     end
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ○ 名前の検索
  505.   #--------------------------------------------------------------------------
  506.   def find_name(filename, fileindex)
  507.     list = A1_System::StandPicture::NAME_CHANGE[filename]
  508.     return [filename,fileindex] if list == nil
  509.    
  510.     if list.size == 1
  511.       info = list[0]
  512.       return [info[0],info[1]*8+fileindex]
  513.     end
  514.    
  515.     return [filename,fileindex] if list[fileindex] == nil
  516.     return list[fileindex]
  517.   end
  518. end
  519. #==============================================================================
  520. # ■ Game_StandPic
  521. #==============================================================================

  522. class Game_StandPic
  523.   #--------------------------------------------------------------------------
  524.   # ○ 定数
  525.   #--------------------------------------------------------------------------
  526.   LEFT  = 0
  527.   RIGHT = 1
  528.   MOVE_DURATION = 30
  529.   MOUTH_MOVE_DURATION = 4
  530.   #--------------------------------------------------------------------------
  531.   # ● 公開インスタンス変数
  532.   #--------------------------------------------------------------------------
  533.   attr_reader   :x                        # X 座標
  534.   attr_reader   :y                        # Y 座標
  535.   attr_reader   :opacity                  # 不透明度
  536.   attr_reader   :tone                     # 色調
  537.   attr_reader   :mirror                   # 左右反転
  538.   attr_reader   :pic_sprite               # スプライト
  539.   attr_reader   :bitmap                   # ビットマップの配列
  540.   #--------------------------------------------------------------------------
  541.   # ● オブジェクト初期化
  542.   #     number : ピクチャ番号
  543.   #--------------------------------------------------------------------------
  544.   def initialize(name, index)
  545.     @name = name
  546.     @duration = 0
  547.     @target_opacity = 255.0
  548.     @tone = Tone.new(0, 0, 0, 0)
  549.     @tone_target = Tone.new(0, 0, 0, 0)
  550.     @tone_duration = 0
  551.     @mirror = false
  552.     @pic_sprite = nil
  553.    
  554.     @face_index = 0
  555.     @mouth_index = 0
  556.     @mouth_move_duration = 0
  557.     @pos = -1
  558.    
  559.     @bitmap = []
  560.     @bitmap_test = []
  561.     plus = (index / 8) * 8
  562.     create_bitmap(name, plus)
  563.    
  564.     @pic_sprite = create_sprite if @bitmap.size > 0
  565.   end
  566.   #--------------------------------------------------------------------------
  567.   # ● スプライトの作成
  568.   #--------------------------------------------------------------------------
  569.   def create_sprite
  570.     pic_sprite = Sprite.new
  571.     pic_sprite.visible = false
  572.     return pic_sprite
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● ビットマップの作成
  576.   #--------------------------------------------------------------------------
  577.   def create_bitmap(name, plus = 0)
  578.    
  579.     file = sprintf("Graphics/Pictures/%s",name)
  580.    
  581.     Dir::glob(sprintf("%s*.*",file)).each {|f|
  582.    
  583.       next unless f =~ /#{file}_(\d+)_(\d+)/i
  584.       next unless FileTest.file?(f)
  585.       next unless file_ext(f)
  586.       
  587.       index = $1.to_i + plus
  588.       
  589.       @bitmap[index] = [] if @bitmap[index] == nil
  590.       file_name = File.basename(f,".*")
  591.       @bitmap[index][$2.to_i] = Cache.picture(file_name)
  592.       @bitmap_test[index] = true
  593.     }
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● 拡張子を調べる
  597.   #--------------------------------------------------------------------------
  598.   def file_ext(f)
  599.     return true if File::extname(f) == ".png"
  600.     return true if File::extname(f) == ".bmp"
  601.     return false
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # ● ビットマップの存在を調べる
  605.   #--------------------------------------------------------------------------
  606.   def enable_bitmap?(index)
  607.     return false if @bitmap[index] == nil
  608.     return true
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● 代替ビットマップの検索
  612.   #--------------------------------------------------------------------------
  613.   def search_bitmap
  614.     for bitmap in @bitmap
  615.       next if bitmap == nil
  616.       return bitmap[0]
  617.     end
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● ピクチャの表示
  621.   #--------------------------------------------------------------------------
  622.   def show(file_name, pos, index, duration, opacity = 255)
  623.    
  624.     @face_index = index
  625.     @pos = pos
  626.    
  627.     if @bitmap[@face_index] == nil and @bitmap_test[@face_index] != true
  628.       plus = (@face_index / 8) * 8
  629.       create_bitmap(file_name, plus)
  630.     end
  631.    
  632.     if @bitmap[@face_index] == nil or $game_system.show_stand_picture == false
  633.       @pic_sprite.bitmap = nil
  634.       @pic_sprite.visible = false
  635.       bitmap = search_bitmap
  636.     else
  637.       @pic_sprite.visible = true
  638.       @pic_sprite.bitmap = @bitmap[@face_index][0]
  639.       bitmap = @pic_sprite.bitmap
  640.     end
  641.    
  642.     fix_pos(pos, duration, bitmap, opacity)
  643.    
  644.     return true
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # ● 場所確定
  648.   #--------------------------------------------------------------------------
  649.   def fix_pos(pos, duration, bitmap, opacity)
  650.     case pos
  651.     when LEFT
  652.       @pic_sprite.x = (0 - bitmap.width).to_f
  653.       @target_x = 0.0
  654.       @duration = duration
  655.       @pic_sprite.mirror = false
  656.       
  657.     when RIGHT
  658.       @pic_sprite.x = Graphics.width.to_f
  659.       @target_x = (Graphics.width - bitmap.width).to_f
  660.       @duration = duration
  661.       @pic_sprite.mirror = true
  662.     end
  663.    
  664.     @pic_sprite.opacity = opacity.to_f
  665.     @pic_sprite.visible = true
  666.    
  667.     @pic_sprite.y = (Graphics.height - bitmap.height).to_f
  668.     @target_y = @pic_sprite.y
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # ● 定位置に戻る
  672.   #--------------------------------------------------------------------------
  673.   def return_pos(pos, duration)
  674.     case pos
  675.     when LEFT
  676.       @target_x = 0.0
  677.       @duration = duration
  678.       @pic_sprite.mirror = false
  679.       
  680.     when RIGHT
  681.       @target_x = (Graphics.width - @pic_sprite.bitmap.width).to_f
  682.       @duration = duration
  683.       @pic_sprite.mirror = true
  684.     end
  685.     @target_y = (Graphics.height - @pic_sprite.bitmap.height).to_f
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # ● 顔変更
  689.   #--------------------------------------------------------------------------
  690.   def change_face(name, index)
  691.     @face_index = index
  692.    
  693.     if @bitmap[@face_index] == nil and @bitmap_test[@face_index] != true
  694.       plus = (@face_index / 8) * 8
  695.       create_bitmap(name, plus)
  696.     end
  697.    
  698.     if @bitmap[@face_index] == nil or $game_system.show_stand_picture == false
  699.       @pic_sprite.bitmap = nil
  700.       @pic_sprite.visible = false
  701.       
  702.     else
  703.       @pic_sprite.bitmap = @bitmap[@face_index][0]
  704.       case @pos
  705.       when LEFT
  706.         @pic_sprite.x = 0.0
  707.         
  708.       when RIGHT
  709.         @pic_sprite.x = (Graphics.width - @pic_sprite.bitmap.width).to_f
  710.       end
  711.       @pic_sprite.y = (Graphics.height - @pic_sprite.bitmap.height).to_f
  712.       @target_x = @pic_sprite.x
  713.       @target_y = @pic_sprite.y
  714.       
  715.       @pic_sprite.visible = true
  716.     end
  717.   end
  718.   #--------------------------------------------------------------------------
  719.   # ● 口パク
  720.   #--------------------------------------------------------------------------
  721.   def mouth_move
  722.    
  723.     return if @mouth_move_duration > 0
  724.     return if bitmap[@face_index] == nil
  725.     return if bitmap[@face_index].size == 1
  726.    
  727.     @mouth_move_duration = MOUTH_MOVE_DURATION
  728.    
  729.     if @mouth_index == 0 and bitmap[@face_index][1] != nil
  730.       @mouth_index = 1
  731.     elsif @mouth_index == 1
  732.       @mouth_index = 0
  733.     end
  734.     @pic_sprite.bitmap = bitmap[@face_index][@mouth_index]
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # ● ピクチャの移動
  738.   #--------------------------------------------------------------------------
  739.   def move(x, y, duration)
  740.     @target_x = x
  741.     @target_y = y
  742.     @duration = duration
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # ● 透明度変更
  746.   #--------------------------------------------------------------------------
  747.   def change_opacity(opacity, duration)
  748.     @target_opacity = opacity
  749.     @duration = duration
  750.   end
  751.   #--------------------------------------------------------------------------
  752.   # ● 相対移動
  753.   #--------------------------------------------------------------------------
  754.   def move_plus(x, y, duration)
  755.     @target_x = @pic_sprite.x + x
  756.     @target_y = @pic_sprite.y + y
  757.     @duration = duration
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 退場
  761.   #--------------------------------------------------------------------------
  762.   def bye(direction, duration)
  763.    
  764.     return if @pic_sprite.bitmap == nil
  765.    
  766.     case direction
  767.     when "D"
  768.       @target_y = Graphics.height
  769.     when "R"
  770.       @target_x = Graphics.width
  771.     when "L"
  772.       @target_x = 0 - @pic_sprite.bitmap.width
  773.     end
  774.     @duration = duration
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● 色調変更の開始
  778.   #--------------------------------------------------------------------------
  779.   def start_tone_change(tone, duration)
  780.     @tone_target = tone.clone
  781.     @tone_duration = duration
  782.     if @tone_duration == 0
  783.       @tone = @tone_target.clone
  784.     end
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ● ピクチャの消去
  788.   #--------------------------------------------------------------------------
  789.   def erase
  790.    
  791.     for arr in @bitmap
  792.       next if arr == nil
  793.       for bitmap in arr
  794.         next if bitmap == nil
  795.         bitmap.dispose
  796.       end
  797.     end
  798.     @bitmap = nil
  799.    
  800.     return if @pic_sprite == nil
  801.    
  802.     @pic_sprite.dispose
  803.     @pic_sprite = nil
  804.   end
  805.   #--------------------------------------------------------------------------
  806.   # ● フレーム更新
  807.   #--------------------------------------------------------------------------
  808.   def update
  809.    
  810.     return if @pic_sprite == nil
  811.    
  812.     @mouth_move_duration -= 1 if @mouth_move_duration > 0
  813.     if @duration >= 1
  814.       d = @duration
  815.       @pic_sprite.x = (@pic_sprite.x * (d - 1) + @target_x) / d
  816.       @pic_sprite.y = (@pic_sprite.y * (d - 1) + @target_y) / d
  817.       @pic_sprite.opacity = (@pic_sprite.opacity * (d - 1) + @target_opacity) / d
  818.       @duration -= 1
  819.     end
  820.     if @tone_duration >= 1
  821.       d = @tone_duration
  822.       @tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
  823.       @tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
  824.       @tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
  825.       @tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
  826.       @tone_duration -= 1
  827.       @pic_sprite.tone = @tone
  828.     end
  829.   end
  830. end
  831. #==============================================================================
  832. # ■ Game_System
  833. #------------------------------------------------------------------------------
  834. #  システム周りのデータを扱うクラスです。乗り物や BGM などの管理も行います。
  835. # このクラスのインスタンスは $game_system で参照されます。
  836. #==============================================================================

  837. class Game_System
  838.   #--------------------------------------------------------------------------
  839.   # ● 公開インスタンス変数
  840.   #--------------------------------------------------------------------------
  841.   attr_accessor :show_stand_picture                # 立ち絵表示フラグ
  842.   #--------------------------------------------------------------------------
  843.   # ☆ オブジェクト初期化
  844.   #--------------------------------------------------------------------------
  845.   alias a1_stand_picture_game_system_initialize initialize
  846.   def initialize
  847.     a1_stand_picture_game_system_initialize
  848.     @show_stand_picture = false
  849.   end
  850. end
  851. #==============================================================================
  852. # ■ Game_Interpreter
  853. #------------------------------------------------------------------------------
  854. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  855. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  856. #==============================================================================

  857. class Game_Interpreter
  858.   
  859.   #--------------------------------------------------------------------------
  860.   # ○ 注釈の処理
  861.   #--------------------------------------------------------------------------
  862.   alias a1_stand_picture_proc_comment_command proc_comment_command
  863.   def proc_comment_command(command, params)
  864.    
  865.     if command == "立ち絵表示"
  866.       case params[0]
  867.       when "on"
  868.         $game_system.show_stand_picture = true
  869.       when "off"
  870.         $game_system.show_stand_picture = false
  871.       end
  872.     else
  873.       a1_stand_picture_proc_comment_command(command, params)
  874.     end
  875.   end
  876. end
  877. end
复制代码
差不多就这样了……

点评

- -b脚本最好贴出来...  发表于 2012-12-26 21:14
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-14 13:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表