if @popchar >= 0
@text_save = @now_text.clone
@max_x = 0
@max_y = 4
for i in 0..3
line = @now_text.split(/\n/)[3-i]
@max_y -= 1 if line == nil and @max_y <= 4-i
next if line == nil
cx = contents.text_size(line).width
@max_x = cx if cx > @max_x
end
self.width = @max_x + 48 + @face_indent
self.height = (@max_y - 1) * 32 + 64
else
@max_x = self.width - 32 - @face_indent
end
reset_window
if name_window_set
#设置名字框的地方!★★★★★★★★★★
if @left_keep == true
off_x = 80 - self.contents.text_size(name_text).width/2
elsif @right_keep == true
off_x = 430 - self.contents.text_size(name_text).width/2
else
off_x = 0
end
off_y = 110
if @left_keep != true and @right_keep != true
off_y = -15
@message_x = @x =80
end
space = 6
w = self.contents.text_size(name_text).width + 26 + space
x = @alignment ? self.x + off_x - space / 2 : self.x + off_x - space / 2 + self.width - w
y = self.y + off_y - space / 2
h = 30 + space
@name_window_frame = Window_Frame.new(x, y, w, h)
@name_window_frame.z = self.z + 1
@name_window_frame.back_opacity = 155#####
@name_window_frame.windowskin = RPG::Cache.windowskin("名字框")
x = @alignment ? self.x + off_x - space / 2 + 4 : self.x + off_x - space / 2 + 4 + self.width - w
y = self.y + off_y - space / 2 - 5
@name_window_text = Air_Text.new(x+11, y+10, name_text)#
@name_window_text.z = 10000
end
end
reset_window
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
super
x=@message_x
#颜色自定义设定范围0-255
self.contents.font.color = Color.new($color0, $color1, $color2)
#颜色自定义设定范围0-255
if @autoclosetime == 0
@autoclosetime = -1
terminate_message
end
if @autoclosetime >= 1
@autoclosetime -= 1
end
if @fade_in
self.contents_opacity += 24
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
if self.contents_opacity == 255
@fade_in = false
end
return
end
@now_text = nil if @now_text == ""
if @now_text != nil and @mid_stop == false
if @write_wait > 0
@write_wait -= 1
return
end
text_not_skip = $game_system.typing
while true
@max_x = @x if @max_x < @x
@max_y = @y if @max_y < @y
if (c = @now_text.slice!(/./m)) != nil
if c == "\000"
c = "\\"
end
if c == "\001"
@now_text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
c = ""
end
if c == "\002"
if @gold_window == nil and @popchar <= 0
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
c = ""
end
if c == "\004"
if @playtime_window == nil and @popchar <=0
@playtime_window = Window_PlayTime.new
@playtime_window.x = 80
if $game_temp.in_battle
@playtime_window.y = 192
else
@playtime_window.y = self.y >= 128 ? 32 : 384
end
@playtime_window.opacity = self.opacity
@playtime_window.back_opacity = self.back_opacity
end
end
if c == "\016"
text_not_skip = false
c = ""
end
if c == "\017"
text_not_skip = true
c = ""
end
if c == "\020"
@mid_stop = true
c = ""
end
if c == "\023"
@indent = @x
c = ""
end
if c == "\024"
@now_text.sub!(/\[([0-9]+)\]/, "")
@opacity = $1.to_i
c = ""
end
self.contents.font.size = Size######################################
if c == "\025"
@now_text.sub!(/\[([0-9]+)\]/, "")
self.contents.font.size = [[$1.to_i, 6].max, 32].min
c = ""
end
if c == "\026"
@now_text.sub!(/\[([0-9]+)\]/, "")
@x += $1.to_i
c = ""
end
if c == "\027"
@now_text.sub!(/\[([0-9]+)\]/, "")
@x += $1.to_i * self.contents.font.size / 2
next
end
if c == "\030"
@now_text.sub!(/\[(.*?)\]/, "")
self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
@x += 24
c = ""
end
if c == "\050"
@now_text.sub!(/\[([0-9]+)\]/, "")
@autoclosetime = $1.to_i
next
end
# Start
# ◎
# \MSの場合
if c == "\052"
@now_text.sub!(/\[([0-9]+)\]/, "")
bcolor = $1.to_i
@bflag = true
end
# \MEの場合
if c == "\053"
@bflag = false
bcolor = 0
end
# ◎
# End
# Start
# ◎
if @bflag == true
if bcolor >= 0 and bcolor <= 7
bsize = self.contents.text_size(c).width
self.contents.fill_rect(4 + @x, 32 * @y, bsize, 32, text_color(bcolor))
end
end
# ◎
# End
if c == "\n"
@x = @message_x
#@x = 150#第二行缩进???
end
#if @lines >= $game_temp.choice_start
# @cursor_width = [@cursor_width, @max_x - @face_indent].max
#end
@cursor_width = 400
@lines += 1
@y += 1
#if @lines >= $game_temp.choice_start
# @x = 8 + @indent + @face_indent
#end
c = ""
end
#mxl = 0
if c != ""
# mxl += 1
# 文字描画
@x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
#if mxl == 0
#c ="◆"+""
#end
end
if Input.press?(Input::B)
text_not_skip = false
end
else
text_not_skip = true
break
end
# 終了判定
if text_not_skip
break
end
end
@write_wait += @write_speed
return
end
if @input_number_window != nil
@input_number_window.update
# 決定
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[$game_temp.num_input_variable_id] =
@input_number_window.number
$game_map.need_refresh = true
@input_number_window.dispose
@input_number_window = nil
terminate_message
end
return
end
if @contents_showing
if $game_temp.choice_max == 0
self.pause = true
end
# 取消
if Input.trigger?(Input::B)
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
$game_system.se_play($data_system.cancel_se)
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
end
# 決定
if Input.trigger?(Input::C)
if $game_temp.choice_max > 0
$game_system.se_play($data_system.decision_se)
$game_temp.choice_proc.call(self.index)
end
if @mid_stop
@mid_stop = false
return
else
terminate_message
end
end
return
end
if @fade_out == false and $game_temp.message_text != nil
@contents_showing = true
$game_temp.message_window_showing = true
refresh
Graphics.frame_reset
self.visible = true
self.contents_opacity = 0
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
@fade_in = true
return
end
if self.visible
@fade_out = true
self.opacity -= 48
if self.opacity == 0
self.visible = false
@fade_out = false
$game_temp.message_window_showing = false
end
return
end
end
#--------------------------------------------------------------------------
# ● 获得字符
#--------------------------------------------------------------------------
def get_character(parameter)
case parameter
when 0
return $game_player
else
events = $game_map.events
return events == nil ? nil : events[parameter]
end
end
#--------------------------------------------------------------------------
# ● ウィンドウの位置と不透明度の設定
#--------------------------------------------------------------------------
def reset_window
# 判定
if @popchar >= 0
events = $game_map.events
if events != nil
character = get_character(@popchar)
x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
self.x = x
self.y = y
end
elsif @popchar == -1
self.x = -4
self.y = -4
self.width = 648
self.height = 488
else
if $game_temp.in_battle
self.y = 48
else
case $game_system.message_position
when 0 # 上
self.y = 16
when 1 # 中
self.y = 160 + 15
when 2 # 下
self.y = 304
end
self.x = 60
self.height = 160
if @name_window_text == nil #@left_keep != true and @right_keep != true
self.width = 520