|
|
|
@ -22,6 +22,9 @@ export class HUDMassSelector extends BaseHUDPart {
|
|
|
|
|
.getBinding(KEYMAPPINGS.massSelect.confirmMassDelete)
|
|
|
|
|
.getKeyCodeString();
|
|
|
|
|
const abortKeybinding = this.root.keyMapper.getBinding(KEYMAPPINGS.general.back).getKeyCodeString();
|
|
|
|
|
const cutKeybinding = this.root.keyMapper
|
|
|
|
|
.getBinding(KEYMAPPINGS.massSelect.massSelectCut)
|
|
|
|
|
.getKeyCodeString();
|
|
|
|
|
const copyKeybinding = this.root.keyMapper
|
|
|
|
|
.getBinding(KEYMAPPINGS.massSelect.massSelectCopy)
|
|
|
|
|
.getKeyCodeString();
|
|
|
|
@ -32,6 +35,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|
|
|
|
[],
|
|
|
|
|
T.ingame.massSelect.infoText
|
|
|
|
|
.replace("<keyDelete>", `<code class='keybinding'>${removalKeybinding}</code>`)
|
|
|
|
|
.replace("<keyCut>", `<code class='keybinding'>${cutKeybinding}</code>`)
|
|
|
|
|
.replace("<keyCopy>", `<code class='keybinding'>${copyKeybinding}</code>`)
|
|
|
|
|
.replace("<keyCancel>", `<code class='keybinding'>${abortKeybinding}</code>`)
|
|
|
|
|
);
|
|
|
|
@ -54,6 +58,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|
|
|
|
this.root.keyMapper
|
|
|
|
|
.getBinding(KEYMAPPINGS.massSelect.confirmMassDelete)
|
|
|
|
|
.add(this.confirmDelete, this);
|
|
|
|
|
this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectCut).add(this.confirmCut, this);
|
|
|
|
|
this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectCopy).add(this.startCopy, this);
|
|
|
|
|
|
|
|
|
|
this.domAttach = new DynamicDomAttach(this.root, this.element);
|
|
|
|
@ -123,6 +128,49 @@ export class HUDMassSelector extends BaseHUDPart {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
confirmCut() {
|
|
|
|
|
if (!this.root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_blueprints)) {
|
|
|
|
|
this.root.hud.parts.dialogs.showInfo(
|
|
|
|
|
T.dialogs.blueprintsNotUnlocked.title,
|
|
|
|
|
T.dialogs.blueprintsNotUnlocked.desc
|
|
|
|
|
);
|
|
|
|
|
} else if (this.selectedUids.size > 100) {
|
|
|
|
|
const { ok } = this.root.hud.parts.dialogs.showWarning(
|
|
|
|
|
T.dialogs.massCutConfirm.title,
|
|
|
|
|
T.dialogs.massCutConfirm.desc.replace(
|
|
|
|
|
"<count>",
|
|
|
|
|
"" + formatBigNumberFull(this.selectedUids.size)
|
|
|
|
|
),
|
|
|
|
|
["cancel:good", "ok:bad"]
|
|
|
|
|
);
|
|
|
|
|
ok.add(() => this.doCut());
|
|
|
|
|
} else {
|
|
|
|
|
this.doCut();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doCut() {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.root.soundProxy.playUiClick();
|
|
|
|
|
} else {
|
|
|
|
|
this.root.soundProxy.playUiError();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* mouse down pre handler
|
|
|
|
|
* @param {Vector} pos
|
|
|
|
|