Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 511 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 setColor( | ||||
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"); | "orange"); | ||||
}, | }, | ||||
"labels": () => g_PopulationCapacities.Title, | "labels": () => g_PopulationCapacities.Title, | ||||
"ids": () => g_PopulationCapacities.Population, | "ids": () => g_PopulationCapacities.Population, | ||||
▲ Show 20 Lines • Show All 408 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 = setColor(name, 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 173 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]) : | setColor(label, data.colors(playerIdx)[id]) : | ||||
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,094 Lines • ▼ Show 20 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 setColor(username, color); | ||||
} | } | ||||
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 194 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator