Add KeyActionFactory. Add compact length related methods to UhkBuffer. Add KeyActions.
This commit is contained in:
34
config-serializer/config-items/KeyActions.ts
Normal file
34
config-serializer/config-items/KeyActions.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
class KeyActions implements Serializable<KeyActions> {
|
||||
|
||||
keyActions: Serializable<KeyAction>[];
|
||||
|
||||
fromJsObject(jsObjects: any): KeyActions {
|
||||
for (let jsObject of jsObjects) {
|
||||
this.keyActions.push(KeyActionFactory.fromJsObject(jsObject));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
fromBinary(buffer: UhkBuffer): KeyActions {
|
||||
let arrayLength = buffer.readCompactLength();
|
||||
for (let i = 0; i < arrayLength; i++) {
|
||||
this.keyActions.push(KeyActionFactory.fromBinary(buffer));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
toJsObject(): any {
|
||||
let array = [];
|
||||
for (let keyAction of this.keyActions) {
|
||||
keyAction.toJsObject();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeCompactLength(this.keyActions.length);
|
||||
for (let keyAction of this.keyActions) {
|
||||
keyAction.toBinary(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user