@m2c2kit/addons 0.3.13 → 0.3.15
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 +293 -57
- package/dist/index.js +799 -144
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1 -0
- package/package.json +13 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Canvas } from 'canvaskit-wasm';
|
|
2
|
-
import { CompositeOptions, Size, RgbaColor, Composite,
|
|
2
|
+
import { CompositeOptions, Size, RgbaColor, Composite, M2Node, GlobalVariables, TextOptions, IText, StringInterpolationMap, M2NodeEvent, CallbackOptions, Point, ShapeOptions, LabelHorizontalAlignmentMode, Transition, StoryOptions, Story, Scene, SceneOptions } from '@m2c2kit/core';
|
|
3
3
|
|
|
4
4
|
interface GridOptions extends CompositeOptions {
|
|
5
5
|
/** Number of rows in the grid. Must be 1 or greater */
|
|
@@ -16,7 +16,7 @@ interface GridOptions extends CompositeOptions {
|
|
|
16
16
|
gridLineColor?: RgbaColor;
|
|
17
17
|
}
|
|
18
18
|
interface GridChild {
|
|
19
|
-
|
|
19
|
+
node: M2Node;
|
|
20
20
|
row: number;
|
|
21
21
|
column: number;
|
|
22
22
|
}
|
|
@@ -32,11 +32,11 @@ declare class Grid extends Composite {
|
|
|
32
32
|
gridChildren: GridChild[];
|
|
33
33
|
private _gridBackground?;
|
|
34
34
|
/**
|
|
35
|
-
* A rectangular grid that supports placement of
|
|
35
|
+
* A rectangular grid that supports placement of nodes within the grid's
|
|
36
36
|
* cells.
|
|
37
37
|
*
|
|
38
|
-
* @remarks This composite
|
|
39
|
-
* has convenience functions for placing and clearing
|
|
38
|
+
* @remarks This composite node is composed of rectangles and lines. It
|
|
39
|
+
* has convenience functions for placing and clearing nodes on the grid
|
|
40
40
|
* by row and column position (zero-based indexing)
|
|
41
41
|
*
|
|
42
42
|
* @param options - {@link GridOptions}
|
|
@@ -47,13 +47,13 @@ declare class Grid extends Composite {
|
|
|
47
47
|
private set gridBackground(value);
|
|
48
48
|
dispose(): void;
|
|
49
49
|
/**
|
|
50
|
-
* Duplicates
|
|
50
|
+
* Duplicates a node using deep copy.
|
|
51
51
|
*
|
|
52
|
-
* @remarks This is a deep recursive clone (
|
|
53
|
-
* The uuid property of all duplicated
|
|
52
|
+
* @remarks This is a deep recursive clone (node and children).
|
|
53
|
+
* The uuid property of all duplicated nodes will be newly created,
|
|
54
54
|
* because uuid must be unique.
|
|
55
55
|
*
|
|
56
|
-
* @param newName - optional name of the new, duplicated
|
|
56
|
+
* @param newName - optional name of the new, duplicated node. If not
|
|
57
57
|
* provided, name will be the new uuid
|
|
58
58
|
*/
|
|
59
59
|
duplicate(newName?: string): Grid;
|
|
@@ -65,26 +65,26 @@ declare class Grid extends Composite {
|
|
|
65
65
|
*/
|
|
66
66
|
removeAllChildren(): void;
|
|
67
67
|
/**
|
|
68
|
-
* Adds
|
|
68
|
+
* Adds a node to the grid at the specified row and column position.
|
|
69
69
|
*
|
|
70
|
-
* @param
|
|
71
|
-
* @param row - row position within grid to add
|
|
72
|
-
* @param column - column position within grid to add
|
|
70
|
+
* @param node - node to add to the grid
|
|
71
|
+
* @param row - row position within grid to add node; zero-based indexing
|
|
72
|
+
* @param column - column position within grid to add node; zero-based indexing
|
|
73
73
|
*/
|
|
74
|
-
addAtCell(
|
|
74
|
+
addAtCell(node: M2Node, row: number, column: number): void;
|
|
75
75
|
/**
|
|
76
|
-
* Removes all child
|
|
76
|
+
* Removes all child nodes at the specified row and column position.
|
|
77
77
|
*
|
|
78
78
|
* @param row - row position within grid at which to remove children; zero-based indexing
|
|
79
79
|
* @param column - column position within grid at which to remove children; zero-based indexing
|
|
80
80
|
*/
|
|
81
81
|
removeAllAtCell(row: number, column: number): void;
|
|
82
82
|
/**
|
|
83
|
-
* Removes the child
|
|
83
|
+
* Removes the child node from the grid.
|
|
84
84
|
*
|
|
85
|
-
* @param
|
|
85
|
+
* @param node - node to remove
|
|
86
86
|
*/
|
|
87
|
-
removeChild(
|
|
87
|
+
removeChild(node: M2Node): void;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
declare global {
|
|
@@ -101,6 +101,8 @@ interface ButtonOptions extends CompositeOptions, TextOptions {
|
|
|
101
101
|
backgroundColor?: RgbaColor;
|
|
102
102
|
/** Color of button text. Default is WebColors.White */
|
|
103
103
|
fontColor?: RgbaColor;
|
|
104
|
+
/** 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 */
|
|
105
|
+
fontNames?: Array<string>;
|
|
104
106
|
}
|
|
105
107
|
declare class Button extends Composite implements IText {
|
|
106
108
|
compositeType: string;
|
|
@@ -113,11 +115,15 @@ declare class Button extends Composite implements IText {
|
|
|
113
115
|
fontSize: number;
|
|
114
116
|
private _text;
|
|
115
117
|
private _fontColor;
|
|
118
|
+
private _fontName;
|
|
119
|
+
private _fontNames;
|
|
120
|
+
private _interpolation;
|
|
121
|
+
private _localize;
|
|
116
122
|
private backgroundPaint?;
|
|
117
123
|
/**
|
|
118
124
|
* A simple button of rectangle with text centered inside.
|
|
119
125
|
*
|
|
120
|
-
* @remarks This composite
|
|
126
|
+
* @remarks This composite node is composed of a rectangle and text. To
|
|
121
127
|
* respond to user taps, the isUserInteractionEnabled property must be set
|
|
122
128
|
* to true and an appropriate callback must be set to handle the tap event.
|
|
123
129
|
*
|
|
@@ -132,14 +138,22 @@ declare class Button extends Composite implements IText {
|
|
|
132
138
|
set backgroundColor(backgroundColor: RgbaColor);
|
|
133
139
|
get fontColor(): RgbaColor;
|
|
134
140
|
set fontColor(fontColor: RgbaColor);
|
|
141
|
+
get fontName(): string | undefined;
|
|
142
|
+
set fontName(fontName: string | undefined);
|
|
143
|
+
get fontNames(): Array<string> | undefined;
|
|
144
|
+
set fontNames(fontNames: Array<string> | undefined);
|
|
145
|
+
get interpolation(): StringInterpolationMap;
|
|
146
|
+
set interpolation(interpolation: StringInterpolationMap);
|
|
147
|
+
get localize(): boolean;
|
|
148
|
+
set localize(localize: boolean);
|
|
135
149
|
/**
|
|
136
|
-
* Duplicates
|
|
150
|
+
* Duplicates a node using deep copy.
|
|
137
151
|
*
|
|
138
|
-
* @remarks This is a deep recursive clone (
|
|
139
|
-
* The uuid property of all duplicated
|
|
152
|
+
* @remarks This is a deep recursive clone (node and children).
|
|
153
|
+
* The uuid property of all duplicated nodes will be newly created,
|
|
140
154
|
* because uuid must be unique.
|
|
141
155
|
*
|
|
142
|
-
* @param newName - optional name of the new, duplicated
|
|
156
|
+
* @param newName - optional name of the new, duplicated node. If not
|
|
143
157
|
* provided, name will be the new uuid
|
|
144
158
|
*/
|
|
145
159
|
duplicate(newName?: string): Button;
|
|
@@ -169,7 +183,7 @@ declare enum DialogResult {
|
|
|
169
183
|
Positive = "Positive",
|
|
170
184
|
Negative = "Negative"
|
|
171
185
|
}
|
|
172
|
-
interface DialogEvent extends
|
|
186
|
+
interface DialogEvent extends M2NodeEvent {
|
|
173
187
|
dialogResult: DialogResult;
|
|
174
188
|
}
|
|
175
189
|
declare class Dialog extends Composite {
|
|
@@ -186,20 +200,20 @@ declare class Dialog extends Composite {
|
|
|
186
200
|
private backgroundPaint?;
|
|
187
201
|
constructor(options?: DialogOptions);
|
|
188
202
|
show(): void;
|
|
189
|
-
onDialogResult(callback: (dialogResultEvent: DialogEvent) => void,
|
|
203
|
+
onDialogResult(callback: (dialogResultEvent: DialogEvent) => void, options?: CallbackOptions): void;
|
|
190
204
|
initialize(): void;
|
|
191
205
|
get backgroundColor(): RgbaColor;
|
|
192
206
|
set backgroundColor(backgroundColor: RgbaColor);
|
|
193
207
|
get fontColor(): RgbaColor;
|
|
194
208
|
set fontColor(fontColor: RgbaColor);
|
|
195
209
|
/**
|
|
196
|
-
* Duplicates
|
|
210
|
+
* Duplicates a node using deep copy.
|
|
197
211
|
*
|
|
198
|
-
* @remarks This is a deep recursive clone (
|
|
199
|
-
* The uuid property of all duplicated
|
|
212
|
+
* @remarks This is a deep recursive clone (node and children).
|
|
213
|
+
* The uuid property of all duplicated nodes will be newly created,
|
|
200
214
|
* because uuid must be unique.
|
|
201
215
|
*
|
|
202
|
-
* @param newName - optional name of the new, duplicated
|
|
216
|
+
* @param newName - optional name of the new, duplicated node. If not
|
|
203
217
|
* provided, name will be the new uuid
|
|
204
218
|
*/
|
|
205
219
|
duplicate(newName?: string): Dialog;
|
|
@@ -236,7 +250,7 @@ declare const DrawPadEventType: {
|
|
|
236
250
|
readonly StrokeEnd: "StrokeEnd";
|
|
237
251
|
};
|
|
238
252
|
type DrawPadEventType = (typeof DrawPadEventType)[keyof typeof DrawPadEventType];
|
|
239
|
-
interface DrawPadEvent extends
|
|
253
|
+
interface DrawPadEvent extends M2NodeEvent {
|
|
240
254
|
type: DrawPadEventType;
|
|
241
255
|
position: Point;
|
|
242
256
|
}
|
|
@@ -245,7 +259,7 @@ declare const DrawPadItemEventType: {
|
|
|
245
259
|
readonly StrokeLeave: "StrokeLeave";
|
|
246
260
|
};
|
|
247
261
|
type DrawPadItemEventType = (typeof DrawPadItemEventType)[keyof typeof DrawPadItemEventType];
|
|
248
|
-
interface DrawPadItemEvent extends
|
|
262
|
+
interface DrawPadItemEvent extends M2NodeEvent {
|
|
249
263
|
type: DrawPadItemEventType;
|
|
250
264
|
}
|
|
251
265
|
interface StrokeInteraction {
|
|
@@ -303,7 +317,7 @@ declare class DrawPad extends Composite {
|
|
|
303
317
|
/**
|
|
304
318
|
* A rectangular area on which the user can draw strokes (lines).
|
|
305
319
|
*
|
|
306
|
-
* @remarks This composite
|
|
320
|
+
* @remarks This composite node is composed of a rectangle Shape and
|
|
307
321
|
* another Shape that is formed from a path of points.
|
|
308
322
|
*
|
|
309
323
|
* @param options - {@link DrawPadOptions}
|
|
@@ -349,20 +363,20 @@ declare class DrawPad extends Composite {
|
|
|
349
363
|
*/
|
|
350
364
|
onStrokeEnd(callback: (ev: DrawPadEvent) => void, options?: CallbackOptions): void;
|
|
351
365
|
/**
|
|
352
|
-
* Adds
|
|
366
|
+
* Adds a node to the DrawPad.
|
|
353
367
|
*
|
|
354
|
-
* @remarks After the
|
|
368
|
+
* @remarks After the node is added to the DrawPad, its
|
|
355
369
|
* position is adjusted to be relative to the DrawPad's coordinate
|
|
356
370
|
* system, and it is made interactive. The method returns an object
|
|
357
|
-
* which is the
|
|
358
|
-
* properties, and events specific to it now being on a DrawPad. The
|
|
371
|
+
* which is the node as a DrawPadItem, which has additional methods,
|
|
372
|
+
* properties, and events specific to it now being on a DrawPad. The node
|
|
359
373
|
* now **must** be manipulated only using the DrawPadItem object. Using
|
|
360
|
-
* the original
|
|
374
|
+
* the original node object will result in undefined behavior.
|
|
361
375
|
*
|
|
362
|
-
* @param
|
|
363
|
-
* @returns the
|
|
376
|
+
* @param node - the node to add to the DrawPad
|
|
377
|
+
* @returns the node as a DrawPadItem
|
|
364
378
|
*/
|
|
365
|
-
addItem<T extends
|
|
379
|
+
addItem<T extends M2Node>(node: T): T & DrawPadItem;
|
|
366
380
|
/**
|
|
367
381
|
* Takes a screenshot of the DrawPad.
|
|
368
382
|
*
|
|
@@ -454,7 +468,7 @@ interface VirtualKeyboardOptions extends CompositeOptions {
|
|
|
454
468
|
/** If true, a preview of the key that will be pressed will be shown. */
|
|
455
469
|
showKeyDownPreview?: boolean;
|
|
456
470
|
}
|
|
457
|
-
interface VirtualKeyboardEvent extends
|
|
471
|
+
interface VirtualKeyboardEvent extends M2NodeEvent {
|
|
458
472
|
/** String that is generated when key is pressed, with any modifiers (e.g., Shift) applied. */
|
|
459
473
|
key: string;
|
|
460
474
|
/** Code for the key, not taking into account any modifiers. */
|
|
@@ -473,6 +487,7 @@ interface KeyTapMetadata {
|
|
|
473
487
|
buttons: number;
|
|
474
488
|
}
|
|
475
489
|
declare class VirtualKeyboard extends Composite {
|
|
490
|
+
compositeType: string;
|
|
476
491
|
private keyboardHorizontalPaddingPercent;
|
|
477
492
|
private keyboardVerticalPaddingPercent;
|
|
478
493
|
private keyHorizontalPaddingPercent;
|
|
@@ -490,6 +505,8 @@ declare class VirtualKeyboard extends Composite {
|
|
|
490
505
|
private showKeyDownPreview;
|
|
491
506
|
private shiftActivated;
|
|
492
507
|
private shiftKeyShape;
|
|
508
|
+
private keyShapes;
|
|
509
|
+
_isUserInteractionEnabled: boolean;
|
|
493
510
|
/**
|
|
494
511
|
* An on-screen keyboard that can be used to enter text.
|
|
495
512
|
*
|
|
@@ -501,29 +518,29 @@ declare class VirtualKeyboard extends Composite {
|
|
|
501
518
|
* Executes a callback when the user presses down on a key.
|
|
502
519
|
*
|
|
503
520
|
* @param callback - function to execute
|
|
504
|
-
* @param
|
|
505
|
-
* any existing callbacks of the same event type on this entity? Usually
|
|
506
|
-
* there should be only one callback defined, instead of chaining multiple
|
|
507
|
-
* ones. It is strongly recommended not to change this, unless you have a
|
|
508
|
-
* special use case. Default is true.
|
|
521
|
+
* @param options
|
|
509
522
|
*/
|
|
510
|
-
onKeyDown(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void,
|
|
523
|
+
onKeyDown(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void, options?: CallbackOptions): void;
|
|
511
524
|
/**
|
|
512
525
|
* Executes a callback when the user releases a key.
|
|
513
526
|
*
|
|
514
527
|
* @param callback - function to execute
|
|
515
|
-
* @param
|
|
516
|
-
* any existing callbacks of the same event type on this entity? Usually
|
|
517
|
-
* there should be only one callback defined, instead of chaining multiple
|
|
518
|
-
* ones. It is strongly recommended not to change this, unless you have a
|
|
519
|
-
* special use case. Default is true.
|
|
528
|
+
* @param options
|
|
520
529
|
*/
|
|
521
|
-
onKeyUp(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void,
|
|
530
|
+
onKeyUp(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void, options?: CallbackOptions): void;
|
|
522
531
|
private addVirtualKeyboardEventListener;
|
|
532
|
+
/**
|
|
533
|
+
* Does the `VirtualKeyboard` respond to user events? Default is true.
|
|
534
|
+
*/
|
|
535
|
+
get isUserInteractionEnabled(): boolean;
|
|
536
|
+
/**
|
|
537
|
+
* Does the `VirtualKeyboard` respond to user events? Default is true.
|
|
538
|
+
*/
|
|
539
|
+
set isUserInteractionEnabled(isUserInteractionEnabled: boolean);
|
|
523
540
|
update(): void;
|
|
524
541
|
draw(canvas: Canvas): void;
|
|
525
542
|
warmup(canvas: Canvas): void;
|
|
526
|
-
duplicate(newName?: string | undefined):
|
|
543
|
+
duplicate(newName?: string | undefined): M2Node;
|
|
527
544
|
}
|
|
528
545
|
|
|
529
546
|
interface InstructionScene {
|
|
@@ -618,12 +635,231 @@ interface InstructionsOptions extends StoryOptions {
|
|
|
618
635
|
}
|
|
619
636
|
declare class Instructions extends Story {
|
|
620
637
|
/**
|
|
621
|
-
*
|
|
638
|
+
* Creates an array of scenes containing instructions on how to complete the assessment
|
|
639
|
+
*
|
|
640
|
+
* @param options - {@link InstructionsOptions}
|
|
641
|
+
* @returns instruction scenes
|
|
642
|
+
*/
|
|
643
|
+
static create(options: InstructionsOptions): Array<Scene>;
|
|
644
|
+
/**
|
|
645
|
+
* Creates an array of scenes containing instructions on how to complete the assessment
|
|
646
|
+
*
|
|
647
|
+
* @deprecated Use {@link Instructions.create} instead (lower case method name "create")
|
|
622
648
|
*
|
|
623
649
|
* @param options - {@link InstructionsOptions}
|
|
624
|
-
* @returns
|
|
650
|
+
* @returns instruction scenes
|
|
625
651
|
*/
|
|
626
652
|
static Create(options: InstructionsOptions): Array<Scene>;
|
|
627
653
|
}
|
|
628
654
|
|
|
629
|
-
|
|
655
|
+
interface CountdownSceneOptions extends SceneOptions {
|
|
656
|
+
/** Duration of the countdown, in milliseconds. */
|
|
657
|
+
milliseconds: number;
|
|
658
|
+
/** Duration of the slide transition, in milliseconds, to the next scene after the countdown completes. Default is 500. */
|
|
659
|
+
transitionDurationMilliseconds?: number;
|
|
660
|
+
/** A custom transition to use to present next scene after the countdown completes. */
|
|
661
|
+
transition?: Transition;
|
|
662
|
+
/** Duration in milliseconds to stay on zero before transitioning to the next scene. Default is zero. This option should be used if `transition` is set to `Transition.none()`. Otherwise, the zero will flash for a single frame before presenting the next scene. */
|
|
663
|
+
zeroDwellMilliseconds?: number;
|
|
664
|
+
/** Text shown below the countdown shape. Default is "GET READY". */
|
|
665
|
+
text?: string;
|
|
666
|
+
/** Font name for text */
|
|
667
|
+
textFontName?: string;
|
|
668
|
+
/** Font size for text. Default is 50. */
|
|
669
|
+
textFontSize?: number;
|
|
670
|
+
/** Font color for text. Default is black. */
|
|
671
|
+
textFontColor?: RgbaColor;
|
|
672
|
+
/** Distance between bottom of countdown shape and text. Default is 32. */
|
|
673
|
+
textMarginTop?: number;
|
|
674
|
+
/** Font name for timer numbers. */
|
|
675
|
+
timerNumbersFontName?: string;
|
|
676
|
+
/** Font size for timer numbers. Default is 50. */
|
|
677
|
+
timerNumbersFontSize?: number;
|
|
678
|
+
/** Font size for timer numbers. Default is white. */
|
|
679
|
+
timerNumbersFontColor?: RgbaColor;
|
|
680
|
+
/** String to show when the timer reaches zero. Default is "0". This could be changed to another value, such as "GO!" */
|
|
681
|
+
timerZeroString?: string;
|
|
682
|
+
/** Shape of the timer. Default is a Royal Blue circle with a radius of 100 centered vertically. */
|
|
683
|
+
timerShape?: TimerShape;
|
|
684
|
+
}
|
|
685
|
+
interface TimerShape {
|
|
686
|
+
circle?: {
|
|
687
|
+
/** Radius of the circle timer shape. */
|
|
688
|
+
radius: number;
|
|
689
|
+
};
|
|
690
|
+
rectangle?: {
|
|
691
|
+
/** Width of the rectangle timer shape. */
|
|
692
|
+
width: number;
|
|
693
|
+
/** Height of the rectangle timer shape. */
|
|
694
|
+
height: number;
|
|
695
|
+
/** Corner radius of the rectangle timer shape. Default is 0. */
|
|
696
|
+
cornerRadius?: number;
|
|
697
|
+
};
|
|
698
|
+
/** Color of the timer shape. Default is Royal Blue. */
|
|
699
|
+
fillColor?: RgbaColor;
|
|
700
|
+
/** Default is to center the timer shape vertically within the scene (verticalBias = .5). Setting verticalBias less than .5 will pull the shape towards the top. Setting verticalBias greater than .5 will pull the shape towards the bottom. */
|
|
701
|
+
verticalBias?: number;
|
|
702
|
+
}
|
|
703
|
+
declare class CountdownScene extends Scene {
|
|
704
|
+
/**
|
|
705
|
+
* A scene that counts down from a specified number to zero, then transitions to the next scene.
|
|
706
|
+
*
|
|
707
|
+
* @param options - {@link CountdownSceneOptions}
|
|
708
|
+
*/
|
|
709
|
+
constructor(options: CountdownSceneOptions);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
interface LocalePickerOptions extends CompositeOptions {
|
|
713
|
+
/** Background color of dialog box. Default is WebColors.White */
|
|
714
|
+
backgroundColor?: RgbaColor;
|
|
715
|
+
/** Locales to choose from in the dialog box. Default is the locales in the game's `Translation`. */
|
|
716
|
+
localeOptions?: Array<LocaleOption>;
|
|
717
|
+
/** What to show as the currently selected locale in the picker. Default is the game's current locale. */
|
|
718
|
+
currentLocale?: string;
|
|
719
|
+
/** Alpha level for the overlay that dims the scene underneath the dialog box. Default is .5 */
|
|
720
|
+
overlayAlpha?: number;
|
|
721
|
+
/** Size of dialog box. Default is automatically sized to fit the number of locale options. */
|
|
722
|
+
size?: Size;
|
|
723
|
+
/** Corner radius of dialog box; can be used to make rounded corners */
|
|
724
|
+
cornerRadius?: number;
|
|
725
|
+
/** Font size of locale options in dialog box. Default is 24. */
|
|
726
|
+
fontSize?: number;
|
|
727
|
+
/** Font color of locale options in dialog box. Default is WebColors.Black */
|
|
728
|
+
fontColor?: RgbaColor;
|
|
729
|
+
/** Image to use for LocalePicker. Default is a globe SVG, 32x32. */
|
|
730
|
+
icon?: LocalePickerIcon;
|
|
731
|
+
/** Position of the LocalePicker icon. Default is { x: 32, y: 32 } */
|
|
732
|
+
iconPosition: Point;
|
|
733
|
+
/** Should the selection in the LocalePicker automatically switch the game's locale? Default is true. */
|
|
734
|
+
automaticallyChangeLocale?: boolean;
|
|
735
|
+
}
|
|
736
|
+
interface LocalePickerIcon {
|
|
737
|
+
/** The HTML SVG tag, in string form, that will be rendered to display the locale.
|
|
738
|
+
* Must begin with <svg> and end with </svg> */
|
|
739
|
+
svgString?: string;
|
|
740
|
+
/** Name of image to use for LocalePicker. Must have been previously loaded */
|
|
741
|
+
imageName?: string;
|
|
742
|
+
/** Height to scale image to */
|
|
743
|
+
height: number;
|
|
744
|
+
/** Width to scale image to */
|
|
745
|
+
width: number;
|
|
746
|
+
}
|
|
747
|
+
interface LocaleOption {
|
|
748
|
+
/** Human-readable text description of the locale. */
|
|
749
|
+
text: string;
|
|
750
|
+
/** SVG of the locale. */
|
|
751
|
+
svg?: LocaleSvg;
|
|
752
|
+
/** Locale in language-country format, xx-YY. */
|
|
753
|
+
locale: string;
|
|
754
|
+
}
|
|
755
|
+
interface LocalePickerResult {
|
|
756
|
+
/** Locale that was selected. Is undefined if dialog was dismissed. */
|
|
757
|
+
locale?: string;
|
|
758
|
+
}
|
|
759
|
+
interface LocalePickerEvent extends M2NodeEvent {
|
|
760
|
+
result: LocalePickerResult;
|
|
761
|
+
}
|
|
762
|
+
interface LocaleSvg {
|
|
763
|
+
/** The HTML SVG tag, in string form, that will be rendered to display the locale.
|
|
764
|
+
* Must begin with <svg> and end with </svg> */
|
|
765
|
+
svgString: string;
|
|
766
|
+
/** Height to scale image to */
|
|
767
|
+
height: number;
|
|
768
|
+
/** Width to scale image to */
|
|
769
|
+
width: number;
|
|
770
|
+
}
|
|
771
|
+
declare class LocalePicker extends Composite {
|
|
772
|
+
compositeType: string;
|
|
773
|
+
zPosition: number;
|
|
774
|
+
private readonly DEFAULT_FONT_SIZE;
|
|
775
|
+
automaticallyChangeLocale: boolean;
|
|
776
|
+
private _localeOptions;
|
|
777
|
+
private _backgroundColor;
|
|
778
|
+
private _fontSize;
|
|
779
|
+
private _fontColor;
|
|
780
|
+
private _currentLocale?;
|
|
781
|
+
private _cornerRadius;
|
|
782
|
+
private _overlayAlpha;
|
|
783
|
+
private _icon;
|
|
784
|
+
private _iconPosition;
|
|
785
|
+
private iconSprite?;
|
|
786
|
+
/**
|
|
787
|
+
* Wrap displayed locale in double angle quotes if it is the current locale.
|
|
788
|
+
* Note: Although the code editor will allow us to enter almost any
|
|
789
|
+
* unicode character, it will not render correctly if the font does
|
|
790
|
+
* not support the character. Thus, be careful to use characters that
|
|
791
|
+
* are supported by the font. For example, check a page like
|
|
792
|
+
* https://www.fontspace.com/roboto-font-f13281 to see which characters
|
|
793
|
+
* are supported by Roboto Regular, which is often the default font in
|
|
794
|
+
* m2c2kit. Emoji or checkmarks like ✓ are not in Roboto Regular!
|
|
795
|
+
*/
|
|
796
|
+
private readonly LEFT_SELECTION_INDICATOR;
|
|
797
|
+
private readonly RIGHT_SELECTION_INDICATOR;
|
|
798
|
+
/**
|
|
799
|
+
* An icon and dialog box for selecting a locale from a list of options.
|
|
800
|
+
*
|
|
801
|
+
* @remarks This composite node is composed of a dialog box that appears
|
|
802
|
+
* when the user taps a globe icon. Typically, the `LocalePicker` will be
|
|
803
|
+
* added as a free node to the game so that it exists independently of
|
|
804
|
+
* the game's scenes. The dialog box contains a list of locales that the
|
|
805
|
+
* user can choose from. By default, this list is populated with the locales
|
|
806
|
+
* in the game's `Translation` object. When the user selects a locale, the
|
|
807
|
+
* dialog box disappears and the locale is set as the game's current locale.
|
|
808
|
+
* The dialog box is automatically sized to fit the number of locale
|
|
809
|
+
* options.
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* let localePicker: LocalePicker;
|
|
813
|
+
* if (game.getParameter<boolean>("show_locale_picker")) {
|
|
814
|
+
* localePicker = new LocalePicker();
|
|
815
|
+
* game.addFreeNode(localePicker);
|
|
816
|
+
* }
|
|
817
|
+
*
|
|
818
|
+
* @param options - {@link LocalePickerOptions}
|
|
819
|
+
*/
|
|
820
|
+
constructor(options?: LocalePickerOptions);
|
|
821
|
+
/**
|
|
822
|
+
* Executes a callback when the user selects a locale.
|
|
823
|
+
*
|
|
824
|
+
* @param callback - function to execute
|
|
825
|
+
* @param options - {@link CallbackOptions}
|
|
826
|
+
*/
|
|
827
|
+
onResult(callback: (localePickerEvent: LocalePickerEvent) => void, options?: CallbackOptions): void;
|
|
828
|
+
initialize(): void;
|
|
829
|
+
private handleLocaleSelection;
|
|
830
|
+
private setDialogVisibility;
|
|
831
|
+
get backgroundColor(): RgbaColor;
|
|
832
|
+
set backgroundColor(backgroundColor: RgbaColor);
|
|
833
|
+
get fontSize(): number;
|
|
834
|
+
set fontSize(fontSize: number);
|
|
835
|
+
get fontColor(): RgbaColor;
|
|
836
|
+
set fontColor(fontColor: RgbaColor);
|
|
837
|
+
get cornerRadius(): number;
|
|
838
|
+
set cornerRadius(cornerRadius: number);
|
|
839
|
+
get overlayAlpha(): number;
|
|
840
|
+
set overlayAlpha(alpha: number);
|
|
841
|
+
get icon(): LocalePickerIcon;
|
|
842
|
+
set icon(icon: LocalePickerIcon);
|
|
843
|
+
get iconPosition(): Point;
|
|
844
|
+
set iconPosition(position: Point);
|
|
845
|
+
get localeOptions(): Array<LocaleOption>;
|
|
846
|
+
set localeOptions(options: Array<LocaleOption>);
|
|
847
|
+
get currentLocale(): string | undefined;
|
|
848
|
+
set currentLocale(locale: string | undefined);
|
|
849
|
+
update(): void;
|
|
850
|
+
draw(canvas: Canvas): void;
|
|
851
|
+
warmup(canvas: Canvas): void;
|
|
852
|
+
/**
|
|
853
|
+
* Duplicates a node using deep copy.
|
|
854
|
+
*
|
|
855
|
+
* @remarks This is a deep recursive clone (node and children).
|
|
856
|
+
* The uuid property of all duplicated nodes will be newly created,
|
|
857
|
+
* because uuid must be unique.
|
|
858
|
+
*
|
|
859
|
+
* @param newName - optional name of the new, duplicated node. If not
|
|
860
|
+
* provided, name will be the new uuid
|
|
861
|
+
*/
|
|
862
|
+
duplicate(newName?: string): LocalePicker;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
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 LocaleOption, LocalePicker, type LocalePickerEvent, type LocalePickerIcon, type LocalePickerOptions, type LocalePickerResult, type StrokeInteraction, type TimerShape, VirtualKeyboard, type VirtualKeyboardEvent, type VirtualKeyboardOptions, type VirtualKeyboardRow };
|