From bbd32276452a5b609b35ea5d9f8fd1bc3f0f8cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Wed, 30 Mar 2016 17:43:27 +0200 Subject: [PATCH] Add SwitchLayerAction. --- .../config-items/SwitchKeymapAction.ts | 36 ++++++++-------- .../config-items/SwitchLayerAction.ts | 41 +++++++++++++++++++ .../config-items/config-items.ts | 1 + 3 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 config-serializer/config-items/SwitchLayerAction.ts diff --git a/config-serializer/config-items/SwitchKeymapAction.ts b/config-serializer/config-items/SwitchKeymapAction.ts index 9749786f..353b87e8 100644 --- a/config-serializer/config-items/SwitchKeymapAction.ts +++ b/config-serializer/config-items/SwitchKeymapAction.ts @@ -1,41 +1,41 @@ -class SwitchKeymapAction extends KeyAction implements Serializable { +class SwitchLayerAction extends KeyAction implements Serializable { - static keyActionTypeString = 'switchKeymap'; + static keyActionTypeString = 'switchLayer'; - private _keymapId: number; + private _layer: number; - get keymapId(): number { - return this._keymapId; + get layer(): number { + return this._layer; } - set keymapId(value) { + set layer(value) { if (!TypeChecker.isUInt8Valid(value)) { - throw 'Invalid SwitchKeymapAction.keymapId: ${value}'; + throw 'Invalid SwitchLayerAction.layerId: ${value}'; } - this._keymapId = value; + this._layer = value; } - fromJsObject(jsObject: any): SwitchKeymapAction { - this.assertKeyActionType(jsObject, SwitchKeymapAction.keyActionTypeString, 'SwitchKeymapAction'); - this.keymapId = jsObject.keymapId; + fromJsObject(jsObject: any): SwitchLayerAction { + this.assertKeyActionType(jsObject, SwitchLayerAction.keyActionTypeString, 'SwitchLayerAction'); + this.layer = jsObject.keymapId; return this; } - fromBinary(buffer: UhkBuffer): SwitchKeymapAction { - this.readAndAssertKeyActionId(buffer, KeyActionId.SwitchKeymapAction, 'SwitchKeymapAction'); - this.keymapId = buffer.readUInt8(); + fromBinary(buffer: UhkBuffer): SwitchLayerAction { + this.readAndAssertKeyActionId(buffer, KeyActionId.SwitchLayerAction, 'SwitchLayerAction'); + this.layer = buffer.readUInt8(); return this; } toJsObject(): any { return { - keyActionType: SwitchKeymapAction.keyActionTypeString, - keymapId: this.keymapId + keyActionType: SwitchLayerAction.keyActionTypeString, + layer: this.layer }; } toBinary(buffer: UhkBuffer) { - buffer.writeUInt8(KeyActionId.SwitchKeymapAction); - buffer.writeUInt8(this.keymapId); + buffer.writeUInt8(KeyActionId.SwitchLayerAction); + buffer.writeUInt8(this.layer); } } diff --git a/config-serializer/config-items/SwitchLayerAction.ts b/config-serializer/config-items/SwitchLayerAction.ts new file mode 100644 index 00000000..9749786f --- /dev/null +++ b/config-serializer/config-items/SwitchLayerAction.ts @@ -0,0 +1,41 @@ +class SwitchKeymapAction extends KeyAction implements Serializable { + + static keyActionTypeString = 'switchKeymap'; + + private _keymapId: number; + + get keymapId(): number { + return this._keymapId; + } + + set keymapId(value) { + if (!TypeChecker.isUInt8Valid(value)) { + throw 'Invalid SwitchKeymapAction.keymapId: ${value}'; + } + this._keymapId = value; + } + + fromJsObject(jsObject: any): SwitchKeymapAction { + this.assertKeyActionType(jsObject, SwitchKeymapAction.keyActionTypeString, 'SwitchKeymapAction'); + this.keymapId = jsObject.keymapId; + return this; + } + + fromBinary(buffer: UhkBuffer): SwitchKeymapAction { + this.readAndAssertKeyActionId(buffer, KeyActionId.SwitchKeymapAction, 'SwitchKeymapAction'); + this.keymapId = buffer.readUInt8(); + return this; + } + + toJsObject(): any { + return { + keyActionType: SwitchKeymapAction.keyActionTypeString, + keymapId: this.keymapId + }; + } + + toBinary(buffer: UhkBuffer) { + buffer.writeUInt8(KeyActionId.SwitchKeymapAction); + buffer.writeUInt8(this.keymapId); + } +} diff --git a/config-serializer/config-items/config-items.ts b/config-serializer/config-items/config-items.ts index 777b4903..e8091af6 100644 --- a/config-serializer/config-items/config-items.ts +++ b/config-serializer/config-items/config-items.ts @@ -4,5 +4,6 @@ /// /// /// +/// /// ///