@drincs/pixi-vn 0.3.2 → 0.3.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/dist/index.d.mts CHANGED
@@ -82,11 +82,29 @@ declare class StoredClassModel {
82
82
  getStorageProperty<T>(propertyName: string): T | undefined;
83
83
  }
84
84
 
85
+ /**
86
+ * CharacterBaseModelProps is an interface that is used to create a character model.
87
+ */
85
88
  interface CharacterBaseModelProps {
89
+ /**
90
+ * The name of the character.
91
+ */
86
92
  name: string;
93
+ /**
94
+ * The surname of the character.
95
+ */
87
96
  surname?: string;
97
+ /**
98
+ * The age of the character.
99
+ */
88
100
  age?: number;
101
+ /**
102
+ * The icon of the character.
103
+ */
89
104
  icon?: string;
105
+ /**
106
+ * The color of the character.
107
+ */
90
108
  color?: string;
91
109
  }
92
110
  /**
@@ -113,19 +131,41 @@ interface CharacterBaseModelProps {
113
131
  * ```
114
132
  */
115
133
  declare class CharacterBaseModel extends StoredClassModel implements CharacterBaseModelProps {
134
+ /**
135
+ * @param id The id of the character.
136
+ * @param props The properties of the character.
137
+ */
116
138
  constructor(id: string, props: CharacterBaseModelProps);
117
139
  private defaultName;
140
+ /***
141
+ * The name of the character.
142
+ * If you set undefined, it will return the default name.
143
+ */
118
144
  get name(): string;
119
- set name(value: string);
145
+ set name(value: string | undefined);
120
146
  private defaultSurname?;
147
+ /**
148
+ * The surname of the character.
149
+ * If you set undefined, it will return the default surname.
150
+ */
121
151
  get surname(): string | undefined;
122
152
  set surname(value: string | undefined);
123
153
  private defaultAge?;
154
+ /**
155
+ * The age of the character.
156
+ * If you set undefined, it will return the default age.
157
+ */
124
158
  get age(): number | undefined;
125
159
  set age(value: number | undefined);
126
160
  private _icon?;
161
+ /**
162
+ * The icon of the character.
163
+ */
127
164
  get icon(): string | undefined;
128
165
  private _color?;
166
+ /**
167
+ * The color of the character.
168
+ */
129
169
  get color(): string | undefined;
130
170
  }
131
171
 
@@ -229,10 +269,43 @@ interface IStoratedChoiceMenuOptionLabel {
229
269
  }
230
270
 
231
271
  /**
232
- * Base class for all dialogue models. I suggest you extend this class to create your own dialogue models.
272
+ * Munu is a type that contains a list of Label that a player can choose from.
273
+ * For Ren'py this is the equivalent of a menu.
233
274
  */
234
- declare class DialogueBaseModel {
235
- constructor(text: string, character: string | CharacterBaseModel | undefined);
275
+ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
276
+
277
+ declare const PauseValueType = "Pause";
278
+ type PauseType = {
279
+ type: typeof PauseValueType;
280
+ duration: number;
281
+ };
282
+ declare function Pause(duration: number): PauseType;
283
+
284
+ type RepeatType = "Repeat";
285
+ declare const Repeat: RepeatType;
286
+
287
+ /**
288
+ * StorageElementType are all the types that can be stored in the storage
289
+ */
290
+ type StorageElementType = string | number | boolean | object | undefined | null;
291
+
292
+ /**
293
+ * Base class for all dialogue models.
294
+ * You can extend this class, but it is not reccomended. You can use the oltherParams property to store any other data you need.
295
+ * @example
296
+ * ```typescript
297
+ * setDialogue(new DialogueBaseModel("Hello World", character))
298
+ * ```
299
+ */
300
+ declare class DialogueBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel> {
301
+ /**
302
+ * @param text The text of the dialogue.
303
+ * @param character The id of the character that is speaking.
304
+ * @param oltherParams Other parameters that can be stored in the dialogue.
305
+ */
306
+ constructor(text: string, character: string | TCharacter | undefined, oltherParams?: {
307
+ [key: string]: StorageElementType;
308
+ });
236
309
  /**
237
310
  * The text of the dialogue.
238
311
  */
@@ -241,6 +314,12 @@ declare class DialogueBaseModel {
241
314
  * The id of the character that is speaking.
242
315
  */
243
316
  characterId?: string;
317
+ /**
318
+ * Other parameters that can be stored in the dialogue.
319
+ */
320
+ oltherParams: {
321
+ [key: string]: StorageElementType;
322
+ };
244
323
  }
245
324
 
246
325
  /**
@@ -538,11 +617,6 @@ interface ITicker<TArgs extends TickerArgsType> {
538
617
  priority?: UPDATE_PRIORITY;
539
618
  }
540
619
 
541
- /**
542
- * StorageElementType are all the types that can be stored in the storage
543
- */
544
- type StorageElementType = string | number | boolean | object | undefined | null;
545
-
546
620
  type TickerArgsType = {
547
621
  [id: string]: StorageElementType;
548
622
  };
@@ -578,6 +652,11 @@ type TickerArgsType = {
578
652
  * ```
579
653
  */
580
654
  declare class TickerBase<TArgs extends TickerArgsType> implements ITicker<TArgs> {
655
+ /**
656
+ * @param args The arguments that you want to pass to the ticker.
657
+ * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
658
+ * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
659
+ */
581
660
  constructor(args: TArgs, duration?: number, priority?: UPDATE_PRIORITY);
582
661
  args: TArgs;
583
662
  duration?: number;
@@ -893,16 +972,6 @@ interface ISaveData {
893
972
  path: string;
894
973
  }
895
974
 
896
- declare const PauseValueType = "Pause";
897
- type PauseType = {
898
- type: typeof PauseValueType;
899
- duration: number;
900
- };
901
- declare function Pause(duration: number): PauseType;
902
-
903
- type RepeatType = "Repeat";
904
- declare const Repeat: RepeatType;
905
-
906
975
  interface ITickersStep<TArgs extends TickerArgsType> extends ITicker<TArgs> {
907
976
  /**
908
977
  * Ticker class name
@@ -927,12 +996,6 @@ interface ITickersSteps {
927
996
  steps: (ITickersStep<any> | RepeatType | PauseType)[];
928
997
  }
929
998
 
930
- /**
931
- * Munu is a type that contains a list of Label that a player can choose from.
932
- * For Ren'py this is the equivalent of a menu.
933
- */
934
- type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
935
-
936
999
  /**
937
1000
  * Set the dialogue to be shown in the game
938
1001
  * @param text Text of the dialogue
@@ -943,12 +1006,13 @@ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
943
1006
  * character: "characterId",
944
1007
  * text: "Hello World"
945
1008
  * })
1009
+ * setDialogue(new DialogueBaseModel("Hello World", character))
946
1010
  * ```
947
1011
  */
948
- declare function setDialogue<T extends CharacterBaseModel = CharacterBaseModel>(props: {
949
- character: string | T;
1012
+ declare function setDialogue<TCharacter extends CharacterBaseModel = CharacterBaseModel, TDialogue extends DialogueBaseModel = DialogueBaseModel>(props: {
1013
+ character: string | TCharacter;
950
1014
  text: string;
951
- } | string): void;
1015
+ } | string | TDialogue): void;
952
1016
  /**
953
1017
  * Get the dialogue to be shown in the game
954
1018
  * @returns Dialogue to be shown in the game
@@ -1118,7 +1182,7 @@ declare class GameStepManager {
1118
1182
  * stepHistory is a list of label events and steps that occurred during the progression of the steps.
1119
1183
  */
1120
1184
  private static _stepsHistory;
1121
- static get stepsHistory(): IHistoryStep<DialogueBaseModel>[];
1185
+ static get stepsHistory(): IHistoryStep<DialogueBaseModel<CharacterBaseModel>>[];
1122
1186
  private static _lastStepIndex;
1123
1187
  /**
1124
1188
  * lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
package/dist/index.d.ts CHANGED
@@ -82,11 +82,29 @@ declare class StoredClassModel {
82
82
  getStorageProperty<T>(propertyName: string): T | undefined;
83
83
  }
84
84
 
85
+ /**
86
+ * CharacterBaseModelProps is an interface that is used to create a character model.
87
+ */
85
88
  interface CharacterBaseModelProps {
89
+ /**
90
+ * The name of the character.
91
+ */
86
92
  name: string;
93
+ /**
94
+ * The surname of the character.
95
+ */
87
96
  surname?: string;
97
+ /**
98
+ * The age of the character.
99
+ */
88
100
  age?: number;
101
+ /**
102
+ * The icon of the character.
103
+ */
89
104
  icon?: string;
105
+ /**
106
+ * The color of the character.
107
+ */
90
108
  color?: string;
91
109
  }
92
110
  /**
@@ -113,19 +131,41 @@ interface CharacterBaseModelProps {
113
131
  * ```
114
132
  */
115
133
  declare class CharacterBaseModel extends StoredClassModel implements CharacterBaseModelProps {
134
+ /**
135
+ * @param id The id of the character.
136
+ * @param props The properties of the character.
137
+ */
116
138
  constructor(id: string, props: CharacterBaseModelProps);
117
139
  private defaultName;
140
+ /***
141
+ * The name of the character.
142
+ * If you set undefined, it will return the default name.
143
+ */
118
144
  get name(): string;
119
- set name(value: string);
145
+ set name(value: string | undefined);
120
146
  private defaultSurname?;
147
+ /**
148
+ * The surname of the character.
149
+ * If you set undefined, it will return the default surname.
150
+ */
121
151
  get surname(): string | undefined;
122
152
  set surname(value: string | undefined);
123
153
  private defaultAge?;
154
+ /**
155
+ * The age of the character.
156
+ * If you set undefined, it will return the default age.
157
+ */
124
158
  get age(): number | undefined;
125
159
  set age(value: number | undefined);
126
160
  private _icon?;
161
+ /**
162
+ * The icon of the character.
163
+ */
127
164
  get icon(): string | undefined;
128
165
  private _color?;
166
+ /**
167
+ * The color of the character.
168
+ */
129
169
  get color(): string | undefined;
130
170
  }
131
171
 
@@ -229,10 +269,43 @@ interface IStoratedChoiceMenuOptionLabel {
229
269
  }
230
270
 
231
271
  /**
232
- * Base class for all dialogue models. I suggest you extend this class to create your own dialogue models.
272
+ * Munu is a type that contains a list of Label that a player can choose from.
273
+ * For Ren'py this is the equivalent of a menu.
233
274
  */
234
- declare class DialogueBaseModel {
235
- constructor(text: string, character: string | CharacterBaseModel | undefined);
275
+ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
276
+
277
+ declare const PauseValueType = "Pause";
278
+ type PauseType = {
279
+ type: typeof PauseValueType;
280
+ duration: number;
281
+ };
282
+ declare function Pause(duration: number): PauseType;
283
+
284
+ type RepeatType = "Repeat";
285
+ declare const Repeat: RepeatType;
286
+
287
+ /**
288
+ * StorageElementType are all the types that can be stored in the storage
289
+ */
290
+ type StorageElementType = string | number | boolean | object | undefined | null;
291
+
292
+ /**
293
+ * Base class for all dialogue models.
294
+ * You can extend this class, but it is not reccomended. You can use the oltherParams property to store any other data you need.
295
+ * @example
296
+ * ```typescript
297
+ * setDialogue(new DialogueBaseModel("Hello World", character))
298
+ * ```
299
+ */
300
+ declare class DialogueBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel> {
301
+ /**
302
+ * @param text The text of the dialogue.
303
+ * @param character The id of the character that is speaking.
304
+ * @param oltherParams Other parameters that can be stored in the dialogue.
305
+ */
306
+ constructor(text: string, character: string | TCharacter | undefined, oltherParams?: {
307
+ [key: string]: StorageElementType;
308
+ });
236
309
  /**
237
310
  * The text of the dialogue.
238
311
  */
@@ -241,6 +314,12 @@ declare class DialogueBaseModel {
241
314
  * The id of the character that is speaking.
242
315
  */
243
316
  characterId?: string;
317
+ /**
318
+ * Other parameters that can be stored in the dialogue.
319
+ */
320
+ oltherParams: {
321
+ [key: string]: StorageElementType;
322
+ };
244
323
  }
245
324
 
246
325
  /**
@@ -538,11 +617,6 @@ interface ITicker<TArgs extends TickerArgsType> {
538
617
  priority?: UPDATE_PRIORITY;
539
618
  }
540
619
 
541
- /**
542
- * StorageElementType are all the types that can be stored in the storage
543
- */
544
- type StorageElementType = string | number | boolean | object | undefined | null;
545
-
546
620
  type TickerArgsType = {
547
621
  [id: string]: StorageElementType;
548
622
  };
@@ -578,6 +652,11 @@ type TickerArgsType = {
578
652
  * ```
579
653
  */
580
654
  declare class TickerBase<TArgs extends TickerArgsType> implements ITicker<TArgs> {
655
+ /**
656
+ * @param args The arguments that you want to pass to the ticker.
657
+ * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
658
+ * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
659
+ */
581
660
  constructor(args: TArgs, duration?: number, priority?: UPDATE_PRIORITY);
582
661
  args: TArgs;
583
662
  duration?: number;
@@ -893,16 +972,6 @@ interface ISaveData {
893
972
  path: string;
894
973
  }
895
974
 
896
- declare const PauseValueType = "Pause";
897
- type PauseType = {
898
- type: typeof PauseValueType;
899
- duration: number;
900
- };
901
- declare function Pause(duration: number): PauseType;
902
-
903
- type RepeatType = "Repeat";
904
- declare const Repeat: RepeatType;
905
-
906
975
  interface ITickersStep<TArgs extends TickerArgsType> extends ITicker<TArgs> {
907
976
  /**
908
977
  * Ticker class name
@@ -927,12 +996,6 @@ interface ITickersSteps {
927
996
  steps: (ITickersStep<any> | RepeatType | PauseType)[];
928
997
  }
929
998
 
930
- /**
931
- * Munu is a type that contains a list of Label that a player can choose from.
932
- * For Ren'py this is the equivalent of a menu.
933
- */
934
- type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
935
-
936
999
  /**
937
1000
  * Set the dialogue to be shown in the game
938
1001
  * @param text Text of the dialogue
@@ -943,12 +1006,13 @@ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
943
1006
  * character: "characterId",
944
1007
  * text: "Hello World"
945
1008
  * })
1009
+ * setDialogue(new DialogueBaseModel("Hello World", character))
946
1010
  * ```
947
1011
  */
948
- declare function setDialogue<T extends CharacterBaseModel = CharacterBaseModel>(props: {
949
- character: string | T;
1012
+ declare function setDialogue<TCharacter extends CharacterBaseModel = CharacterBaseModel, TDialogue extends DialogueBaseModel = DialogueBaseModel>(props: {
1013
+ character: string | TCharacter;
950
1014
  text: string;
951
- } | string): void;
1015
+ } | string | TDialogue): void;
952
1016
  /**
953
1017
  * Get the dialogue to be shown in the game
954
1018
  * @returns Dialogue to be shown in the game
@@ -1118,7 +1182,7 @@ declare class GameStepManager {
1118
1182
  * stepHistory is a list of label events and steps that occurred during the progression of the steps.
1119
1183
  */
1120
1184
  private static _stepsHistory;
1121
- static get stepsHistory(): IHistoryStep<DialogueBaseModel>[];
1185
+ static get stepsHistory(): IHistoryStep<DialogueBaseModel<CharacterBaseModel>>[];
1122
1186
  private static _lastStepIndex;
1123
1187
  /**
1124
1188
  * lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
package/dist/index.js CHANGED
@@ -186,9 +186,11 @@ function getLabelInstanceByClassName(labelName) {
186
186
  function setDialogue(props) {
187
187
  let text = "";
188
188
  let characterId = void 0;
189
+ let dialogue;
189
190
  if (typeof props === "string") {
190
191
  text = props;
191
- } else {
192
+ dialogue = new DialogueBaseModel(text, characterId);
193
+ } else if (!(props instanceof DialogueBaseModel)) {
192
194
  text = props.text;
193
195
  if (props.character) {
194
196
  if (typeof props.character === "string") {
@@ -197,8 +199,10 @@ function setDialogue(props) {
197
199
  characterId = props.character.id;
198
200
  }
199
201
  }
202
+ dialogue = new DialogueBaseModel(text, characterId);
203
+ } else {
204
+ dialogue = props;
200
205
  }
201
- let dialogue = new DialogueBaseModel(text, characterId);
202
206
  GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, dialogue);
203
207
  GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
204
208
  }
@@ -798,6 +802,11 @@ function setMemoryText(element, memory) {
798
802
 
799
803
  // src/classes/ticker/TickerBase.ts
800
804
  var TickerBase = class {
805
+ /**
806
+ * @param args The arguments that you want to pass to the ticker.
807
+ * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
808
+ * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
809
+ */
801
810
  constructor(args, duration, priority) {
802
811
  this.args = args;
803
812
  this.duration = duration;
@@ -2373,6 +2382,10 @@ var StoredClassModel = class {
2373
2382
 
2374
2383
  // src/classes/CharacterBaseModel.ts
2375
2384
  var CharacterBaseModel2 = class extends StoredClassModel {
2385
+ /**
2386
+ * @param id The id of the character.
2387
+ * @param props The properties of the character.
2388
+ */
2376
2389
  constructor(id, props) {
2377
2390
  super(GameStorageManager.keysSystem.CHARACTER_CATEGORY_KEY, id);
2378
2391
  this.defaultName = "";
@@ -2382,27 +2395,45 @@ var CharacterBaseModel2 = class extends StoredClassModel {
2382
2395
  this._icon = props.icon;
2383
2396
  this._color = props.color;
2384
2397
  }
2398
+ /***
2399
+ * The name of the character.
2400
+ * If you set undefined, it will return the default name.
2401
+ */
2385
2402
  get name() {
2386
2403
  return this.getStorageProperty("name") || this.defaultName;
2387
2404
  }
2388
2405
  set name(value) {
2389
2406
  this.setStorageProperty("name", value);
2390
2407
  }
2408
+ /**
2409
+ * The surname of the character.
2410
+ * If you set undefined, it will return the default surname.
2411
+ */
2391
2412
  get surname() {
2392
2413
  return this.getStorageProperty("surname") || this.defaultSurname;
2393
2414
  }
2394
2415
  set surname(value) {
2395
2416
  this.setStorageProperty("surname", value);
2396
2417
  }
2418
+ /**
2419
+ * The age of the character.
2420
+ * If you set undefined, it will return the default age.
2421
+ */
2397
2422
  get age() {
2398
2423
  return this.getStorageProperty("age") || this.defaultAge;
2399
2424
  }
2400
2425
  set age(value) {
2401
2426
  this.setStorageProperty("age", value);
2402
2427
  }
2428
+ /**
2429
+ * The icon of the character.
2430
+ */
2403
2431
  get icon() {
2404
2432
  return this._icon;
2405
2433
  }
2434
+ /**
2435
+ * The color of the character.
2436
+ */
2406
2437
  get color() {
2407
2438
  return this._color;
2408
2439
  }
@@ -2431,17 +2462,27 @@ var ChoiceMenuOptionLabel = class {
2431
2462
 
2432
2463
  // src/classes/DialogueBaseModel.ts
2433
2464
  var DialogueBaseModel = class {
2434
- constructor(text, character) {
2465
+ /**
2466
+ * @param text The text of the dialogue.
2467
+ * @param character The id of the character that is speaking.
2468
+ * @param oltherParams Other parameters that can be stored in the dialogue.
2469
+ */
2470
+ constructor(text, character, oltherParams = {}) {
2435
2471
  /**
2436
2472
  * The text of the dialogue.
2437
2473
  */
2438
2474
  this.text = "";
2475
+ /**
2476
+ * Other parameters that can be stored in the dialogue.
2477
+ */
2478
+ this.oltherParams = {};
2439
2479
  this.text = text;
2440
2480
  if (typeof character === "string") {
2441
2481
  this.characterId = character;
2442
2482
  } else {
2443
2483
  this.characterId = character == null ? void 0 : character.id;
2444
2484
  }
2485
+ this.oltherParams = oltherParams;
2445
2486
  }
2446
2487
  };
2447
2488