赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 2015 |
最后登录 | 2017-8-16 |
在线时间 | 13 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 13 小时
- 注册时间
- 2017-4-9
- 帖子
- 19
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#==============================================================================
# [VX] 漫画式对话框
# [VX] ComicStyle Window_message
#----------------------------------------------------------------------------
# 使用说明:
#
# ⑴ 关于对话者 (在地图事件里找到对话者,实现漫画式对话)
# ① 自动抓取对话者名字
# 对于未进行手动填写的,会根据头像的文件名自动抓取对话者名字
# ② 手动指定对话者名字
# 对话框第一行输入引号内文字"名字:",脚本会把名字提取出来美化显示
# 例如"拉尔夫:",显示为"【拉尔夫】" ,美化符可在参数设定中修改
# 可以使用"\n[队伍第几人]:"获得名字
# ③ 允许指定事件(对话者)ID
# ④ 允许暂时停止自动抓取名字
# ⑤ 允许设定跳过自动抓取名字的头像文件
# ⑥ 三种指定对话者的方法可以共存
# 优先级: ③ > ② > ①
# ①和②都必须以对话者名字为地图事件命名
# 事件页无效或暂时消除事件时,③仍然强制指定,即使地图上未显示事件
#
# ⑵ 默认头像在左边显示
# 当您需要右边显示时,在第一行加"\r"(大小写不限,位置不限)
# 例: "拉尔夫\r:" 请注意此时头像显示为水平翻转
#
# ⑶ 对话框动态显示功能,但缩放Sprite较消耗系统资源
#
# ⑷ 使用自定义皮肤, 图片文件保存于Graphics\System内
# 配置文件保存于游戏文件夹内(Skin.ini)
#
#
# ⑸ 在对话中更改字体:
# \f[sX]:更改字号为X
# \f[nX]:更改字体为X
# 更改字体失败(找不到字体)时,启用默认字体
# \f[cX]:更改字色为第X号颜色(text_color中的定义)
#
# ⑹ 在对话中显示(技能 物品 武器 防具)图标和名称:
# \s[X]: 显示第X号技能图标和名称
# \i[X]: 显示第X号物品图标和名称
# \w[X]: 显示第X号武器图标和名称
# \a[X]: 显示第X号防具图标和名称
#
# ⑺ 在对话中更改文字不透明度:
# \o[X]: 把文字不透明度更改为X (取值范围在0~255)
#
# ⑻ 在对话中指定时间后自动关闭对话框:
# \x[X]: 对话框将在X帧后自动关闭
# \x: 省略参数时,将于默认帧数后自动关闭(默认值在参数设定中)
#
# ⑼ 在对话中调整文字显示速度:
# \p[X]: 文字在X帧后显示
#
# ⑽ 指定对话框在人物上方或下方(仅下一段文章有效):
# 在对话前用"事件脚本"输入: ComicStyle "对话框在上"
# 或: ComicStyle "对话框在下"
#
# ⑾ 禁用漫画式对话(仅下一段文章有效):
# 在对话前用"事件脚本"输入: ComicStyle "禁用漫画式"
#
# ⑿ 停止自动抓取名字(仅下一段文章有效):
# 在对话前用"事件脚本"输入: ComicStyle "禁用自动名字"
#
# ⒀ 指定事件(对话者)ID(仅下一段文章有效):
# 在对话前用"事件脚本"输入: ComicStyle "指定事件[ID号]"
# 主角ID号已设定为 0
#
# ⒁ 指定新的皮肤:
# 在对话前用"事件脚本"输入: ComicStyle "换皮肤[新的皮肤名]"
#
# ⒂ 指定背景不透明度:
# 在对话前用"事件脚本"输入: ComicStyle "背景不透明度[0-255]"
#
# ⒃ 输入文章时设定冻结字符和注释字符:
# #[XX]: 字符串XX被冻结,不受转义等影响直接显示
# 此功能可用于第一行显示冒号而不会被脚本误识别为对话者名字
# #<XX>: 字符串XX被当作注释,游戏运行时不会出现
#------------------------------------------------------------------------------
# 素材规格:
#
# ⑴ 采用vx默认头像素材(Graphics\Faces)的格式
# 即每个素材文件由2行4列共8格头像组成
#
# ⑵ 所有头像朝向一致,默认是正面偏右
#
# ⑶ 自定义皮肤有两个必须文件:
# ① 皮肤图片(Graphics\System),规格请看范例所附图片说明
# ② 配置文件,统一保存在游戏目录下,命名为Skin.ini,每个皮肤以自身
# [皮肤图片文件名](包含[])开头,详见范例使用的Skin.ini
#----------------------------------------------------------------------------
# 更新作者: 沉影不器
# 许可协议: FSL
# 项目版本: 2.00.1213
# 引用网址: http://rpg.blue/thread-86073-1-1.html
#----------------------------------------------------------------------------
# - *2.1.1213* (2011-12-13) By 沉影不器
# *新增 切换对话框模式(漫画式 \ 普通模式)
# *新增 对话框最小宽度和最小高度
# *新增 手动指定对话者名字
# *新增 允许首行名字被冻结或被注释
# *新增 对话者名字启用\n[X]
# *删简 删除对冒号的补偿转义
#
# - *2.0.0213* (2011-02-13) By 沉影不器
# *优化 全部代码重写
# *优化 自动提取对话者名字功能
# *优化 两次字符串转义处理合并为一次
# *优化 改进窗体大小计算,增加行高逐行计算
# *修改 头像在右的控制符改为"\r"(大小写不限)
# *新增 自定义对话框皮肤
# *新增 自定义对话框暂停标记
# *新增 对话框皮肤不透明度
# *新增 对话者名字自动美化
# *新增 对话中修改字体名称、字号和透明度,失败时使用默认字体
# *新增 显示数据库各种图标及名称
# *新增 允许不受转义影响的字符串
# *新增 对话中播放动画和心情
# *新增 自动关闭对话框
#
# - *1.1.0517* (2008-05-17) By 沉影不器
# *修复 消除数值输入影响头像坐标
# *修复 头像微调错位
# *新增 附加功能2项
# *新增 游戏中更改对话框设定多项
# *优化 对话框箭头图标上下独立
# *优化 无意义的代码
#
# - *1.0.0510* (2008-05-10) By 沉影不器
# *初版
#==============================================================================
$fscript = {} if $fscript == nil
$fscript["ComicStyle_Window_message"] = "2.1.1213"
#----------------------------------------------------------------------------
# ▼ 通用配置模块
#----------------------------------------------------------------------------
module FSL
module ComicStyle_Window_message
## 全局
FastShow = true ## 是否确定键快速显示文字
Actional = true ## 是否动态显示对话框
AutoClose = 80 ## 默认自动关闭时间(单位:帧)
TypeDelay = 0 ## 改变全局打字延时(单位:帧)
LineSpace = 2 ## 文字的行间距
SkipName = [] ## 跳过自动抓取名字的头像文件
## 窗体
Window_MinWidth = 96 ## 对话框最小宽度
Window_MinHeight = 24 ## 对话框最小高度
Window_DefWidth = 0 ## 对话框默认宽度(非漫画式时)
Window_DefHeight = 0 ## 对话框默认高度(非漫画式时)
Window_MaxLine = 5 ## 对话框最大行数
## 自定义暂停标记
Pause_Custom = 3 ## 位置(0:禁用 1:底边居中 2:右下角 3:跟随文字)
Pause_AniDelay = 8 ## 动画帧间隔(影响动画速度,单位:帧)
## 皮肤
Skin_Name = "Default" ## 对话框皮肤文件名
Skin_Opacity = 200 ## 皮肤的不透明度
end
end
#==============================================================================
# □ INI
#==============================================================================
module FSL
module ComicStyle_Window_message
module_function
#--------------------------------------------------------------------------
# ○ 常量
#--------------------------------------------------------------------------
RdINI = Win32API.new("kernel32","GetPrivateProfileStringA","pppplp","l")
WtINI = Win32API.new("kernel32","WritePrivateProfileStringA","pppp","l")
M2W = Win32API.new("kernel32","MultiByteToWideChar","ilpipi","l")
W2M = Win32API.new("kernel32","WideCharToMultiByte","ilpipipp","l")
#--------------------------------------------------------------------------
# ○ 读取配置
#--------------------------------------------------------------------------
def readini(app_name, key_name)
buff = "\0" * 256
RdINI.call(app_name,key_name,"",buff,buff.size,"./Skin.ini")
buff.delete!("\0")
return a2u(buff)
end
#--------------------------------------------------------------------------
# ○ 保存配置
#--------------------------------------------------------------------------
def writeini(app_name, key_name, value)
WtINI.call(app_name,key_name,u2a(value),"./Skin.ini")
end
#--------------------------------------------------------------------------
# ○ ASCII转UTF8
#--------------------------------------------------------------------------
def a2u(str)
len = M2W.call(0,0,str,-1,nil,0)
buf = "\0" * (len*2)
M2W.call(0,0,str,-1,buf,buf.size/2)
len = W2M.call(0xFDE9,0,buf,-1,nil,0,nil,nil)
ret = "\0" * len
W2M.call(0xFDE9,0,buf,-1,ret,ret.size,nil,nil)
return ret.delete!("\0")
end
#--------------------------------------------------------------------------
# ○ UTF8转ASCII
#--------------------------------------------------------------------------
def u2a(str)
len = M2W.call(0xFDE9,0,str,-1,nil,0)
buf = "\0" * (len*2)
M2W.call(0xFDE9,0,str,-1,buf,buf.size/2)
len = W2M.call(0,0,buf,-1,nil,0,nil,nil)
ret = "\0" * len
W2M.call(0,0,buf,-1,ret,ret.size,nil,nil)
return ret.delete!("\0")
end
end
end
#==============================================================================
# ■ Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ○ 平铺
#--------------------------------------------------------------------------
def tile(dest_rect, src_bitmap, src_rect, opacity = 255)
m = dest_rect.width / src_rect.width
n = dest_rect.height / src_rect.height
m += 1 if dest_rect.width % src_rect.width > 0
n += 1 if dest_rect.height % src_rect.height > 0
buf = Bitmap.new(dest_rect.width, dest_rect.height)
for i in 0...m
x = src_rect.width * i
for j in 0...n
y = src_rect.height * j
buf.blt(x, y, src_bitmap, src_rect)
end
end
src_rect = Rect.new(0, 0, dest_rect.width, dest_rect.height)
self.blt(dest_rect.x, dest_rect.y, buf, src_rect, opacity)
buf.dispose
end
end
#==============================================================================
# ■ Game_Message
#==============================================================================
class Game_Message
include FSL::ComicStyle_Window_message
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
## 标题
attr_accessor :title_symbol ## 为名字添加的修饰符(一对)
attr_accessor :title_spaceh ## 名字与对话内容之间的附加距离
attr_accessor :title_fontname ## 名字使用的字体
attr_accessor :title_fontsize ## 名字使用的字号
attr_accessor :title_fontcolor ## 名字使用的字体颜色
## 内容
attr_accessor :content_fontname ## 对话内容使用的字体
attr_accessor :content_fontsize ## 对话内容使用的字号
attr_accessor :content_fontcolor ## 对话内容使用的字体颜色
## 头像
attr_accessor :face_type ## 头像制式(0:小头像 1:半身像)
attr_accessor :face_indentx ## 头像横坐标微调
attr_accessor :face_indenty ## 头像纵坐标微调
attr_accessor :face_reserved ## 头像的保留空间(与对话文字的保留间隔)
## 皮肤
attr_accessor :skin_pauseframe ## 暂停标记的动画帧数(1-5)
attr_accessor :skin_pausex ## 暂停标记的x坐标微调
attr_accessor :skin_pausey ## 暂停标记的y坐标微调
attr_accessor :skin_indent ## 对话框内缩(用于减小框与文字的边距)
attr_accessor :skin_namegauge ## 增加名字条和上边框的间距
attr_accessor :skin_adjarrow ## 漫画式箭头横向偏移值
attr_accessor :skin_adjtx ## 名字背景条横向偏移值
attr_accessor :skin_adjty ## 名字背景条纵向偏移值
attr_accessor :skin_et ## 名字背景条高度加成值
attr_accessor :skin_it ## 名字背景条横向内缩值
attr_accessor :skin_ib ## 皮肤背景内缩值
## 请参考vx帮助文件-素材规格-窗口皮肤
#--------------------------------------------------------------------------
# ○ 设定参数
#--------------------------------------------------------------------------
def set_arg(app_name)
@title_symbol = readini(app_name, "Title_Symbol")
@title_spaceh = readini(app_name, "Title_SpaceH").to_i
@title_fontname = readini(app_name, "Title_FontName")
@title_fontsize = readini(app_name, "Title_FontSize").to_i
@title_fontcolor = readini(app_name, "Title_FontColor").to_i
@content_fontname = readini(app_name, "Content_FontName")
@content_fontsize = readini(app_name, "Content_FontSize").to_i
@content_fontcolor = readini(app_name, "Content_FontColor").to_i
@face_type = readini(app_name, "Face_Type").to_i
@face_indentx = readini(app_name, "Face_IndentX").to_i
@face_indenty = readini(app_name, "Face_IndentY").to_i
@face_reserved = readini(app_name, "Face_Reserved").to_i
@skin_pauseframe = readini(app_name, "Skin_PauseFrame").to_i
@skin_pausex = readini(app_name, "Skin_PauseX").to_i
@skin_pausey = readini(app_name, "Skin_PauseY").to_i
@skin_indent = readini(app_name, "Skin_Indent").to_i
@skin_namegauge = readini(app_name, "Skin_NameGauge").to_i
@skin_adjarrow = readini(app_name, "Skin_AdjArrow").to_i
@skin_adjtx = readini(app_name, "Skin_AdjTx").to_i
@skin_adjty = readini(app_name, "Skin_AdjTy").to_i
@skin_et = readini(app_name, "Skin_ET").to_i
@skin_it = readini(app_name, "Skin_IT").to_i
@skin_ib = readini(app_name, "Skin_IB").to_i
end
end
#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event < Game_Character
attr_reader :erased ## 被擦除
attr_reader :page ## 事件页
#--------------------------------------------------------------------------
# ○ 获取名称
#--------------------------------------------------------------------------
def name
return @event.name
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ○ 漫画式开关
#--------------------------------------------------------------------------
def ComicStyle(str)
msg_win = $scene.instance_variable_get :@message_window
## 直接匹配
msg_win.instance_variable_set :@fix_type, 2 if str =~ /对话框在上/
msg_win.instance_variable_set :@fix_type, 8 if str =~ /对话框在下/
msg_win.instance_variable_set :@comic_style, false if str =~ /禁用漫画式/
msg_win.instance_variable_set :@auto_name, false if str =~ /禁用自动名字/
## 待解释
str.sub(/换皮肤\[(\S+)\]/) {"#{$1}"}
msg_win.set_skin($1) if $1
str.sub(/指定事件\[(\d+)\]/) {"#{$1}"}
msg_win.instance_variable_set :@target_id, $1.to_i if $1
str.sub(/背景不透明度\[(\d+)\]/) {"#{$1}"}
msg_win.instance_variable_set :@skin_opacity, $1.to_i if $1
end
end
#==============================================================================
# ■ Sprite_Character
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ◎ 开始显示心情图标
#--------------------------------------------------------------------------
def start_balloon
dispose_balloon
@balloon_duration = 8 * 8 + BALLOON_WAIT
@balloon_sprite = ::Sprite.new##(viewport)
@balloon_sprite.bitmap = Cache.system("Balloon")
@balloon_sprite.ox = 16
@balloon_sprite.oy = 32
update_balloon
end
end
#==============================================================================
# □ Spriteset_Skin
#==============================================================================
class Spriteset_Skin
include FSL::ComicStyle_Window_message
#--------------------------------------------------------------------------
# ○ 实例变量
#--------------------------------------------------------------------------
attr_reader :type ## 指定上箭头或下箭头
#--------------------------------------------------------------------------
# ○ 初始化
#--------------------------------------------------------------------------
def initialize(filename, width, height, type = 2)
@type =type
@bitmap = Cache.system(filename)
@main_sprite = Sprite.new
@main_sprite.bitmap = Bitmap.new(width, height + 32)
draw_skin(width, height + 32)
if Actional
@main_sprite.zoom_x = @main_sprite.zoom_y = 0
self.visible = false
else
@main_sprite.zoom_x = @main_sprite.zoom_y = 1
self.visible = true
end
end
#--------------------------------------------------------------------------
# ○ 释放
#--------------------------------------------------------------------------
def dispose
@main_sprite.bitmap.dispose
@main_sprite.dispose
@sprite_2.bitmap.dispose
@sprite_8.bitmap.dispose
@sprite_2.dispose
@sprite_8.dispose
end
#--------------------------------------------------------------------------
# ○ 宽度
#--------------------------------------------------------------------------
def width
return @main_sprite.bitmap.width
end
#--------------------------------------------------------------------------
# ○ 高度
#--------------------------------------------------------------------------
def height
return @main_sprite.bitmap.height
end
#--------------------------------------------------------------------------
# ○ X原点
#--------------------------------------------------------------------------
def ox
return @main_sprite.ox
end
#--------------------------------------------------------------------------
# ○ Y原点
#--------------------------------------------------------------------------
def oy
return @main_sprite.oy
end
#--------------------------------------------------------------------------
# ○ X坐标
#--------------------------------------------------------------------------
def x
return @main_sprite.x
end
#--------------------------------------------------------------------------
# ○ Y坐标
#--------------------------------------------------------------------------
def y
return @main_sprite.y
end
#--------------------------------------------------------------------------
# ○ Z坐标
#--------------------------------------------------------------------------
def z
return @main_sprite.z
end
#--------------------------------------------------------------------------
# ○ 修改X坐标
#--------------------------------------------------------------------------
def x=(val)
@main_sprite.x = val
@sprite_2.x = val - @main_sprite.ox + 16
@sprite_8.x = val - @main_sprite.ox + 16
end
#--------------------------------------------------------------------------
# ○ 修改Y坐标
#--------------------------------------------------------------------------
def y=(val)
@main_sprite.y = val
@sprite_2.y = val - @main_sprite.oy + @main_sprite.height - 32
@sprite_8.y = val - @main_sprite.oy
end
#--------------------------------------------------------------------------
# ○ 修改Z坐标
#--------------------------------------------------------------------------
def z=(val)
@main_sprite.z = val
@sprite_2.z = val + 1
@sprite_8.z = val + 1
end
#--------------------------------------------------------------------------
# ○ 修改可视性
#--------------------------------------------------------------------------
def visible=(val)
@main_sprite.visible = val
@sprite_2.visible = val
@sprite_8.visible = val
end
#--------------------------------------------------------------------------
# ○ 更改类型
#--------------------------------------------------------------------------
def type=(val)
if @type != val
@type = val
@sprite_8.src_rect.x,@sprite_2.src_rect.x =
@sprite_2.src_rect.x,@sprite_8.src_rect.x
end
end
#--------------------------------------------------------------------------
# ○ 修改不透明度
#--------------------------------------------------------------------------
def opacity=(val)
@main_sprite.opacity = val
@sprite_2.opacity = val
@sprite_8.opacity = val
end
#--------------------------------------------------------------------------
# ○ 显示标题
#--------------------------------------------------------------------------
def draw_title(height)
x = $game_message.skin_it + $game_message.skin_adjtx
y = $game_message.skin_adjty + 32 - $game_message.skin_indent + $game_message.skin_namegauge
width = @main_sprite.width - $game_message.skin_it*2
dst_rect = Rect.new(x, y, width, height + $game_message.skin_et)
src_rect = Rect.new(96,80,24,32)
@main_sprite.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
dst_rect = Rect.new(x, y, width, height + $game_message.skin_et)
src_rect = Rect.new(120,80,24,32)
@main_sprite.bitmap.tile(dst_rect, @bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ○ 描绘底面
#--------------------------------------------------------------------------
def draw_skin(width, height)
## 背景
dst_rect = Rect.new($game_message.skin_ib,$game_message.skin_ib+16,width-$game_message.skin_ib*2,height-$game_message.skin_ib*2-32)
src_rect = Rect.new(0,0,64,64)
@main_sprite.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
src_rect = Rect.new(0,64,64,64)
@main_sprite.bitmap.tile(dst_rect, @bitmap, src_rect)
## 四角
src_rect = Rect.new(64,16,16,16)
@main_sprite.bitmap.blt(0, 16, @bitmap, src_rect)
src_rect = Rect.new(128,16,16,16)
@main_sprite.bitmap.blt(width-16, 16, @bitmap, src_rect)
src_rect = Rect.new(64,48,16,16)
@main_sprite.bitmap.blt(0, height-32, @bitmap, src_rect)
src_rect = Rect.new(128,48,16,16)
@main_sprite.bitmap.blt(width-16, height-32, @bitmap, src_rect)
## 左右边框
dst_rect=Rect.new(0,32,16,height-64)
src_rect=Rect.new(64,32,16,16)
@main_sprite.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
dst_rect=Rect.new(width-16,32,16,height-64)
src_rect=Rect.new(128,32,16,16)
@main_sprite.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
## 箭头(上下框)
draw_arrow(width-32, height)
end
#--------------------------------------------------------------------------
# ○ 描绘箭头
#--------------------------------------------------------------------------
def draw_arrow(width, height)
@sprite_2 = Sprite.new
@sprite_8 = Sprite.new
@sprite_2.bitmap = Bitmap.new(width*2+16, 32)
@sprite_8.bitmap = Bitmap.new(width*2+16, 32)
##2
dst_rect=Rect.new(0, 0, width, 32)
src_rect=Rect.new(80,48,16,32)
@sprite_2.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
dst_rect=Rect.new(width+16,0,width, 32)
src_rect=Rect.new(112,48,16,32)
@sprite_2.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
src_rect=Rect.new(96,48,16,32)
@sprite_2.bitmap.blt(width, 0, @bitmap, src_rect)
## 8
dst_rect=Rect.new(0, 0, width, 32)
src_rect=Rect.new(80,0,16,32)
@sprite_8.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
dst_rect=Rect.new(width+16,0,width, 32)
src_rect=Rect.new(112,0,16,32)
@sprite_8.bitmap.stretch_blt(dst_rect, @bitmap, src_rect)
src_rect=Rect.new(96,0,16,32)
@sprite_8.bitmap.blt(width, 0, @bitmap, src_rect)
## 位图区域
@sprite_2.src_rect = @sprite_8.src_rect = Rect.new(0,0,width,32)
end
#--------------------------------------------------------------------------
# ○ 移动箭头
#--------------------------------------------------------------------------
def slide(val)
## 微调 + 箭头宽度/2
val += $game_message.skin_adjarrow + 8
val = [@main_sprite.width-32, [@main_sprite.width-val, 16].max].min
@sprite_2.src_rect.x = val if @type == 2
@sprite_8.src_rect.x = val if @type == 8
end
#--------------------------------------------------------------------------
# ○ 动作
#--------------------------------------------------------------------------
def action(openness)
case @type
when 2
@main_sprite.ox = width - @sprite_2.src_rect.x - 8
@main_sprite.oy = @main_sprite.height - 16
when 8
@main_sprite.ox = width - @sprite_8.src_rect.x - 8
@main_sprite.oy = 16
when nil
@main_sprite.ox = @main_sprite.width / 2
@main_sprite.oy = @main_sprite.height / 2
end
zoom = openness / 255.0
@main_sprite.zoom_x = zoom
@main_sprite.zoom_y = zoom
if openness == 255
self.visible = true
## 还原
if @backup
@main_sprite.bitmap.clear_rect(16, 0, width-32, 32)
@main_sprite.bitmap.clear_rect(16, height-32, width-32, 32)
@main_sprite.bitmap.blt(16, 0, @backup, Rect.new(0,0,width-32,32))
@main_sprite.bitmap.blt(16, height-32, @backup, Rect.new(0,32,width-32,32))
@backup.dispose
end
else
@main_sprite.visible = true
@sprite_2.visible = @sprite_8.visible = false
## 临时描绘
unless @backup
@backup = Bitmap.new(width-32,64)
r = Rect.new(16, 0, width-32, 32)
@backup.blt(0, 0, @main_sprite.bitmap, r)
r = Rect.new(16, height-32, width-32, 32)
@backup.blt(0, 32, @main_sprite.bitmap, r)
@main_sprite.bitmap.blt(16, 0, @sprite_8.bitmap, @sprite_8.src_rect)
@main_sprite.bitmap.blt(16, height-32, @sprite_2.bitmap, @sprite_2.src_rect)
end
end
end
end
#==============================================================================
# ■ Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# ◎ 更新画面
#--------------------------------------------------------------------------
alias selectable_update update
end
#==============================================================================
# ■ Window_NumberInput
#==============================================================================
class Window_NumberInput < Window_Base
include FSL::ComicStyle_Window_message
#--------------------------------------------------------------------------
# ◎ 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
s = sprintf("%0*d", @digits_max, @number)
h = self.contents.font.size + LineSpace
for i in 0...@digits_max
self.contents.draw_text(24 + i * h, 0, h, h, s[i,1], 1)
end
end
#--------------------------------------------------------------------------
# ◎ 更新光标
#--------------------------------------------------------------------------
def update_cursor
h = self.contents.font.size + LineSpace
self.cursor_rect.set(24 + @index * h, 0, h, h)
end
end
#==============================================================================
# □ Window_ComicStyle
#==============================================================================
class Window_ComicStyle < Window_Message
include FSL::ComicStyle_Window_message
#--------------------------------------------------------------------------
# ◎ 初始化对象
#--------------------------------------------------------------------------
def initialize
super
self.opacity = 0
## 冻结字符池
@frozen_char = []
## 头像右判断
@show_right = false
## 指定上下型
@fix_type = 0
## 自定义暂停标记
@custom_pause = false
## 本行最大高度
@line_maxh = []
## 漫画式标志
@comic_style = true
## 手动输入名字
@auto_name = true
## 指定事件ID
@target_id = nil
## 设定系统窗体的皮肤
set_skin(Skin_Name)
## 修改默认字体
contents.font = default_font
## 皮肤不透明度
@skin_opacity = Skin_Opacity
## 生成头像
create_face_sprite
end
#--------------------------------------------------------------------------
# ○ 设定皮肤
#--------------------------------------------------------------------------
def set_skin(skin_name)
## 名字
@skin_name = skin_name
## 参数
$game_message.set_arg(skin_name)
## 选择框
src_bitmap = Cache.system @skin_name
src_rect = Rect.new(64, 80, 32, 32)
new_skin = self.windowskin.clone
new_skin.blt(64, 64, src_bitmap, src_rect)
@number_input_window.windowskin = self.windowskin = new_skin
## 字体
@number_input_window.contents.font = @gold_window.contents.font = default_font
## 暂停标记
create_pause_sprite
end
#--------------------------------------------------------------------------
# ◎ 更新画面
#--------------------------------------------------------------------------
def update
selectable_update
update_gold_window
update_number_input_window
update_back_sprite
update_show_fast
## 更新自定义暂停标记
update_pause_sprite
unless @opening or @closing # 除窗体关闭以外
if @wait_count > 0 # 文章内等待中
@wait_count -= 1
elsif @custom_pause # 等待文章翻页待机中
input_pause
elsif self.active ## 正在输入选择项
input_choice
elsif @number_input_window.visible # 正在输入数值
input_number
elsif @text != nil # 还有剩余的文章
update_message # 更新消息
elsif continue? # 继续的情况
start_message # 开始消息
## 更新窗体坐标
update_window_pos
open # 打开窗体
$game_message.visible = true
else # 不继续的情况
close # 关闭窗体
$game_message.visible = @closing
end
## 更新窗体坐标
update_window_pos
end
## 自动关闭对话框
if @auto_close != nil
if @auto_close > 0
@auto_close -= 1
else
terminate_message
end
end
end
#--------------------------------------------------------------------------
# ◎ 更新快速显示标志
#--------------------------------------------------------------------------
def update_show_fast
if @custom_pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C)
if FastShow ## 快速显示文字
@show_fast = true
@wait_count = 0
end
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# ◎ 开始显示消息
#--------------------------------------------------------------------------
def start_message
@text = ""
## 回避无文章的情况
unless $game_message.texts.empty?
## 暂存消息
tmp_texts = []
$game_message.texts.each{|text| tmp_texts.push text.clone}
## 特定字符预处理
tmp_texts[0].gsub!(/#\[(.*?)\]/) { @frozen_char.push($1); "\xff" }
tmp_texts[0].gsub!(/#\<(.*?)\>/) { "" }
tmp_texts[0].gsub!(/\\N\[(\d+)\]/i){ $game_actors[$1.to_i].name }
## 判断头像朝向
@show_right = tmp_texts[0].sub!(/\\R/i){""} != nil
## 处理名字
if tmp_texts[0].sub!(/[::]/){""}
## 手动输入
unless tmp_texts[0].sub("\xff\]"){""}.empty?
@name = tmp_texts[0].clone
end
end
if @auto_name and show_face? and @name.nil?
## 自动抓取
unless SkipName.include? $game_message.face_name
@name = $game_message.face_name
tmp_texts.unshift @name
$game_message.choice_start += 1
end
end
## 名字美化
if show_name?
## 去冒号加修饰符(可选)
unless $game_message.title_symbol.empty?
size = $game_message.title_symbol.size/2
tmp_texts[0] = $game_message.title_symbol[0, size] +
tmp_texts[0] + $game_message.title_symbol[size, size]
end
## 设定文字颜色
tmp_texts[0] = "\\C[#{$game_message.title_fontcolor}]" +
tmp_texts[0] + "\\C[#{$game_message.content_fontcolor}]"
## 设定文字字体
tmp_texts[0] = "\\F[N#{$game_message.title_fontname}]" +
tmp_texts[0] + "\\F[N#{$game_message.content_fontname}]"
## 设定文字大小
tmp_texts[0] = "\\F[S#{$game_message.title_fontsize}]" +
tmp_texts[0] + "\\F[S#{$game_message.content_fontsize}]"
## 内容缩进
for i in 1...tmp_texts.size
tmp_texts = " " + tmp_texts
end
end
for i in 0...tmp_texts.size
@text += " " if i >= $game_message.choice_start
@text += tmp_texts.clone + "\x00"
end
end
@item_max = $game_message.choice_max
get_target
convert_special_characters
new_page #条件:@show_right
## 重设窗体背景与位置
reset_window(*get_window_size) #条件:@text @name
end
#--------------------------------------------------------------------------
# ◎ 更换页面处理
#--------------------------------------------------------------------------
def new_page
contents.clear
## 初始化文字描绘起点
@contents_x = 0
if show_face?
refresh_face_sprite
## 计算文字横坐标起始
@contents_x += face_width + $game_message.face_reserved unless @show_right
else
@face_sprite.bitmap.clear
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
end
#--------------------------------------------------------------------------
# ◎ 换行处理
#--------------------------------------------------------------------------
def new_line
## 提前处理自定义暂停标记
set_pause_sprite_pos
@contents_x = 0
if show_face? and !@show_right
@contents_x = face_width + $game_message.face_reserved
end
@contents_y += @line_maxh[@line_count]
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# ◎ 特殊文字变换
#--------------------------------------------------------------------------
def convert_special_characters
## 特定字符处理
@text.gsub!(/#\[(.*?)\]/) {@frozen_char.push($1); "\xff"}
@text.gsub!(/#\<(.*?)\>/) {""}
## 更改不透明度
@text.gsub!(/\\O\[(\d+)\]/i) {"\x09[#{$1}]"}
## 显示数据库元素
@text.gsub!(/\\S\[(\d+)\]/i) {"\x0a[#{$1}]" + $data_skills[$1.to_i].name}
@text.gsub!(/\\I\[(\d+)\]/i) {"\x0b[#{$1}]" + $data_items[$1.to_i].name}
@text.gsub!(/\\W\[(\d+)\]/i) {"\x0c[#{$1}]" + $data_weapons[$1.to_i].name}
@text.gsub!(/\\A\[(\d+)\]/i) {"\x0d[#{$1}]" + $data_armors[$1.to_i].name}
## 更改字体
@text.gsub!(/\\F\[S(\d+)\]/i){"\x0e[#{$1}]"}
@text.gsub!(/\\F\[N(.+?)\]/i){"\x0f[#{$1}]"}
@text.gsub!(/\\F\[C(\d+)\]/i){"\x01[#{$1}]"}
## 字速控制
@text.gsub!(/\\P\[(\d+)\]/i) {"\x10[#{$1}]"}
## 自动关闭
@text.gsub!(/\\X\[(\d+)\]/i) {"\x11[#{$1}]"}
@text.gsub!(/\\X/i) {"\x12"}
## 提取动画对象和 ID
@text.gsub!(/\\A\[(\S+)\,(\d+)\]/i) {"\x13[#{$1},#{$2}]"}
@text.gsub!(/\\B\[(\S+)\,(\d+)\]/i) {"\x14[#{$1},#{$2}]"}
super
end
#--------------------------------------------------------------------------
# ◎ 设置窗体背景与位置
#--------------------------------------------------------------------------
def reset_window(width = nil, height = nil)
unless width.nil? || height.nil?
self.width = width
self.height = height
font = self.contents.font.clone
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
## 修改默认字体
contents.font = font
## 坐标
if comic_style?
if @target.x < visual_width / 2
self.x = -$game_message.skin_indent
elsif @target.x > Graphics.width - visual_width / 2
self.x = Graphics.width - visual_width - $game_message.skin_indent
else
self.x = @target.x - visual_width / 2
end
if @target.y < visual_height
self.y = @target.y - $game_message.skin_indent
type = 8
else
self.y = @target.y - @target.height - self.height + $game_message.skin_indent
type = 2
end
## 修复名字条预留
self.y += $game_message.skin_namegauge if show_name? and type == 8
else
self.x = (Graphics.width - self.width) / 2
case $game_message.position
when 0 # 上
self.y = visual_height-self.height
@gold_window.y = 360
when 1 # 中
self.y = (Graphics.height - self.height) / 2
@gold_window.y = 0
when 2 # 下
self.y = $game_message.skin_indent + Graphics.height - self.height
@gold_window.y = 0
end
end
## 皮肤
create_skin_sprite(width, height, type)
@skin_sprite.draw_title(self.contents.font.size) if show_name?
@skin_sprite.x = self.x + $game_message.skin_indent + @skin_sprite.ox
@skin_sprite.y = self.y + $game_message.skin_indent - 16 + @skin_sprite.oy
@skin_sprite.y -= $game_message.skin_namegauge if show_name?
@skin_sprite.opacity = @skin_opacity
end
end
#--------------------------------------------------------------------------
# ○ 更新窗体坐标
#--------------------------------------------------------------------------
def update_window_pos
return unless self.openness == 255 or Actional
return unless comic_style?
return unless @skin_sprite
## 超出屏幕时
unless within_screen_range?(@target)
self.x = (Graphics.width - self.width) / 2
case $game_message.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 = $game_message.skin_indent + Graphics.height - self.height
@gold_window.y = 0
end
## 取消箭头
@skin_sprite.slide(0)
return
end
## 指定上下型
@skin_sprite.type = @fix_type if @fix_type != 0
## 处理X
if @target.x < visual_width / 2
self.x = -$game_message.skin_indent
elsif @target.x > Graphics.width - visual_width / 2
self.x = Graphics.width - visual_width - $game_message.skin_indent
else
self.x = @target.x - visual_width / 2
end
## 处理Y
case @skin_sprite.type
when 2
if @target.y < visual_height + @target.height
self.y = @target.y - $game_message.skin_indent
type = 8
else
self.y = @target.y - @target.height - self.height + $game_message.skin_indent
end
when 8
if @target.y < visual_height
self.y = @target.y - $game_message.skin_indent
elsif @target.y > Graphics.height - self.height - $game_message.skin_indent
self.y = @target.y - @target.height - self.height + $game_message.skin_indent
type = 2
else
self.y = @target.y - $game_message.skin_indent
end
end
## 修改上下型
@skin_sprite.type = type if @skin_sprite and type
## 修复名字条预留
self.y += $game_message.skin_namegauge if show_name? and @skin_sprite.type == 8
## 皮肤箭头
val = @target.x - self.x - $game_message.skin_indent
if @skin_sprite
@skin_sprite.slide(val)
@skin_sprite.x = self.x + $game_message.skin_indent + @skin_sprite.ox
@skin_sprite.y = self.y + $game_message.skin_indent - 16 + @skin_sprite.oy
@skin_sprite.y -= $game_message.skin_namegauge if show_name?
end
## 金钱窗体
@gold_window.y = self.y > @gold_window.height ? 0 : 360
end
#--------------------------------------------------------------------------
# ◎ 消息结束
#--------------------------------------------------------------------------
def terminate_message
@fix_type = 0
@custom_pause = false
@auto_close = nil
@name = nil
@face_sprite.visible = false if @face_sprite
@skin_sprite.dispose
@skin_sprite = nil
@comic_style = true
@auto_name = true
@target_id = nil
super
close
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
@custom_pause = true
end
@wait_count = 10
@text = nil
@speed = nil
end
#--------------------------------------------------------------------------
# ◎ 更新消息
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # 获取下一条文字
case c
when nil # 没有可以显示的文字
finish_message # 更新结束
break
when "\x00" # 换行
new_line
if @line_count >= Window_MaxLine# 行数为最大时
unless @text.empty? # 如果还有增加则继续
## 暂停
@custom_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" # \! (等待输入)
@custom_pause = true
break
when "\x06" # \> (瞬间显示 ON)
@line_show_fast = true
when "\x07" # \< (瞬间显示 OFF)
@line_show_fast = false
when "\x08" # \^ (不等待输入)
@pause_skip = true
## 更改不透明度的情况下
when "\x09"
@text.sub!(/\[(\d+)\]/, "")
contents.font.color.alpha = $1.to_i
## 显示技能情况下
when "\x0a"
@text.sub!(/\[(\d+)\]/, "")
draw_icon($data_skills[$1.to_i].icon_index, @contents_x, @contents_y)
## 横坐标增加图标宽度
@contents_x += 24
## 显示物品情况下
when "\x0b"
@text.sub!(/\[(\d+)\]/, "")
draw_icon($data_items[$1.to_i].icon_index, @contents_x, @contents_y)
## 横坐标增加图标宽度
@contents_x += 24
## 显示武器情况下
when "\x0c"
@text.sub!(/\[(\d+)\]/, "")
draw_icon($data_weapons[$1.to_i].icon_index, @contents_x, @contents_y)
## 横坐标增加图标宽度
@contents_x += 24
## 显示防具情况下
when "\x0d"
@text.sub!(/\[(\d+)\]/, "")
draw_icon($data_armors[$1.to_i].icon_index, @contents_x, @contents_y)
## 横坐标增加图标宽度
@contents_x += 24
## 更改字体的情况下
when "\x0e"
@text.sub!(/\[(\d+)\]/, "")
contents.font.size = $1.to_i
when "\x0f"
@text.sub!(/\[(.+?)\]/, "")
contents.font.name = Font.exist?($1) ? $1 : Font.default_name
## \P[n] (字速)
when "\x10"
@text.sub!(/\[(\d+)\]/, "")
## 获取字体显示速度
@speed = $1.to_i
## 自动关闭对话框的情况下
when "\x11"
@text.sub!(/\[(\d+)\]/, "")
@auto_close = $1.to_i
when "\x12"
@auto_close = AutoClose
## 显示角色动画
when "\x13"
@text.sub!(/\[(\S+)\,(\d+)\]/, "")
character = interpreter.get_character($1.to_i)
character.animation_id = $2.to_i unless character.nil?
next
## 显示心情动画
when "\x14"
@text.sub!(/\[(\S+)\,(\d+)\]/, "")
character = interpreter.get_character($1.to_i)
character.balloon_id = $2.to_i unless character.nil?
next
## 特定字符处理
when "\xff"
@text.insert(0, @frozen_char.shift)
else
## 字速控制
@wait_count = TypeDelay
@wait_count = @speed if @speed != nil
contents.draw_text(@contents_x, @contents_y, contents.font.size, @line_maxh[@line_count], c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
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
@number_input_window.x = x
## 代入头像宽度
@number_input_window.x += face_width if show_face? and !@show_right
@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.skin_indent
x += face_width + $game_message.face_reserved if show_face? and !@show_right
y = 0
for i in 0...$game_message.choice_start + @index
y += @line_maxh
end
width = contents.width - x
height = @line_maxh[$game_message.choice_start + @index]
self.cursor_rect.set(x, y, width, height)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# ◎ 文章显示输入处理
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::C) or Input.trigger?(Input::B)
## 还原自定义暂停标记
@custom_pause = false
unless @text.nil? or @text.empty?
new_page if @line_count >= Window_MaxLine
else
terminate_message
end
end
end
#--------------------------------------------------------------------------
# ○ 是否启用漫画式
#--------------------------------------------------------------------------
def comic_style?
return @comic_style && [email protected]?
end
#--------------------------------------------------------------------------
# ○ 是否显示名字
#--------------------------------------------------------------------------
def show_name?
return [email protected]?
end
#--------------------------------------------------------------------------
# ○ 是否显示头像
#--------------------------------------------------------------------------
def show_face?
return !$game_message.face_name.empty?
end
#--------------------------------------------------------------------------
# ○ 头像宽度
#--------------------------------------------------------------------------
def face_width
return 0 unless show_face?
return @face_sprite.bitmap.width
end
#--------------------------------------------------------------------------
# ○ 头像高度
#--------------------------------------------------------------------------
def face_height
return 0 unless show_face?
return @face_sprite.bitmap.height
end
#--------------------------------------------------------------------------
# ○ 视觉宽度
#--------------------------------------------------------------------------
def visual_width
return self.width - $game_message.skin_indent * 2
end
#--------------------------------------------------------------------------
# ○ 视觉高度
#--------------------------------------------------------------------------
def visual_height
if show_face? and $game_message.face_type == 1
return face_height - $game_message.face_indenty
else
return self.height - $game_message.skin_indent * 2
end
end
#--------------------------------------------------------------------------
# ○ 计算窗体尺寸
#--------------------------------------------------------------------------
def get_window_size
## 非漫画式对话模式时,恢复默认尺寸
unless comic_style? or Window_DefWidth <= 0 or Window_DefHeight <= 0
return Window_DefWidth + $game_message.skin_indent*2, Window_DefHeight + $game_message.skin_indent
end
## 计算呼出窗体
x,y,width,height = 0,0,0,0
## 最后一行宽度
width_last = 0
text = @text.clone
frozen_char = @frozen_char.clone
@line_maxh.clear
loop do
c = text.slice!(/./m)
case c
when nil ## 完结
break
when "\x00" ## 换行
width = x if width < x
y += $game_message.title_spaceh if @line_maxh.empty? and show_name?
@line_maxh.push y + LineSpace
width_last = x
x,y = 0,0
when "\x01" # \C[n] (更改文字色)
text.sub!(/\[(\d+)\]/, "")
next
## 更改不透明度的情况下
when "\x09"
text.sub!(/\[(\d+)\]/, "")
## 显示技能情况下
when "\x0a"
text.sub!(/\[(\d+)\]/, "")
x += 24
y = 24 if y < 24
## 显示物品情况下
when "\x0b"
text.sub!(/\[(\d+)\]/, "")
x += 24
y = 24 if y < 24
## 显示武器情况下
when "\x0c"
text.sub!(/\[(\d+)\]/, "")
x += 24
y = 24 if y < 24
## 显示防具情况下
when "\x0d"
text.sub!(/\[(\d+)\]/, "")
x += 24
y = 24 if y < 24
## 更改字体的情况下
when "\x0e"
text.sub!(/\[(\d+)\]/, "")
contents.font.size = $1.to_i
y = $1.to_i if y < $1.to_i
when "\x0f"
text.sub!(/\[(.+?)\]/, "")
contents.font.name = Font.exist?($1) ? $1 : Font.default_name
## \P[n] (字速)
when "\x10"
text.sub!(/\[(\d+)\]/, "")
## 自动关闭对话框的情况下
when "\x11"
text.sub!(/\[(\d+)\]/, "")
## 显示角色动画
when "\x13"
text.sub!(/\[(\S+)\,(\d+)\]/, "")
next
## 显示心情动画
when "\x14"
text.sub!(/\[(\S+)\,(\d+)\]/, "")
next
## 特定字符处理
when "\xff"
text.insert(0, frozen_char.shift)
else
c_rect = contents.text_size(c)
x += c_rect.width
y = c_rect.height if y < c_rect.height
next
end
end
## 输入数值的情况
if $game_message.num_input_variable_id > 0
shift = 24 + $game_message.num_input_digits_max * ($game_message.content_fontsize + LineSpace)
width = shift if width < shift
## 数值窗体高度
shift = $game_message.content_fontsize + LineSpace
@line_maxh.push shift
else
width += 16 if Pause_Custom > 1 and $game_message.choice_start > 98 and width < width_last + 16
end
width += 32 + 1 ## 边框+阴影
height += 32 + 1 ## 边框+阴影
@line_maxh.each{|h| height += h}
## 头像
if show_face?
case $game_message.face_type
when 0 ## 小头像
shift = face_width + $game_message.face_reserved
width += shift
shift = face_height + $game_message.face_indenty + 32
height = shift if shift > height
when 1 ## 半身像
shift = face_width + $game_message.face_reserved
width += shift
end
end
## 保证窗体最小值
min = Window_MinWidth + $game_message.skin_indent * 2
width = min if width < min
min = Window_MinHeight + $game_message.skin_indent * 2
height = min if height < min
return width, height
end
#--------------------------------------------------------------------------
# ○ 生成皮肤
#--------------------------------------------------------------------------
def create_skin_sprite(width, height, type)
width -= $game_message.skin_indent * 2
height -= $game_message.skin_indent * 2
height += $game_message.skin_namegauge if show_name?
@skin_sprite = Spriteset_Skin.new(@skin_name, width, height, type)
@skin_sprite.z = self.z - 1
end
#--------------------------------------------------------------------------
# ○ 生成头像
#--------------------------------------------------------------------------
def create_face_sprite
@face_sprite = Sprite.new
@face_sprite.bitmap = Bitmap.new(1, 1)
@face_sprite.visible = false
@face_sprite.z = self.z + 1
end
#--------------------------------------------------------------------------
# ○ 刷新头像
#--------------------------------------------------------------------------
def refresh_face_sprite
face_name = $game_message.face_name
face_index = $game_message.face_index
@face_sprite.bitmap.clear
buff = Cache.face(face_name)
width = buff.width / 4
height = buff.height / 2
rect = Rect.new(face_index%4*width, face_index/4*height, width, height)
@face_sprite.bitmap = Bitmap.new(width, height)
@face_sprite.bitmap.blt(0, 0, buff, rect)
@face_sprite.mirror = @show_right
@face_sprite.visible = true unless Actional
###buff.dispose
end
#--------------------------------------------------------------------------
# ○ 生成暂停标记
#--------------------------------------------------------------------------
def create_pause_sprite
return if Pause_Custom == 0
if @pause_sprite
@pause_sprite.bitmap.dispose
@pause_sprite.dispose
end
@pause_sprite = Sprite.new
@pause_sprite.visible = false
bitmap = Cache.system(@skin_name)
@pause_sprite.bitmap = Bitmap.new(16*$game_message.skin_pauseframe, 16)
@pause_sprite.bitmap.blt(0, 0, bitmap, Rect.new(64, 112, 16*$game_message.skin_pauseframe, 16))
@pause_sprite.ox = @pause_sprite.oy = 8
@pause_sprite.z = self.z + 2
@pause_aniindex = -1
@pause_anidelay = 0
end
#--------------------------------------------------------------------------
# ○ 更新暂停标记
#--------------------------------------------------------------------------
def update_pause_sprite
return unless @pause_sprite
@pause_sprite.visible = @custom_pause
@pause_sprite.visible = false if @pause_aniindex == -1
return unless @custom_pause
if @pause_anidelay > 0
@pause_anidelay -= 1
else
@pause_aniindex = (@pause_aniindex + 1) % $game_message.skin_pauseframe
@pause_sprite.src_rect.set(@pause_aniindex*16, 0, 16, 16)
@pause_anidelay = Pause_AniDelay
end
end
#--------------------------------------------------------------------------
# ○ 设定暂停标记坐标
#--------------------------------------------------------------------------
def set_pause_sprite_pos
return if Pause_Custom == 0
case Pause_Custom
when 1 ## 底边居中
@pause_sprite.x = self.x + self.width / 2
@pause_sprite.y = self.y + self.height - $game_message.skin_indent - 8
when 2 ## 右下角
@pause_sprite.x = self.x + self.width - $game_message.skin_indent - 8
@pause_sprite.y = self.y + self.height - $game_message.skin_indent - 8
@pause_sprite.x -= face_width if @show_right
when 3 ## 文字后
@pause_sprite.x = self.x + @contents_x + 24
@pause_sprite.y = self.y + @contents_y + 16 + @line_maxh.last/2
end
@pause_sprite.x += $game_message.skin_pausex
@pause_sprite.y += $game_message.skin_pausey
end
#--------------------------------------------------------------------------
# ○ 获取目标(Sprite_Character)
#--------------------------------------------------------------------------
def get_target
@target = nil
return unless @name or @target_id
## 精灵
spriteset = $scene.instance_variable_get :@spriteset
sprites = spriteset.instance_variable_get :@character_sprites
## 主角
if $game_party.members[0].name == @name or @target_id == 0
@target = sprites.last
return
end
## 事件
$game_map.events.values.each do |e|
if @target_id == e.id or e.name == @name && e.page && !e.erased
sprites.each do |s|
if s.character == e
@target = s
return
end
end
end
end
end
#--------------------------------------------------------------------------
# ○ 是否在屏幕范围内
#--------------------------------------------------------------------------
def within_screen_range?(sprite)
return false if sprite.x < 0
return false if sprite.y < 0
return false if sprite.x > Graphics.width
return false if sprite.y > Graphics.height
return true
end
#--------------------------------------------------------------------------
# ○ 默认字体
#--------------------------------------------------------------------------
def default_font
font = Font.new($game_message.content_fontname, $game_message.content_fontsize)
font.shadow = Font.default_shadow
font.italic = Font.default_italic
font.color = text_color($game_message.content_fontcolor)
font.bold = Font.default_bold
return font
end
#--------------------------------------------------------------------------
# ○ 当前解释器
#--------------------------------------------------------------------------
def interpreter
if $game_temp.in_battle
return $game_troop.interpreter
else
return $game_map.interpreter
end
end
#--------------------------------------------------------------------------
# ○ 横坐标同步
#--------------------------------------------------------------------------
def x=(val)
@skin_sprite.x = val + $game_message.skin_indent + @skin_sprite.ox if @skin_sprite
@pause_sprite.x += val - self.x if @pause_sprite
@number_input_window.x += val - self.x if @number_input_window
if @face_sprite
if @show_right
@face_sprite.x = val - $game_message.face_indentx + self.width - face_width - 16
else
@face_sprite.x = val + $game_message.face_indentx + 16
end
end
super
end
#--------------------------------------------------------------------------
# ○ 纵坐标同步
#--------------------------------------------------------------------------
def y=(val)
if @skin_sprite
@skin_sprite.y = val + $game_message.skin_indent - 16 + @skin_sprite.oy
@skin_sprite.y -= $game_message.skin_namegauge if show_name?
end
@pause_sprite.y += val - self.y if @pause_sprite
@number_input_window.y += val - self.y if @number_input_window
if @face_sprite
case $game_message.face_type
when 0
@face_sprite.y = val + $game_message.face_indenty + 16 - $game_message.skin_namegauge
when 1
@face_sprite.y = val + $game_message.face_indenty + self.height - face_height - 16
end
end
super
end
#--------------------------------------------------------------------------
# ○ 开启度同步
#--------------------------------------------------------------------------
def openness=(val)
super(val)
if @skin_sprite and Actional
@skin_sprite.action(self.openness)
@skin_sprite.x = self.x + $game_message.skin_indent + @skin_sprite.ox
@skin_sprite.y = self.y + $game_message.skin_indent - 16 + @skin_sprite.oy
@skin_sprite.y -= $game_message.skin_namegauge if show_name?
@face_sprite.visible = true if @face_sprite and self.openness == 255
end
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ◎ 开始处理
#--------------------------------------------------------------------------
alias comic_style_start start
def start
comic_style_start
@message_window = Window_ComicStyle.new
end
end
老是这样,求哪位大神能帮忙解决? |
|