1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Add "Paste last blueprint" keybind. Last blueprint is not preserved on save/exit.

This commit is contained in:
hexagonhexagon 2020-06-11 17:56:13 -04:00
parent f34813392f
commit e39a868998
6 changed files with 30 additions and 10 deletions

View File

@ -74,6 +74,7 @@ export class GameHUD {
shapeUnpinRequested: /** @type {TypedSignal<[string]>} */ (new Signal()), shapeUnpinRequested: /** @type {TypedSignal<[string]>} */ (new Signal()),
notification: /** @type {TypedSignal<[string, enumNotificationType]>} */ (new Signal()), notification: /** @type {TypedSignal<[string, enumNotificationType]>} */ (new Signal()),
buildingsSelectedForCopy: /** @type {TypedSignal<[Array<number>]>} */ (new Signal()), buildingsSelectedForCopy: /** @type {TypedSignal<[Array<number>]>} */ (new Signal()),
pasteBlueprintRequested: new Signal(),
}; };
if (!IS_MOBILE) { if (!IS_MOBILE) {

View File

@ -29,6 +29,8 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
/** @type {TypedTrackedState<Blueprint?>} */ /** @type {TypedTrackedState<Blueprint?>} */
this.currentBlueprint = new TrackedState(this.onBlueprintChanged, this); this.currentBlueprint = new TrackedState(this.onBlueprintChanged, this);
/** @type {Blueprint?} */
this.lastBlueprintUsed = null;
const keyActionMapper = this.root.keyMapper; const keyActionMapper = this.root.keyMapper;
keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.abortPlacement, this); keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.abortPlacement, this);
@ -36,9 +38,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
.getBinding(KEYMAPPINGS.placement.abortBuildingPlacement) .getBinding(KEYMAPPINGS.placement.abortBuildingPlacement)
.add(this.abortPlacement, this); .add(this.abortPlacement, this);
keyActionMapper.getBinding(KEYMAPPINGS.placement.rotateWhilePlacing).add(this.rotateBlueprint, this); keyActionMapper.getBinding(KEYMAPPINGS.placement.rotateWhilePlacing).add(this.rotateBlueprint, this);
keyActionMapper keyActionMapper.getBinding(KEYMAPPINGS.massSelect.pasteLastBlueprint).add(this.pasteBlueprint, this);
.getBinding(KEYMAPPINGS.placement.abortBuildingPlacement)
.add(this.abortPlacement, this);
this.root.camera.downPreHandler.add(this.onMouseDown, this); this.root.camera.downPreHandler.add(this.onMouseDown, this);
this.root.camera.movePreHandler.add(this.onMouseMove, this); this.root.camera.movePreHandler.add(this.onMouseMove, this);
@ -73,6 +73,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
*/ */
onBlueprintChanged(blueprint) { onBlueprintChanged(blueprint) {
if (blueprint) { if (blueprint) {
this.lastBlueprintUsed = blueprint;
this.costDisplayText.innerText = "" + blueprint.getCost(); this.costDisplayText.innerText = "" + blueprint.getCost();
} }
} }
@ -144,6 +145,15 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
} }
} }
pasteBlueprint() {
if (this.lastBlueprintUsed !== null) {
this.root.hud.signals.pasteBlueprintRequested.dispatch();
this.currentBlueprint.set(this.lastBlueprintUsed);
} else {
this.root.soundProxy.playUiError();
}
}
/** /**
* *
* @param {DrawParameters} parameters * @param {DrawParameters} parameters

View File

@ -40,6 +40,7 @@ export class HUDBuildingPlacer extends BaseHUDPart {
keyActionMapper.getBinding(KEYMAPPINGS.placement.cycleBuildingVariants).add(this.cycleVariants, this); keyActionMapper.getBinding(KEYMAPPINGS.placement.cycleBuildingVariants).add(this.cycleVariants, this);
this.root.hud.signals.buildingsSelectedForCopy.add(this.abortPlacement, this); this.root.hud.signals.buildingsSelectedForCopy.add(this.abortPlacement, this);
this.root.hud.signals.pasteBlueprintRequested.add(this.abortPlacement, this);
this.domAttach = new DynamicDomAttach(this.root, this.element, {}); this.domAttach = new DynamicDomAttach(this.root, this.element, {});

View File

@ -48,6 +48,11 @@ export class HUDKeybindingOverlay extends BaseHUDPart {
<label>${T.ingame.keybindingsOverlay.selectBuildings}</label> <label>${T.ingame.keybindingsOverlay.selectBuildings}</label>
</div> </div>
<div class="binding noPlacementOnly">
<code class="keybinding">${getKeycode(KEYMAPPINGS.massSelect.pasteLastBlueprint)}</code>
<label>${T.ingame.keybindingsOverlay.pasteLastBlueprint}</label>
</div>
<div class="binding placementOnly"> <div class="binding placementOnly">
<code class="keybinding leftMouse"></code> <code class="keybinding leftMouse"></code>

View File

@ -67,6 +67,7 @@ export const KEYMAPPINGS = {
massSelectCopy: { keyCode: key("C") }, massSelectCopy: { keyCode: key("C") },
massSelectCut: { keyCode: key("X") }, massSelectCut: { keyCode: key("X") },
confirmMassDelete: { keyCode: 46 }, // DEL confirmMassDelete: { keyCode: 46 }, // DEL
pasteLastBlueprint: { keyCode: key("V") },
}, },
placementModifiers: { placementModifiers: {

View File

@ -291,6 +291,7 @@ ingame:
placeBuilding: Place building placeBuilding: Place building
createMarker: Create Marker createMarker: Create Marker
delete: Destroy delete: Destroy
pasteLastBlueprint: Paste last blueprint
# Everything related to placing buildings (I.e. as soon as you selected a building # Everything related to placing buildings (I.e. as soon as you selected a building
# from the toolbar) # from the toolbar)
@ -710,6 +711,7 @@ keybindings:
Modifier: Rotate CCW instead Modifier: Rotate CCW instead
cycleBuildingVariants: Cycle Variants cycleBuildingVariants: Cycle Variants
confirmMassDelete: Confirm Mass Delete confirmMassDelete: Confirm Mass Delete
pasteLastBlueprint: Paste last blueprint
cycleBuildings: Cycle Buildings cycleBuildings: Cycle Buildings
massSelectStart: Hold and drag to start massSelectStart: Hold and drag to start