-
Notifications
You must be signed in to change notification settings - Fork 18
/
d-text-piece.ts
70 lines (61 loc) · 2.36 KB
/
d-text-piece.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
import { utils } from "pixi.js";
import { DAlignHorizontal } from "./d-align-horizontal";
import { DAlignVertical } from "./d-align-vertical";
import { DBaseStateSet } from "./d-base-state-set";
import { DDynamicText } from "./d-dynamic-text";
import { DThemeFont } from "./d-font";
import { DStateAwareOrValueMightBe } from "./d-state-aware";
import { DTextPieceAlign } from "./d-text-piece-align";
import { DTextPieceStyle, DTextPieceStyleOptions } from "./d-text-piece-style";
import { DDynamicTextStyleWordWrap } from "./d-dynamic-text-style-word-wrap";
export interface DTextPieceTextAlignOptions {
vertical?: keyof typeof DAlignVertical | DAlignVertical;
horizontal?: keyof typeof DAlignHorizontal | DAlignHorizontal;
}
export type DTextPieceFormatter<VALUE> = (value: VALUE, caller: any) => string;
export interface DTextPieceOptions<VALUE> {
value?: DStateAwareOrValueMightBe<VALUE>;
color?: DStateAwareOrValueMightBe<number>;
alpha?: DStateAwareOrValueMightBe<number>;
style?: DTextPieceStyleOptions;
align?: DTextPieceTextAlignOptions;
formatter?: DTextPieceFormatter<VALUE>;
}
export interface DThemeTextPiece<VALUE> extends DThemeFont {
getTextFormatter(): DTextPieceFormatter<VALUE>;
/**
* Returns a new text value.
* Called to initialize a text value if a text value is not given.
*/
newTextValue(): DStateAwareOrValueMightBe<VALUE>;
/**
* Returns a text value.
* Called to get a text vale if there is no text value.
*
* @param state a state
*/
getTextValue(state: DBaseStateSet): VALUE | undefined;
getTextAlignVertical(): DAlignVertical;
getTextAlignHorizontal(): DAlignHorizontal;
getTextStyleClipping(): boolean;
getTextStyleFitting(): boolean;
getTextStyleWordWrap(): DDynamicTextStyleWordWrap;
isOverflowMaskEnabled(): boolean;
}
export interface DTextPiece<VALUE> extends utils.EventEmitter {
value: DStateAwareOrValueMightBe<VALUE>;
getValue(): DStateAwareOrValueMightBe<VALUE>;
setValue(value: DStateAwareOrValueMightBe<VALUE>, forcibly?: boolean): void;
compute(forcibly?: boolean): void;
formatter: DTextPieceFormatter<VALUE>;
readonly computed: VALUE | undefined;
color: DStateAwareOrValueMightBe<number>;
alpha: DStateAwareOrValueMightBe<number>;
readonly align: DTextPieceAlign;
readonly style: DTextPieceStyle;
readonly object: DDynamicText | null | undefined;
show(): this;
hide(): this;
isShown(): boolean;
destroy(): this;
}