Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | "getItems": function() | ||||
return getAllBuildableEntitiesFromSelection(); | return getAllBuildableEntitiesFromSelection(); | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
let template = GetTemplateData(data.item); | let template = GetTemplateData(data.item); | ||||
if (!template) | if (!template) | ||||
return false; | return false; | ||||
let technologyEnabled = Engine.GuiInterfaceCall("IsTechnologyResearched", { | let technologyEnabled = Engine.GuiInterfaceCall("AreTechnologiesResearched", { | ||||
"tech": template.requiredTechnology, | "techs": template.requiredTechnologies, | ||||
"player": data.player | "player": data.player | ||||
}); | }); | ||||
let neededResources; | let neededResources; | ||||
if (template.cost) | if (template.cost) | ||||
neededResources = Engine.GuiInterfaceCall("GetNeededResources", { | neededResources = Engine.GuiInterfaceCall("GetNeededResources", { | ||||
"cost": multiplyEntityCosts(template, 1), | "cost": multiplyEntityCosts(template, 1), | ||||
"player": data.player | "player": data.player | ||||
Show All 11 Lines | let tooltips = [ | ||||
getGarrisonTooltip, | getGarrisonTooltip, | ||||
getPopulationBonusTooltip, | getPopulationBonusTooltip, | ||||
showTemplateViewerOnRightClickTooltip | showTemplateViewerOnRightClickTooltip | ||||
].map(func => func(template)); | ].map(func => func(template)); | ||||
let limits = getEntityLimitAndCount(data.playerState, data.item); | let limits = getEntityLimitAndCount(data.playerState, data.item); | ||||
tooltips.push( | tooltips.push( | ||||
formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers), | formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers), | ||||
getRequiredTechnologyTooltip(technologyEnabled, template.requiredTechnology, GetSimState().players[data.player].civ), | getRequiredTechnologyTooltip(technologyEnabled, template.requiredTechnologies, GetSimState().players[data.player].civ), | ||||
getNeededResourcesTooltip(neededResources)); | getNeededResourcesTooltip(neededResources)); | ||||
data.button.tooltip = tooltips.filter(tip => tip).join("\n"); | data.button.tooltip = tooltips.filter(tip => tip).join("\n"); | ||||
let modifier = ""; | let modifier = ""; | ||||
if (!technologyEnabled || limits.canBeAddedCount == 0) | if (!technologyEnabled || limits.canBeAddedCount == 0) | ||||
{ | { | ||||
data.button.enabled = false; | data.button.enabled = false; | ||||
▲ Show 20 Lines • Show All 667 Lines • ▼ Show 20 Lines | "getItems": function() | ||||
return getAllTrainableEntitiesFromSelection(); | return getAllTrainableEntitiesFromSelection(); | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
let template = GetTemplateData(data.item); | let template = GetTemplateData(data.item); | ||||
if (!template) | if (!template) | ||||
return false; | return false; | ||||
let technologyEnabled = Engine.GuiInterfaceCall("IsTechnologyResearched", { | let technologyEnabled = Engine.GuiInterfaceCall("AreTechnologiesResearched", { | ||||
"tech": template.requiredTechnology, | "techs": template.requiredTechnologies, | ||||
"player": data.player | "player": data.player | ||||
}); | }); | ||||
let unitIds = data.unitEntStates.map(status => status.id) | let unitIds = data.unitEntStates.map(status => status.id) | ||||
let [buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch] = | let [buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch] = | ||||
getTrainingStatus(unitIds, data.item, data.playerState); | getTrainingStatus(unitIds, data.item, data.playerState); | ||||
let trainNum = buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch; | let trainNum = buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch; | ||||
Show All 38 Lines | if (Engine.ConfigDB_GetValue("user", "showdetailedtooltips") === "true") | ||||
getGarrisonTooltip, | getGarrisonTooltip, | ||||
getProjectilesTooltip, | getProjectilesTooltip, | ||||
getSpeedTooltip | getSpeedTooltip | ||||
].map(func => func(template))); | ].map(func => func(template))); | ||||
tooltips.push(showTemplateViewerOnRightClickTooltip()); | tooltips.push(showTemplateViewerOnRightClickTooltip()); | ||||
tooltips.push( | tooltips.push( | ||||
formatBatchTrainingString(buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch), | formatBatchTrainingString(buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch), | ||||
getRequiredTechnologyTooltip(technologyEnabled, template.requiredTechnology, GetSimState().players[data.player].civ), | getRequiredTechnologyTooltip(technologyEnabled, template.requiredTechnologies, GetSimState().players[data.player].civ), | ||||
getNeededResourcesTooltip(neededResources)); | getNeededResourcesTooltip(neededResources)); | ||||
data.button.tooltip = tooltips.filter(tip => tip).join("\n"); | data.button.tooltip = tooltips.filter(tip => tip).join("\n"); | ||||
let modifier = ""; | let modifier = ""; | ||||
if (!technologyEnabled || limits.canBeAddedCount == 0) | if (!technologyEnabled || limits.canBeAddedCount == 0) | ||||
{ | { | ||||
data.button.enabled = false; | data.button.enabled = false; | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator