Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show All 24 Lines | |||||
/** | /** | ||||
* Current games will be listed in these colors. | * Current games will be listed in these colors. | ||||
*/ | */ | ||||
var g_GameColors = { | var g_GameColors = { | ||||
"init": "0 219 0", | "init": "0 219 0", | ||||
"waiting": "255 127 0", | "waiting": "255 127 0", | ||||
"running": "219 0 0" | "running": "219 0 0" | ||||
}; | }; | ||||
elexisUnsubmitted Not Done Inline Actionselexis: ```
var g_GameStateTags = {
"init": { "color": "foo" },
};
``` | |||||
/** | /** | ||||
* Initial sorting order of the gamelist. | * Initial sorting order of the gamelist. | ||||
*/ | */ | ||||
var g_GameStatusOrder = ["init", "waiting", "running"]; | var g_GameStatusOrder = ["init", "waiting", "running"]; | ||||
/** | /** | ||||
* The playerlist will be assembled using these values. | * The playerlist will be assembled using these values. | ||||
*/ | */ | ||||
var g_PlayerStatuses = { | var g_PlayerStatuses = { | ||||
"available": { "color": "0 219 0", "status": translate("Online") }, | "available": { "color": "0 219 0", "status": translate("Online") }, | ||||
"away": { "color": "229 76 13", "status": translate("Away") }, | "away": { "color": "229 76 13", "status": translate("Away") }, | ||||
"playing": { "color": "200 0 0", "status": translate("Busy") }, | "playing": { "color": "200 0 0", "status": translate("Busy") }, | ||||
"offline": { "color": "0 0 0", "status": translate("Offline") }, | "offline": { "color": "0 0 0", "status": translate("Offline") }, | ||||
"unknown": { "color": "178 178 178", "status": translateWithContext("lobby presence", "Unknown") } | "unknown": { "color": "178 178 178", "status": translateWithContext("lobby presence", "Unknown") } | ||||
elexisUnsubmitted Not Done Inline Actionsvar g_PlayerStatuses = { "available": { "tags": { "color": "foo" }, "label": translate("Online") } }; elexis: ```
var g_PlayerStatuses = {
"available": { "tags": { "color": "foo" }, "label": translate… | |||||
}; | }; | ||||
var g_RoleNames = { | var g_RoleNames = { | ||||
"moderator": translate("Moderator"), | "moderator": translate("Moderator"), | ||||
"participant": translate("Player"), | "participant": translate("Player"), | ||||
"visitor": translate("Muted Player") | "visitor": translate("Muted Player") | ||||
}; | }; | ||||
Show All 10 Lines | |||||
/** | /** | ||||
* Used for highlighting the sender of chat messages. | * Used for highlighting the sender of chat messages. | ||||
*/ | */ | ||||
var g_SenderFont = "sans-bold-13"; | var g_SenderFont = "sans-bold-13"; | ||||
/** | /** | ||||
* Color to highlight chat commands in the explanation. | * Color to highlight chat commands in the explanation. | ||||
*/ | */ | ||||
var g_ChatCommandColor = "200 200 255"; | var g_ChatCommandColor = "200 200 255"; | ||||
elexisUnsubmitted Not Done Inline Actionsthese ought to become tag objects elexis: these ought to become tag objects | |||||
/** | /** | ||||
* All chat messages received since init (i.e. after lobby join and after returning from a game). | * All chat messages received since init (i.e. after lobby join and after returning from a game). | ||||
*/ | */ | ||||
var g_ChatMessages = []; | var g_ChatMessages = []; | ||||
/** | /** | ||||
* Rating of the current user. | * Rating of the current user. | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | "help": { | ||||
"description": translate("Show this help."), | "description": translate("Show this help."), | ||||
"handler": args => { | "handler": args => { | ||||
let isModerator = Engine.LobbyGetPlayerRole(g_Username) == "moderator"; | let isModerator = Engine.LobbyGetPlayerRole(g_Username) == "moderator"; | ||||
let text = translate("Chat commands:"); | let text = translate("Chat commands:"); | ||||
for (let command in g_ChatCommands) | for (let command in g_ChatCommands) | ||||
if (!g_ChatCommands[command].moderatorOnly || isModerator) | if (!g_ChatCommands[command].moderatorOnly || isModerator) | ||||
// Translation: Chat command help format | // Translation: Chat command help format | ||||
text += "\n" + sprintf(translate("%(command)s - %(description)s"), { | text += "\n" + sprintf(translate("%(command)s - %(description)s"), { | ||||
"command": coloredText(command, g_ChatCommandColor), | "command": setColor(command, g_ChatCommandColor), | ||||
"description": g_ChatCommands[command].description | "description": g_ChatCommands[command].description | ||||
}); | }); | ||||
addChatMessage({ | addChatMessage({ | ||||
"from": "system", | "from": "system", | ||||
"text": text | "text": text | ||||
}); | }); | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | if (player.rating && player.name == g_Username) | ||||
g_UserRating = player.rating; | g_UserRating = player.rating; | ||||
let rating = player.rating ? (" " + player.rating).substr(-5) : " -"; | let rating = player.rating ? (" " + player.rating).substr(-5) : " -"; | ||||
let presence = g_PlayerStatuses[player.presence] ? player.presence : "unknown"; | let presence = g_PlayerStatuses[player.presence] ? player.presence : "unknown"; | ||||
if (presence == "unknown") | if (presence == "unknown") | ||||
warn("Unknown presence:" + player.presence); | warn("Unknown presence:" + player.presence); | ||||
let statusColor = g_PlayerStatuses[presence].color; | let statusColor = g_PlayerStatuses[presence].color; | ||||
buddyStatusList.push(player.isBuddy ? coloredText(g_BuddySymbol, statusColor) : ""); | buddyStatusList.push(player.isBuddy ? setColor(g_BuddySymbol, statusColor) : ""); | ||||
playerList.push(colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name)); | playerList.push(colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name)); | ||||
presenceList.push(coloredText(g_PlayerStatuses[presence].status, statusColor)); | presenceList.push(setColor(g_PlayerStatuses[presence].status, statusColor)); | ||||
ratingList.push(coloredText(rating, statusColor)); | ratingList.push(setColor(rating, statusColor)); | ||||
nickList.push(player.name); | nickList.push(player.name); | ||||
} | } | ||||
playersBox.list_buddy = buddyStatusList; | playersBox.list_buddy = buddyStatusList; | ||||
playersBox.list_name = playerList; | playersBox.list_name = playerList; | ||||
playersBox.list_status = presenceList; | playersBox.list_status = presenceList; | ||||
playersBox.list_rating = ratingList; | playersBox.list_rating = ratingList; | ||||
playersBox.list = nickList; | playersBox.list = nickList; | ||||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | function updateGameList() | ||||
{ | { | ||||
let game = g_GameList[i]; | let game = g_GameList[i]; | ||||
let gameName = escapeText(game.name); | let gameName = escapeText(game.name); | ||||
let mapTypeIdx = g_MapTypes.Name.indexOf(game.mapType); | let mapTypeIdx = g_MapTypes.Name.indexOf(game.mapType); | ||||
if (game.ip == g_SelectedGameIP && game.port == g_SelectedGamePort) | if (game.ip == g_SelectedGameIP && game.port == g_SelectedGamePort) | ||||
selectedGameIndex = +i; | selectedGameIndex = +i; | ||||
list_buddy.push(game.hasBuddies ? coloredText(g_BuddySymbol, g_GameColors[game.state]) : ""); | list_buddy.push(game.hasBuddies ? setColor(g_BuddySymbol, g_GameColors[game.state]) : ""); | ||||
list_name.push(coloredText(gameName, g_GameColors[game.state])); | list_name.push(setColor(gameName, g_GameColors[game.state])); | ||||
list_mapName.push(translateMapTitle(game.niceMapName)); | list_mapName.push(translateMapTitle(game.niceMapName)); | ||||
list_mapSize.push(translateMapSize(game.mapSize)); | list_mapSize.push(translateMapSize(game.mapSize)); | ||||
list_mapType.push(g_MapTypes.Title[mapTypeIdx] || ""); | list_mapType.push(g_MapTypes.Title[mapTypeIdx] || ""); | ||||
list_nPlayers.push(game.nbp + "/" + game.maxnbp); | list_nPlayers.push(game.nbp + "/" + game.maxnbp); | ||||
list_gameRating.push(game.gameRating); | list_gameRating.push(game.gameRating); | ||||
list.push(gameName); | list.push(gameName); | ||||
list_data.push(i); | list_data.push(i); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | function handleChatCommand(text) | ||||
args = ircSplit("/" + args); | args = ircSplit("/" + args); | ||||
if (!g_ChatCommands[cmd]) | if (!g_ChatCommands[cmd]) | ||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
"from": "system", | "from": "system", | ||||
"text": sprintf( | "text": sprintf( | ||||
translate("The command '%(cmd)s' is not supported."), { | translate("The command '%(cmd)s' is not supported."), { | ||||
"cmd": coloredText(cmd, g_ChatCommandColor) | "cmd": setColor(cmd, g_ChatCommandColor) | ||||
}) | }) | ||||
}); | }); | ||||
return false; | return false; | ||||
} | } | ||||
if (g_ChatCommands[cmd].moderatorOnly && Engine.LobbyGetPlayerRole(g_Username) != "moderator") | if (g_ChatCommands[cmd].moderatorOnly && Engine.LobbyGetPlayerRole(g_Username) != "moderator") | ||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
"from": "system", | "from": "system", | ||||
"text": sprintf( | "text": sprintf( | ||||
translate("The command '%(cmd)s' is restricted to moderators."), { | translate("The command '%(cmd)s' is restricted to moderators."), { | ||||
"cmd": coloredText(cmd, g_ChatCommandColor) | "cmd": setColor(cmd, g_ChatCommandColor) | ||||
}) | }) | ||||
}); | }); | ||||
return false; | return false; | ||||
} | } | ||||
return g_ChatCommands[cmd].handler(args); | return g_ChatCommands[cmd].handler(args); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | function ircFormat(msg) | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
let senderString; | let senderString; | ||||
// Translation: IRC message prefix. | // Translation: IRC message prefix. | ||||
if (msg.private) | if (msg.private) | ||||
senderString = sprintf(translateWithContext("lobby private message", "(%(private)s) <%(sender)s>"), { | senderString = sprintf(translateWithContext("lobby private message", "(%(private)s) <%(sender)s>"), { | ||||
"private": coloredText(translate("Private"), g_PrivateMessageColor), | "private": setColor(translate("Private"), g_PrivateMessageColor), | ||||
"sender": coloredFrom | "sender": coloredFrom | ||||
}); | }); | ||||
else | else | ||||
senderString = sprintf(translate("<%(sender)s>"), { | senderString = sprintf(translate("<%(sender)s>"), { | ||||
"sender": coloredFrom | "sender": coloredFrom | ||||
}); | }); | ||||
// Translation: IRC message. | // Translation: IRC message. | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Returns the given playername wrapped in an appropriate color-tag. | * Returns the given playername wrapped in an appropriate color-tag. | ||||
* | * | ||||
* @param {string} playername | * @param {string} playername | ||||
* @param {string} rating | * @param {string} rating | ||||
*/ | */ | ||||
function colorPlayerName(playername, rating) | function colorPlayerName(playername, rating) | ||||
{ | { | ||||
return coloredText( | return setColor( | ||||
(rating ? sprintf( | (rating ? sprintf( | ||||
translate("%(nick)s (%(rating)s)"), { | translate("%(nick)s (%(rating)s)"), { | ||||
"nick": playername, | "nick": playername, | ||||
"rating": rating | "rating": rating | ||||
}) : playername | }) : playername | ||||
), | ), | ||||
getPlayerColor(playername.replace(g_ModeratorPrefix, ""))); | getPlayerColor(playername.replace(g_ModeratorPrefix, ""))); | ||||
} | } | ||||
Show All 15 Lines |
Wildfire Games · Phabricator