Add keybinding hint for direction lock

This commit is contained in:
tobspr 2020-06-17 14:29:43 +02:00
parent 3ddc0de2c4
commit fc883f1e5e
5 changed files with 32 additions and 4 deletions

View File

@ -75,6 +75,14 @@
display: none;
}
&:not(.hasDirectionLock) .binding.directionLock {
display: none;
}
&.hasDirectionLock .noDirectionLock {
display: none;
}
.binding.placementOnly,
&:not(.placementActive) .binding.noPlacementOnly {
transform-origin: 0% 50%;

View File

@ -121,7 +121,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
return (
metaBuilding &&
metaBuilding.getHasDirectionLockAvailable() &&
this.root.keyMapper.getBinding(KEYMAPPINGS.placement.lockBeltDirection).pressed
this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.lockBeltDirection).pressed
);
}
@ -246,7 +246,10 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
* @param {any} args
*/
checkForDirectionLockSwitch({ keyCode }) {
if (keyCode === this.root.keyMapper.getBinding(KEYMAPPINGS.placement.lockBeltDirection).keyCode) {
if (
keyCode ===
this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.lockBeltDirection).keyCode
) {
this.abortDragging();
}
}

View File

@ -3,6 +3,7 @@ import { T } from "../../../translations";
import { getStringForKeyCode, KEYMAPPINGS } from "../../key_action_mapper";
import { BaseHUDPart } from "../base_hud_part";
import { TrackedState } from "../../../core/tracked_state";
import { MetaBuilding } from "../../meta_building";
export class HUDKeybindingOverlay extends BaseHUDPart {
initialize() {
@ -77,19 +78,34 @@ export class HUDKeybindingOverlay extends BaseHUDPart {
(this.root.app.settings.getAllSettings().alwaysMultiplace
? ""
: `
<div class="binding placementOnly">
<div class="binding placementOnly noDirectionLock">
<code class="keybinding builtinKey shift">${getKeycode(
KEYMAPPINGS.placementModifiers.placeMultiple
)}</code>
<label>${T.ingame.keybindingsOverlay.placeMultiple}</label>
</div>`) +
`
<div class="binding placementOnly directionLock">
<code class="keybinding builtinKey shift">${getKeycode(
KEYMAPPINGS.placementModifiers.lockBeltDirection
)}</code>
<label>${T.ingame.keybindingsOverlay.lockBeltDirection}</label>
</div>
`
);
}
/**
*
* @param {MetaBuilding} selectedMetaBuilding
*/
onSelectedBuildingForPlacementChanged(selectedMetaBuilding) {
this.element.classList.toggle("placementActive", !!selectedMetaBuilding);
this.element.classList.toggle(
"hasDirectionLock",
selectedMetaBuilding && selectedMetaBuilding.getHasDirectionLockAvailable()
);
}
applyCssClasses() {

View File

@ -61,7 +61,6 @@ export const KEYMAPPINGS = {
rotateInverseModifier: { keyCode: 16 }, // SHIFT
cycleBuildingVariants: { keyCode: key("T") },
cycleBuildings: { keyCode: 9 }, // TAB
lockBeltDirection: { keyCode: 16 }, // SHIFT
},
massSelect: {
@ -74,6 +73,7 @@ export const KEYMAPPINGS = {
},
placementModifiers: {
lockBeltDirection: { keyCode: 16 }, // SHIFT
placementDisableAutoOrientation: { keyCode: 17 }, // CTRL
placeMultiple: { keyCode: 16 }, // SHIFT
placeInverse: { keyCode: 18 }, // ALT

View File

@ -283,6 +283,7 @@ ingame:
createMarker: Create Marker
delete: Destroy
pasteLastBlueprint: Paste last blueprint
lockBeltDirection: Enable belt planner
# Everything related to placing buildings (I.e. as soon as you selected a building
# from the toolbar)