Advertisement
FlipelyFlip

Chiisai+pitch+sound+icons+fis+think+shake+pet

Sep 29th, 2012
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 33.66 KB | None | 0 0
  1. # ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
  2. #
  3. # publish 2010/ 3/ 2
  4. # update  - 11/ 1/10a
  5. #
  6. #==============================================================================
  7. # カスタマイズポイント
  8. #==============================================================================
  9. class Window_Message < Window_Selectable
  10.   #
  11.   # 基本行数
  12.   #
  13.   MAX_LINE = 4
  14.   #
  15.   # \p[] - キャラポップの高さ
  16.   #
  17.   CHARPOP_HEIGHT = 40
  18.   #
  19.   # \name[] - 名前枠 X,Y座標
  20.   #
  21.   NAME_WINDOW_OFFSET_X =   0
  22.   NAME_WINDOW_OFFSET_Y = -24
  23.  
  24.   WINDOW_RECT  = Rect.new(0, 0, 544, 128)
  25.   P_WINDOW     = 2        # ポーズサイン位置 0 = 中央下 1 = 右下 2 = 文末
  26.   P_WINDOW_XY  = [-24,-24]# XY座標修正[X, Y]
  27.  
  28. end
  29.  
  30. module Y6
  31.   module MESSAGE
  32.     #==========================================================================
  33.     # Sectio I. Basic Settings
  34.     # -------------------------------------------------------------------------
  35.     # The following below will adjust the basic settings and that will affect
  36.     # the majority of the script.
  37.     #==========================================================================
  38.  
  39.     # This adjusts the pixel width given to your icons so they won't throw
  40.     # certain monospaced fonts out of alignment.
  41.     ICON_WIDTH = 24
  42.  
  43.     # This button is the button used to make message windows instantly skip
  44.     # forward. Hold down for the effect. Note that when held down, this will
  45.     # speed up the messages, but still wait for the pauses. However, it will
  46.     # automatically go to the next page when prompted.
  47.     TEXT_SKIP = Input::A     # Input::A is the shift button on keyboard.
  48.  
  49.     #==========================================================================
  50.     # Section IV. Sound Settings
  51.     # -------------------------------------------------------------------------
  52.     # When text is being played out on the screen by a message. This can be
  53.     # changed in game through the following script calls:
  54.     #   $game_message.text_sound = "name"     Filename of sound to be played.
  55.     #   $game_message.text_volume = 40        Volume of sound to be played.
  56.     #   $game_message.text_pitch  = 100       Pitch of sound to be played.
  57.     #==========================================================================
  58.    
  59.     # This adjusts the default sound that's played when text appears. If you
  60.     # don't want to use this feature, just set this value to nil.
  61.     SOUND_DEFAULT = "Cursor"
  62.    
  63.     # This adjusts the volume of the sound that's played when text appears.
  64.     SOUND_VOLUME = 60
  65.    
  66.     # The sound pitch varies each time it's played by this amount. This is so
  67.     # that the sound doesn't become monotonous and actually offers variability.
  68.     # Set this value to 0 if you don't want any changes.
  69.     SOUND_PITCH_OFFSET = 3
  70.   end
  71. end
  72.  
  73. #==============================================================================
  74. # 参照機能
  75. #==============================================================================
  76. class Game_Temp
  77.   attr_accessor :last_gain_material
  78.   attr_accessor :last_gain_holder
  79. end
  80. #==============================================================================
  81. # フルグレードアップベース - 制御文字・基本機能
  82. #==============================================================================
  83. class Window_Message < Window_Selectable
  84.   alias flip_init initialize
  85.   def initialize
  86.     flip_init
  87.     shake_reset                 # シェイク #flippy
  88.     self.x = WINDOW_RECT.x
  89.     self.y = WINDOW_RECT.y
  90.     self.width = WINDOW_RECT.width
  91.     self.height = WINDOW_RECT.height
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 特殊文字の変換 + 準備
  95.   #--------------------------------------------------------------------------
  96.   alias xrxsv2_convert_special_characters convert_special_characters
  97.   def convert_special_characters
  98.     # 初期化
  99.     contents.font.size   = Font.default_size
  100.     contents.font.bold   = Font.default_italic
  101.     contents.font.italic = Font.default_bold
  102.     contents.font.shadow = Font.default_shadow
  103.     @type_wait = 0
  104.     @line_widths = []
  105.     @line_aligns = []
  106.     self.pop_character = nil
  107.     # ウィンドウ保持指定\holdがあるか?
  108.     @window_hold = (@text.gsub!(/\\hold/) { "" } != nil)
  109.     # \info
  110.     @info_mode = (@text.gsub!(/\\info/) { "" } != nil)
  111.     # 改行削除指定\_があるか?
  112.     if (/\\_(.*?)\x00/.match(@text)) != nil
  113.       $game_message.choice_start -= 1
  114.       @text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
  115.     end
  116.     # \name 判定
  117.     if @text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  118.       name = $1
  119.       bitmap = @name_sprite.bitmap
  120.       w = [bitmap.text_size(name).width, 1].max
  121.       bitmap.dispose
  122.       @name_sprite.bitmap = Bitmap.new(w, 32)
  123.       bitmap = @name_sprite.bitmap
  124.       bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
  125.       @name_window.width = w + 16
  126.       @name_window.create_contents
  127.       @name_window.openness = 0
  128.       @name_window.open
  129.       @name_window.visible = true
  130.       @name_sprite.visible = true
  131.     elsif @text.sub!(/\\[Nn][Bb]\[(.*?)\]/) { "" }
  132.       name = $1
  133.       bitmap = @name_sprite.bitmap
  134.       w = [bitmap.text_size(name).width, 1].max
  135.       bitmap.dispose
  136.       @name_sprite.bitmap = Bitmap.new(w, 32)
  137.       bitmap = @name_sprite.bitmap
  138.       bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
  139.       @name_window.width = w + 16
  140.       @name_window.create_contents
  141.       @name_window.openness = 0
  142.       @name_window.open
  143.       @name_window.visible = true
  144.       @name_sprite.visible = true
  145.     else
  146.       @name_window.visible = false
  147.       @name_sprite.visible = false
  148.       @name_sprite.bitmap.dispose
  149.       @name_sprite.bitmap = Bitmap.new(32,32)
  150.     end
  151.     # キャラボップモード
  152.     if @text.gsub!(/\\[Pp]\[-1\]/) { "" }
  153.       self.pop_character = -1
  154.     elsif @text.gsub!(/\\[Pp]\[-2\]/) { "" }
  155.       self.pop_character = -2
  156.     elsif @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "" }
  157.       self.pop_character = $1.to_i
  158.     elsif @text.gsub!(/\\[Pp]/) { "" }
  159.       self.pop_character = 0
  160.     end
  161.     if @text.gsub!(/\\[Tt]/) { "" }
  162.       @think = true
  163.     else
  164.       @think = false
  165.     end
  166.     # 制御文字処理
  167.     xrxsv2_convert_special_characters
  168.     @text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\x11[#{$1}]" }
  169.     @text.gsub!(/\\size\[([0-9]+)\]/i) { "\x12[#{$1}]" }
  170.     @text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\x13[#{$1}]" }
  171.     @text.gsub!(/\\icon\[([0-9]+)\]/i) { "\x17[#{$1}]" }
  172.     @text.gsub!(/\\[Ii]\[([0-9]+)\]/i) { "\x17[#{$1}]" }
  173.     @text.gsub!(/\\last_holder/i) { "\x18" }
  174.     @text.gsub!(/\\last_material/i) { "\x19" }
  175.     @text.gsub!(/\\[Ff][Bb]/) { "\x14" }
  176.     @text.gsub!(/\\[Ff][Ii]/) { "\x15" }
  177.     @text.gsub!(/\\[Ff][Hh]/) { "\x16" }
  178.     @text.gsub!(/\\[Nn][Ll]/) { "\x00" }
  179.     @text.gsub!(/\\[Ii][Ii]\[(\d+)\]/i) {
  180.       "\x17{#{$data_items[$1.to_i].icon_index}}" +
  181.       "#{$data_items[$1.to_i].name}"}
  182.     @text.gsub!(/\\[Ii][Ww]\[(\d+)\]/i) {
  183.       "\x17{#{$data_weapons[$1.to_i].icon_index}}" +
  184.       "#{$data_weapons[$1.to_i].name}"}
  185.     @text.gsub!(/\\[Ii][Aa]\[(\d+)\]/i) {
  186.       "\x17{#{$data_armors[$1.to_i].icon_index}}" +
  187.       "#{$data_armors[$1.to_i].name}"}
  188.     @text.gsub!(/\\[Ii][Ss]\[(\d+)\]/i) {
  189.       "\x17{#{$data_skills[$1.to_i].icon_index}}" +
  190.       "#{$data_skills[$1.to_i].name}"}
  191.     @text.gsub!(/\\[Ii][Tt]\[(\d+)\]/i) {
  192.       "\x17{#{$data_states[$1.to_i].icon_index}}" +
  193.       "#{$data_states[$1.to_i].name}"}
  194.     @text.gsub!(/\\[Ss][Hh]\[(\d+),(\d+),(\d+)\]/i) {"\xa4[#{[$1]},#{[$2]},#{[$3]}]"}
  195.     #
  196.     # ライン情報の取得
  197.     rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
  198.       /\[([0-9]+)\]/,
  199.       "\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19", "\xa4"]
  200.     lines = @text.split("\x00")
  201.     @lines_max = lines.size
  202.     for i in 0...@lines_max
  203.       line = lines[i]
  204.       for rx in rxs
  205.         line.gsub!(rx) {""}
  206.       end
  207.       @line_aligns[i] =
  208.         line.sub!(/\\center/) {""} ? CENTER :
  209.         line.sub!(/\\right/)  {""} ? RIGHT :
  210.                                      AUTO
  211.       # 行の横幅の取得と設定
  212.       cx = contents.text_size(line).width
  213.       @line_widths[i] = cx
  214.     end
  215.     # 位置揃え制御文字の削除
  216.     @text.gsub!(/\\center/) {""}
  217.     @text.gsub!(/\\right/) {""}
  218.     # キャラポップ時のウィンドウリサイズ
  219.     reszie_window_for_pop
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● メッセージの更新 *
  223.   #--------------------------------------------------------------------------
  224.   def update_message
  225.     @wait_count = @type_wait
  226.     loop do
  227.       @line_show_fast = true if Input.press?(Y6::MESSAGE::TEXT_SKIP)
  228.       c = @text.slice!(/./m)
  229.       case update_message_type(c)
  230.       when 1
  231.         break
  232.       when 2
  233.         next
  234.       end
  235.       break unless @show_fast or @line_show_fast
  236.     end
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # 一文字の描画 (返り値 1:break, 2:next)
  240.   #--------------------------------------------------------------------------
  241.   def update_message_type(c)
  242.     case c
  243.     when nil                          # 描画すべき文字がない
  244.       finish_message                  # 更新終了
  245.       return 1
  246.     when "\x00"                       # 改行
  247.       new_line
  248.       max = MAX_LINE
  249.       max = 14 if self.pop_character != nil
  250.       if @line_count >= max      # 行数が最大のとき
  251.         unless @text.empty?           # さらに続きがあるなら
  252.           self.pause = true           # 入力待ちを入れる
  253.           return 1
  254.         end
  255.       end
  256.     when "\x01"                       # \C[n]  (文字色変更)
  257.       @text.sub!(/\[([0-9]+)\]/, "")
  258.       contents.font.color = text_color($1.to_i)
  259.       return 2
  260.     when "\x11"                       # \s[n]  (スピード変更)
  261.       @text.sub!(/\[([0-9]+)\]/, "")
  262.       @type_wait = $1.to_i
  263.       return 2
  264.     when "\x12"                       # \size
  265.       @text.sub!(/\[([0-9]+)\]/, "")
  266.       contents.font.size = $1.to_i
  267.       return 2
  268.     when "\x13"                       # \O
  269.       @text.sub!(/\[([0-9]+)\]/, "")
  270.       contents.font.color.alpha = $1.to_i
  271.       return 2
  272.     when "\x02"                       # \G  (所持金表示)
  273.       @gold_window.refresh
  274.       @gold_window.open
  275.     when "\x03"                       # \.  (ウェイト 1/4 秒)
  276.       @wait_count = 15
  277.       return 1
  278.     when "\x04"                       # \|  (ウェイト 1 秒)
  279.       @wait_count = 60
  280.       return 1
  281.     when "\x05"                       # \!  (入力待ち)
  282.       self.pause = true
  283.       return 1
  284.     when "\x06"                       # \>  (瞬間表示 ON)
  285.       @line_show_fast = true
  286.     when "\x07"                       # \<  (瞬間表示 OFF)
  287.       @line_show_fast = false
  288.     when "\x08"                       # \^  (入力待ちなし)
  289.       @pause_skip = true
  290.     when "\x14" #\B
  291.       contents.font.bold ^= true
  292.     when "\x15" #\I
  293.       contents.font.italic ^= true
  294.     when "\x16" #\D
  295.       contents.font.shadow ^= true
  296.     when "\x17"
  297.       @text.sub!(/\{(\d+)\}/, "")
  298.       icon = $1.to_i
  299.       icon_width = (24 - Y6::MESSAGE::ICON_WIDTH) / 2
  300.       draw_icon(icon, @contents_x - icon_width, @contents_y)
  301.       @contents_x += Y6::MESSAGE::ICON_WIDTH
  302.     when "\x18"
  303.       name = ($game_temp.last_gain_holder.name rescue "")
  304.       update_message_type_draw_at(name)
  305.     when "\x19"
  306.       item = ($game_temp.last_gain_material.item rescue nil)
  307.       draw_item_name(item, @contents_x, @contents_y)
  308.       @contents_x += 196
  309.     when "\xa4"                       # \SH[p,s,d] #flippy
  310.       @text.sub!(/\[(\d+),(\d+),(\d+)\]/, "")
  311.       start_shake($1.to_i, $2.to_i, $3.to_i)
  312.     else                              # 普通の文字
  313.       play_text_sound unless c == " "
  314.       update_message_type_draw_at(c)
  315.     end
  316.     return 0
  317.   end
  318.   def update_message_type_draw_at(c)
  319.     return if c.to_s.size == 0
  320.     c_width  = contents.text_size(c).width
  321.     c_height = contents.text_size(c).height
  322.     contents.draw_text(@contents_x, @contents_y - (c_height - WLH) / 2, c_width, c_height, c)
  323.     @contents_x += c_width
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 改ページ処理
  327.   #--------------------------------------------------------------------------
  328.   alias xrxsv2_new_page new_page
  329.   def new_page
  330.     xrxsv2_new_page
  331.     update_charpop_window
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 改行処理
  335.   #--------------------------------------------------------------------------
  336.   alias xrxsv2_new_line new_line
  337.   def new_line
  338.     xrxsv2_new_line
  339.     set_align
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # 位置揃え
  343.   #--------------------------------------------------------------------------
  344.   def set_align
  345.     w = @line_widths[@line_count].to_i
  346.     a = @line_aligns[@line_count]
  347.     case a
  348.     when CENTER
  349.       @contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
  350.     when RIGHT
  351.       @contents_x = contents.width - w
  352.     end
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● メッセージの終了
  356.   #--------------------------------------------------------------------------
  357.   alias xrxsv2_terminate_message terminate_message
  358.   def terminate_message
  359.     xrxsv2_terminate_message
  360.     process_hold
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # 定数
  364.   #--------------------------------------------------------------------------
  365.   AUTO   = 0
  366.   LEFT   = 1
  367.   CENTER = 2
  368.   RIGHT  = 3
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # overwrite method: input_pause
  372.   #--------------------------------------------------------------------------
  373.   def input_pause
  374.     if Input.trigger?(Input::B) or Input.trigger?(Input::C) or
  375.     Input.press?(Y6::MESSAGE::TEXT_SKIP)
  376.       self.pause = false
  377.       if @text != nil and not @text.empty?
  378.         new_page if @line_count >= MAX_LINE
  379.       else
  380.         terminate_message
  381.       end
  382.     end
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ● シェイクの開始 #flippy
  386.   #--------------------------------------------------------------------------
  387.   def start_shake(power, speed, duration)
  388.     @shake_power = power
  389.     @shake_speed = speed
  390.     @shake_duration = duration
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # ● シェイクリセット #flippy
  394.   #--------------------------------------------------------------------------
  395.   def shake_reset
  396.     @shake = @shake_power = 0
  397.     @shake_speed = @shake_duration = 0
  398.     @shake_direction = 1
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● シェイクの更新 #flippy
  402.   #--------------------------------------------------------------------------
  403.   def update_shake
  404.     delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
  405.     if @shake_duration <= 1 and @shake * (@shake + delta) < 0
  406.       @shake = 0
  407.     else
  408.       @shake += delta
  409.     end
  410.     @shake_direction = -1 if @shake > @shake_power * 2
  411.     @shake_direction = 1 if @shake < - @shake_power * 2
  412.     @shake_duration -= 1 if @shake_duration >= 1
  413.     self.x = self.x; self.y = self.y
  414.   end
  415. end
  416. #==============================================================================
  417. # アクティブイベント取得
  418. #==============================================================================
  419. class Game_Interpreter
  420.   attr_reader   :event_id
  421. end
  422. #==============================================================================
  423. # 各種機能の追加 - キャラポップ/ネーム/ホールド
  424. #==============================================================================
  425. class Window_Message < Window_Selectable
  426.   #--------------------------------------------------------------------------
  427.   # ● カーソルの更新 *
  428.   #--------------------------------------------------------------------------
  429.   def update_cursor
  430.     if @index >= 0
  431.       x = ($game_message.face_name.empty? ? 0 : 112)
  432.       y = ($game_message.choice_start + @index) * WLH - 1
  433.       w = contents.width - x
  434.       if self.pop_character != nil
  435.         x += 28
  436.         w -= 20
  437.       end
  438.       self.cursor_rect.set(x, y, w, WLH)
  439.     else
  440.       self.cursor_rect.empty
  441.     end
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # キャラクターの取得
  445.   #   parameter : パラメータ
  446.   #--------------------------------------------------------------------------
  447.   def get_character(parameter)
  448.     @pety = false
  449.     # パラメータで分岐
  450.     case parameter
  451.     when -1  # プレイヤー
  452.       return $game_player
  453.     when -2
  454.       return $game_party.pet
  455.     when 0  # 現在アクティブなイベント
  456.       id = $game_map.interpreter.event_id
  457.       events = $game_map.events
  458.       return events == nil ? nil : events[id]
  459.     else  # 特定のイベント
  460.       events = $game_map.events
  461.       return events == nil ? nil : events[parameter]
  462.     end
  463.   end
  464.   #--------------------------------------------------------------------------
  465.   # (メッセージ終了時)ホールドの処理
  466.   #--------------------------------------------------------------------------
  467.   def process_hold
  468.     if @window_hold
  469.       @held_windows.push(Window_Copy.new(self))
  470.       @held_windows.push(Window_Copy.new(@name_window))
  471.       @held_windows.push(Sprite_Copy.new(@name_sprite))
  472.       @held_windows.push(Sprite_Copy.new(@back_sprite))
  473.       for sprite in @extra_sprites
  474.         next if sprite.disposed?
  475.         @held_windows.push(Sprite_Copy.new(sprite))
  476.       end
  477.       @extra_sprites.clear
  478.       self.openness = 0
  479.       @name_window.openness = 0
  480.       @back_sprite.visible = false
  481.     else
  482.       @held_windows.each {|object| object.dispose}
  483.       @held_windows.clear
  484.     end
  485.     @name_window.close
  486.     @name_sprite.visible = false
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # キャラポップ位置の設定と取得
  490.   #--------------------------------------------------------------------------
  491.   def pop_character=(character_id)
  492.     @pop_character = character_id
  493.   end
  494.   def pop_character
  495.     return @pop_character
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # キャラポップ時のウィンドウリサイズ
  499.   #--------------------------------------------------------------------------
  500.   def reszie_window_for_pop
  501.     if self.pop_character != nil
  502.       max_x = @line_widths.max.to_i
  503.       n  = max_x + 32
  504.       n += $game_message.face_name.empty? ? 0 : 122
  505.       m  = $game_message.face_name.empty? ? 0 : 96
  506.       w  = @name_sprite.bitmap.width
  507.       self.width  = [n, w].max
  508.       self.height = [@lines_max * WLH, m].max + 32
  509.       create_contents
  510.       update_charpop_window
  511.     elsif @info_mode
  512.       @line_aligns[0] = CENTER
  513.       self.x = - 8
  514.       self.width = Graphics.width + 16
  515.       self.height = 56
  516.       create_contents
  517.     else
  518.       self.x = 0
  519.       self.width  = Graphics.width
  520.       self.height = MAX_LINE * WLH + 32
  521.       create_contents
  522.     end
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● 背景スプライトの作成
  526.   #--------------------------------------------------------------------------
  527.   alias xrxsv2_create_back_sprite create_back_sprite
  528.   def create_back_sprite
  529.     xrxsv2_create_back_sprite
  530.     @back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
  531.     @name_window = Window_Base.new(0,0,112,36)
  532.     @name_window.visible = false
  533.     @name_sprite = Sprite.new
  534.     @name_sprite.bitmap = Bitmap.new(32,32)
  535.     @name_sprite.visible = false
  536.     self.x = self.x
  537.     self.y = self.y
  538.     self.z = self.z
  539.     @held_windows = []
  540.     @extra_sprites = []
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # ● 背景スプライトの解放
  544.   #--------------------------------------------------------------------------
  545.   alias xrxsv2_dispose_back_sprite dispose_back_sprite
  546.   def dispose_back_sprite
  547.     xrxsv2_dispose_back_sprite
  548.     @name_window.dispose
  549.     @name_sprite.dispose
  550.     for window in @held_windows
  551.       window.dispose
  552.     end
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ● 背景スプライトの更新
  556.   #--------------------------------------------------------------------------
  557.   alias xrxsv2_update_back_sprite update_back_sprite
  558.   def update_back_sprite
  559.     @name_window.update
  560.     xrxsv2_update_back_sprite
  561.     update_charpop_window
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # ウィンドウの位置と不透明度の設定 (キャラポップ)
  565.   #--------------------------------------------------------------------------
  566.   def update_charpop_window
  567.     if self.pop_character
  568.       character = get_character(self.pop_character)
  569.       return if character == nil
  570.       # [X座標]
  571.       n = self.width / 2
  572.       n = [n, @name_skin.width + 16].max if @current_name != nil
  573.       w = @name_sprite.bitmap.width
  574.       x = character.screen_x - [[n, w].max, self.width - 32].min
  575.       if character.screen_y <= 128
  576.         @position = 2
  577.       elsif character.screen_y >= 288
  578.         @position = 0
  579.       end
  580.       # [Y座標]
  581.       case @position
  582.       when 0
  583.         y = character.screen_y - CHARPOP_HEIGHT - self.height
  584.       else
  585.         y = character.screen_y + 16
  586.       end
  587.       x_max = Graphics.width - 4 - self.width
  588.       x_min = 4
  589.       y_max = Graphics.height - self.height
  590.       y_min = 4
  591.       self.x = [[x, x_max].min, x_min].max
  592.       self.y = [[y, y_max].min, y_min].max
  593.       self.x += @shake if @shake != nil
  594.     end
  595.   end
  596.   #--------------------------------------------------------------------------
  597.   # 位置の連動
  598.   #--------------------------------------------------------------------------
  599.   def x=(n)
  600.     super(n)
  601.     n += @shake if @shake != nil
  602.     if @name_window
  603.       @name_window.x = n + NAME_WINDOW_OFFSET_X
  604.       @name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
  605.     end
  606.   end
  607.   def y=(n)
  608.     super
  609.     if @name_window
  610.       @name_window.y = n + NAME_WINDOW_OFFSET_Y
  611.       @name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
  612.     end
  613.   end
  614.   def z=(n)
  615.     super
  616.     if @name_window
  617.       @name_window.z = n + 1
  618.       @name_sprite.z = n + 2
  619.     end
  620.   end
  621. end
  622. #==============================================================================
  623. # 伸縮対応
  624. #==============================================================================
  625. class Window_Message < Window_Selectable
  626.   #--------------------------------------------------------------------------
  627.   # ● ウィンドウの背景と位置の設定 [再定義]
  628.   #--------------------------------------------------------------------------
  629.   def reset_window
  630.     @background = $game_message.background
  631.     @position = $game_message.position
  632.     if @background == 0   # 通常ウィンドウ
  633.       self.opacity = 255
  634.     else                  # 背景を暗くする、透明にする
  635.       self.opacity = 0
  636.     end
  637.     case @position
  638.     when 0  # 上
  639.       self.y = 0
  640.       @gold_window.y = 360
  641.     when 1  # 中
  642.       self.y = (Graphics.height - self.height) / 2
  643.       @gold_window.y = 0
  644.     when 2  # 下
  645.       self.y = Graphics.height - self.height
  646.       @gold_window.y = 0
  647.     end
  648.   end
  649. end
  650. #==============================================================================
  651. # □ Window_Copy
  652. #------------------------------------------------------------------------------
  653. #   指定のウィンドウのコピーを作成します。
  654. #==============================================================================
  655. class Window_Copy < Window_Base
  656.   #--------------------------------------------------------------------------
  657.   # ○ オブジェクト初期化
  658.   #--------------------------------------------------------------------------
  659.   def initialize(window)
  660.     super(window.x, window.y, window.width, window.height)
  661.     self.contents = window.contents.dup unless window.contents.nil?
  662.     self.opacity = window.opacity
  663.     self.back_opacity = window.back_opacity
  664.     self.z = window.z - 3
  665.     self.visible = window.visible
  666.   end
  667. end
  668. #==============================================================================
  669. # □ Sprite_Copy
  670. #------------------------------------------------------------------------------
  671. #   指定のスプライトのコピーを作成します。
  672. #==============================================================================
  673. class Sprite_Copy < Sprite
  674.   #--------------------------------------------------------------------------
  675.   # ○ オブジェクト初期化
  676.   #--------------------------------------------------------------------------
  677.   def initialize(sprite)
  678.     super()
  679.     self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  680.     self.opacity = sprite.opacity
  681.     self.x = sprite.x
  682.     self.y = sprite.y
  683.     self.z = sprite.z - 3
  684.     self.ox = sprite.ox
  685.     self.oy = sprite.oy
  686.     self.zoom_x = sprite.zoom_x
  687.     self.visible = sprite.visible
  688.   end
  689. end
  690.  
  691. class Window_Message < Window_Selectable  
  692.   #--------------------------------------------------------------------------
  693.   # new method: play_text_sound
  694.   #--------------------------------------------------------------------------
  695.   def play_text_sound
  696.     return if $game_message.text_sound == nil
  697.     return if @line_show_fast or @show_fast
  698.     name  = $game_message.text_sound
  699.     $game_message.text_volume = 60 if $game_message.text_volume == nil
  700.     vol   = $game_message.text_volume
  701.     $game_message.text_pitch = 100 if $game_message.text_pitch == nil
  702.     pitch = $game_message.text_pitch
  703.     pitch += rand(Y6::MESSAGE::SOUND_PITCH_OFFSET)
  704.     pitch -= rand(Y6::MESSAGE::SOUND_PITCH_OFFSET)
  705.     RPG::SE.new(name, vol, pitch).play
  706.   end
  707.  
  708.   alias flip_update update
  709.   def update
  710.     update_shake if @shake_duration >= 1 or @shake != 0 # シェイク更新
  711.     flip_update
  712.   end
  713.  
  714.   alias flip_reset_window reset_window
  715.   def reset_window
  716.     flip_reset_window
  717.     text = @text.clone                  # テキスト
  718.     loop do
  719.       c = text.slice!(/./m)             # 次の文字を取得
  720.       case c
  721.       when nil
  722.         break                  # 残りの文字が無い場合、ループ中断
  723.       when "\xa4"
  724.         text.sub!(/\[\d+,\d+,\d+\]/, "")# \SH[p,s,d]
  725.       end
  726.     end
  727.   end
  728. end
  729.  
  730. #==============================================================================
  731. # ** Game_Message
  732. #==============================================================================
  733.  
  734. class Game_Message
  735.  
  736.   #--------------------------------------------------------------------------
  737.   # public instance variables
  738.   #--------------------------------------------------------------------------
  739.   attr_accessor :text_sound
  740.   attr_accessor :text_volume
  741.   attr_accessor :text_pitch
  742.   attr_accessor :choice_text
  743.  
  744.   #--------------------------------------------------------------------------
  745.   # alias method: initialize
  746.   #--------------------------------------------------------------------------
  747.   alias initialize_cms initialize unless $@
  748.   def initialize
  749.     @text_sound  = Y6::MESSAGE::SOUND_DEFAULT
  750.     @text_volume = Y6::MESSAGE::SOUND_VOLUME
  751.     @text_pitch  = 100
  752.     initialize_cms
  753.   end
  754.  
  755.   #--------------------------------------------------------------------------
  756.   # alias method: clear
  757.   #--------------------------------------------------------------------------
  758.   alias clear_cms clear unless $@
  759.   def clear
  760.     @choice_text = []
  761.     clear_cms
  762.   end
  763.  
  764. end # Game_Message
  765.  
  766. #==============================================================================
  767. # +++ 「+ふきだし表示」VX +++
  768. # by パラ犬  http://2d6.parasite.jp/
  769. #      ×
  770. #    row       http://xms.rdy.jp/
  771. #
  772. # publish 2010/ 3/ 2
  773. # update  -
  774. #
  775. #------------------------------------------------------------------------------
  776. #    ほぼどんなメッセージウィンドウに対しても後付け可能な「ふきだし表示」です。
  777. #  また、テール部分のみの自動追尾機能を持ちます。
  778. #   ふきだし表示をするには、
  779. #  テール用画像「Window-top」「Window-under」を
  780. #  「Graphics/System」フォルダにインポートしておく必要があります。
  781. #==============================================================================
  782. # ■ Window_Message
  783. #==============================================================================
  784. class Window_Message < Window_Selectable
  785.   #--------------------------------------------------------------------------
  786.   # ● メッセージの開始
  787.   #--------------------------------------------------------------------------
  788.   alias parashelf_start_message start_message
  789.   def start_message
  790.     parashelf_start_message
  791.     update_tail
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # クローズ [オーバーライド]
  795.   #--------------------------------------------------------------------------
  796.   def close
  797.     super
  798.     del_tail
  799.   end
  800.   #--------------------------------------------------------------------------
  801.   # ● 特殊文字の変換
  802.   #--------------------------------------------------------------------------
  803.   alias parashelf_convert_special_characters convert_special_characters
  804.   def convert_special_characters
  805.     parashelf_convert_special_characters
  806.     set_tail
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # ● 背景スプライトの更新
  810.   #--------------------------------------------------------------------------
  811.   alias parashelf_update_back_sprite update_back_sprite
  812.   def update_back_sprite
  813.     parashelf_update_back_sprite
  814.     update_tail
  815.   end
  816.   #--------------------------------------------------------------------------
  817.   # ○ フレーム更新 (ふきだしテール)
  818.   #--------------------------------------------------------------------------
  819.   def update_tail
  820.     # ふきだしモードではイベントの動きに追従
  821.     if $mes_id != nil and @tail != nil
  822.       tale_pos = get_tale_pos
  823.       @tail.x = tale_pos[0]
  824.       @tail.y = tale_pos[1]
  825.       skin = "Window"
  826.       case @position
  827.       when 0  # 上
  828.           @tail.bitmap = Cache.system(skin + "-top") if @think == false
  829.           @tail.bitmap = Cache.system(skin + "-top-think") if @think == true
  830.       when 2  # 下
  831.           @tail.bitmap = Cache.system(skin + "-under") if @think == false
  832.           @tail.bitmap = Cache.system(skin + "-under-think") if @think == true
  833.       end
  834.       # 可視状態
  835.       @tail.visible = self.openness == 255
  836.     end
  837.   end
  838.   #--------------------------------------------------------------------------
  839.   # ○ ふきだしテールを表示
  840.   #--------------------------------------------------------------------------
  841.   def set_tail
  842.     del_tail
  843.     # $mes_id が空のときと戦闘中はふきだしを表示しない
  844.     if $mes_id != nil and not $game_temp.in_battle
  845.       # ふきだしのテールを描画
  846.       skin = "Window"
  847.       if @background == 0
  848.         # 位置を取得
  849.         tale_pos = get_tale_pos
  850.         @tail = Sprite.new
  851.         case @position
  852.         when 0  # 上
  853.           @tail.bitmap = Cache.system(skin + "-top") if @think == false
  854.           @tail.bitmap = Cache.system(skin + "-top-think") if @think == true
  855.           @tail.x = tale_pos[0]
  856.           @tail.y = tale_pos[1]
  857.           @tail.z = self.z + 1
  858.         when 1  # 中
  859.           @tail.dispose
  860.           @tail = nil
  861.         when 2  # 下
  862.           @tail.bitmap = Cache.system(skin + "-under") if @think == false
  863.           @tail.bitmap = Cache.system(skin + "-under-think") if @think == true
  864.           @tail.x = tale_pos[0]
  865.           @tail.y = tale_pos[1]
  866.           @tail.z = self.z + 1
  867.         end
  868.         # エクストラスプライトに登録
  869.         @extra_sprites = [] if @extra_sprites.nil?
  870.         @extra_sprites.push(@tail) if @tail != nil
  871.         # 更新
  872.         update_tail
  873.       end
  874.     end
  875.   end
  876.   #--------------------------------------------------------------------------
  877.   # ○ テールの位置を計算
  878.   #--------------------------------------------------------------------------
  879.   def get_tale_pos
  880.     character = get_character($mes_id)
  881.     x = [[character.screen_x - 16, self.x].max, self.x + self.width - 32].min
  882.     case @position
  883.     when 0
  884.       y = self.y + self.height - 16 #24 #16
  885.     when 2
  886.       y = self.y - 16 #8 #16
  887.     end
  888.     return [x, y]
  889.   end
  890.   #--------------------------------------------------------------------------
  891.   # ○ ふきだしを破棄
  892.   #--------------------------------------------------------------------------
  893.   def del_tail
  894.     if @tail != nil
  895.       @tail.dispose
  896.       @tail = nil
  897.     end
  898.   end
  899. end
  900. #
  901. # ▼▲▼ XRXS 9拡張CO-X. ふきだし自動設定 ▼▲▼
  902. #==============================================================================
  903. # ■ Window_Message
  904. #==============================================================================
  905. class Window_Message < Window_Selectable
  906.   #--------------------------------------------------------------------------
  907.   # ○ ポップキャラクターの設定
  908.   #--------------------------------------------------------------------------
  909.   def pop_character=(character_id)
  910.     @pop_character = character_id
  911.     $mes_id = character_id
  912.   end
  913. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement