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