class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
x = y = 0
@cursor_width = 0
# 到选择项的下一行字
if $game_temp.choice_start == 0
x = 8
end
# 有等待显示的文字的情况下
if $game_temp.message_text != nil
text = $game_temp.message_text
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
text.gsub!(/\\[Gg][Ss]\[([\w]+)\]/) { eval("$game_system."+$1) }#萌新添加
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 为了方便、将 "\\\\" 变换为 "\000"
text.gsub!(/\\\\/) { "\000" }
# "\\C" 变为 "\001" 、"\\G" 变为 "\002"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# \\ 的情况下
if c == "\000"
# 还原为本来的文字
c = "\\"
end
# \C[n] 的情况下
if c == "\001"
# 更改文字色
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# 下面的文字
next
end
# \G 的情况下
if c == "\002"
# 生成金钱窗口
if @gold_window == nil
@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
# 下面的文字
next
end
# 另起一行文字的情况下
if c == "\n"
# 刷新选择项及光标的高
if y >= $game_temp.choice_start
@cursor_width = [@cursor_width, x].max
end
# y 加 1
y += 1
x = 0
# 移动到选择项的下一行
if y >= $game_temp.choice_start
x = 8
end
# 下面的文字
next
if (x + 4 + self.contents.text_size(c).width) > self.contents.width
y += 1
x = 0
end
end
# 描绘文字
self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
# x 为要描绘文字的加法运算
x += self.contents.text_size(c).width
#Audio.se_play("Audio/SE/"+"006-System06",80,100)
end
end
# 选择项的情况
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
end