Differential D2412 Diff 10357 binaries/data/mods/public/gui/lobby/LobbyPage/Chat/StatusMessages/StatusMessageEvents.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/LobbyPage/Chat/StatusMessages/StatusMessageEvents.js
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
/** | |||||
* @file The classes in this file trigger notifications about occurrences in the multi-user | |||||
* chat room that are not chat messages, nor events that demand the current players attention. | |||||
*/ | |||||
Freagarach: So they're not events that demand the current players attention? Or are they neither chat… | |||||
ChatMessageEvents.ClientEvents = class | |||||
{ | |||||
constructor(xmppMessages, chat, statusMessageFormat) | |||||
{ | |||||
this.chat = chat; | |||||
this.statusMessageFormat = statusMessageFormat; | |||||
this.kickStrings = new KickStrings(); | |||||
this.nickArgs = {}; | |||||
xmppMessages.registerHandler("chat", "join", this.onClientJoin.bind(this)); | |||||
xmppMessages.registerHandler("chat", "leave", this.onClientLeave.bind(this)); | |||||
xmppMessages.registerHandler("chat", "kicked", this.onClientKicked.bind(this, false)); | |||||
xmppMessages.registerHandler("chat", "banned", this.onClientKicked.bind(this, true)); | |||||
} | |||||
onClientJoin(message) | |||||
{ | |||||
this.nickArgs.nick = escapeText(message.nick); | |||||
this.chat.addText( | |||||
message.time, | |||||
this.statusMessageFormat.format(sprintf(this.Format, this.nickArgs))); | |||||
} | |||||
onClientLeave(message) | |||||
{ | |||||
this.nickArgs.nick = escapeText(message.nick); | |||||
this.chat.addText( | |||||
message.time, | |||||
this.statusMessageFormat.format(sprintf(this.Format, this.nickArgs))); | |||||
} | |||||
onClientKicked(banned, message) | |||||
{ | |||||
// If the local player had been kicked, that is logged more vividly than a neutral status message | |||||
if (message.nick != g_Username) | |||||
Not Done Inline Actions+. Freagarach: +`.` | |||||
this.chat.addText( | |||||
message.time, | |||||
this.statusMessageFormat.format(this.kickStrings.get(banned, message))); | |||||
} | |||||
}; | |||||
ChatMessageEvents.ClientEvents.prototype.Format = translate("%(nick)s has joined."); | |||||
ChatMessageEvents.ClientEvents.prototype.Format = translate("%(nick)s has left."); | |||||
ChatMessageEvents.Nick = class | |||||
{ | |||||
constructor(xmppMessages, chat, statusMessageFormat) | |||||
{ | |||||
this.chat = chat; | |||||
this.statusMessageFormat = statusMessageFormat; | |||||
this.args = {}; | |||||
xmppMessages.registerHandler("chat", "nick", this.onNickChange.bind(this)); | |||||
} | |||||
onNickChange(message) | |||||
{ | |||||
this.args.oldnick = escapeText(message.oldnick); | |||||
this.args.newnick = escapeText(message.newnick); | |||||
this.chat.addText( | |||||
message.time, | |||||
this.statusMessageFormat.format(sprintf(this.Format, this.args))); | |||||
} | |||||
}; | |||||
ChatMessageEvents.Nick.prototype.Format = translate("%(oldnick)s is now known as %(newnick)s."); | |||||
Not Done Inline ActionsKind of a strange name it seems, in respect of the other names chosen? Freagarach: Kind of a strange name it seems, in respect of the other names chosen? | |||||
Done Inline Actionsyes, can rename elexis: yes, can rename | |||||
ChatMessageEvents.Role = class | |||||
{ | |||||
constructor(xmppMessages, chat, statusMessageFormat) | |||||
{ | |||||
this.chat = chat; | |||||
this.statusMessageFormat = statusMessageFormat; | |||||
this.args = {}; | |||||
xmppMessages.registerHandler("chat", "role", this.onRoleChange.bind(this)); | |||||
} | |||||
onRoleChange(message) | |||||
{ | |||||
let roleType = this.RoleStrings.find(type => | |||||
type.newRole == message.newRole && | |||||
(!type.oldRole || type.oldRole == message.oldRole)); | |||||
let txt; | |||||
if (message.nick == g_Username) | |||||
txt = roleType.you; | |||||
else | |||||
{ | |||||
this.args.nick = escapeText(message.nick); | |||||
txt = sprintf(roleType.nick, this.args); | |||||
} | |||||
this.chat.addText( | |||||
message.time, | |||||
this.statusMessageFormat.format(txt)); | |||||
} | |||||
}; | |||||
ChatMessageEvents.Role.prototype.RoleStrings = | |||||
[ | |||||
{ | |||||
"newRole": "visitor", | |||||
"you": translate("You have been muted."), | |||||
"nick": translate("%(nick)s has been muted.") | |||||
}, | |||||
{ | |||||
"newRole": "moderator", | |||||
"you": translate("You are now a moderator."), | |||||
"nick": translate("%(nick)s is now a moderator.") | |||||
}, | |||||
{ | |||||
"newRole": "participant", | |||||
"oldrole": "visitor", | |||||
"you": translate("You have been unmuted."), | |||||
"nick": translate("%(nick)s has been unmuted.") | |||||
}, | |||||
{ | |||||
"newRole": "participant", | |||||
"oldrole": "moderator", | |||||
"you": translate("You are not a moderator anymore."), | |||||
"nick": translate("%(nick)s is not a moderator anymore.") | |||||
} | |||||
]; | |||||
Not Done Inline ActionsCan't go from mod to visitor? ;) Freagarach: Can't go from mod to visitor? ;) | |||||
Done Inline ActionsThen it shows "player has been muted" elexis: Then it shows "player has been muted" | |||||
ChatMessageEvents.Subject = class | |||||
{ | |||||
constructor(xmppMessages, chat, statusMessageFormat) | |||||
{ | |||||
this.chat = chat; | |||||
this.statusMessageFormat = statusMessageFormat; | |||||
this.args = {}; | |||||
xmppMessages.registerHandler("chat", "subject", this.onSubjectChange.bind(this)); | |||||
} | |||||
onSubjectChange(message) | |||||
{ | |||||
this.args.nick = escapeText(message.nick); | |||||
let subject = message.subject.trim(); | |||||
this.chat.addText( | |||||
message.time, | |||||
this.statusMessageFormat.format( | |||||
subject ? | |||||
sprintf(this.FormatChange, this.args) + "\n" + subject : | |||||
sprintf(this.FormatDelete, this.args))); | |||||
} | |||||
}; | |||||
ChatMessageEvents.Subject.prototype.FormatChange = translate("%(nick)s changed the lobby subject to:"); | |||||
ChatMessageEvents.Subject.prototype.FormatDelete = translate("%(nick)s deleted the lobby subject."); |
Wildfire Games · Phabricator
So they're not events that demand the current players attention? Or are they neither chat messages, nor events. But they do demand the current players attention?
(Context explains it all, but still.)