| 赞 | 120 |
| VIP | |
| 好人卡 | |
| 积分 | 194 |
| 经验 | |
| 最后登录 | 2026-7-4 |
| 在线时间 | 3082 小时 |
- 梦石
- 0
- 星屑
- 19426
- 在线时间
- 3082 小时
- 注册时间
- 2013-1-11
- 回帖
- 1207
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 张咚咚 于 2019-1-25 15:47 编辑
脚本内容- #encoding:utf-8
- #==============================================================================
- # ■ Log信息提示v1.1 By_QQEat
- #
- # 说明:提示信息使用。
- # 依赖:此脚本需依赖 【Timer_定时器】脚本。
- # 地址:http://rpg.blue/home.php?mod=space&uid=326184&do=blog&id=16491
- #
- # [创建/更新/释放]
- #
- # @log = Log.new
- # @log.update
- # @log.dispose
- #
- # [使用]
- #
- # @log.add({
- # text: 'message', # 提示信息
- # font: '黑体', # 字体名称
- # size: 24, # 字体大小
- # color: color, # 字体颜色
- # background: color, # 背景颜色
- # lineColor: color, # 边缘颜色
- # clear: 180, # 消失帧数
- # format: 0, # 格式(0普通, 1支持字符格式)
- # viewport: viewport, # 显示端口
- # location: 1, # 显示位置(0:左下, 1右下)
- # moveType: 'in-bounce', # 弹出方式('in-/out-/in-out-/out-in-' + 'quad/cubic/quart/quint/sine/expo/circ/back/bounce/elastic')
- # moveSpeed: 40, # 弹出速度
- # })
- #
- # [内容字符支持格式]
- #
- # \n 换行
- # \\c[x] 更改颜色
- # \\i[x] 绘制图标
- # \\{ 字体增大 8 号
- # \\} 字体缩小 8 号
- #
- # [范例]
- #
- # @log.add({text: '提示信息'})
- #
- # [全局使用]
- #
- # $log.add({text: '全局提示信息'})
- #
- #==============================================================================
- class Log
- attr_accessor :logs
- def initialize
- @logs = []
- end
- def update
- @logs.each do |log|
- log.update
- if log.dead
- log.dispose
- @logs.delete(log)
- end
- end
- end
- def dispose
- @logs.each(&:dispose)
- end
- def add(set={})
- # 默认参数,在这里修改
- text = set[:text] || ''
- font = set[:font]
- size = set[:size] || 24
- color = set[:color] || Color.new(255,255,255)
- background = set[:background] || Color.new(0,0,0,125)
- lineColor = set[:lineColor] || Color.new(255,255,255)
- clear = set[:clear] || 180
- format = set[:format] || 0
- viewport = set[:viewport]
- location = set[:location] || 1
- moveType = set[:moveType] || 'in-bounce'
- moveSpeed = set[:moveSpeed] || 40
- @logs.push LogText.new(text, font, size, color, background, lineColor, clear, format, viewport, location, moveType, moveSpeed)
- @logs.each{|l| l.move_up(@logs[-1]) if l.viewport == viewport }
- end
- end
- class LogText < Sprite_Base
- attr_accessor :dead
- def initialize(text, font, size, color, background, lineColor, clear, format, viewport, location, moveType, moveSpeed)
- super(viewport)
- # 属性设置
- tmpBitmap = (Bitmap.new(1,1).tap do |b| b.font.size = size end)
- if format = 1 # 字符处理
- arrStr,arrWid = text.dup.split("\n"),[]
- # 计算每行宽度,取最大宽度的那行
- arrStr.each_with_index{|s,i|
- arrWid[i] = 0
- s.gsub!(/\\(.)(\[(\d)+\])?/){arrWid[i]+=$1.upcase=='I'?24:0;''}
- arrWid[i] += tmpBitmap.text_size(s).width
- }
- rect = Rect.new(0,0, arrWid.max, arrStr.size*(size||24))
- else
- tmpBitmap.text_size(text)
- end
- self.bitmap = Bitmap.new(rect.width + 24, rect.height + 24)
- self.bitmap.font.name = font if font
- self.bitmap.font.size = size if size
- self.bitmap.fill_rect(self.bitmap.rect, background) if background
- if lineColor
- self.bitmap.fill_rect(0,0,1,self.bitmap.height, lineColor)
- self.bitmap.fill_rect(self.bitmap.width-1,0,1,self.bitmap.height, lineColor)
- end
- self.bitmap.font.color = color if color
-
- # 文字绘制
- case format
- when 0
- self.bitmap.draw_text(self.bitmap.rect, text, 1)
- when 1
- temp = Sprite.new
- temp.bitmap = self.bitmap.dup
- temp.bitmap.clear
- temp.draw_text_ex_drawLog(self.bitmap.rect, text.dup)
- self.bitmap.blt((self.width-rect.width)/2, (self.height-rect.height)/2, temp.bitmap, temp.bitmap.rect)
- temp.dispose
- end
-
- # 显示位置
- self.x = case location
- when 0; (viewport.nil? ? 0 : viewport.rect.x) + 10
- when 1; (viewport.nil? ? Graphics.width : viewport.rect.width) - (self.width + 5)
- end
- self.y = (viewport.nil? ? Graphics.height : viewport.rect.height)
- self.z = 99999999
-
- # 滑动
- @timer = Timer.new
- @clear, @moveType, @moveSpeed = clear, moveType, moveSpeed
- end
- def update
- super
- @timer.update
- self.dead = true if self.y + self.height < 0
- end
- def dispose
- super
- @timer.dispose
- end
- def move_up(obj)
- @timer.tween(@moveSpeed || 30, self, {y: self.y - (obj.height + 5)}, @moveType)
- @timer.after(@clear, proc{
- @timer.tween(30, self, {opacity: 0}, 'linear', proc{ self.dead = true })
- })
- end
- end
- class Sprite
- #--------------------------------------------------------------------------
- # ● 绘制带有控制符的文本内容
- #--------------------------------------------------------------------------
- def draw_text_ex_drawLog(*args)
- case args.size
- when 2
- x, y, w, h, text = args[0].x,args[0].y,args[0].width,args[0].height,args[1]
- when 5
- x, y, w, h, text = *args
- else
- p '信息框内容格式 1 绘制参数传递错误'
- return
- end
- text.gsub!(/\\/) { "\e" }
- text.gsub!(/\e\e/) { "\" }
- pos = {:x => x, :y => y, :new_x => x, :height => [24, self.bitmap.font.size].max}
- until text.empty?
- process_new_line = Proc.new{
- pos[:x] = pos[:new_x]
- pos[:y] += pos[:height]
- pos[:height] = [24, self.bitmap.font.size].max
- }
- c = text.slice!(0, 1)
- case c
- when "\r" # 回车
- return
- when "\n" # 换行
- process_new_line.call
- when "\e" # 控制符
- code = text.slice!(/^[\$\.\|\^!><\{\}\\]|^[A-Z]+/i)
- param = Proc.new{|s| s.slice!(/^\[\d+\]/)[/\d+/].to_i rescue 0 }
- case code.upcase
- when 'C'
- n = param.call text
- self.bitmap.font.color = Cache.system("Window").get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
- when 'I'
- icon_index = param.call text
- icon_bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- process_new_line.call if pos[:x] + rect.width >= w
- self.bitmap.blt(pos[:x], pos[:y], icon_bitmap, rect, 255)
- pos[:x] += rect.width
- when '{'
- self.bitmap.font.size += 8 if self.bitmap.font.size <= 64
- pos[:height] = [24, self.bitmap.font.size].max
- when '}'
- self.bitmap.font.size -= 8 if self.bitmap.font.size >= 16
- pos[:height] = [24, self.bitmap.font.size].max
- end
- else # 普通文字
- text_width = self.bitmap.text_size(c).width
- process_new_line.call if pos[:x] + text_width >= w
- self.bitmap.draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
- pos[:x] += text_width
- end
- end
- return pos[:x],pos[:y] + pos[:height]
- end
- end
- class << Input
- alias :qqeat_log_input_update :update unless $@
- def update
- $log ||= Log.new
- $log.update
- qqeat_log_input_update
- end
- end
复制代码
更新内容
【v1.1更新_2019.01.25】
1.新增更多参数并支持特殊字符。
2.使用$log可以全局调用。
旧版下载链接
提示信息使用...
范例下载:
[RM]Log信息提示v1.1.7z
(1.41 MB, 下载次数: 215)
|
评分
-
查看全部评分
|