赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 498 |
最后登录 | 2013-8-6 |
在线时间 | 19 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 19 小时
- 注册时间
- 2013-7-21
- 帖子
- 18
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
希望对大家有一点点的帮助。- #encoding:utf-8
- #==============================================================================
- # ■ Message_Advanced
- #------------------------------------------------------------------------------
- # 使对话框略微美观一点
- # 调用方式:在对话内容的第一行输入“l/r”+“对话者姓名”
- # l和r表示头像在左边或者右边显示,对话者姓名显示在头像下方
- # 第一行输入“no”则为取消使用
- #==============================================================================
- class Game_Message
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :talker_name # 说话者姓名
- attr_reader :talker_mirror # 是否镜象显示
- #--------------------------------------------------------------------------
- # ● 清除
- #--------------------------------------------------------------------------
- def clear
- @texts = []
- @choices = []
- # 初始化
- @talker_name = ""
- @talker_mirror = false
- @face_name = ""
- @face_index = 0
- @background = 0
- @position = 2
- @choice_cancel_type = 0
- @choice_proc = nil
- @num_input_variable_id = 0
- @num_input_digits_max = 0
- @item_choice_variable_id = 0
- @scroll_mode = false
- @scroll_speed = 2
- @scroll_no_fast = false
- end
- #--------------------------------------------------------------------------
- # ● 获取包括换行符的所有内容
- #--------------------------------------------------------------------------
- def all_text
- # 当不取消时执行处理
- if @texts[0] != "no"
- # 当输入的内容包含说话者姓名时
- if @texts.size > 1
- # 取出第一个字符
- ch = @texts[0].slice!(0, 1)
- # 当右侧显示头像时设置mirror标志
- @talker_mirror = true if ch == "r"
- @talker_name = "[" + @texts[0] + "]"
- # 当输入的内容不包含说话者姓名时
- else
- @talker_name = "未定义"
- end
- end
- # 删除第一行控制内容
- @texts.delete_at(0)
- @texts.inject("") {|r, text| r += text + "\n" }
- end
- end
- class Window_Message < Window_Base
- #--------------------------------------------------------------------------
- # ● 处理纤程的主逻辑
- #--------------------------------------------------------------------------
- def fiber_main
- $game_message.visible = true
- update_background
- update_placement
- loop do
- # 生成显示精灵
- @face_sprite = Sprite.new
- @name_sprite = Sprite.new
- process_all_text if $game_message.has_text?
- process_input
- # 将显示精灵释放
- @face_sprite.dispose
- @name_sprite.dispose
- $game_message.clear
- @gold_window.close
- Fiber.yield
- break unless text_continue?
- end
- close_and_wait
- $game_message.visible = false
- @fiber = nil
- end
- #--------------------------------------------------------------------------
- # ● 翻页处理
- #--------------------------------------------------------------------------
- def new_page(text, pos)
- contents.clear
- if !$game_message.talker_name.empty?
- # 判断左右侧显示
- if $game_message.talker_mirror
- draw_face_right($game_message.face_name,$game_message.face_index)
- draw_name_right($game_message.talker_name)
- else
- draw_face_left($game_message.face_name,$game_message.face_index)
- draw_name_left($game_message.talker_name)
- end
- else
- draw_face($game_message.face_name, $game_message.face_index, 0, 0)
- end
- reset_font_settings
- pos[:x] = new_line_x
- pos[:y] = 0
- pos[:new_x] = new_line_x
- pos[:height] = calc_line_height(text)
- clear_flags
- end
- #--------------------------------------------------------------------------
- # ● 显示说话者脸图(左)
- #--------------------------------------------------------------------------
- def draw_face_left(face_name, face_index)
- # 取出图片
- source = Cache.face(face_name)
- # 找到脸图位置
- rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
- bitmap = Bitmap.new(96, 96)
- # 复制到bitmap中
- bitmap.blt(0, 0, source, rect)
- # 计算精灵位置并显示
- @face_sprite.x = standard_padding
- @face_sprite.y = Graphics.height - 96 - standard_padding - line_height
- @face_sprite.z = 1000
- @face_sprite.bitmap = bitmap
- end
- #--------------------------------------------------------------------------
- # ● 显示说话者脸图(右)
- #--------------------------------------------------------------------------
- def draw_face_right(face_name, face_index)
- source = Cache.face(face_name)
- rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
- bitmap = Bitmap.new(96, 96)
- bitmap.blt(0, 0, source, rect)
- @face_sprite.x = Graphics.width - 96 - standard_padding
- @face_sprite.y = Graphics.height - 96 - standard_padding - line_height
- @face_sprite.z = 1000
- # 设置为右侧显示
- @face_sprite.mirror = true
- @face_sprite.bitmap = bitmap
- end
- #--------------------------------------------------------------------------
- # ● 显示说话者姓名图(左)
- #--------------------------------------------------------------------------
- def draw_name_left(talker_name)
- bitmap = Bitmap.new(96, line_height)
- # 描绘姓名图像
- bitmap.draw_text(bitmap.rect, talker_name, 1)
- # 计算精灵位置并显示
- @name_sprite.x = standard_padding
- @name_sprite.y = Graphics.height - standard_padding - line_height
- @name_sprite.z = 1000
- @name_sprite.bitmap = bitmap
- end
- #--------------------------------------------------------------------------
- # ● 显示说话者姓名图(右)
- #--------------------------------------------------------------------------
- def draw_name_right(talker_name)
- bitmap = Bitmap.new(96, line_height)
- bitmap.draw_text(bitmap.rect, talker_name, 1)
- @name_sprite.x = Graphics.width - 96 - standard_padding
- @name_sprite.y = Graphics.height - standard_padding - line_height
- @name_sprite.z = 1000
- @name_sprite.bitmap = bitmap
- end
- #--------------------------------------------------------------------------
- # ● 获取换行位置
- #--------------------------------------------------------------------------
- def new_line_x
- if !$game_message.talker_mirror
- return $game_message.face_name.empty? ? 0 : 112
- # 右侧显示时,换行显示位置为行首
- else
- return 0
- end
- end
- end
复制代码 |
|