Index: binaries/data/mods/public/gui/session/input.js =================================================================== --- binaries/data/mods/public/gui/session/input.js +++ binaries/data/mods/public/gui/session/input.js @@ -1574,16 +1574,6 @@ }); } -function lockGate(lock) -{ - var selection = g_Selection.toList(); - Engine.PostNetworkCommand({ - "type": "lock-gate", - "entities": selection, - "lock": lock, - }); -} - function packUnit(pack) { var selection = g_Selection.toList(); @@ -1606,21 +1596,22 @@ }); } -function upgradeEntity(Template) +function chargeAbility(ability) { Engine.PostNetworkCommand({ - "type": "upgrade", + "type": "charge-ability", "entities": g_Selection.toList(), - "template": Template, + "ability": ability, "queued": false }); } -function cancelUpgradeEntity() +function cancelChargeAbility(ability) { Engine.PostNetworkCommand({ - "type": "cancel-upgrade", + "type": "cancel-charge-ability", "entities": g_Selection.toList(), + "ability": ability, "queued": false }); } Index: binaries/data/mods/public/gui/session/selection_panels.js =================================================================== --- binaries/data/mods/public/gui/session/selection_panels.js +++ binaries/data/mods/public/gui/session/selection_panels.js @@ -432,65 +432,6 @@ } }; -g_SelectionPanels.Gate = { - "getMaxNumberOfItems": function() - { - return 24 - getNumberOfRightPanelButtons(); - }, - "getItems": function(unitEntStates) - { - let gates = []; - for (let state of unitEntStates) - { - if (state.gate && !gates.length) - { - gates.push({ - "gate": state.gate, - "tooltip": translate("Lock Gate"), - "locked": true, - "callback": function (item) { lockGate(item.locked); } - }, - { - "gate": state.gate, - "tooltip": translate("Unlock Gate"), - "locked": false, - "callback": function (item) { lockGate(item.locked); } - }); - } - // Show both 'locked' and 'unlocked' as active if the selected gates have both lock states. - else if (state.gate && state.gate.locked != gates[0].gate.locked) - for (let j = 0; j < gates.length; ++j) - delete gates[j].gate.locked; - } - - return gates; - }, - "setupButton": function(data) - { - data.button.onPress = function() {data.item.callback(data.item); }; - - data.button.tooltip = data.item.tooltip; - - data.button.enabled = controlsPlayer(data.player); - let gateIcon; - if (data.item.gate) - { - // show locking actions - gateIcon = "icons/lock_" + GATE_ACTIONS[data.item.locked ? 0 : 1] + "ed.png"; - if (data.item.gate.locked === undefined) - data.guiSelection.hidden = false; - else - data.guiSelection.hidden = data.item.gate.locked != data.item.locked; - } - - data.icon.sprite = (data.neededResources ? resourcesToAlphaMask(data.neededResources) + ":" : "") + "stretched:session/" + gateIcon; - - let index = data.i + getNumberOfRightPanelButtons(); - setPanelObjectPosition(data.button, index, data.rowLength); - return true; - } -}; - g_SelectionPanels.Pack = { "getMaxNumberOfItems": function() { @@ -1066,27 +1007,22 @@ } }; -g_SelectionPanels.Upgrade = { +g_SelectionPanels.Ability = { "getMaxNumberOfItems": function() { return 24 - getNumberOfRightPanelButtons(); }, "getItems": function(unitEntStates) { - // Interface becomes complicated with multiple different units and this is meant per-entity, so prevent it if the selection has multiple different units. + // Interface becomes complicated with multiple different units and this is meant per-entity, so prevent it if the selection has multiple different units for now. if (unitEntStates.some(state => state.template != unitEntStates[0].template)) return false; - return unitEntStates[0].upgrade && unitEntStates[0].upgrade.upgrades; + return unitEntStates[0].abilities && unitEntStates[0].abilities; }, "setupButton" : function(data) { - let template = GetTemplateData(data.item.entity); - if (!template) - return false; - let technologyEnabled = true; - if (data.item.requiredTechnology) technologyEnabled = Engine.GuiInterfaceCall("IsTechnologyResearched", { "tech": data.item.requiredTechnology, @@ -1099,59 +1035,59 @@ for (let cost in data.item.cost) if (cost != "time") data.item.cost[cost] *= data.unitEntStates.length; - neededResources = Engine.GuiInterfaceCall("GetNeededResources", { "cost": data.item.cost, "player": data.player }); } - let limits = getEntityLimitAndCount(data.playerState, data.item.entity); - let progress = data.unitEntStates[0].upgrade.progress || 0; - let isUpgrading = data.unitEntStates[0].upgrade.template == data.item.entity; + let progress = data.item.progress || 0; + let availability = data.item.availability; let tooltip; - if (!progress) - { - let tooltips = []; - if (data.item.tooltip) - tooltips.push(sprintf(translate("Upgrade into a %(name)s. %(tooltip)s"), { - "name": template.name.generic, - "tooltip": translate(data.item.tooltip) - })); - else - tooltips.push(sprintf(translate("Upgrade into a %(name)s."), { - "name": template.name.generic - })); + let tooltips = []; + tooltips.push(sprintf(translate("[font=\"sans-bold-16\"]%(name)s[/font]"), { + "name": data.item.readableName + })); + tooltips = tooltips.concat(data.item.tooltips || []); + if (availability == "unavailable" || availability == "available") + { tooltips.push( - getEntityCostTooltip(data.item), - formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers), getRequiredTechnologyTooltip(technologyEnabled, data.item.requiredTechnology, GetSimState().players[data.player].civ), getNeededResourcesTooltip(neededResources)); - tooltip = tooltips.filter(tip => tip).join("\n"); - - data.button.onPress = function() { upgradeEntity(data.item.entity); }; + data.button.onPress = function() { chargeAbility(data.item.ability); }; } - else if (isUpgrading) + else if (availability == "charging") { - tooltip = translate("Cancel Upgrading"); - data.button.onPress = function() { cancelUpgradeEntity(); }; + tooltips.push(translate("\nCancel Ability.")); + data.button.onPress = function() { cancelChargeAbility(data.item.ability); }; + } + else if (availability == "ready") + { + tooltips.push(translate("\nThis ability is charged and can now be activated.")); + data.button.onPress = function() {}; + } + else if (availability == "cooldown") + { + tooltips.push(translate("\nThis ability is cooling down and cannot be charged.")); + data.button.onPress = function() {}; } else { - tooltip = translate("Cannot upgrade when the entity is already upgrading."); + tooltips.push(translate("\nThis ability is active.")); data.button.onPress = function() {}; } + tooltip = tooltips.filter(tip => tip).join("\n"); + data.button.enabled = controlsPlayer(data.player); data.button.tooltip = tooltip; let modifier = ""; - if (!isUpgrading) + if (availability == "unavailable" || availability == "available") { - if (progress || !technologyEnabled || limits.canBeAddedCount == 0 && - !hasSameRestrictionCategory(data.item.entity, data.unitEntStates[0].template)) + if (availability == "unavailable" || !technologyEnabled) { data.button.enabled = false; modifier = "color:0 0 0 127:grayscale:"; @@ -1163,19 +1099,41 @@ } } - data.icon.sprite = modifier + "stretched:session/" + - (data.item.icon || "portraits/" + template.icon); + data.icon.sprite = modifier + "stretched:session/" + data.item.icon; + + let overlayIcon = Engine.GetGUIObjectByName("unitAbilityOverlayIcon[" + data.i + "]"); + if (data.item.overlayIcon && availability != "active") + { + overlayIcon.hidden = false; + overlayIcon.sprite = "stretched:session/" + data.item.overlayIcon; + } + else if (availability == "active") + { + overlayIcon.hidden = false; + overlayIcon.sprite = "stretched:session/icons/corners.png"; + } + else + overlayIcon.hidden = true; data.countDisplay.caption = data.unitEntStates.length > 1 ? data.unitEntStates.length : ""; - let progressOverlay = Engine.GetGUIObjectByName("unitUpgradeProgressSlider[" + data.i + "]"); - if (isUpgrading) + let progressOverlay = Engine.GetGUIObjectByName("unitAbilityProgressSlider[" + data.i + "]"); + if (availability == "charging") { let size = progressOverlay.size; size.top = size.left + Math.round(progress * (size.right - size.left)); progressOverlay.size = size; + progressOverlay.sprite = "queueProgressSlider"; + } + else if (availability == "cooldown") + { + + let size = progressOverlay.size; + size.top = size.left + Math.round(progress * (size.right - size.left)); + progressOverlay.size = size; + progressOverlay.sprite = "queueGrayProgressSlider"; } - progressOverlay.hidden = !isUpgrading; + progressOverlay.hidden = !(availability == "charging" || availability == "cooldown"); let index = data.i + getNumberOfRightPanelButtons(); setPanelObjectPosition(data.button, index, data.rowLength); @@ -1198,9 +1156,8 @@ "Stance", // Normal together with formation // RIGHT PANE - "Gate", // Must always be shown on gates "Pack", // Must always be shown on packable entities - "Upgrade", // Must always be shown on upgradable entities + "Ability", // Must always be shown on entities with abilities "Training", "Construction", "Research", // Normal together with training Index: binaries/data/mods/public/gui/session/selection_panels_helpers.js =================================================================== --- binaries/data/mods/public/gui/session/selection_panels_helpers.js +++ binaries/data/mods/public/gui/session/selection_panels_helpers.js @@ -1,7 +1,6 @@ -const GATE_ACTIONS = ["lock", "unlock"]; - -const UPGRADING_NOT_STARTED = -2; -const UPGRADING_CHOSEN_OTHER = -1; +const BARTER_RESOURCE_AMOUNT_TO_SELL = 100; +const BARTER_BUNCH_MULTIPLIER = 5; +const BARTER_ACTIONS = ["Sell", "Buy"]; function canMoveSelectionIntoFormation(formationTemplate) { Index: binaries/data/mods/public/gui/session/selection_panels_right/abilities_panel.xml =================================================================== --- binaries/data/mods/public/gui/session/selection_panels_right/abilities_panel.xml +++ binaries/data/mods/public/gui/session/selection_panels_right/abilities_panel.xml @@ -1,15 +1,15 @@ - -