1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-12 10:59:23 +00:00

Cycle backwards through building types

Use SHIFT+TAB to cycle backwards through the
building types in the toolbar
This commit is contained in:
Andifaind 2020-06-20 10:10:28 -03:00
parent 18388541d5
commit 2230602295
3 changed files with 13 additions and 2 deletions

View File

@ -331,8 +331,11 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
); );
// #51 Cycle backwards if SHIFT is pressed // #51 Cycle backwards if SHIFT is pressed
const cycleBackwards = this.root.keyMapper.getBinding(
KEYMAPPINGS.placement.cycleBuildingVariantsInverseModifier
).pressed;
let newIndex; let newIndex;
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.cycleBuildingsInverseModifier).pressed) { if (cycleBackwards) {
newIndex = (index - 1 + availableVariants.length) % availableVariants.length; newIndex = (index - 1 + availableVariants.length) % availableVariants.length;
} else { } else {
newIndex = (index + 1) % availableVariants.length; newIndex = (index + 1) % availableVariants.length;

View File

@ -109,8 +109,15 @@ export class HUDBuildingsToolbar extends BaseHUDPart {
} }
cycleBuildings() { cycleBuildings() {
const cycleBackwards = this.root.keyMapper.getBinding(
KEYMAPPINGS.placement.cycleBuildingsInverseModifier
).pressed;
let newIndex = this.lastSelectedIndex; let newIndex = this.lastSelectedIndex;
for (let i = 0; i < toolbarBuildings.length; ++i, ++newIndex) { for (
let i = 0;
i < toolbarBuildings.length;
++i, newIndex += toolbarBuildings.length + (cycleBackwards ? -1 : 1)
) {
newIndex %= toolbarBuildings.length; newIndex %= toolbarBuildings.length;
const metaBuilding = gMetaBuildingRegistry.findByClass(toolbarBuildings[newIndex]); const metaBuilding = gMetaBuildingRegistry.findByClass(toolbarBuildings[newIndex]);
const handle = this.buildingHandles[metaBuilding.id]; const handle = this.buildingHandles[metaBuilding.id];

View File

@ -60,6 +60,7 @@ export const KEYMAPPINGS = {
rotateWhilePlacing: { keyCode: key("R") }, rotateWhilePlacing: { keyCode: key("R") },
rotateInverseModifier: { keyCode: 16 }, // SHIFT rotateInverseModifier: { keyCode: 16 }, // SHIFT
cycleBuildingVariants: { keyCode: key("T") }, cycleBuildingVariants: { keyCode: key("T") },
cycleBuildingVariantsInverseModifier: { keyCode: 16 }, // SHIFT
cycleBuildings: { keyCode: 9 }, // TAB cycleBuildings: { keyCode: 9 }, // TAB
cycleBuildingsInverseModifier: { keyCode: 16 }, // SHIFT cycleBuildingsInverseModifier: { keyCode: 16 }, // SHIFT
switchDirectionLockSide: { keyCode: key("R") }, switchDirectionLockSide: { keyCode: key("R") },