Skip to content
Snippets Groups Projects
Commit a2181790 authored by dg's avatar dg
Browse files

There is now a "tome" and a "tome-spoiler" ingame channels

When messages appear in the non-current channels their button will glow and the messages will not be put in the game log


git-svn-id: http://svn.net-core.org/repos/t-engine4@3573 51575b47-30f0-44d4-a5cc-537603b46e54
parent 01d3faec
No related branches found
No related tags found
No related merge requests found
......@@ -279,6 +279,8 @@ function _M:instanciate(mod, name, new_game, no_reboot)
profile.chat:setupOnGame()
profile.chat:join("global")
profile.chat:join(mod.short_name)
profile.chat:join(mod.short_name.."-spoiler")
profile.chat:selectChannel(mod.short_name)
end
-- Disable the profile if ungood
......
......@@ -51,11 +51,12 @@ function _M:setupOnGame()
if ok and UC then self.uc_ext = UC.new(self) end
end
function _M:addMessage(channel, login, name, msg, extra_data)
function _M:addMessage(channel, login, name, msg, extra_data, no_change)
local log = self.channels[channel].log
table.insert(log, 1, {login=login, name=name, msg=msg, extra_data=extra_data})
while #log > self.max do table.remove(log) end
self.changed = true
if not no_change and channel ~= self.cur_channel then self.channels[channel].changed = true self.channels_changed = true end
end
function _M:event(e)
......@@ -65,16 +66,16 @@ function _M:event(e)
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self:addMessage(e.channel, e.login, e.name, e.msg)
if type(game) == "table" and game.logChat then
if type(game) == "table" and game.logChat and self.cur_channel == e.channel then
game.logChat("#YELLOW#<%s> %s", e.name, e.msg)
end
elseif e.se == "Achievement" then
e.msg = e.msg:removeColorCodes()
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self:addMessage(e.channel, e.login, e.name, "#{italic}##LIGHT_BLUE#has earned the achievement <"..e.msg..">#{normal}#")
self:addMessage(e.channel, e.login, e.name, "#{italic}##LIGHT_BLUE#has earned the achievement <"..e.msg..">#{normal}#", nil, true)
if type(game) == "table" and game.logChat then
if type(game) == "table" and game.logChat and self.cur_channel == e.channel then
game.logChat("#LIGHT_BLUE#%s has earned the achievement <%s>", e.name, e.msg)
end
elseif e.se == "SerialData" then
......@@ -86,7 +87,7 @@ function _M:event(e)
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.login] = {name=e.name, login=e.login}
self.channels_changed = true
self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has joined the channel#{normal}#")
self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has joined the channel#{normal}#", nil, true)
if type(game) == "table" and game.logChat and e.channel == self.cur_channel then
game.logChat("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.login, e.channel)
end
......@@ -95,7 +96,7 @@ function _M:event(e)
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.login] = nil
self.channels_changed = true
self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has left the channel#{normal}#")
self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has left the channel#{normal}#", nil, true)
if type(game) == "table" and game.logChat and e.channel == self.cur_channel then
game.logChat("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.login, e.channel)
end
......@@ -133,6 +134,7 @@ end
function _M:selectChannel(channel)
if not self.channels[channel] then return end
self.channels[channel].changed = false
self.cur_channel = channel
self.channels_changed = true
self.changed = true
......@@ -361,7 +363,12 @@ function _M:toScreen()
local item = self.display_chans[i]
local f = item.sel and self.frame_sel or self.frame
f.w = item.w
Base:drawFrame(f, self.display_x + w, self.display_y)
if self.channels[item.name].changed then
local glow = (1+math.sin(core.game.getTime() / 500)) / 2 * 100 + 120
Base:drawFrame(f, self.display_x + w, self.display_y, 139/255, 210/255, 77/255, glow / 255)
end
item._tex:toScreenFull(self.display_x + w, self.display_y, item.w, item.h, item._tex_w, item._tex_h)
w = w + item.w + 4
end
......
......@@ -51,10 +51,10 @@ function _M:event(e)
if not data then return end
if data.kind == "object-link" then
self.chat:addMessage(e.channel, e.login, e.name, "#ANTIQUE_WHITE#has linked an item: #WHITE# "..data.name, {mode="tooltip", tooltip=data.desc})
game.logChat("#LIGHT_BLUE#%s has linked an item <%s>", e.name, data.name)
if self.chat.cur_channel == e.channel then game.logChat("#LIGHT_BLUE#%s has linked an item <%s>", e.name, data.name) end
elseif data.kind == "actor-link" then
self.chat:addMessage(e.channel, e.login, e.name, "#ANTIQUE_WHITE#has linked a creature: #WHITE# "..data.name, {mode="tooltip", tooltip=data.desc})
game.logChat("#LIGHT_BLUE#%s has linked a creature <%s>", e.name, data.name)
if self.chat.cur_channel == e.channel then game.logChat("#LIGHT_BLUE#%s has linked a creature <%s>", e.name, data.name) end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment