From a719f066180c3a9ec757816d6af4f3224f8dcf5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Farkas=20J=C3=B3zsef?= Date: Sun, 25 Sep 2016 14:14:02 +0200 Subject: [PATCH] refactor: Layer --- .../popover/tab/keymap/keymap-tab.component.html | 2 +- .../svg/wrap/svg-keyboard-wrap.component.html | 2 +- .../svg/wrap/svg-keyboard-wrap.component.ts | 4 ++-- src/config-serializer/config-items/Layer.ts | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/popover/tab/keymap/keymap-tab.component.html b/src/components/popover/tab/keymap/keymap-tab.component.html index a7bc1500..14df4822 100644 --- a/src/components/popover/tab/keymap/keymap-tab.component.html +++ b/src/components/popover/tab/keymap/keymap-tab.component.html @@ -12,6 +12,6 @@ + [moduleConfig]="selectedKeymap.layers[0].modules"> \ No newline at end of file diff --git a/src/components/svg/wrap/svg-keyboard-wrap.component.html b/src/components/svg/wrap/svg-keyboard-wrap.component.html index 8e526b63..e68c46bf 100644 --- a/src/components/svg/wrap/svg-keyboard-wrap.component.html +++ b/src/components/svg/wrap/svg-keyboard-wrap.component.html @@ -3,7 +3,7 @@
diff --git a/src/components/svg/wrap/svg-keyboard-wrap.component.ts b/src/components/svg/wrap/svg-keyboard-wrap.component.ts index 55bcd327..dd69cc26 100644 --- a/src/components/svg/wrap/svg-keyboard-wrap.component.ts +++ b/src/components/svg/wrap/svg-keyboard-wrap.component.ts @@ -130,7 +130,7 @@ export class SvgKeyboardWrapComponent implements OnChanges { onKeyClick(moduleId: number, keyId: number): void { if (!this.popoverShown && this.popoverEnabled) { this.keyEditConfig = { - keyActions: this.layers[this.currentLayer].modules.elements[moduleId].keyActions.elements, + keyActions: this.layers[this.currentLayer].modules[moduleId].keyActions.elements, keyId }; @@ -140,7 +140,7 @@ export class SvgKeyboardWrapComponent implements OnChanges { } onKeyHover(moduleId: number, event: MouseEvent, over: boolean, keyId: number): void { - let keyActionToEdit: KeyAction = this.layers[this.currentLayer].modules.elements[moduleId].keyActions.elements[keyId]; + let keyActionToEdit: KeyAction = this.layers[this.currentLayer].modules[moduleId].keyActions.elements[keyId]; if (this.tooltipEnabled) { if (over) { diff --git a/src/config-serializer/config-items/Layer.ts b/src/config-serializer/config-items/Layer.ts index e8d1f5c6..97e0ac9f 100644 --- a/src/config-serializer/config-items/Layer.ts +++ b/src/config-serializer/config-items/Layer.ts @@ -1,11 +1,11 @@ import { AnimationKeyboard } from '../../components/svg/wrap'; import { Serializable } from '../Serializable'; import { UhkBuffer } from '../UhkBuffer'; -import { Modules } from './Modules'; +import { Module } from './Module'; export class Layer extends Serializable { - modules: Modules; + modules: Module[]; animation: AnimationKeyboard; constructor(layers?: Layer) { @@ -14,28 +14,28 @@ export class Layer extends Serializable { this.animation = 'none'; return; } - this.modules = new Modules(layers.modules); + this.modules = layers.modules.map(module => new Module(module)); this.animation = layers.animation; } _fromJsObject(jsObject: any): Layer { - this.modules = new Modules().fromJsObject(jsObject.modules); + this.modules = jsObject.modules.map((module: any) => new Module().fromJsObject(module)); return this; } _fromBinary(buffer: UhkBuffer): Layer { - this.modules = new Modules().fromBinary(buffer); + this.modules = buffer.readArray(Module); return this; } _toJsObject(): any { return { - modules: this.modules.toJsObject() + modules: this.modules.map(module => module.toJsObject()) }; } _toBinary(buffer: UhkBuffer): void { - this.modules.toBinary(buffer); + buffer.writeArray(this.modules); } toString(): string {