refactor: Keymap
This commit is contained in:
@@ -12,6 +12,6 @@
|
||||
<img src="./images/base-layer--blank.svg">
|
||||
</div>
|
||||
<svg-keyboard *ngIf="selectedKeymap?.abbreviation"
|
||||
[moduleConfig]="selectedKeymap.layers.elements[0].modules.elements">
|
||||
[moduleConfig]="selectedKeymap.layers[0].modules.elements">
|
||||
</svg-keyboard>
|
||||
</div>
|
||||
@@ -117,7 +117,7 @@ export class SvgKeyboardWrapComponent implements OnChanges {
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['keymap'].previousValue.abbreviation !== changes['keymap'].currentValue.abbreviation) {
|
||||
this.layers = this.keymap.layers.elements;
|
||||
this.layers = this.keymap.layers;
|
||||
this.currentLayer = 0;
|
||||
|
||||
if (this.layers.length > 0) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Serializable } from '../Serializable';
|
||||
import { UhkBuffer } from '../UhkBuffer';
|
||||
import { Layers } from './Layers';
|
||||
import { Layer } from './Layer';
|
||||
|
||||
export class Keymap extends Serializable<Keymap> {
|
||||
|
||||
@@ -12,7 +12,7 @@ export class Keymap extends Serializable<Keymap> {
|
||||
|
||||
isDefault: boolean;
|
||||
|
||||
layers: Layers;
|
||||
layers: Layer[];
|
||||
|
||||
constructor(keymap?: Keymap) {
|
||||
super();
|
||||
@@ -24,7 +24,7 @@ export class Keymap extends Serializable<Keymap> {
|
||||
this.description = keymap.description;
|
||||
this.abbreviation = keymap.abbreviation;
|
||||
this.isDefault = keymap.isDefault;
|
||||
this.layers = new Layers(keymap.layers);
|
||||
this.layers = keymap.layers.map(layer => new Layer(layer));
|
||||
}
|
||||
|
||||
_fromJsObject(jsObject: any): Keymap {
|
||||
@@ -32,7 +32,7 @@ export class Keymap extends Serializable<Keymap> {
|
||||
this.abbreviation = jsObject.abbreviation;
|
||||
this.name = jsObject.name;
|
||||
this.description = jsObject.description;
|
||||
this.layers = new Layers().fromJsObject(jsObject.layers);
|
||||
this.layers = jsObject.layers.map((layer: any) => new Layer().fromJsObject(layer));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class Keymap extends Serializable<Keymap> {
|
||||
this.abbreviation = buffer.readString();
|
||||
this.name = buffer.readString();
|
||||
this.description = buffer.readString();
|
||||
this.layers = new Layers().fromBinary(buffer);
|
||||
this.layers = buffer.readArray<Layer>(Layer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export class Keymap extends Serializable<Keymap> {
|
||||
abbreviation: this.abbreviation,
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
layers: this.layers.toJsObject()
|
||||
layers: this.layers.map(layer => layer.toJsObject())
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class Keymap extends Serializable<Keymap> {
|
||||
buffer.writeString(this.abbreviation);
|
||||
buffer.writeString(this.name);
|
||||
buffer.writeString(this.description);
|
||||
this.layers.toBinary(buffer);
|
||||
buffer.writeArray(this.layers);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
|
||||
Reference in New Issue
Block a user