Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | let formationSelected = Engine.GuiInterfaceCall("IsFormationSelected", { | ||||
"ents": unitIds, | "ents": unitIds, | ||||
"formationTemplate": data.item | "formationTemplate": data.item | ||||
}); | }); | ||||
data.button.onPress = function() { | data.button.onPress = function() { | ||||
performFormation(unitIds, data.item); | performFormation(unitIds, data.item); | ||||
}; | }; | ||||
// This is called often, so we do not use setStringTags here, since it would create a new object on every call. | |||||
let tooltip = translate(formationInfo.name); | let tooltip = translate(formationInfo.name); | ||||
if (!formationOk && formationInfo.tooltip) | if (!formationOk && formationInfo.tooltip) | ||||
tooltip += "\n" + coloredText(translate(formationInfo.tooltip), "red"); | tooltip += "\n" + coloredText(translate(formationInfo.tooltip), "red"); | ||||
data.button.tooltip = tooltip; | data.button.tooltip = tooltip; | ||||
data.button.enabled = formationOk && controlsPlayer(data.player); | data.button.enabled = formationOk && controlsPlayer(data.player); | ||||
let grayscale = formationOk ? "" : "grayscale:"; | let grayscale = formationOk ? "" : "grayscale:"; | ||||
data.guiSelection.hidden = !formationSelected; | data.guiSelection.hidden = !formationSelected; | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | else | ||||
return false; | return false; | ||||
} | } | ||||
data.button.onPress = function() { removeFromProductionQueue(data.item.producingEnt, queuedItem.id); }; | data.button.onPress = function() { removeFromProductionQueue(data.item.producingEnt, queuedItem.id); }; | ||||
let tooltip = getEntityNames(template); | let tooltip = getEntityNames(template); | ||||
if (queuedItem.neededSlots) | if (queuedItem.neededSlots) | ||||
{ | { | ||||
tooltip += "\n" + coloredText(translate("Insufficient population capacity:"), "red"); | tooltip += "\n" + setStringTags(translate("Insufficient population capacity:"), g_TooltipTextFormats.insufficient); | ||||
tooltip += "\n" + sprintf(translate("%(population)s %(neededSlots)s"), { | tooltip += "\n" + sprintf(translate("%(population)s %(neededSlots)s"), { | ||||
"population": resourceIcon("population"), | "population": resourceIcon("population"), | ||||
"neededSlots": queuedItem.neededSlots | "neededSlots": queuedItem.neededSlots | ||||
}); | }); | ||||
} | } | ||||
data.button.tooltip = tooltip; | data.button.tooltip = tooltip; | ||||
data.countDisplay.caption = queuedItem.count > 1 ? queuedItem.count : ""; | data.countDisplay.caption = queuedItem.count > 1 ? queuedItem.count : ""; | ||||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Lines | "getItems": function(unitEntStates) | ||||
return unitEntStates[0].unitAI.selectableStances; | return unitEntStates[0].unitAI.selectableStances; | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
let unitIds = data.unitEntStates.map(state => state.id); | let unitIds = data.unitEntStates.map(state => state.id); | ||||
data.button.onPress = function() { performStance(unitIds, data.item); }; | data.button.onPress = function() { performStance(unitIds, data.item); }; | ||||
data.button.tooltip = getStanceDisplayName(data.item) + "\n" + | data.button.tooltip = headerFont(getStanceDisplayName(data.item)) + "\n" + | ||||
"[font=\"sans-13\"]" + getStanceTooltip(data.item) + "[/font]"; | bodyFont(getStanceTooltip(data.item)); | ||||
data.guiSelection.hidden = !Engine.GuiInterfaceCall("IsStanceSelected", { | data.guiSelection.hidden = !Engine.GuiInterfaceCall("IsStanceSelected", { | ||||
"ents": unitIds, | "ents": unitIds, | ||||
"stance": data.item | "stance": data.item | ||||
}); | }); | ||||
data.icon.sprite = "stretched:session/icons/stances/" + data.item + ".png"; | data.icon.sprite = "stretched:session/icons/stances/" + data.item + ".png"; | ||||
data.button.enabled = controlsPlayer(data.player); | data.button.enabled = controlsPlayer(data.player); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
}; | }; | ||||
data.button.onPressRight = function() { | data.button.onPressRight = function() { | ||||
showTemplateDetails(data.item); | showTemplateDetails(data.item); | ||||
}; | }; | ||||
data.countDisplay.caption = trainNum > 1 ? trainNum : ""; | data.countDisplay.caption = trainNum > 1 ? trainNum : ""; | ||||
let tooltips = [ | let tooltips = [ | ||||
"[font=\"sans-bold-16\"]" + | setStringTags( | ||||
colorizeHotkey("%(hotkey)s", "session.queueunit." + (data.i + 1)) + | colorizeHotkey("%(hotkey)s", "session.queueunit." + (data.i + 1)), | ||||
"[/font]" + " " + getEntityNamesFormatted(template), | g_TooltipTextFormats.nameGeneric | ||||
) + " " + getEntityNamesFormatted(template), | |||||
getVisibleEntityClassesFormatted(template), | getVisibleEntityClassesFormatted(template), | ||||
getAurasTooltip(template), | getAurasTooltip(template), | ||||
getEntityTooltip(template), | getEntityTooltip(template), | ||||
getEntityCostTooltip(template, unitIds[0], buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch) | getEntityCostTooltip(template, unitIds[0], buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch) | ||||
]; | ]; | ||||
let limits = getEntityLimitAndCount(data.playerState, data.item); | let limits = getEntityLimitAndCount(data.playerState, data.item); | ||||
tooltips.push(formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers)); | tooltips.push(formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers)); | ||||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator