# ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
#
# publish 2010/ 3/ 2
# update - 11/ 1/10a
#
#==============================================================================
# カスタマイズポイント
#==============================================================================
class Window_Message < Window_Selectable
#
# 基本行数
#
MAX_LINE = 3
#
# \p[] - キャラポップの高さ
#
CHARPOP_HEIGHT = 40
#
# \name[] - 名前枠 X,Y座標
#
NAME_WINDOW_OFFSET_X = 0
NAME_WINDOW_OFFSET_Y = -24
end
#==============================================================================
# 参照機能
#==============================================================================
class Game_Temp
attr_accessor :last_gain_material
attr_accessor :last_gain_holder
end
#==============================================================================
# フルグレードアップベース - 制御文字・基本機能
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 特殊文字の変換 + 準備
#--------------------------------------------------------------------------
alias xrxsv2_convert_special_characters convert_special_characters
def convert_special_characters
# 初期化
contents.font.size = Font.default_size
contents.font.bold = Font.default_italic
contents.font.italic = Font.default_bold
contents.font.shadow = Font.default_shadow
@type_wait = 0
@line_widths = []
@line_aligns = []
self.pop_character = nil
# ウィンドウ保持指定\holdがあるか?
@window_hold = (@text.gsub!(/\\hold/) { "" } != nil)
# \info
@info_mode = (@text.gsub!(/\\info/) { "" } != nil)
# 改行削除指定\_があるか?
if (/\\_(.*?)\x00/.match(@text)) != nil
$game_message.choice_start -= 1
@text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
end
# \name 判定
if @text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
name = $1
bitmap = @name_sprite.bitmap
w = [bitmap.text_size(name).width, 1].max
bitmap.dispose
@name_sprite.bitmap = Bitmap.new(w, 32)
bitmap = @name_sprite.bitmap
bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
@name_window.width = w + 16
@name_window.create_contents
@name_window.openness = 0
@name_window.open
@name_window.visible = true
@name_sprite.visible = true
else
@name_window.visible = false
@name_sprite.visible = false
@name_sprite.bitmap.dispose
@name_sprite.bitmap = Bitmap.new(32,32)
end
# キャラボップモード
if @text.gsub!(/\\[Pp]\[-1\]/) { "" }
self.pop_character = -1
elsif @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "" }
self.pop_character = $1.to_i
elsif @text.gsub!(/\\[Pp]/) { "" }
self.pop_character = 0
end
# 制御文字処理
xrxsv2_convert_special_characters
@text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\x11[#{$1}]" }
@text.gsub!(/\\size\[([0-9]+)\]/i) { "\x12[#{$1}]" }
@text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\x13[#{$1}]" }
@text.gsub!(/\\icon\[([0-9]+)\]/i) { "\x17[#{$1}]" }
@text.gsub!(/\\last_holder/i) { "\x18" }
@text.gsub!(/\\last_material/i) { "\x19" }
@text.gsub!(/\\B/) { "\x14" }
@text.gsub!(/\\I/) { "\x15" }
@text.gsub!(/\\D/) { "\x16" }
@text.gsub!(/\\n/) { "\x00" }
#
# ライン情報の取得
rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
/\[([0-9]+)\]/,
"\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
lines = @text.split("\x00")
@lines_max = lines.size
for i in 0...@lines_max
line = lines[i]
for rx in rxs
line.gsub!(rx) {""}
end
@line_aligns[i] =
line.sub!(/\\center/) {""} ? CENTER :
line.sub!(/\\right/) {""} ? RIGHT :
AUTO
# 行の横幅の取得と設定
cx = contents.text_size(line).width
@line_widths[i] = cx
end
# 位置揃え制御文字の削除
@text.gsub!(/\\center/) {""}
@text.gsub!(/\\right/) {""}
# キャラポップ時のウィンドウリサイズ
reszie_window_for_pop
end
#--------------------------------------------------------------------------
# ● メッセージの更新 *
#--------------------------------------------------------------------------
def update_message
@wait_count = @type_wait
loop do
c = @text.slice!(/./m)
case update_message_type(c)
when 1
break
when 2
next
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# 一文字の描画 (返り値 1:break, 2:next)
#--------------------------------------------------------------------------
def update_message_type(c)
case c
when nil # 描画すべき文字がない
finish_message # 更新終了
return 1
when "\x00" # 改行
new_line
max = MAX_LINE
max = 14 if self.pop_character != nil
if @line_count >= max # 行数が最大のとき
unless @text.empty? # さらに続きがあるなら
self.pause = true # 入力待ちを入れる
return 1
end
end
when "\x01" # \C[n] (文字色変更)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
return 2
when "\x11" # \s[n] (スピード変更)
@text.sub!(/\[([0-9]+)\]/, "")
@type_wait = $1.to_i
return 2
when "\x12" # \size
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.size = $1.to_i
return 2
when "\x13" # \O
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color.alpha = $1.to_i
return 2
when "\x02" # \G (所持金表示)
@gold_window.refresh
@gold_window.open
when "\x03" # \. (ウェイト 1/4 秒)
@wait_count = 15
return 1
when "\x04" # \| (ウェイト 1 秒)
@wait_count = 60
return 1
when "\x05" # \! (入力待ち)
self.pause = true
return 1
when "\x06" # \> (瞬間表示 ON)
@line_show_fast = true
when "\x07" # \< (瞬間表示 OFF)
@line_show_fast = false
when "\x08" # \^ (入力待ちなし)
@pause_skip = true
when "\x14" #\B
contents.font.bold ^= true
when "\x15" #\I
contents.font.italic ^= true
when "\x16" #\D
contents.font.shadow ^= true
when "\x17"
@text.sub!(/\[([0-9]+)\]/, "")
draw_icon($1.to_i, @contents_x, @contents_y)
@contents_x += 24
when "\x18"
name = ($game_temp.last_gain_holder.name rescue "")
update_message_type_draw_at(name)
when "\x19"
item = ($game_temp.last_gain_material.item rescue nil)
draw_item_name(item, @contents_x, @contents_y)
@contents_x += 196
else # 普通の文字
update_message_type_draw_at(c)
end
return 0
end
def update_message_type_draw_at(c)
return if c.to_s.size == 0
c_width = contents.text_size(c).width
c_height = contents.text_size(c).height
contents.draw_text(@contents_x, @contents_y - (c_height - WLH) / 2, c_width, c_height, c)
@contents_x += c_width
end
#--------------------------------------------------------------------------
# ● 改ページ処理
#--------------------------------------------------------------------------
alias xrxsv2_new_page new_page
def new_page
xrxsv2_new_page
update_charpop_window
end
#--------------------------------------------------------------------------
# ● 改行処理
#--------------------------------------------------------------------------
alias xrxsv2_new_line new_line
def new_line
xrxsv2_new_line
set_align
end
#--------------------------------------------------------------------------
# 位置揃え
#--------------------------------------------------------------------------
def set_align
w = @line_widths[@line_count].to_i
a = @line_aligns[@line_count]
case a
when CENTER
@contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
when RIGHT
@contents_x = contents.width - w
end
end
#--------------------------------------------------------------------------
# ● メッセージの終了
#--------------------------------------------------------------------------
alias xrxsv2_terminate_message terminate_message
def terminate_message
xrxsv2_terminate_message
process_hold
end
#--------------------------------------------------------------------------
# 定数
#--------------------------------------------------------------------------
AUTO = 0
LEFT = 1
CENTER = 2
RIGHT = 3
end
#==============================================================================
# アクティブイベント取得
#==============================================================================
class Game_Interpreter
attr_reader :event_id
end
#==============================================================================
# 各種機能の追加 - キャラポップ/ネーム/ホールド
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● カーソルの更新 *
#--------------------------------------------------------------------------
def update_cursor
if @index >= 0
x = ($game_message.face_name.empty? ? 0 : 112)
y = ($game_message.choice_start + @index) * WLH - 1
w = contents.width - x
if self.pop_character != nil
x += 28
w -= 20
end
self.cursor_rect.set(x, y, w, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# キャラクターの取得
# parameter : パラメータ
#--------------------------------------------------------------------------
def get_character(parameter)
# パラメータで分岐
case parameter
when -1 # プレイヤー
return $game_player
when 0 # 現在アクティブなイベント
id = $game_map.interpreter.event_id
events = $game_map.events
return events == nil ? nil : events[id]
else # 特定のイベント
events = $game_map.events
return events == nil ? nil : events[parameter]
end
end
#--------------------------------------------------------------------------
# (メッセージ終了時)ホールドの処理
#--------------------------------------------------------------------------
def process_hold
if @window_hold
@held_windows.push(Window_Copy.new(self))
@held_windows.push(Window_Copy.new(@name_window))
@held_windows.push(Sprite_Copy.new(@name_sprite))
@held_windows.push(Sprite_Copy.new(@back_sprite))
for sprite in @extra_sprites
next if sprite.disposed?
@held_windows.push(Sprite_Copy.new(sprite))
end
@extra_sprites.clear
self.openness = 0
@name_window.openness = 0
@back_sprite.visible = false
else
@held_windows.each {|object| object.dispose}
@held_windows.clear
end
@name_window.close
@name_sprite.visible = false
end
#--------------------------------------------------------------------------
# キャラポップ位置の設定と取得
#--------------------------------------------------------------------------
def pop_character=(character_id)
@pop_character = character_id
end
def pop_character
return @pop_character
end
#--------------------------------------------------------------------------
# キャラポップ時のウィンドウリサイズ
#--------------------------------------------------------------------------
def reszie_window_for_pop
if self.pop_character != nil
max_x = @line_widths.max.to_i
n = max_x + 32
n += $game_message.face_name.empty? ? 0 : 122
m = $game_message.face_name.empty? ? 0 : 96
w = @name_sprite.bitmap.width
self.width = [n, w].max
self.height = [@lines_max * WLH, m].max + 32
create_contents
update_charpop_window
elsif @info_mode
@line_aligns[0] = CENTER
self.x = - 8
self.width = Graphics.width + 16
self.height = 56
create_contents
else
self.x = 0
self.width = Graphics.width
self.height = MAX_LINE * WLH + 32
create_contents
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
alias xrxsv2_create_back_sprite create_back_sprite
def create_back_sprite
xrxsv2_create_back_sprite
@back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
@name_window = Window_Base.new(0,0,112,36)
@name_window.visible = false
@name_sprite = Sprite.new
@name_sprite.bitmap = Bitmap.new(32,32)
@name_sprite.visible = false
self.x = self.x
self.y = self.y
self.z = self.z
@held_windows = []
@extra_sprites = []
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
alias xrxsv2_dispose_back_sprite dispose_back_sprite
def dispose_back_sprite
xrxsv2_dispose_back_sprite
@name_window.dispose
@name_sprite.dispose
for window in @held_windows
window.dispose
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
alias xrxsv2_update_back_sprite update_back_sprite
def update_back_sprite
@name_window.update
xrxsv2_update_back_sprite
update_charpop_window
end
#--------------------------------------------------------------------------
# ウィンドウの位置と不透明度の設定 (キャラポップ)
#--------------------------------------------------------------------------
def update_charpop_window
if self.pop_character
character = get_character(self.pop_character)
return if character == nil
# [X座標]
n = self.width / 2
n = [n, @name_skin.width + 16].max if @current_name != nil
w = @name_sprite.bitmap.width
x = character.screen_x - [[n, w].max, self.width - 32].min
# [Y座標]
case @position
when 0
y = character.screen_y - CHARPOP_HEIGHT - self.height
else
y = character.screen_y + 16
end
x_max = Graphics.width - 4 - self.width
x_min = 4
y_max = Graphics.height - self.height
y_min = 4
self.x = [[x, x_max].min, x_min].max
self.y = [[y, y_max].min, y_min].max
end
end
#--------------------------------------------------------------------------
# 位置の連動
#--------------------------------------------------------------------------
def x=(n)
super
if @name_window
@name_window.x = n + NAME_WINDOW_OFFSET_X
@name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
end
end
def y=(n)
super
if @name_window
@name_window.y = n + NAME_WINDOW_OFFSET_Y
@name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
end
end
def z=(n)
super
if @name_window
@name_window.z = n + 1
@name_sprite.z = n + 2
end
end
end
#==============================================================================
# 伸縮対応
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● ウィンドウの背景と位置の設定 [再定義]
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # 通常ウィンドウ
self.opacity = 255
else # 背景を暗くする、透明にする
self.opacity = 0
end
case @position
when 0 # 上
self.y = 0
@gold_window.y = 360
when 1 # 中
self.y = (Graphics.height - self.height) / 2
@gold_window.y = 0
when 2 # 下
self.y = Graphics.height - self.height
@gold_window.y = 0
end
end
end
#==============================================================================
# □ Window_Copy
#------------------------------------------------------------------------------
# 指定のウィンドウのコピーを作成します。
#==============================================================================
class Window_Copy < Window_Base
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(window)
super(window.x, window.y, window.width, window.height)
self.contents = window.contents.dup unless window.contents.nil?
self.opacity = window.opacity
self.back_opacity = window.back_opacity
self.z = window.z - 3
self.visible = window.visible
end
end
#==============================================================================
# □ Sprite_Copy
#------------------------------------------------------------------------------
# 指定のスプライトのコピーを作成します。
#==============================================================================
class Sprite_Copy < Sprite
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(sprite)
super()
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = sprite.opacity
self.x = sprite.x
self.y = sprite.y
self.z = sprite.z - 3
self.ox = sprite.ox
self.oy = sprite.oy
self.zoom_x = sprite.zoom_x
self.visible = sprite.visible
end
end
#==============================================================================
# Window_Message
#------------------------------------------------------------------------------
# RMVX Window_Message with Thai Vowels Support
# by Woratana [[email protected]]
# Thaiware RPG Maker Community
# Special Thanks: Thai AMS by Mako & Nechigawara
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
MAX_LINE = 4 # 最大行数
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 288, 544, 128)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # ウィンドウのオープン中フラグ
@closing = false # ウィンドウのクローズ中フラグ
@text = nil # 表示すべき残りの文章
@contents_x = 0 # 次の文字を描画する X 座標
@contents_y = 0 # 次の文字を描画する Y 座標
@line_count = 0 # 現在までに描画した行数
@wait_count = 0 # ウェイトカウント
@background = 0 # 背景タイプ
@position = 2 # 表示位置
@show_fast = false # 早送りフラグ
@line_show_fast = false # 行単位早送りフラグ
@pause_skip = false # 入力待ち省略フラグ
@last_c = nil
@last_chara = ""
create_gold_window
create_number_input_window
create_back_sprite
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
super
dispose_gold_window
dispose_number_input_window
dispose_back_sprite
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
update_gold_window
update_number_input_window
update_back_sprite
update_show_fast
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_gold_window
@gold_window = Window_Gold.new(384, 0)
@gold_window.openness = 0
end
#--------------------------------------------------------------------------
# ● 数値入力ウィンドウの作成
#--------------------------------------------------------------------------
def create_number_input_window
@number_input_window = Window_NumberInput.new
@number_input_window.visible = false
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = Cache.system("MessageBack")
@back_sprite.visible = (@background == 1)
@back_sprite.z = 190
end
#--------------------------------------------------------------------------
# ● 所持金ウィンドウの解放
#--------------------------------------------------------------------------
def dispose_gold_window
@gold_window.dispose
end
#--------------------------------------------------------------------------
# ● 数値入力ウィンドウの解放
#--------------------------------------------------------------------------
def dispose_number_input_window
@number_input_window.dispose
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 所持金ウィンドウの更新
#--------------------------------------------------------------------------
def update_gold_window
@gold_window.update
end
#--------------------------------------------------------------------------
# ● 数値入力ウィンドウの更新
#--------------------------------------------------------------------------
def update_number_input_window
@number_input_window.update
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
def update_back_sprite
@back_sprite.visible = (@background == 1)
@back_sprite.y = y - 16
@back_sprite.opacity = openness
@back_sprite.update
end
#--------------------------------------------------------------------------
# ● 早送りフラグの更新
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# ● 次のメッセージを続けて表示するべきか判定
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# ● メッセージの開始
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# ● 改ページ処理
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# ● 改行処理
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# ● 特殊文字の変換
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# ● ウィンドウの背景と位置の設定
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # 通常ウィンドウ
self.opacity = 255
else # 背景を暗くする、透明にする
self.opacity = 0
end
case @position
when 0 # 上
self.y = 0
@gold_window.y = 360
when 1 # 中
self.y = 144
@gold_window.y = 0
when 2 # 下
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# ● メッセージの終了
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
@gold_window.close
@number_input_window.active = false
@number_input_window.visible = false
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# ● メッセージの更新
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # 次の文字を取得
p = ""
deduct = 0
if c == "้" or c == "่" or c == "๊" or c == "๋" or c == "ี" or c == "ิ" or c == "ื" or c == "ึ" or c == "ุ" or c == "ู" or c == "ั" or c == "็" or c == "์"
p = c
elsif c == "ำ"
deduct = 2
else
@last_c = nil
end
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
else # 普通の文字
if p != ""
@contents_x -= @last_c
c = @last_chara
c.concat(p)
end
@contents_x -= deduct
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
if @last_c != nil
@contents_x += @last_c
else
@contents_x += c_width
@last_c = c_width
@last_chara = c
end
@contents_x += deduct
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# ● メッセージの更新終了
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# ● 選択肢の開始
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# ● 数値入力の開始
#--------------------------------------------------------------------------
def start_number_input
digits_max = $game_message.num_input_digits_max
number = $game_variables[$game_message.num_input_variable_id]
@number_input_window.digits_max = digits_max
@number_input_window.number = number
if $game_message.face_name.empty?
@number_input_window.x = x
else
@number_input_window.x = x + 112
end
@number_input_window.y = y + @contents_y
@number_input_window.active = true
@number_input_window.visible = true
@number_input_window.update
end
#--------------------------------------------------------------------------
# ● カーソルの更新
#--------------------------------------------------------------------------
def update_cursor
if @index >= 0
x = $game_message.face_name.empty? ? 0 : 112
y = ($game_message.choice_start + @index) * WLH
self.cursor_rect.set(x, y, contents.width - x, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# ● 文章送りの入力処理
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
#--------------------------------------------------------------------------
# ● 選択肢の入力処理
#--------------------------------------------------------------------------
def input_choice
if Input.trigger?(Input::B)
if $game_message.choice_cancel_type > 0
Sound.play_cancel
$game_message.choice_proc.call($game_message.choice_cancel_type - 1)
terminate_message
end
elsif Input.trigger?(Input::C)
Sound.play_decision
$game_message.choice_proc.call(self.index)
terminate_message
end
end
#--------------------------------------------------------------------------
# ● 数値入力の処理
#--------------------------------------------------------------------------
def input_number
if Input.trigger?(Input::C)
Sound.play_decision
$game_variables[$game_message.num_input_variable_id] =
@number_input_window.number
$game_map.need_refresh = true
terminate_message
end
end
end
===============================
# ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
#
# publish 2010/ 3/ 2
# update - 11/ 1/10a
#
#==============================================================================
# カスタマイズポイント
#==============================================================================
class Window_Message < Window_Selectable
#
# 基本行数
#
MAX_LINE = 3
#
# \p[] - キャラポップの高さ
#
CHARPOP_HEIGHT = 40
#
# \name[] - 名前枠 X,Y座標
#
NAME_WINDOW_OFFSET_X = 0
NAME_WINDOW_OFFSET_Y = -24
end
#==============================================================================
# 参照機能
#==============================================================================
class Game_Temp
attr_accessor :last_gain_material
attr_accessor :last_gain_holder
end
#==============================================================================
# フルグレードアップベース - 制御文字・基本機能
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 特殊文字の変換 + 準備
#--------------------------------------------------------------------------
alias xrxsv2_convert_special_characters convert_special_characters
def convert_special_characters
# 初期化
contents.font.size = Font.default_size
contents.font.bold = Font.default_italic
contents.font.italic = Font.default_bold
contents.font.shadow = Font.default_shadow
@type_wait = 0
@line_widths = []
@line_aligns = []
self.pop_character = nil
# ウィンドウ保持指定\holdがあるか?
@window_hold = (@text.gsub!(/\\hold/) { "" } != nil)
# \info
@info_mode = (@text.gsub!(/\\info/) { "" } != nil)
# 改行削除指定\_があるか?
if (/\\_(.*?)\x00/.match(@text)) != nil
$game_message.choice_start -= 1
@text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
end
# \name 判定
if @text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
name = $1
bitmap = @name_sprite.bitmap
w = [bitmap.text_size(name).width, 1].max
bitmap.dispose
@name_sprite.bitmap = Bitmap.new(w, 32)
bitmap = @name_sprite.bitmap
bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
@name_window.width = w + 16
@name_window.create_contents
@name_window.openness = 0
@name_window.open
@name_window.visible = true
@name_sprite.visible = true
else
@name_window.visible = false
@name_sprite.visible = false
@name_sprite.bitmap.dispose
@name_sprite.bitmap = Bitmap.new(32,32)
end
# キャラボップモード
if @text.gsub!(/\\[Pp]\[-1\]/) { "" }
self.pop_character = -1
elsif @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "" }
self.pop_character = $1.to_i
elsif @text.gsub!(/\\[Pp]/) { "" }
self.pop_character = 0
end
# 制御文字処理
xrxsv2_convert_special_characters
@text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\x11[#{$1}]" }
@text.gsub!(/\\size\[([0-9]+)\]/i) { "\x12[#{$1}]" }
@text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\x13[#{$1}]" }
@text.gsub!(/\\icon\[([0-9]+)\]/i) { "\x17[#{$1}]" }
@text.gsub!(/\\last_holder/i) { "\x18" }
@text.gsub!(/\\last_material/i) { "\x19" }
@text.gsub!(/\\B/) { "\x14" }
@text.gsub!(/\\I/) { "\x15" }
@text.gsub!(/\\D/) { "\x16" }
@text.gsub!(/\\n/) { "\x00" }
#
# ライン情報の取得
rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
/\[([0-9]+)\]/,
"\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
lines = @text.split("\x00")
@lines_max = lines.size
for i in 0...@lines_max
line = lines[i]
for rx in rxs
line.gsub!(rx) {""}
end
@line_aligns[i] =
line.sub!(/\\center/) {""} ? CENTER :
line.sub!(/\\right/) {""} ? RIGHT :
AUTO
# 行の横幅の取得と設定
cx = contents.text_size(line).width
@line_widths[i] = cx
end
# 位置揃え制御文字の削除
@text.gsub!(/\\center/) {""}
@text.gsub!(/\\right/) {""}
# キャラポップ時のウィンドウリサイズ
reszie_window_for_pop
end
#--------------------------------------------------------------------------
# ● メッセージの更新 *
#--------------------------------------------------------------------------
def update_message
@wait_count = @type_wait
loop do
c = @text.slice!(/./m) # 次の文字を取得
p = ""
deduct = 0
if c == "้" or c == "่" or c == "๊" or c == "๋" or c == "ี" or c == "ิ" or c == "ื" or c == "ึ" or c == "ุ" or c == "ู" or c == "ั" or c == "็" or c == "์"
p = c
elsif c == "ำ"
deduct = 2
else
@last_c = nil
end
case update_message_type(c)
when 1
break
when 2
next
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# 一文字の描画 (返り値 1:break, 2:next)
#--------------------------------------------------------------------------
def update_message_type(c)
case c
when nil # 描画すべき文字がない
finish_message # 更新終了
return 1
when "\x00" # 改行
new_line
max = MAX_LINE
max = 14 if self.pop_character != nil
if @line_count >= max # 行数が最大のとき
unless @text.empty? # さらに続きがあるなら
self.pause = true # 入力待ちを入れる
return 1
end
end
when "\x01" # \C[n] (文字色変更)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
return 2
when "\x11" # \s[n] (スピード変更)
@text.sub!(/\[([0-9]+)\]/, "")
@type_wait = $1.to_i
return 2
when "\x12" # \size
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.size = $1.to_i
return 2
when "\x13" # \O
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color.alpha = $1.to_i
return 2
when "\x02" # \G (所持金表示)
@gold_window.refresh
@gold_window.open
when "\x03" # \. (ウェイト 1/4 秒)
@wait_count = 15
return 1
when "\x04" # \| (ウェイト 1 秒)
@wait_count = 60
return 1
when "\x05" # \! (入力待ち)
self.pause = true
return 1
when "\x06" # \> (瞬間表示 ON)
@line_show_fast = true
when "\x07" # \< (瞬間表示 OFF)
@line_show_fast = false
when "\x08" # \^ (入力待ちなし)
@pause_skip = true
when "\x14" #\B
contents.font.bold ^= true
when "\x15" #\I
contents.font.italic ^= true
when "\x16" #\D
contents.font.shadow ^= true
when "\x17"
@text.sub!(/\[([0-9]+)\]/, "")
draw_icon($1.to_i, @contents_x, @contents_y)
@contents_x += 24
when "\x18"
name = ($game_temp.last_gain_holder.name rescue "")
update_message_type_draw_at(name)
when "\x19"
item = ($game_temp.last_gain_material.item rescue nil)
draw_item_name(item, @contents_x, @contents_y)
@contents_x += 196
else # 普通の文字
update_message_type_draw_at(c)
end
return 0
end
def update_message_type_draw_at(c)
return if c.to_s.size == 0
c_width = contents.text_size(c).width
c_height = contents.text_size(c).height
contents.draw_text(@contents_x, @contents_y - (c_height - WLH) / 2, c_width, c_height, c)
@contents_x += c_width
end
#--------------------------------------------------------------------------
# ● 改ページ処理
#--------------------------------------------------------------------------
alias xrxsv2_new_page new_page
def new_page
xrxsv2_new_page
update_charpop_window
end
#--------------------------------------------------------------------------
# ● 改行処理
#--------------------------------------------------------------------------
alias xrxsv2_new_line new_line
def new_line
xrxsv2_new_line
set_align
end
#--------------------------------------------------------------------------
# 位置揃え
#--------------------------------------------------------------------------
def set_align
w = @line_widths[@line_count].to_i
a = @line_aligns[@line_count]
case a
when CENTER
@contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
when RIGHT
@contents_x = contents.width - w
end
end
#--------------------------------------------------------------------------
# ● メッセージの終了
#--------------------------------------------------------------------------
alias xrxsv2_terminate_message terminate_message
def terminate_message
xrxsv2_terminate_message
process_hold
end
#--------------------------------------------------------------------------
# 定数
#--------------------------------------------------------------------------
AUTO = 0
LEFT = 1
CENTER = 2
RIGHT = 3
end
#==============================================================================
# アクティブイベント取得
#==============================================================================
class Game_Interpreter
attr_reader :event_id
end
#==============================================================================
# 各種機能の追加 - キャラポップ/ネーム/ホールド
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● カーソルの更新 *
#--------------------------------------------------------------------------
def update_cursor
if @index >= 0
x = ($game_message.face_name.empty? ? 0 : 112)
y = ($game_message.choice_start + @index) * WLH - 1
w = contents.width - x
if self.pop_character != nil
x += 28
w -= 20
end
self.cursor_rect.set(x, y, w, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# キャラクターの取得
# parameter : パラメータ
#--------------------------------------------------------------------------
def get_character(parameter)
# パラメータで分岐
case parameter
when -1 # プレイヤー
return $game_player
when 0 # 現在アクティブなイベント
id = $game_map.interpreter.event_id
events = $game_map.events
return events == nil ? nil : events[id]
else # 特定のイベント
events = $game_map.events
return events == nil ? nil : events[parameter]
end
end
#--------------------------------------------------------------------------
# (メッセージ終了時)ホールドの処理
#--------------------------------------------------------------------------
def process_hold
if @window_hold
@held_windows.push(Window_Copy.new(self))
@held_windows.push(Window_Copy.new(@name_window))
@held_windows.push(Sprite_Copy.new(@name_sprite))
@held_windows.push(Sprite_Copy.new(@back_sprite))
for sprite in @extra_sprites
next if sprite.disposed?
@held_windows.push(Sprite_Copy.new(sprite))
end
@extra_sprites.clear
self.openness = 0
@name_window.openness = 0
@back_sprite.visible = false
else
@held_windows.each {|object| object.dispose}
@held_windows.clear
end
@name_window.close
@name_sprite.visible = false
end
#--------------------------------------------------------------------------
# キャラポップ位置の設定と取得
#--------------------------------------------------------------------------
def pop_character=(character_id)
@pop_character = character_id
end
def pop_character
return @pop_character
end
#--------------------------------------------------------------------------
# キャラポップ時のウィンドウリサイズ
#--------------------------------------------------------------------------
def reszie_window_for_pop
if self.pop_character != nil
max_x = @line_widths.max.to_i
n = max_x + 32
n += $game_message.face_name.empty? ? 0 : 122
m = $game_message.face_name.empty? ? 0 : 96
w = @name_sprite.bitmap.width
self.width = [n, w].max
self.height = [@lines_max * WLH, m].max + 32
create_contents
update_charpop_window
elsif @info_mode
@line_aligns[0] = CENTER
self.x = - 8
self.width = Graphics.width + 16
self.height = 56
create_contents
else
self.x = 0
self.width = Graphics.width
self.height = MAX_LINE * WLH + 32
create_contents
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
alias xrxsv2_create_back_sprite create_back_sprite
def create_back_sprite
xrxsv2_create_back_sprite
@back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
@name_window = Window_Base.new(0,0,112,36)
@name_window.visible = false
@name_sprite = Sprite.new
@name_sprite.bitmap = Bitmap.new(32,32)
@name_sprite.visible = false
self.x = self.x
self.y = self.y
self.z = self.z
@held_windows = []
@extra_sprites = []
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
alias xrxsv2_dispose_back_sprite dispose_back_sprite
def dispose_back_sprite
xrxsv2_dispose_back_sprite
@name_window.dispose
@name_sprite.dispose
for window in @held_windows
window.dispose
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
alias xrxsv2_update_back_sprite update_back_sprite
def update_back_sprite
@name_window.update
xrxsv2_update_back_sprite
update_charpop_window
end
#--------------------------------------------------------------------------
# ウィンドウの位置と不透明度の設定 (キャラポップ)
#--------------------------------------------------------------------------
def update_charpop_window
if self.pop_character
character = get_character(self.pop_character)
return if character == nil
# [X座標]
n = self.width / 2
n = [n, @name_skin.width + 16].max if @current_name != nil
w = @name_sprite.bitmap.width
x = character.screen_x - [[n, w].max, self.width - 32].min
# [Y座標]
case @position
when 0
y = character.screen_y - CHARPOP_HEIGHT - self.height
else
y = character.screen_y + 16
end
x_max = Graphics.width - 4 - self.width
x_min = 4
y_max = Graphics.height - self.height
y_min = 4
self.x = [[x, x_max].min, x_min].max
self.y = [[y, y_max].min, y_min].max
end
end
#--------------------------------------------------------------------------
# 位置の連動
#--------------------------------------------------------------------------
def x=(n)
super
if @name_window
@name_window.x = n + NAME_WINDOW_OFFSET_X
@name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
end
end
def y=(n)
super
if @name_window
@name_window.y = n + NAME_WINDOW_OFFSET_Y
@name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
end
end
def z=(n)
super
if @name_window
@name_window.z = n + 1
@name_sprite.z = n + 2
end
end
end
#==============================================================================
# 伸縮対応
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● ウィンドウの背景と位置の設定 [再定義]
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # 通常ウィンドウ
self.opacity = 255
else # 背景を暗くする、透明にする
self.opacity = 0
end
case @position
when 0 # 上
self.y = 0
@gold_window.y = 360
when 1 # 中
self.y = (Graphics.height - self.height) / 2
@gold_window.y = 0
when 2 # 下
self.y = Graphics.height - self.height
@gold_window.y = 0
end
end
end
#==============================================================================
# □ Window_Copy
#------------------------------------------------------------------------------
# 指定のウィンドウのコピーを作成します。
#==============================================================================
class Window_Copy < Window_Base
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(window)
super(window.x, window.y, window.width, window.height)
self.contents = window.contents.dup unless window.contents.nil?
self.opacity = window.opacity
self.back_opacity = window.back_opacity
self.z = window.z - 3
self.visible = window.visible
end
end
#==============================================================================
# □ Sprite_Copy
#------------------------------------------------------------------------------
# 指定のスプライトのコピーを作成します。
#==============================================================================
class Sprite_Copy < Sprite
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(sprite)
super()
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = sprite.opacity
self.x = sprite.x
self.y = sprite.y
self.z = sprite.z - 3
self.ox = sprite.ox
self.oy = sprite.oy
self.zoom_x = sprite.zoom_x
self.visible = sprite.visible
end
end
# ▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
#
# publish 2010/ 3/ 2
# update - 11/ 1/10a
#
#==============================================================================
# カスタマイズポイント
#==============================================================================
class Window_Message < Window_Selectable
#
# 基本行数
#
MAX_LINE = 3
#
# \p[] - キャラポップの高さ
#
CHARPOP_HEIGHT = 40
#
# \name[] - 名前枠 X,Y座標
#
NAME_WINDOW_OFFSET_X = 0
NAME_WINDOW_OFFSET_Y = -24
end
#==============================================================================
# 参照機能
#==============================================================================
class Game_Temp
attr_accessor :last_gain_material
attr_accessor :last_gain_holder
end
#==============================================================================
# フルグレードアップベース - 制御文字・基本機能
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 特殊文字の変換 + 準備
#--------------------------------------------------------------------------
alias xrxsv2_convert_special_characters convert_special_characters
def convert_special_characters
# 初期化
contents.font.size = Font.default_size
contents.font.bold = Font.default_italic
contents.font.italic = Font.default_bold
contents.font.shadow = Font.default_shadow
@type_wait = 0
@line_widths = []
@line_aligns = []
self.pop_character = nil
# ウィンドウ保持指定\holdがあるか?
@window_hold = (@text.gsub!(/\\hold/) { "" } != nil)
# \info
@info_mode = (@text.gsub!(/\\info/) { "" } != nil)
# 改行削除指定\_があるか?
if (/\\_(.*?)\x00/.match(@text)) != nil
$game_message.choice_start -= 1
@text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
end
# \name 判定
if @text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
name = $1
bitmap = @name_sprite.bitmap
w = [bitmap.text_size(name).width, 1].max
bitmap.dispose
@name_sprite.bitmap = Bitmap.new(w, 32)
bitmap = @name_sprite.bitmap
bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
@name_window.width = w + 16
@name_window.create_contents
@name_window.openness = 0
@name_window.open
@name_window.visible = true
@name_sprite.visible = true
else
@name_window.visible = false
@name_sprite.visible = false
@name_sprite.bitmap.dispose
@name_sprite.bitmap = Bitmap.new(32,32)
end
# キャラボップモード
if @text.gsub!(/\\[Pp]\[-1\]/) { "" }
self.pop_character = -1
elsif @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "" }
self.pop_character = $1.to_i
elsif @text.gsub!(/\\[Pp]/) { "" }
self.pop_character = 0
end
# 制御文字処理
xrxsv2_convert_special_characters
@text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\x11[#{$1}]" }
@text.gsub!(/\\size\[([0-9]+)\]/i) { "\x12[#{$1}]" }
@text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\x13[#{$1}]" }
@text.gsub!(/\\icon\[([0-9]+)\]/i) { "\x17[#{$1}]" }
@text.gsub!(/\\last_holder/i) { "\x18" }
@text.gsub!(/\\last_material/i) { "\x19" }
@text.gsub!(/\\B/) { "\x14" }
@text.gsub!(/\\I/) { "\x15" }
@text.gsub!(/\\D/) { "\x16" }
@text.gsub!(/\\n/) { "\x00" }
#
# ライン情報の取得
rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
/\[([0-9]+)\]/,
"\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
lines = @text.split("\x00")
@lines_max = lines.size
for i in 0...@lines_max
line = lines[i]
for rx in rxs
line.gsub!(rx) {""}
end
@line_aligns[i] =
line.sub!(/\\center/) {""} ? CENTER :
line.sub!(/\\right/) {""} ? RIGHT :
AUTO
# 行の横幅の取得と設定
cx = contents.text_size(line).width
@line_widths[i] = cx
end
# 位置揃え制御文字の削除
@text.gsub!(/\\center/) {""}
@text.gsub!(/\\right/) {""}
# キャラポップ時のウィンドウリサイズ
reszie_window_for_pop
end
#--------------------------------------------------------------------------
# ● メッセージの更新 *
#--------------------------------------------------------------------------
def update_message
@wait_count = @type_wait
loop do
c = @text.slice!(/./m) # 次の文字を取得
case update_message_type(c)
when 1
break
when 2
next
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# 一文字の描画 (返り値 1:break, 2:next)
#--------------------------------------------------------------------------
def update_message_type(c)
case c
when nil # 描画すべき文字がない
finish_message # 更新終了
return 1
when "\x00" # 改行
new_line
max = MAX_LINE
max = 14 if self.pop_character != nil
if @line_count >= max # 行数が最大のとき
unless @text.empty? # さらに続きがあるなら
self.pause = true # 入力待ちを入れる
return 1
end
end
when "\x01" # \C[n] (文字色変更)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
return 2
when "\x11" # \s[n] (スピード変更)
@text.sub!(/\[([0-9]+)\]/, "")
@type_wait = $1.to_i
return 2
when "\x12" # \size
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.size = $1.to_i
return 2
when "\x13" # \O
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color.alpha = $1.to_i
return 2
when "\x02" # \G (所持金表示)
@gold_window.refresh
@gold_window.open
when "\x03" # \. (ウェイト 1/4 秒)
@wait_count = 15
return 1
when "\x04" # \| (ウェイト 1 秒)
@wait_count = 60
return 1
when "\x05" # \! (入力待ち)
self.pause = true
return 1
when "\x06" # \> (瞬間表示 ON)
@line_show_fast = true
when "\x07" # \< (瞬間表示 OFF)
@line_show_fast = false
when "\x08" # \^ (入力待ちなし)
@pause_skip = true
when "\x14" #\B
contents.font.bold ^= true
when "\x15" #\I
contents.font.italic ^= true
when "\x16" #\D
contents.font.shadow ^= true
when "\x17"
@text.sub!(/\[([0-9]+)\]/, "")
draw_icon($1.to_i, @contents_x, @contents_y)
@contents_x += 24
when "\x18"
name = ($game_temp.last_gain_holder.name rescue "")
update_message_type_draw_at(name)
when "\x19"
item = ($game_temp.last_gain_material.item rescue nil)
draw_item_name(item, @contents_x, @contents_y)
@contents_x += 196
else # 普通の文字
update_message_type_draw_at(c)
end
return 0
end
def update_message_type_draw_at(c)
return if c.to_s.size == 0
c_width = contents.text_size(c).width
c_height = contents.text_size(c).height
if c == "่" or c == "้" or c == "๊" or c == "๋"
@contents_x -= 2
elsif c == "ิ" or c == "ี" or c == "ึ" or c == "ื" or c == "็"
@contents_x -= 7
elsif c == "ำ"
@contents_x -= 3
elsif c == "์" or c == "ั"
@contents_x -= 6
elsif c == "ู" or c == "ุ"
@contents_x -= 6
end
contents.draw_text(@contents_x, @contents_y - (c_height - WLH) / 2, c_width, c_height, c)
if c == "่" or c == "้" or c == "๊" or c == "๋"
@contents_x += 1
elsif c == "ิ" or c == "ี" or c == "ึ" or c == "ื" or c == "็"
@contents_x += 1
elsif c == "ำ"
@contents_x += 1
elsif c == "์" or c == "ั"
@contents_x += 1
elsif c == "ู" or c == "ุ"
@contents_x += 1
end
@contents_x += c_width
end
#--------------------------------------------------------------------------
# ● 改ページ処理
#--------------------------------------------------------------------------
alias xrxsv2_new_page new_page
def new_page
xrxsv2_new_page
update_charpop_window
end
#--------------------------------------------------------------------------
# ● 改行処理
#--------------------------------------------------------------------------
alias xrxsv2_new_line new_line
def new_line
xrxsv2_new_line
set_align
end
#--------------------------------------------------------------------------
# 位置揃え
#--------------------------------------------------------------------------
def set_align
w = @line_widths[@line_count].to_i
a = @line_aligns[@line_count]
case a
when CENTER
@contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
when RIGHT
@contents_x = contents.width - w
end
end
#--------------------------------------------------------------------------
# ● メッセージの終了
#--------------------------------------------------------------------------
alias xrxsv2_terminate_message terminate_message
def terminate_message
xrxsv2_terminate_message
process_hold
end
#--------------------------------------------------------------------------
# 定数
#--------------------------------------------------------------------------
AUTO = 0
LEFT = 1
CENTER = 2
RIGHT = 3
end
#==============================================================================
# アクティブイベント取得
#==============================================================================
class Game_Interpreter
attr_reader :event_id
end
#==============================================================================
# 各種機能の追加 - キャラポップ/ネーム/ホールド
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● カーソルの更新 *
#--------------------------------------------------------------------------
def update_cursor
if @index >= 0
x = ($game_message.face_name.empty? ? 0 : 112)
y = ($game_message.choice_start + @index) * WLH - 1
w = contents.width - x
if self.pop_character != nil
x += 28
w -= 20
end
self.cursor_rect.set(x, y, w, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# キャラクターの取得
# parameter : パラメータ
#--------------------------------------------------------------------------
def get_character(parameter)
# パラメータで分岐
case parameter
when -1 # プレイヤー
return $game_player
when 0 # 現在アクティブなイベント
id = $game_map.interpreter.event_id
events = $game_map.events
return events == nil ? nil : events[id]
else # 特定のイベント
events = $game_map.events
return events == nil ? nil : events[parameter]
end
end
#--------------------------------------------------------------------------
# (メッセージ終了時)ホールドの処理
#--------------------------------------------------------------------------
def process_hold
if @window_hold
@held_windows.push(Window_Copy.new(self))
@held_windows.push(Window_Copy.new(@name_window))
@held_windows.push(Sprite_Copy.new(@name_sprite))
@held_windows.push(Sprite_Copy.new(@back_sprite))
for sprite in @extra_sprites
next if sprite.disposed?
@held_windows.push(Sprite_Copy.new(sprite))
end
@extra_sprites.clear
self.openness = 0
@name_window.openness = 0
@back_sprite.visible = false
else
@held_windows.each {|object| object.dispose}
@held_windows.clear
end
@name_window.close
@name_sprite.visible = false
end
#--------------------------------------------------------------------------
# キャラポップ位置の設定と取得
#--------------------------------------------------------------------------
def pop_character=(character_id)
@pop_character = character_id
end
def pop_character
return @pop_character
end
#--------------------------------------------------------------------------
# キャラポップ時のウィンドウリサイズ
#--------------------------------------------------------------------------
def reszie_window_for_pop
if self.pop_character != nil
max_x = @line_widths.max.to_i
n = max_x + 32
n += $game_message.face_name.empty? ? 0 : 122
m = $game_message.face_name.empty? ? 0 : 96
w = @name_sprite.bitmap.width
self.width = [n, w].max
self.height = [@lines_max * WLH, m].max + 32
create_contents
update_charpop_window
elsif @info_mode
@line_aligns[0] = CENTER
self.x = - 8
self.width = Graphics.width + 16
self.height = 56
create_contents
else
self.x = 0
self.width = Graphics.width
self.height = MAX_LINE * WLH + 32
create_contents
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
alias xrxsv2_create_back_sprite create_back_sprite
def create_back_sprite
xrxsv2_create_back_sprite
@back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
@name_window = Window_Base.new(0,0,112,36)
@name_window.visible = false
@name_sprite = Sprite.new
@name_sprite.bitmap = Bitmap.new(32,32)
@name_sprite.visible = false
self.x = self.x
self.y = self.y
self.z = self.z
@held_windows = []
@extra_sprites = []
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
alias xrxsv2_dispose_back_sprite dispose_back_sprite
def dispose_back_sprite
xrxsv2_dispose_back_sprite
@name_window.dispose
@name_sprite.dispose
for window in @held_windows
window.dispose
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
alias xrxsv2_update_back_sprite update_back_sprite
def update_back_sprite
@name_window.update
xrxsv2_update_back_sprite
update_charpop_window
end
#--------------------------------------------------------------------------
# ウィンドウの位置と不透明度の設定 (キャラポップ)
#--------------------------------------------------------------------------
def update_charpop_window
if self.pop_character
character = get_character(self.pop_character)
return if character == nil
# [X座標]
n = self.width / 2
n = [n, @name_skin.width + 16].max if @current_name != nil
w = @name_sprite.bitmap.width
x = character.screen_x - [[n, w].max, self.width - 32].min
# [Y座標]
case @position
when 0
y = character.screen_y - CHARPOP_HEIGHT - self.height
else
y = character.screen_y + 16
end
x_max = Graphics.width - 4 - self.width
x_min = 4
y_max = Graphics.height - self.height
y_min = 4
self.x = [[x, x_max].min, x_min].max
self.y = [[y, y_max].min, y_min].max
end
end
#--------------------------------------------------------------------------
# 位置の連動
#--------------------------------------------------------------------------
def x=(n)
super
if @name_window
@name_window.x = n + NAME_WINDOW_OFFSET_X
@name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
end
end
def y=(n)
super
if @name_window
@name_window.y = n + NAME_WINDOW_OFFSET_Y
@name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
end
end
def z=(n)
super
if @name_window
@name_window.z = n + 1
@name_sprite.z = n + 2
end
end
end
#==============================================================================
# 伸縮対応
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● ウィンドウの背景と位置の設定 [再定義]
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # 通常ウィンドウ
self.opacity = 255
else # 背景を暗くする、透明にする
self.opacity = 0
end
case @position
when 0 # 上
self.y = 0
@gold_window.y = 360
when 1 # 中
self.y = (Graphics.height - self.height) / 2
@gold_window.y = 0
when 2 # 下
self.y = Graphics.height - self.height
@gold_window.y = 0
end
end
end
#==============================================================================
# □ Window_Copy
#------------------------------------------------------------------------------
# 指定のウィンドウのコピーを作成します。
#==============================================================================
class Window_Copy < Window_Base
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(window)
super(window.x, window.y, window.width, window.height)
self.contents = window.contents.dup unless window.contents.nil?
self.opacity = window.opacity
self.back_opacity = window.back_opacity
self.z = window.z - 3
self.visible = window.visible
end
end
#==============================================================================
# □ Sprite_Copy
#------------------------------------------------------------------------------
# 指定のスプライトのコピーを作成します。
#==============================================================================
class Sprite_Copy < Sprite
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(sprite)
super()
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = sprite.opacity
self.x = sprite.x
self.y = sprite.y
self.z = sprite.z - 3
self.ox = sprite.ox
self.oy = sprite.oy
self.zoom_x = sprite.zoom_x
self.visible = sprite.visible
end
end