From 068e2877696031803e327c958ec2206b85271dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Farkas?= Date: Sun, 9 Apr 2017 13:38:22 +0200 Subject: [PATCH] Copy SwitchLayer actions from base layer to every none base layer --- .../src/config-serializer/config-items/Keymap.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/shared/src/config-serializer/config-items/Keymap.ts b/shared/src/config-serializer/config-items/Keymap.ts index ed4ccb51..be7dc599 100644 --- a/shared/src/config-serializer/config-items/Keymap.ts +++ b/shared/src/config-serializer/config-items/Keymap.ts @@ -1,7 +1,7 @@ import { UhkBuffer } from '../UhkBuffer'; import { Layer } from './Layer'; import { Macro } from './Macro'; -import { SwitchLayerAction } from './key-action'; +import { SwitchLayerAction, KeyAction } from './key-action'; export class Keymap { @@ -106,6 +106,19 @@ export class Keymap { }); } } + + // Adds the SwitchLayerActions from the base layer to any none base layer + const baseLayerModules = this.layers[0].modules; + for (let i = 0; i < baseLayerModules.length; ++i) { + baseLayerModules[i].keyActions.forEach((keyAction: KeyAction, keyActionIndex: number) => { + if (keyAction instanceof SwitchLayerAction) { + for (let j = 1; j < this.layers.length; ++j) { + this.layers[j].modules[i].keyActions[keyActionIndex] = new SwitchLayerAction(keyAction); + } + } + }); + + } } }