赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 869 |
最后登录 | 2017-8-29 |
在线时间 | 7 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 7 小时
- 注册时间
- 2010-6-22
- 帖子
- 5
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 提妲 于 2010-7-5 12:51 编辑
- #==============================================================================
- # vx呼出对话框 by 沉影不器
- #------------------------------------------------------------------------------
- # 呼出对话框原作者: パラ犬(日)
- #------------------------------------------------------------------------------
- # 『素材准备』
- # ① 按vx默认头像素材的格式,但要求每个头像文件所有8格均为同一人的表
- # 情并且所有表情朝向一致(默认是正面偏右), 以角色(对话者)名称来命
- # 名每个头像文件,用于对话框中自动生成对话者名称.
- # ② vx窗体较xp更精致,头像不宜太大.
- # 小头像不宜超过96*96; 半身像不宜超过140*140
- # ③ 呼出对话框箭头图标的命名规则为:
- # 制作上下两个对话框箭头图标, 分别命名为:
- # 您设定的对话框皮肤名称后加"_arrow_down"(对应下箭头)
- # 或"_arrow_up"(对应上箭头), 并存放在system文件夹内.
- #
- # 『脚本使用』
- # ① 复制脚本插入到Main之前.
- # ② 请务必看完脚本的设定部分,并根据游戏素材的情况设定好各参数
- # 脚本第 47-98 行为默认设定部分
- # 脚本第 107-113 行为游戏中可更改的设定部分.
- # ③ 地图上跟角色进行对话的事件名称使用与头像素材一致的名称, 即对话
- # 者的名称,以便脚本根据名称找到对应事件.
- # ④ 可在游戏中更改参数的说明:
- # ▼ 以第行的fuki_font_name举例
- # 对话之前,在事件脚本中输入$game_temp.fuki_font_name = "宋体"
- # 将把对话框使用的字体改为"宋体".
- # ▼ 以第行的face_type举例
- # 对话之前,在事件脚本中输入$game_temp.face_type = 1
- # 将把头像的水平显示位置改为"头像在右".
- # 其它可改参数同上.
- #
- # 『脚本自动完成部分的补充说明』
- # ① 根据头像的文件名自动填写对话者名称,这将占用一行对话框的位置
- # ② 脚本根据事件名称,在屏幕范围内自动查找对话者,如果对话者在范围内
- # 不存在,则使用普通对话框,自动调节对话框大小,自动水平居中显示,垂
- # 直方向仍由对话事件本身决定.
- # ③ 默认头像素材为正面偏右,当您指定头像显示在右时,脚本将对头像素材
- # 镜像处理,您的头像素材中须注意这点
- #------------------------------------------------------------------------------
- # 最后一句提示: 善用素材,配合默认设定的修改. 感谢您看完烦琐的说明.
- #==============================================================================
- #==============================================================================
- # ■ 默认设定(部分设定允许在游戏中随时更改,见脚本第 107-113 行)
- #==============================================================================
- module FUKI
- #--------------------------------------------------------------------------
- # ◎ 坐标微调
- #--------------------------------------------------------------------------
- # 对话框
- MSG_Y_ADJ = 8 # 使用呼出对话框时,角色和对话框的纵向间距
- # 头像
- FACE_X_ADJ = 8 # 头像向对话框内横向缩进(避免遮盖对话框外框)
- FACE_Y_ADJ = -2 # 头像向对话框内纵向缩进(避免遮盖对话框外框)
- # 名称背景条
- NAME_BAR_X = 6 # 名称背景条相对于对话框的起始横坐标
- # 呼出对话框箭头
- ARR0W_UP_X_ADJ = 0 # 上箭头的横向调节
- ARR0W_UP_Y_ADJ = 6 # 上箭头的纵向调节
- ARR0W_DOWN_X_ADJ = 0 # 下箭头的横向调节
- ARR0W_DOWN_Y_ADJ = -6 # 下箭头的纵向调节
- #--------------------------------------------------------------------------
- # ◎ 窗体设定
- #--------------------------------------------------------------------------
- SKIN = "window" # 设定对话框Skin
- OPACITY = 255 # 窗口透明度
- #--------------------------------------------------------------------------
- # ◎ 文字设定
- # 文字颜色说明: 使用Window_Base中text_color(n)的颜色代码
- #--------------------------------------------------------------------------
- # 字体
- FONT_NAME = "黑体" # 对话框字体
- FONT_SIZE = 14 # 对话框文字字号
- FONT_SHADOW = true # 对话框文字阴影
- # 文字颜色
- MSG_COLOR = 0 # 对话框文字颜色
- NAME_COLOR = 16 # 角色名称文字颜色
- #--------------------------------------------------------------------------
- # ◎ 头像设定
- #--------------------------------------------------------------------------
- # 头像始终在对话框内(默认使用半身像, 则为 false)
- IN_CONTENT = true
- # 头像垂直对齐方式(0: 顶端对齐; 1: 居中对齐; 2: 底端对齐)
- V_ALIGN = 2
- # 头像水平显示位置(0: 头像在左; 1: 头像在右)
- H_ALIGN = 1
- #--------------------------------------------------------------------------
- # ◎ 自动显示名称设定
- #--------------------------------------------------------------------------
- NAME_Y_ADJ = 6 # 显示名称时,对话者名称与对话内容之间的距离
- NAME_BAR_COLOR = 0 # 名称背景条颜色
- NAME_BAR_OPACITY = 72 # 名称背景条透明度
- #--------------------------------------------------------------------------
- # ◎ 附带功能设定
- #--------------------------------------------------------------------------
- # 超过指定时间,玩家无输入则自动关闭对话框(单位: 帧)
- AUTO_CLOSE_TIME = 60*60 # 默认为1分钟
- # 默认打字速度修正
- SPEED = 2
- end
- #==============================================================================
- # ■ Game_Temp
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :fuki_font_name # 呼出对话框字体
- attr_accessor :fuki_font_size # 呼出对话框字号
- attr_accessor :fuki_msg_color # 呼出对话框文字颜色
- attr_accessor :fuki_name_color # 角色名称文字颜色
- attr_accessor :face_type # 头像水平显示位置
- attr_accessor :auto_close # 对话框自动关闭时间
- attr_accessor :speed # 对话框打字速度修正
- attr_accessor :fuki_noface_name
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize
- ini
- @fuki_font_name = FUKI::FONT_NAME
- @fuki_font_size = FUKI::FONT_SIZE
- @fuki_msg_color = FUKI::MSG_COLOR
- @fuki_name_color = FUKI::NAME_COLOR
- @face_type = FUKI::H_ALIGN
- @auto_close = FUKI::AUTO_CLOSE_TIME
- @speed = FUKI::SPEED
- @fuki_noface_name=""
- end
- end
- #==============================================================================
- # ■ Game_Event
- #==============================================================================
- class Game_Event
- #--------------------------------------------------------------------------
- # ◎ 返回事件名称
- #--------------------------------------------------------------------------
- def name
- return @event.name
- end
- end
- #==============================================================================
- # ■ Window_NumberInput
- #==============================================================================
- class Window_NumberInput < Window_Base
- #--------------------------------------------------------------------------
- # ◎ 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.name = $game_temp.fuki_font_name
- self.contents.font.size = $game_temp.fuki_font_size
- self.contents.font.shadow = FUKI::FONT_SHADOW
- self.contents.font.color = normal_color
- s = sprintf("%0*d", @digits_max, @number)
- for i in 0...@digits_max
- self.contents.draw_text\
- (24 + i * 16, 0, 16, FUKI::FONT_SIZE + 2, s[i,1], 1)
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- self.cursor_rect.set(24 + @index * 16, 0, 16, FUKI::FONT_SIZE + 2)
- end
- end
- #==============================================================================
- # ■ Window_Message
- #==============================================================================
- class Window_Message < Window_Selectable
- #--------------------------------------------------------------------------
- # ◎ 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :user_cancel # 暂时使用默认对话框
- attr_accessor :face_type # 头像水平显示位置
- #--------------------------------------------------------------------------
- # ◎ 常量
- #--------------------------------------------------------------------------
- MAX_LINE = 5 # 最大行数
- #--------------------------------------------------------------------------
- # ◎ 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 288, 544, 128)
- 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 # 省略等待输入标志
- @update_pos = false # 对话框跟随开关关闭
- @show_name = false # 名称显示开关关闭
- @fuki_pause = false # 为了方便代替window类的pause
- @user_cancel = false # 暂时使用默认对话框的标志
- # 生成对象
- create_gold_window
- create_number_input_window
- create_back_sprite
- create_face_sprite # 生成头像
- create_namebar_sprite # 生成名称背景条
- create_arrow_sprite # 生成对话框箭头
- # 透明度设定
- set_opacity(self)
- set_opacity(@arrow_sprite)
- end
- #--------------------------------------------------------------------------
- # ◎ 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- dispose_gold_window
- dispose_number_input_window
- dispose_back_sprite
- dispose_face_sprite # 释放头像
- dispose_arrow_sprite # 释放对话框箭头
- end
- #--------------------------------------------------------------------------
- # ◎ 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_gold_window
- update_number_input_window
- update_back_sprite
- update_show_fast
- if @update_pos
- reset_msg_pos # 重设对话框坐标
- reset_namebar_bitmap # 重绘名称背景条
- end
- # 除窗口关闭以外
- unless @opening or @closing
- # 文章内等待中
- if @wait_count > 0
- @wait_count -= 1
- # 等待文章翻页待机中
- elsif @fuki_pause
- input_pause
- # 正在输入选择项
- elsif self.active
- input_choice
- # 正在输入数值
- elsif @number_input_window.visible
- input_number
- # 还有剩余的文章
- elsif @text != nil
- update_message # 更新消息
- # 继续的情况
- elsif continue?
- start_message # 开始消息
- reset_msg_size # 重设对话框尺寸
- reset_contents # 重设位图容器
- reset_msg_pos # 重设对话框坐标
- reset_namebar_bitmap # 重绘名称背景条
- $game_message.visible = true
- open # 打开窗口
- @face_sprite.visible = true
- # 不继续的情况
- else
- @face_sprite.visible = @closing # 关闭头像显示
- @arrow_sprite.visible = @closing # 关闭头像显示
- close # 关闭窗口
- $game_message.visible = @closing
- end
- end
- # 显示对话时,计算自动关闭时间
- if $game_message.visible
- if $game_temp.auto_close > 0
- $game_temp.auto_close -= 1
- else
- terminate_message
- end
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 还原默认设定
- #--------------------------------------------------------------------------
- def default_setting
- @user_cancel = false # 暂时使用默认对话框的标志
- $game_temp.face_type = FUKI::H_ALIGN # 头像水平显示位置
- $game_temp.speed = FUKI::SPEED # 对话打字速度修正
- $game_temp.auto_close = FUKI::AUTO_CLOSE_TIME # 自动关闭时间
- @namebar_sprite.bitmap.clear
- end
- #--------------------------------------------------------------------------
- # ◎ 头像图像预留宽度
- #--------------------------------------------------------------------------
- def face_width
- name = $game_message.face_name
- #print(name)
- return 0 if name == ""
- return Cache.face(name).width/4# + FUKI::FACE_X_ADJ
- end
- #--------------------------------------------------------------------------
- # ◎ 头像图像预留高度
- #--------------------------------------------------------------------------
- def face_height
- name = $game_message.face_name
- return 0 if name == ""
- return Cache.face(name).height/2# + FUKI::FACE_Y_ADJ
- end
- #--------------------------------------------------------------------------
- # ◎ 是否使用呼出对话框
- #--------------------------------------------------------------------------
- def use_fuki?
- # 考虑细分条件
- return false if @user_cancel # 暂时使用默认对话框的标志
- return false if get_character_pos == nil # 找不到说话者坐标时
- return true
- end
- #--------------------------------------------------------------------------
- # ● 生成所持金窗口
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_Gold.new(384, 0)
- @gold_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 生成数值输入窗口
- #--------------------------------------------------------------------------
- def create_number_input_window
- @number_input_window = Window_NumberInput.new
- @number_input_window.visible = false
- 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 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 # 判断头像是否改变
- end
- #--------------------------------------------------------------------------
- # ◎ 生成对话框箭头
- #--------------------------------------------------------------------------
- def create_arrow_sprite
- @arrow_sprite = Sprite.new
- @arrow_sprite.bitmap = Bitmap.new(1, 1)
- @arrow_sprite.z = self.z + 1
- @arrow_sprite.visible = false
- end
- #--------------------------------------------------------------------------
- # ◎ 生成名称背景条
- #--------------------------------------------------------------------------
- def create_namebar_sprite
- @namebar_sprite = Sprite.new
- @namebar_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- @namebar_sprite.z = self.z + 1
- end
- #--------------------------------------------------------------------------
- # ◎ 释放名称背景条
- #--------------------------------------------------------------------------
- def dispose_namebar_sprite
- @namebar_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ◎ 释放对话框箭头
- #--------------------------------------------------------------------------
- def dispose_arrow_sprite
- @arrow_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ◎ 释放头像
- #--------------------------------------------------------------------------
- def dispose_face_sprite
- @face_sprite.dispose
- 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 @fuki_pause or self.openness < 255
- @show_fast = false
- elsif Input.trigger?(Input::C) and @wait_count < 2
- @show_fast = true
- 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
- @show_name = false
- if $game_message.face_name.empty? and $game_temp.fuki_noface_name!=""
-
- text = "\\C[#{$game_temp.fuki_name_color}]" +
- $game_temp.fuki_noface_name.to_s + ":" +
- "\\C[#{$game_temp.fuki_msg_color}]"
- $game_message.texts.unshift(text)
- @show_name = true
- end
- # 重新初始化名称标志
- unless $game_message.face_name.empty?
- # 新增名称并设定文字颜色
- text = "\\C[#{$game_temp.fuki_name_color}]" +
- $game_message.face_name.to_s + ":" +
- "\\C[#{$game_temp.fuki_msg_color}]"
- $game_message.texts.unshift(text)
- @show_name = true # 设定名称标志
- end
- @text = ""
- for i in 0...$game_message.texts.size
- @text += " " if i >= $game_message.choice_start
- @text += $game_message.texts[i].clone + "\x00"
- end
- @item_max = $game_message.choice_max
- convert_special_characters
- new_page
- @update_pos = true # 对话框跟随开关关闭
- end
- #--------------------------------------------------------------------------
- # ◎ 更换页面处理
- #--------------------------------------------------------------------------
- def new_page
- contents.clear
- if $game_message.face_name.empty? # 清除上一次的头像
- @contents_x = 0
- @face_sprite.bitmap.dispose unless @face_sprite.bitmap.disposed?
- else # 初始化头像重绘环境
- name = $game_message.face_name
- index = $game_message.face_index
- if @old_name != name or @old_index != index
- @old_name = name
- @old_index = index
- end
- draw_fuki_face(name, index) # 重绘头像
- @contents_x = face_width # 根据头像修正横坐标
- 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
- if $game_message.face_name.empty?
- @contents_x = 0
- else
- name = $game_message.face_name
- @contents_x = face_width
- end
- @contents_y += FUKI::FONT_SIZE + 2
- @line_count += 1
- @line_show_fast = false
- end
- #--------------------------------------------------------------------------
- # ● 特殊文字变换
- #--------------------------------------------------------------------------
- def convert_special_characters
- @text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
- @text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
- @text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
- @text.gsub!(/\\C\[([0-9]+)\]/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!(/\\\\/) { "\\" }
- end
- #--------------------------------------------------------------------------
- # ◎ 重绘名称背景条
- #--------------------------------------------------------------------------
- def reset_namebar_bitmap
- @namebar_sprite.bitmap.clear # 重绘之前清理名称背景条
- return if $game_message.face_name.empty? and $game_temp.fuki_noface_name=="" # 无名称时不描绘
- rect = Rect.new(0, 0, 0, 0)
- rect.x = self.x + FUKI::NAME_BAR_X
- rect.y = self.y + 16
- rect.width = self.width - FUKI::NAME_BAR_X * 2
- rect.height = FUKI::FONT_SIZE + 2
- color1 = text_color(FUKI::NAME_BAR_COLOR)
- color2 = text_color(FUKI::NAME_BAR_COLOR)
- color1.alpha = FUKI::NAME_BAR_OPACITY
- color2.alpha = 0
- # 渐变条
- @namebar_sprite.bitmap.gradient_fill_rect(rect, color1, color2)
- end
- #--------------------------------------------------------------------------
- # ◎ 设置窗口背景与位置
- #--------------------------------------------------------------------------
- def reset_window
- self.pause = true
- @background = $game_message.background
- @position = $game_message.position
- if @background == 0 # 普通窗口
- set_opacity(self) # 透明度设定
- else # 背景变暗、透明
- self.opacity = 0
- end
- # 窗口水平居中
- self.x = (544 - self.width) / 2
- case @position
- when 0 # 上
- if FUKI::IN_CONTENT
- self.y = 8
- else
- if FUKI::V_ALIGN == 2
- self.y = [face_height, self.height].max - self.height + 8
- else
- self.y = 8
- end
- end
- @gold_window.y = 360
- when 1 # 中
- self.y = (Graphics.height - self.height) / 2
- @gold_window.y = 0
- when 2 # 下
- if FUKI::V_ALIGN == 0 and face_height > 0
- self.y = \
- Graphics.height - [face_height, self.height].max - self.height*2 - 8
- else
- self.y = Graphics.height - self.height - 8
- end
- @gold_window.y = 0
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 预提取文本
- #--------------------------------------------------------------------------
- def get_message
- text = []
- for i in 0...$game_message.texts.size
- text[i] = ""
- text[i] += " " if i >= $game_message.choice_start
- text[i] += $game_message.texts[i].clone
- text[i].gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
- text[i].gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
- text[i].gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
- text[i].gsub!(/\\C\[([0-9]+)\]/i) { "" }
- text[i].gsub!(/\\G/) { "" }
- text[i].gsub!(/\\\./) { "" }
- text[i].gsub!(/\\\|/) { "" }
- text[i].gsub!(/\\!/) { "" }
- text[i].gsub!(/\\>/) { "" }
- text[i].gsub!(/\\</) { "" }
- text[i].gsub!(/\\\^/) { "" }
- text[i].gsub!(/\\\\/) { "\\" }
- end
- return text
- end
- #--------------------------------------------------------------------------
- # ◎ 获取窗口尺寸
- #--------------------------------------------------------------------------
- def get_window_size
- contents.font.name = $game_temp.fuki_font_name
- contents.font.size = $game_temp.fuki_font_size
- w = h = 0 # 初始化长宽
- text_con = get_message
- for text in text_con
- x = @contents_x
- loop do
- c = text.slice!(/./m) # 获取下一个文字
- case c
- when nil # 没有可以显示的文字
- break
- else # 普通文字
- c_width = contents.text_size(c).width
- x += c_width
- end
- end
- w = [x, w].max
- if $game_message.face_name.empty?
- h = $game_message.texts.size * (FUKI::FONT_SIZE + 2) + 32
- else
- if FUKI::IN_CONTENT
- h_min = face_height + FUKI::FACE_Y_ADJ
- h = [h_min, text_con.size*(FUKI::FONT_SIZE + 2) + 32].max
- else
- h = [48, text_con.size*(FUKI::FONT_SIZE + 2) + 32].max
- end
- end
- end
- # 调整名称显示的高度差
- h += FUKI::NAME_Y_ADJ if @show_name
- # 输入数值的情况
- if $game_message.num_input_variable_id > 0
- w = [w, 24 + $game_message.num_input_digits_max * 16 + face_width].max
- # 预留数值窗口高度
- h += FUKI::FONT_SIZE + 2
- # 避开空对话内容的情况
- h = [h, @number_input_window.height].max
- end
- return w-16, h
- end
- #--------------------------------------------------------------------------
- # ◎ 重设位图容器
- #--------------------------------------------------------------------------
- def reset_contents
- self.contents.dispose
- self.contents = Bitmap.new(self.width - 32, self.height - 32)
- end
- #--------------------------------------------------------------------------
- # ◎ 重设对话框尺寸
- #--------------------------------------------------------------------------
- def reset_msg_size
- size = get_window_size
- self.width = size[0] + 48
- self.height = size[1]
- end
- #--------------------------------------------------------------------------
- # ◎ 重设对话框坐标
- #--------------------------------------------------------------------------
- def reset_msg_pos
- self.pause = false if use_fuki? # 关闭暂停标志
- # 调整对话框坐标
- pos = get_character_pos
- case pos
- when nil # 当前屏幕无对话角色时
- @arrow_sprite.visible = false
- reset_window
- unless $game_message.face_name.empty?
- set_face(0)
- end
- else
- # X 坐标
- if pos[0] < 0
- self.x = 0
- elsif pos[0] > Graphics.width - self.width
- self.x = Graphics.width - self.width
- else
- self.x = pos[0]
- end
- # Y 坐标 ◎
- compare = FUKI::IN_CONTENT ? self.height : face_height
-
- if pos[1] < compare
- self.y = pos[1] + self.height + FUKI::MSG_Y_ADJ
- # 调整对话框箭头
- set_arrow(0, pos)
- else
- self.y = pos[1] - pos[2] - FUKI::MSG_Y_ADJ
- # 调整对话框箭头
- set_arrow(1, pos)
- end
- end
- # 调整头像
- unless $game_message.face_name.empty?
- set_face(1)
- # 调整数据输入窗体坐标
- end
- set_input_window(x, y, $game_temp.face_type)
- end
- #--------------------------------------------------------------------------
- # ◎ 调整数值输入
- # align : 对齐方式 (1:左 ;0:右)
- # 和头像相反方向
- #--------------------------------------------------------------------------
- def set_input_window(x, y, align)
- return unless @number_input_window.active
- case align
- when 1
- @number_input_window.x = x
- @number_input_window.y = y + @contents_y
- when 0
- @number_input_window.x = x + face_width
- @number_input_window.y = y + @contents_y
- end
- @number_input_window.visible = true
- end
- #--------------------------------------------------------------------------
- # ◎ 调整对话框箭头#######
- # type : 上下标志 (0: 箭头在上; 1: 箭头在下)
- # pos : 坐标数组 (get_character_pos)
- #--------------------------------------------------------------------------
- def set_arrow(type, pos)
- return if pos == nil
- if type == 0
- arrow_name = FUKI::SKIN + "_arrow_up.png"
- @arrow_sprite.bitmap = Cache.system(arrow_name)
- @arrow_sprite.x = pos[0] + (self.width / 2) + FUKI::ARR0W_UP_X_ADJ
- @arrow_sprite.y = self.y - @arrow_sprite.height + FUKI::ARR0W_UP_Y_ADJ
- else
- arrow_name = FUKI::SKIN + "_arrow_down.png"
- @arrow_sprite.bitmap = Cache.system(arrow_name)
- @arrow_sprite.x = pos[0] + (self.width / 2) + FUKI::ARR0W_DOWN_X_ADJ
- @arrow_sprite.y = self.y + self.height + FUKI::ARR0W_DOWN_Y_ADJ
- end
- @arrow_sprite.visible = true
- end
- #--------------------------------------------------------------------------
- # ◎ 调整头像
- # type : 头像位置标志 (0:普通对话框 ;1:呼出对话框)
- #--------------------------------------------------------------------------
- def set_face(type)
- case type
- when 0 # 普通对话框
- if $game_temp.face_type == 0
- @face_sprite.x = 16
- @face_sprite.mirror = false
- else
- @face_sprite.x = self.width - face_width
- @face_sprite.mirror = true
- end
- @face_sprite.y = self.y + 16
- when 1 # 呼出对话框
- # 调整横坐标
- case $game_temp.face_type
- when 0
- @face_sprite.x = self.x + FUKI::FACE_X_ADJ
- @face_sprite.mirror = false
- when 1
- @face_sprite.x = self.x + self.width - face_width - FUKI::FACE_X_ADJ
- @face_sprite.mirror = true
- end
- # 调整纵坐标
- case FUKI::V_ALIGN
- when 0
- @face_sprite.y = self.y
- when 1
- @face_sprite.y = self.y + (self.height - face_height)/2
- when 2
- @face_sprite.y = self.y + self.height - face_height
- end
- @face_sprite.y += FUKI::FACE_Y_ADJ
- # 头像在对话框内的情况
- @face_sprite.y = self.y + FUKI::FACE_Y_ADJ if FUKI::IN_CONTENT
- end
- # 打开头像显示
- @face_sprite.visible = true
- end
- #--------------------------------------------------------------------------
- # ◎ 设定透明名
- # target : 对象
- #--------------------------------------------------------------------------
- def set_opacity(target)
- target.opacity = FUKI::OPACITY
- end
- #--------------------------------------------------------------------------
- # ◎ 事件是否在屏幕范围内
- # event : 事件
- #--------------------------------------------------------------------------
- def within_screen_range?(event)
- # 考虑到某些长得比较高的事件
- height = Cache.character(event.character_name).height
- y_plus = event.character_name.include?('!$') ? height/4 : height/8
- range_x = (0..Graphics.width).include?(event.screen_x)
- range_y = (0..Graphics.height + y_plus).include?(event.screen_y)
- return range_x && range_y
- end
- #--------------------------------------------------------------------------
- # ◎ 获取角色坐标
- #--------------------------------------------------------------------------
- def get_character_pos
- # 使用呼出对话框时
-
- if $game_message.face_name.empty? and $game_temp.fuki_noface_name!=""
-
- for event in $game_map.events.values
- next unless within_screen_range?(event)
- if event.name == $game_temp.fuki_noface_name
- x = event.screen_x - (self.width / 2)
- y = event.screen_y - self.height
- height = Cache.character(event.character_name).height
- y_plus = event.character_name.include?('!$') ? height/4 : height/8
- return x, y, y_plus
- end
- end
- end
-
- unless $game_message.face_name.empty? # 待改为@texts判断
- # 事件时
- for event in $game_map.events.values
- next unless within_screen_range?(event)
- if event.name == $game_message.face_name
- x = event.screen_x - (self.width / 2)
- y = event.screen_y - self.height
- height = Cache.character(event.character_name).height
- y_plus = event.character_name.include?('!$') ? height/4 : height/8
- return x, y, y_plus
- end
- end
- # 玩家时
- for member in $game_party.members
- if member.name == $game_message.face_name
- x = $game_player.screen_x - (self.width / 2)
- y = $game_player.screen_y - self.height
- height = Cache.character(member.character_name).height
- y_plus = member.character_name.include?('!$') ? height/4 : height/8
- return x, y, y_plus
- end
- end
- end
- # 无坐标时
- return nil
- end
- #--------------------------------------------------------------------------
- # ◎ 描绘脸谱
- # face_name : 脸谱图像文件名
- # face_index : 脸谱图像索引
- #--------------------------------------------------------------------------
- def draw_fuki_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)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 消息结束
- #--------------------------------------------------------------------------
- def terminate_message
- self.active = false
- @fuki_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
- @face_sprite.visible = false
- @update_pos = false # 对话框跟随开关关闭
- default_setting # 还原默认设定
- end
- #--------------------------------------------------------------------------
- # ◎ 更新消息
- #--------------------------------------------------------------------------
- def update_message
- # 字体设定
- contents.font.name = $game_temp.fuki_font_name
- contents.font.size = $game_temp.fuki_font_size
- contents.font.shadow = FUKI::FONT_SHADOW
- loop do
- c = @text.slice!(/./m) # 获取下一条文字
- case c
- when nil # 没有可以显示的文字
- finish_message # 更新结束
- break
- when "\x00" # 换行
- # 调整名称显示的高度
- if @show_name
- @show_name = false
- @contents_y += FUKI::NAME_Y_ADJ
- end
- new_line
- if @line_count >= MAX_LINE # 行数为最大时
- unless @text.empty? # 如果还有增加则继续
- @fuki_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" # \! (等待输入)
- @fuki_pause = true
- break
- when "\x06" # \> (瞬间显示 ON)
- @line_show_fast = true
- when "\x07" # \< (瞬间显示 OFF)
- @line_show_fast = false
- when "\x08" # \^ (不等待输入)
- @pause_skip = true
- else # 普通文字
- @wait_count = $game_temp.speed # 对话框打字速度修正
- # 判断头像对文字的影响
- case $game_temp.face_type
- when 0
- contents.draw_text\
- (@contents_x, @contents_y, 40, FUKI::FONT_SIZE + 2, c)
- when 1
- contents.draw_text\
- (@contents_x - face_width, @contents_y, 40, FUKI::FONT_SIZE + 2, 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
- @fuki_pause = true
- end
- @wait_count = 10
- @text = 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
- @number_input_window.y = y + @contents_y
- @number_input_window.active = true
- @number_input_window.update
- end
- #--------------------------------------------------------------------------
- # ◎ 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- if @index >= 0
- # 获取光标的横坐标
- if $game_message.face_name.empty? or FUKI::H_ALIGN == 1
- x = 0
- else
- x = face_width
- end
- # 获取光标的纵坐标
- y = ($game_message.choice_start + @index) * (FUKI::FONT_SIZE + 2)
- # 修正名称行
- unless $game_message.face_name.empty?
- y += FUKI::NAME_Y_ADJ + FUKI::FONT_SIZE + 2
- end
- width = contents.width - face_width
- self.cursor_rect.set(x, y, width, FUKI::FONT_SIZE + 2)
- else
- self.cursor_rect.empty
- end
- end
- #--------------------------------------------------------------------------
- # ● 文章显示输入处理
- #--------------------------------------------------------------------------
- def input_pause
- if Input.trigger?(Input::B) or Input.trigger?(Input::C)
- @fuki_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
- end
复制代码 我通过在游戏中给$game_temp.fuki_noface_name赋值的方式得到事件的坐标,从而使用FUKI对话框。可使用后没有 头像 的对话框显示不出对话框背景,这是怎么回事?跪求一老师指导改错!!!!!!!!!! |
|