@drincs/pixi-vn 0.1.3 → 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.
- package/README.md +20 -16
- package/dist/index.d.mts +283 -200
- package/dist/index.d.ts +283 -200
- package/dist/index.js +1923 -1797
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1879 -1753
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as pixi_js from 'pixi.js';
|
|
2
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';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* CanvasEventNamesType is a type that is used to define the event names for the canvas.
|
|
@@ -33,8 +34,8 @@ declare class CanvasEvent<C> {
|
|
|
33
34
|
* @example
|
|
34
35
|
* ```typescript
|
|
35
36
|
* export class CharacterModelBase extends StoredClassModel implements ICharacterModelBase {
|
|
36
|
-
* constructor(
|
|
37
|
-
* super(
|
|
37
|
+
* constructor(id: string, props: ICharacterModelBase) {
|
|
38
|
+
* super(id)
|
|
38
39
|
* this.defaultName = props.name
|
|
39
40
|
* this.defaultSurname = props.surname
|
|
40
41
|
* }
|
|
@@ -43,14 +44,14 @@ declare class CanvasEvent<C> {
|
|
|
43
44
|
* return this.getStorageProperty<string>("name") || this.defaultName
|
|
44
45
|
* }
|
|
45
46
|
* set name(value: string) {
|
|
46
|
-
* this.
|
|
47
|
+
* this.updateStorageProperty<string>("name", value)
|
|
47
48
|
* }
|
|
48
49
|
* private defaultSurname?: string
|
|
49
50
|
* get surname(): string | undefined {
|
|
50
51
|
* return this.getStorageProperty<string>("surname") || this.defaultSurname
|
|
51
52
|
* }
|
|
52
53
|
* set surname(value: string | undefined) {
|
|
53
|
-
* this.
|
|
54
|
+
* this.updateStorageProperty<string>("surname", value)
|
|
54
55
|
* }
|
|
55
56
|
* }
|
|
56
57
|
* ```
|
|
@@ -59,7 +60,7 @@ declare abstract class StoredClassModel {
|
|
|
59
60
|
id: string;
|
|
60
61
|
constructor(id: string);
|
|
61
62
|
private get nameClass();
|
|
62
|
-
|
|
63
|
+
updateStorageProperty<T>(key: string, value: T | undefined): void;
|
|
63
64
|
getStorageProperty<T>(key: string): T | undefined;
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -94,7 +95,7 @@ interface ICharacterModelBase {
|
|
|
94
95
|
* ```
|
|
95
96
|
*/
|
|
96
97
|
declare class CharacterModelBase extends StoredClassModel implements ICharacterModelBase {
|
|
97
|
-
constructor(
|
|
98
|
+
constructor(id: string, props: ICharacterModelBase);
|
|
98
99
|
private defaultName;
|
|
99
100
|
get name(): string;
|
|
100
101
|
set name(value: string);
|
|
@@ -104,25 +105,26 @@ declare class CharacterModelBase extends StoredClassModel implements ICharacterM
|
|
|
104
105
|
private defaultAge?;
|
|
105
106
|
get age(): number | undefined;
|
|
106
107
|
set age(value: number | undefined);
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
private _icon?;
|
|
109
|
+
get icon(): string | undefined;
|
|
110
|
+
private _color?;
|
|
111
|
+
get color(): string | undefined;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
/**
|
|
112
|
-
*
|
|
115
|
+
* Enumeration of label modes that occurred during the progression of the steps.
|
|
113
116
|
*/
|
|
114
|
-
declare
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* The text of the dialogue.
|
|
118
|
-
*/
|
|
119
|
-
text: string;
|
|
120
|
-
/**
|
|
121
|
-
* The tag of the character that is speaking.
|
|
122
|
-
*/
|
|
123
|
-
characterTag?: string;
|
|
117
|
+
declare enum LabelRunModeEnum {
|
|
118
|
+
OpenByCall = "openbycall",
|
|
119
|
+
OpenByJump = "openbyjump"
|
|
124
120
|
}
|
|
125
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
|
+
|
|
126
128
|
/**
|
|
127
129
|
* StepHistoryData is a string that will be stored in the history of the game.
|
|
128
130
|
* It is a function converted to string.
|
|
@@ -148,9 +150,9 @@ type StepLabelType = (() => void | Promise<void>);
|
|
|
148
150
|
* () => {
|
|
149
151
|
* GameWindowManager.clear()
|
|
150
152
|
* setDialogue({ character: liam, text: "Which test do you want to perform?" })
|
|
151
|
-
*
|
|
152
|
-
* new
|
|
153
|
-
* new
|
|
153
|
+
* setChoiceMenuOptions([
|
|
154
|
+
* new ChoiceMenuOptionLabel("Events Test", EventsTestLabel),
|
|
155
|
+
* new ChoiceMenuOptionLabel("Show Image Test", ShowImageTest),
|
|
154
156
|
* ])
|
|
155
157
|
* },
|
|
156
158
|
* () => GameStepManager.jumpLabel(StartLabel),
|
|
@@ -176,26 +178,52 @@ declare class Label {
|
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
/**
|
|
179
|
-
*
|
|
180
|
-
*/
|
|
181
|
-
declare enum LabelRunModeEnum {
|
|
182
|
-
OpenByCall = "openbycall",
|
|
183
|
-
OpenByJump = "openbyjump"
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* MenuOptionLabel is a class that contains a Label and a text that will be displayed in the menu.
|
|
181
|
+
* ChoiceMenuOptionLabel is a class that contains a Label and a text that will be displayed in the menu.
|
|
188
182
|
* @example
|
|
189
183
|
* ```typescript
|
|
190
|
-
* new
|
|
184
|
+
* new ChoiceMenuOptionLabel("Events Test", EventsTestLabel)
|
|
191
185
|
* ```
|
|
192
186
|
*/
|
|
193
|
-
declare class
|
|
187
|
+
declare class ChoiceMenuOptionLabel {
|
|
188
|
+
/**
|
|
189
|
+
* Text to be displayed in the menu
|
|
190
|
+
*/
|
|
194
191
|
text: string;
|
|
192
|
+
/**
|
|
193
|
+
* Label to be opened when the option is selected
|
|
194
|
+
*/
|
|
195
195
|
label: typeof Label;
|
|
196
|
+
/**
|
|
197
|
+
* Type of the label to be opened
|
|
198
|
+
*/
|
|
196
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
|
+
*/
|
|
197
205
|
constructor(text: string, label: typeof Label, type?: LabelRunModeEnum);
|
|
198
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
|
+
}
|
|
199
227
|
|
|
200
228
|
/**
|
|
201
229
|
* Interface for the canvas base memory
|
|
@@ -211,7 +239,7 @@ interface ICanvasContainerMemory extends ContainerOptions, ICanvasBaseMemory {
|
|
|
211
239
|
elements: ICanvasBaseMemory[];
|
|
212
240
|
}
|
|
213
241
|
|
|
214
|
-
type
|
|
242
|
+
type EventIdType = string;
|
|
215
243
|
|
|
216
244
|
/**
|
|
217
245
|
* Interface for texture memory
|
|
@@ -223,7 +251,7 @@ interface ITextureMemory {
|
|
|
223
251
|
interface ICanvasSpriteBaseMemory extends SpriteOptions, ICanvasBaseMemory {
|
|
224
252
|
textureImage: ITextureMemory;
|
|
225
253
|
onEvents: {
|
|
226
|
-
[name: CanvasEventNamesType]:
|
|
254
|
+
[name: CanvasEventNamesType]: EventIdType;
|
|
227
255
|
};
|
|
228
256
|
}
|
|
229
257
|
/**
|
|
@@ -246,7 +274,7 @@ interface ICanvasImageMemory extends ICanvasSpriteBaseMemory {
|
|
|
246
274
|
interface ICanvasTextMemory extends TextOptions, ICanvasBaseMemory {
|
|
247
275
|
className: "CanvasText";
|
|
248
276
|
onEvents: {
|
|
249
|
-
[name: CanvasEventNamesType]:
|
|
277
|
+
[name: CanvasEventNamesType]: EventIdType;
|
|
250
278
|
};
|
|
251
279
|
}
|
|
252
280
|
|
|
@@ -285,7 +313,7 @@ declare class CanvasBase<T2 extends ICanvasBaseMemory> extends Container {
|
|
|
285
313
|
|
|
286
314
|
/**
|
|
287
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,
|
|
288
|
-
* but it has the ability to be saved and loaded by the Pixi'
|
|
316
|
+
* but it has the ability to be saved and loaded by the Pixi'VN library.
|
|
289
317
|
* @example
|
|
290
318
|
* ```typescript
|
|
291
319
|
* const container = new CanvasContainer();
|
|
@@ -307,7 +335,7 @@ declare class CanvasContainer extends Container implements CanvasBase<ICanvasCon
|
|
|
307
335
|
|
|
308
336
|
/**
|
|
309
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,
|
|
310
|
-
* but it has the ability to be saved and loaded by the Pixi'
|
|
338
|
+
* but it has the ability to be saved and loaded by the Pixi'VN library.
|
|
311
339
|
* @example
|
|
312
340
|
* ```typescript
|
|
313
341
|
* const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
|
|
@@ -387,7 +415,7 @@ declare class CanvasSprite<Memory extends SpriteOptions & ICanvasBaseMemory = IC
|
|
|
387
415
|
* This class is a extension of the CanvasSprite class, it has the same properties and methods,
|
|
388
416
|
* but it has some features that make texture management easier.
|
|
389
417
|
* You need to use CanvasImage.load() to show the image in the canvas.
|
|
390
|
-
* This class is used for functions like addImage, showCanvasImages and
|
|
418
|
+
* This class is used for functions like addImage, showCanvasImages and showImageWithDissolveTransition.
|
|
391
419
|
* @example
|
|
392
420
|
* ```typescript
|
|
393
421
|
* let alien = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
|
|
@@ -411,7 +439,7 @@ declare class CanvasImage extends CanvasSprite<ICanvasImageMemory> {
|
|
|
411
439
|
|
|
412
440
|
/**
|
|
413
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,
|
|
414
|
-
* but it has the ability to be saved and loaded by the Pixi'
|
|
442
|
+
* but it has the ability to be saved and loaded by the Pixi'VN library.
|
|
415
443
|
* @example
|
|
416
444
|
* ```typescript
|
|
417
445
|
* const text = new CanvasText();
|
|
@@ -498,7 +526,7 @@ interface ITicker<TArgs extends TickerArgsType> {
|
|
|
498
526
|
type StorageElementType = string | number | boolean | object | undefined | null;
|
|
499
527
|
|
|
500
528
|
type TickerArgsType = {
|
|
501
|
-
[
|
|
529
|
+
[id: string]: StorageElementType;
|
|
502
530
|
};
|
|
503
531
|
/**
|
|
504
532
|
* A class is used to create a ticker element to add into a Pixi Application.
|
|
@@ -664,15 +692,15 @@ declare function canvasElementDecorator(name?: CanvasElementTagType): (target: t
|
|
|
664
692
|
*/
|
|
665
693
|
declare function saveCharacter<T extends CharacterModelBase = CharacterModelBase>(character: T | T[]): void;
|
|
666
694
|
/**
|
|
667
|
-
* is a function that returns the character by the
|
|
668
|
-
* @param
|
|
695
|
+
* is a function that returns the character by the id
|
|
696
|
+
* @param id is the id of the character
|
|
669
697
|
* @returns the character
|
|
670
698
|
* @example
|
|
671
699
|
* ```typescript
|
|
672
|
-
* const liam =
|
|
700
|
+
* const liam = getCharacterById('liam');
|
|
673
701
|
* ```
|
|
674
702
|
*/
|
|
675
|
-
declare function
|
|
703
|
+
declare function getCharacterById<T extends CharacterModelBase>(id: string): T | undefined;
|
|
676
704
|
|
|
677
705
|
/**
|
|
678
706
|
* Is a decorator that register a event in the game.
|
|
@@ -681,13 +709,7 @@ declare function getCharacterByTag<T extends CharacterModelBase>(tag: string): T
|
|
|
681
709
|
* @param name is th identifier of the event, by default is the name of the class
|
|
682
710
|
* @returns
|
|
683
711
|
*/
|
|
684
|
-
declare function eventDecorator(name?:
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* LabelTagType is a string containing the name of the label.
|
|
688
|
-
* It is used to GameStepManager.registeredLabels to get the label class.
|
|
689
|
-
*/
|
|
690
|
-
type LabelTagType = string;
|
|
712
|
+
declare function eventDecorator(name?: EventIdType): (target: typeof CanvasEvent<any>) => void;
|
|
691
713
|
|
|
692
714
|
/**
|
|
693
715
|
* Is a decorator that register a label in the game.
|
|
@@ -696,13 +718,13 @@ type LabelTagType = string;
|
|
|
696
718
|
* @param name is th identifier of the label, by default is the name of the class
|
|
697
719
|
* @returns
|
|
698
720
|
*/
|
|
699
|
-
declare function labelDecorator(name?:
|
|
721
|
+
declare function labelDecorator(name?: LabelIdType): (target: typeof Label) => void;
|
|
700
722
|
|
|
701
723
|
/**
|
|
702
|
-
*
|
|
724
|
+
* is a string that represents a ticker id.
|
|
703
725
|
* It is used to GameWindowManager.tickers to get the ticker class.
|
|
704
726
|
*/
|
|
705
|
-
type
|
|
727
|
+
type TickerIdType = string;
|
|
706
728
|
|
|
707
729
|
/**
|
|
708
730
|
* Is a decorator that register a ticker in the game.
|
|
@@ -711,13 +733,178 @@ type TickerTagType = string;
|
|
|
711
733
|
* @param name is th identifier of the label, by default is the name of the class
|
|
712
734
|
* @returns
|
|
713
735
|
*/
|
|
714
|
-
declare function tickerDecorator(name?:
|
|
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
|
+
}
|
|
715
902
|
|
|
716
903
|
/**
|
|
717
904
|
* Munu is a type that contains a list of Label that a player can choose from.
|
|
718
905
|
* For Ren'py this is the equivalent of a menu.
|
|
719
906
|
*/
|
|
720
|
-
type
|
|
907
|
+
type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
|
|
721
908
|
|
|
722
909
|
/**
|
|
723
910
|
* Set the dialogue to be shown in the game
|
|
@@ -726,20 +913,20 @@ type MenuOptionsType = MenuOptionLabel[];
|
|
|
726
913
|
* ```typescript
|
|
727
914
|
* setDialogue("Hello World")
|
|
728
915
|
* setDialogue({
|
|
729
|
-
* character: "
|
|
916
|
+
* character: "characterId",
|
|
730
917
|
* text: "Hello World"
|
|
731
918
|
* })
|
|
732
919
|
* ```
|
|
733
920
|
*/
|
|
734
|
-
declare function setDialogue(props: {
|
|
735
|
-
character: string |
|
|
921
|
+
declare function setDialogue<T extends CharacterModelBase = CharacterModelBase>(props: {
|
|
922
|
+
character: string | T;
|
|
736
923
|
text: string;
|
|
737
924
|
} | string): void;
|
|
738
925
|
/**
|
|
739
926
|
* Get the dialogue to be shown in the game
|
|
740
927
|
* @returns Dialogue to be shown in the game
|
|
741
928
|
*/
|
|
742
|
-
declare function getDialogue():
|
|
929
|
+
declare function getDialogue<T extends DialogueModelBase = DialogueModelBase>(): T | undefined;
|
|
743
930
|
/**
|
|
744
931
|
* Clear the dialogue to be shown in the game
|
|
745
932
|
*/
|
|
@@ -749,30 +936,30 @@ declare function clearDialogue(): void;
|
|
|
749
936
|
* @param options Options to be shown in the game
|
|
750
937
|
* @example
|
|
751
938
|
* ```typescript
|
|
752
|
-
*
|
|
753
|
-
* new
|
|
754
|
-
* new
|
|
755
|
-
* new
|
|
756
|
-
* new
|
|
757
|
-
* new
|
|
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)
|
|
758
945
|
* ])
|
|
759
946
|
* ```
|
|
760
947
|
*/
|
|
761
|
-
declare function
|
|
948
|
+
declare function setChoiceMenuOptions(options: ChoiceMenuOptionsType): void;
|
|
762
949
|
/**
|
|
763
950
|
* Get the options to be shown in the game
|
|
764
951
|
* @returns Options to be shown in the game
|
|
765
952
|
*/
|
|
766
|
-
declare function
|
|
953
|
+
declare function getChoiceMenuOptions(): ChoiceMenuOptionsType | undefined;
|
|
767
954
|
/**
|
|
768
955
|
* Clear the options to be shown in the game
|
|
769
956
|
*/
|
|
770
|
-
declare function
|
|
957
|
+
declare function clearChoiceMenuOptions(): void;
|
|
771
958
|
/**
|
|
772
959
|
* Get the history of the dialogues
|
|
773
960
|
* @returns the history of the dialogues
|
|
774
961
|
*/
|
|
775
|
-
declare function getDialogueHistory():
|
|
962
|
+
declare function getDialogueHistory<T extends DialogueModelBase = DialogueModelBase>(): IDialogueHistory<T>[];
|
|
776
963
|
|
|
777
964
|
/**
|
|
778
965
|
* Clear all game data. This function is used to reset the game.
|
|
@@ -815,84 +1002,7 @@ declare function removeCanvasElement(tag: string | string[]): void;
|
|
|
815
1002
|
* @param priority The priority of the effect
|
|
816
1003
|
* @returns The sprite of the image.
|
|
817
1004
|
*/
|
|
818
|
-
declare function
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* IClassWithArgsHistory is a class that contains the name of a class and the arguments that were used to create it.
|
|
822
|
-
*/
|
|
823
|
-
interface IClassWithArgsHistory<TArgs extends TickerArgsType> {
|
|
824
|
-
fn: TickerCallback<any>;
|
|
825
|
-
className: TickerTagType;
|
|
826
|
-
args: TArgs;
|
|
827
|
-
canvasElementTags: string[];
|
|
828
|
-
priority?: UPDATE_PRIORITY;
|
|
829
|
-
duration?: number;
|
|
830
|
-
}
|
|
831
|
-
interface IClassWithArgsHistoryForExport<TArgs extends TickerArgsType> {
|
|
832
|
-
className: TickerTagType;
|
|
833
|
-
args: TArgs;
|
|
834
|
-
canvasElementTags: string[];
|
|
835
|
-
priority?: UPDATE_PRIORITY;
|
|
836
|
-
duration?: number;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* Interface exported canvas
|
|
841
|
-
*/
|
|
842
|
-
interface ExportedCanvas {
|
|
843
|
-
currentTickers: IClassWithArgsHistoryForExport<any>[];
|
|
844
|
-
currentElements: {
|
|
845
|
-
[tag: string]: ICanvasBaseMemory;
|
|
846
|
-
};
|
|
847
|
-
childrenTagsOrder: string[];
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* Interface exported storage data
|
|
852
|
-
*/
|
|
853
|
-
interface ExportedStorage {
|
|
854
|
-
storage: {
|
|
855
|
-
[key: string]: StorageElementType;
|
|
856
|
-
};
|
|
857
|
-
stepOidUsedList: string[];
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
interface IOpenedLabel {
|
|
861
|
-
label: LabelTagType;
|
|
862
|
-
currentStepIndex: number;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* IHistoryStep is a interface that contains:
|
|
867
|
-
* - the browser path that occurred during the progression of the steps.
|
|
868
|
-
* - the storage that occurred during the progression of the steps.
|
|
869
|
-
* - the step data.
|
|
870
|
-
* - the canvas that occurred during the progression of the steps.
|
|
871
|
-
*/
|
|
872
|
-
interface IHistoryStep {
|
|
873
|
-
path: string;
|
|
874
|
-
storage: ExportedStorage;
|
|
875
|
-
stepSha1: StepHistoryDataType;
|
|
876
|
-
stepIndex: number;
|
|
877
|
-
canvas: ExportedCanvas;
|
|
878
|
-
openedLabels: IOpenedLabel[];
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
/**
|
|
882
|
-
* Interface exported step data
|
|
883
|
-
*/
|
|
884
|
-
interface ExportedStep {
|
|
885
|
-
stepsHistory: IHistoryStep[];
|
|
886
|
-
openedLabels: IOpenedLabel[];
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
interface ISaveData {
|
|
890
|
-
version: string;
|
|
891
|
-
stepData: ExportedStep;
|
|
892
|
-
storageData: ExportedStorage;
|
|
893
|
-
canvasData: ExportedCanvas;
|
|
894
|
-
path: string;
|
|
895
|
-
}
|
|
1005
|
+
declare function showImageWithDissolveTransition(tag: string, imageUrl: string, speed: number, priority?: UPDATE_PRIORITY): Promise<void>;
|
|
896
1006
|
|
|
897
1007
|
/**
|
|
898
1008
|
* Get the save data
|
|
@@ -921,7 +1031,7 @@ declare function getSaveJson(): string;
|
|
|
921
1031
|
* @param data The save data
|
|
922
1032
|
* @param navigate The function to navigate to a path
|
|
923
1033
|
*/
|
|
924
|
-
declare function
|
|
1034
|
+
declare function loadSaveData(data: ISaveData, navigate: (path: string) => void): void;
|
|
925
1035
|
/**
|
|
926
1036
|
* Load the save data from a JSON string
|
|
927
1037
|
* @param dataString The save data as a JSON string
|
|
@@ -940,7 +1050,7 @@ declare function loadSave(data: ISaveData, navigate: (path: string) => void): vo
|
|
|
940
1050
|
* reader.onload = (e) => {
|
|
941
1051
|
* const jsonString = e.target?.result as string;
|
|
942
1052
|
* // load the save data from the JSON string
|
|
943
|
-
*
|
|
1053
|
+
* loadSaveJson(jsonString, navigate);
|
|
944
1054
|
* afterLoad && afterLoad();
|
|
945
1055
|
* };
|
|
946
1056
|
* reader.readAsText(file);
|
|
@@ -950,7 +1060,7 @@ declare function loadSave(data: ISaveData, navigate: (path: string) => void): vo
|
|
|
950
1060
|
* }
|
|
951
1061
|
* ```
|
|
952
1062
|
*/
|
|
953
|
-
declare function
|
|
1063
|
+
declare function loadSaveJson(dataString: string, navigate: (path: string) => void): void;
|
|
954
1064
|
|
|
955
1065
|
/**
|
|
956
1066
|
* Get a texture from a url.
|
|
@@ -959,42 +1069,8 @@ declare function loadSaveJsonString(dataString: string, navigate: (path: string)
|
|
|
959
1069
|
*/
|
|
960
1070
|
declare function getTexture(imageUrl: string): Promise<Texture | void>;
|
|
961
1071
|
|
|
962
|
-
declare const PauseValueType = "Pause";
|
|
963
|
-
type PauseType = {
|
|
964
|
-
type: typeof PauseValueType;
|
|
965
|
-
duration: number;
|
|
966
|
-
};
|
|
967
|
-
declare function Pause(duration: number): PauseType;
|
|
968
|
-
|
|
969
|
-
type RepeatType = "Repeat";
|
|
970
|
-
declare const Repeat: RepeatType;
|
|
971
|
-
|
|
972
|
-
interface ITickersStep<TArgs extends TickerArgsType> extends ITicker<TArgs> {
|
|
973
|
-
/**
|
|
974
|
-
* Ticker class name
|
|
975
|
-
*/
|
|
976
|
-
ticker: string;
|
|
977
|
-
/**
|
|
978
|
-
* Duration in milliseconds
|
|
979
|
-
*/
|
|
980
|
-
duration: number;
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* The steps of the tickers
|
|
984
|
-
*/
|
|
985
|
-
interface ITickersSteps {
|
|
986
|
-
/**
|
|
987
|
-
* The step number
|
|
988
|
-
*/
|
|
989
|
-
currentStepNumber: number;
|
|
990
|
-
/**
|
|
991
|
-
* The steps of the tickers
|
|
992
|
-
*/
|
|
993
|
-
steps: (ITickersStep<any> | RepeatType | PauseType)[];
|
|
994
|
-
}
|
|
995
|
-
|
|
996
1072
|
/**
|
|
997
|
-
*
|
|
1073
|
+
* GameStepManager is a class that manages the steps and labels of the game.
|
|
998
1074
|
*/
|
|
999
1075
|
declare class GameStepManager {
|
|
1000
1076
|
private constructor();
|
|
@@ -1002,8 +1078,16 @@ declare class GameStepManager {
|
|
|
1002
1078
|
* stepHistory is a list of label events and steps that occurred during the progression of the steps.
|
|
1003
1079
|
*/
|
|
1004
1080
|
private static _stepsHistory;
|
|
1005
|
-
static get stepsHistory(): IHistoryStep[];
|
|
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
|
+
*/
|
|
1006
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;
|
|
1007
1091
|
private static _openedLabels;
|
|
1008
1092
|
static get openedLabels(): IOpenedLabel[];
|
|
1009
1093
|
/**
|
|
@@ -1011,13 +1095,16 @@ declare class GameStepManager {
|
|
|
1011
1095
|
*/
|
|
1012
1096
|
private static get currentLabel();
|
|
1013
1097
|
/**
|
|
1014
|
-
*
|
|
1098
|
+
* is the current step index of the current label that occurred during the progression of the steps.
|
|
1015
1099
|
*/
|
|
1016
1100
|
private static get currentLabelStepIndex();
|
|
1017
1101
|
/**
|
|
1018
1102
|
* lastHistoryStep is the last history step that occurred during the progression of the steps.
|
|
1019
1103
|
*/
|
|
1020
1104
|
private static get lastHistoryStep();
|
|
1105
|
+
private static _originalStepData;
|
|
1106
|
+
private static get originalStepData();
|
|
1107
|
+
private static set originalStepData(value);
|
|
1021
1108
|
/**
|
|
1022
1109
|
* Add a label to the history.
|
|
1023
1110
|
* @param label The label to add to the history.
|
|
@@ -1032,11 +1119,11 @@ declare class GameStepManager {
|
|
|
1032
1119
|
* Close the current label and add it to the history.
|
|
1033
1120
|
* @returns
|
|
1034
1121
|
*/
|
|
1035
|
-
|
|
1122
|
+
static closeCurrentLabel(): void;
|
|
1036
1123
|
/**
|
|
1037
1124
|
* Close all labels and add them to the history.
|
|
1038
1125
|
*/
|
|
1039
|
-
|
|
1126
|
+
static closeAllLabels(): void;
|
|
1040
1127
|
/**
|
|
1041
1128
|
* Increase the current step index of the current label.
|
|
1042
1129
|
*/
|
|
@@ -1102,7 +1189,7 @@ declare class GameStepManager {
|
|
|
1102
1189
|
* ```
|
|
1103
1190
|
*/
|
|
1104
1191
|
static goBack(navigate: (path: string) => void, steps?: number): void;
|
|
1105
|
-
private static
|
|
1192
|
+
private static goBackInternal;
|
|
1106
1193
|
/**
|
|
1107
1194
|
* Add a label to the history.
|
|
1108
1195
|
*/
|
|
@@ -1130,19 +1217,15 @@ declare class GameStepManager {
|
|
|
1130
1217
|
}
|
|
1131
1218
|
|
|
1132
1219
|
declare class GameStorageManager {
|
|
1133
|
-
private static oidsUsed;
|
|
1134
1220
|
private static storage;
|
|
1135
1221
|
private constructor();
|
|
1136
1222
|
static get keysSystem(): {
|
|
1137
1223
|
CURRENT_DIALOGUE_MEMORY_KEY: string;
|
|
1138
1224
|
LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: string;
|
|
1139
1225
|
CURRENT_MENU_OPTIONS_MEMORY_KEY: string;
|
|
1226
|
+
LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: string;
|
|
1227
|
+
CHARACTER_PREKEY: string;
|
|
1140
1228
|
};
|
|
1141
|
-
/**
|
|
1142
|
-
* Get a new oid that is not used yet
|
|
1143
|
-
* @returns A new oid that is not used yet
|
|
1144
|
-
*/
|
|
1145
|
-
static getNewOid(): string;
|
|
1146
1229
|
/**
|
|
1147
1230
|
* Set a variable in the storage
|
|
1148
1231
|
* @param key The key of the variable
|
|
@@ -1221,7 +1304,7 @@ declare class GameWindowManager {
|
|
|
1221
1304
|
* Add the canvas into a html element.
|
|
1222
1305
|
* @param element it is the html element where I will put the canvas. Example: document.body
|
|
1223
1306
|
*/
|
|
1224
|
-
static addCanvasIntoElement
|
|
1307
|
+
private static addCanvasIntoElement;
|
|
1225
1308
|
/**
|
|
1226
1309
|
* Initialize the interface div and add it into a html element.
|
|
1227
1310
|
* @param element it is the html element where I will put the interface div. Example: document.getElementById('root')
|
|
@@ -1424,4 +1507,4 @@ declare class GameWindowManager {
|
|
|
1424
1507
|
static import(data: object): void;
|
|
1425
1508
|
}
|
|
1426
1509
|
|
|
1427
|
-
export { CanvasBase, CanvasContainer, CanvasEvent, type CanvasEventNamesType, CanvasImage, CanvasSprite, CanvasText, CharacterModelBase, 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 IHistoryStep, type IOpenedLabel, type ISaveData, type ITextureMemory, type ITicker, type ITickersSteps, Label, LabelRunModeEnum,
|
|
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 };
|