Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/gamedescription.js
/** | /** | ||||
* Highlights the victory condition in the game-description. | * Highlights the victory condition in the game-description. | ||||
*/ | */ | ||||
var g_DescriptionHighlight = "orange"; | var g_DescriptionHighlight = "orange"; | ||||
/** | /** | ||||
* The rating assigned to lobby players who didn't complete a ranked 1v1 yet. | * The rating assigned to lobby players who didn't complete a ranked 1v1 yet. | ||||
*/ | */ | ||||
var g_DefaultLobbyRating = 1200; | var g_DefaultLobbyRating = 0; | ||||
/** | /** | ||||
* XEP-0172 doesn't restrict nicknames, but our lobby policy does. | * XEP-0172 doesn't restrict nicknames, but our lobby policy does. | ||||
* So use this human readable delimiter to separate buddy names in the config file. | * So use this human readable delimiter to separate buddy names in the config file. | ||||
*/ | */ | ||||
var g_BuddyListDelimiter = ","; | var g_BuddyListDelimiter = ","; | ||||
/** | /** | ||||
* Returns the nickname without the lobby rating. | * @Returns {object} containing the name and rating seperately. | ||||
*/ | */ | ||||
function splitRatingFromNick(playerName) | function splitRatingFromNick(playerName) | ||||
{ | { | ||||
let result = /^(\S+)\ \((\d+)\)$/g.exec(playerName); | let result = /^(\S+)\ \((\d+)\)$/g.exec(playerName); | ||||
return { "nick": result ? result[1] : playerName, "rating": result ? +result[2] : "" }; | return { "nick": result ? result[1] : playerName, "rating": result ? +result[2] : "" }; | ||||
} | } | ||||
/** | /** | ||||
* Array of playernames that the current user has marked as buddies. | * Array of playernames that the current user has marked as buddies. | ||||
*/ | */ | ||||
var g_Buddies = Engine.ConfigDB_GetValue("user", "lobby.buddies").split(g_BuddyListDelimiter); | var g_Buddies = Engine.ConfigDB_GetValue("user", "lobby.buddies").split(g_BuddyListDelimiter); | ||||
/** | /** | ||||
* Denotes which players are a lobby buddy of the current user. | |||||
*/ | |||||
var g_BuddySymbol = '•'; | |||||
/** | |||||
* Returns a formatted string describing the player assignments. | * Returns a formatted string describing the player assignments. | ||||
* Needs g_CivData to translate! | * Needs g_CivData to translate! | ||||
* | * | ||||
* @param {Object} playerDataArray - As known from game setup and sim state. | * @param {Object} playerDataArray - As known from game setup and sim state. | ||||
* @param {(string[]|false)} playerStates - One of "won", "defeated", "active" for each player. | * @param {(string[]|false)} playerStates - One of "won", "defeated", "active" for each player. | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function formatPlayerInfo(playerDataArray, playerStates) | function formatPlayerInfo(playerDataArray, playerStates) | ||||
{ | { | ||||
let playerDescriptions = {}; | let playerDescriptions = {}; | ||||
Silier: please revert the one space addition | |||||
GrapjasAuthorUnsubmitted Done Inline ActionsSure, but why? Grapjas: Sure, but why? | |||||
SilierUnsubmitted Not Done Inline Actionsbecause there is mechanism called "blame" which tracks who changed line as the last and this is making harder to track relevant changes Silier: because there is mechanism called "blame" which tracks who changed line as the last and this is… | |||||
GrapjasAuthorUnsubmitted Done Inline ActionsI see what you mean, but isn't it wrong to have a leading space everywhere? Shouldn't it be fixed? Grapjas: I see what you mean, but isn't it wrong to have a leading space everywhere? Shouldn't it be… | |||||
let playerIdx = 0; | let playerIdx = 0; | ||||
for (let playerData of playerDataArray) | for (let playerData of playerDataArray) | ||||
{ | { | ||||
if (playerData == null || playerData.Civ && playerData.Civ == "gaia") | if (playerData == null || playerData.Civ && playerData.Civ == "gaia") | ||||
continue; | continue; | ||||
++playerIdx; | ++playerIdx; | ||||
let teamIdx = playerData.Team; | let teamIdx = playerData.Team; | ||||
let isAI = playerData.AI && playerData.AI != ""; | let isAI = playerData.AI && playerData.AI != ""; | ||||
let playerState = playerStates && playerStates[playerIdx] || playerData.State; | let playerState = playerStates && playerStates[playerIdx] || playerData.State; | ||||
let isActive = !playerState || playerState == "active"; | let isActive = !playerState || playerState == "active"; | ||||
let playerDescription; | let playerDescription; | ||||
if (isAI) | if (isAI) | ||||
{ | { | ||||
if (playerData.Civ) | if (playerData.Civ) | ||||
{ | { | ||||
if (isActive) | if (isActive) | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(civ)s, %(AIdescription)s)"); | playerDescription = translate("%(status)s %(civ)s %(playerName)s (%(AIdescription)s)"); | ||||
else | else | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(civ)s, %(AIdescription)s, %(state)s)"); | playerDescription = translate("%(status)s %(civ)s %(state)s %(playerName)s (%(AIdescription)s)"); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (isActive) | if (isActive) | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(AIdescription)s)"); | playerDescription = translate("%(status)s %(playerName)s (%(AIdescription)s)"); | ||||
else | else | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(AIdescription)s, %(state)s)"); | playerDescription = translate("%(status)s %(state)s %(playerName)s (%(AIdescription)s)"); | ||||
} | } | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (playerData.Offline) | if (playerData.Offline) | ||||
{ | { | ||||
// Can only occur in the lobby for now, so no strings with civ needed | // Can only occur in the lobby for now. | ||||
if (isActive) | if (isActive) | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (OFFLINE)"); | playerDescription = "%(status)s %(civ)s %(playerName)s"; | ||||
else | else | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (OFFLINE, %(state)s)"); | playerDescription = "%(status)s %(civ)s %(state)s %(playerName)s"; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (playerData.Civ) | if (playerData.Civ) | ||||
if (isActive) | if (isActive) | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(civ)s)"); | playerDescription = "%(civ)s %(playerName)s"; | ||||
else | else | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(civ)s, %(state)s)"); | playerDescription = "%(civ)s %(state)s %(playerName)s"; | ||||
else | else | ||||
if (isActive) | if (isActive) | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s"); | playerDescription = "%(playerName)s"; | ||||
else | else | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(state)s)"); | playerDescription = "%(state)s %(playerName)s"; | ||||
} | } | ||||
} | } | ||||
// Sort player descriptions by team | // Sort player descriptions by team | ||||
if (!playerDescriptions[teamIdx]) | if (!playerDescriptions[teamIdx]) | ||||
playerDescriptions[teamIdx] = []; | playerDescriptions[teamIdx] = []; | ||||
let playerNick = splitRatingFromNick(playerData.Name).nick; | let playerNick = splitRatingFromNick(playerData.Name).nick; | ||||
SilierUnsubmitted Not Done Inline ActionsI would cache this to variable splitRatingFromNick(playerData.Name) and then do .rating and .nick on that variable also let -> const on anything that will not be changed Silier: I would cache this to variable `splitRatingFromNick(playerData.Name)` and then do .rating and . | |||||
playerDescriptions[teamIdx].push(sprintf(playerDescription, { | |||||
let playerRating = splitRatingFromNick(playerData.Name).rating; | |||||
playerRating ? playerRating = ' (' + PlayerColor.ColorByRating(playerRating) + ')' : playerRating = ""; | |||||
playerDescriptions[teamIdx].push(setStringTags(sprintf(playerDescription, { | |||||
"playerName": | "playerName": | ||||
coloredText( | (g_Buddies.indexOf(playerNick) != -1 ? setStringTags(g_BuddySymbol, PlayerColor.ColorTags.buddyIcon) + " " : "") + | ||||
(g_Buddies.indexOf(playerNick) != -1 ? g_BuddySymbol + " " : "") + | PlayerColor.ColorPlayerNameByRole(escapeText(playerNick), Engine.LobbyGetPlayerRole(playerNick)) + playerRating, | ||||
escapeText(playerData.Name), | |||||
(typeof getPlayerColor == 'function' ? | |||||
(isAI ? "white" : getPlayerColor(playerNick)) : | |||||
rgbToGuiColor(playerData.Color || g_Settings.PlayerDefaults[playerIdx].Color))), | |||||
Not Done Inline Actionsi think this should stay because colours are from the match Silier: i think this should stay because colours are from the match | |||||
Done Inline Actionsdon't understand what you mean, reword it. It colors player names in game details, which would only be white or purple as defined by playercolor function. Grapjas: don't understand what you mean, reword it. It colors player names in game details, which would… | |||||
"civ": | "civ": | ||||
!playerData.Civ ? | !playerData.Civ ? | ||||
translate("Unknown Civilization") : | translate("Unknown Civilization") : | ||||
g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ? | g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ? | ||||
translate(g_CivData[playerData.Civ].Name) : | '[icon="icon_' + playerData.Civ + '"]' : playerData.Civ, | ||||
playerData.Civ, | |||||
"status": | |||||
isAI ? '[icon="icon_bot"]' : '[icon="icon_offline"]', | |||||
"state": | "state": | ||||
playerState == "defeated" ? | playerState == "defeated" ? '[icon="icon_defeated"]' : '[icon="icon_victorious"]', | ||||
translateWithContext("playerstate", "defeated") : | |||||
translateWithContext("playerstate", "won"), | "AIdescription": setStringTags(translateAISettings(playerData), PlayerColor.ColorTags.username) | ||||
}), { "tooltip": PlayerTooltip() })); | |||||
function PlayerTooltip() { | |||||
let txt = ""; | |||||
let civ = !playerData.Civ ? translate("Unknown Civilization") : | |||||
g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ? | |||||
g_CivData[playerData.Civ].Name : playerData.Civ; | |||||
if (playerData.Offline || isAI) | |||||
{ | |||||
txt += translate("Status") + ": "; | |||||
txt += isAI ? translateAIName(playerData.AI) + "\n" : translate("Offline") + "\n"; | |||||
} | |||||
if (playerData.Civ) | |||||
txt += translate("Civilization") + ": " + civ + "\n"; | |||||
if (playerState) | |||||
{ | |||||
txt += translate("State") + ": "; | |||||
txt += (playerState == "defeated") ? translate("Defeated") + "\n" : translate("Victorious") + "\n"; | |||||
} | |||||
return txt; | |||||
}; | |||||
"AIdescription": translateAISettings(playerData) | |||||
})); | |||||
} | } | ||||
let teams = Object.keys(playerDescriptions); | let teams = Object.keys(playerDescriptions); | ||||
if (teams.indexOf("observer") > -1) | if (teams.indexOf("observer") > -1) | ||||
teams.splice(teams.indexOf("observer"), 1); | teams.splice(teams.indexOf("observer"), 1); | ||||
let teamDescription = []; | let teamDescription = []; | ||||
// If there are no teams, merge all playersDescriptions | // If there are no teams, merge all playersDescriptions | ||||
if (teams.length == 1) | if (teams.length == 1) | ||||
teamDescription.push(playerDescriptions[teams[0]].join("\n")); | teamDescription.push(playerDescriptions[teams[0]].join("\n")); | ||||
// If there are teams, merge "Team N:" + playerDescriptions | // If there are teams, merge "Team N:" + playerDescriptions | ||||
else | else | ||||
teamDescription = teams.map(team => { | teamDescription = teams.map(team => { | ||||
let teamCaption = team == -1 ? | let teamCaption = team == -1 ? | ||||
translate("No Team") : | translate("No Team") : | ||||
sprintf(translate("Team %(team)s"), { "team": +team + 1 }); | sprintf(translate("Team %(team)s"), { "team": +team + 1 }); | ||||
// Translation: Describe players of one team in a selected game, f.e. in the replay- or savegame menu or lobby | // Translation: Describe players of one team in a selected game, f.e. in the replay- or savegame menu or lobby | ||||
return sprintf(translate("%(team)s:\n%(playerDescriptions)s"), { | return sprintf(translate("%(team)s:\n%(playerDescriptions)s"), { | ||||
"team": '[font="sans-bold-14"]' + teamCaption + "[/font]", | "team": setStringTags(teamCaption, GameDetails.prototype.CaptionTags), | ||||
"playerDescriptions": playerDescriptions[team].join("\n") | "playerDescriptions": playerDescriptions[team].join("\n") | ||||
}); | }); | ||||
}); | }); | ||||
if (playerDescriptions.observer) | if (playerDescriptions.observer) | ||||
teamDescription.push(sprintf(translate("%(team)s:\n%(playerDescriptions)s"), { | teamDescription.push(sprintf(translate("%(team)s:\n%(playerDescriptions)s"), { | ||||
"team": '[font="sans-bold-14"]' + translatePlural("Observer", "Observers", playerDescriptions.observer.length) + "[/font]", | "team": setStringTags(translatePlural("Observer", "Observers", playerDescriptions.observer.length), GameDetails.prototype.CaptionTags), | ||||
"playerDescriptions": playerDescriptions.observer.join("\n") | "playerDescriptions": playerDescriptions.observer.join("\n") | ||||
})); | })); | ||||
return teamDescription.join("\n\n"); | return teamDescription.join("\n\n"); | ||||
} | } | ||||
/** | /** | ||||
* Sets an additional map label, map preview image and describes the chosen game settings more closely. | * Sets an additional map label, map preview image and describes the chosen game settings more closely. | ||||
* | * | ||||
* Requires g_VictoryConditions. | * Requires g_VictoryConditions. | ||||
*/ | */ | ||||
function getGameDescription(initAttributes, mapCache) | function getGameDescription(initAttributes, mapCache) | ||||
{ | { | ||||
let titles = []; | let titles = []; | ||||
if (!initAttributes.settings.VictoryConditions.length) | if (!initAttributes.settings.VictoryConditions.length) | ||||
titles.push({ | titles.push({ | ||||
"label": translateWithContext("victory condition", "Endless Game"), | "label": translateWithContext("victory condition", "Endless Game"), | ||||
"value": translate("No winner will be determined, even if everyone is defeated.") | "value": translate("No winner will be determined, even if everyone is defeated.") | ||||
}); | }); | ||||
for (let victoryCondition of g_VictoryConditions) | for (let victoryCondition of g_VictoryConditions) | ||||
{ | { | ||||
if (initAttributes.settings.VictoryConditions.indexOf(victoryCondition.Name) == -1) | if (initAttributes.settings.VictoryConditions.indexOf(victoryCondition.Name) == -1) | ||||
continue; | continue; | ||||
let title = translateVictoryCondition(victoryCondition.Name); | let title = translateVictoryCondition(victoryCondition.Name); | ||||
if (victoryCondition.Name == "wonder") | if (victoryCondition.Name == "wonder") | ||||
{ | { | ||||
let wonderDuration = Math.round(initAttributes.settings.WonderDuration); | let wonderDuration = Math.round(initAttributes.settings.WonderDuration); | ||||
title = sprintf( | title = sprintf( | ||||
translatePluralWithContext( | translatePluralWithContext( | ||||
"victory condition", | "victory condition", | ||||
"Wonder (%(min)s minute)", | "Wonder (%(min)s minute)", | ||||
"Wonder (%(min)s minutes)", | "Wonder (%(min)s minutes)", | ||||
wonderDuration | wonderDuration | ||||
), | ), | ||||
{ "min": wonderDuration }); | { "min": wonderDuration }); | ||||
} | } | ||||
let isCaptureTheRelic = victoryCondition.Name == "capture_the_relic"; | let isCaptureTheRelic = victoryCondition.Name == "capture_the_relic"; | ||||
if (isCaptureTheRelic) | if (isCaptureTheRelic) | ||||
{ | { | ||||
let relicDuration = Math.round(initAttributes.settings.RelicDuration); | let relicDuration = Math.round(initAttributes.settings.RelicDuration); | ||||
title = sprintf( | title = sprintf( | ||||
translatePluralWithContext( | translatePluralWithContext( | ||||
"victory condition", | "victory condition", | ||||
"Capture the Relic (%(min)s minute)", | "Capture the Relic (%(min)s minute)", | ||||
"Capture the Relic (%(min)s minutes)", | "Capture the Relic (%(min)s minutes)", | ||||
relicDuration | relicDuration | ||||
), | ), | ||||
{ "min": relicDuration }); | { "min": relicDuration }); | ||||
} | } | ||||
titles.push({ | titles.push({ | ||||
"label": title, | "label": title, | ||||
"value": victoryCondition.Description | "value": victoryCondition.Description | ||||
}); | }); | ||||
if (isCaptureTheRelic) | if (isCaptureTheRelic) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Relic Count"), | "label": translate("Relic Count"), | ||||
"value": Math.round(initAttributes.settings.RelicCount) | "value": Math.round(initAttributes.settings.RelicCount) | ||||
}); | }); | ||||
if (victoryCondition.Name == "regicide") | if (victoryCondition.Name == "regicide") | ||||
if (initAttributes.settings.RegicideGarrison) | if (initAttributes.settings.RegicideGarrison) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Hero Garrison"), | "label": translate("Hero Garrison"), | ||||
"value": translate("Heroes can be garrisoned.") | "value": translate("Heroes can be garrisoned.") | ||||
}); | }); | ||||
else | else | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Exposed Heroes"), | "label": translate("Exposed Heroes"), | ||||
"value": translate("Heroes cannot be garrisoned and they are vulnerable to raids.") | "value": translate("Heroes cannot be garrisoned and they are vulnerable to raids.") | ||||
}); | }); | ||||
} | } | ||||
if (initAttributes.settings.LockTeams) | if (initAttributes.settings.LockTeams) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Locked Teams"), | "label": translate("Locked Teams"), | ||||
"value": translate("Players can't change the initial teams.") | "value": translate("Players can't change the initial teams.") | ||||
}); | }); | ||||
else | else | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Diplomacy"), | "label": translate("Diplomacy"), | ||||
"value": translate("Players can make alliances and declare war on allies.") | "value": translate("Players can make alliances and declare war on allies.") | ||||
}); | }); | ||||
if (initAttributes.settings.LastManStanding) | if (initAttributes.settings.LastManStanding) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Last Man Standing"), | "label": translate("Last Man Standing"), | ||||
"value": translate("Only one player can win the game. If the remaining players are allies, the game continues until only one remains.") | "value": translate("Only one player can win the game. If the remaining players are allies, the game continues until only one remains.") | ||||
}); | }); | ||||
else | else | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Allied Victory"), | "label": translate("Allied Victory"), | ||||
"value": translate("If one player wins, his or her allies win too. If one group of allies remains, they win.") | "value": translate("If one player wins, his or her allies win too. If one group of allies remains, they win.") | ||||
}); | }); | ||||
let ceasefire = Math.round(initAttributes.settings.Ceasefire); | let ceasefire = Math.round(initAttributes.settings.Ceasefire); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Ceasefire"), | "label": translate("Ceasefire"), | ||||
"value": | "value": | ||||
!ceasefire ? | !ceasefire ? | ||||
translate("disabled") : | translate("disabled") : | ||||
ceasefire == 1 ? | ceasefire == 1 ? | ||||
translate("For the first minute, other players will stay neutral.") : | translate("For the first minute, other players will stay neutral.") : | ||||
sprintf(translatePlural( | sprintf(translatePlural( | ||||
"For the first %(min)s minute, other players will stay neutral.", | "For the first %(min)s minute, other players will stay neutral.", | ||||
"For the first %(min)s minutes, other players will stay neutral.", | "For the first %(min)s minutes, other players will stay neutral.", | ||||
ceasefire), | ceasefire), | ||||
{ "min": ceasefire }) | { "min": ceasefire }) | ||||
}); | }); | ||||
if (initAttributes.map == "random") | if (initAttributes.map == "random") | ||||
titles.push({ | titles.push({ | ||||
"label": translateWithContext("Map Selection", "Random Map"), | "label": translateWithContext("Map Selection", "Random Map"), | ||||
"value": translate("Randomly select a map from the list.") | "value": translate("Randomly select a map from the list.") | ||||
}); | }); | ||||
else | else | ||||
{ | { | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Name"), | "label": translate("Map Name"), | ||||
"value": mapCache.translateMapName( | "value": mapCache.translateMapName( | ||||
mapCache.getTranslatableMapName(initAttributes.mapType, initAttributes.map, initAttributes)) | mapCache.getTranslatableMapName(initAttributes.mapType, initAttributes.map, initAttributes)) | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Description"), | "label": translate("Map Description"), | ||||
"value": mapCache.getTranslatedMapDescription(initAttributes.mapType, initAttributes.map) | "value": mapCache.getTranslatedMapDescription(initAttributes.mapType, initAttributes.map) | ||||
}); | }); | ||||
} | } | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Type"), | "label": translate("Map Type"), | ||||
"value": g_MapTypes.Title[g_MapTypes.Name.indexOf(initAttributes.mapType)] | "value": g_MapTypes.Title[g_MapTypes.Name.indexOf(initAttributes.mapType)] | ||||
}); | }); | ||||
if (initAttributes.mapType == "random") | if (initAttributes.mapType == "random") | ||||
{ | { | ||||
let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(initAttributes.settings.Size)]; | let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(initAttributes.settings.Size)]; | ||||
if (mapSize) | if (mapSize) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Size"), | "label": translate("Map Size"), | ||||
"value": mapSize | "value": mapSize | ||||
}); | }); | ||||
} | } | ||||
if (initAttributes.settings.Biome) | if (initAttributes.settings.Biome) | ||||
{ | { | ||||
let biome = g_Settings.Biomes.find(b => b.Id == initAttributes.settings.Biome); | let biome = g_Settings.Biomes.find(b => b.Id == initAttributes.settings.Biome); | ||||
titles.push({ | titles.push({ | ||||
"label": biome ? biome.Title : translateWithContext("biome", "Random Biome"), | "label": biome ? biome.Title : translateWithContext("biome", "Random Biome"), | ||||
"value": biome ? biome.Description : translate("Randomly select a biome from the list.") | "value": biome ? biome.Description : translate("Randomly select a biome from the list.") | ||||
}); | }); | ||||
} | } | ||||
if (initAttributes.settings.TriggerDifficulty !== undefined) | if (initAttributes.settings.TriggerDifficulty !== undefined) | ||||
{ | { | ||||
let triggerDifficulty = g_Settings.TriggerDifficulties.find(difficulty => difficulty.Difficulty == initAttributes.settings.TriggerDifficulty); | let triggerDifficulty = g_Settings.TriggerDifficulties.find(difficulty => difficulty.Difficulty == initAttributes.settings.TriggerDifficulty); | ||||
titles.push({ | titles.push({ | ||||
"label": triggerDifficulty.Title, | "label": triggerDifficulty.Title, | ||||
"value": triggerDifficulty.Tooltip | "value": triggerDifficulty.Tooltip | ||||
}); | }); | ||||
} | } | ||||
if (initAttributes.settings.Nomad !== undefined) | if (initAttributes.settings.Nomad !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": initAttributes.settings.Nomad ? translate("Nomad Mode") : translate("Civic Centers"), | "label": initAttributes.settings.Nomad ? translate("Nomad Mode") : translate("Civic Centers"), | ||||
"value": | "value": | ||||
initAttributes.settings.Nomad ? | initAttributes.settings.Nomad ? | ||||
translate("Players start with only few units and have to find a suitable place to build their city.") : | translate("Players start with only few units and have to find a suitable place to build their city.") : | ||||
translate("Players start with a Civic Center.") | translate("Players start with a Civic Center.") | ||||
}); | }); | ||||
if (initAttributes.settings.StartingResources !== undefined) | if (initAttributes.settings.StartingResources !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Starting Resources"), | "label": translate("Starting Resources"), | ||||
"value": | "value": | ||||
initAttributes.settings.PlayerData && | initAttributes.settings.PlayerData && | ||||
initAttributes.settings.PlayerData.some(pData => pData && pData.Resources !== undefined) ? | initAttributes.settings.PlayerData.some(pData => pData && pData.Resources !== undefined) ? | ||||
translateWithContext("starting resources", "Per Player") : | translateWithContext("starting resources", "Per Player") : | ||||
sprintf(translate("%(startingResourcesTitle)s (%(amount)s)"), { | sprintf(translate("%(startingResourcesTitle)s (%(amount)s)"), { | ||||
"startingResourcesTitle": | "startingResourcesTitle": | ||||
g_StartingResources.Title[ | g_StartingResources.Title[ | ||||
g_StartingResources.Resources.indexOf( | g_StartingResources.Resources.indexOf( | ||||
initAttributes.settings.StartingResources)], | initAttributes.settings.StartingResources)], | ||||
"amount": initAttributes.settings.StartingResources | "amount": initAttributes.settings.StartingResources | ||||
}) | }) | ||||
}); | }); | ||||
if (initAttributes.settings.PopulationCap !== undefined) | if (initAttributes.settings.PopulationCap !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Population Limit"), | "label": translate("Population Limit"), | ||||
"value": | "value": | ||||
initAttributes.settings.PlayerData && | initAttributes.settings.PlayerData && | ||||
initAttributes.settings.PlayerData.some(pData => pData && pData.PopulationLimit !== undefined) ? | initAttributes.settings.PlayerData.some(pData => pData && pData.PopulationLimit !== undefined) ? | ||||
translateWithContext("population limit", "Per Player") : | translateWithContext("population limit", "Per Player") : | ||||
g_PopulationCapacities.Title[ | g_PopulationCapacities.Title[ | ||||
g_PopulationCapacities.Population.indexOf( | g_PopulationCapacities.Population.indexOf( | ||||
initAttributes.settings.PopulationCap)] | initAttributes.settings.PopulationCap)] | ||||
}); | }); | ||||
if (initAttributes.settings.WorldPopulationCap !== undefined) | if (initAttributes.settings.WorldPopulationCap !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("World Population Cap"), | "label": translate("World Population Cap"), | ||||
"value": | "value": | ||||
g_WorldPopulationCapacities.Title[ | g_WorldPopulationCapacities.Title[ | ||||
g_WorldPopulationCapacities.Population.indexOf( | g_WorldPopulationCapacities.Population.indexOf( | ||||
initAttributes.settings.WorldPopulationCap)] | initAttributes.settings.WorldPopulationCap)] | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Treasures"), | "label": translate("Treasures"), | ||||
"value": initAttributes.settings.DisableTreasures ? | "value": initAttributes.settings.DisableTreasures ? | ||||
translateWithContext("treasures", "Disabled") : | translateWithContext("treasures", "Disabled") : | ||||
translateWithContext("treasures", "As defined by the map.") | translateWithContext("treasures", "As defined by the map.") | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Explored Map"), | "label": translate("Explored Map"), | ||||
"value": initAttributes.settings.ExploreMap | "value": initAttributes.settings.ExploreMap | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Revealed Map"), | "label": translate("Revealed Map"), | ||||
"value": initAttributes.settings.RevealMap | "value": initAttributes.settings.RevealMap | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Allied View"), | "label": translate("Allied View"), | ||||
"value": initAttributes.settings.AllyView | "value": initAttributes.settings.AllyView | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Cheats"), | "label": translate("Cheats"), | ||||
"value": initAttributes.settings.CheatsEnabled | "value": initAttributes.settings.CheatsEnabled | ||||
}); | }); | ||||
const ratingDescription = translate("When the winner of this match is determined, the lobby score will be adapted."); | const ratingDescription = translate("When the winner of this match is determined, the lobby score will be adapted."); | ||||
if (initAttributes.settings.RatingEnabled && | if (initAttributes.settings.RatingEnabled && | ||||
initAttributes.settings.PlayerData.length == 2) | initAttributes.settings.PlayerData.length == 2) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Rated game"), | "label": translate("Rated game"), | ||||
"value": ratingDescription | "value": ratingDescription | ||||
}); | }); | ||||
else if (g_IsNetworked && Engine.HasXmppClient()) | else if (g_IsNetworked && Engine.HasXmppClient()) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Rated game"), | "label": translate("Rated game"), | ||||
"value": initAttributes.settings.RatingEnabled === true ? ratingDescription : translateWithContext("game setup option", "disabled") | "value": initAttributes.settings.RatingEnabled === true ? ratingDescription : translateWithContext("game setup option", "disabled") | ||||
}); | }); | ||||
return titles.map(title => sprintf(translate("%(label)s %(details)s"), { | return titles.map(title => sprintf(translate("%(label)s %(details)s"), { | ||||
"label": coloredText(title.label, g_DescriptionHighlight), | "label": coloredText(title.label, g_DescriptionHighlight), | ||||
"details": | "details": | ||||
title.value === true ? translateWithContext("game setup option", "enabled") : | title.value === true ? translateWithContext("game setup option", "enabled") : | ||||
title.value || translateWithContext("game setup option", "disabled") | title.value || translateWithContext("game setup option", "disabled") | ||||
})).join("\n"); | })).join("\n"); | ||||
} | } | ||||
/** | /** | ||||
* Sets the win/defeat icon to indicate current player's state. | * Sets the win/defeat icon to indicate current player's state. | ||||
*/ | */ | ||||
function setOutcomeIcon(state, image) | function setOutcomeIcon(state, image) | ||||
{ | { | ||||
if (state == "won") | if (state == "won") | ||||
{ | { | ||||
image.sprite = "stretched:session/icons/victory.png"; | image.sprite = "stretched:session/icons/victory.png"; | ||||
image.tooltip = translate("Victorious"); | image.tooltip = translate("Victorious"); | ||||
} | } | ||||
else if (state == "defeated") | else if (state == "defeated") | ||||
{ | { | ||||
image.sprite = "stretched:session/icons/defeat.png"; | image.sprite = "stretched:session/icons/defeat.png"; | ||||
image.tooltip = translate("Defeated"); | image.tooltip = translate("Defeated"); | ||||
} | } | ||||
} | } | ||||
function translateAISettings(playerData) | function translateAISettings(playerData) | ||||
{ | { | ||||
if (!playerData.AI) | if (!playerData.AI) | ||||
return ""; | return ""; | ||||
return sprintf(translate("%(AIdifficulty)s %(AIbehavior)s %(AIname)s"), { | return sprintf(translate("%(AIdifficulty)s"), { | ||||
"AIplayername": playerData.Name, | |||||
"AIname": translateAIName(playerData.AI), | "AIname": translateAIName(playerData.AI), | ||||
"AIdifficulty": translateAIDifficulty(playerData.AIDiff), | "AIdifficulty": translateAIDifficulty(playerData.AIDiff), | ||||
"AIbehavior": translateAIBehavior(playerData.AIBehavior), | "AIbehavior": translateAIBehavior(playerData.AIBehavior), | ||||
}); | }); | ||||
} | } | ||||
No newline at end of file |
Wildfire Games · Phabricator
please revert the one space addition