Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels_helpers.js
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | case "passive": | ||||
return translateWithContext("stance", "Flee if attacked"); | return translateWithContext("stance", "Flee if attacked"); | ||||
case "standground": | case "standground": | ||||
return translateWithContext("stance", "Attack opponents in range, but don't move"); | return translateWithContext("stance", "Attack opponents in range, but don't move"); | ||||
default: | default: | ||||
return ""; | return ""; | ||||
} | } | ||||
} | } | ||||
function getPrefAttackDisplay(name) | |||||
{ | |||||
let text = {}; | |||||
text.name = sprintf(translateWithContext("attack type", "%(name)s"), { | |||||
"name": name | |||||
}); | |||||
text.tooltip = name == "Default" ? translate("Let the unit decide.") : | |||||
sprintf(translate("Prefer %(name)s attack."), { | |||||
"name": translateWithContext("attack type", name) | |||||
}); | |||||
return text; | |||||
} | |||||
/** | /** | ||||
* Format entity count/limit message for the tooltip | * Format entity count/limit message for the tooltip | ||||
*/ | */ | ||||
function formatLimitString(trainEntLimit, trainEntCount, trainEntLimitChangers) | function formatLimitString(trainEntLimit, trainEntCount, trainEntLimitChangers) | ||||
{ | { | ||||
if (trainEntLimit == undefined) | if (trainEntLimit == undefined) | ||||
return ""; | return ""; | ||||
var text = sprintf(translate("Current Count: %(count)s, Limit: %(limit)s."), { | var text = sprintf(translate("Current Count: %(count)s, Limit: %(limit)s."), { | ||||
"count": trainEntCount, | "count": trainEntCount, | ||||
"limit": trainEntLimit | "limit": trainEntLimit | ||||
}); | }); | ||||
if (trainEntCount >= trainEntLimit) | if (trainEntCount >= trainEntLimit) | ||||
text = coloredText(text, "red"); | text = coloredText(text, "red"); | ||||
for (var c in trainEntLimitChangers) | for (var c in trainEntLimitChangers) | ||||
{ | { | ||||
if (!trainEntLimitChangers[c]) | if (!trainEntLimitChangers[c]) | ||||
continue; | continue; | ||||
Freagarach: Can be generalised. | |||||
let string = trainEntLimitChangers[c] > 0 ? | let string = trainEntLimitChangers[c] > 0 ? | ||||
translate("%(changer)s enlarges the limit with %(change)s.") : | translate("%(changer)s enlarges the limit with %(change)s.") : | ||||
translate("%(changer)s lessens the limit with %(change)s."); | translate("%(changer)s lessens the limit with %(change)s."); | ||||
text += "\n" + sprintf(string, { | text += "\n" + sprintf(string, { | ||||
"changer": translate(c), | "changer": translate(c), | ||||
"change": trainEntLimitChangers[c] | "change": trainEntLimitChangers[c] | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | function performStance(entities, stanceName) | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "stance", | "type": "stance", | ||||
"entities": entities, | "entities": entities, | ||||
"name": stanceName | "name": stanceName | ||||
}); | }); | ||||
} | } | ||||
function performPrefAttack(entities, prefAttackType) | |||||
{ | |||||
if (!entities) | |||||
return; | |||||
Engine.PostNetworkCommand({ | |||||
"type": "prefAttackType", | |||||
"entities": entities, | |||||
"name": prefAttackType | |||||
}); | |||||
} | |||||
function lockGate(lock) | function lockGate(lock) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "lock-gate", | "type": "lock-gate", | ||||
"entities": g_Selection.toList(), | "entities": g_Selection.toList(), | ||||
"lock": lock | "lock": lock | ||||
}); | }); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Can be generalised.