赞 | 1 |
VIP | 6 |
好人卡 | 1 |
积分 | 65 |
经验 | 9766 |
最后登录 | 2024-11-28 |
在线时间 | 493 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6521
- 在线时间
- 493 小时
- 注册时间
- 2010-8-27
- 帖子
- 254
|
4楼
楼主 |
发表于 2011-9-8 17:14:54
|
只看该作者
RPGmaster 发表于 2011-9-8 17:01
应该来说,没有修改脚本
是不会出错的
应该是某脚本冲突或者xx脚本xx地方没搞定= =
我只加了一个“华丽版显示地图名”,把Window_Message换了一下,之前还是好好的,重装系统之后重安了一次RM,刚安的时候也能用,后来不知怎的就成这样了……
zxlxp2006于2011-9-8 17:25补充以下内容:- #==============================================================================
- # 跳转地图时显示地图名 by 沉影不器
- #------------------------------------------------------------------------------
- # 功能: 在初进地图时,渐显地图名,随后渐隐
- # 对于不需要显示地图名的地图,请在地图名里添加字符"@"
- # 自定义各个地图名显示动画: 在地图名后加"_数字"
- # 例: "戈壁_1"表示此地图显示的地图名为"戈壁",使用1号动画
- #==============================================================================
- # ■ Spriteset_Map
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 参数
- #--------------------------------------------------------------------------
- # 基本设定
- MAX_OPACITY = 192 # 最大不透明度
- SHOW_COUNT = 120 # 显示时间(均以帧为单位)
- TRANS_COUNT = 60 # 渐变时间
- NAME_WIN_WIDTH = 192 # 名称窗体宽度
- NAME_WIN_HEIGHT = 56 # 名称窗体高度
-
- # 美化选项
- FONT_SIZE = 20 # 名称字体大小
- FONT_COLOR = Color.new(255,255,255) # 名称字体颜色
- FONT_SHADOW = true # 名称字体是否描绘阴影
- SKIN = "Booky_Skin" # 名称窗体自定义皮肤(空字符时隐藏窗体)
- ANIMATION_ID = 32 # 显示名称时的动画 ID(0以下为无动画)
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize
- # 获取地图名
- name = get_map_name($game_map.map_id)
- if $game_temp.old_map_name != name
- $game_temp.old_map_name = name
- unless name.include? "@"
- create_name_window
- end
- end
- ini
- end
- #--------------------------------------------------------------------------
- # ○ 生成名窗体
- #--------------------------------------------------------------------------
- def create_name_window
- # 初始化参数
- @show_count = SHOW_COUNT
- @trans_count_1 = TRANS_COUNT
- @trans_count_2 = TRANS_COUNT
- animation_id = get_animation_id($game_map.map_id)
- animation_id = ANIMATION_ID if animation_id <= 0
- # 显示动画
- @name_animation = Sprite_Base.new(@viewport2)
- @name_animation.x = Graphics.width/2
- @name_animation.y = Graphics.height/2
- if animation_id > 0
- animation = $data_animations[animation_id]
- if animation != nil
- @name_animation.start_animation(animation)
- else
- p '指定动画不存在!'
- end
- end
- x = (Graphics.width - NAME_WIN_WIDTH)/2
- y = (Graphics.height - NAME_WIN_HEIGHT)/2
- # 生成窗体
- @name_window = Window_Base.new(x, y, NAME_WIN_WIDTH, NAME_WIN_HEIGHT)
- @name_window.windowskin = Cache.system(SKIN)
- @name_window.contents.font.size = FONT_SIZE
- @name_window.contents.font.color = FONT_COLOR
- @name_window.contents.font.shadow = FONT_SHADOW
- @name_window.viewport = @viewport3
- @name_window.opacity = 0
- @name_window.contents_opacity = 0
- # 地图名
- text = $game_temp.old_map_name
- @name_window.contents.draw_text(0,0,NAME_WIN_WIDTH-32,FONT_SIZE+4,text,1)
- end
- #--------------------------------------------------------------------------
- # ○ 获取地图名
- # map_id : 地图 ID
- #--------------------------------------------------------------------------
- def get_map_name(map_id)
- mapinfo = load_data("Data/MapInfos.rvdata")
- result = mapinfo[map_id].name
- return result.split(/,/)[0].split(/_/)[0]
- end
- #--------------------------------------------------------------------------
- # ○ 获取动画 ID
- # map_id : 地图 ID
- #--------------------------------------------------------------------------
- def get_animation_id(map_id)
- mapinfo = load_data("Data/MapInfos.rvdata")
- result = mapinfo[map_id].name
- return result.split(/,/)[0].split(/_/)[1].to_i
- end
- #--------------------------------------------------------------------------
- # ○ 更新名窗体
- #--------------------------------------------------------------------------
- def update_name_window
- return if @name_window == nil
- # 已关闭时不需更新
- return unless @name_window.visible
- # 更新动画
- @name_animation.update
- # 渐现
- if @trans_count_1 >= 0
- @trans_count_1 -= 1
- @name_window.opacity += MAX_OPACITY/TRANS_COUNT
- @name_window.contents_opacity += MAX_OPACITY/TRANS_COUNT
- end
- # 显示时间计数
- if @show_count >=0
- @show_count -= 1
- end
- # 渐隐
- if @show_count <= 0
- if @trans_count_2 > 0
- @trans_count_2 -= 1
- @name_window.opacity -= MAX_OPACITY/TRANS_COUNT
- @name_window.contents_opacity -= MAX_OPACITY/TRANS_COUNT
- end
- if @trans_count_2 <= 0
- @name_window.visible = false
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- alias old_dispose dispose
- def dispose
- old_dispose
- return if @name_window == nil
- @name_window.dispose
- @name_animation.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- alias old_update update
- def update
- old_update
- update_name_window
- end
- end
- #==============================================================================
- # ■ Game_Temp
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :old_map_name # 背景位图
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize
- ini
- @old_map_name = ""
- end
- end
复制代码- #==============================================================================
- # ■ [VX] 对话框加强版
- # [VX] Window_message Plus
- #----------------------------------------------------------------------------
- # 使用说明:
- #
- # ① 此脚本可代替默认的 Window_Message 全脚本
- #
- # ② 对话框第一行输入引号内文字"名称:",脚本会把名称提取出来美化显示
- # 例如"张三:",显示为"【张三】" ,美化符可在参数设定中修改
- #
- # ③ 默认头像在左边显示
- # 当您需要右边显示时,在第一行输入的名称之后加"@r"(大小写不限)
- # 例: "拉尔夫@r:"
- # 请注意此时头像将进行左右翻转显示
- #
- # ④ 在对话中更改字体的方法:
- # \f[sX]:更改字号为X
- # \f[nX]:更改字体名称为"预设字体库"第X号字体 (预设字体库请看参数设定)
- # 更改字体名称失败(无指定字体或字体损坏)时,启用游戏默认字体
- # \f[cX]:更改字色为第X号颜色 (text_color中的定义)
- # \f[aX]:更改字体附加效果为第X号效果
- # 附加样式列表:
- # X=0 :无附加; X=1 :阴影字; X=2 :粗体字;
- # X=4 :斜体字; X=8 :描边字; X=16:发光字
- # 叠加效果即数字相加,示例: 3:阴影+粗体 14:粗体+斜体+描边
- # 注意!此三种效果互斥: 阴影/描边/发光
- #
- # ⑤ 在对话中显示(技能 物品 武器 防具)图标和名称的方法:
- # \s[X]: 显示第X号技能图标和名称
- # \i[X]: 显示第X号物品图标和名称
- # \w[X]: 显示第X号武器图标和名称
- # \a[X]: 显示第X号防具图标和名称
- #
- # ⑥ 在对话中更改文字不透明度的方法:
- # \o[X]: 把文字不透明度更改为X (取值范围在0~255)
- #
- # ⑦ 指定时间后自动关闭对话框的方法:
- # \x[X]: 对话框将在X帧后自动关闭
- # \x: 省略参数时,将在AutoClose帧后自动关闭 (AutoClose在参数设定中)
- #
- # ⑧ 调整文字显示速度的方法:
- # \p[X]: 文字在X帧后显示
- #
- # ⑨ 对话中更换对话框皮肤(或直接使用图片)的方法:
- # \b[X]: 更改字体名称为"预设样式库"第X号样式 (预设样式库请看参数设定)
- # 注: vx对话框可使用Window皮肤或直接使用图片,请配合事件页设定
- # 素材格式和命名规则:
- #
- # 在对应的Window皮肤或对话框图片的文件名后+"_pause",做为自定义暂停标记
- # 的名称,并和对应皮肤或图片文件放在一起.
- #
- # ⑩ 启用头像动态显示的方法:
- # \e[X]: 设定头像动态显示的值为X
- # X=0 :关闭动态效果; X=1 :水平趋中; X=2 :渐显
- #
- # 参数设定在脚本第114~167行
- #------------------------------------------------------------------------------
- # 素材要求:
- #
- # ① 采用vx默认头像素材(Graphics\Faces)的格式
- # 即每个素材文件由2行4列共8格头像组成
- #
- # ② 要求所有头像朝向一致(默认是正面偏右)
- #
- # ③ 自定义暂停标记的素材采用横向多帧格式,每帧图片大小一致
- # 注意: 帧数在脚本参数中设定.
- # 在对应的Window皮肤或对话框图片的文件名后+"_pause",做为自定义暂停标记
- # 的名称,并和对应皮肤或图片文件放在一起.
- #----------------------------------------------------------------------------
- # 更新作者: 沉影不器
- # 许可协议: FSL
- # 项目版本: 1.05.1007
- # 引用网址: http://rpg.blue/
- #----------------------------------------------------------------------------
- # - *1.05.1007* (2010-10-07) By 沉影不器
- # *修复 冒号被脚本占用而无法显示
- # *优化 预处理部分数据
- # *新增 自定义暂停标记
- # *新增 全局和局部字速调整
- # *新增 支持滚动显示多行对话内容
- # *新增 显示动画功能(数据库动画/心情动画)
- #
- # - *1.04.0207* (2009-02-07) By 沉影不器
- # *新增 字体附加效果:发光字
- # *新增 更换对话皮肤功能
- # *新增 头像动态显现功能
- #
- # - *1.03.1107* (2008-11-07) By 沉影不器
- # *优化 字体附加效果的叠加方法
- # *新增 字体附加效果:斜体字
- #
- # - *1.02.1023* (2008-10-23) By 沉影不器
- # *修复 自动关闭对话框时可能存在的关闭延后生效
- # *新增 字体附加效果:无效果、阴影字、粗体字、描边字
- # *新增 更改字体无效时,使用游戏默认字体
- #
- # - *1.01.0911* (2008-09-11) By 沉影不器
- # *新增 更改字体功能
- # *新增 显示(技能 物品 武器 防具)图标和名称
- # *新增 更改文字不透明度
- # *新增 自动关闭对话框
- #
- # - *1.00.0831* (2008-08-31) By 沉影不器
- # *初版
- #==============================================================================
- $fscript = {} if $fscript == nil
- $fscript["Window_message_Plus"] = "1.05.1007"
- #----------------------------------------------------------------------------
- # ▼ 通用配置模块
- #----------------------------------------------------------------------------
- module FSL
- module Window_message_Plus
- # 超4行文字时,滚动显示的等待时间(0表示禁止)
- MultiLinesWait = 30
- # 确定键快速显示文字
- FastShow = true
-
- # 自定义暂停标记
- Pause_Custom = 3 # 暂停标记的位置(0:不使用 1:底边居中 2:右下角 3:跟随文字)
- Pause_AdjX = -2 # 暂停标记的X坐标微调
- Pause_AdjY = -2 # 暂停标记的Y坐标微调
- Pause_AniCyc = 6 # 暂停标记的动画周期
- Pause_AniFrm = 4 # 暂停标记的动画帧数
-
- # 预设字体库
- Font_Lib = ["黑体", "仿宋_GB2312", "幼圆"]
- # 字间距
- Font_Space = 4
-
- # 描边颜色
- EdgingColor = 15
- # 发光颜色
- RadiateColor = 10
-
- # 名称条参数
- Name_Symbol = "【】" # 为名称添加的修饰符(一对)
- Name_SpaceX = 6 # 名称条宽度缩进值
- Name_SpaceY = 6 # 名称与对话内容之间的附加距离
- Name_FontIndex = 0 # 名称文字字体在预设字体库中的序号
- Name_FontSize = 18 # 名称文字字号
- Name_FontColor = 18 # 名称文字颜色
- Name_FontAdj = 1 # 名称文字附加效果
- NameBar_Color = 0 # 名称背景条颜色
- NameBar_Opacity = 64 # 名称背景条透明度
-
- # 头像参数
- Face_Enter = 1 # 头像显示模式
- Face_EnterRate = 12 # 头像进入画面的时间
- Face_AdjX = 6 # 头像横坐标微调
- Face_AdjY = -6 # 头像纵坐标微调
- Face_Align = 2 # 头像垂直对齐方式
- # 0:顶端对齐; 1:居中对齐; 2:底端对齐
- # 对话框参数
- Msg_FontName = 0 # 对话文字字体在预设字体库中的序号
- Msg_FontSize = 16 # 对话文字字号
- Msg_FontColor = 0 # 对话文字颜色
- Msg_FontPlus = 1 # 对话文字附加效果
-
- # 预设样式库(其中"Window"和"MessageBack"是vx默认样式)
- Msg_StyleLib = { 0=>["Window","Window"], # Window皮肤
- 1=>["MessageBack","MessageBack"]} # 图片皮肤
- # 自动关闭
- AutoClose = 80 # 默认自动关闭时间(以帧计时)
- # 全局文字速度
- GlobalSpeed = 0 # 改变全局文字延时(以帧计时)
- end
- end
- #==============================================================================
- # ■ Window_Message
- #==============================================================================
- class Window_Message < Window_Selectable
- include FSL::Window_message_Plus
- #--------------------------------------------------------------------------
- # ● 常量
- #--------------------------------------------------------------------------
- MAX_LINE = 4 # 最大行数
- #--------------------------------------------------------------------------
- # ◎ 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- h = [Name_FontSize,Msg_FontSize].max + Name_SpaceY +
- (Msg_FontSize+Font_Space)*(MAX_LINE-1) + 34
- y = Graphics.height - h
- super(0, y, Graphics.width, h)
- self.z = 200
- self.active = false
- self.index = -1
- self.openness = 0
- @opening = false # 窗口正在打开的标志
- @closing = false # 窗口正在关闭的标志
- @text = nil # 已经没有可显示的文章
- @contents_x = 0 # 下一条文字描绘的 X 坐标
- @contents_y = 0 # 下一条文字描绘的 Y 坐标
- @line_count = 0 # 现在描绘的行数
- @wait_count = 0 # 等待计数
- @background = 0 # 背景类型
- @position = 2 # 显示位置
- @show_fast = false # 快速显示标志
- @line_show_fast = false # 以行为单位快速显示
- @pause_skip = false # 省略等待输入标志
- # 显示名称
- @show_name = false
- # 自定义暂停标记
- @custom_pause = false if Pause_Custom > 0
- # 多行对话框标记
- @multi_lines = false
- # 字体附加效果
- @font_adj = Msg_FontPlus
- # 描边和发光字的自设颜色
- @stroke_color = EdgingColor
- @radiate_color = RadiateColor
- create_gold_window
- create_number_input_window
- create_back_sprite
- # 头像左右判断
- @show_right = false
- # 头像宽度
- @face_width = 0
- # 生成自定义暂停标记
- create_custom_pause
- # 生成名称背景条
- create_namebar_sprite
- # 生成头像
- create_face_sprite
- # 修改默认字体
- contents.font = get_font(1)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- dispose_gold_window
- dispose_number_input_window
- dispose_back_sprite
- end
- #--------------------------------------------------------------------------
- # ◎ 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_gold_window
- update_number_input_window
- update_back_sprite
- update_show_fast
- # 更新自定义暂停标记
- update_custom_pause
- unless @opening or @closing # 除窗口关闭以外
- if @wait_count > 0 # 文章内等待中
- @wait_count -= 1
- elsif @multi_lines
- scroll_line
- 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 # 开始消息
- open # 打开窗口
- $game_message.visible = true
- else # 不继续的情况
- close # 关闭窗口
- $game_message.visible = @closing
- end
- end
- # 头像动态显现
- if @face_sprite.visible
- # 水平趋中
- result = @face_x <=> @face_sprite.x
- x_enter = [(@face_x - @face_sprite.x).abs,Face_EnterRate].min
- @face_sprite.x += x_enter if result > 0
- @face_sprite.x -= x_enter if result < 0
- # 渐显
- @face_sprite.opacity += Face_EnterRate if @face_sprite.opacity < 255
- end
- # 自动关闭对话框
- if @auto_close != nil
- if @auto_close > 0
- @auto_close -= 1
- else
- terminate_message
- end
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 生成所持金窗口
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_Gold.new(384, 0)
- @gold_window.openness = 0
- # 统一字体
- @gold_window.contents.font = get_font(1)
- end
- #--------------------------------------------------------------------------
- # ◎ 生成数值输入窗口
- #--------------------------------------------------------------------------
- def create_number_input_window
- @number_input_window = Window_NumberInput.new
- @number_input_window.visible = false
- # 统一字体
- @number_input_window.contents.font = get_font(1)
- end
- #--------------------------------------------------------------------------
- # ● 生成背景活动块
- #--------------------------------------------------------------------------
- def create_back_sprite
- @back_sprite = Sprite.new
- @back_sprite.bitmap = Cache.system("MessageBack")
- @back_sprite.visible = (@background == 1)
- @back_sprite.z = 190
- end
- #--------------------------------------------------------------------------
- # ● 释放所持金窗口
- #--------------------------------------------------------------------------
- def dispose_gold_window
- @gold_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 释放数值输入窗口
- #--------------------------------------------------------------------------
- def dispose_number_input_window
- @number_input_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 释放背景活动块
- #--------------------------------------------------------------------------
- def dispose_back_sprite
- @back_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新所持金窗口
- #--------------------------------------------------------------------------
- def update_gold_window
- @gold_window.update
- end
- #--------------------------------------------------------------------------
- # ● 更新数值输入窗口
- #--------------------------------------------------------------------------
- def update_number_input_window
- @number_input_window.update
- end
- #--------------------------------------------------------------------------
- # ● 更新背景活动块
- #--------------------------------------------------------------------------
- def update_back_sprite
- @back_sprite.visible = (@background == 1)
- @back_sprite.y = y - 16
- @back_sprite.opacity = openness
- @back_sprite.update
- 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 continue?
- return true if $game_message.num_input_variable_id > 0
- return false if $game_message.texts.empty?
- if self.openness > 0 and not $game_temp.in_battle
- return false if @background != $game_message.background
- return false if @position != $game_message.position
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ◎ 开始显示消息
- #--------------------------------------------------------------------------
- def start_message
- # 重设窗口背景与位置
- reset_window
- # 还原头像左右判断
- @show_right = false
- # 暂存消息
- temp_texts = []
- $game_message.texts.each do |text|
- tmp = text.clone
- # 判断对话框皮肤
- if tmp.sub!(/\\B\[(\d+)\]/i) { "" }
- filename = Msg_StyleLib[@background][$1.to_i]
- if @background == 0
- self.windowskin = Cache.system(filename)
- if Pause_Custom>0 && !@pause_sprite.nil? && !@pause_sprite.disposed?
- @pause_sprite.bitmap = Cache.system(filename + "_pause")
- end
- else
- @back_sprite.bitmap = Cache.system(filename)
- if Pause_Custom>0 && !@pause_sprite.nil? && !@pause_sprite.disposed?
- @pause_sprite.bitmap = Cache.system(filename + "_pause")
- end
- end
- # 开始自定义暂停标记动画
- @pause_aniindex = -1
- end
- # 判断头像显现
- @face_enter = $1.to_i if tmp.sub!(/\\E\[(\d+)\]/i) { "" }
- temp_texts.push(tmp)
- end
- # 判断头像方向
- if !temp_texts[0].nil? and temp_texts[0].sub!(/@R/i){ "" }
- @show_right = true
- end
- # 判断名称
- if temp_texts[0] != nil and temp_texts[0] =~ /[::]/
- if temp_texts[0] =~ /\\[::]/
- # 忽略名称的处理
- temp_texts[0].sub!(/\\:/) { ":" }
- temp_texts[0].sub!(/\\:/) { ":" }
- else
- # 去冒号加修饰符(可选)
- unless Name_Symbol.empty?
- temp_texts[0].sub!(/[::]/) { "" }
- temp_texts[0] = Name_Symbol[0,Name_Symbol.size/2] +
- temp_texts[0] + Name_Symbol[Name_Symbol.size/2,Name_Symbol.size/2]
- end
- # 设定文字颜色
- temp_texts[0] = "\\C[#{Name_FontColor}]" +
- temp_texts[0] + "\\C[#{Msg_FontColor}]"
- # 设定文字字体
- temp_texts[0] = "\\F[N#{Name_FontIndex}]" +
- temp_texts[0] + "\\F[N#{Msg_FontName}]"
- # 设定文字大小
- temp_texts[0] = "\\F[S#{Name_FontSize}]" +
- temp_texts[0] + "\\F[S#{Msg_FontSize}]"
- # 设定文字附加效果
- temp_texts[0] = "\\F[A#{Name_FontAdj}]" +
- temp_texts[0] + "\\F[A#{Msg_FontPlus}]"
- # 显示名称背景条
- show_namebar_sprite
- end
- end
- @text = ""
- for i in 0...temp_texts.size
- @text += " " if i >= $game_message.choice_start
- @text += temp_texts[i].clone + "\x00"
- end
- @item_max = $game_message.choice_max
- convert_special_characters
- new_page
- end
- #--------------------------------------------------------------------------
- # ◎ 更换页面处理
- #--------------------------------------------------------------------------
- def new_page
- contents.clear
- # 初始化文字描绘起点
- @contents_x = 0
- # 除名称外文字右移1字符
- @contents_x += Msg_FontSize+Font_Space unless @show_name
- if $game_message.face_name.empty?
- @face_sprite.bitmap.clear
- else
- name = $game_message.face_name
- index = $game_message.face_index
- # 获取头像宽度
- set_face_width(name)
- # 计算文字横坐标起始
- @contents_x += @face_width-16 unless @show_right
- draw_msg_face(name, index)
- # 设定头像坐标
- set_face_plus
- end
- @contents_y = 0
- @line_count = 0
- @show_fast = false
- @line_show_fast = false
- @pause_skip = false
- contents.font.color = text_color(0)
- end
- #--------------------------------------------------------------------------
- # ◎ 换行处理
- #--------------------------------------------------------------------------
- def new_line
- # 提前处理自定义暂停标记
- set_custom_pause_pos
- @contents_x = 0
- unless $game_message.face_name.empty?
- # 头像显示在左时
- @contents_x = @face_width-16 unless @show_right
- end
- # 除名称外文字右移1字符
- @contents_x += (Msg_FontSize+Font_Space)
- # 显示名称之后,对话内容下移 Name_SpaceY
- @contents_y += Name_SpaceY if @line_count == 0 and @show_name
- # 以字号为新间距
- @contents_y += (Msg_FontSize+Font_Space)
- @line_count += 1
- @line_show_fast = false
- end
- #--------------------------------------------------------------------------
- # ◎ 特殊文字变换
- #--------------------------------------------------------------------------
- def convert_special_characters
-
- @text.gsub!(/\\V\[(\d+)\]/i) {$game_variables[$1.to_i]}
- @text.gsub!(/\\V\[(\d+)\]/i) {$game_variables[$1.to_i]}
- @text.gsub!(/\\N\[(\d+)\]/i) {$game_actors[$1.to_i].name}
- @text.gsub!(/\\C\[(\d+)\]/i) {"\x01[#{$1}]"}
- @text.gsub!(/\\G/) {"\x02"}
- @text.gsub!(/\\\./) {"\x03"}
- @text.gsub!(/\\\|/) {"\x04"}
- @text.gsub!(/\\!/) {"\x05"}
- @text.gsub!(/\\>/) {"\x06"}
- @text.gsub!(/\\</) {"\x07"}
- @text.gsub!(/\\\^/) {"\x08"}
- @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(\d+)\]/i){"\x0f[#{$1}]"}
- @text.gsub!(/\\F\[C(\d+)\]/i){"\x10[#{$1}]"}
- # 字体附加效果
- @text.gsub!(/\\F\[A(\d+)\]/i){"\x11[#{$1}]"}
- # 自动关闭
- @text.gsub!(/\\X\[(\d+)\]/i) {"\x12[#{$1}]"}
- @text.gsub!(/\\X/i) {"\x13"}
- # 字速控制
- @text.gsub!(/\\P\[(\d+)\]/i) {"\x14[#{$1}]"}
- ## 提取动画对象和 ID
- @text.gsub!(/\\A\[(\S+)\,(\d+)\]/i) {"\x15[#{$1},#{$2}]"}
- @text.gsub!(/\\B\[(\S+)\,(\d+)\]/i) {"\x16[#{$1},#{$2}]"}
- end
- #--------------------------------------------------------------------------
- # ◎ 设置窗口背景与位置
- #--------------------------------------------------------------------------
- def reset_window
- @background = $game_message.background
- @position = $game_message.position
- if @background == 0 # 普通窗口
- self.opacity = 255
- else # 背景变暗、透明
- self.opacity = 0
- end
- case @position
- when 0 # 上
- fh = get_face_height($game_message.face_name)
- self.y = fh-self.height-Face_AdjY
- self.y = 0 if self.y < 0
- @gold_window.y = 360
- when 1 # 中
- # 通过计算获取
- self.y = (Graphics.height-self.height)/2
- @gold_window.y = 0
- when 2 # 下
- # 通过计算获取
- self.y = Graphics.height-self.height
- @gold_window.y = 0
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 消息结束
- #--------------------------------------------------------------------------
- def terminate_message
- self.active = false
- self.custom_pause = false
- self.index = -1
- @gold_window.close
- @number_input_window.active = false
- @number_input_window.visible = false
- $game_message.main_proc.call if $game_message.main_proc != nil
- $game_message.clear
- # 还原自动关闭
- @auto_close = nil
- # 处理名称背景条和头像
- @show_name = false
- @namebar_sprite.visible = false
- @face_sprite.visible = false
- @face_sprite.bitmap.clear
- end
- #--------------------------------------------------------------------------
- # ◎ 更新消息
- #--------------------------------------------------------------------------
- def update_message
- loop do
- c = @text.slice!(/./m) # 获取下一条文字
- case c
- when nil # 没有可以显示的文字
- finish_message # 更新结束
- break
- when "\x00" # 换行
- new_line
- if @line_count >= MAX_LINE # 行数为最大时
- unless @text.empty? # 如果还有增加则继续
- @wait_count = MultiLinesWait# 等待滚动
- @multi_lines = 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" # \! (等待输入)
- self.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!(/\[(\d+)\]/, "")
- contents.font.name = Font_Lib[$1.to_i]
- when "\x10"
- @text.sub!(/\[(\d+)\]/, "")
- contents.font.color = text_color($1.to_i)
- # 字体附加效果
- when "\x11"
- @text.sub!(/\[(\d+)\]/, "")
- # 获取字体附加效果
- @font_adj = $1.to_i
- # 自动关闭对话框的情况下
- when "\x12"
- @text.sub!(/\[(\d+)\]/, "")
- @auto_close = $1.to_i
- when "\x13"
- @auto_close = AutoClose
- # \P[n] (字速)
- # 普通文字的情况下
- when "\x14"
- @text.sub!(/\[(\d+)\]/, "")
- # 获取字体显示速度
- @speed = $1.to_i
- # 显示角色动画
- when "\x15"
- @text.sub!(/\[(\S+)\,(\d+)\]/, "")
- character = $game_map.interpreter.get_character($1.to_i)
- character.animation_id = $2.to_i unless character.nil?
- next
- # 显示心情动画
- when "\x16"
- @text.sub!(/\[(\S+)\,(\d+)\]/, "")
- character = $game_map.interpreter.get_character($1.to_i)
- character.balloon_id = $2.to_i unless character.nil?
- next
- else
- # 字速控制
- @wait_count = GlobalSpeed
- @wait_count = @speed if @speed != nil
- h = contents.font.size + Font_Space
- # 字体附加效果
- if @font_adj & 1 != 0
- contents.font.shadow = true
- else
- contents.font.shadow = false
- end
- if @font_adj & 2 != 0
- contents.font.bold = true
- else
- contents.font.bold = false
- end
- if @font_adj & 4 != 0
- contents.font.italic = true
- else
- contents.font.italic = false
- end
- if @font_adj & 8 != 0#draw_stroke_text
- color = text_color(@stroke_color)
- contents.draw_stroke_text(@contents_x,@contents_y,h,h,c,0,color)
- elsif @font_adj & 16 != 0#draw_radiate_text
- color = text_color(@radiate_color)
- contents.draw_radiate_text(@contents_x,@contents_y,h,h,c,0,color)
- else
- contents.draw_text(@contents_x, @contents_y, h, h, c)
- end
- c_width = contents.text_size(c).width
- @contents_x += c_width
- end
- break unless @show_fast or @line_show_fast
- end
- 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
- self.custom_pause = true
- end
- @wait_count = 10
- @text = nil
- # 临时字速还原
- @speed = nil
- end
- #--------------------------------------------------------------------------
- # ● 开始选择项
- #--------------------------------------------------------------------------
- def start_choice
- self.active = true
- self.index = 0
- 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
- if $game_message.face_name.empty?
- @number_input_window.x = x
- else
- # 代入头像宽度
- @number_input_window.x = @show_right ? x : x + @face_width
- end
- @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
- if $game_message.face_name.empty?
- x = 0
- y = ($game_message.choice_start+@index)*(Msg_FontSize+Font_Space)
- width = contents.width
- else
- x = @show_right ? 0 : @face_width
- y = ($game_message.choice_start+@index)*(Msg_FontSize+Font_Space) +
- Name_SpaceY
- width = contents.width - @face_width
- end
- self.cursor_rect.set(x, y, width, (Msg_FontSize+Font_Space))
- else
- self.cursor_rect.empty
- end
- end
- #--------------------------------------------------------------------------
- # ● 文章显示输入处理
- #--------------------------------------------------------------------------
- def input_pause
- if Input.trigger?(Input::B) or Input.trigger?(Input::C)
- self.custom_pause = false
- if @text != nil and not @text.empty?
- new_page if @line_count >= MAX_LINE
- else
- terminate_message
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 选择项输入处理
- #--------------------------------------------------------------------------
- def input_choice
- if Input.trigger?(Input::B)
- if $game_message.choice_cancel_type > 0
- Sound.play_cancel
- $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
- terminate_message
- end
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- $game_message.choice_proc.call(self.index)
- terminate_message
- end
- end
- #--------------------------------------------------------------------------
- # ● 数值输入处理
- #--------------------------------------------------------------------------
- def input_number
- if Input.trigger?(Input::C)
- Sound.play_decision
- $game_variables[$game_message.num_input_variable_id] =
- @number_input_window.number
- $game_map.need_refresh = true
- terminate_message
- end
- end
- #--------------------------------------------------------------------------
- # ○ 生成名称背景条
- #--------------------------------------------------------------------------
- def create_namebar_sprite
- @namebar_sprite = Sprite.new
- @namebar_sprite.bitmap = Bitmap.new(width-Name_SpaceX, Name_FontSize+4)
- # 可视性
- @namebar_sprite.visible = false
- # 准备参数
- rect = Rect.new(Name_SpaceX,0,@namebar_sprite.width,@namebar_sprite.height)
- color1 = text_color(NameBar_Color)
- color2 = text_color(NameBar_Color)
- color1.alpha = NameBar_Opacity
- color2.alpha = 0
- # 描绘渐变条
- @namebar_sprite.bitmap.gradient_fill_rect(rect, color1, color2)
- end
- #--------------------------------------------------------------------------
- # ○ 生成头像
- #--------------------------------------------------------------------------
- def create_face_sprite
- @face_sprite = Sprite.new
- @face_sprite.bitmap = Bitmap.new(1,1)
- @face_sprite.z = self.z + 2
- @face_sprite.visible = false
- @old_name = "" # 判断头像是否改变
- @old_index = 0 # 判断头像是否改变
- @face_enter = Face_Enter # 头像显示模式
- end
- #--------------------------------------------------------------------------
- # ○ 显示名称背景条
- #--------------------------------------------------------------------------
- def show_namebar_sprite
- @show_name = true
- return if @background == 1
- # 坐标跟随
- @namebar_sprite.x = self.x
- @namebar_sprite.y = self.y + 16 - 1
- @namebar_sprite.z = self.z + 1
- # 可视性
- @namebar_sprite.visible = true
- end
- #--------------------------------------------------------------------------
- # ○ 描绘头像
- # face_name : 头像图像文件名
- # face_index : 头像图像索引
- #--------------------------------------------------------------------------
- def draw_msg_face(face_name, face_index)
- bitmap = Cache.face(face_name)
- width = bitmap.width / 4
- height = bitmap.height / 2
- rect = Rect.new(0, 0, 0, 0)
- rect.x = face_index % 4 * width
- rect.y = face_index / 4 * height
- rect.width = width
- rect.height = height
- @face_sprite.bitmap = Bitmap.new(width, height)
- @face_sprite.bitmap.blt(0, 0, bitmap, rect)
- @face_sprite.mirror = @show_right
- end
- #--------------------------------------------------------------------------
- # ○ 生成自定义暂停标记
- #--------------------------------------------------------------------------
- def create_custom_pause
- return if Pause_Custom == 0
- @pause_sprite = Sprite.new
- @pause_sprite.visible = false
- @pause_sprite.z = self.z + 3
- @pause_sprite.bitmap = Cache.system("Window_pause")
- @pause_aniindex = -1
- @pause_anispeed = 0
- end
- #--------------------------------------------------------------------------
- # ○ 获取暂停标记
- #--------------------------------------------------------------------------
- def custom_pause
- return @custom_pause
- end
- #--------------------------------------------------------------------------
- # ○ 更改暂停标记
- #--------------------------------------------------------------------------
- def custom_pause=(val)
- @custom_pause = val
- self.pause = val if Pause_Custom == 0
- end
- #--------------------------------------------------------------------------
- # ○ 更新暂停标记
- #--------------------------------------------------------------------------
- def update_custom_pause
- return if Pause_Custom == 0
- @pause_sprite.visible = @custom_pause
- @pause_sprite.visible = false if @pause_aniindex == -1
- return if !@custom_pause
- if @pause_anispeed > 0
- @pause_anispeed -= 1
- else
- @pause_aniindex = (@pause_aniindex + 1) % Pause_AniFrm
- pw = @pause_sprite.bitmap.width / Pause_AniFrm
- ph = @pause_sprite.bitmap.height
- @pause_sprite.src_rect.set(@pause_aniindex*pw, 0, pw, ph)
- @pause_anispeed = Pause_AniCyc
- end
- end
- #--------------------------------------------------------------------------
- # ○ 设定暂停标记坐标
- #--------------------------------------------------------------------------
- def set_custom_pause_pos
- return if Pause_Custom == 0
- #@pause_sprite.visible = false
- pw = @pause_sprite.bitmap.width / Pause_AniFrm
- ph = @pause_sprite.bitmap.height
- case Pause_Custom
- when 1 # 底边居中
- @pause_sprite.x = self.x + (self.width - pw)/2
- @pause_sprite.y = self.y + self.height - ph
- when 2 # 右下角
- @pause_sprite.x = self.x + self.width - pw
- @pause_sprite.y = self.y + self.height - ph
- @pause_sprite.x -= @face_width if @show_right
- when 3 # 文字后
- @pause_sprite.x = self.x + @contents_x + Msg_FontSize + Font_Space
- @pause_sprite.y = self.y + @contents_y + Msg_FontSize + Font_Space
- end
- @pause_sprite.x += Pause_AdjX
- @pause_sprite.y += Pause_AdjY
- #@pause_sprite.visible = @custom_pause
- end
- #--------------------------------------------------------------------------
- # ○ 滚动换行
- #--------------------------------------------------------------------------
- def scroll_line
- w = self.width - 32
- hm = Msg_FontSize + Font_Space
- if @show_name
- l = MAX_LINE - 2
- hn = Name_FontSize + Font_Space + Name_SpaceY
- rect = Rect.new(0, hn+hm, w, hm*l)
- else
- l = MAX_LINE - 1
- hn = 0
- rect = Rect.new(0, hm, w, hm*l)
- end
- # 复制位图
- buff = Bitmap.new(w, hm*l)
- buff.blt(0, 0, contents, rect)
- # 描绘位图
- contents.clear_rect Rect.new(0, hn, w, hm*l+hm)
- contents.blt 0, hn, buff, Rect.new(0, 0, w, hm*l)
- buff.dispose
- @contents_y -= Msg_FontSize + Font_Space
- @multi_lines = false
- end
- #--------------------------------------------------------------------------
- # ○ 返回字体
- # index : 编号
- #--------------------------------------------------------------------------
- def get_font(index)
- case index
- when 0
- name = [Font_Lib[Name_FontIndex], Font.default_name].flatten!
- size = Name_FontSize
- font = Font.new(name, size)
- when 1
- name = [Font_Lib[Msg_FontName], Font.default_name].flatten!
- size = Msg_FontSize
- font = Font.new(name, size)
- else
- name = [Font_Lib[index],Font.default_name].flatten!
- font = Font.new(name)
- end
- return font
- end
- #--------------------------------------------------------------------------
- # ○ 设定头像宽度
- # face_name : 头像图像文件名
- #--------------------------------------------------------------------------
- def set_face_width(face_name)
- bitmap = Cache.face(face_name)
- @face_width = bitmap.width / 4
- end
- #--------------------------------------------------------------------------
- # ○ 获取头像高度
- # face_name : 头像图像文件名
- #--------------------------------------------------------------------------
- def get_face_height(face_name)
- bitmap = Cache.face(face_name)
- return bitmap.height / 2
- end
- #--------------------------------------------------------------------------
- # ○ 设定头像增强功能
- #--------------------------------------------------------------------------
- def set_face_plus
- fw = @face_sprite.width
- fh = @face_sprite.height
- # 水平坐标
- if @show_right
- @face_x = self.width - fw - Face_AdjX
- else
- @face_x = self.x + Face_AdjX
- end
- @face_sprite.x = @face_x
- # 垂直坐标
- case Face_Align
- when 0
- @face_sprite.y = self.y + Face_AdjY
- when 1
- @face_sprite.y = self.y + (self.height - fh) / 2
- when 2
- @face_sprite.y = self.y + (self.height - fh) + Face_AdjY
- end
- case @face_enter
- when 1 # 水平趋中时
- @face_sprite.x += (@show_right ? fw : -fw)
- when 2 # 渐显时
- @face_sprite.opacity = 0
- end
- # 可视性
- @face_sprite.visible = true
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ◎ 显示文章
- #--------------------------------------------------------------------------
- def command_101
- unless $game_message.busy
- $game_message.face_name = @params[0]
- $game_message.face_index = @params[1]
- $game_message.background = @params[2]
- $game_message.position = @params[3]
- @index += 1
- loop do
- case @list[@index].code
- when 101 # 对话设定
- multi_lines? ? @index += 1 : break
- when 401 # 对话数据
- $game_message.texts.push(@list[@index].parameters[0])
- @index += 1
- else
- break
- end
- end
- if @list[@index].code == 102 # 显示选择项
- setup_choices(@list[@index].parameters)
- elsif @list[@index].code == 103 # 处理数值输入
- setup_num_input(@list[@index].parameters)
- end
- set_message_waiting # 消息待机状态
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ○ 多行模式?
- #--------------------------------------------------------------------------
- def multi_lines?
- return false if FSL::Window_message_Plus::MultiLinesWait <= 0
- return false if $game_message.face_name != @list[@index].parameters[0]
- return false if $game_message.face_index != @list[@index].parameters[1]
- return false if $game_message.background != @list[@index].parameters[2]
- return false if $game_message.position != @list[@index].parameters[3]
- return true
- end
- #--------------------------------------------------------------------------
- # ○ 心情图标扩展
- # character_id: 角色 ID (-1 为角色、0 为本事件、除此之外为事件 ID)
- # balloon_id : 心情动画 ID (从1开始)
- #--------------------------------------------------------------------------
- def balloon_extend(character_id, balloon_id)
- character = get_character(character_id)
- if character != nil
- character.balloon_id = balloon_id
- end
- return true
- end
- end
- #==============================================================================
- # ■ Bitmap
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # ○ 描边字
- #--------------------------------------------------------------------------
- def draw_stroke_text(x, y, width, height, str, align = 0, color = nil)
- # 准备字体
- font_backup = self.font.clone
- # 处理字色
- self.font.color.set(color.red,color.green,color.blue) if color
- # 关闭默认阴影
- self.font.shadow = false
- # 描绘边缘
- self.draw_text(x-1, y-1, width, height, str, align)
- self.draw_text(x-1, y+1, width, height, str, align)
- self.draw_text(x+1, y-1, width, height, str, align)
- self.draw_text(x+1, y+1, width, height, str, align)
- self.draw_text(x, y-1, width, height, str, align)
- self.draw_text(x, y+1, width, height, str, align)
- self.draw_text(x-1, y, width, height, str, align)
- self.draw_text(x+1, y, width, height, str, align)
- # 描绘主文字
- self.font.color = font_backup.color
- self.draw_text(x, y, width, height, str, align)
- # 还原默认字体
- self.font = font_backup
- end
- #--------------------------------------------------------------------------
- # ○ 发光字
- #--------------------------------------------------------------------------
- def draw_radiate_text(x, y, width, height, str, align = 0, color = nil)
- # 准备buffer
- buffer = Bitmap.new(width, height)
- # 同步font
- buffer.font = self.font.clone
- # 关闭默认阴影
- buffer.font.shadow = false
- # 处理字色
- buffer.font.color.set(color.red,color.green,color.blue) if color
- # 描绘边缘
- buffer.draw_text(-1, -1, width, height, str, align)
- buffer.draw_text(-1, 1, width, height, str, align)
- buffer.draw_text(1, -1, width, height, str, align)
- buffer.draw_text(1, 1, width, height, str, align)
- buffer.draw_text(0, -1, width, height, str, align)
- buffer.draw_text(0, 1, width, height, str, align)
- buffer.draw_text(0-1, 0, width, height, str, align)
- buffer.draw_text(1, 0, width, height, str, align)
- buffer.blur
- # 描绘主文字
- buffer.font.color = self.font.color
- buffer.draw_text(0, 0, width, height, str, align)
- self.blt(x, y, buffer, Rect.new(0, 0, width, height))
- buffer.dispose
- end
- end
复制代码 |
|