diff --git a/binaries/data/mods/public/gui/common/tooltips.js b/binaries/data/mods/public/gui/common/tooltips.js index 9ceb00c72c..a6c5ec01df 100644 --- a/binaries/data/mods/public/gui/common/tooltips.js +++ b/binaries/data/mods/public/gui/common/tooltips.js @@ -353,14 +353,14 @@ function multiplyEntityCosts(template, trainNum) /** * Helper function for getEntityCostTooltip. */ -function getEntityCostComponentsTooltipString(template, trainNum, entity) +function getEntityCostComponentsTooltipString(template, entity, buildingsCountToTrainFullBatch = 1, fullBatchSize = 1, remainderBatch = 0) { - if (!trainNum) - trainNum = 1; - - let totalCosts = multiplyEntityCosts(template, trainNum); + let totalCosts = multiplyEntityCosts(template, buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch); if (template.cost.time) - totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { "entity": entity, "batchSize": trainNum }) : 1)); + totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { + "entity": entity, + "batchSize": buildingsCountToTrainFullBatch > 0 ? fullBatchSize : remainderBatch + }) : 1)); let costs = []; for (let type in template.cost) @@ -493,7 +493,7 @@ function getWallPieceTooltip(wallTypes) /** * Returns the cost information to display in the specified entity's construction button tooltip. */ -function getEntityCostTooltip(template, trainNum, entity) +function getEntityCostTooltip(template, entity, buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch) { // Entities with a wallset component are proxies for initiating wall placement and as such do not have a cost of // their own; the individual wall pieces within it do. @@ -512,7 +512,7 @@ function getEntityCostTooltip(template, trainNum, entity) } if (template.cost) - return getEntityCostComponentsTooltipString(template, trainNum, entity).join(" "); + return getEntityCostComponentsTooltipString(template, entity, buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch).join(" "); return ""; } diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index d83cfd245e..cf8e41898e 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -1423,7 +1423,7 @@ function addResearchToQueue(entity, researchType) /** * Returns the number of units that will be present in a batch if the user clicks - * the training button with shift down + * the training button depending on the batch training modifier hotkey */ function getTrainingStatus(playerState, trainEntType, selection) { @@ -1445,10 +1445,13 @@ function getTrainingStatus(playerState, trainEntType, selection) limits = getEntityLimitAndCount(playerState, trainEntType); // We need to calculate count after the next increment if it's possible - if (limits.canBeAddedCount == undefined || - limits.canBeAddedCount > nextBatchTrainingCount * appropriateBuildings.length) + if ((limits.canBeAddedCount == undefined || + limits.canBeAddedCount > nextBatchTrainingCount * appropriateBuildings.length) && + Engine.HotkeyIsPressed("session.batchtrain")) nextBatchTrainingCount += batchIncrementSize; + nextBatchTrainingCount = Math.max(nextBatchTrainingCount, 1); + // If training limits don't allow us to train batchTrainingCount in each appropriate building // train as many full batches as we can and remainer in one more building. var buildingsCountToTrainFullBatch = appropriateBuildings.length; diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js index 79fb843f1f..785996cdd8 100644 --- a/binaries/data/mods/public/gui/session/selection_panels.js +++ b/binaries/data/mods/public/gui/session/selection_panels.js @@ -986,9 +986,7 @@ g_SelectionPanels.Training = { let [buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch] = getTrainingStatus(data.playerState, data.item, data.unitEntStates.map(status => status.id)); - let trainNum = buildingsCountToTrainFullBatch || 1; - if (Engine.HotkeyIsPressed("session.batchtrain")) - trainNum = buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch; + let trainNum = buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch; let neededResources; if (template.cost) @@ -1010,7 +1008,7 @@ g_SelectionPanels.Training = { getVisibleEntityClassesFormatted(template), getAurasTooltip(template), getEntityTooltip(template), - getEntityCostTooltip(template, trainNum, data.unitEntStates[0].id) + getEntityCostTooltip(template, data.unitEntStates[0].id, buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch) ]; let limits = getEntityLimitAndCount(data.playerState, data.item);