diff --git a/src/js/game/hud/parts/mass_selector.js b/src/js/game/hud/parts/mass_selector.js index fb55676e..dda09756 100644 --- a/src/js/game/hud/parts/mass_selector.js +++ b/src/js/game/hud/parts/mass_selector.js @@ -13,6 +13,7 @@ import { T } from "../../../translations"; import { KEYMAPPINGS } from "../../key_action_mapper"; import { THEME } from "../../theme"; import { enumHubGoalRewards } from "../../tutorial_goals"; +import { Blueprint } from "../../blueprint"; const logger = createLogger("hud/mass_selector"); @@ -145,16 +146,30 @@ export class HUDMassSelector extends BaseHUDPart { if (this.selectedUids.size > 0) { const entityUids = Array.from(this.selectedUids); - // copy code relies on entities still existing, so must copy before deleting. - this.root.hud.signals.buildingsSelectedForCopy.dispatch(entityUids); + const cutAction = () => { + // copy code relies on entities still existing, so must copy before deleting. + this.root.hud.signals.buildingsSelectedForCopy.dispatch(entityUids); - for (let i = 0; i < entityUids.length; ++i) { - const uid = entityUids[i]; - const entity = this.root.entityMgr.findByUid(uid); - if (!this.root.logic.tryDeleteBuilding(entity)) { - logger.error("Error in mass cut, could not remove building"); - this.selectedUids.delete(uid); + for (let i = 0; i < entityUids.length; ++i) { + const uid = entityUids[i]; + const entity = this.root.entityMgr.findByUid(uid); + if (!this.root.logic.tryDeleteBuilding(entity)) { + logger.error("Error in mass cut, could not remove building"); + this.selectedUids.delete(uid); + } } + }; + + const blueprint = Blueprint.fromUids(this.root, entityUids); + if (blueprint.canAfford(this.root)) { + cutAction(); + } else { + const { cancel, ok } = this.root.hud.parts.dialogs.showWarning( + T.dialogs.massCutInsufficientConfirm.title, + T.dialogs.massCutInsufficientConfirm.desc, + ["cancel:good:escape", "ok:bad:enter"] + ); + ok.add(cutAction); } this.root.soundProxy.playUiClick(); diff --git a/translations/base-en.yaml b/translations/base-en.yaml index ed1999b7..c6f03666 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -243,6 +243,11 @@ dialogs: desc: >- You are cutting a lot of buildings ( to be exact)! Are you sure you want to do this? + massCutInsufficientConfirm: + title: Confirm cut + desc: >- + The cost for pasting is insufficient! Are you sure you want to do this? + blueprintsNotUnlocked: title: Not unlocked yet desc: >- diff --git a/translations/base-ja.yaml b/translations/base-ja.yaml index d6d5139f..3e6ba511 100644 --- a/translations/base-ja.yaml +++ b/translations/base-ja.yaml @@ -263,6 +263,11 @@ dialogs: desc: >- 多数の建造物をカットしようとしています! ( 個の選択) 続行しますか? + massCutInsufficientConfirm: + title: カット確認 + desc: >- + 設置コストが不足しています! 続行しますか? + exportScreenshotWarning: title: スクリーンショット出力 desc: >-