Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show All 17 Lines | |||||
*/ | */ | ||||
const g_Username = Engine.LobbyGetNick(); | const g_Username = Engine.LobbyGetNick(); | ||||
/** | /** | ||||
* Lobby server address to construct host JID. | * Lobby server address to construct host JID. | ||||
*/ | */ | ||||
const g_LobbyServer = Engine.ConfigDB_GetValue("user", "lobby.server"); | const g_LobbyServer = Engine.ConfigDB_GetValue("user", "lobby.server"); | ||||
/** | /** | ||||
ffffffff: not sure allowed making this const.
maybe var. | |||||
* 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" | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
var g_SelectedGamePort = ""; | var g_SelectedGamePort = ""; | ||||
/** | /** | ||||
* Whether the current user has been kicked or banned. | * Whether the current user has been kicked or banned. | ||||
*/ | */ | ||||
var g_Kicked = false; | var g_Kicked = false; | ||||
/* | |||||
* List of more buttons bar shown below chat input, when mouse hovering there. | |||||
*/ | |||||
var g_MoreButtonsBar = [ | |||||
{ "text": "Replays", "func": () => Engine.SwitchGuiPage("page_replaymenu.xml") }, | |||||
{ "text": "Last Summary", "func": () => lastSummary() }, | |||||
{ "text": "Civilizations", "func": () => Engine.PushGuiPage("page_structree.xml") }, | |||||
{ "text": "Options", "func": () => Engine.PushGuiPage("page_options.xml", { | |||||
"selectedCategory": "Lobby", | |||||
"callback": "initConfigurables" | |||||
})} | |||||
]; | |||||
/** | /** | ||||
* Processing of notifications sent by XmppClient.cpp. | * Processing of notifications sent by XmppClient.cpp. | ||||
* | * | ||||
* @returns true if the playerlist GUI must be updated. | * @returns true if the playerlist GUI must be updated. | ||||
*/ | */ | ||||
var g_NetMessageTypes = { | var g_NetMessageTypes = { | ||||
"system": { | "system": { | ||||
// Three cases are handled in prelobby.js | // Three cases are handled in prelobby.js | ||||
▲ Show 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | function init(attribs) | ||||
initGameFilters(); | initGameFilters(); | ||||
Engine.LobbySetPlayerPresence("available"); | Engine.LobbySetPlayerPresence("available"); | ||||
// When rejoining the lobby after a game, we don't need to process presence changes | // When rejoining the lobby after a game, we don't need to process presence changes | ||||
Engine.LobbyClearPresenceUpdates(); | Engine.LobbyClearPresenceUpdates(); | ||||
updatePlayerList(); | updatePlayerList(); | ||||
updateSubject(Engine.LobbyGetRoomSubject()); | updateSubject(Engine.LobbyGetRoomSubject()); | ||||
updateLobbyColumns(); | initConfigurables(); | ||||
updateToggleBuddy(); | updateToggleBuddy(); | ||||
Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey(); | Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey(); | ||||
// Get all messages since the login | // Get all messages since the login | ||||
for (let msg of Engine.LobbyGuiPollHistoricMessages()) | for (let msg of Engine.LobbyGuiPollHistoricMessages()) | ||||
g_NetMessageTypes[msg.type][msg.level](msg); | g_NetMessageTypes[msg.type][msg.level](msg); | ||||
} | } | ||||
function initConfigurables() | |||||
{ | |||||
updateLobbyColumns(); | |||||
initAutoHiddenButtons(); | |||||
} | |||||
function initAutoHiddenButtons() | |||||
{ | |||||
let showConfig = Engine.ConfigDB_GetValue("user", "gui.lobby.morebuttonsbar"); | |||||
let autoHideArea = Engine.GetGUIObjectByName("moreOptionsBarActionHide"); | |||||
let autoShowArea = Engine.GetGUIObjectByName("moreOptionsBarActionShow"); | |||||
autoHideArea.onmouseenter = () => true; | |||||
autoShowArea.onmouseenter = () => true; | |||||
if (showConfig == "hiding") | |||||
{ | |||||
autoHideArea.onmouseenter = () => showHiddenButtons(false); | |||||
autoShowArea.onmouseenter = () => showHiddenButtons(true); | |||||
} | |||||
showHiddenButtons(showConfig == "visible"); | |||||
if (showConfig == "disabled") | |||||
return; | |||||
let butWidthPercent = (1 / g_MoreButtonsBar.length) * 100; | |||||
for (let i in g_MoreButtonsBar) | |||||
{ | |||||
let but = Engine.GetGUIObjectByName("moreButtons[" + i + "]"); | |||||
but.hidden = false; | |||||
// Let gap "+2" between buttons and calculate size to fit space | |||||
but.size = i * butWidthPercent + "%" + (i > 0 ? "+2" : "") + " 100%-25 " + ((+i + 1) * butWidthPercent) + "%" + " 100%"; | |||||
but.caption = g_MoreButtonsBar[i].text; | |||||
but.onpress = g_MoreButtonsBar[i].func; | |||||
} | |||||
} | |||||
function showHiddenButtons(show) | |||||
{ | |||||
Engine.GetGUIObjectByName("moreOptionsBarActionHide").hidden = !show; | |||||
Engine.GetGUIObjectByName("chatPanel").size = show ? "0 49% 100% 100%-29" : "0 49% 100% 100%" | |||||
Engine.GetGUIObjectByName("moreButtons").hidden = !show; | |||||
} | |||||
function updateLobbyColumns() | function updateLobbyColumns() | ||||
{ | { | ||||
let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; | let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; | ||||
// Only show the selected columns | // Only show the selected columns | ||||
let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | ||||
gamesBox.hidden_mapType = gameRating; | gamesBox.hidden_mapType = gameRating; | ||||
gamesBox.hidden_gameRating = !gameRating; | gamesBox.hidden_gameRating = !gameRating; | ||||
▲ Show 20 Lines • Show All 1,058 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
not sure allowed making this const.
maybe var.