Changeset View
Standalone View
binaries/data/mods/public/gui/session/messages.js
Show All 39 Lines | "netwarn": msg => { | ||||
addNetworkWarning(msg); | addNetworkWarning(msg); | ||||
}, | }, | ||||
"players": msg => { | "players": msg => { | ||||
handlePlayerAssignmentsMessage(msg); | handlePlayerAssignmentsMessage(msg); | ||||
}, | }, | ||||
"paused": msg => { | "paused": msg => { | ||||
setClientPauseState(msg.guid, msg.pause); | setClientPauseState(msg.guid, msg.pause); | ||||
}, | }, | ||||
"clients-loading": msg => { | |||||
handleClientsLoadingMessage(msg.guids); | |||||
}, | |||||
"rejoined": msg => { | "rejoined": msg => { | ||||
addChatMessage({ | addChatMessage({ | ||||
"type": "rejoined", | "type": "rejoined", | ||||
"guid": msg.guid | "guid": msg.guid | ||||
}); | }); | ||||
}, | }, | ||||
"kicked": msg => { | "kicked": msg => { | ||||
addChatMessage({ | addChatMessage({ | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
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."), | ||||
"disconnected": msg => translate("Connection to the server has been lost.") + "\n" + | "disconnected": msg => translate("Connection to the server has been lost.") + "\n" + | ||||
// Translation: States the reason why the client disconnected from the server. | // Translation: States the reason why the client disconnected from the server. | ||||
sprintf(translate("Reason: %(reason)s."), { | sprintf(translate("Reason: %(reason)s."), { | ||||
"reason": getDisconnectReason(msg.reason, true) | "reason": getDisconnectReason(msg.reason, true) | ||||
}), | }), | ||||
"waiting_for_players": msg => translate("Waiting for other players to connect..."), | "waiting_for_players": msg => translate("Waiting for players to connect:"), | ||||
elexis: (Okay to use players instead of clients here, as observers can be considered players that don't… | |||||
"join_syncing": msg => translate("Synchronising gameplay with other players..."), | "join_syncing": msg => translate("Synchronising gameplay with other players..."), | ||||
"active": msg => "" | "active": msg => "" | ||||
}; | }; | ||||
/** | /** | ||||
* Chatmessage shown after commands like /me or /enemies. | * Chatmessage shown after commands like /me or /enemies. | ||||
*/ | */ | ||||
var g_ChatCommands = { | var g_ChatCommands = { | ||||
▲ Show 20 Lines • Show All 434 Lines • ▼ Show 20 Lines | function handleNetStatusMessage(message) | ||||
if (!g_StatusMessageTypes[message.status]) | if (!g_StatusMessageTypes[message.status]) | ||||
{ | { | ||||
error("Unrecognised netstatus type '" + message.status + "'"); | error("Unrecognised netstatus type '" + message.status + "'"); | ||||
return; | return; | ||||
} | } | ||||
g_IsNetworkedActive = message.status == "active"; | g_IsNetworkedActive = message.status == "active"; | ||||
let label = Engine.GetGUIObjectByName("netStatus"); | let netStatus = Engine.GetGUIObjectByName("netStatus"); | ||||
let statusMessage = g_StatusMessageTypes[message.status](message); | let statusMessage = g_StatusMessageTypes[message.status](message); | ||||
label.caption = statusMessage; | netStatus.caption = statusMessage; | ||||
label.hidden = !statusMessage; | netStatus.hidden = !statusMessage; | ||||
let netStatusText = Engine.GetGUIObjectByName("netStatusText"); | |||||
netStatusText.hidden = message.status != "waiting_for_players"; | |||||
Done Inline ActionsThis looks like it assumes no other netstatus messages while in that waiting period. elexis: This looks like it assumes no other netstatus messages while in that waiting period. | |||||
Not Done Inline Actions"This looks like it assumes no other netstatus messages while in that waiting period." Sure, as that is totally correct. Which other message should arrive during waiting period? Imarok: "This looks like it assumes no other netstatus messages while in that waiting period." Sure, as… | |||||
Not Done Inline ActionsLag warnings? Kick? Player Assignments? elexis: Lag warnings? Kick? Player Assignments? | |||||
Not Done Inline ActionsAh yes, confused g_StatusMessageTypes with g_NetMessageTypes. If the renaming proposed is done, that should be more self-evident elexis: Ah yes, confused g_StatusMessageTypes with g_NetMessageTypes. If the renaming proposed is done… | |||||
Not Done Inline Actionsremove that false &&. elexis: remove that false &&.
also much better with the rename (precise language ftw) | |||||
if (message.status == "disconnected") | if (message.status == "disconnected") | ||||
{ | { | ||||
// Hide the pause overlay, and pause animations. | // Hide the pause overlay, and pause animations. | ||||
Engine.GetGUIObjectByName("pauseOverlay").hidden = true; | Engine.GetGUIObjectByName("pauseOverlay").hidden = true; | ||||
Engine.SetPaused(true, false); | Engine.SetPaused(true, false); | ||||
g_Disconnected = true; | g_Disconnected = true; | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
} | } | ||||
} | } | ||||
function handleClientsLoadingMessage(guids) | |||||
{ | |||||
let netStatusText = Engine.GetGUIObjectByName("netStatusText"); | |||||
netStatusText.caption = guids.map(guid => colorizePlayernameByGUID(guid)).join(translate(", ")); | |||||
Not Done Inline ActionsSince all other occurances don't have translation context either, seems ok to keep it consistent elexis: Since all other occurances don't have translation context either, seems ok to keep it consistent | |||||
} | |||||
function handlePlayerAssignmentsMessage(message) | function handlePlayerAssignmentsMessage(message) | ||||
{ | { | ||||
for (let guid in g_PlayerAssignments) | for (let guid in g_PlayerAssignments) | ||||
if (!message.newAssignments[guid]) | if (!message.newAssignments[guid]) | ||||
onClientLeave(guid); | onClientLeave(guid); | ||||
let joins = Object.keys(message.newAssignments).filter(guid => !g_PlayerAssignments[guid]); | let joins = Object.keys(message.newAssignments).filter(guid => !g_PlayerAssignments[guid]); | ||||
▲ Show 20 Lines • Show All 518 Lines • Show Last 20 Lines |
(Okay to use players instead of clients here, as observers can be considered players that don't participate in the current match too and we don't want to bother our users with technical terms. Also afaics the list can never be empty, so ending with a colon is ok)