Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show First 20 Lines • Show All 1,286 Lines • ▼ Show 20 Lines | function addChatMessage(msg) | ||||
Engine.GetGUIObjectByName("chatText").caption = g_ChatMessages.join("\n"); | Engine.GetGUIObjectByName("chatText").caption = g_ChatMessages.join("\n"); | ||||
} | } | ||||
/** | /** | ||||
* Splits given input into command and argument. | * Splits given input into command and argument. | ||||
*/ | */ | ||||
function ircSplit(string) | function ircSplit(string) | ||||
{ | { | ||||
let idx = string.indexOf(' '); | let idx = string.indexOf(' '); | ||||
bb: (wondering why single `'` are used and not `"`, but out of scope I guess) | |||||
if (idx != -1) | if (idx != -1) | ||||
return [string.substr(1, idx - 1), string.substr(idx + 1)]; | return [string.substr(1, idx - 1), string.substr(idx + 1)]; | ||||
return [string.substr(1), ""]; | return [string.substr(1), ""]; | ||||
} | } | ||||
elexisUnsubmitted Not Done Inline ActionsLast time I came around this I didn't find a nice way to obliterate it. Would be nice to find some JS split magic for it and have it inlined. elexis: Last time I came around this I didn't find a nice way to obliterate it. Would be nice to find… | |||||
templeAuthorUnsubmitted Not Done Inline Actionsmessages.js uses // Split addressee command and message-text msg.cmd = msg.text.split(/\s/)[0]; msg.text = msg.text.substr(msg.cmd.length + 1); You could do split to get an array of words then add back spaces later. temple: messages.js uses
```
// Split addressee command and message-text
msg.cmd = msg.text.split… | |||||
/** | /** | ||||
* Format text in an IRC-like way. | * Format text in an IRC-like way. | ||||
Not Done Inline ActionsDon't know what to do here, if anything. temple: Don't know what to do here, if anything. | |||||
Not Done Inline Actionsthe comment seems valid, so nothing is ok imo bb: the comment seems valid, so nothing is ok imo | |||||
* | * | ||||
* @param {Object} msg - Received chat message. | * @param {Object} msg - Received chat message. | ||||
* @returns {string} - Formatted text. | * @returns {string} - Formatted text. | ||||
*/ | */ | ||||
function ircFormat(msg) | function ircFormat(msg) | ||||
elexisUnsubmitted Not Done Inline ActionsformatChatMessage? elexis: `formatChatMessage`? | |||||
{ | { | ||||
let formattedMessage = ""; | let formattedMessage = ""; | ||||
let coloredFrom = msg.from && colorPlayerName(msg.from); | let coloredFrom = msg.from && colorPlayerName(msg.from); | ||||
// Handle commands allowed past handleChatCommand. | // Handle commands allowed past handleChatCommand. | ||||
if (msg.text[0] == '/') | if (msg.text[0] == '/') | ||||
{ | { | ||||
let [command, message] = ircSplit(msg.text); | let [command, message] = ircSplit(msg.text); | ||||
switch (command) | switch (command) | ||||
{ | { | ||||
case "me": | case "me": | ||||
{ | { | ||||
// Translation: IRC message prefix when the sender uses the /me command. | // Translation: IRC message prefix when the sender uses the /me command. | ||||
let senderString = sprintf(translate("* %(sender)s"), { | let senderString = sprintf(translate("* %(sender)s"), { | ||||
"sender": coloredFrom | "sender": coloredFrom | ||||
}); | }); | ||||
// Translation: IRC message issued using the ‘/me’ command. | // Translation: IRC message issued using the ‘/me’ command. | ||||
Not Done Inline Actionswhy is here some quotation and in previous comment not? bb: why is here some quotation and in previous comment not? | |||||
formattedMessage = sprintf(translate("%(sender)s %(action)s"), { | formattedMessage = sprintf(translate("%(sender)s %(action)s"), { | ||||
"sender": senderFont(senderString), | "sender": senderFont(senderString), | ||||
"action": message | "action": message | ||||
}); | }); | ||||
break; | break; | ||||
} | } | ||||
case "say": | case "say": | ||||
{ | { | ||||
// Translation: IRC message prefix. | // Translation: IRC message prefix. | ||||
Not Done Inline Actionsand why isn't here the /me type explanation? bb: and why isn't here the /me type explanation? | |||||
let senderString = sprintf(translate("<%(sender)s>"), { | let senderString = sprintf(translate("<%(sender)s>"), { | ||||
"sender": coloredFrom | "sender": coloredFrom | ||||
}); | }); | ||||
// Translation: IRC message. | // Translation: IRC message. | ||||
formattedMessage = sprintf(translate("%(sender)s %(message)s"), { | formattedMessage = sprintf(translate("%(sender)s %(message)s"), { | ||||
"sender": senderFont(senderString), | "sender": senderFont(senderString), | ||||
"message": message | "message": message | ||||
Show All 25 Lines | if (msg.text[0] == '/') | ||||
default: | default: | ||||
return ""; | return ""; | ||||
} | } | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
let senderString; | let senderString; | ||||
// Translation: IRC message prefix. | |||||
if (msg.private) | if (msg.private) | ||||
senderString = sprintf(translateWithContext("lobby private message", "(%(private)s) <%(sender)s>"), { | // Translation: IRC message prefix for private messages. | ||||
"private": coloredText(translate("Private"), g_PrivateMessageColor), | senderString = sprintf(translate("(%(private)s) <%(sender)s>"), { | ||||
"private": coloredText(translateWithContext("chat message", "Private"), g_PrivateMessageColor), | |||||
"sender": coloredFrom | "sender": coloredFrom | ||||
}); | }); | ||||
else | else | ||||
// Translation: IRC message prefix. | |||||
elexisUnsubmitted Not Done Inline ActionsI've always wondered why we speak of IRC messages in XMPP. Can we shoot at it? Just replacing IRC with chat everywhere should do. elexis: I've always wondered why we speak of IRC messages in XMPP. Can we shoot at it? Just replacing… | |||||
senderString = sprintf(translate("<%(sender)s>"), { | senderString = sprintf(translate("<%(sender)s>"), { | ||||
"sender": coloredFrom | "sender": coloredFrom | ||||
}); | }); | ||||
// Translation: IRC message. | // Translation: IRC message. | ||||
formattedMessage = sprintf(translate("%(sender)s %(message)s"), { | formattedMessage = sprintf(translate("%(sender)s %(message)s"), { | ||||
"sender": senderFont(senderString), | "sender": senderFont(senderString), | ||||
"message": msg.text | "message": msg.text | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
(wondering why single ' are used and not ", but out of scope I guess)