@m2c2kit/addons 0.3.14 → 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 CHANGED
@@ -1,5 +1,5 @@
1
1
  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';
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 */
@@ -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,6 +115,10 @@ 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.
@@ -132,6 +138,14 @@ 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
150
  * Duplicates a node using deep copy.
137
151
  *
@@ -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
  *
@@ -512,6 +529,14 @@ declare class VirtualKeyboard extends Composite {
512
529
  */
513
530
  onKeyUp(callback: (virtualKeyboardEvent: VirtualKeyboardEvent) => void, options?: CallbackOptions): void;
514
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);
515
540
  update(): void;
516
541
  draw(canvas: Canvas): void;
517
542
  warmup(canvas: Canvas): void;
@@ -684,4 +709,157 @@ declare class CountdownScene extends Scene {
684
709
  constructor(options: CountdownSceneOptions);
685
710
  }
686
711
 
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 };
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 &#123; x: 32, y: 32 &#125; */
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 &#60;svg> and end with &#60;/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 &#60;svg> and end with &#60;/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 };