#============================================================================== # Emoticon on Face #------------------------------------------------------------------------------ # By Nechigawara Sanzenin # WARNING!! : This script can use on RPG Maker VX Only!! (XP Not Support) =begin How to Use: Add "\E[Number Of Emoticon]" To text in message control You can see Number of Emoticon on "Balloon.png" in "Graphics\System" or "%programfiles%\Common Files\Enterbrain\RGSS2\RPGVX\Graphics\System". when the line number of emoticonset is 1 , Number of Emoticon is 1. when the line number of emoticonset is 2 , Number of Emoticon is 2. Max of Number of Emoticon is 10. You can set Emoticon's Position at EMO_X and EMO_y. You can set frame rate at BALLOON_WAIT. if the message window don't have face,Noting happen. =end #============================================================================== class Window_Message < Window_Selectable #-------------------------------------------------------------------------- BALLOON_WAIT = 12 EMO_X = 93 EMO_Y = 15 #-------------------------------------------------------------------------- alias inc_initialize initialize def initialize inc_initialize @viewport = Viewport.new(0, 0, 544, 416) @viewport.z = z + 50 @balloon_face = 0 create_balloon end #-------------------------------------------------------------------------- alias inc_dispose dispose def dispose inc_dispose dispose_balloon @viewport.dispose end #-------------------------------------------------------------------------- def update super update_gold_window update_number_input_window update_back_sprite update_show_fast update_balloon unless @opening or @closing # ウィンドウの開閉中以外 if @wait_count > 0 # 文章内ウェイト中 @wait_count -= 1 elsif self.pause # 文章送り待機中 input_pause elsif self.active # 選択肢入力中 input_choice elsif @number_input_window.visible # 数値入力中 input_number elsif @text != nil # 残りの文章が存在 update_message # メッセージの更新 elsif continue? # 続ける場合 start_message # メッセージの開始 open # ウィンドウを開く $game_message.visible = true else # 続けない場合 close # ウィンドウを閉じる $game_message.visible = @closing end end end #-------------------------------------------------------------------------- def create_balloon dispose_balloon @balloon_duration = 8 * 8 + BALLOON_WAIT @balloon_sprite = ::Sprite.new(@viewport) @balloon_sprite.bitmap = Cache.system("Balloon") @balloon_sprite.ox = 16 @balloon_sprite.oy = 32 @balloon_sprite.visible = false update_balloon end #-------------------------------------------------------------------------- def refresh_balloon if @balloon_face == 0 or @balloon_face > 10 @balloon_sprite.visible = false else @balloon_sprite.visible = true end update_balloon end #-------------------------------------------------------------------------- def update_balloon if @balloon_duration > 0 @balloon_duration -= 1 if @balloon_duration == 0 @balloon_duration = 8 * 8 + BALLOON_WAIT @balloon_duration -= 1 else @balloon_sprite.x = x + EMO_X @balloon_sprite.y = y + EMO_Y @balloon_sprite.z = z + 50 if @balloon_duration < BALLOON_WAIT sx = 7 * 32 else sx = (7 - (@balloon_duration - BALLOON_WAIT) / 8) * 32 end sy = (@balloon_face - 1) * 32 @balloon_sprite.src_rect.set(sx, sy, 32, 32) end end end #-------------------------------------------------------------------------- def dispose_balloon if @balloon_sprite != nil @balloon_sprite.dispose @balloon_sprite = nil end end #-------------------------------------------------------------------------- alias inc_terminate_message terminate_message def terminate_message inc_terminate_message @balloon_sprite.visible = false end #-------------------------------------------------------------------------- alias inc_convert_special_characters convert_special_characters def convert_special_characters inc_convert_special_characters @text.gsub!(/\\E\[([0-9]+)\]/i) { "\x09[#{$1}]" } end #-------------------------------------------------------------------------- def update_message loop do c = @text.slice!(/./m) # 次の文字を取得 case c when nil # 描画すべき文字がない finish_message # 更新終了 break when "\x00" # 改行 new_line if @line_count >= MAX_LINE # 行数が最大のとき unless @text.empty? # さらに続きがあるなら self.pause = true # 入力待ちを入れる break end end when "\x01" # \C[n] (文字色変更) @text.sub!(/\[([0-9]+)\]/, "") contents.font.color = text_color($1.to_i) next when "\x02" # \G (所持金表示) @gold_window.refresh @gold_window.open when "\x03" # \. (ウェイト 1/4 秒) @wait_count = 15 break when "\x04" # \| (ウェイト 1 秒) @wait_count = 60 break when "\x05" # \! (入力待ち) self.pause = true break when "\x06" # \> (瞬間表示 ON) @line_show_fast = true when "\x07" # \< (瞬間表示 OFF) @line_show_fast = false when "\x08" # \^ (入力待ちなし) @pause_skip = true when "\x09" @text.sub!(/\[([0-9]+)\]/, "") unless $game_message.face_name.empty? @balloon_face = $1.to_i refresh_balloon end else # 普通の文字 contents.draw_text(@contents_x, @contents_y, 40, WLH, c) c_width = contents.text_size(c).width @contents_x += c_width end break unless @show_fast or @line_show_fast end end end