Project1
标题:
问一个有关对话框脚本的问题。。。
[打印本页]
作者:
CR~
时间:
2014-12-10 21:58
标题:
问一个有关对话框脚本的问题。。。
这个脚本如果使用了\p让对话框显示在事件上方的话,那么不用\p[-2]他是不会变回系统默认的对话框,,,
怎么能让他只有在用了\p的控制符才会显示在事件上方,如果什么控制符都没有就是系统默认的对话框。。?
谢谢,
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 显示文章、选择项等信息的窗口。
#==============================================================================
#
# 系统默认控制符:
# \| :停顿片刻(20帧)
# \~ :文字直接消失
# \\:显示"\"这个符号
# \c[0-7]:更改颜色
# \g:显示金钱窗口
# \name[1]:显示1号角色的姓名
# \v[7]:显示7号变量的值
#
# 加强控制符(除非含义不同,否则命令不区分大小写):
# \A:头像及姓名框靠左排列
# \a:头像及姓名框靠右排列
#
# \b[50]:空50象素
#
# \d[4]:空4个字节(2个汉字)的位置
#
# \F[001]:在对话显示头像“Graphics/battlers/66rpg_001_f.png”
# \f[1]:在对话中显示1号角色的头像,没有的话同\F[1]效果
#
# \h[12]:改用12号字
#
# \i:下一行从这个位置开始
#
# \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
# \l[1]:在左边显示1号角色的半身像,没有的话同\L[1]效果
# \Lk:清除左边的图像
# 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
#
# \m[李逍遥]:用默认颜色(颜色0)显示一个“李逍遥”方框,表示说话人姓名
# \m2[\n[1]]:用颜色2显示1号主角的姓名方框
#
# \o[123]:文字透明度改为123,模拟将死之人(汗)
#
# 地图画面
# \p[-1]:对话框全屏显示
# \p:本事件上方出现对话框,如果上方空间不够则出现在下方
# \p[0]:主人公上方(或下方)出现对话框
# \p[1]:对话框出现在1号事件的上方(或下方)
# \p[-2]:恢复系统的对话框位置
# 用正数参数使用\p功能时,会自动调整对话框的大小和位置
#
# 战斗画面
# \p[-1]:对话框最小化并居中显示
# \p[0-3]:我方战斗者上方出现对话框
# \p[4-11]:敌方战斗者上方出现对话框
# \p[-2]:恢复系统的对话框位置
# 用不是-2的参数使用\p功能时,会自动调整对话框的大小和位置
#
# \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
# \r[1]:在右边显示1号角色的半身像,没有的话同\R[1]效果
# \Rk:清除右边的图像
# 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
#
# \s:关闭打字效果
# \s[0-9]:打字速度设定,越大越慢
#
# \t:显示游戏时间窗口
#
# \u[rrggbb]:直接以十六进制指定颜色,注意这里会把透明度重设为255
#
# \v[7:3]:显示7号变量的值,不足3位的话补零
# \v[a7]:显示7号防具的图标和名称
# \v[c7]:显示7号职业的名称
# \v[e7]:显示7号属性的名称
# \v[i7]:显示7号道具的图标和名称
# \v[m7]:显示7号地图的名称
# (注:需配合$data_maps加载使用)
# \v[n7]:显示7号角色的名称(和\n[7]重复,主要功能在下面)
# \v[n7:7]:显示7号角色的灵巧,参数0-13分别表示等级、EXP、HP、SP、MaxHP、MaxSP
# 力量、灵巧、速度、魔力、攻击、防御、魔防、回避
# \v[s7]:显示7号特技的图标和名称
# \v[t7]:显示7号状态的名称
# \v[v7]:显示7号事件的名称,v0为显示本事件名称
# \v[w7]:显示7号武器的图标和名称
#
# \w[20]:等待20帧(1秒)后自动关闭窗口
#
# \x[20]:本行之后文字定位到第20列,已超宽的话忽略
#
# \z[20]:打字到这里时停顿20帧,关闭打字效果的话忽略
#
#==============================================================================
# 如果游戏加密请将以下内容解除注释
# $encrypted = true
# 如果要使用地图名显示功能请将以下内容解除注释
$data_maps = load_data("Data/MapInfos.rxdata")
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化状态
#--------------------------------------------------------------------------
def initialize
super(40, 304, 560, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.visible = false
self.z = 9998
@fade_in = false
@fade_out = false
@contents_showing = false
@cursor_width = 0
self.active = false
self.index = -1
@popchar = -2
@alignment = true
@wait_count = 0
@type_speed = 0
@type_wait = 0
@text_buffer = []
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
terminate_message
$game_temp.message_window_showing = false
if @input_number_window != nil
@input_number_window.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 处理信息结束
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
self.contents.clear
# 清除显示中标志
@contents_showing = false
# 呼叫信息调用
if $game_temp.message_proc != nil
$game_temp.message_proc.call
end
# 清除文章、选择项、输入数值的相关变量
$game_temp.message_text = nil
$game_temp.message_proc = nil
$game_temp.choice_start = 99
$game_temp.choice_max = 0
$game_temp.choice_cancel_type = 0
$game_temp.choice_proc = nil
$game_temp.num_input_start = 99
$game_temp.num_input_variable_id = 0
$game_temp.num_input_digits_max = 0
# 开放金钱窗口
if @gold_window != nil
@gold_window.dispose
@gold_window = nil
end
# 开放时间窗口
if @playtime_window != nil
@playtime_window.dispose
@playtime_window = nil
end
# 开放姓名窗口
if @name_window != nil
@name_window.dispose
@name_window = nil
end
if @name_airtext != nil
@name_airtext.dispose
@name_airtext = nil
end
# 开放角色图片
if @right_picture != nil and @right_keep == true
@right_picture.dispose
end
if @left_picture != nil and @left_keep == true
@left_picture.dispose
end
@face_bitmap = nil
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 初期化
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = Font.default_size
x = y = max_x = max_y = @indent = lines = 0
@left_keep = @right_keep = false
@face_indent = 0
@opacity = 255
@cursor_width = 0
@wait_set = 0
face = nil
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]\[([ACEIMNSTVWaceimnstvw]?)([0-9]+)[:]?([0-9]*)\]/) {
convert_value($1, $2.to_i, $3)
}
end until text == last_text
# 显示后等待的判定
if (/\\[Ww]\[([0-9]+)\]/.match(text)) != nil
@wait_set = $1.to_i * 2 - 1
text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "" }
end
# 文字位置的判定
if (/\\[Pp]\[([-0-9]+)\]/.match(text))!=nil then
@popchar = $1.to_i
if @popchar == -1 and not $game_temp.in_battle
x = @indent = 48
y = 4
end
text.gsub!(/\\[Pp]\[([-0-9]+)\]/) { "" }
if $game_temp.in_battle
if @popchar >= 4
@alignment = true
else
@alignment = false
end
end
elsif (/\\[Pp]/.match(text))!=nil then
@popchar = 1000
text.gsub!(/\\[Pp]/) { "" }
end
#——对齐设置
if (/\\([Aa])/.match(text))!=nil then
if $1 == "A"
@alignment = true
else
@alignment = false
end
text.gsub!(/\\([Aa])/) { "" }
end
#——头像设置
if (/\\([Ff])\[(.+?)\]/.match(text))!=nil then
face = "66rpg_" + $2 + "_f.png"
if $1 == "f" and $game_actors[$2.to_i] != nil
face = $game_actors[$2.to_i].battler_name + "_f.png"
end
if $encrypted or FileTest.exist?("Graphics/Battlers/#{face}")
@face_bitmap = Bitmap.new("Graphics/Battlers/#{face}")
if @alignment
@face_indent = 128
x += @face_indent
end
else
@face_bitmap = nil
end
text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
end
#——左半身像设置
if (/\\([Ll])\[(.+?)\]/.match(text))!=nil then
face = "66rpg_" + $2 + "_h.png"
if $1 == "l" and $game_actors[$2.to_i] != nil
face = $game_actors[$2.to_i].battler_name + "_h.png"
end
if $encrypted or FileTest.exist?("Graphics/battlers/#{face}")
if @left_picture != nil
@left_picture.dispose
end
@left_picture = Sprite.new
@left_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
@left_picture.y = 480-@left_picture.bitmap.height
@left_picture.x = 0
@left_picture.mirror = true
@popchar = -2
text.gsub!(/\\([Ll])\[(.*?)\]/) { "" }
end
end
#——右半身像设置
if (/\\([Rr])\[(.+?)\]/.match(text))!=nil then
face = "66rpg_" + $2 + "_h.png"
if $1 == "r" and $game_actors[$2.to_i] != nil
face = $game_actors[$2.to_i].battler_name + "_h.png"
end
if $encrypted or FileTest.exist?("Graphics/battlers/#{face}")
if @right_picture != nil
@right_picture.dispose
end
@right_picture = Sprite.new
@right_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
@right_picture.y = 480-@right_picture.bitmap.height
@right_picture.x = 640-@right_picture.bitmap.width
@popchar = -2
text.gsub!(/\\([Rr])\[(.*?)\]/) { "" }
end
end
if (/\\[Rr][Kk]/.match(text)) != nil
@right_keep = true
text.sub!(/\\[Rr]k/) { "" }
end
if (/\\[Ll][Kk]/.match(text)) != nil
@left_keep = true
text.sub!(/\\[Ll]k/) { "" }
end
# 替换人物姓名
text.gsub!(/\\[Nn]ame\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 显示人物姓名
name_window_set = false
if (/\\[Nn]ame([0-9]*?)\[(.+?)\]/.match(text)) != nil
name_window_set = true
if $1 == ""
color = 0
else
color = $1.to_i
end
if color >= 0 and color <= 7
name_color = color
end
name_text = $2
text.gsub!(/\\[Nn]ame([0-9]*?)\[(.*?)\]/) { "" }
end
# 打字效果设定
if (/\\[Ss]\[([0-9]+)\]/.match(text)) != nil
@type_speed = [$1.to_i, 9].min
text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "" }
# 关闭打字效果
elsif (/\\[Ss]/.match(text))!=nil then
@type_speed = -1
text.gsub!(/\\[Ss]/) { "" }
end
# 窗口位置计算
if @popchar >= 0 or (@popchar == -1 and $game_temp.in_battle)
# 浮于事件上方的情况
max_x = 16
# 获得行数
textlines = text.split(/\n/)
cy = max_y = textlines.size
for i in 0..max_y - 1
line = plain_text(textlines[i])
if line == ""
cy -= 1
next
end
cx = contents.text_size(line).width
if i >= $game_temp.choice_start and $game_temp.choice_start > 0
cx += 16
end
# 获得最大宽度
max_x = cx if cx > max_x
end
# 计算宽度和高度
max_y = cy if cy < max_y
max_y = [max_y, 1].max
self.width = max_x + 32 + @face_indent
self.width += 16 if $game_temp.choice_start == 0
# 右边有头像的情况宽度再加 128
self.width += 128 if @face_bitmap != nil and not @alignment
max_x += 8 if $game_temp.choice_start == 0
# 有输入数值的情况下增加一行并调整宽度
if $game_temp.num_input_variable_id > 0
max_y += 1
dummy_bitmap = Bitmap.new(32, 32)
cursor_width = dummy_bitmap.text_size("0").width + 8
dummy_bitmap.dispose
cx = cursor_width * $game_temp.num_input_digits_max + 16
max_x = cx if cx > max_x
end
self.height = max_y * 32 + 32
# 有头像的情况高度定为 160
self.height = [self.height, 160].max if @face_bitmap != nil
# 不是浮于事件上方的情况
else
max_x = self.width - 12 - @face_indent
self.height = [text.split(/\n/).size * 32 + 32, 160].max
end
# 绘制窗体样式
reset_window
# 姓名框
if name_window_set
w = self.contents.text_size(name_text).width + 16
xn = @alignment ? self.x : self.x + self.width - w
if self.y < 20
if @popchar >= 0
self.y += self.height + 48 if @popchar >= 0
else
self.y = 36
end
end
yn = self.y - 20
@name_window = Window_Name.new(xn, yn, w)
@name_window.z = self.z + 1
@name_airtext = Window_AirText.new(xn + 8, yn + 8, name_text, name_color)
@name_airtext.z = self.z + 2
@name_window.back_opacity = self.back_opacity
end
# 逐字打印文本
text.gsub!(/\\\\/) { "\000" }
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
text.gsub!(/\\[Tt]/) { "\003" }
text.gsub!(/\\[Uu]\[([0-9A-Fa-f]{6})\]/) { "\004[#{$1}]" }
text.gsub!(/\\[Xx]\[([0-9]+)\]/) { "\005[#{$1}]" }
text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "\022[#{$1}]" }
text.gsub!(/\\[Ii]/) { "\023" }
text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
text.gsub!(/\\[~]/) { "\031" }
text.gsub!(/\\[|]/) { "\032" }
start_x = @indent + @face_indent
@text_buffer = []
c_wait = 0
while ((c = text.slice!(/./m)) != nil)
if c == "\000"
c = "\\"
end
if c == "\001"
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
if @type_speed < 0
self.contents.font.color = text_color(color)
else
@text_buffer.push([nil, -1, text_color(color)])
end
end
next
end
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 == "\003"
if @playtime_window == nil
@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
next
end
if c == "\004"
text.sub!(/\[([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\]/, "")
if @type_speed < 0
self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)
else
@text_buffer.push([nil, -1, Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)])
end
next
end
if c == "\005"
text.sub!(/\[([0-9]+)\]/, "")
tab = ($1.to_i - 1) * self.contents.text_size("0").width
x = start_x + tab if x < start_x + tab
next
end
if c == "\022"
text.sub!(/\[([0-9]+)\]/, "")
c_wait += $1.to_i
next
end
if c == "\023"
@indent = x
next
end
if c == "\024"
text.sub!(/\[([0-9]+)\]/, "")
if @type_speed < 0
self.contents.font.color.alpha = [[0, $1.to_i].max, 255].min
else
color = self.contents.font.color.clone
color.alpha = [[0, $1.to_i].max, 255].min
@text_buffer.push([nil, -1, color])
end
next
end
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
self.contents.font.size = [[$1.to_i, 6].max, 32].min
if @type_speed >= 0
@text_buffer.push([nil, -1, self.contents.font.size])
end
next
end
if c == "\026"
text.sub!(/\[([0-9]+)\]/, "")
x += $1.to_i
next
end
if c == "\027"
text.sub!(/\[([0-9]+)\]/, "")
x += $1.to_i * self.contents.text_size("0").width
next
end
if c == "\030"
text.sub!(/\[(.*?)\]/, "")
if @type_speed < 0
self.contents.blt(x , y * line_height + 4, RPG::Cache.icon($1),
Rect.new(0, 0, 24, 24))
else
@text_buffer.push([Rect.new(x, y * line_height + 4, 24, 24),
c_wait, RPG::Cache.icon($1)])
c_wait = @type_speed
end
x += 24
next
end
if c == "\031"
terminate_message
return
end
if c == "\032"
c_wait += 20
c = ""
end
if c == "\n"
if x == start_x and (@popchar != -2 and not $game_temp.in_battle)
$game_temp.choice_start -= 1
lines -= 1
y -= 1
end
if lines >= $game_temp.choice_start
@cursor_width = [@cursor_width, x - @face_indent].max
end
lines += 1
y += 1
start_x = @face_indent + @indent
x = start_x
if lines >= $game_temp.choice_start
x += 8
end
next
end
# 描绘文字
c_width = self.contents.text_size(c).width
c_height = line_height
if @type_speed < 0
self.contents.draw_text(x, c_height * y, c_width, c_height, c)
else
@text_buffer.push([Rect.new(x, c_height * y, c_width, c_height),
c_wait, c])
c_wait = @type_speed
end
x += c_width
end
@type_wait = @text_buffer[0][1] if @text_buffer.size > 0
end
if @type_speed < 0 and $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
# 渐变的情况下
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
# 打字的情况下
if @text_buffer.size > 0
# 按键跳过打字
if Input.trigger?(Input::C) or Input.trigger?(Input::B)
type_next_char until @text_buffer.size == 0
return
end
# 等待打字延时
if @type_wait > 0
@type_wait -= 1
end
# 传送位图
if @type_wait <= 0
type_next_char
end
return
end
# 输入数值的情况下
if @input_number_window != nil
if @input_number_window.contents_opacity < 255
@input_number_window.contents_opacity += 24
return
end
@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
terminate_message
end
# 时间窗口可见的情况下
if @playtime_window != nil
@playtime_window.update
end
# 等待中的情况下
if @wait_count > 0
@wait_count -= 1
if @wait_count == 0
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
@wait_count = 0
if @wait_set != 0
@wait_count = @wait_set
end
self.visible = true
if @type_speed < 0
self.contents_opacity = 0
@fade_in = true
else
self.contents_opacity = 255
end
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
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 1000 # 本事件
return $game_system.map_interpreter.get_character(0)
when 0 # 角色
return $game_player
else # 其他事件
return $game_system.map_interpreter.get_character(parameter)
end
end
#--------------------------------------------------------------------------
# ● 设置窗口位置与不透明度
#--------------------------------------------------------------------------
def reset_window
# 位置判定
if $game_temp.in_battle
if @popchar >= 4
x = $game_troop.enemies[@popchar - 4].screen_x - self.width / 2
y = $game_troop.enemies[@popchar - 4].screen_y - self.height - 100
self.x = [[x, 0].max, 640 - self.width].min
self.y = [y, 16].max
elsif @popchar >= 0
x = $game_party.actors[@popchar].screen_x - self.width / 2
y = $game_party.actors[@popchar].screen_y - self.height - 100
self.x = [[x, 0].max, 640 - self.width].min
self.y = [y, 16].max
elsif @popchar == -1
self.x = 320 - self.width / 2
self.y = 192 - self.height / 2
elsif @popchar == -2
self.y = 16
end
else
if @popchar >= 0
events = $game_map.events
if events != nil
character = get_character(@popchar)
if character != nil
x = [[character.screen_x - self.width / 2, 4].max, 636 - self.width].min
y = character.screen_y - 48 - self.height
y = character.screen_y if y < 4
y = [y, 476 - self.height].min
self.x = x
self.y = y
else
@popchar = -2
end
end
elsif @popchar == -1
self.x = -4
self.y = -4
self.width = 648
self.height = 488
else
case $game_system.message_position
when 0 # 上
self.y = 16
when 1 # 中
self.y = [240 - self.height / 2, 16].max
when 2 # 下
self.y = [[304, 464 - self.height].min, 16].max
end
if (@left_picture != nil and not @left_keep) or
(@right_picture != nil and not @right_keep)
self.y = [[304, 464 - self.height].min, 16].max
end
self.x = 60
if @face_bitmap == nil
self.width = 520
else
self.width = 600
self.x -= 60
end
end
end
self.contents = Bitmap.new(self.width - 32, self.height - 32)
if @face_bitmap != nil
if @alignment
self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
else
self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
Rect.new(0, 0, 96, 96))
end
@face_bitmap.dispose
@face_bitmap = nil
end
if @popchar == -1 and not $game_temp.in_battle
self.opacity = 255
self.back_opacity = 0
elsif $game_system.message_frame == 0
self.opacity = 255
self.back_opacity = 224
else
self.opacity = 0
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 行高
#--------------------------------------------------------------------------
def line_height
if self.contents.font.size >= 20 and self.contents.font.size <= 24
return 32
else
return self.contents.font.size * 15 / 10
end
end
#--------------------------------------------------------------------------
# ● 纯文本变换
#--------------------------------------------------------------------------
def plain_text(text)
plain = text.clone
plain.gsub!(/\\\\/) { "\\" }
plain.gsub!(/\\[CcGgTtUuOoHhIiZz]+(\[([0-9A-Fa-f]+)\])*/) { "" }
plain.gsub!(/\030\[(.*?)\]/) { " " * (24.0 / self.contents.font.size * 2).ceil }
plain.gsub!(/\\[Bb]\[([0-9]+)\]/) { " " * ($1.to_f / self.contents.font.size * 2).ceil }
plain.gsub!(/\\[Dd]\[([0-9]+)\]/) { " " * $1.to_i}
plain.gsub!(/^.*?\\[Xx]\[([0-9]+)\]/) { " " * ($1.to_i - 1)}
return plain
end
#--------------------------------------------------------------------------
# ● \V 变换
#--------------------------------------------------------------------------
def convert_value(option, index, width)
option == nil ? option = "" : nil
option.downcase!
case option
when "a"
unless $data_armors[index].name == nil
r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
end
when "c"
unless $data_classes[index] == nil
r = $data_classes[index].name
end
when "e"
unless $data_system.elements[index] == nil
r = $data_system.elements[index]
end
when "i"
unless $data_items[index].name == nil
r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
end
when "m"
unless $data_maps == nil or $data_maps[index].name == nil
r = $data_maps[index].name
end
when "n"
unless $game_actors[index] == nil
case width
when "0"
r = $game_actors[index].level
when "1"
r = $game_actors[index].exp
when "2"
r = $game_actors[index].hp
when "3"
r = $game_actors[index].sp
when "4"
r = $game_actors[index].maxhp
when "5"
r = $game_actors[index].maxsp
when "6"
r = $game_actors[index].str
when "7"
r = $game_actors[index].dex
when "8"
r = $game_actors[index].agi
when "9"
r = $game_actors[index].int
when "10"
r = $game_actors[index].atk
when "11"
r = $game_actors[index].pdef
when "12"
r = $game_actors[index].mdef
when "13"
r = $game_actors[index].eva
else
r = $game_actors[index].name
end
end
when "s"
unless $data_skills[index].name == nil
r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
end
when "t"
unless $data_states[index] == nil
r = $data_states[index].name
end
when "v"
unless $game_map == nil or index < 0 or
$game_system.map_interpreter.get_character(index) == nil
r = $game_system.map_interpreter.get_character(index).name
end
when "w"
unless $data_weapons[index].name == nil
r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
end
else
if width != ""
r = sprintf("%0#{width}d", $game_variables[index])
else
r = $game_variables[index]
end
end
r == nil ? r = "" : nil
return r
end
#--------------------------------------------------------------------------
# ● 更新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 0
n = $game_temp.choice_start + @index
self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# ● 打印下一个字
#--------------------------------------------------------------------------
def type_next_char
c = @text_buffer.shift
rc = c[0]
case c[2]
when Bitmap
self.contents.blt(rc.x, rc.y, c[2], c[2].rect)
when Color
self.contents.font.color = c[2]
when Integer
self.contents.font.size = c[2]
else
self.contents.draw_text(rc, c[2])
end
if @text_buffer.size > 0
@type_wait = @text_buffer[0][1]
type_next_char if @type_wait == -1
else
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
end
end
end
#==============================================================================
# ■ Window_Name
#------------------------------------------------------------------------------
# 显示对话人姓名的窗口。
#==============================================================================
class Window_Name < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize(x, y, width)
super(x, y, width, 40)
self.contents = nil
self.back_opacity = 160
end
end
#==============================================================================
# ■ Window_AirText
#------------------------------------------------------------------------------
# 显示对话人姓名的文字。
#==============================================================================
class Window_AirText < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize(x, y, designate_text, color)
super(x-16, y-16, 32 + designate_text.size * 12, 56)
self.opacity = 0
self.back_opacity = 0
self.contents = Bitmap.new(self.width - 32, self.height - 32)
w = self.contents.width
h = self.contents.height
if color.is_a?(Integer)
self.contents.font.color = text_color(color)
else
self.contents.font.color = color
end
self.contents.draw_text(0, 0, w, h, designate_text)
end
end
#==============================================================================
# ■ Game_Event
#------------------------------------------------------------------------------
# 处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
# 在 Game_Map 类的内部使用。
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# ● 事件名字
#--------------------------------------------------------------------------
def name
return @event.name
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1