module configurations

This commit is contained in:
Sam Rang
2016-04-18 21:40:30 -05:00
parent 324103e5b6
commit 41f2e31ea2
5 changed files with 125 additions and 3 deletions

View File

@@ -0,0 +1,55 @@
class ModuleConfiguration extends Serializable<ModuleConfiguration> {
/*
* module id enumeration is a separate story
*/
// @assertUInt8
id: number;
// @assertUInt8
initialPointerSpeed: number;
// @assertUInt8
pointerAcceleration: number;
// @assertUInt8
maxPointerSpeed: number;
_fromJsObject(jsObject: any): ModuleConfiguration {
this.id = jsObject.id;
this.initialPointerSpeed = jsObject.initialPointerSpeed;
this.pointerAcceleration = jsObject.pointerAcceleration;
this.maxPointerSpeed = jsObject.maxPointerSpeed;
return this;
}
_fromBinary(buffer: UhkBuffer): ModuleConfiguration {
this.id = buffer.readUInt8();
this.initialPointerSpeed = buffer.readUInt8();
this.pointerAcceleration = buffer.readUInt8();
this.maxPointerSpeed = buffer.readUInt8();
return this;
}
_toJsObject(): any {
return {
id: this.id,
initialPointerSpeed: this.initialPointerSpeed,
pointerAcceleration: this.pointerAcceleration,
maxPointerSpeed: this.maxPointerSpeed
};
}
_toBinary(buffer: UhkBuffer): void {
buffer.writeUInt8(this.id);
buffer.writeUInt8(this.initialPointerSpeed);
buffer.writeUInt8(this.pointerAcceleration);
buffer.writeUInt8(this.maxPointerSpeed);
}
toString(): string {
return `<ModuleConfiguration id="${this.id}" >`;
}
}

View File

@@ -0,0 +1,11 @@
class ModuleConfigurations extends ClassArray<ModuleConfiguration> {
jsObjectToClass(jsObject: any): Serializable<ModuleConfiguration> {
return new ModuleConfiguration().fromJsObject(jsObject);
}
binaryToClass(buffer: UhkBuffer): Serializable<ModuleConfiguration> {
return new ModuleConfiguration().fromBinary(buffer);
}
}

View File

@@ -0,0 +1,53 @@
class UhkConfiguration extends Serializable<UhkConfiguration> {
// @assertUInt8
id: number;
name: string;
abbreviation: string;
isDefault: boolean;
layers: Serializable<Layers>;
_fromJsObject(jsObject: any): UhkConfiguration {
this.id = jsObject.id;
this.isDefault = jsObject.isDefault;
this.abbreviation = jsObject.abbreviation;
this.name = jsObject.name;
this.layers = new Layers().fromJsObject(jsObject.layers);
return this;
}
_fromBinary(buffer: UhkBuffer): UhkConfiguration {
this.id = buffer.readUInt8();
this.isDefault = buffer.readBoolean();
this.abbreviation = buffer.readString();
this.name = buffer.readString();
this.layers = new Layers().fromBinary(buffer);
return this;
}
_toJsObject(): any {
return {
id: this.id,
isDefault: this.isDefault,
abbreviation: this.abbreviation,
name: this.name,
layers: this.layers.toJsObject()
};
}
_toBinary(buffer: UhkBuffer): void {
buffer.writeUInt8(this.id);
buffer.writeBoolean(this.isDefault);
buffer.writeString(this.abbreviation);
buffer.writeString(this.name);
this.layers.toBinary(buffer);
}
toString(): string {
return `<UhkConfiguration id="${this.id}" name="${this.name}">`;
}
}

View File

@@ -32,3 +32,6 @@
/// <reference path="ScrollMouseMacroAction.ts" />
/// <reference path="DelayMacroAction.ts" />
/// <reference path="TextMacroAction.ts" />
/// <reference path="ModuleConfiguration.ts" />
/// <reference path="ModuleConfigurations.ts" />
/// <reference path="UhkConfiguration.ts" />