Make SwitchLayerAction serialize the correct layer.
This commit is contained in:
@@ -30,23 +30,24 @@ class SwitchLayerAction extends KeyAction implements Serializable<SwitchLayerAct
|
|||||||
|
|
||||||
fromJsObject(jsObject: any): SwitchLayerAction {
|
fromJsObject(jsObject: any): SwitchLayerAction {
|
||||||
this.assertKeyActionType(jsObject, KeyActionType.SwitchLayerAction, 'SwitchLayerAction');
|
this.assertKeyActionType(jsObject, KeyActionType.SwitchLayerAction, 'SwitchLayerAction');
|
||||||
this.layer = jsObject.layer;
|
this.layer = Layer[<string>jsObject.layer];
|
||||||
this.isLayerToggleable = jsObject.toggle;
|
this.isLayerToggleable = jsObject.toggle;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromBinary(buffer: UhkBuffer): SwitchLayerAction {
|
fromBinary(buffer: UhkBuffer): SwitchLayerAction {
|
||||||
this.readAndAssertKeyActionId(buffer, KeyActionId.SwitchLayerAction, 'SwitchLayerAction');
|
this.readAndAssertKeyActionId(buffer, KeyActionId.SwitchLayerAction, 'SwitchLayerAction');
|
||||||
this.layer = buffer.readUInt8();
|
let layer = buffer.readUInt8();
|
||||||
this.isLayerToggleable = (this.layer & SwitchLayerAction.toggleFlag) !== 0;
|
this.isLayerToggleable = (layer & SwitchLayerAction.toggleFlag) !== 0;
|
||||||
this.layer &= ~SwitchLayerAction.toggleFlag; // Clear toggle bit.
|
layer &= ~SwitchLayerAction.toggleFlag; // Clear toggle bit.
|
||||||
|
this.layer = layer;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJsObject(): any {
|
toJsObject(): any {
|
||||||
return {
|
return {
|
||||||
keyActionType: KeyActionType.SwitchLayerAction,
|
keyActionType: KeyActionType.SwitchLayerAction,
|
||||||
layer: this.layer,
|
layer: Layer[this.layer],
|
||||||
toggle: this.isLayerToggleable
|
toggle: this.isLayerToggleable
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user