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

/r in the talkbox will switch to talking to the last person whispering you

<tab> in the talkbox when whispering will cycle between all last whisperers


git-svn-id: http://svn.net-core.org/repos/t-engine4@6380 51575b47-30f0-44d4-a5cc-537603b46e54
parent e45875db
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ function _M:init()
self.do_display_chans = true
self.on_event = {}
self.full_log = {}
self.last_whispers = {}
end
--- Hook up in the current running game
......@@ -136,6 +137,17 @@ function _M:addMessage(kind, channel, login, name, msg, extra_data, no_change)
local log = self.full_log
table.insert(log, 1, item)
while #log > self.max do table.remove(log) end
if kind == "whisper" then
local found = nil
for i, l in ipairs(self.last_whispers) do if l == login then found = i break end end
if not found then
table.insert(self.last_whispers, 1, login)
else
table.remove(self.last_whispers, found)
table.insert(self.last_whispers, 1, login)
end
end
end
--- Register to receive events
......
......@@ -66,9 +66,18 @@ function _M:init(chat, on_end)
EXIT = function() game:unregisterDialog(self) end,
}
self.key:addCommand("_ESCAPE", function() game:unregisterDialog(self) end)
-- self.key:addCommand("_TAB", function()
-- self:checkTarget(self.c_box.text)
-- end)
self.key:addCommand("_TAB", function()
local type, name = self.chat:getCurrentTarget()
if type == "whisper" then
local found = nil
for i, l in ipairs(self.chat.last_whispers) do if l == name then found = i break end end
if found then
found = util.boundWrap(found + 1, 1, #self.chat.last_whispers)
self.chat:setCurrentTarget(false, self.chat.last_whispers[found])
self:updateTitle(self:getTitle())
end
end
end)
end
function _M:getTargets()
......@@ -109,12 +118,18 @@ function _M:checkTarget(text)
end
end
if text:sub(1, 1) == "/" then
local _, _, chancode = text:find("^/([0-9]+) ")
chancode = tonumber(chancode)
if chancode and self.chat.channel_codes_rev and self.chat.channel_codes_rev[chancode] then
self.chat:setCurrentTarget(true, self.chat.channel_codes_rev[chancode])
if text == "/r " and self.chat.last_whispers and self.chat.last_whispers[1] then
self.chat:setCurrentTarget(false, self.chat.last_whispers[1])
self:updateTitle(self:getTitle())
self.c_box:setText("")
else
local _, _, chancode = text:find("^/([0-9]+) ")
chancode = tonumber(chancode)
if chancode and self.chat.channel_codes_rev and self.chat.channel_codes_rev[chancode] then
self.chat:setCurrentTarget(true, self.chat.channel_codes_rev[chancode])
self:updateTitle(self:getTitle())
self.c_box:setText("")
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