Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | var g_PlayerAssignmentColors = { | ||||
"observer": "170 170 250", | "observer": "170 170 250", | ||||
"unassigned": "140 140 140", | "unassigned": "140 140 140", | ||||
"AI": "70 150 70" | "AI": "70 150 70" | ||||
}; | }; | ||||
/** | /** | ||||
* Used for highlighting the sender of chat messages. | * Used for highlighting the sender of chat messages. | ||||
*/ | */ | ||||
var g_SenderFont = "sans-bold-13"; | var g_SenderFontTag = { "font": "sans-bold-13" }; | ||||
/** | /** | ||||
* This yields [1, 2, ..., MaxPlayers]. | * This yields [1, 2, ..., MaxPlayers]. | ||||
*/ | */ | ||||
var g_NumPlayersList = Array(g_MaxPlayers).fill(0).map((v, i) => i + 1); | var g_NumPlayersList = Array(g_MaxPlayers).fill(0).map((v, i) => i + 1); | ||||
/** | /** | ||||
* Used for generating the botnames. | * Used for generating the botnames. | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | var g_ReadyData = [ | ||||
}, | }, | ||||
{ | { | ||||
"color": "green", | "color": "green", | ||||
"chat": translate("* %(username)s is ready!"), | "chat": translate("* %(username)s is ready!"), | ||||
"caption": translate("Stay ready"), | "caption": translate("Stay ready"), | ||||
"tooltip": translate("Stay ready even when the game settings change.") | "tooltip": translate("Stay ready even when the game settings change.") | ||||
}, | }, | ||||
{ | { | ||||
"color": "150 150 250", | "color": "150 150 250", | ||||
elexis: The name could clarify whether "text" means the chat, caption or tooltip. Seems to be… | |||||
"chat": "", | "chat": "", | ||||
"caption": translate("I'm not ready!"), | "caption": translate("I'm not ready!"), | ||||
"tooltip": translate("State that you are not ready to play.") | "tooltip": translate("State that you are not ready to play.") | ||||
} | } | ||||
]; | ]; | ||||
/** | /** | ||||
* Processes a CNetMessage (see NetMessage.h, NetMessages.h) sent by the CNetServer. | * Processes a CNetMessage (see NetMessage.h, NetMessages.h) sent by the CNetServer. | ||||
▲ Show 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | "populationCap": { | ||||
"tooltip": (hoverIdx) => { | "tooltip": (hoverIdx) => { | ||||
let popCap = g_PopulationCapacities.Population[hoverIdx]; | let popCap = g_PopulationCapacities.Population[hoverIdx]; | ||||
let players = g_GameAttributes.settings.PlayerData.length; | let players = g_GameAttributes.settings.PlayerData.length; | ||||
if (hoverIdx == -1 || popCap * players <= g_PopulationCapacityRecommendation) | if (hoverIdx == -1 || popCap * players <= g_PopulationCapacityRecommendation) | ||||
return translate("Select population limit."); | return translate("Select population limit."); | ||||
return coloredText( | return setStringTags( | ||||
sprintf(translate("Warning: There might be performance issues if all %(players)s players reach %(popCap)s population."), { | sprintf(translate("Warning: There might be performance issues if all %(players)s players reach %(popCap)s population."), { | ||||
"players": players, | "players": players, | ||||
"popCap": popCap | "popCap": popCap | ||||
}), | }), | ||||
"orange"); | { "color": "orange" }); | ||||
}, | }, | ||||
"labels": () => g_PopulationCapacities.Title, | "labels": () => g_PopulationCapacities.Title, | ||||
"ids": () => g_PopulationCapacities.Population, | "ids": () => g_PopulationCapacities.Population, | ||||
"default": () => g_PopulationCapacities.Default, | "default": () => g_PopulationCapacities.Default, | ||||
"defined": () => g_GameAttributes.settings.PopulationCap !== undefined, | "defined": () => g_GameAttributes.settings.PopulationCap !== undefined, | ||||
"get": () => g_GameAttributes.settings.PopulationCap, | "get": () => g_GameAttributes.settings.PopulationCap, | ||||
"select": (itemIdx) => { | "select": (itemIdx) => { | ||||
g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[itemIdx]; | g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[itemIdx]; | ||||
▲ Show 20 Lines • Show All 484 Lines • ▼ Show 20 Lines | "caption": (playerIdx) => { | ||||
let pData = g_GameAttributes.settings.PlayerData[playerIdx]; | let pData = g_GameAttributes.settings.PlayerData[playerIdx]; | ||||
let assignedGUID = Object.keys(g_PlayerAssignments).find( | let assignedGUID = Object.keys(g_PlayerAssignments).find( | ||||
guid => g_PlayerAssignments[guid].player == playerIdx + 1); | guid => g_PlayerAssignments[guid].player == playerIdx + 1); | ||||
let name = translate(pData.Name || g_DefaultPlayerData[playerIdx].Name); | let name = translate(pData.Name || g_DefaultPlayerData[playerIdx].Name); | ||||
if (g_IsNetworked) | if (g_IsNetworked) | ||||
name = coloredText(name, g_ReadyData[assignedGUID ? g_PlayerAssignments[assignedGUID].status : 2].color); | name = setStringTags(name, { "color": g_ReadyData[assignedGUID ? g_PlayerAssignments[assignedGUID].status : 2].color }); | ||||
return name; | return name; | ||||
}, | }, | ||||
}, | }, | ||||
"playerColor": { | "playerColor": { | ||||
"sprite": (playerIdx) => "color:" + rgbToGuiColor(g_GameAttributes.settings.PlayerData[playerIdx].Color, 100), | "sprite": (playerIdx) => "color:" + rgbToGuiColor(g_GameAttributes.settings.PlayerData[playerIdx].Color, 100), | ||||
}, | }, | ||||
"playerConfig": { | "playerConfig": { | ||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | function initDropdown(name, playerIdx) | ||||
let [guiName, guiType, guiIdx] = getGUIObjectNameFromSetting(name); | let [guiName, guiType, guiIdx] = getGUIObjectNameFromSetting(name); | ||||
let idxName = playerIdx === undefined ? "" : "[" + playerIdx + "]"; | let idxName = playerIdx === undefined ? "" : "[" + playerIdx + "]"; | ||||
let data = (playerIdx === undefined ? g_Dropdowns : g_PlayerDropdowns)[name]; | let data = (playerIdx === undefined ? g_Dropdowns : g_PlayerDropdowns)[name]; | ||||
let dropdown = Engine.GetGUIObjectByName(guiName + guiType + guiIdx + idxName); | let dropdown = Engine.GetGUIObjectByName(guiName + guiType + guiIdx + idxName); | ||||
dropdown.list = data.labels(playerIdx).map((label, id) => | dropdown.list = data.labels(playerIdx).map((label, id) => | ||||
data.colors && data.colors(playerIdx) ? | data.colors && data.colors(playerIdx) ? | ||||
coloredText(label, data.colors(playerIdx)[id]) : | setStringTags(label, { "color": data.colors(playerIdx)[id] }) : | ||||
Done Inline Actions(same) elexis: (same) | |||||
Done Inline Actionsas? Freagarach: as? | |||||
Not Done Inline ActionsWhat are the benefits and disadvantages of this hunk? elexis: What are the benefits and disadvantages of this hunk? | |||||
label); | label); | ||||
dropdown.list_data = data.ids(playerIdx); | dropdown.list_data = data.ids(playerIdx); | ||||
dropdown.onSelectionChange = function() { | dropdown.onSelectionChange = function() { | ||||
if (!g_IsController || | if (!g_IsController || | ||||
g_IsInGuiUpdate || | g_IsInGuiUpdate || | ||||
▲ Show 20 Lines • Show All 1,176 Lines • ▼ Show 20 Lines | function submitChatInput() | ||||
if (!executeNetworkCommand(text)) | if (!executeNetworkCommand(text)) | ||||
Engine.SendNetworkChat(text); | Engine.SendNetworkChat(text); | ||||
chatInput.focus(); | chatInput.focus(); | ||||
} | } | ||||
function senderFont(text) | function senderFont(text) | ||||
{ | { | ||||
return '[font="' + g_SenderFont + '"]' + text + '[/font]'; | return setStringTags(text, g_SenderFontTag); | ||||
} | } | ||||
function systemMessage(message) | function systemMessage(message) | ||||
{ | { | ||||
return senderFont(sprintf(translate("== %(message)s"), { "message": message })); | return senderFont(sprintf(translate("== %(message)s"), { "message": message })); | ||||
} | } | ||||
function colorizePlayernameByGUID(guid, username = "") | function colorizePlayernameByGUID(guid, username = "") | ||||
Show All 10 Lines | if (playerID > 0) | ||||
// Enlighten playercolor to improve readability | // Enlighten playercolor to improve readability | ||||
let [h, s, l] = rgbToHsl(color.r, color.g, color.b); | let [h, s, l] = rgbToHsl(color.r, color.g, color.b); | ||||
let [r, g, b] = hslToRgb(h, s, Math.max(0.6, l)); | let [r, g, b] = hslToRgb(h, s, Math.max(0.6, l)); | ||||
color = rgbToGuiColor({ "r": r, "g": g, "b": b }); | color = rgbToGuiColor({ "r": r, "g": g, "b": b }); | ||||
} | } | ||||
return coloredText(username, color); | return setStringTags(username, { "color": color }); | ||||
Done Inline Actions(same) elexis: (same) | |||||
Done Inline Actionsas? Freagarach: as? | |||||
} | } | ||||
function addChatMessage(msg) | function addChatMessage(msg) | ||||
{ | { | ||||
if (!g_FormatChatMessage[msg.type]) | if (!g_FormatChatMessage[msg.type]) | ||||
return; | return; | ||||
if (msg.type == "chat") | if (msg.type == "chat") | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
The name could clarify whether "text" means the chat, caption or tooltip. Seems to be captionTags.