-
Notifications
You must be signed in to change notification settings - Fork 18
/
e-shape-action-value-change-color-brightness.ts
74 lines (65 loc) · 3.05 KB
/
e-shape-action-value-change-color-brightness.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (C) 2019 Toshiba Corporation
* SPDX-License-Identifier: Apache-2.0
*/
import { EShapeResourceManagerDeserialization } from "../e-shape-resource-manager-deserialization";
import { EShapeResourceManagerSerialization } from "../e-shape-resource-manager-serialization";
import { EShapeActionRuntimeChangeColorBrightness } from "./e-shape-action-runtime-change-color-brightness";
import { EShapeActionValue } from "./e-shape-action-value";
import { EShapeActionValueChangeColorTarget } from "./e-shape-action-value-change-color-target";
import { EShapeActionValueChangeColorType } from "./e-shape-action-value-change-color-type";
import { EShapeActionValueChangeColorTypeLegacy } from "./e-shape-action-value-change-color-type-legacy";
import { EShapeActionValueChangeColorTypes } from "./e-shape-action-value-change-color-types";
import { EShapeActionValueSubtyped } from "./e-shape-action-value-subtyped";
import { EShapeActionValueType } from "./e-shape-action-value-type";
import { EShapeActionValues } from "./e-shape-action-values";
export type EShapeActionValueChangeColorBrightnessSerialized = [
typeof EShapeActionValueType.CHANGE_COLOR,
number,
EShapeActionValueChangeColorType,
typeof EShapeActionValueChangeColorTarget.BRIGHTNESS,
number
];
export type EShapeActionValueChangeColorBrightnessSerializedLegacy = [
typeof EShapeActionValueType.CHANGE_COLOR_LEGACY,
number,
EShapeActionValueChangeColorTypeLegacy,
typeof EShapeActionValueChangeColorTarget.BRIGHTNESS,
number
];
export class EShapeActionValueChangeColorBrightness extends EShapeActionValueSubtyped<EShapeActionValueChangeColorType> {
readonly brightness: string;
constructor(subtype: EShapeActionValueChangeColorType, condition: string, brightness: string) {
super(EShapeActionValueType.CHANGE_COLOR, condition, subtype);
this.brightness = brightness;
}
isEquals(value: EShapeActionValue): boolean {
return (
super.isEquals(value) &&
value instanceof EShapeActionValueChangeColorBrightness &&
this.brightness === value.brightness
);
}
toRuntime(): EShapeActionRuntimeChangeColorBrightness {
return new EShapeActionRuntimeChangeColorBrightness(this);
}
serialize(manager: EShapeResourceManagerSerialization): number {
const conditionId = manager.addResource(this.condition);
const target = EShapeActionValueChangeColorTarget.BRIGHTNESS;
const brightnessId = manager.addResource(this.brightness);
return manager.addResource(
`[${this.type},${conditionId},${this.subtype},${target},${brightnessId}]`
);
}
static deserialize(
serialized:
| EShapeActionValueChangeColorBrightnessSerialized
| EShapeActionValueChangeColorBrightnessSerializedLegacy,
manager: EShapeResourceManagerDeserialization
): EShapeActionValueChangeColorBrightness {
const subtype = EShapeActionValueChangeColorTypes.from(serialized);
const condition = EShapeActionValues.toResource(1, serialized, manager.resources);
const brightness = EShapeActionValues.toResource(4, serialized, manager.resources);
return new EShapeActionValueChangeColorBrightness(subtype, condition, brightness);
}
}