Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | if (data.item === NULL_FORMATION) | ||||
translate("Default formation is disabled.") : | translate("Default formation is disabled.") : | ||||
translate("Right-click to disable the default formation feature.")); | translate("Right-click to disable the default formation feature.")); | ||||
else | else | ||||
tooltip += "\n" + (isDefaultFormation ? | tooltip += "\n" + (isDefaultFormation ? | ||||
translate("This is the default formation, used for movement orders.") : | translate("This is the default formation, used for movement orders.") : | ||||
translate("Right-click to set this as the default formation.")); | translate("Right-click to set this as the default formation.")); | ||||
if (!formationOk && formationInfo.tooltip) | if (!formationOk && formationInfo.tooltip) | ||||
tooltip += "\n" + coloredText(translate(formationInfo.tooltip), "red"); | tooltip += "\n" + objectionFont(translate(formationInfo.tooltip)); | ||||
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; | ||||
data.countDisplay.hidden = !isDefaultFormation; | data.countDisplay.hidden = !isDefaultFormation; | ||||
data.icon.sprite = "stretched:" + grayscale + "session/icons/" + formationInfo.icon; | data.icon.sprite = "stretched:" + grayscale + "session/icons/" + formationInfo.icon; | ||||
▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
} | } | ||||
data.button.onPress = function() { removeFromProductionQueue(data.item.producingEnt, queuedItem.id); }; | data.button.onPress = function() { removeFromProductionQueue(data.item.producingEnt, queuedItem.id); }; | ||||
const tooltips = [getEntityNames(template)]; | const tooltips = [getEntityNames(template)]; | ||||
if (data.item.ghost) | if (data.item.ghost) | ||||
tooltips.push(translate("The auto-queue will try to train this item later.")); | tooltips.push(translate("The auto-queue will try to train this item later.")); | ||||
if (queuedItem.neededSlots) | if (queuedItem.neededSlots) | ||||
{ | { | ||||
tooltips.push(coloredText(translate("Insufficient population capacity:"), "red")); | tooltips.push(objectionFont(translate("Insufficient population capacity:"))); | ||||
tooltips.push(sprintf(translate("%(population)s %(neededSlots)s"), { | tooltips.push(sprintf(translate("%(population)s %(neededSlots)s"), { | ||||
"population": resourceIcon("population"), | "population": resourceIcon("population"), | ||||
"neededSlots": queuedItem.neededSlots | "neededSlots": queuedItem.neededSlots | ||||
})); | })); | ||||
} | } | ||||
tooltips.push(showTemplateViewerOnRightClickTooltip(template)); | tooltips.push(showTemplateViewerOnRightClickTooltip(template)); | ||||
data.button.tooltip = tooltips.join("\n"); | data.button.tooltip = tooltips.join("\n"); | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | for (let tech of data.item.tech.pair ? [data.item.tech.bottom, data.item.tech.top] : [data.item.tech]) | ||||
"class": translate(entity.class) | "class": translate(entity.class) | ||||
})); | })); | ||||
} | } | ||||
tip += " " + sprintf(translate("Remaining: %(entityCounts)s"), { | tip += " " + sprintf(translate("Remaining: %(entityCounts)s"), { | ||||
"entityCounts": entityCounts.join(translateWithContext("Separator for a list of entity counts", ", ")) | "entityCounts": entityCounts.join(translateWithContext("Separator for a list of entity counts", ", ")) | ||||
}); | }); | ||||
} | } | ||||
tooltips.push(tip); | tooltips.push(objectionFont(tip)); | ||||
} | } | ||||
tooltips.push(getNeededResourcesTooltip(neededResources)); | tooltips.push(getNeededResourcesTooltip(neededResources)); | ||||
button.tooltip = tooltips.filter(tip => tip).join("\n"); | button.tooltip = tooltips.filter(tip => tip).join("\n"); | ||||
button.onPress = (t => function() { | button.onPress = (t => function() { | ||||
addResearchToQueue(data.item.researchFacilityId, t); | addResearchToQueue(data.item.researchFacilityId, t); | ||||
})(tech); | })(tech); | ||||
Show All 32 Lines | for (let tech of data.item.tech.pair ? [data.item.tech.bottom, data.item.tech.top] : [data.item.tech]) | ||||
} | } | ||||
else | else | ||||
button.enabled = controlsPlayer(data.player); | button.enabled = controlsPlayer(data.player); | ||||
if (data.item.isUpgrading) | if (data.item.isUpgrading) | ||||
{ | { | ||||
button.enabled = false; | button.enabled = false; | ||||
modifier += "color:0 0 0 127:grayscale:"; | modifier += "color:0 0 0 127:grayscale:"; | ||||
button.tooltip += "\n" + coloredText(translate("Cannot research while upgrading."), "red"); | button.tooltip += "\n" + objectionFont(translate("Cannot research while upgrading.")); | ||||
} | } | ||||
if (template.icon) | if (template.icon) | ||||
icon.sprite = modifier + "stretched:session/portraits/" + template.icon; | icon.sprite = modifier + "stretched:session/portraits/" + template.icon; | ||||
setPanelObjectPosition(button, position, data.rowLength); | setPanelObjectPosition(button, position, data.rowLength); | ||||
▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | else | ||||
if (neededResources) | if (neededResources) | ||||
modifier = resourcesToAlphaMask(neededResources) + ":"; | modifier = resourcesToAlphaMask(neededResources) + ":"; | ||||
} | } | ||||
if (data.unitEntStates.every(state => state.upgrade && state.upgrade.isUpgrading)) | if (data.unitEntStates.every(state => state.upgrade && state.upgrade.isUpgrading)) | ||||
{ | { | ||||
data.button.enabled = false; | data.button.enabled = false; | ||||
modifier = "color:0 0 0 127:grayscale:"; | modifier = "color:0 0 0 127:grayscale:"; | ||||
data.button.tooltip += "\n" + coloredText(translate("Cannot train while upgrading."), "red"); | data.button.tooltip += "\n" + objectionFont(translate("Cannot train while upgrading.")); | ||||
} | } | ||||
if (template.icon) | if (template.icon) | ||||
data.icon.sprite = modifier + "stretched:session/portraits/" + template.icon; | data.icon.sprite = modifier + "stretched:session/portraits/" + template.icon; | ||||
let index = data.i + getNumberOfRightPanelButtons(); | let index = data.i + getNumberOfRightPanelButtons(); | ||||
setPanelObjectPosition(data.button, index, data.rowLength); | setPanelObjectPosition(data.button, index, data.rowLength); | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | else if (upgradingEntStates.length) | ||||
let progressOverlaySize = progressOverlay.size; | let progressOverlaySize = progressOverlay.size; | ||||
// TODO This is bad: we assume the progressOverlay is square | // TODO This is bad: we assume the progressOverlay is square | ||||
progressOverlaySize.top = progressOverlaySize.bottom + Math.round((1 - progress) * (progressOverlaySize.left - progressOverlaySize.right)); | progressOverlaySize.top = progressOverlaySize.bottom + Math.round((1 - progress) * (progressOverlaySize.left - progressOverlaySize.right)); | ||||
progressOverlay.size = progressOverlaySize; | progressOverlay.size = progressOverlaySize; | ||||
progressOverlay.hidden = false; | progressOverlay.hidden = false; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
tooltip = coloredText(translatePlural( | tooltip = objectionFont(translatePlural( | ||||
"Cannot upgrade when the entity is training, researching or already upgrading.", | "Cannot upgrade when the entity is training, researching or already upgrading.", | ||||
"Cannot upgrade when all entities are training, researching or already upgrading.", | "Cannot upgrade when all entities are training, researching or already upgrading.", | ||||
data.unitEntStates.length), "red"); | data.unitEntStates.length)); | ||||
data.button.onPress = function() {}; | data.button.onPress = function() {}; | ||||
data.button.enabled = false; | data.button.enabled = false; | ||||
modifier = "color:0 0 0 127:grayscale:"; | modifier = "color:0 0 0 127:grayscale:"; | ||||
} | } | ||||
data.button.enabled = controlsPlayer(data.player); | data.button.enabled = controlsPlayer(data.player); | ||||
data.button.tooltip = tooltip; | data.button.tooltip = tooltip; | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator