#==============================================================================
# ■ Window_Down
#------------------------------------------------------------------------------
# 信息窗口。Instant_Messaging
#==============================================================================
class Window_Instant_Messaging < Window_Selectable
# 显示行数数列
INSTANT_SIZE = 10
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 设置窗口坐标,和窗口大小
super(0, 250, 330, 240)
# 绝对透明处理
self.opacity = 0
# 激活处理
self.active = false
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(count = 0)
if $old_messaging.size > 0
# 如果hash表的键值数值大于显示的所能容下的行数
if $old_messaging.size > INSTANT_SIZE
# 计算多出来的部分
@size = INSTANT_SIZE
@count = $old_messaging.size
@count -= INSTANT_SIZE
else
# 如果没有超过…就返回0
@size = $old_messaging.size
@count = 0
end
self.contents = Bitmap.new(width - 32, INSTANT_SIZE * 16)
# 清理不需要的字符串--清楚多出来的字
self.contents.clear
@count_no = 0
# 循环处理能够显示的
for i in 0...@size
if i + count + @count >= 0
@no = i + count + @count
# 变量 = 键值
item = $old_messaging[@no]
x = 0
y = (i - @count_no) * 16 # ----显示"常量:INSTANT_SIZE"行,不介意很大
# 显示键值
self.contents.font.size = 14
self.contents.font.color = Color.new(-170,-170,-170,255)
self.contents.draw_text(x + 6, y + 1, self.contents.text_size(item).width, 16, item, 0)
self.contents.font.color = normal_color
self.contents.draw_text(x + 5, y, self.contents.text_size(item).width, 16, item, 0)
end
end
end
end
#--------------------------------------
# ● 刷新光标
#--------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
# cursor_width = 0
# 计算光标坐标
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 32 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, self.width - 32, 96)
end
end
#-------------------------------------------------------------------------------
# □ Game_Instant_Messaging处理即时信息的系统类
#-------------------------------------------------------------------------------
# 从游戏重新开始 或者是 游戏读档 都会工作,如果清除过那么自己看效果吧
class Game_Instant_Messaging
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
# 生成即时信息显示窗口
@instant_messaging_window = Window_Instant_Messaging.new
@instant_messaging_window.z = -1
@instant_messaging_window.index = -1
@instant_messaging_window.active = @look = false
@count = 0
end
#--------------------------------------------------------------------------
# ● 刷新 $game_instant_messaging.update
#--------------------------------------------------------------------------
def update
@instant_messaging_window.refresh
@instant_messaging_window.update
end
#--------------------------------------------------------------------------
# ● 清除 $game_instant_messaging.clear
#--------------------------------------------------------------------------
def clear
@instant_messaging_window.dispose
end
#--------------------------------------------------------------------------
# ● 设置即时消息 $game_instant_messaging.setup("你好") or
# ● 用法: messagin = "你好"
# $game_instant_messaging.setup(messagin)
#--------------------------------------------------------------------------
def setup(messaging)
$old_messaging[$old_messaging.size] = messaging
end
#--------------------------------------------------------------------------
# ● 往上查看(查看过期信息) $game_instant_messaging.up
#--------------------------------------------------------------------------
def up
@size = 0 - $old_messaging.size + 11
if @count >= @size
@count -= 1
end
@instant_messaging_window.refresh(@count)
@instant_messaging_window.update
end
#--------------------------------------------------------------------------
# ● 往下查看---不能超过0--超过0后果自付 $game_instant_messaging.down
#--------------------------------------------------------------------------
def down
if @count < 0
@count += 1
end
@instant_messaging_window.refresh(@count)
@instant_messaging_window.update
end
end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |