@m2c2kit/addons 0.3.14 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import * as _m2c2kit_core from '@m2c2kit/core';
2
+ import { CompositeOptions, Size, RgbaColor, M2Node, Composite, TextOptions, IText, StringInterpolationMap, M2NodeEvent, CallbackOptions, Point, ShapeOptions, CompositeEvent, LabelHorizontalAlignmentMode, Transition, StoryOptions, Story, Scene, SceneOptions } from '@m2c2kit/core';
1
3
  import { Canvas } from 'canvaskit-wasm';
2
- import { CompositeOptions, Size, RgbaColor, Composite, M2Node, GlobalVariables, TextOptions, IText, M2NodeEvent, CallbackOptions, Point, ShapeOptions, LabelHorizontalAlignmentMode, Transition, StoryOptions, Story, Scene, SceneOptions } from '@m2c2kit/core';
3
4
 
4
5
  interface GridOptions extends CompositeOptions {
5
6
  /** Number of rows in the grid. Must be 1 or greater */
@@ -8,7 +9,7 @@ interface GridOptions extends CompositeOptions {
8
9
  columns: number;
9
10
  /** Size of the grid in pixels */
10
11
  size: Size;
11
- /** Background color of the grid. Default is a transparent gray */
12
+ /** Background color of the grid. Default is a transparent blue */
12
13
  backgroundColor?: RgbaColor;
13
14
  /** Width of the grid lines. Default is 1 */
14
15
  gridLineWidth?: number;
@@ -20,16 +21,17 @@ interface GridChild {
20
21
  row: number;
21
22
  column: number;
22
23
  }
23
- declare class Grid extends Composite {
24
+ declare class Grid extends Composite implements GridOptions {
24
25
  compositeType: string;
25
- rows: number;
26
- columns: number;
27
- gridBackgroundColor: RgbaColor;
28
- gridLineColor: RgbaColor;
29
- gridLineWidth: number;
26
+ private _rows;
27
+ private _columns;
28
+ private _gridBackgroundColor;
29
+ private _gridLineColor;
30
+ private _gridLineWidth;
30
31
  cellWidth: number;
31
32
  cellHeight: number;
32
- gridChildren: GridChild[];
33
+ private _gridChildren;
34
+ private cellContainers;
33
35
  private _gridBackground?;
34
36
  /**
35
37
  * A rectangular grid that supports placement of nodes within the grid's
@@ -42,9 +44,44 @@ declare class Grid extends Composite {
42
44
  * @param options - {@link GridOptions}
43
45
  */
44
46
  constructor(options: GridOptions);
47
+ get completeNodeOptions(): {
48
+ rows: number;
49
+ columns: number;
50
+ size: Size;
51
+ backgroundColor: RgbaColor;
52
+ gridLineWidth: number;
53
+ gridLineColor: RgbaColor;
54
+ anchorPoint?: _m2c2kit_core.Point;
55
+ zPosition?: number;
56
+ name?: string;
57
+ position?: _m2c2kit_core.Point;
58
+ scale?: number;
59
+ alpha?: number;
60
+ zRotation?: number;
61
+ isUserInteractionEnabled?: boolean;
62
+ draggable?: boolean;
63
+ hidden?: boolean;
64
+ layout?: _m2c2kit_core.Layout;
65
+ uuid?: string;
66
+ suppressEvents?: boolean;
67
+ };
45
68
  initialize(): void;
46
69
  private get gridBackground();
47
70
  private set gridBackground(value);
71
+ /**
72
+ * note: below we do not have getter and setter for size because the getter
73
+ * and setter in M2Node will handle it.
74
+ */
75
+ get rows(): number;
76
+ set rows(rows: number);
77
+ get columns(): number;
78
+ set columns(columns: number);
79
+ get gridBackgroundColor(): RgbaColor;
80
+ set gridBackgroundColor(backgroundColor: RgbaColor);
81
+ get gridLineWidth(): number;
82
+ set gridLineWidth(gridLineWidth: number);
83
+ get gridLineColor(): RgbaColor;
84
+ set gridLineColor(gridLineColor: RgbaColor);
48
85
  dispose(): void;
49
86
  /**
50
87
  * Duplicates a node using deep copy.
@@ -61,11 +98,23 @@ declare class Grid extends Composite {
61
98
  draw(canvas: Canvas): void;
62
99
  warmup(canvas: Canvas): void;
63
100
  /**
64
- * Removes all children from the grid, but retains grid lines.
101
+ * The child nodes that have been added to the grid.
102
+ *
103
+ * @remarks Do not set this property directly. Use the methods for adding
104
+ * and removing grid children, such as `addAtCell()`, `removeAllAtCell()`,
105
+ * `removeGridChild()`, and `removeAllGridChildren()`.
65
106
  */
66
- removeAllChildren(): void;
107
+ get gridChildren(): Array<GridChild>;
108
+ set gridChildren(gridChildren: Array<GridChild>);
67
109
  /**
68
- * Adds a node to the grid at the specified row and column position.
110
+ * Removes all grid children from the grid.
111
+ *
112
+ * @remarks This retains grid lines and grid appearance.
113
+ */
114
+ removeAllGridChildren(): void;
115
+ /**
116
+ * Adds a node as a grid child to the grid at the specified row and column
117
+ * position.
69
118
  *
70
119
  * @param node - node to add to the grid
71
120
  * @param row - row position within grid to add node; zero-based indexing
@@ -73,46 +122,50 @@ declare class Grid extends Composite {
73
122
  */
74
123
  addAtCell(node: M2Node, row: number, column: number): void;
75
124
  /**
76
- * Removes all child nodes at the specified row and column position.
125
+ * Removes all grid child nodes at the specified row and column position.
77
126
  *
78
- * @param row - row position within grid at which to remove children; zero-based indexing
79
- * @param column - column position within grid at which to remove children; zero-based indexing
127
+ * @param row - row position within grid at which to remove grid children; zero-based indexing
128
+ * @param column - column position within grid at which to remove grid children; zero-based indexing
80
129
  */
81
130
  removeAllAtCell(row: number, column: number): void;
82
131
  /**
83
- * Removes the child node from the grid.
132
+ * Removes the grid child node from the grid.
84
133
  *
85
134
  * @param node - node to remove
86
135
  */
87
- removeChild(node: M2Node): void;
88
- }
89
-
90
- declare global {
91
- var Globals: GlobalVariables;
136
+ removeGridChild(node: M2Node): void;
137
+ addChild(child: M2Node): void;
138
+ removeAllChildren(): void;
139
+ removeChild(child: M2Node): void;
140
+ removeChildren(children: M2Node[]): void;
92
141
  }
93
- //# sourceMappingURL=Globals.d.ts.map
94
142
 
95
143
  interface ButtonOptions extends CompositeOptions, TextOptions {
96
- /** Size of button */
144
+ /** Size of button. Default is 200 wide by 50 high. */
97
145
  size?: Size;
98
- /** Corner radius of button; can be used to make rounded corners */
146
+ /** Corner radius of button; can be used to make rounded corners. Default is 9 */
99
147
  cornerRadius?: number;
100
- /** Background color of button. Default is WebColors.RoyalBlue */
148
+ /** Background color of button. Default is WebColors.Black */
101
149
  backgroundColor?: RgbaColor;
102
150
  /** Color of button text. Default is WebColors.White */
103
151
  fontColor?: RgbaColor;
152
+ /** Names of multiple fonts to use for text. For example, if a text font and an emoji font are to be used together. Must have been previously loaded */
153
+ fontNames?: Array<string>;
154
+ /** Size of button text. Default is 20. */
155
+ fontSize?: number;
104
156
  }
105
- declare class Button extends Composite implements IText {
157
+ declare class Button extends Composite implements IText, ButtonOptions {
106
158
  compositeType: string;
159
+ isText: boolean;
107
160
  private _backgroundColor;
108
- size: {
109
- width: number;
110
- height: number;
111
- };
112
- cornerRadius: number;
113
- fontSize: number;
161
+ private _cornerRadius;
162
+ private _fontSize;
114
163
  private _text;
115
164
  private _fontColor;
165
+ private _fontName;
166
+ private _fontNames;
167
+ private _interpolation;
168
+ private _localize;
116
169
  private backgroundPaint?;
117
170
  /**
118
171
  * A simple button of rectangle with text centered inside.
@@ -124,6 +177,31 @@ declare class Button extends Composite implements IText {
124
177
  * @param options - {@link ButtonOptions}
125
178
  */
126
179
  constructor(options: ButtonOptions);
180
+ get completeNodeOptions(): {
181
+ size: Size;
182
+ cornerRadius: number;
183
+ backgroundColor: RgbaColor;
184
+ fontNames: string[] | undefined;
185
+ text?: string;
186
+ fontName?: string;
187
+ fontColor?: RgbaColor;
188
+ fontSize?: number;
189
+ interpolation?: StringInterpolationMap;
190
+ localize?: boolean;
191
+ anchorPoint?: _m2c2kit_core.Point;
192
+ zPosition?: number;
193
+ name?: string;
194
+ position?: _m2c2kit_core.Point;
195
+ scale?: number;
196
+ alpha?: number;
197
+ zRotation?: number;
198
+ isUserInteractionEnabled?: boolean;
199
+ draggable?: boolean;
200
+ hidden?: boolean;
201
+ layout?: _m2c2kit_core.Layout;
202
+ uuid?: string;
203
+ suppressEvents?: boolean;
204
+ };
127
205
  initialize(): void;
128
206
  dispose(): void;
129
207
  get text(): string;
@@ -132,6 +210,18 @@ declare class Button extends Composite implements IText {
132
210
  set backgroundColor(backgroundColor: RgbaColor);
133
211
  get fontColor(): RgbaColor;
134
212
  set fontColor(fontColor: RgbaColor);
213
+ get fontName(): string | undefined;
214
+ set fontName(fontName: string | undefined);
215
+ get fontNames(): Array<string> | undefined;
216
+ set fontNames(fontNames: Array<string> | undefined);
217
+ get cornerRadius(): number;
218
+ set cornerRadius(cornerRadius: number);
219
+ get fontSize(): number;
220
+ set fontSize(fontSize: number);
221
+ get interpolation(): StringInterpolationMap;
222
+ set interpolation(interpolation: StringInterpolationMap);
223
+ get localize(): boolean;
224
+ set localize(localize: boolean);
135
225
  /**
136
226
  * Duplicates a node using deep copy.
137
227
  *
@@ -180,8 +270,6 @@ declare class Dialog extends Composite {
180
270
  contentText: string;
181
271
  positiveButtonText: string;
182
272
  negativeButtonText: string;
183
- zPosition: number;
184
- hidden: boolean;
185
273
  private _fontColor;
186
274
  private backgroundPaint?;
187
275
  constructor(options?: DialogOptions);
@@ -192,6 +280,8 @@ declare class Dialog extends Composite {
192
280
  set backgroundColor(backgroundColor: RgbaColor);
193
281
  get fontColor(): RgbaColor;
194
282
  set fontColor(fontColor: RgbaColor);
283
+ get hidden(): boolean;
284
+ set hidden(hidden: boolean);
195
285
  /**
196
286
  * Duplicates a node using deep copy.
197
287
  *
@@ -296,6 +386,7 @@ declare class DrawPad extends Composite {
296
386
  private isDrawingPointerDown;
297
387
  private pointerIsDownAndPointerLeftDrawAreaWhenDown;
298
388
  private currentStrokesNotAllowed;
389
+ private originalOptions;
299
390
  /** Array of strokes created on the DrawPad, with position and timestamps
300
391
  * of all interactions with each DrawPadStroke.
301
392
  */
@@ -309,6 +400,39 @@ declare class DrawPad extends Composite {
309
400
  * @param options - {@link DrawPadOptions}
310
401
  */
311
402
  constructor(options: DrawPadOptions);
403
+ get completeNodeOptions(): {
404
+ /** Size of the DrawPad */
405
+ size: Size;
406
+ /** Color of drawn lines. Default is red. */
407
+ lineColor?: RgbaColor;
408
+ /** Width of drawn lines. Default is 1 */
409
+ lineWidth?: number;
410
+ /** Background color of the DrawPad. Default is transparent. */
411
+ backgroundColor?: RgbaColor;
412
+ /** Width of the border. Default is 1 */
413
+ borderWidth?: number;
414
+ /** Color of the border. Default is black */
415
+ borderColor?: RgbaColor;
416
+ isUserInteractionEnabled?: boolean;
417
+ /** Should drawing resume when the pointer, in a down state, returns to the DrawPad area after exiting it while drawing? Default is false. */
418
+ resumeDrawingOnReturn?: boolean;
419
+ /** Should the user be permitted to draw only one continuous line? If so, no more drawing is allowed after the first stroke ends. */
420
+ continuousDrawingOnly?: boolean;
421
+ /** If `continuousDrawingOnly`, this is the maximum pixel distance from the last stroke's end point that the user is allowed to continue drawing with a new stroke. */
422
+ continuousDrawingOnlyExceptionDistance?: number;
423
+ name?: string;
424
+ position?: Point;
425
+ scale?: number;
426
+ alpha?: number;
427
+ zRotation?: number;
428
+ draggable?: boolean;
429
+ hidden?: boolean;
430
+ layout?: _m2c2kit_core.Layout;
431
+ uuid?: string;
432
+ suppressEvents?: boolean;
433
+ anchorPoint?: Point;
434
+ zPosition?: number;
435
+ };
312
436
  initialize(): void;
313
437
  private initializeDrawShape;
314
438
  private initializeDrawArea;
@@ -402,6 +526,12 @@ declare class DrawPad extends Composite {
402
526
  duplicate(newName?: string): DrawPad;
403
527
  }
404
528
 
529
+ /**
530
+ * Additional, optional properties for a key in the `VirtualKeyboard`.
531
+ *
532
+ * @remarks This is used to define special keys (e.g., Shift, Backspace),
533
+ * keys with icons, and keys of custom size.
534
+ */
405
535
  interface KeyConfiguration {
406
536
  /** Width of the key in units of a regular key width. Default is 1. */
407
537
  widthRatio?: number;
@@ -420,7 +550,21 @@ interface KeyConfiguration {
420
550
  /** ShapeOptions of the optional icon to show on the key. */
421
551
  keyIconShapeOptions?: ShapeOptions;
422
552
  }
423
- type VirtualKeyboardRow = Array<KeyConfiguration | string | Array<string>>;
553
+ /**
554
+ * A row in the `VirtualKeyboard`.
555
+ *
556
+ * @remarks Each row is an array of objects that defines a key, where each
557
+ * object can be one of the following:
558
+ * - a string, e.g., `a`. The string is the key in the keyboard's unshifted
559
+ * state (`a`), and the string's value after applying `toUpperCase()` is the key
560
+ * in the keyboard's shifted state (`A`).
561
+ * - an array of two strings, e.g., `["1", "!"]`. The first string is the key
562
+ * in the keyboard's unshifted state (`1`), and the second string is the key
563
+ * in the keyboard's shifted state (`!`).
564
+ * - A `KeyConfiguration` object, which can be used to further customize the
565
+ * key's appearance and behavior.
566
+ */
567
+ type VirtualKeyboardRow = Array<string | Array<string> | KeyConfiguration>;
424
568
  interface VirtualKeyboardOptions extends CompositeOptions {
425
569
  size: Size;
426
570
  /** Percent of the keyboard width that should be used for padding on the left and right sides. Default is .02 */
@@ -454,7 +598,11 @@ interface VirtualKeyboardOptions extends CompositeOptions {
454
598
  /** If true, a preview of the key that will be pressed will be shown. */
455
599
  showKeyDownPreview?: boolean;
456
600
  }
457
- interface VirtualKeyboardEvent extends M2NodeEvent {
601
+ interface VirtualKeyboardEvent extends CompositeEvent {
602
+ type: "Composite";
603
+ compositeType: "VirtualKeyboard";
604
+ compositeEventType: "VirtualKeyboardKeyUp" | "VirtualKeyboardKeyDown" | "VirtualKeyboardKeyLeave";
605
+ target: VirtualKeyboard | string;
458
606
  /** String that is generated when key is pressed, with any modifiers (e.g., Shift) applied. */
459
607
  key: string;
460
608
  /** Code for the key, not taking into account any modifiers. */
@@ -473,11 +621,12 @@ interface KeyTapMetadata {
473
621
  buttons: number;
474
622
  }
475
623
  declare class VirtualKeyboard extends Composite {
624
+ readonly compositeType = "VirtualKeyboard";
476
625
  private keyboardHorizontalPaddingPercent;
477
626
  private keyboardVerticalPaddingPercent;
478
627
  private keyHorizontalPaddingPercent;
479
628
  private keyVerticalPaddingPercent;
480
- private rowsConfiguration;
629
+ private keyboardRows;
481
630
  private keysPerRow;
482
631
  private fontSize;
483
632
  private fontNames;
@@ -488,14 +637,64 @@ declare class VirtualKeyboard extends Composite {
488
637
  private specialKeyDownColor;
489
638
  private backgroundColor;
490
639
  private showKeyDownPreview;
640
+ private originalOptions;
491
641
  private shiftActivated;
492
- private shiftKeyShape;
642
+ private keyShapes;
643
+ private keyLabels;
644
+ private letterCircle?;
645
+ private letterCircleLabel?;
493
646
  /**
494
647
  * An on-screen keyboard that can be used to enter text.
495
648
  *
496
649
  * @param options - {@link VirtualKeyboardOptions}
497
650
  */
498
651
  constructor(options: VirtualKeyboardOptions);
652
+ get completeNodeOptions(): {
653
+ size: Size;
654
+ /** Percent of the keyboard width that should be used for padding on the left and right sides. Default is .02 */
655
+ keyboardHorizontalPaddingPercent?: number;
656
+ /** Percent of the keyboard height that should be used for padding on the top and bottom sides. Default is .025 */
657
+ keyboardVerticalPaddingPercent?: number;
658
+ /** Percent of each key's width that should be used for padding on the left and right sides. Default is .10 */
659
+ keyHorizontalPaddingPercent?: number;
660
+ /** Percent of each key's height that should be used for padding on the top and bottom sides. Default is .10 */
661
+ keyVerticalPaddingPercent?: number;
662
+ /** Configuration of keyboard rows. Order is from top to bottom rows. */
663
+ rows?: Array<VirtualKeyboardRow>;
664
+ /** How many regular-sized keys should fit in a row? This is used for scaling purposes. If not provided, it will be inferred from the row configuration. */
665
+ keysPerRow?: number;
666
+ /** Size of font for keys. */
667
+ fontSize?: number;
668
+ /** The fonts for the key labels, if not the default font. */
669
+ fontNames?: Array<string> | undefined;
670
+ /** Comma-separated list of keys to hide. */
671
+ hiddenKeys?: string;
672
+ /** If true, only capital letters will be shown. */
673
+ capitalLettersOnly?: boolean;
674
+ /** Color of keys. */
675
+ keyColor?: RgbaColor;
676
+ /** Color of keys when pressed. */
677
+ keyDownColor?: RgbaColor;
678
+ /** Color of special keys when pressed. */
679
+ specialKeyDownColor?: RgbaColor;
680
+ /** Background color of keyboard. */
681
+ backgroundColor?: RgbaColor;
682
+ /** If true, a preview of the key that will be pressed will be shown. */
683
+ showKeyDownPreview?: boolean;
684
+ name?: string;
685
+ position?: Point;
686
+ scale?: number;
687
+ alpha?: number;
688
+ zRotation?: number;
689
+ isUserInteractionEnabled?: boolean;
690
+ draggable?: boolean;
691
+ hidden?: boolean;
692
+ layout?: _m2c2kit_core.Layout;
693
+ uuid?: string;
694
+ suppressEvents?: boolean;
695
+ anchorPoint?: Point;
696
+ zPosition?: number;
697
+ };
499
698
  initialize(): void;
500
699
  /**
501
700
  * Executes a callback when the user presses down on a key.
@@ -511,11 +710,54 @@ declare class VirtualKeyboard extends Composite {
511
710
  * @param options
512
711
  */
513
712
  onKeyUp(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void, options?: CallbackOptions): void;
514
- private addVirtualKeyboardEventListener;
713
+ /**
714
+ * Executes a callback when the user has pressed a key with the pointer, but
715
+ * moves the pointer outside the key bounds before releasing the pointer.
716
+ *
717
+ * @remarks Typically, this event will not be used, since it is a user's
718
+ * inaccurate interaction with the keyboard. However, it can be used to
719
+ * provide feedback to the user that they have moved the pointer outside the
720
+ * key bounds, and thus the key stroke will not be registered.
721
+ *
722
+ * @param callback - function to execute
723
+ * @param options
724
+ */
725
+ onKeyLeave(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void, options?: CallbackOptions): void;
515
726
  update(): void;
516
727
  draw(canvas: Canvas): void;
517
728
  warmup(canvas: Canvas): void;
518
729
  duplicate(newName?: string | undefined): M2Node;
730
+ private handleKeyShapeTapDown;
731
+ private handleKeyShapeTapUp;
732
+ private handleKeyShapeTapLeave;
733
+ private getKeyAsString;
734
+ /**
735
+ * Converts the keyboard rows to the internal keyboard configuration.
736
+ *
737
+ * @remarks This normalizes the keyboard rows so that each key is a
738
+ * full `KeyConfigurationWithShape` object, instead of a string or array of
739
+ * strings.
740
+ *
741
+ * @param keyboardRows
742
+ * @returns the keyboard for internal use
743
+ */
744
+ private internalKeyboardRowsToInternalKeyboardConfiguration;
745
+ handleCompositeEvent(event: VirtualKeyboardEvent): void;
746
+ private handleKeyDownEvent;
747
+ private handleKeyUpEvent;
748
+ private handleKeyLeaveEvent;
749
+ private showKeyboardShifted;
750
+ private showKeyboardNotShifted;
751
+ private createDefaultKeyboardRows;
752
+ private addVirtualKeyboardEventListener;
753
+ /**
754
+ * Does the `VirtualKeyboard` respond to user events? Default is true.
755
+ */
756
+ get isUserInteractionEnabled(): boolean;
757
+ /**
758
+ * Does the `VirtualKeyboard` respond to user events? Default is true.
759
+ */
760
+ set isUserInteractionEnabled(isUserInteractionEnabled: boolean);
519
761
  }
520
762
 
521
763
  interface InstructionScene {
@@ -684,4 +926,159 @@ declare class CountdownScene extends Scene {
684
926
  constructor(options: CountdownSceneOptions);
685
927
  }
686
928
 
687
- export { Button, type ButtonOptions, CountdownScene, type CountdownSceneOptions, Dialog, type DialogEvent, type DialogOptions, DialogResult, DrawPad, type DrawPadEvent, DrawPadEventType, type DrawPadItem, type DrawPadItemEvent, DrawPadItemEventType, type DrawPadOptions, type DrawPadStroke, Grid, type GridOptions, type InstructionScene, Instructions, type InstructionsOptions, type KeyConfiguration, type KeyTapMetadata, type StrokeInteraction, type TimerShape, VirtualKeyboard, type VirtualKeyboardEvent, type VirtualKeyboardOptions, type VirtualKeyboardRow };
929
+ interface LocalePickerOptions extends CompositeOptions {
930
+ /** Background color of dialog box. Default is WebColors.White */
931
+ backgroundColor?: RgbaColor;
932
+ /** Locales to choose from in the dialog box. Default is the locales in the game's `Translation`. */
933
+ localeOptions?: Array<LocaleOption>;
934
+ /** What to show as the currently selected locale in the picker. Default is the game's current locale. */
935
+ currentLocale?: string;
936
+ /** Alpha level for the overlay that dims the scene underneath the dialog box. Default is .5 */
937
+ overlayAlpha?: number;
938
+ /** Size of dialog box. Default is automatically sized to fit the number of locale options. */
939
+ size?: Size;
940
+ /** Corner radius of dialog box; can be used to make rounded corners */
941
+ cornerRadius?: number;
942
+ /** Font size of locale options in dialog box. Default is 24. */
943
+ fontSize?: number;
944
+ /** Font color of locale options in dialog box. Default is WebColors.Black */
945
+ fontColor?: RgbaColor;
946
+ /** Image to use for LocalePicker. Default is a globe SVG, 32x32. */
947
+ icon?: LocalePickerIcon;
948
+ /** Position of the LocalePicker icon. Default is &#123; x: 32, y: 32 &#125; */
949
+ iconPosition: Point;
950
+ /** Should the selection in the LocalePicker automatically switch the game's locale? Default is true. */
951
+ automaticallyChangeLocale?: boolean;
952
+ }
953
+ interface LocalePickerIcon {
954
+ /** The HTML SVG tag, in string form, that will be rendered to display the locale.
955
+ * Must begin with &#60;svg> and end with &#60;/svg> */
956
+ svgString?: string;
957
+ /** Name of image to use for LocalePicker. Must have been previously loaded */
958
+ imageName?: string;
959
+ /** Height to scale image to */
960
+ height: number;
961
+ /** Width to scale image to */
962
+ width: number;
963
+ }
964
+ interface LocaleOption {
965
+ /** Human-readable text description of the locale. */
966
+ text: string;
967
+ /** SVG of the locale. */
968
+ svg?: LocaleSvg;
969
+ /** Locale in language-country format, xx-YY. */
970
+ locale: string;
971
+ }
972
+ interface LocalePickerResult {
973
+ /** Locale that was selected. Is undefined if dialog was dismissed. */
974
+ locale?: string;
975
+ }
976
+ interface LocalePickerEvent extends CompositeEvent {
977
+ type: "Composite";
978
+ compositeType: "LocalePicker";
979
+ compositeEventType: "LocalePickerResult";
980
+ result: LocalePickerResult;
981
+ }
982
+ interface LocaleSvg {
983
+ /** The HTML SVG tag, in string form, that will be rendered to display the locale.
984
+ * Must begin with &#60;svg> and end with &#60;/svg> */
985
+ svgString: string;
986
+ /** Height to scale image to */
987
+ height: number;
988
+ /** Width to scale image to */
989
+ width: number;
990
+ }
991
+ declare class LocalePicker extends Composite {
992
+ readonly compositeType = "LocalePicker";
993
+ private readonly DEFAULT_FONT_SIZE;
994
+ automaticallyChangeLocale: boolean;
995
+ private _localeOptions;
996
+ private _backgroundColor;
997
+ private _fontSize;
998
+ private _fontColor;
999
+ private _currentLocale?;
1000
+ private _cornerRadius;
1001
+ private _overlayAlpha;
1002
+ private _icon;
1003
+ private _iconPosition;
1004
+ private iconSprite?;
1005
+ /**
1006
+ * Wrap displayed locale in double angle quotes if it is the current locale.
1007
+ * Note: Although the code editor will allow us to enter almost any
1008
+ * unicode character, it will not render correctly if the font does
1009
+ * not support the character. Thus, be careful to use characters that
1010
+ * are supported by the font. For example, check a page like
1011
+ * https://www.fontspace.com/roboto-font-f13281 to see which characters
1012
+ * are supported by Roboto Regular, which is often the default font in
1013
+ * m2c2kit. Emoji or checkmarks like ✓ are not in Roboto Regular!
1014
+ */
1015
+ private readonly LEFT_SELECTION_INDICATOR;
1016
+ private readonly RIGHT_SELECTION_INDICATOR;
1017
+ /**
1018
+ * An icon and dialog box for selecting a locale from a list of options.
1019
+ *
1020
+ * @remarks This composite node is composed of a dialog box that appears
1021
+ * when the user taps a globe icon. Typically, the `LocalePicker` will be
1022
+ * added as a free node to the game so that it exists independently of
1023
+ * the game's scenes. The dialog box contains a list of locales that the
1024
+ * user can choose from. By default, this list is populated with the locales
1025
+ * in the game's `Translation` object. When the user selects a locale, the
1026
+ * dialog box disappears and the locale is set as the game's current locale.
1027
+ * The dialog box is automatically sized to fit the number of locale
1028
+ * options.
1029
+ *
1030
+ * @example
1031
+ * let localePicker: LocalePicker;
1032
+ * if (game.getParameter<boolean>("show_locale_picker")) {
1033
+ * localePicker = new LocalePicker();
1034
+ * game.addFreeNode(localePicker);
1035
+ * }
1036
+ *
1037
+ * @param options - {@link LocalePickerOptions}
1038
+ */
1039
+ constructor(options?: LocalePickerOptions);
1040
+ /**
1041
+ * Executes a callback when the user selects a locale.
1042
+ *
1043
+ * @param callback - function to execute
1044
+ * @param options - {@link CallbackOptions}
1045
+ */
1046
+ onResult(callback: (localePickerEvent: LocalePickerEvent) => void, options?: CallbackOptions): void;
1047
+ initialize(): void;
1048
+ private handleLocaleSelection;
1049
+ private setDialogVisibility;
1050
+ get backgroundColor(): RgbaColor;
1051
+ set backgroundColor(backgroundColor: RgbaColor);
1052
+ get fontSize(): number;
1053
+ set fontSize(fontSize: number);
1054
+ get fontColor(): RgbaColor;
1055
+ set fontColor(fontColor: RgbaColor);
1056
+ get cornerRadius(): number;
1057
+ set cornerRadius(cornerRadius: number);
1058
+ get overlayAlpha(): number;
1059
+ set overlayAlpha(alpha: number);
1060
+ get icon(): LocalePickerIcon;
1061
+ set icon(icon: LocalePickerIcon);
1062
+ get iconPosition(): Point;
1063
+ set iconPosition(position: Point);
1064
+ get localeOptions(): Array<LocaleOption>;
1065
+ set localeOptions(options: Array<LocaleOption>);
1066
+ get currentLocale(): string | undefined;
1067
+ set currentLocale(locale: string | undefined);
1068
+ update(): void;
1069
+ draw(canvas: Canvas): void;
1070
+ warmup(canvas: Canvas): void;
1071
+ /**
1072
+ * Duplicates a node using deep copy.
1073
+ *
1074
+ * @remarks This is a deep recursive clone (node and children).
1075
+ * The uuid property of all duplicated nodes will be newly created,
1076
+ * because uuid must be unique.
1077
+ *
1078
+ * @param newName - optional name of the new, duplicated node. If not
1079
+ * provided, name will be the new uuid
1080
+ */
1081
+ duplicate(newName?: string): LocalePicker;
1082
+ }
1083
+
1084
+ export { Button, type ButtonOptions, CountdownScene, type CountdownSceneOptions, Dialog, type DialogEvent, type DialogOptions, DialogResult, DrawPad, type DrawPadEvent, DrawPadEventType, type DrawPadItem, type DrawPadItemEvent, DrawPadItemEventType, type DrawPadOptions, type DrawPadStroke, Grid, type GridChild, type GridOptions, type InstructionScene, Instructions, type InstructionsOptions, type KeyConfiguration, type KeyTapMetadata, type LocaleOption, LocalePicker, type LocalePickerEvent, type LocalePickerIcon, type LocalePickerOptions, type LocalePickerResult, type StrokeInteraction, type TimerShape, VirtualKeyboard, type VirtualKeyboardEvent, type VirtualKeyboardOptions, type VirtualKeyboardRow };