Changeset View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Context not available. | |||||
let game = g_GameList[i]; | let game = g_GameList[i]; | ||||
let gameName = escapeText(game.name); | let gameName = escapeText(game.name); | ||||
let mapTypeIdx = g_MapTypes.Name.indexOf(game.mapType); | let mapTypeIdx = g_MapTypes.Name.indexOf(game.mapType); | ||||
let observerNumbers = stringifiedTeamListToPlayerData(game.players).filter(player => { return player.Team == "observer"}).length; | |||||
Krinkle: The filter closure can be further simplified given it's only a single expression:
```lang=js
. | |||||
KrinkleUnsubmitted Done Inline ActionsHigher up in the code, the gamer.players string is also parsed. Rather than parsing it again, might be worth re-using that result here. Krinkle: Higher up in the code, the `gamer.players` string is also parsed. Rather than parsing it again… | |||||
if (game.ip == g_SelectedGameIP && game.port == g_SelectedGamePort) | if (game.ip == g_SelectedGameIP && game.port == g_SelectedGamePort) | ||||
selectedGameIndex = +i; | selectedGameIndex = +i; | ||||
Context not available. | |||||
list_mapName.push(translateMapTitle(game.niceMapName)); | list_mapName.push(translateMapTitle(game.niceMapName)); | ||||
list_mapSize.push(translateMapSize(game.mapSize)); | list_mapSize.push(translateMapSize(game.mapSize)); | ||||
list_mapType.push(g_MapTypes.Title[mapTypeIdx] || ""); | list_mapType.push(g_MapTypes.Title[mapTypeIdx] || ""); | ||||
list_nPlayers.push(game.nbp + "/" + game.maxnbp); | list_nPlayers.push(game.nbp + '/' + game.maxnbp + (observerNumbers > 0 ? '[color="0 128 128 128"]+' + observerNumbers + '[/color]' : '' )); | ||||
list.push(gameName); | list.push(gameName); | ||||
list_data.push(i); | list_data.push(i); | ||||
} | } | ||||
Context not available. | |||||
Not Done Inline ActionsWhy different quotes? vladislavbelov: Why different quotes? | |||||
Not Done Inline Actionsno mean change. ffffffff: no mean change. | |||||
Not Done Inline ActionsAnd empty line? vladislavbelov: And empty line? | |||||
Not Done Inline Actionsno mean change. ffffffff: no mean change. | |||||
Not Done Inline Actions(FYI: I change this number locally to e.g. 1, 2 or 14, to see what it would look like with that number of observers). Krinkle: //(FYI: I change this number locally to e.g. 1, 2 or 14, to see what it would look like with… | |||||
Done Inline ActionsMight be interesting to use setStringTags for this. See D2151. Stan: Might be interesting to use setStringTags for this. See D2151. | |||||
Done Inline Actionsindeed ffffffff: indeed | |||||
Done Inline ActionsTranslators won't know what this is about, so it should have a translation comment: Don't split the translate and sprintf, so that people see the string arguments right near the string. elexis: Translators won't know what this is about, so it should have a translation comment:
//… | |||||
Done Inline ActionsAt least it would be consistent to make "gray" a global. And the more recent version of that would be to use setStringTags, so that people can also specify a font alongside if they want. That += " " + is preventing translators to change the order of the arguments. Same for playerText and the "/" operator. So
(
But that won't work, since the english strings can only be specified for singular n=1 and plural n>1, but we need 0 and > 0 checks here. elexis: At least it would be consistent to make "gray" a global. And the more recent version of that… | |||||
Done Inline ActionsI don't know if the order needs to be localisable, and using plural for this seems like a workaround. Do you want me to split it into two separate messages? e.g. one for x/y and one for x/y +z? Krinkle: I don't know if the order needs to be localisable, and using plural for this seems like a… | |||||
Done Inline ActionsYes, the order should be localizable, everything that is displayed should be. Plural strings allow the translator to use a different format depending on the count.
Yes. It's not our task to judge what makes sense in every language, but to provide translators the choice to decide it for them. elexis: Yes, the order should be localizable, everything that is displayed should be.
Whenever there is… | |||||
Done Inline Actions(> 0 unneeded I guesS) elexis: (`> 0` unneeded I guesS) | |||||
Done Inline ActionsYeah, wasn't sure which style is preferred. Typecasting is sometimes frowned upon, but for properties where only one type is allowed, I think it's fair to expect the reader to know those rules for the shorter form to be an easily recognised idiom. Krinkle: Yeah, wasn't sure which style is preferred.
Typecasting is sometimes frowned upon, but for… | |||||
Done Inline Actions+%(observercount)s or +%(observers)s? elexis: `+%(observercount)s` or `+%(observers)s`? | |||||
Done Inline Actionsnon-bot players -> lobby players? Also seen "human player" somewhere. Otherwise bot -> AI. (Its also not obvious whether thats a bug, whether it should reflect human players or ingame players including AI. For example 2 human vs 6 AI player looks like 2/8, as in 6 missing, but theyre not missing. Can be changed, but not sure if it should, also OT) elexis: non-bot players -> lobby players? Also seen "human player" somewhere. Otherwise bot -> AI. | |||||
Not Done Inline ActionsThe duplication can be avoided by using game.observerCount ? translate("%(current)s/%(max)s +%(observercount)s") : translate("%(current)s/%(max)s") (optionally with ?\n :\n and some tabs) elexis: The duplication can be avoided by using `game.observerCount ? translate("%(current)s/%(max)s +%… | |||||
Not Done Inline ActionsThe duplication of what exactly? Do you mean we should pass all three variables to both? I avoided that as I wasn't sure whether that'd be allowed (might trip a warning for unused variable, depending on how strict we want things to be). The following could work though if that's preferred. let plainText = game.observerCount ? // Translation: The number of human players and observers in this game translate("%(current)s/%(max)s +%(observercount)s") : // Translation: The number of human players in this game translate("%(current)s/%(max)s"); let playerText = setStringTags(sprintf(plainText, { "current": game.nbp, "max": game.maxnbp, "observercount": game.observerCount }), g_ObserverCountTags); Krinkle: The duplication of what exactly? Do you mean we should pass all three variables to both?
I… | |||||
Not Done Inline Actions(Don't blame me, it was my computer science teacher who recommended to change if (x != y) to if (x==y) in if-else patterns to reduce the complexity by one operation) elexis: (Don't blame me, it was my computer science teacher who recommended to change `if (x != y)` to… | |||||
Not Done Inline ActionsThe gray g_ObserverCountTags is applied to the entire text, shouldn't the playercount have a different color? White and gray, or whatever. elexis: The gray `g_ObserverCountTags` is applied to the entire text, shouldn't the playercount have a… | |||||
Done Inline ActionsOne could say that the unification of the two sprintf's makes the close slightly slower, but then again one could care less if there are only < 30 games at a time and it costs probably something of the order of magnitude of 1 microseconds. elexis: One could say that the unification of the two sprintf's makes the close slightly slower, but… |
The filter closure can be further simplified given it's only a single expression: