Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/messages.js
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | "kicked": msg => | ||||
), | ), | ||||
"clientlist": msg => getUsernameList(), | "clientlist": msg => getUsernameList(), | ||||
"message": msg => formatChatCommand(msg), | "message": msg => formatChatCommand(msg), | ||||
"defeat": msg => formatDefeatMessage(msg), | "defeat": msg => formatDefeatMessage(msg), | ||||
"won": msg => formatWinMessage(msg), | "won": msg => formatWinMessage(msg), | ||||
"diplomacy": msg => formatDiplomacyMessage(msg), | "diplomacy": msg => formatDiplomacyMessage(msg), | ||||
"tribute": msg => formatTributeMessage(msg), | "tribute": msg => formatTributeMessage(msg), | ||||
"barter": msg => formatBarterMessage(msg), | "barter": msg => formatBarterMessage(msg), | ||||
"attack": msg => formatAttackMessage(msg) | "attack": msg => formatAttackMessage(msg), | ||||
"phase": msg => formatPhaseMessage(msg) | |||||
}; | }; | ||||
/** | /** | ||||
* Show a label and grey overlay or hide both on connection change. | * Show a label and grey overlay or hide both on connection change. | ||||
*/ | */ | ||||
var g_StatusMessageTypes = { | var g_StatusMessageTypes = { | ||||
"authenticated": msg => translate("Connection to the server has been authenticated."), | "authenticated": msg => translate("Connection to the server has been authenticated."), | ||||
"connected": msg => translate("Connected to the server."), | "connected": msg => translate("Connected to the server."), | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | "attack": function(notification, player) | ||||
addChatMessage({ | addChatMessage({ | ||||
"type": "attack", | "type": "attack", | ||||
"player": player, | "player": player, | ||||
"attacker": notification.attacker, | "attacker": notification.attacker, | ||||
"targetIsDomesticAnimal": notification.targetIsDomesticAnimal | "targetIsDomesticAnimal": notification.targetIsDomesticAnimal | ||||
}); | }); | ||||
}, | }, | ||||
"phase": function(notification, player) | |||||
{ | |||||
addChatMessage({ | |||||
"type": "phase", | |||||
"player": player, | |||||
"phaseName": notification.phaseName, | |||||
"phaseState": notification.phaseState | |||||
}); | |||||
}, | |||||
"dialog": function(notification, player) | "dialog": function(notification, player) | ||||
{ | { | ||||
if (player == Engine.GetPlayerID()) | if (player == Engine.GetPlayerID()) | ||||
openDialog(notification.dialogName, notification.data, player); | openDialog(notification.dialogName, notification.data, player); | ||||
}, | }, | ||||
"resetselectionpannel": function(notification, player) | "resetselectionpannel": function(notification, player) | ||||
{ | { | ||||
if (player != Engine.GetPlayerID()) | if (player != Engine.GetPlayerID()) | ||||
▲ Show 20 Lines • Show All 540 Lines • ▼ Show 20 Lines | let message = msg.targetIsDomesticAnimal ? | ||||
translate("Your livestock has been attacked by %(attacker)s!") : | translate("Your livestock has been attacked by %(attacker)s!") : | ||||
translate("You have been attacked by %(attacker)s!"); | translate("You have been attacked by %(attacker)s!"); | ||||
return sprintf(message, { | return sprintf(message, { | ||||
"attacker": colorizePlayernameByID(msg.attacker) | "attacker": colorizePlayernameByID(msg.attacker) | ||||
}); | }); | ||||
} | } | ||||
function formatPhaseMessage(msg) | |||||
{ | |||||
let notifyPhase = Engine.ConfigDB_GetValue("user", "gui.session.notifications.phase"); | |||||
if (notifyPhase == 0 || msg.player != g_ViewedPlayer && !g_IsObserver && !g_Players[msg.player].isMutualAlly[g_ViewedPlayer]) | |||||
return ""; | |||||
let message = ""; | |||||
if (notifyPhase == 2) | |||||
{ | |||||
if (msg.phaseState == "started") | |||||
message = translate("%(player)s is advancing to the %(phaseName)s."); | |||||
else if (msg.phaseState == "aborted") | |||||
message = translate("The %(phaseName)s of %(player)s has been aborted."); | |||||
} | |||||
if (msg.phaseState == "completed") | |||||
message = translate("%(player)s has reached the %(phaseName)s."); | |||||
return sprintf(message, { | |||||
"player": colorizePlayernameByID(msg.player), | |||||
"phaseName": getEntityNames(GetTechnologyData(msg.phaseName, g_Players[msg.player].civ)) | |||||
}); | |||||
} | |||||
function formatChatCommand(msg) | function formatChatCommand(msg) | ||||
{ | { | ||||
if (!msg.text) | if (!msg.text) | ||||
return ""; | return ""; | ||||
let isMe = msg.text.indexOf("/me ") == 0; | let isMe = msg.text.indexOf("/me ") == 0; | ||||
if (!isMe && !parseChatAddressee(msg)) | if (!isMe && !parseChatAddressee(msg)) | ||||
return ""; | return ""; | ||||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator