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

When dead (on the death screen) it is now possible to review message log, see...

When dead (on the death screen) it is now possible to review message log, see current chat and talk to people


git-svn-id: http://svn.net-core.org/repos/t-engine4@4299 51575b47-30f0-44d4-a5cc-537603b46e54
parent 16bce49f
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ function _M:init()
self.channels = {}
self.max = 500
self.do_display_chans = true
self.on_event = {}
end
--- Hook up in the current running game
......@@ -80,6 +81,16 @@ function _M:addMessage(kind, channel, login, name, msg, extra_data, no_change)
if not no_change and channel ~= self.cur_channel then self.channels[channel].changed = true self.channels_changed = true end
end
--- Register to receive events
function _M:registerTalkEvents(fct)
self.on_event[fct] = true
end
--- Register to not receive events
function _M:unregisterTalkEvents(fct)
self.on_event[fct] = nil
end
function _M:event(e)
if e.se == "Talk" then
e.msg = e.msg:removeColorCodes()
......@@ -150,6 +161,10 @@ function _M:event(e)
end
self.channels_changed = true
end
for fct, _ in pairs(self.on_event) do
fct(e)
end
end
function _M:join(channel)
......
......@@ -148,6 +148,8 @@ function _M:use(item)
self:resurrectBasic(self.actor)
elseif act == "dump" then
game:registerDialog(require("mod.dialogs.CharacterSheet").new(self.actor))
elseif act == "log" then
game:registerDialog(require("mod.dialogs.ShowChatLog").new("Message Log", 0.6, game.logdisplay, profile.chat))
end
end
......@@ -155,6 +157,7 @@ function _M:generateList()
local list = {}
if config.settings.cheat then list[#list+1] = {name="Resurrect by cheating", action="cheat"} end
list[#list+1] = {name=(not profile.auth and "Message Log" or "Message/Chat log (allows to talk)"), action="log"}
list[#list+1] = {name="Character dump", action="dump"}
list[#list+1] = {name="Restart the same character", action="exit", subaction="restart"}
list[#list+1] = {name="Restart with a new character", action="exit", subaction="restart-new"}
......
......@@ -187,6 +187,8 @@ function _M:use(item)
end
elseif act == "dump" then
game:registerDialog(require("mod.dialogs.CharacterSheet").new(self.actor))
elseif act == "log" then
game:registerDialog(require("mod.dialogs.ShowChatLog").new("Message Log", 0.6, game.logdisplay, profile.chat))
elseif act == "cheat" then
game.logPlayer(self.actor, "#LIGHT_BLUE#You resurrect! CHEATER!")
......@@ -272,6 +274,7 @@ function _M:generateList()
end)
end
list[#list+1] = {name=(not profile.auth and "Message Log" or "Message/Chat log (allows to talk)"), action="log"}
list[#list+1] = {name="Character dump", action="dump"}
list[#list+1] = {name="Restart the same character", action="exit", subaction="restart"}
list[#list+1] = {name="Restart with a new character", action="exit", subaction="restart-new"}
......
......@@ -33,6 +33,9 @@ function _M:init(title, shadow, log, chat)
self.log, self.chat = log, chat
self.event_fct = function(e) self:onTalkEvent(e) end
chat:registerTalkEvents(self.event_fct)
local tabs = {}
local order = {}
......@@ -65,6 +68,16 @@ function _M:init(title, shadow, log, chat)
self:switchTo(self.last_tab or "__log")
end
function _M:unload()
self.chat:unregisterTalkEvents(self.event_fct)
end
function _M:onTalkEvent(e)
if not e.channel then return end
if e.channel ~= self.last_tab then return end
self:switchTo(self.last_tab)
end
function _M:generate()
Dialog.generate(self)
......@@ -83,6 +96,15 @@ function _M:generate()
_PAGEUP = function() self:setScroll(self.scroll - self.max_display) end,
_PAGEDOWN = function() self:setScroll(self.scroll + self.max_display) end,
}
for i, tab in ipairs(tabs) do
local tab = tab
tab.ui.key:addBind("USERCHAT_TALK", function()
local type, name = profile.chat:getCurrentTarget()
if type == "channel" and self.last_tab ~= "__log" then profile.chat:setCurrentTarget(true, self.last_tab) end
profile.chat:talkBox()
end)
end
end
function _M:mouseEvent(button, x, y, xrel, yrel, bx, by, event)
......
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