move bin<->bool conversion to UhkBuffer

This commit is contained in:
Sam Rang
2016-04-18 20:00:27 -05:00
parent 0c53b49c6a
commit 634aa6c532
5 changed files with 16 additions and 18 deletions

View File

@@ -22,7 +22,7 @@ class KeyMap extends Serializable<KeyMap> {
_fromBinary(buffer: UhkBuffer): KeyMap {
this.id = buffer.readUInt8();
this.isDefault = this.binToBool(buffer.readUInt8());
this.isDefault = buffer.readBoolean();
this.abbreviation = buffer.readString();
this.name = buffer.readString();
this.layers = new Layers().fromBinary(buffer);
@@ -41,7 +41,7 @@ class KeyMap extends Serializable<KeyMap> {
_toBinary(buffer: UhkBuffer): void {
buffer.writeUInt8(this.id);
buffer.writeUInt8(this.boolToBin(this.isDefault));
buffer.writeBoolean(this.isDefault);
buffer.writeString(this.abbreviation);
buffer.writeString(this.name);
this.layers.toBinary(buffer);

View File

@@ -22,8 +22,8 @@ class Macro extends Serializable<Macro> {
_fromBinary(buffer: UhkBuffer): Macro {
this.id = buffer.readUInt8();
this.isLooped = this.binToBool(buffer.readUInt8());
this.isPrivate = this.binToBool(buffer.readUInt8());
this.isLooped = buffer.readBoolean();
this.isPrivate = buffer.readBoolean();
this.name = buffer.readString();
this.macroActions = new MacroActions().fromBinary(buffer);
return this;
@@ -41,8 +41,8 @@ class Macro extends Serializable<Macro> {
_toBinary(buffer: UhkBuffer): void {
buffer.writeUInt8(this.id);
buffer.writeUInt8(this.boolToBin(this.isLooped));
buffer.writeUInt8(this.boolToBin(this.isPrivate));
buffer.writeBoolean(this.isLooped);
buffer.writeBoolean(this.isPrivate);
buffer.writeString(this.name);
this.macroActions.toBinary(buffer);
}

View File

@@ -21,7 +21,7 @@ class SwitchLayerAction extends KeyAction {
_fromBinary(buffer: UhkBuffer): SwitchLayerAction {
this.readAndAssertKeyActionId(buffer);
this.layer = buffer.readUInt8();
this.isLayerToggleable = this.binToBool(buffer.readUInt8());
this.isLayerToggleable = buffer.readBoolean();
return this;
}
@@ -36,7 +36,7 @@ class SwitchLayerAction extends KeyAction {
_toBinary(buffer: UhkBuffer) {
buffer.writeUInt8(KeyActionId.SwitchLayerAction);
buffer.writeUInt8(this.layer);
buffer.writeUInt8(this.boolToBin(this.isLayerToggleable));
buffer.writeBoolean(this.isLayerToggleable);
}
toString(): string {