Merge pull request #1004 from diath/add_channel_events

Add support for channel events
This commit is contained in:
Konrad Kuśnierz
2019-01-16 13:30:09 +01:00
committed by GitHub
3 changed files with 40 additions and 6 deletions

View File

@@ -52,6 +52,13 @@ SayModes = {
[3] = { speakTypeDesc = 'yell', icon = '/images/game/console/yell' }
}
ChannelEventFormats = {
[ChannelEvent.Join] = '%s joined the channel.',
[ChannelEvent.Leave] = '%s left the channel.',
[ChannelEvent.Invite] = '%s has been invited to the channel.',
[ChannelEvent.Exclude] = '%s has been removed from the channel.',
}
MAX_HISTORY = 500
MAX_LINES = 100
HELP_CHANNEL = 9
@@ -98,7 +105,8 @@ function init()
onRuleViolationCancel = onRuleViolationCancel,
onRuleViolationLock = onRuleViolationLock,
onGameStart = online,
onGameEnd = offline
onGameEnd = offline,
onChannelEvent = onChannelEvent,
})
consolePanel = g_ui.loadUI('console', modules.game_interface.getBottomPanel())
@@ -240,7 +248,8 @@ function terminate()
onRuleViolationCancel = onRuleViolationCancel,
onRuleViolationLock = onRuleViolationLock,
onGameStart = online,
onGameEnd = offline
onGameEnd = offline,
onChannelEvent = onChannelEvent,
})
if g_game.isOnline() then clear() end
@@ -1437,3 +1446,19 @@ function offline()
end
clear()
end
function onChannelEvent(channelId, name, type)
local fmt = ChannelEventFormats[type]
if not fmt then
print(('Unknown channel event type (%d).'):format(type))
return
end
local channel = channels[channelId]
if channel then
local tab = getTab(channel)
if tab then
addTabText(fmt:format(name), SpeakTypesSettings.channelOrange, tab)
end
end
end