6R增强对话框升级版
这个对话框多久没人维护了……是不是大家都用fuki去了小日本写的东西,6R翻译了一遍。原来的刷新机制给搞的一塌糊涂,用了一大堆临时变量去保存状态……
姐抽空维护了一下这个玩意
1)增加了一堆\v变换内容
2)去掉了打字声效,win7下调midi格式的se和me伤不起
3)附带按C键或B键跳过打字效果
4)打字效果关掉或改速度是长时生效的
5)部分命令字修改(如\name,全部字母化),说话人姓名支持颜色表记
以后姐有空整合一下fuki吧,看心情,这个对素材要求还是有一些的,当然可以切窗口的角当sprite后angel=45/225来搞……太山寨……
其他看注释,姐不想多说,累……
RUBY 代码
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 显示文章、选择项等信息的窗口。
#==============================================================================
#
# 系统默认控制符:
# \\:显示"\"这个符号
# \c:更改颜色
# \g:显示金钱窗口
# \n:显示1号角色的姓名
# \v:显示7号变量的值
#
# 加强控制符(除非含义不同,否则命令不区分大小写):
# \A:头像及姓名框靠左排列
# \a:头像及姓名框靠右排列
#
# \b:空50象素
#
# \d:空4个字节(2个汉字)的位置
#
# \F:在对话显示头像“Graphics/battlers/66rpg_001_f.png”
# \f:在对话中显示1号角色的头像,没有的话同\F效果
#
# \h:改用12号字
#
# \i:下一行从这个位置开始
#
# \L:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
# \l:在左边显示1号角色的半身像,没有的话同\L效果
# \Lk:清除左边的图像
# 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
#
# \m[李逍遥]:用默认颜色(颜色0)显示一个“李逍遥”方框,表示说话人姓名
# \m2[\n]:用颜色2显示1号主角的姓名方框
#
# \o:文字透明度改为123,模拟将死之人(汗)
#
# 地图画面
# \p[-1]:对话框全屏显示
# \p:本事件上方出现对话框,如果上方空间不够则出现在下方
# \p:主人公上方(或下方)出现对话框
# \p:对话框出现在1号事件的上方(或下方)
# \p[-2]:恢复系统的对话框位置
# 用正数参数使用\p功能时,会自动调整对话框的大小和位置
#
# 战斗画面
# \p[-1]:对话框最小化并居中显示
# \p:我方战斗者上方出现对话框
# \p:敌方战斗者上方出现对话框
# \p[-2]:恢复系统的对话框位置
# 用不是-2的参数使用\p功能时,会自动调整对话框的大小和位置
#
# \R:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
# \r:在右边显示1号角色的半身像,没有的话同\R效果
# \Rk:清除右边的图像
# 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
#
# \s:关闭打字效果
# \s:打字速度设定,越大越慢
#
# \t:显示游戏时间窗口
#
# \u:直接以十六进制指定颜色,注意这里会把透明度重设为255
#
# \v:显示7号变量的值,不足3位的话补零
# \v:显示7号防具的图标和名称
# \v:显示7号职业的名称
# \v:显示7号属性的名称
# \v:显示7号道具的图标和名称
# \v:显示7号地图的名称
# (注:需配合$data_maps加载使用)
# \v:显示7号角色的名称(和\n重复,主要功能在下面)
# \v:显示7号角色的灵巧,参数0-13分别表示等级、EXP、HP、SP、MaxHP、MaxSP
# 力量、灵巧、速度、魔力、攻击、防御、魔防、回避
# \v:显示7号特技的图标和名称
# \v:显示7号状态的名称
# \v:显示7号事件的名称,v0为显示本事件名称
# \v:显示7号武器的图标和名称
#
# \w:等待20帧(1秒)后自动关闭窗口
#
# \x:本行之后文字定位到第20列,已超宽的话忽略
#
# \z:打字到这里时停顿20帧,关闭打字效果的话忽略
#
#==============================================================================
# 如果游戏加密请将以下内容解除注释
# $encrypted = true
# 如果要使用地图名显示功能请将以下内容解除注释
$data_maps = load_data("Data/MapInfos.rxdata")
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化状态
#--------------------------------------------------------------------------
def initialize
super(80, 304, 480, 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 != niland@right_keep == true
@right_picture.dispose
end
if@left_picture != niland@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!(/\\\[(?)(+)[:]?(*)\]/){
convert_value($1, $2.to_i, $3)
}
enduntil text == last_text
# 显示后等待的判定
if(/\\\[(+)\]/.match(text)) != nil
@wait_set = $1.to_i * 2 - 1
text.gsub!(/\\\[(+)\]/){""}
end
# 文字位置的判定
if(/\\\[([-0-9]+)\]/.match(text))!=nilthen
@popchar = $1.to_i
if@popchar == -1andnot$game_temp.in_battle
x = @indent = 48
y = 4
end
text.gsub!(/\\\[([-0-9]+)\]/){""}
if$game_temp.in_battle
if@popchar >= 4
@alignment = true
else
@alignment = false
end
end
elsif(/\\/.match(text))!=nilthen
@popchar = 1000
text.gsub!(/\\/){""}
end
#——对齐设置
if(/\\()/.match(text))!=nilthen
if $1 == "A"
@alignment = true
else
@alignment = false
end
text.gsub!(/\\()/){""}
end
#——头像设置
if(/\\()\[(.+?)\]/.match(text))!=nilthen
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$encryptedorFileTest.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!(/\\()\[(.*?)\]/){""}
end
#——左半身像设置
if(/\\()\[(.+?)\]/.match(text))!=nilthen
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$encryptedorFileTest.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!(/\\()\[(.*?)\]/){""}
end
end
#——右半身像设置
if(/\\()\[(.+?)\]/.match(text))!=nilthen
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$encryptedorFileTest.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!(/\\()\[(.*?)\]/){""}
end
end
if(/\\/.match(text)) != nil
@right_keep = true
text.sub!(/\\k/){""}
end
if(/\\/.match(text)) != nil
@left_keep = true
text.sub!(/\\k/){""}
end
# 替换人物姓名
text.gsub!(/\\\[(+)\]/)do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 显示人物姓名
name_window_set = false
if(/\\(*?)\[(.+?)\]/.match(text)) != nil
name_window_set = true
if $1 == ""
color = 0
else
color = $1.to_i
end
if color >= 0and color = 0or(@popchar == -1and$game_temp.in_battle)
# 浮于事件上方的情况
max_x = 16
# 获得行数
textlines = text.split(/\n/)
cy = max_y = textlines.size
for i in0..max_y - 1
line = plain_text(textlines)
if line == ""
cy -= 1
next
end
cx = contents.text_size(line).width
if i >= $game_temp.choice_startand$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
self.width = max_x + 32 + @face_indent
self.width += 16if$game_temp.choice_start == 0
# 右边有头像的情况宽度再加 128
self.width += 128if@face_bitmap != nilandnot@alignment
max_x += 8if$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 = .maxif@face_bitmap != nil
# 不是浮于事件上方的情况
else
max_x = self.width - 32 - @face_indent
self.height = .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
ifself.y < 20
if@popchar >= 0
self.y += self.height + 48if@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!(/\\\[(+)\]/){"\001[#{$1}]"}
text.gsub!(/\\/){"\002"}
text.gsub!(/\\/){"\003"}
text.gsub!(/\\\[({6})\]/){"\004[#{$1}]"}
text.gsub!(/\\\[(+)\]/){"\005[#{$1}]"}
text.gsub!(/\\\[(+)\]/){"\022[#{$1}]"}
text.gsub!(/\\/){"\023"}
text.gsub!(/\\\[(+)\]/){"\024[#{$1}]"}
text.gsub!(/\\\[(+)\]/){"\025[#{$1}]"}
text.gsub!(/\\\[(+)\]/){"\026[#{$1}]"}
text.gsub!(/\\\[(+)\]/){"\027[#{$1}]"}
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!(/\[(+)\]/, "")
color = $1.to_i
if color >= 0and color = 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!(/\[({2})({2})({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()
end
next
end
if c == "\005"
text.sub!(/\[(+)\]/, "")
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!(/\[(+)\]/, "")
c_wait += $1.to_i
next
end
if c == "\023"
@indent = x
next
end
if c == "\024"
text.sub!(/\[(+)\]/, "")
if@type_speed < 0
self.contents.font.color.alpha = [.max, 255].min
else
color = self.contents.font.color.clone
color.alpha = [.max, 255].min
@text_buffer.push()
end
next
end
if c == "\025"
text.sub!(/\[(+)\]/, "")
self.contents.font.size = [[$1.to_i, 6].max, 32].min
if@type_speed >= 0
@text_buffer.push()
end
next
end
if c == "\026"
text.sub!(/\[(+)\]/, "")
x += $1.to_i
next
end
if c == "\027"
text.sub!(/\[(+)\]/, "")
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 == "\n"
if x == start_x and(@popchar != -2andnot$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_bufferif@text_buffer.size > 0
end
if@type_speed < 0and$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
ifself.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_wait0and$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 == falseand$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
# 没有可以显示的信息、但是窗口为可见的情况下
ifself.visible
@fade_out = true
self.opacity -= 48
ifself.opacity == 0
self.visible = false
@fade_out = false
$game_temp.message_window_showing = false
end
return
end
end
#--------------------------------------------------------------------------
# ● 获得角色
#--------------------------------------------------------------------------
def get_character(parameter)
case parameter
when1000# 本事件
return$game_system.map_interpreter.get_character(0)
when0# 角色
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 = [.max, 640 - self.width].min
self.y = .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 = [.max, 640 - self.width].min
self.y = .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 = [.max, 636 - self.width].min
y = character.screen_y - 48 - self.height
y = character.screen_yif y < 4
y = .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
when0# 上
self.y = 16
when1# 中
self.y = .max
when2# 下
self.y = [.min, 16].max
end
if(@left_picture != nilandnot@left_keep)or
(@right_picture != nilandnot@right_keep)
self.y = [.min, 16].max
end
self.x = 80
if@face_bitmap == nil
self.width = 480
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 == -1andnot$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
ifself.contents.font.size >= 20andself.contents.font.size = 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
case c
when Bitmap
self.contents.blt(rc.x, rc.y, c, c.rect)
when Color
self.contents.font.color = c
whenInteger
self.contents.font.size = c
else
self.contents.draw_text(rc, c)
end
if@text_buffer.size > 0
@type_wait = @text_buffer
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
附件是范例工程。老规矩,姐一般不提供范例工程,避免伸手党,所以收20G意思下,范例中不含配套的半身像和头像素材。
本帖来自P1论坛作者卓越大白痴,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=249914若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]