layer and layers
This commit is contained in:
25
config-serializer/config-items/Layer.ts
Normal file
25
config-serializer/config-items/Layer.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
class Layer extends Serializable<Layer> {
|
||||
|
||||
modules: Serializable<Modules>;
|
||||
|
||||
_fromJsObject(jsObject: any): Layer {
|
||||
this.modules = new Modules().fromJsObject(jsObject.modules);
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): Layer {
|
||||
this.modules = new Modules().fromBinary(buffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
modules: this.modules.toJsObject()
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer): void {
|
||||
this.modules.toBinary(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
11
config-serializer/config-items/Layers.ts
Normal file
11
config-serializer/config-items/Layers.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
class Layers extends ClassArray<Layer> {
|
||||
|
||||
jsObjectToClass(jsObject: any): Serializable<Layer> {
|
||||
return new Layer().fromJsObject(jsObject);
|
||||
}
|
||||
|
||||
binaryToClass(buffer: UhkBuffer): Serializable<Layer> {
|
||||
return new Layer().fromBinary(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
enum Layer {
|
||||
enum KeyLayer {
|
||||
mod,
|
||||
fn,
|
||||
mouse
|
||||
@@ -10,12 +10,12 @@ class SwitchLayerAction extends KeyAction {
|
||||
|
||||
isLayerToggleable: boolean;
|
||||
|
||||
// @assertEnum(Layer)
|
||||
private layer: Layer;
|
||||
// @assertEnum(KeyLayer)
|
||||
private layer: KeyLayer;
|
||||
|
||||
_fromJsObject(jsObject: any): SwitchLayerAction {
|
||||
this.assertKeyActionType(jsObject);
|
||||
this.layer = Layer[<string> jsObject.layer];
|
||||
this.layer = KeyLayer[<string> jsObject.layer];
|
||||
this.isLayerToggleable = jsObject.toggle;
|
||||
return this;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class SwitchLayerAction extends KeyAction {
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
keyActionType: keyActionType.SwitchLayerAction,
|
||||
layer: Layer[this.layer],
|
||||
layer: KeyLayer[this.layer],
|
||||
toggle: this.isLayerToggleable
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,3 +11,5 @@
|
||||
/// <reference path="NoneAction.ts" />
|
||||
/// <reference path="Module.ts" />
|
||||
/// <reference path="Modules.ts" />
|
||||
/// <reference path="Layer.ts" />
|
||||
/// <reference path="Layers.ts" />
|
||||
|
||||
Reference in New Issue
Block a user