@drincs/pixi-vn 0.3.2 → 0.3.3

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
@@ -230,9 +230,23 @@ interface IStoratedChoiceMenuOptionLabel {
230
230
 
231
231
  /**
232
232
  * Base class for all dialogue models. I suggest you extend this class to create your own dialogue models.
233
+ * @example
234
+ * ```typescript
235
+ * export class DialogueModel extends DialogueBaseModel {
236
+ * constructor(
237
+ * character: CharacterBaseModel | string,
238
+ * text: string,
239
+ * emotion: string
240
+ * ) {
241
+ * super(character, text);
242
+ * this.emotion = emotion;
243
+ * }
244
+ * emotion = ""
245
+ * }
246
+ * ```
233
247
  */
234
- declare class DialogueBaseModel {
235
- constructor(text: string, character: string | CharacterBaseModel | undefined);
248
+ declare class DialogueBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel> {
249
+ constructor(text: string, character: string | TCharacter | undefined);
236
250
  /**
237
251
  * The text of the dialogue.
238
252
  */
@@ -943,12 +957,13 @@ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
943
957
  * character: "characterId",
944
958
  * text: "Hello World"
945
959
  * })
960
+ * setDialogue(new DialogueBaseModel("Hello World", character))
946
961
  * ```
947
962
  */
948
- declare function setDialogue<T extends CharacterBaseModel = CharacterBaseModel>(props: {
949
- character: string | T;
963
+ declare function setDialogue<TCharacter extends CharacterBaseModel = CharacterBaseModel, TDialogue extends DialogueBaseModel = DialogueBaseModel>(props: {
964
+ character: string | TCharacter;
950
965
  text: string;
951
- } | string): void;
966
+ } | string | TDialogue): void;
952
967
  /**
953
968
  * Get the dialogue to be shown in the game
954
969
  * @returns Dialogue to be shown in the game
@@ -1118,7 +1133,7 @@ declare class GameStepManager {
1118
1133
  * stepHistory is a list of label events and steps that occurred during the progression of the steps.
1119
1134
  */
1120
1135
  private static _stepsHistory;
1121
- static get stepsHistory(): IHistoryStep<DialogueBaseModel>[];
1136
+ static get stepsHistory(): IHistoryStep<DialogueBaseModel<CharacterBaseModel>>[];
1122
1137
  private static _lastStepIndex;
1123
1138
  /**
1124
1139
  * 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
@@ -230,9 +230,23 @@ interface IStoratedChoiceMenuOptionLabel {
230
230
 
231
231
  /**
232
232
  * Base class for all dialogue models. I suggest you extend this class to create your own dialogue models.
233
+ * @example
234
+ * ```typescript
235
+ * export class DialogueModel extends DialogueBaseModel {
236
+ * constructor(
237
+ * character: CharacterBaseModel | string,
238
+ * text: string,
239
+ * emotion: string
240
+ * ) {
241
+ * super(character, text);
242
+ * this.emotion = emotion;
243
+ * }
244
+ * emotion = ""
245
+ * }
246
+ * ```
233
247
  */
234
- declare class DialogueBaseModel {
235
- constructor(text: string, character: string | CharacterBaseModel | undefined);
248
+ declare class DialogueBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel> {
249
+ constructor(text: string, character: string | TCharacter | undefined);
236
250
  /**
237
251
  * The text of the dialogue.
238
252
  */
@@ -943,12 +957,13 @@ type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[];
943
957
  * character: "characterId",
944
958
  * text: "Hello World"
945
959
  * })
960
+ * setDialogue(new DialogueBaseModel("Hello World", character))
946
961
  * ```
947
962
  */
948
- declare function setDialogue<T extends CharacterBaseModel = CharacterBaseModel>(props: {
949
- character: string | T;
963
+ declare function setDialogue<TCharacter extends CharacterBaseModel = CharacterBaseModel, TDialogue extends DialogueBaseModel = DialogueBaseModel>(props: {
964
+ character: string | TCharacter;
950
965
  text: string;
951
- } | string): void;
966
+ } | string | TDialogue): void;
952
967
  /**
953
968
  * Get the dialogue to be shown in the game
954
969
  * @returns Dialogue to be shown in the game
@@ -1118,7 +1133,7 @@ declare class GameStepManager {
1118
1133
  * stepHistory is a list of label events and steps that occurred during the progression of the steps.
1119
1134
  */
1120
1135
  private static _stepsHistory;
1121
- static get stepsHistory(): IHistoryStep<DialogueBaseModel>[];
1136
+ static get stepsHistory(): IHistoryStep<DialogueBaseModel<CharacterBaseModel>>[];
1122
1137
  private static _lastStepIndex;
1123
1138
  /**
1124
1139
  * 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
  }