@drincs/pixi-vn 0.1.2 → 0.1.4

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.
@@ -0,0 +1,1510 @@
1
+ import * as pixi_js from 'pixi.js';
2
+ import { ContainerOptions, SpriteOptions, TextOptions, Container, Sprite, ContainerEvents, EventEmitter, Texture, TextureSourceLike, Text, UPDATE_PRIORITY, Ticker, TickerCallback, Application, ApplicationOptions } from 'pixi.js';
3
+ import deepDiff from 'deep-diff';
4
+
5
+ /**
6
+ * CanvasEventNamesType is a type that is used to define the event names for the canvas.
7
+ */
8
+ type CanvasEventNamesType = (string | symbol) extends string | symbol ? (string | symbol) : keyof (string | symbol);
9
+
10
+ /**
11
+ * CanvasEvent is a class that is used to create a pixi event, and connect it to a canvas element, with on().
12
+ * This class should be extended and the fn method should be overridden.
13
+ * You must use the eventDecorator to register the event in the game.
14
+ * @example
15
+ * ```typescript
16
+ * \@eventDecorator() // this is equivalent to eventDecorator("EventTest")
17
+ * export class EventTest extends CanvasEvent<CanvasSprite> {
18
+ * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void {
19
+ * if (event === 'pointerdown') {
20
+ * sprite.scale.x *= 1.25;
21
+ * sprite.scale.y *= 1.25;
22
+ * }
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ declare class CanvasEvent<C> {
28
+ fn(_event: CanvasEventNamesType, _element: C): void;
29
+ }
30
+
31
+ /**
32
+ * StoredClassModel is a abstract class that contains the methods to store a class in the game.
33
+ * I suggest you extend this class to create your own stored class.
34
+ * @example
35
+ * ```typescript
36
+ * export class CharacterModelBase extends StoredClassModel implements ICharacterModelBase {
37
+ * constructor(id: string, props: ICharacterModelBase) {
38
+ * super(id)
39
+ * this.defaultName = props.name
40
+ * this.defaultSurname = props.surname
41
+ * }
42
+ * private defaultName: string = ""
43
+ * get name(): string {
44
+ * return this.getStorageProperty<string>("name") || this.defaultName
45
+ * }
46
+ * set name(value: string) {
47
+ * this.updateStorageProperty<string>("name", value)
48
+ * }
49
+ * private defaultSurname?: string
50
+ * get surname(): string | undefined {
51
+ * return this.getStorageProperty<string>("surname") || this.defaultSurname
52
+ * }
53
+ * set surname(value: string | undefined) {
54
+ * this.updateStorageProperty<string>("surname", value)
55
+ * }
56
+ * }
57
+ * ```
58
+ */
59
+ declare abstract class StoredClassModel {
60
+ id: string;
61
+ constructor(id: string);
62
+ private get nameClass();
63
+ updateStorageProperty<T>(key: string, value: T | undefined): void;
64
+ getStorageProperty<T>(key: string): T | undefined;
65
+ }
66
+
67
+ interface ICharacterModelBase {
68
+ name: string;
69
+ surname?: string;
70
+ age?: number;
71
+ icon?: string;
72
+ color?: string;
73
+ }
74
+ /**
75
+ * CharacterModelBase is a class that is used to create a character model.
76
+ * I suggest you extend this class to create your own character models.
77
+ * You must use the saveCharacter function to save the character in the game.
78
+ * @example
79
+ * ```typescript
80
+ * export const liam = new CharacterModelBase('liam', {
81
+ * name: 'Liam',
82
+ * surname: 'Smith',
83
+ * age: 25,
84
+ * icon: "https://pixijs.com/assets/eggHead.png",
85
+ * color: "#9e2e12"
86
+ * });
87
+ * export const alice = new CharacterModelBase('alice', {
88
+ * name: 'Alice',
89
+ * surname: 'Smith',
90
+ * age: 25,
91
+ * icon: "https://pixijs.com/assets/eggHead.png",
92
+ * color: "#9e2e12"
93
+ * });
94
+ * saveCharacter([liam, alice]);
95
+ * ```
96
+ */
97
+ declare class CharacterModelBase extends StoredClassModel implements ICharacterModelBase {
98
+ constructor(id: string, props: ICharacterModelBase);
99
+ private defaultName;
100
+ get name(): string;
101
+ set name(value: string);
102
+ private defaultSurname?;
103
+ get surname(): string | undefined;
104
+ set surname(value: string | undefined);
105
+ private defaultAge?;
106
+ get age(): number | undefined;
107
+ set age(value: number | undefined);
108
+ private _icon?;
109
+ get icon(): string | undefined;
110
+ private _color?;
111
+ get color(): string | undefined;
112
+ }
113
+
114
+ /**
115
+ * Enumeration of label modes that occurred during the progression of the steps.
116
+ */
117
+ declare enum LabelRunModeEnum {
118
+ OpenByCall = "openbycall",
119
+ OpenByJump = "openbyjump"
120
+ }
121
+
122
+ /**
123
+ * is a string containing the name of the label.
124
+ * It is used to GameStepManager.registeredLabels to get the label class.
125
+ */
126
+ type LabelIdType = string;
127
+
128
+ /**
129
+ * StepHistoryData is a string that will be stored in the history of the game.
130
+ * It is a function converted to string.
131
+ * if the corresponding function of the step has been changed then StepHistoryData is not equal.
132
+ */
133
+ type StepHistoryDataType = string;
134
+
135
+ /**
136
+ * StepLabel is a function that will be executed as the game continues.
137
+ */
138
+ type StepLabelType = (() => void | Promise<void>);
139
+
140
+ /**
141
+ * Label is a class that contains a list of steps, which will be performed as the game continues.
142
+ * You must use the labelDecorator to register the label in the game.
143
+ * For Ren'py this is the equivalent of a label.
144
+ * @example
145
+ * ```typescript
146
+ * \@labelDecorator() // this is equivalent to labelDecorator("StartLabel")
147
+ * export class StartLabel extends Label {
148
+ * override get steps(): StepLabelType[] {
149
+ * return [
150
+ * () => {
151
+ * GameWindowManager.clear()
152
+ * setDialogue({ character: liam, text: "Which test do you want to perform?" })
153
+ * setChoiceMenuOptions([
154
+ * new ChoiceMenuOptionLabel("Events Test", EventsTestLabel),
155
+ * new ChoiceMenuOptionLabel("Show Image Test", ShowImageTest),
156
+ * ])
157
+ * },
158
+ * () => GameStepManager.jumpLabel(StartLabel),
159
+ * ]
160
+ * }
161
+ * }
162
+ * GameStepManager.callLabel(StartLabel)
163
+ * ```
164
+ */
165
+ declare class Label {
166
+ /**
167
+ * Get the steps of the label.
168
+ * This class should be extended and the steps method should be overridden.
169
+ * Every time you update this list will also be updated when the other game versions load.
170
+ */
171
+ get steps(): StepLabelType[];
172
+ /**
173
+ * Get the corresponding steps number
174
+ * @param externalSteps
175
+ * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1
176
+ */
177
+ getCorrespondingStepsNumber(externalSteps: StepHistoryDataType[] | StepLabelType[]): number;
178
+ }
179
+
180
+ /**
181
+ * ChoiceMenuOptionLabel is a class that contains a Label and a text that will be displayed in the menu.
182
+ * @example
183
+ * ```typescript
184
+ * new ChoiceMenuOptionLabel("Events Test", EventsTestLabel)
185
+ * ```
186
+ */
187
+ declare class ChoiceMenuOptionLabel {
188
+ /**
189
+ * Text to be displayed in the menu
190
+ */
191
+ text: string;
192
+ /**
193
+ * Label to be opened when the option is selected
194
+ */
195
+ label: typeof Label;
196
+ /**
197
+ * Type of the label to be opened
198
+ */
199
+ type: LabelRunModeEnum;
200
+ /**
201
+ * @param text Text to be displayed in the menu
202
+ * @param label Label to be opened when the option is selected
203
+ * @param type Type of the label to be opened
204
+ */
205
+ constructor(text: string, label: typeof Label, type?: LabelRunModeEnum);
206
+ }
207
+ interface IStoratedChoiceMenuOptionLabel {
208
+ text: string;
209
+ label: LabelIdType;
210
+ type: LabelRunModeEnum;
211
+ }
212
+
213
+ /**
214
+ * Base class for all dialogue models. I suggest you extend this class to create your own dialogue models.
215
+ */
216
+ declare class DialogueModelBase {
217
+ constructor(text: string, characterId: string | undefined);
218
+ /**
219
+ * The text of the dialogue.
220
+ */
221
+ text: string;
222
+ /**
223
+ * The id of the character that is speaking.
224
+ */
225
+ characterId?: string;
226
+ }
227
+
228
+ /**
229
+ * Interface for the canvas base memory
230
+ */
231
+ interface ICanvasBaseMemory {
232
+ className: string;
233
+ }
234
+
235
+ /**
236
+ * Interface for the canvas container memory
237
+ */
238
+ interface ICanvasContainerMemory extends ContainerOptions, ICanvasBaseMemory {
239
+ elements: ICanvasBaseMemory[];
240
+ }
241
+
242
+ type EventIdType = string;
243
+
244
+ /**
245
+ * Interface for texture memory
246
+ */
247
+ interface ITextureMemory {
248
+ image: string;
249
+ }
250
+
251
+ interface ICanvasSpriteBaseMemory extends SpriteOptions, ICanvasBaseMemory {
252
+ textureImage: ITextureMemory;
253
+ onEvents: {
254
+ [name: CanvasEventNamesType]: EventIdType;
255
+ };
256
+ }
257
+ /**
258
+ * Interface for the canvas sprite memory
259
+ */
260
+ interface ICanvasSpriteMemory extends ICanvasSpriteBaseMemory {
261
+ className: "CanvasSprite";
262
+ }
263
+
264
+ /**
265
+ * The memory of the image. It uses for save the state of the image.
266
+ */
267
+ interface ICanvasImageMemory extends ICanvasSpriteBaseMemory {
268
+ className: "CanvasImage";
269
+ }
270
+
271
+ /**
272
+ * Interface for the canvas text memory
273
+ */
274
+ interface ICanvasTextMemory extends TextOptions, ICanvasBaseMemory {
275
+ className: "CanvasText";
276
+ onEvents: {
277
+ [name: CanvasEventNamesType]: EventIdType;
278
+ };
279
+ }
280
+
281
+ /**
282
+ * This class is used to create a canvas element to add into a Pixi Application.
283
+ * You can use GameWindowManager.addCanvasElement() to add this element into the application.
284
+ * This class should be implemented and the memory method should be overridden.
285
+ * You must use the canvasElementDecorator to register the canvas in the game.
286
+ * In Ren'Py is a displayable.
287
+ * @example
288
+ * ```typescript
289
+ * \@canvasElementDecorator() // this is equivalent to canvasElementDecorator("CanvasExample")
290
+ * export class CanvasExample extends Container implements CanvasBase<ICanvasExampleMemory> {
291
+ * get memory(): ICanvasExampleMemory {
292
+ * return {
293
+ * className: "CanvasExample",
294
+ * // ... other properties
295
+ * }
296
+ * }
297
+ * set memory(value: ICanvasExampleMemory) {
298
+ * // ... set other properties
299
+ * }
300
+ * }
301
+ * ```
302
+ */
303
+ declare class CanvasBase<T2 extends ICanvasBaseMemory> extends Container {
304
+ /**
305
+ * This method return the memory of the canvas element.
306
+ */
307
+ get memory(): T2;
308
+ /**
309
+ * This method set the memory of the canvas element.
310
+ */
311
+ set memory(_value: T2);
312
+ }
313
+
314
+ /**
315
+ * This class is a extension of the [PIXI.Container class](https://pixijs.com/8.x/examples/basic/container), it has the same properties and methods,
316
+ * but it has the ability to be saved and loaded by the Pixi'VN library.
317
+ * @example
318
+ * ```typescript
319
+ * const container = new CanvasContainer();
320
+ * GameWindowManager.addCanvasElement(container);
321
+ * const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
322
+ * for (let i = 0; i < 25; i++)
323
+ * {
324
+ * const bunny = new CanvasSprite(texture);
325
+ * bunny.x = (i % 5) * 40;
326
+ * bunny.y = Math.floor(i / 5) * 40;
327
+ * container.addChild(bunny);
328
+ * }
329
+ * ```
330
+ */
331
+ declare class CanvasContainer extends Container implements CanvasBase<ICanvasContainerMemory> {
332
+ get memory(): ICanvasContainerMemory;
333
+ set memory(value: ICanvasContainerMemory);
334
+ }
335
+
336
+ /**
337
+ * This class is a extension of the [PIXI.Sprite class](https://pixijs.com/8.x/examples/sprite/basic), it has the same properties and methods,
338
+ * but it has the ability to be saved and loaded by the Pixi'VN library.
339
+ * @example
340
+ * ```typescript
341
+ * const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
342
+ * const sprite = CanvasSprite.from(texture);
343
+ *
344
+ * sprite.anchor.set(0.5);
345
+ * sprite.x = GameWindowManager.screen.width / 2;
346
+ * sprite.y = GameWindowManager.screen.height / 2;
347
+ *
348
+ * sprite.eventMode = 'static';
349
+ * sprite.cursor = 'pointer';
350
+ * sprite.onEvent('pointerdown', EventTest);
351
+ *
352
+ * GameWindowManager.addCanvasElement("bunny", sprite);
353
+ * ```
354
+ */
355
+ declare class CanvasSprite<Memory extends SpriteOptions & ICanvasBaseMemory = ICanvasSpriteMemory> extends Sprite implements CanvasBase<Memory | ICanvasSpriteMemory> {
356
+ get memory(): Memory | ICanvasSpriteMemory;
357
+ set memory(value: ICanvasSpriteMemory);
358
+ private _onEvents;
359
+ get onEvents(): {
360
+ [name: string]: string;
361
+ [name: symbol]: string;
362
+ };
363
+ /**
364
+ * is same function as on(), but it keeps in memory the children.
365
+ * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
366
+ * @param eventClass The class that extends CanvasEvent.
367
+ * @returns
368
+ * @example
369
+ * ```typescript
370
+ * \@eventDecorator()
371
+ * export class EventTest extends CanvasEvent<CanvasSprite> {
372
+ * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void {
373
+ * if (event === 'pointerdown') {
374
+ * sprite.scale.x *= 1.25;
375
+ * sprite.scale.y *= 1.25;
376
+ * }
377
+ * }
378
+ * }
379
+ * ```
380
+ *
381
+ * ```typescript
382
+ * let sprite = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
383
+ * await sprite.load()
384
+ *
385
+ * sprite.eventMode = 'static';
386
+ * sprite.cursor = 'pointer';
387
+ * sprite.onEvent('pointerdown', EventTest);
388
+ *
389
+ * GameWindowManager.addCanvasElement("bunny", sprite);
390
+ * ```
391
+ */
392
+ onEvent<T extends CanvasEventNamesType, T2 extends typeof CanvasEvent<typeof this>>(event: T, eventClass: T2): this;
393
+ /**
394
+ * on() does not keep in memory the event class, use onEvent() instead
395
+ * @deprecated
396
+ * @private
397
+ * @param event
398
+ * @param fn
399
+ * @param context
400
+ */
401
+ on<T extends keyof ContainerEvents | keyof {
402
+ [K: symbol]: any;
403
+ [K: {} & string]: any;
404
+ }>(event: T, fn: (...args: EventEmitter.ArgumentMap<ContainerEvents & {
405
+ [K: symbol]: any;
406
+ [K: {} & string]: any;
407
+ }>[Extract<T, keyof ContainerEvents | keyof {
408
+ [K: symbol]: any;
409
+ [K: {} & string]: any;
410
+ }>]) => void, context?: any): this;
411
+ static from(source: Texture | TextureSourceLike, skipCache?: boolean): CanvasSprite<any>;
412
+ }
413
+
414
+ /**
415
+ * This class is a extension of the CanvasSprite class, it has the same properties and methods,
416
+ * but it has some features that make texture management easier.
417
+ * You need to use CanvasImage.load() to show the image in the canvas.
418
+ * This class is used for functions like addImage, showCanvasImages and showImageWithDissolveTransition.
419
+ * @example
420
+ * ```typescript
421
+ * let alien = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
422
+ * alien.anchor.set(0.5);
423
+ * alien.x = 100
424
+ * alien.y = 100
425
+ * await alien.load()
426
+ * ```
427
+ */
428
+ declare class CanvasImage extends CanvasSprite<ICanvasImageMemory> {
429
+ get memory(): ICanvasImageMemory;
430
+ set memory(memory: ICanvasImageMemory);
431
+ imageLink: string;
432
+ static from(source: Texture | TextureSourceLike, skipCache?: boolean): CanvasImage;
433
+ /**
434
+ * Load the image in the canvas.
435
+ * @returns a promise that resolves when the image is loaded.
436
+ */
437
+ load(): Promise<void>;
438
+ }
439
+
440
+ /**
441
+ * This class is a extension of the [PIXI.Text class](https://pixijs.com/8.x/examples/text/pixi-text), it has the same properties and methods,
442
+ * but it has the ability to be saved and loaded by the Pixi'VN library.
443
+ * @example
444
+ * ```typescript
445
+ * const text = new CanvasText();
446
+ * text.text = "Hello World"
447
+ * GameWindowManager.addCanvasElement("text", text);
448
+ * ```
449
+ */
450
+ declare class CanvasText extends Text implements CanvasBase<ICanvasTextMemory> {
451
+ get memory(): ICanvasTextMemory;
452
+ set memory(value: ICanvasTextMemory);
453
+ private _onEvents;
454
+ get onEvents(): {
455
+ [name: string]: string;
456
+ [name: symbol]: string;
457
+ };
458
+ /**
459
+ * is same function as on(), but it keeps in memory the children.
460
+ * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
461
+ * @param eventClass The class that extends CanvasEvent.
462
+ * @returns
463
+ * @example
464
+ * ```typescript
465
+ * \@eventDecorator()
466
+ * export class EventTest extends CanvasEvent<CanvasText> {
467
+ * override fn(event: CanvasEventNamesType, text: CanvasText): void {
468
+ * if (event === 'pointerdown') {
469
+ * text.scale.x *= 1.25;
470
+ * text.scale.y *= 1.25;
471
+ * }
472
+ * }
473
+ * }
474
+ * ```
475
+ *
476
+ * ```typescript
477
+ * const text = new CanvasText();
478
+ * text.text = "Hello World"
479
+ *
480
+ * text.eventMode = 'static';
481
+ * text.cursor = 'pointer';
482
+ * text.onEvent('pointerdown', EventTest);
483
+ *
484
+ * GameWindowManager.addCanvasElement("text", text);
485
+ * ```
486
+ */
487
+ onEvent<T extends CanvasEventNamesType, T2 extends typeof CanvasEvent<typeof this>>(event: T, eventClass: T2): this;
488
+ /**
489
+ * on() does not keep in memory the event class, use onEvent() instead
490
+ * @deprecated
491
+ * @private
492
+ * @param event
493
+ * @param fn
494
+ * @param context
495
+ */
496
+ on<T extends keyof ContainerEvents | keyof {
497
+ [K: symbol]: any;
498
+ [K: {} & string]: any;
499
+ }>(event: T, fn: (...args: EventEmitter.ArgumentMap<ContainerEvents & {
500
+ [K: symbol]: any;
501
+ [K: {} & string]: any;
502
+ }>[Extract<T, keyof ContainerEvents | keyof {
503
+ [K: symbol]: any;
504
+ [K: {} & string]: any;
505
+ }>]) => void, context?: any): this;
506
+ }
507
+
508
+ interface ITicker<TArgs extends TickerArgsType> {
509
+ /**
510
+ * Arguments to pass to the ticker
511
+ */
512
+ args: TArgs;
513
+ /**
514
+ * Duration in milliseconds
515
+ */
516
+ duration?: number;
517
+ /**
518
+ * Priority of the ticker
519
+ */
520
+ priority?: UPDATE_PRIORITY;
521
+ }
522
+
523
+ /**
524
+ * StorageElementType are all the types that can be stored in the storage
525
+ */
526
+ type StorageElementType = string | number | boolean | object | undefined | null;
527
+
528
+ type TickerArgsType = {
529
+ [id: string]: StorageElementType;
530
+ };
531
+ /**
532
+ * A class is used to create a ticker element to add into a Pixi Application.
533
+ * You can use GameWindowManager.addTicker() to add this element into the application.
534
+ * This class should be extended and the fn method should be overridden.
535
+ * You must use the tickerDecorator to register the ticker in the game.
536
+ * In Ren'Py is a transform.
537
+ * @example
538
+ * ```typescript
539
+ * \@tickerDecorator() // this is equivalent to tickerDecorator("TickerRotate")
540
+ * export class TickerRotate extends TickerBase<{ speed?: number }> {
541
+ * override fn(
542
+ * t: Ticker,
543
+ * args: {
544
+ * speed?: number,
545
+ * },
546
+ * tags: string[]
547
+ * ): void {
548
+ * let speed = args.speed === undefined ? 0.1 : args.speed
549
+ * tags.forEach((tag) => {
550
+ * let element = GameWindowManager.getCanvasElement(tag)
551
+ * if (element && element instanceof Container) {
552
+ * if (clockwise)
553
+ * element.rotation += speed * t.deltaTime
554
+ * else
555
+ * element.rotation -= speed * t.deltaTime
556
+ * }
557
+ * })
558
+ * }
559
+ * }
560
+ * ```
561
+ */
562
+ declare class TickerBase<TArgs extends TickerArgsType> implements ITicker<TArgs> {
563
+ constructor(args: TArgs, duration?: number, priority?: UPDATE_PRIORITY);
564
+ args: TArgs;
565
+ duration?: number;
566
+ priority?: UPDATE_PRIORITY;
567
+ /**
568
+ * The method that will be called every frame.
569
+ * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.
570
+ * @param t The ticker that is calling this method
571
+ * @param args The arguments that you passed when you added the ticker
572
+ * @param tags The tags of the canvas elements that are connected to this ticker
573
+ */
574
+ fn(_t: Ticker, _args: TArgs, _tags: string | string[]): void;
575
+ }
576
+
577
+ /**
578
+ * A ticker that fades the alpha of the canvas element of the canvas.
579
+ * @param args The arguments that are passed to the ticker
580
+ * - speed: The speed of the fade
581
+ * - type: The type of the fade, default is "hide"
582
+ * - limit: The limit of the fade, default is 0 for hide and 1 for show
583
+ * - tagToRemoveAfter?: The tag to remove after the fade is done
584
+ * - startOnlyIfHaveTexture?: If true, the fade only starts if the canvas element have a texture
585
+ * @param duration The duration of the ticker
586
+ * @param priority The priority of the ticker
587
+ * @example
588
+ * ```typescript
589
+ * let bunny = addImage("bunny1", "https://pixijs.com/assets/eggHead.png")
590
+ * await bunny.load()
591
+ * GameWindowManager.addCanvasElement("bunny", bunny);
592
+ * // ...
593
+ * const ticker = new TickerFadeAlpha({
594
+ * speed: 0.01,
595
+ * type: "hide",
596
+ * }),
597
+ * GameWindowManager.addTicker("bunny", ticker)
598
+ * ```
599
+ */
600
+ declare class TickerFadeAlpha extends TickerBase<{
601
+ speed: number;
602
+ type?: "hide" | "show";
603
+ limit?: number;
604
+ tagToRemoveAfter?: string[] | string;
605
+ startOnlyIfHaveTexture?: boolean;
606
+ }> {
607
+ /**
608
+ * The method that will be called every frame to fade the alpha of the canvas element of the canvas.
609
+ * @param delta The delta time
610
+ * @param args The arguments that are passed to the ticker
611
+ * @param tags The tags of the canvas element that are connected to this ticker
612
+ */
613
+ fn(t: Ticker, args: {
614
+ speed?: number;
615
+ type?: "hide" | "show";
616
+ limit?: number;
617
+ tagToRemoveAfter?: string[] | string;
618
+ startOnlyIfHaveTexture?: boolean;
619
+ }, tags: string[]): void;
620
+ }
621
+
622
+ type TickerProgrationType = ITickerProgrationLinear | ITickerProgrationExponential;
623
+ interface ITickerProgrationLinear {
624
+ amt: number;
625
+ limit?: number;
626
+ type: "linear";
627
+ }
628
+ interface ITickerProgrationExponential {
629
+ percentage: number;
630
+ limit?: number;
631
+ type: "exponential";
632
+ }
633
+
634
+ /**
635
+ * A ticker that rotates the canvas element of the canvas.
636
+ * @param args The arguments that are passed to the ticker
637
+ * - speed: The speed of the rotation, default is 0.1
638
+ * - clockwise: The direction of the rotation, default is true
639
+ * - speedProgression: The progression of the speed
640
+ * - startOnlyIfHaveTexture?: If true, the rotation only starts if the canvas element have a texture
641
+ * @param duration The duration of the ticker
642
+ * @param priority The priority of the ticker
643
+ * @example
644
+ * ```typescript
645
+ * let alien = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
646
+ * GameWindowManager.addCanvasElement("alien", alien);
647
+ * const ticker = new TickerRotate({
648
+ * speed: 0.1,
649
+ * clockwise: true,
650
+ * }),
651
+ * GameWindowManager.addTicker("alien", ticker)
652
+ */
653
+ declare class TickerRotate extends TickerBase<{
654
+ speed?: number;
655
+ clockwise?: boolean;
656
+ speedProgression?: TickerProgrationType;
657
+ startOnlyIfHaveTexture?: boolean;
658
+ }> {
659
+ /**
660
+ * The method that will be called every frame to rotate the canvas element of the canvas.
661
+ * @param delta The delta time
662
+ * @param args The arguments that are passed to the ticker
663
+ * @param tags The tags of the canvas element that are connected to this ticker
664
+ */
665
+ fn(t: Ticker, args: {
666
+ speed?: number;
667
+ clockwise?: boolean;
668
+ speedProgression?: TickerProgrationType;
669
+ startOnlyIfHaveTexture?: boolean;
670
+ }, tags: string[]): void;
671
+ }
672
+
673
+ type CanvasElementTagType = string;
674
+
675
+ /**
676
+ * Is a decorator that register a canvas element in the game.
677
+ * @param name Name of the canvas element, by default it will use the class name. If the name is already registered, it will show a warning
678
+ * @returns
679
+ */
680
+ declare function canvasElementDecorator(name?: CanvasElementTagType): (target: typeof CanvasBase<any>) => void;
681
+
682
+ /**
683
+ * Is a function that saves the character. If the character already exists, it will be overwritten.
684
+ * @param character is the character to save
685
+ * @returns
686
+ * @example
687
+ * ```typescript
688
+ * export const liam = new CharacterModelBase('liam', { name: 'Liam'});
689
+ * export const alice = new CharacterModelBase('alice', { name: 'Alice'});
690
+ * saveCharacter([liam, alice]);
691
+ * ```
692
+ */
693
+ declare function saveCharacter<T extends CharacterModelBase = CharacterModelBase>(character: T | T[]): void;
694
+ /**
695
+ * is a function that returns the character by the id
696
+ * @param id is the id of the character
697
+ * @returns the character
698
+ * @example
699
+ * ```typescript
700
+ * const liam = getCharacterById('liam');
701
+ * ```
702
+ */
703
+ declare function getCharacterById<T extends CharacterModelBase>(id: string): T | undefined;
704
+
705
+ /**
706
+ * Is a decorator that register a event in the game.
707
+ * Is a required decorator for use the event in the game.
708
+ * Thanks to this decoration the game has the possibility of updating the events to the latest modification and saving the game.
709
+ * @param name is th identifier of the event, by default is the name of the class
710
+ * @returns
711
+ */
712
+ declare function eventDecorator(name?: EventIdType): (target: typeof CanvasEvent<any>) => void;
713
+
714
+ /**
715
+ * Is a decorator that register a label in the game.
716
+ * Is a required decorator for use the label in the game.
717
+ * Thanks to this decoration the game has the possibility of updating the labels to the latest modification and saving the game.
718
+ * @param name is th identifier of the label, by default is the name of the class
719
+ * @returns
720
+ */
721
+ declare function labelDecorator(name?: LabelIdType): (target: typeof Label) => void;
722
+
723
+ /**
724
+ * is a string that represents a ticker id.
725
+ * It is used to GameWindowManager.tickers to get the ticker class.
726
+ */
727
+ type TickerIdType = string;
728
+
729
+ /**
730
+ * Is a decorator that register a ticker in the game.
731
+ * Is a required decorator for use the ticker in the game.
732
+ * Thanks to this decoration the game has the possibility of updating the tickers to the latest modification and saving the game.
733
+ * @param name is th identifier of the label, by default is the name of the class
734
+ * @returns
735
+ */
736
+ declare function tickerDecorator(name?: TickerIdType): (target: typeof TickerBase<any>) => void;
737
+
738
+ /**
739
+ * IClassWithArgsHistory is a class that contains the name of a class and the arguments that were used to create it.
740
+ */
741
+ interface IClassWithArgsHistory<TArgs extends TickerArgsType> {
742
+ fn: TickerCallback<any>;
743
+ className: TickerIdType;
744
+ args: TArgs;
745
+ canvasElementTags: string[];
746
+ priority?: UPDATE_PRIORITY;
747
+ duration?: number;
748
+ }
749
+ interface IClassWithArgsHistoryForExport<TArgs extends TickerArgsType> {
750
+ className: TickerIdType;
751
+ args: TArgs;
752
+ canvasElementTags: string[];
753
+ priority?: UPDATE_PRIORITY;
754
+ duration?: number;
755
+ }
756
+
757
+ interface IDialogueHistory<T extends DialogueModelBase = DialogueModelBase> {
758
+ /**
759
+ * Dialogue to be shown in the game
760
+ */
761
+ dialoge?: T;
762
+ /**
763
+ * List of choices asked of the player
764
+ */
765
+ choices?: IStoratedChoiceMenuOptionLabel[];
766
+ /**
767
+ * Choice made by the player
768
+ */
769
+ choiceMade?: IStoratedChoiceMenuOptionLabel;
770
+ /**
771
+ * The index of the step in the history.
772
+ */
773
+ stepIndex: number;
774
+ }
775
+
776
+ /**
777
+ * Interface exported canvas
778
+ */
779
+ interface ExportedCanvas {
780
+ currentTickers: IClassWithArgsHistoryForExport<any>[];
781
+ currentElements: {
782
+ [tag: string]: ICanvasBaseMemory;
783
+ };
784
+ childrenTagsOrder: string[];
785
+ }
786
+
787
+ /**
788
+ * Interface exported storage data
789
+ */
790
+ interface ExportedStorage {
791
+ [key: string]: StorageElementType;
792
+ }
793
+
794
+ interface IOpenedLabel {
795
+ label: LabelIdType;
796
+ currentStepIndex: number;
797
+ }
798
+
799
+ /**
800
+ * IHistoryStep is a interface that contains the information of a step in the history.
801
+ */
802
+ interface IHistoryStepData {
803
+ /**
804
+ * The browser path that occurred during the progression of the steps.
805
+ */
806
+ path: string;
807
+ /**
808
+ * The storage that occurred during the progression of the steps.
809
+ */
810
+ storage: ExportedStorage;
811
+ /**
812
+ * The index of the label that occurred during the progression of the steps.
813
+ */
814
+ labelIndex: number;
815
+ /**
816
+ * The canvas that occurred during the progression of the steps.
817
+ */
818
+ canvas: ExportedCanvas;
819
+ /**
820
+ * The opened labels that occurred during the progression of the steps.
821
+ */
822
+ openedLabels: IOpenedLabel[];
823
+ }
824
+ interface IHistoryStep<T extends DialogueModelBase = DialogueModelBase> {
825
+ /**
826
+ * The difference between the previous step and the current step.
827
+ */
828
+ diff: deepDiff.Diff<IHistoryStepData, IHistoryStepData>[];
829
+ /**
830
+ * The label id of the current step.
831
+ */
832
+ currentLabel?: LabelIdType;
833
+ /**
834
+ * The sha1 of the step function.
835
+ */
836
+ stepSha1: StepHistoryDataType;
837
+ /**
838
+ * The index of the step in the history.
839
+ */
840
+ index: number;
841
+ /**
842
+ * Dialogue to be shown in the game
843
+ */
844
+ dialoge?: T;
845
+ /**
846
+ * List of choices asked of the player
847
+ */
848
+ choices?: IStoratedChoiceMenuOptionLabel[];
849
+ }
850
+
851
+ /**
852
+ * Interface exported step data
853
+ */
854
+ interface ExportedStep {
855
+ stepsHistory: IHistoryStep[];
856
+ openedLabels: IOpenedLabel[];
857
+ lastStepIndex: number;
858
+ originalStepData: IHistoryStepData | undefined;
859
+ }
860
+
861
+ interface ISaveData {
862
+ version: string;
863
+ stepData: ExportedStep;
864
+ storageData: ExportedStorage;
865
+ canvasData: ExportedCanvas;
866
+ path: string;
867
+ }
868
+
869
+ declare const PauseValueType = "Pause";
870
+ type PauseType = {
871
+ type: typeof PauseValueType;
872
+ duration: number;
873
+ };
874
+ declare function Pause(duration: number): PauseType;
875
+
876
+ type RepeatType = "Repeat";
877
+ declare const Repeat: RepeatType;
878
+
879
+ interface ITickersStep<TArgs extends TickerArgsType> extends ITicker<TArgs> {
880
+ /**
881
+ * Ticker class name
882
+ */
883
+ ticker: string;
884
+ /**
885
+ * Duration in milliseconds
886
+ */
887
+ duration: number;
888
+ }
889
+ /**
890
+ * The steps of the tickers
891
+ */
892
+ interface ITickersSteps {
893
+ /**
894
+ * The step number
895
+ */
896
+ currentStepNumber: number;
897
+ /**
898
+ * The steps of the tickers
899
+ */
900
+ steps: (ITickersStep<any> | RepeatType | PauseType)[];
901
+ }
902
+
903
+ /**
904
+ * Munu is a type that contains a list of Label that a player can choose from.
905
+ * For Ren'py this is the equivalent of a menu.
906
+ */
907
+ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
908
+
909
+ /**
910
+ * Set the dialogue to be shown in the game
911
+ * @param text Text of the dialogue
912
+ * @example
913
+ * ```typescript
914
+ * setDialogue("Hello World")
915
+ * setDialogue({
916
+ * character: "characterId",
917
+ * text: "Hello World"
918
+ * })
919
+ * ```
920
+ */
921
+ declare function setDialogue<T extends CharacterModelBase = CharacterModelBase>(props: {
922
+ character: string | T;
923
+ text: string;
924
+ } | string): void;
925
+ /**
926
+ * Get the dialogue to be shown in the game
927
+ * @returns Dialogue to be shown in the game
928
+ */
929
+ declare function getDialogue<T extends DialogueModelBase = DialogueModelBase>(): T | undefined;
930
+ /**
931
+ * Clear the dialogue to be shown in the game
932
+ */
933
+ declare function clearDialogue(): void;
934
+ /**
935
+ * Set the options to be shown in the game
936
+ * @param options Options to be shown in the game
937
+ * @example
938
+ * ```typescript
939
+ * setChoiceMenuOptions([
940
+ * new ChoiceMenuOptionLabel("Events Test", EventsTestLabel),
941
+ * new ChoiceMenuOptionLabel("Show Image Test", ShowImageTest),
942
+ * new ChoiceMenuOptionLabel("Ticker Test", TickerTestLabel),
943
+ * new ChoiceMenuOptionLabel("Tinting Test", TintingTestLabel),
944
+ * new ChoiceMenuOptionLabel("Base Canvas Element Test Label", BaseCanvasElementTestLabel)
945
+ * ])
946
+ * ```
947
+ */
948
+ declare function setChoiceMenuOptions(options: ChoiceMenuOptionsType): void;
949
+ /**
950
+ * Get the options to be shown in the game
951
+ * @returns Options to be shown in the game
952
+ */
953
+ declare function getChoiceMenuOptions(): ChoiceMenuOptionsType | undefined;
954
+ /**
955
+ * Clear the options to be shown in the game
956
+ */
957
+ declare function clearChoiceMenuOptions(): void;
958
+ /**
959
+ * Get the history of the dialogues
960
+ * @returns the history of the dialogues
961
+ */
962
+ declare function getDialogueHistory<T extends DialogueModelBase = DialogueModelBase>(): IDialogueHistory<T>[];
963
+
964
+ /**
965
+ * Clear all game data. This function is used to reset the game.
966
+ */
967
+ declare function clearAllGameDatas(): void;
968
+
969
+ /**
970
+ * Add a image in the canvas.
971
+ * Is the same that showImage, but the image is not shown.
972
+ * If you want to show the image, then you need to use the function CanvasImage.load().
973
+ * @param tag is the unique tag of the image. You can use this tag to refer to this image
974
+ * @param imageUrl is the url of the image.
975
+ * @returns the container of the image.
976
+ * @example
977
+ * ```typescript
978
+ * let alien = addImage("bunny1", "https://pixijs.com/assets/eggHead.png")
979
+ * await alien.load()
980
+ * ```
981
+ */
982
+ declare function addImage(tag: string, imageUrl: string): CanvasImage;
983
+ /**
984
+ * Show a list of images in the canvas, at the same time.
985
+ * @param canvasImages is a list of images to show.
986
+ * @returns the list of images.
987
+ */
988
+ declare function showCanvasImages(canvasImages: CanvasImage[] | CanvasImage): Promise<CanvasImage[]>;
989
+ /**
990
+ * Remove a image from the canvas.
991
+ * @param tag is the unique tag of the image. You can use this tag to refer to this image
992
+ */
993
+ declare function removeCanvasElement(tag: string | string[]): void;
994
+ /**
995
+ * Show a image in the canvas with a disolve effect.
996
+ * Disolve effect is a effect that the image is shown with a fade in.
997
+ * If exist a image with the same tag, then the image is replaced. And the first image is removed after the effect is done.
998
+ * @param tag The unique tag of the image. You can use this tag to refer to this image
999
+ * @param imageUrl The url of the image.
1000
+ * @param args The arguments of the effect
1001
+ * @param duration The duration of the effect
1002
+ * @param priority The priority of the effect
1003
+ * @returns The sprite of the image.
1004
+ */
1005
+ declare function showImageWithDissolveTransition(tag: string, imageUrl: string, speed: number, priority?: UPDATE_PRIORITY): Promise<void>;
1006
+
1007
+ /**
1008
+ * Get the save data
1009
+ * @returns The save data
1010
+ */
1011
+ declare function getSaveData(): ISaveData;
1012
+ /**
1013
+ * Get the save data as a JSON string
1014
+ * @returns The save data as a JSON string
1015
+ * @example
1016
+ * ```typescript
1017
+ * export function saveGame() {
1018
+ * const jsonString = getSaveJson()
1019
+ * const blob = new Blob([jsonString], { type: "application/json" });
1020
+ * const url = URL.createObjectURL(blob);
1021
+ * const a = document.createElement('a');
1022
+ * a.href = url;
1023
+ * a.download = "save.json";
1024
+ * a.click();
1025
+ * }
1026
+ * ```
1027
+ */
1028
+ declare function getSaveJson(): string;
1029
+ /**
1030
+ * Load the save data
1031
+ * @param data The save data
1032
+ * @param navigate The function to navigate to a path
1033
+ */
1034
+ declare function loadSaveData(data: ISaveData, navigate: (path: string) => void): void;
1035
+ /**
1036
+ * Load the save data from a JSON string
1037
+ * @param dataString The save data as a JSON string
1038
+ * @param navigate The function to navigate to a path
1039
+ * @example
1040
+ * ```typescript
1041
+ * export function loadGameSave(navigate: (path: string) => void, afterLoad?: () => void) {
1042
+ * // load the save data from a JSON file
1043
+ * const input = document.createElement('input');
1044
+ * input.type = 'file';
1045
+ * input.accept = 'application/json';
1046
+ * input.onchange = (e) => {
1047
+ * const file = (e.target as HTMLInputElement).files?.[0];
1048
+ * if (file) {
1049
+ * const reader = new FileReader();
1050
+ * reader.onload = (e) => {
1051
+ * const jsonString = e.target?.result as string;
1052
+ * // load the save data from the JSON string
1053
+ * loadSaveJson(jsonString, navigate);
1054
+ * afterLoad && afterLoad();
1055
+ * };
1056
+ * reader.readAsText(file);
1057
+ * }
1058
+ * };
1059
+ * input.click();
1060
+ * }
1061
+ * ```
1062
+ */
1063
+ declare function loadSaveJson(dataString: string, navigate: (path: string) => void): void;
1064
+
1065
+ /**
1066
+ * Get a texture from a url.
1067
+ * @param imageUrl is the url of the image.
1068
+ * @returns the texture of the image, or a text with the error.
1069
+ */
1070
+ declare function getTexture(imageUrl: string): Promise<Texture | void>;
1071
+
1072
+ /**
1073
+ * GameStepManager is a class that manages the steps and labels of the game.
1074
+ */
1075
+ declare class GameStepManager {
1076
+ private constructor();
1077
+ /**
1078
+ * stepHistory is a list of label events and steps that occurred during the progression of the steps.
1079
+ */
1080
+ private static _stepsHistory;
1081
+ static get stepsHistory(): IHistoryStep<DialogueModelBase>[];
1082
+ private static _lastStepIndex;
1083
+ /**
1084
+ * lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
1085
+ */
1086
+ static get lastStepIndex(): number;
1087
+ /**
1088
+ * Increase the last step index that occurred during the progression of the steps.
1089
+ */
1090
+ private static increaseLastStepIndex;
1091
+ private static _openedLabels;
1092
+ static get openedLabels(): IOpenedLabel[];
1093
+ /**
1094
+ * currentLabel is the current label that occurred during the progression of the steps.
1095
+ */
1096
+ private static get currentLabel();
1097
+ /**
1098
+ * is the current step index of the current label that occurred during the progression of the steps.
1099
+ */
1100
+ private static get currentLabelStepIndex();
1101
+ /**
1102
+ * lastHistoryStep is the last history step that occurred during the progression of the steps.
1103
+ */
1104
+ private static get lastHistoryStep();
1105
+ private static _originalStepData;
1106
+ private static get originalStepData();
1107
+ private static set originalStepData(value);
1108
+ /**
1109
+ * Add a label to the history.
1110
+ * @param label The label to add to the history.
1111
+ */
1112
+ private static addStepHistory;
1113
+ /**
1114
+ * Add a label to the history.
1115
+ * @param label The label to add to the history.
1116
+ */
1117
+ private static pushNewLabel;
1118
+ /**
1119
+ * Close the current label and add it to the history.
1120
+ * @returns
1121
+ */
1122
+ static closeCurrentLabel(): void;
1123
+ /**
1124
+ * Close all labels and add them to the history.
1125
+ */
1126
+ static closeAllLabels(): void;
1127
+ /**
1128
+ * Increase the current step index of the current label.
1129
+ */
1130
+ private static increaseCurrentStepIndex;
1131
+ /**
1132
+ * Execute the next step and add it to the history.
1133
+ * @returns
1134
+ * @example
1135
+ * ```typescript
1136
+ * function nextOnClick() {
1137
+ * setLoading(true)
1138
+ * GameStepManager.runNextStep()
1139
+ * .then(() => {
1140
+ * setUpdate((p) => p + 1)
1141
+ * setLoading(false)
1142
+ * })
1143
+ * .catch((e) => {
1144
+ * setLoading(false)
1145
+ * console.error(e)
1146
+ * })
1147
+ * }
1148
+ * ```
1149
+ */
1150
+ static runNextStep(): Promise<void>;
1151
+ /**
1152
+ * Execute the current step and add it to the history.
1153
+ * @returns
1154
+ */
1155
+ private static runCurrentStep;
1156
+ /**
1157
+ * Execute the label and add it to the history.
1158
+ * Is a call function in Ren'Py.
1159
+ * @param label The label to execute.
1160
+ * @returns
1161
+ * @example
1162
+ * ```typescript
1163
+ * GameStepManager.callLabel(StartLabel)
1164
+ * ```
1165
+ */
1166
+ static callLabel(label: typeof Label | Label): Promise<void>;
1167
+ /**
1168
+ * Execute the label, close all labels and add them to the history.
1169
+ * Is a jump function in Ren'Py.
1170
+ * @param label
1171
+ * @returns
1172
+ * @example
1173
+ * ```typescript
1174
+ * GameStepManager.jumpLabel(StartLabel)
1175
+ * ```
1176
+ */
1177
+ static jumpLabel(label: typeof Label | Label): Promise<void>;
1178
+ /**
1179
+ * Go back to the last step and add it to the history.
1180
+ * @param navigate The navigate function.
1181
+ * @param steps The number of steps to go back.
1182
+ * @returns
1183
+ * @example
1184
+ * ```typescript
1185
+ * export function goBack(navigate: (path: string) => void, afterBack?: () => void) {
1186
+ * GameStepManager.goBack(navigate)
1187
+ * afterBack && afterBack()
1188
+ * }
1189
+ * ```
1190
+ */
1191
+ static goBack(navigate: (path: string) => void, steps?: number): void;
1192
+ private static goBackInternal;
1193
+ /**
1194
+ * Add a label to the history.
1195
+ */
1196
+ static clear(): void;
1197
+ /**
1198
+ * Export the history to a JSON string.
1199
+ * @returns The history in a JSON string.
1200
+ */
1201
+ static exportJson(): string;
1202
+ /**
1203
+ * Export the history to an object.
1204
+ * @returns The history in an object.
1205
+ */
1206
+ static export(): ExportedStep;
1207
+ /**
1208
+ * Import the history from a JSON string.
1209
+ * @param dataString The history in a JSON string.
1210
+ */
1211
+ static importJson(dataString: string): void;
1212
+ /**
1213
+ * Import the history from an object.
1214
+ * @param data The history in an object.
1215
+ */
1216
+ static import(data: object): void;
1217
+ }
1218
+
1219
+ declare class GameStorageManager {
1220
+ private static storage;
1221
+ private constructor();
1222
+ static get keysSystem(): {
1223
+ CURRENT_DIALOGUE_MEMORY_KEY: string;
1224
+ LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: string;
1225
+ CURRENT_MENU_OPTIONS_MEMORY_KEY: string;
1226
+ LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: string;
1227
+ CHARACTER_PREKEY: string;
1228
+ };
1229
+ /**
1230
+ * Set a variable in the storage
1231
+ * @param key The key of the variable
1232
+ * @param value The value of the variable. If undefined, the variable will be removed
1233
+ * @returns
1234
+ */
1235
+ static setVariable(key: string, value: StorageElementType): void;
1236
+ /**
1237
+ * Get a variable from the storage
1238
+ * @param key The key of the variable
1239
+ * @returns The value of the variable. If the variable does not exist, it will return undefined
1240
+ */
1241
+ static getVariable<T extends StorageElementType>(key: string): T | undefined;
1242
+ /**
1243
+ * Remove a variable from the storage
1244
+ * @param key The key of the variable
1245
+ * @returns
1246
+ */
1247
+ static removeVariable(key: string): void;
1248
+ /**
1249
+ * Clear the storage and the oidsUsed
1250
+ * @returns
1251
+ */
1252
+ static clear(): void;
1253
+ static exportJson(): string;
1254
+ static export(): ExportedStorage;
1255
+ static importJson(dataString: string): void;
1256
+ static import(data: object): void;
1257
+ }
1258
+
1259
+ /**
1260
+ * This class is responsible for managing the canvas, the tickers, the events, and the window size and the children of the window.
1261
+ */
1262
+ declare class GameWindowManager {
1263
+ private constructor();
1264
+ private static _app;
1265
+ /**
1266
+ * The PIXI Application instance.
1267
+ * It not recommended to use this property directly.
1268
+ */
1269
+ static get app(): Application<pixi_js.Renderer>;
1270
+ private static _isInitialized;
1271
+ /**
1272
+ * If the manager is initialized.
1273
+ */
1274
+ static get isInitialized(): boolean;
1275
+ /**
1276
+ * This is the div that have same size of the canvas.
1277
+ * This is useful to put interface elements.
1278
+ * You can use React or other framework to put elements in this div.
1279
+ */
1280
+ static htmlLayout: HTMLElement;
1281
+ static canvasWidth: number;
1282
+ static canvasHeight: number;
1283
+ static get screen(): pixi_js.Rectangle;
1284
+ /**
1285
+ * Initialize the PIXI Application and the interface div.
1286
+ * This method should be called before any other method.
1287
+ * @param element The html element where I will put the canvas. Example: document.body
1288
+ * @param width The width of the canvas
1289
+ * @param height The height of the canvas
1290
+ * @param options The options of PIXI Application
1291
+ * @example
1292
+ * ```typescript
1293
+ * const body = document.body
1294
+ * if (!body) {
1295
+ * throw new Error('body element not found')
1296
+ * }
1297
+ * await GameWindowManager.initialize(body, 1920, 1080, {
1298
+ * backgroundColor: "#303030"
1299
+ * })
1300
+ * ```
1301
+ */
1302
+ static initialize(element: HTMLElement, width: number, height: number, options?: Partial<ApplicationOptions>): Promise<void>;
1303
+ /**
1304
+ * Add the canvas into a html element.
1305
+ * @param element it is the html element where I will put the canvas. Example: document.body
1306
+ */
1307
+ private static addCanvasIntoElement;
1308
+ /**
1309
+ * Initialize the interface div and add it into a html element.
1310
+ * @param element it is the html element where I will put the interface div. Example: document.getElementById('root')
1311
+ * @example
1312
+ * ```typescript
1313
+ * const root = document.getElementById('root')
1314
+ * if (!root) {
1315
+ * throw new Error('root element not found')
1316
+ * }
1317
+ * GameWindowManager.initializeHTMLLayout(root)
1318
+ * const reactRoot = createRoot(GameWindowManager.htmlLayout)
1319
+ * reactRoot.render(
1320
+ * <App />
1321
+ * )
1322
+ * ```
1323
+ */
1324
+ static initializeHTMLLayout(element: HTMLElement): void;
1325
+ /**
1326
+ * This method returns the scale of the screen.
1327
+ */
1328
+ static get screenScale(): number;
1329
+ /**
1330
+ * This method returns the width of the screen enlarged by the scale.
1331
+ */
1332
+ static get screenWidth(): number;
1333
+ /**
1334
+ * This method returns the height of the screen enlarged by the scale.
1335
+ */
1336
+ static get screenHeight(): number;
1337
+ /**
1338
+ * This method returns the horizontal margin of the screen.
1339
+ */
1340
+ static get horizontalMargin(): number;
1341
+ /**
1342
+ * This method returns the vertical margin of the screen.
1343
+ */
1344
+ static get verticalMargin(): number;
1345
+ /**
1346
+ * This method is called when the screen is resized.
1347
+ */
1348
+ private static resize;
1349
+ /**
1350
+ * This is a dictionary that contains all Canvas Elements of Canvas, currently.
1351
+ */
1352
+ static get currentCanvasElements(): {
1353
+ [tag: string]: CanvasBase<any>;
1354
+ };
1355
+ private static _children;
1356
+ /**
1357
+ * The order of the children tags.
1358
+ */
1359
+ private static childrenTagsOrder;
1360
+ /**
1361
+ * Add a canvas element to the canvas.
1362
+ * If there is a canvas element with the same tag, it will be removed.
1363
+ * @param tag The tag of the canvas element.
1364
+ * @param canvasElement The canvas elements to be added.
1365
+ * @example
1366
+ * ```typescript
1367
+ * const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
1368
+ * const sprite = CanvasSprite.from(texture);
1369
+ * GameWindowManager.addCanvasElement("bunny", sprite);
1370
+ * ```
1371
+ */
1372
+ static addCanvasElement(tag: string, canvasElement: CanvasBase<any>): void;
1373
+ /**
1374
+ * Remove a canvas element from the canvas.
1375
+ * And remove all tickers that are not connected to any canvas element.
1376
+ * @param tag The tag of the canvas element to be removed.
1377
+ * @returns
1378
+ * @example
1379
+ * ```typescript
1380
+ * GameWindowManager.removeCanvasElement("bunny");
1381
+ * ```
1382
+ */
1383
+ static removeCanvasElement(tag: string | string[]): void;
1384
+ /**
1385
+ * Get a canvas element by the tag.
1386
+ * @param tag The tag of the canvas element.
1387
+ * @returns The canvas element.
1388
+ * @example
1389
+ * ```typescript
1390
+ * const sprite = GameWindowManager.getCanvasElement<CanvasSprite>("bunny");
1391
+ * ```
1392
+ */
1393
+ static getCanvasElement<T extends CanvasBase<any>>(tag: string): T | undefined;
1394
+ /**
1395
+ * Check if a DisplayObject is on the canvas.
1396
+ * @param pixiElement The DisplayObject to be checked.
1397
+ * @returns If the DisplayObject is on the canvas.
1398
+ */
1399
+ static canvasElementIsOnCanvas<T extends Container>(pixiElement: T): boolean;
1400
+ /**
1401
+ * Remove all canvas elements from the canvas.
1402
+ * And remove all tickers that are not connected to any canvas element.
1403
+ */
1404
+ static removeCanvasElements(): void;
1405
+ /**
1406
+ * Edit the tag of a canvas element.
1407
+ * @param oldTag The old tag of the canvas element.
1408
+ * @param newTag The new tag of the canvas element.
1409
+ */
1410
+ static editTagCanvasElement(oldTag: string, newTag: string): void;
1411
+ /** Edit Tickers Methods */
1412
+ /**
1413
+ * Currently tickers that are running.
1414
+ */
1415
+ static get currentTickers(): IClassWithArgsHistory<any>[];
1416
+ private static _currentTickers;
1417
+ /**
1418
+ * The steps of the tickers
1419
+ */
1420
+ static get currentTickersSteps(): {
1421
+ [tag: string]: ITickersSteps;
1422
+ };
1423
+ private static _currentTickersSteps;
1424
+ static currentTickersTimeouts: {
1425
+ [timeout: string]: {
1426
+ tags: string[];
1427
+ ticker: string;
1428
+ };
1429
+ };
1430
+ /**
1431
+ * Run a ticker.
1432
+ * @param canvasEslementTag The tag of the canvas element that will use the ticker.
1433
+ * @param ticker The ticker class to be run.
1434
+ * @param args The arguments to be used in the ticker.
1435
+ * @param duration The time to be used in the ticker. This number is in milliseconds. If it is undefined, the ticker will run forever.
1436
+ * @param priority The priority to be used in the ticker.
1437
+ * @returns
1438
+ * @example
1439
+ * ```typescript
1440
+ * GameWindowManager.addTicker("alien", new TickerRotate({ speed: 0.2 }))
1441
+ * ```
1442
+ */
1443
+ static addTicker<TArgs extends TickerArgsType>(canvasElementTag: string | string[], ticker: TickerBase<TArgs>): void;
1444
+ private static pushTicker;
1445
+ /**
1446
+ * Run a sequence of tickers.
1447
+ * @param tag The tag of canvas element that will use the tickers.
1448
+ * @param steps The steps of the tickers.
1449
+ * @returns
1450
+ * @example
1451
+ * ```typescript
1452
+ * GameWindowManager.addTickersSteps("alien", [
1453
+ * new TickerRotate({ speed: 0.1, clockwise: true }, 2000),
1454
+ * Pause(500),
1455
+ * new TickerRotate({ speed: 0.2, clockwise: false }, 2000),
1456
+ * Repeat,
1457
+ * ])
1458
+ * ```
1459
+ */
1460
+ static addTickersSteps<TArgs extends TickerArgsType>(tag: string, steps: (ITicker<TArgs> | RepeatType | PauseType)[]): void;
1461
+ private static runTickersSteps;
1462
+ private static nextTickerStep;
1463
+ /**
1464
+ * Remove a connection between a canvas element and a ticker.
1465
+ * And remove the ticker if there is no canvas element connected to it.
1466
+ * @param tag The tag of the canvas element that will use the ticker.
1467
+ * @param ticker The ticker class to be removed.
1468
+ * @example
1469
+ * ```typescript
1470
+ * GameWindowManager.removeAssociationBetweenTickerCanvasElement("alien", TickerRotate)
1471
+ * ```
1472
+ */
1473
+ static removeAssociationBetweenTickerCanvasElement(tag: string | string[], ticker: typeof TickerBase<any> | TickerBase<any>): void;
1474
+ /**
1475
+ * Remove all tickers that are not connected to any existing canvas element.
1476
+ */
1477
+ private static removeTickersWithoutAssociatedCanvasElement;
1478
+ private static addTickerTimeoutInfo;
1479
+ private static removeTickerTimeoutInfo;
1480
+ /**
1481
+ * Remove all tickers from the canvas.
1482
+ */
1483
+ static removeTickers(): void;
1484
+ /**
1485
+ * Clear the canvas and the tickers.
1486
+ */
1487
+ static clear(): void;
1488
+ /**
1489
+ * Export the canvas and the tickers to a JSON string.
1490
+ * @returns The JSON string.
1491
+ */
1492
+ static exportJson(): string;
1493
+ /**
1494
+ * Export the canvas and the tickers to an object.
1495
+ * @returns The object.
1496
+ */
1497
+ static export(): ExportedCanvas;
1498
+ /**
1499
+ * Import the canvas and the tickers from a JSON string.
1500
+ * @param dataString The JSON string.
1501
+ */
1502
+ static importJson(dataString: string): void;
1503
+ /**
1504
+ * Import the canvas and the tickers from an object.
1505
+ * @param data The object.
1506
+ */
1507
+ static import(data: object): void;
1508
+ }
1509
+
1510
+ export { CanvasBase, CanvasContainer, CanvasEvent, type CanvasEventNamesType, CanvasImage, CanvasSprite, CanvasText, CharacterModelBase, ChoiceMenuOptionLabel, type ChoiceMenuOptionsType, DialogueModelBase, type ExportedCanvas, type ExportedStep, type ExportedStorage, GameStepManager, GameStorageManager, GameWindowManager, type ICanvasBaseMemory, type ICanvasContainerMemory, type ICanvasImageMemory, type ICanvasSpriteBaseMemory, type ICanvasSpriteMemory, type ICanvasTextMemory as ICanvasTextTextMemory, type IClassWithArgsHistory, type IClassWithArgsHistoryForExport, type IDialogueHistory, type IHistoryStep, type IHistoryStepData, type IOpenedLabel, type ISaveData, type ITextureMemory, type ITicker, type ITickersSteps, Label, LabelRunModeEnum, Pause, type PauseType, PauseValueType, Repeat, type RepeatType, type StepLabelType, type StorageElementType, StoredClassModel, TickerBase, TickerFadeAlpha, type TickerProgrationType, TickerRotate, addImage, canvasElementDecorator, clearAllGameDatas, clearChoiceMenuOptions, clearDialogue, eventDecorator, getCharacterById, getChoiceMenuOptions, getDialogue, getDialogueHistory, getSaveData, getSaveJson, getTexture, labelDecorator, loadSaveData, loadSaveJson, removeCanvasElement, saveCharacter, setChoiceMenuOptions, setDialogue, showCanvasImages, showImageWithDissolveTransition, tickerDecorator };