From f689910905e8b6c8218214fb354523dcd8e88fe0 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Thu, 24 Feb 2011 15:40:04 +0000 Subject: [PATCH] update chat git-svn-id: http://svn.net-core.org/repos/t-engine4@2824 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/UserChat.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/game/engines/default/engine/UserChat.lua b/game/engines/default/engine/UserChat.lua index 82c24c0aaf..91ff23f7a0 100644 --- a/game/engines/default/engine/UserChat.lua +++ b/game/engines/default/engine/UserChat.lua @@ -68,10 +68,12 @@ function _M:event(e) self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}} self.channels[e.channel].users[e.user] = true self.channels_changed = true + if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.user, e.channel) end elseif e.se == "Part" then self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}} self.channels[e.channel].users[e.user] = nil self.channels_changed = true + if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.user, e.channel) end elseif e.se == "UserInfo" then local info = e.data:unserialize() if not info then return end @@ -191,7 +193,9 @@ function _M:display() table.sort(list, function(a,b) if a == "global" then return 1 elseif b == "global" then return nil else return a < b end end) for i, name in ipairs(list) do local oname = name - name = "["..name:capitalize().." ("..#self.channels[name].users..")]" + local nb_users = 0 + for _, _ in pairs(self.channels[name].users) do nb_users = nb_users + 1 end + name = "["..name:capitalize().." ("..nb_users..")]" local len = self.font_mono:size(name) local s = core.display.newSurface(len + ls_w + rs_w, ls_h) -- GitLab