赞 | 2 |
VIP | 33 |
好人卡 | 2 |
积分 | 14 |
经验 | 34317 |
最后登录 | 2024-11-5 |
在线时间 | 1705 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1433
- 在线时间
- 1705 小时
- 注册时间
- 2011-8-17
- 帖子
- 818
|
好人做到底,下载完那个脚本以后复制下面这个替换里面的脚本(为什么不直接使用这个脚本呢,因为没有那个脚本的素材)- #==============================================================================
- # ■ [VX] 对话框加强版
- # [VX] Window_message Plus
- #----------------------------------------------------------------------------
- # 此脚本可代替官方 Window_Message 全脚本
- #----------------------------------------------------------------------------
- # 使用说明:
- #
- # ⑴ 对话框第一行输入引号内文字"名称:",脚本会把名称提取出来美化显示
- # 例如"张三:",显示为"【张三】" ,美化符可在参数设定中修改
- #
- # ⑵ 默认头像在左边显示
- # 当您需要右边显示时,在第一行输入的名称时加"\r"(大小写不限)
- # 例: "拉尔夫\r:"
- # 请注意此时头像将进行左右翻转显示
- #
- # ⑶ 在对话中更改字体的方法:
- # \f[sX]:更改字号为X
- # \f[nX]:更改字体名称为"预设字体库"第X号字体(预设字体库请看参数设定)
- # 更改字体名称失败(无指定字体或字体损坏)时,启用游戏默认字体
- # \f[cX]:更改字色为第X号颜色 (text_color中的定义)
- # \f[c#FF0000]:使用16进制指定字体颜色,如本句表示红色
- # \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 :渐显
- #
- # ⑽ 在对话中更换头像:
- # \@[X]: 设定头像索引号为X X值范围0-7
- # 可更改的仅是索引号,头像文件名称不可改 主要用于对话中换表情
- #
- # ⑾ 输入文章时设定冻结字符和注释字符:
- # #[XX]: 字符串XX被冻结,不受转义等影响直接显示
- # #<XX>: 字符串XX被当作注释,显示文章时不出现
- #------------------------------------------------------------------------------
- # 素材要求:
- #
- # ① 采用vx默认头像素材(Graphics\Faces)的格式
- # 即每个素材文件由2行4列共8格头像组成
- #
- # ② 要求所有头像朝向一致(默认是正面偏右)
- #
- # ③ 自定义暂停标记的素材采用横向多帧格式,每帧图片大小一致
- # 注意: 帧数在脚本参数中设定.
- # 在对应的Window皮肤或对话框图片的文件名后+"_pause",做为自定义暂停标记
- # 的名称,并和对应皮肤或图片文件放在一起.
- #------------------------------------------------------------------------------
- # 合并功能附加说明:
- #
- # ① 对话框合并
- # 头像、背景、位置等相同的上下两段对话都会被合并成一段对话;
- # 如果要打断合并,请在两段对话之间加个非对话框的执行项,比如空注释.
- #
- # ② 选择项合并
- # 当前选项组满4项,且取消设定不为"分歧",且下一个执行项也是选择组,就合并;
- # 取消键的规定: 如果有"分歧",必须设定在最后一个选项组,其它不限.
- # 合并后最多只有一个取消设定,多个设定时,仅最后一个有效.
- #----------------------------------------------------------------------------
- # 更新作者: 沉影不器
- # 许可协议: FSL
- # 项目版本: 1.09.1031
- # 引用网址: http://rpg.blue/thread-158161-1-1.html
- #----------------------------------------------------------------------------
- # - *1.09.1031* (2010-10-31) By 沉影不器
- # *新增 指定被冻结的字符串
- # *新增 允许字符串做为注释
- #
- # - *1.08.1030* (2010-10-30) By 沉影不器
- # *新增 对话中更改头像
- # *新增 允许指定16进制颜色为字色
- # *修改 取消对话中切换[是否独立显示选项窗体]的开关
- #
- # - *1.07.1029* (2010-10-29) By 沉影不器
- # *优化 重写合并选择项的功能,大幅降低冲突
- #
- # - *1.06.1026* (2010-10-26) By 沉影不器
- # *修改 头像在右的控制符改为"\r"(大小写不限)
- # *优化 改变字体失败时使用默认字体
- # *新增 允许独立显示选项窗体
- # *新增 合并多个事件页选项(突破4选项上限)
- #
- # - *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.09.1031"
- #----------------------------------------------------------------------------
- # ▼ 通用配置模块
- #----------------------------------------------------------------------------
- module FSL
- module Window_message_Plus
- ## 对话框的预设样式库(其中"Window"和"MessageBack"是vx默认样式)
- Msg_StyleLib = {0=>["Window","Sinicism"], ## Window皮肤
- 1=>["MessageBack","Black"]} ## 图片皮肤
- ## 字体参数
- Font_Lib = ["黑体", "仿宋_GB2312", "幼圆"] ## 预设字体库
- Font_Space = 4 ## 字间距
- EdgeColor = 15 ## 描边颜色
- GlowColor = 10 ## 发光颜色
-
- ## 名称条参数
- Name_Symbol = "【】" ## 为名称添加的修饰符(一对)
- Name_SpaceX = 6 ## 名称条宽度缩进值
- Name_SpaceY = 6 ## 名称与对话内容之间的附加距离
- Name_FontIndex = 0 ## 名称文字字体在预设字体库中的序号
- Name_FontSize = 18 ## 名称文字字号
- Name_FontColor = 16 ## 名称文字颜色
- Name_FontAdj = 1 ## 名称文字附加效果
- NameBar_Color = 0 ## 名称背景条颜色
- NameBar_Opacity = 64 ## 名称背景条透明度
-
- ## 头像参数
- Face_Enter = 0 ## 头像显示模式
- Face_EnterRate = 12 ## 头像进入画面的时间
- Face_AdjX = 6 ## 头像横坐标微调
- Face_AdjY = -6 ## 头像纵坐标微调
- Face_Align = 2 ## 头像垂直对齐方式
- ## 0:顶端对齐; 1:居中对齐; 2:底端对齐
-
- ## 对话框参数
- Msg_FontName = 1 ## 对话文字字体在预设字体库中的序号
- Msg_FontSize = 16 ## 对话文字字号
- Msg_FontColor = 0 ## 对话文字颜色
- Msg_FontPlus = 1 ## 对话文字附加效果
-
- ## 全局功能参数
- FastShow = true ## 确定键快速显示文字
- AutoClose = 80 ## 默认自动关闭时间(以帧计时)
- GlobalSpeed = 0 ## 改变全局文字延时(以帧计时)
-
- ## 自定义暂停标记
- Pause_Custom = 3 ## 位置(0:不使用 1:底边居中 2:右下角 3:跟随文字)
- Pause_AdjX = -2 ## X坐标微调
- Pause_AdjY = -2 ## Y坐标微调
- Pause_AniCyc = 6 ## 动画周期
- Pause_AniFrm = 4 ## 动画帧数
-
- ## 对话和选择项合并
- MultiLinesWait = 30 ## 滚动显示对话的等待时间(0表示禁止合并多段对话)
- Choice_Strip = true ## 是否单独显示选项窗体
- ## 注: 选择项合并功能仅在单独显示的选项窗体生效
- Choice_MaxLines = 4 ## 选项窗体的最大行数(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 # 省略等待输入标志
- ## 冻结字符池
- @frozen_char = []
- ## 显示名称
- @show_name = false
- ## 自定义暂停标记
- @custom_pause = false if Pause_Custom > 0
- ## 多行对话框标记
- @multi_lines = false
- ## 字体附加效果
- @font_adj = Msg_FontPlus
- 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 = default_font
- 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 || @choice ## 正在输入选择项
- 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 = default_font
- end
- #--------------------------------------------------------------------------
- # ◎ 生成数值输入窗体
- #--------------------------------------------------------------------------
- def create_number_input_window
- @number_input_window = Window_NumberInput.new
- @number_input_window.visible = false
- ## 统一字体
- @number_input_window.contents.font = default_font
- 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)
- ## 头像进入画面
- face_in
- 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!(/#\[(.*?)\]/) {@frozen_char.push($1); "\xff"}
- @text.gsub!(/#\<(.*?)\>/) {""}
- ## 默认控制符
- @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){"\x01[#{$1}]"}
- ## 16进制颜色
- @text.gsub!(/\\F\[C\#([a-f0-9]+)\]/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}]"}
- ## 切换头像index
- @text.gsub!(/\\@\[(\d+)\]/) {"\x17[#{$1}]"}
- 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
- ## 选项窗体
- Choice_Strip ? @choice = false : 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+)\]/, "")
- name = Font_Lib[$1.to_i]
- contents.font.name = Font.exist?(name) ? name : Font.default_name
- ## 16进制颜色
- when "\x10"
- @text.sub!(/\[(\w+)\]/, "")
- r,g,b = $1.scan(/../)
- contents.font.color = Color.new(r.hex, g.hex, b.hex)
- ## 字体附加效果
- 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 = interpreter.get_character($1.to_i)
- character.animation_id = $2.to_i unless character.nil?
- next
- ## 显示心情动画
- when "\x16"
- @text.sub!(/\[(\S+)\,(\d+)\]/, "")
- character = interpreter.get_character($1.to_i)
- character.balloon_id = $2.to_i unless character.nil?
- next
- ## 换头像
- when "\x17"
- @text.sub!(/\[(\d+)\]/, "")
- name = $game_message.face_name
- index = $game_message.face_index = $1.to_i
- draw_msg_face(name, index)
- ## 选择项
- when "\x18"
- finish_message
- break
- ## 特定字符处理
- when "\xff"
- @text.insert(0, @frozen_char.shift)
- 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 ## 描边字
- color = text_color(EdgeColor)
- contents.draw_edge_text(@contents_x,@contents_y,h,h,c,0,color)
- elsif @font_adj & 16 != 0 ## 发光字
- color = text_color(GlowColor)
- contents.draw_glow_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
- if Choice_Strip
- @choice = true
- width = 0
- commands = []
- for i in $game_message.choice_start+1 ...$game_message.texts.size
- commands.push $game_message.texts[i]
- iw = contents.text_size($game_message.texts[i]).width
- width = iw if width < iw
- end
- ## 计算高度
- if commands.size > Choice_MaxLines
- row_max = Choice_MaxLines
- else
- row_max = commands.size
- end
- @choice_window = Window_Command.new(width+42, commands, 1, row_max)
- @choice_window.contents.font = default_font
- @choice_window.refresh
- ## 计算坐标
- if @show_right
- @choice_window.x = self.x + self.width/2 - @choice_window.width/2
- else
- @choice_window.x = self.x + self.width/2 - @choice_window.width/2
- end
- if @position == 0
- @choice_window.y = self.y + self.height
- else
- @choice_window.y = self.y - @choice_window.height
- end
- else
- self.active = true
- self.index = 0
- 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
- 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::C) or Input.trigger?(Input::B)
- ## 还原自定义暂停标记
- 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
- ## 获取相应index
- index = Choice_Strip ? @choice_window.index : self.index
- $game_message.choice_proc.call(index)
- terminate_message
- end
- ## 刷新选项窗体
- return unless Choice_Strip
- if @choice
- @choice_window.update
- else
- @choice_window.dispose
- @choice_window = nil
- 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 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
- #--------------------------------------------------------------------------
- # ○ 生成头像
- #--------------------------------------------------------------------------
- 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
- #--------------------------------------------------------------------------
- # ○ 描绘头像
- # 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
- #--------------------------------------------------------------------------
- # ○ 设定头像宽度
- # 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 face_in
- 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
- #--------------------------------------------------------------------------
- # ○ 生成自定义暂停标记
- #--------------------------------------------------------------------------
- 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
- 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
- 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
- #--------------------------------------------------------------------------
- # ○ 默认字体
- #--------------------------------------------------------------------------
- def default_font
- font = Font.new(Font.default_name, Msg_FontSize)
- font.shadow = Font.default_shadow
- font.italic = Font.default_italic
- font.color = text_color(Msg_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
- end
- #==============================================================================
- # ■ Window_Command
- #==============================================================================
- class Window_Command < Window_Selectable
- #--------------------------------------------------------------------------
- # ◎ 初始化
- # width : 窗口宽
- # commands : 命令字符串列表
- # column_max : 列数 (2 以上横向选择)
- # row_max : 行数 (0:与命令数一致)
- # spacing : 项目横向的空白空间
- #--------------------------------------------------------------------------
- def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
- line_max = (commands.size + column_max - 1) / column_max
- row_max = line_max if row_max == 0
- super(0, 0, width, [line_max,row_max].max * WLH + 32, spacing)
- @commands = commands
- @item_max = commands.size
- @column_max = column_max
- refresh
- self.index = 0
- self.height = row_max * WLH + 32
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ◎ 设置事件
- # list : 执行内容
- # event_id : 事件 ID
- #--------------------------------------------------------------------------
- alias msg_plus_setup setup
- def setup(list, event_id = 0)
- msg_plus_setup(list, event_id)
- ## 获取执行列表
- @list = Marshal.load(Marshal.dump list)
- end
- #--------------------------------------------------------------------------
- # ◎ 显示文章
- #--------------------------------------------------------------------------
- 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 setup_choices(params)
- if FSL::Window_message_Plus::Choice_Strip &&
- FSL::Window_message_Plus::Choice_MaxLines > 0
- ## 备重建
- @modify = []
- @delete = []
- @cancel = 0
- ## 获取合并后的command
- command = @list[@index].clone
- command.parameters = connect_choice(@index), @cancel
- ## 消息参数
- $game_message.choice_start = $game_message.texts.size
- $game_message.choice_max = command.parameters[0].size
- $game_message.texts.push "\x18"
- command.parameters[0].each{|s| $game_message.texts.push(s)}
- ## 重建数据
- @modify.each_index do |i|
- key,value = @modify[i].is_a?(Array) ? @modify[i] : [@modify[i],i]
- @list[key].parameters[0] = value
- end
- @delete.reverse.each{|i| @list[i,1] = nil}
- @list.insert(@index, command)
- $game_message.choice_cancel_type = @cancel
- $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
- ## 推进
- @index += 1
- else
- ## 默认情况
- if $game_message.texts.size <= 4 - params[0].size
- $game_message.choice_start = $game_message.texts.size
- $game_message.choice_max = params[0].size
- for s in params[0]
- $game_message.texts.push(s)
- end
- $game_message.choice_cancel_type = params[1]
- $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
- @index += 1
- end
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 取消的情况下
- #--------------------------------------------------------------------------
- alias msg_plus_command_403 command_403
- def command_403
- ## 合并选项时
- if !@params[0].nil? && @branch[@indent] == @params[0] - 1
- @branch.delete(@indent)
- return true
- end
- msg_plus_command_403
- end
- #--------------------------------------------------------------------------
- # ## 合并选项
- #--------------------------------------------------------------------------
- def connect_choice(index, result=[])
- params = @list[index].parameters
- indent = @list[index].indent
- ## 取消项
- @cancel = result.size + params[1] if params[1] > 0
- params[0].each{|s| result.push(s)}
- @delete.push(index) ## 102
- index = next_choice(index)
- ## 判断合并的条件 选项:满4项;取消:非分歧
- if index && params[0].size == 4 && params[1] < 5
- @delete.push(index-1) ## 404
- connect_choice(index, result)
- else
- return result
- end
- end
- #--------------------------------------------------------------------------
- # ## 下个选项
- #--------------------------------------------------------------------------
- def next_choice(index)
- params = @list[index].parameters
- indent = @list[index].indent
- until @list[index+1].nil?
- index += 1
- if indent == @list[index].indent
- case @list[index].code
- when 402
- @modify.push(index)
- when 403
- @modify.push([index,@cancel])
- when 404
- ## 判断合并的条件 下一个同级执行项102
- return @list[index+1].code == 102 ? index+1 : nil
- end
- end
- end
- 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_edge_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_glow_text(x, y, width, height, str, align = 0, color = nil)
- buff = Bitmap.new(width, height)
- buff.font = self.font.clone
- buff.font.shadow = false
- buff.font.color.set(color.red,color.green,color.blue) if color
- # 描绘边缘
- buff.draw_text(-1, -1, width, height, str, align)
- buff.draw_text(-1, 1, width, height, str, align)
- buff.draw_text(1, -1, width, height, str, align)
- buff.draw_text(1, 1, width, height, str, align)
- buff.draw_text(0, -1, width, height, str, align)
- buff.draw_text(0, 1, width, height, str, align)
- buff.draw_text(0-1, 0, width, height, str, align)
- buff.draw_text(1, 0, width, height, str, align)
- buff.blur
- # 描绘主文字
- buff.font.color = self.font.color
- buff.draw_text(0, 0, width, height, str, align)
- self.blt(x, y, buff, Rect.new(0, 0, width, height))
- buff.dispose
- end
- #--------------------------------------------------------------------------
- # ○ 多层字
- #--------------------------------------------------------------------------
- def draw_sedimentary_text(x, y, width, height, str, align = 0, *color)
- color.unshift font.color
- sheet = (font.size.to_f / color.size).ceil
- buff = Bitmap.new(width, sheet)
- buff.font = font.clone
- max = (height - font.size)/2 > 0 ? (height - font.size)/2 : 0
- min = buff.font.size < height ? buff.font.size : height
- color.each_index do |i|
- buff.clear
- buff.font.color = color[i]
- buff.draw_text(0, -i*sheet, width, min, str, align)
- blt(x, y+i*sheet+max, buff, Rect.new(0, 0, width, sheet))
- break if i*sheet >= height
- end
- end
- end
复制代码 |
评分
-
查看全部评分
|