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"; | ||||
/** | /** | ||||
* 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. | |||||
*/ | |||||
var g_BuddyListDelimiter = ","; | |||||
/** | |||||
* Array of playernames that the current user has marked as buddies. | |||||
*/ | |||||
var g_Buddies = Engine.ConfigDB_GetValue("user", "lobby.buddies").split(g_BuddyListDelimiter); | |||||
Imarok: Why not just use a normal js array and `JSON.stringify()`/`JSON.parse()` to save/load it?
Then… | |||||
elexisAuthorUnsubmitted Not Done Inline ActionsWanted to keep that user.cfg editable by humans elexis: Wanted to keep that user.cfg editable by humans | |||||
ImarokUnsubmitted Not Done Inline ActionsÄhhmm, JSON is human readable ^^ Imarok: Ähhmm, JSON is human readable ^^ | |||||
elexisAuthorUnsubmitted Not Done Inline ActionsStill easy to introduce syntax errors for non-programmers since quotes must match everywhere, no trailing comma, array braces, potentially escaping. Better have it as simple as possible -> CSV elexis: Still easy to introduce syntax errors for non-programmers since quotes must match everywhere… | |||||
ImarokUnsubmitted Not Done Inline ActionsWhy should users edit the buddy list manually? Imarok: Why should users edit the buddy list manually? | |||||
/** | |||||
* Denotes which players are a lobby buddy of the current user. | |||||
*/ | |||||
var g_BuddySymbol = '•'; | |||||
/** | |||||
* Removes the lobby rating from a players nickname. | |||||
*/ | |||||
function removeRatingFromNick(playerName) | |||||
ffffffffUnsubmitted Not Done Inline Actionsthis can be stored in some common file e.g. binaries/data/mods/public/gui/common/functions_utility.js as we can us it then also in other files like gamesdescription.js or so ffffffff: this can be stored in some common file e.g. binaries/data/mods/public/gui/common/functions_util… | |||||
{ | |||||
let result = /^(\S+)\ \(\d+\)$/g.exec(playerName); | |||||
return result ? result[1] : playerName; | |||||
} | |||||
/** | |||||
* Returns map description and preview image or placeholder. | * Returns map description and preview image or placeholder. | ||||
*/ | */ | ||||
function getMapDescriptionAndPreview(mapType, mapName) | function getMapDescriptionAndPreview(mapType, mapName) | ||||
{ | { | ||||
let mapData; | let mapData; | ||||
if (mapType == "random" && mapName == "random") | if (mapType == "random" && mapName == "random") | ||||
mapData = { "settings": { "Description": translate("A randomly selected map.") } }; | mapData = { "settings": { "Description": translate("A randomly selected map.") } }; | ||||
else if (mapType == "random" && Engine.FileExists(mapName + ".json")) | else if (mapType == "random" && Engine.FileExists(mapName + ".json")) | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (!playerDescriptions[teamIdx]) | ||||
playerDescriptions[teamIdx] = []; | playerDescriptions[teamIdx] = []; | ||||
playerDescriptions[teamIdx].push(sprintf(playerDescription, { | playerDescriptions[teamIdx].push(sprintf(playerDescription, { | ||||
"playerName": | "playerName": | ||||
'[color="' + | '[color="' + | ||||
(typeof getPlayerColor == 'function' ? | (typeof getPlayerColor == 'function' ? | ||||
(isAI ? "white" : getPlayerColor(playerData.Name)) : | (isAI ? "white" : getPlayerColor(playerData.Name)) : | ||||
rgbToGuiColor(playerData.Color || g_Settings.PlayerDefaults[playerIdx].Color)) + | rgbToGuiColor(playerData.Color || g_Settings.PlayerDefaults[playerIdx].Color)) + | ||||
'"]' + escapeText(playerData.Name) + "[/color]", | '"]' + | ||||
(g_Buddies.indexOf(removeRatingFromNick(playerData.Name)) != -1 ? g_BuddySymbol + " " : "") + | |||||
escapeText(playerData.Name) + | |||||
"[/color]", | |||||
"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) : | translate(g_CivData[playerData.Civ].Name) : | ||||
playerData.Civ, | playerData.Civ, | ||||
▲ Show 20 Lines • Show All 230 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Why not just use a normal js array and JSON.stringify()/JSON.parse() to save/load it?
Then you'll have no problems with names containing g_BuddyListDelimiter.