Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/messages.js
/** | /** | ||||
* All known cheat commands. | * All known cheat commands. | ||||
*/ | */ | ||||
const g_Cheats = getCheatsData(); | const g_Cheats = getCheatsData(); | ||||
/** | /** | ||||
* All tutorial messages received so far. | * All tutorial messages received so far. | ||||
*/ | */ | ||||
var g_TutorialMessages = []; | var g_TutorialMessages = []; | ||||
/** | /** | ||||
* GUI tags applied to the most recent tutorial message. | * GUI tags applied to the most recent tutorial message. | ||||
*/ | */ | ||||
var g_TutorialNewMessageTags = { "color": "yellow" }; | var g_TutorialNewMessageTags = { "color": "yellow" }; | ||||
/** | /** | ||||
* These handlers are called everytime a client joins or disconnects. | |||||
*/ | |||||
var g_PlayerAssignmentsChangeHandlers = new Set(); | |||||
/** | |||||
* Handle all netmessage types that can occur. | * Handle all netmessage types that can occur. | ||||
*/ | */ | ||||
var g_NetMessageTypes = { | var g_NetMessageTypes = { | ||||
"netstatus": msg => { | "netstatus": msg => { | ||||
handleNetStatusMessage(msg); | handleNetStatusMessage(msg); | ||||
}, | }, | ||||
"netwarn": msg => { | "netwarn": msg => { | ||||
addNetworkWarning(msg); | addNetworkWarning(msg); | ||||
▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | if (notification.lock) | ||||
global.music.storeTracks(notification.tracks.map(track => ({ "Type": "custom", "File": track }))); | global.music.storeTracks(notification.tracks.map(track => ({ "Type": "custom", "File": track }))); | ||||
global.music.setState(global.music.states.CUSTOM); | global.music.setState(global.music.states.CUSTOM); | ||||
} | } | ||||
global.music.setLocked(notification.lock); | global.music.setLocked(notification.lock); | ||||
} | } | ||||
}; | }; | ||||
function registerPlayerAssignmentsChangeHandler(handler) | |||||
{ | |||||
g_PlayerAssignmentsChangeHandlers.add(handler); | |||||
} | |||||
/** | /** | ||||
* Loads all known cheat commands. | * Loads all known cheat commands. | ||||
*/ | */ | ||||
function getCheatsData() | function getCheatsData() | ||||
{ | { | ||||
let cheats = {}; | let cheats = {}; | ||||
for (let fileName of Engine.ListDirectoryFiles("simulation/data/cheats/", "*.json", false)) | for (let fileName of Engine.ListDirectoryFiles("simulation/data/cheats/", "*.json", false)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | function handlePlayerAssignmentsMessage(message) | ||||
let joins = Object.keys(message.newAssignments).filter(guid => !g_PlayerAssignments[guid]); | let joins = Object.keys(message.newAssignments).filter(guid => !g_PlayerAssignments[guid]); | ||||
g_PlayerAssignments = message.newAssignments; | g_PlayerAssignments = message.newAssignments; | ||||
joins.forEach(guid => { | joins.forEach(guid => { | ||||
onClientJoin(guid); | onClientJoin(guid); | ||||
}); | }); | ||||
for (let handler of g_PlayerAssignmentsChangeHandlers) | |||||
handler(); | |||||
// TODO: use subsription instead | |||||
Stan: Typo. | |||||
updateGUIObjects(); | updateGUIObjects(); | ||||
g_Chat.onUpdatePlayers(); | |||||
sendLobbyPlayerlistUpdate(); | |||||
} | } | ||||
function onClientJoin(guid) | function onClientJoin(guid) | ||||
{ | { | ||||
let playerID = g_PlayerAssignments[guid].player; | let playerID = g_PlayerAssignments[guid].player; | ||||
if (g_Players[playerID]) | if (g_Players[playerID]) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Typo.