@drincs/pixi-vn 0.4.6 → 0.4.7

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.mjs CHANGED
@@ -1015,31 +1015,31 @@ function loadImages(canvasImages) {
1015
1015
  function removeCanvasElement(tag) {
1016
1016
  GameWindowManager.removeCanvasElement(tag);
1017
1017
  }
1018
- function showImageWithDissolveTransition(tag, imageUrl, speed, priority) {
1018
+ function showWithDissolveTransition(tag, image, speed, priority) {
1019
1019
  return __async(this, null, function* () {
1020
- if (!GameWindowManager.getCanvasElement(tag)) {
1021
- let image2 = addImage(tag, imageUrl);
1022
- image2.alpha = 0;
1023
- let effect2 = new TickerFadeAlpha({
1024
- speed,
1025
- type: "show",
1026
- startOnlyIfHaveTexture: true
1027
- }, 1e4, priority);
1028
- GameWindowManager.addTicker(tag, effect2);
1029
- return image2.load();
1030
- }
1031
- let specialTag = tag + "_temp_disolve";
1020
+ let specialTag = void 0;
1021
+ if (GameWindowManager.getCanvasElement(tag)) {
1022
+ specialTag = tag + "_temp_disolve";
1023
+ GameWindowManager.editTagCanvasElement(tag, specialTag);
1024
+ }
1025
+ let canvasElement;
1026
+ if (typeof image === "string") {
1027
+ canvasElement = addImage(tag, image);
1028
+ } else {
1029
+ canvasElement = image;
1030
+ }
1031
+ image.alpha = 0;
1032
1032
  let effect = new TickerFadeAlpha({
1033
1033
  speed,
1034
1034
  type: "show",
1035
1035
  tagToRemoveAfter: specialTag,
1036
1036
  startOnlyIfHaveTexture: true
1037
1037
  }, 1e4, priority);
1038
- GameWindowManager.editTagCanvasElement(tag, specialTag);
1039
- let image = addImage(tag, imageUrl);
1040
- image.alpha = 0;
1041
1038
  GameWindowManager.addTicker(tag, effect);
1042
- return image.load();
1039
+ if (canvasElement instanceof CanvasImage) {
1040
+ return canvasElement.load();
1041
+ }
1042
+ return;
1043
1043
  });
1044
1044
  }
1045
1045
 
@@ -2006,12 +2006,13 @@ var _GameStepManager = class _GameStepManager {
2006
2006
  /* Run Methods */
2007
2007
  /**
2008
2008
  * Execute the next step and add it to the history.
2009
+ * @param props The props to pass to the step.
2009
2010
  * @returns StepLabelResultType or undefined.
2010
2011
  * @example
2011
2012
  * ```typescript
2012
2013
  * function nextOnClick() {
2013
2014
  * setLoading(true)
2014
- * GameStepManager.runNextStep()
2015
+ * GameStepManager.runNextStep(yourParams)
2015
2016
  * .then((result) => {
2016
2017
  * setUpdate((p) => p + 1)
2017
2018
  * setLoading(false)
@@ -2026,21 +2027,22 @@ var _GameStepManager = class _GameStepManager {
2026
2027
  * }
2027
2028
  * ```
2028
2029
  */
2029
- static runNextStep() {
2030
+ static runNextStep(props) {
2030
2031
  return __async(this, null, function* () {
2031
2032
  if (_GameStepManager._openedLabels.length === 0) {
2032
2033
  console.warn("[Pixi'VN] There are no labels to run");
2033
2034
  return;
2034
2035
  }
2035
2036
  _GameStepManager.increaseCurrentStepIndex();
2036
- return yield _GameStepManager.runCurrentStep();
2037
+ return yield _GameStepManager.runCurrentStep(props);
2037
2038
  });
2038
2039
  }
2039
2040
  /**
2040
2041
  * Execute the current step and add it to the history.
2042
+ * @param props The props to pass to the step.
2041
2043
  * @returns StepLabelResultType or undefined.
2042
2044
  */
2043
- static runCurrentStep() {
2045
+ static runCurrentStep(props) {
2044
2046
  return __async(this, null, function* () {
2045
2047
  if (_GameStepManager.currentLabelId) {
2046
2048
  let lasteStepsLength = _GameStepManager.currentLabelStepIndex;
@@ -2056,12 +2058,12 @@ var _GameStepManager = class _GameStepManager {
2056
2058
  let n = currentLabel.steps.length;
2057
2059
  if (n > lasteStepsLength) {
2058
2060
  let nextStep = currentLabel.steps[lasteStepsLength];
2059
- let result = yield nextStep();
2061
+ let result = yield nextStep(props);
2060
2062
  _GameStepManager.addStepHistory(nextStep);
2061
2063
  return result;
2062
2064
  } else if (n === lasteStepsLength) {
2063
2065
  _GameStepManager.closeCurrentLabel();
2064
- return yield _GameStepManager.runNextStep();
2066
+ return yield _GameStepManager.runNextStep(props);
2065
2067
  } else {
2066
2068
  console.warn("[Pixi'VN] There are no steps to run");
2067
2069
  }
@@ -2072,10 +2074,11 @@ var _GameStepManager = class _GameStepManager {
2072
2074
  * Execute the label and add it to the history.
2073
2075
  * Is a call function in Ren'Py.
2074
2076
  * @param label The label to execute.
2077
+ * @param props The props to pass to the label.
2075
2078
  * @returns StepLabelResultType or undefined.
2076
2079
  * @example
2077
2080
  * ```typescript
2078
- * GameStepManager.callLabel(StartLabel).then((result) => {
2081
+ * GameStepManager.callLabel(StartLabel, yourParams).then((result) => {
2079
2082
  * if (result) {
2080
2083
  * // your code
2081
2084
  * }
@@ -2089,7 +2092,7 @@ var _GameStepManager = class _GameStepManager {
2089
2092
  * })
2090
2093
  * ```
2091
2094
  */
2092
- static callLabel(label) {
2095
+ static callLabel(label, props) {
2093
2096
  return __async(this, null, function* () {
2094
2097
  try {
2095
2098
  if (label instanceof Label) {
@@ -2101,17 +2104,18 @@ var _GameStepManager = class _GameStepManager {
2101
2104
  console.error("[Pixi'VN] Error calling label", e);
2102
2105
  return;
2103
2106
  }
2104
- return yield _GameStepManager.runCurrentStep();
2107
+ return yield _GameStepManager.runCurrentStep(props);
2105
2108
  });
2106
2109
  }
2107
2110
  /**
2108
2111
  * Execute the label, close all labels and add them to the history.
2109
2112
  * Is a jump function in Ren'Py.
2110
2113
  * @param label The label to execute.
2114
+ * @param props The props to pass to the label.
2111
2115
  * @returns StepLabelResultType or undefined.
2112
2116
  * @example
2113
2117
  * ```typescript
2114
- * GameStepManager.jumpLabel(StartLabel).then((result) => {
2118
+ * GameStepManager.jumpLabel(StartLabel, yourParams).then((result) => {
2115
2119
  * if (result) {
2116
2120
  * // your code
2117
2121
  * }
@@ -2125,7 +2129,7 @@ var _GameStepManager = class _GameStepManager {
2125
2129
  * })
2126
2130
  * ```
2127
2131
  */
2128
- static jumpLabel(label) {
2132
+ static jumpLabel(label, props) {
2129
2133
  return __async(this, null, function* () {
2130
2134
  _GameStepManager.closeAllLabels();
2131
2135
  try {
@@ -2138,7 +2142,7 @@ var _GameStepManager = class _GameStepManager {
2138
2142
  console.error("[Pixi'VN] Error jumping label", e);
2139
2143
  return;
2140
2144
  }
2141
- return yield _GameStepManager.runCurrentStep();
2145
+ return yield _GameStepManager.runCurrentStep(props);
2142
2146
  });
2143
2147
  }
2144
2148
  /* After Update Methods */
@@ -2590,7 +2594,7 @@ export {
2590
2594
  setChoiceMenuOptions,
2591
2595
  setDialogue,
2592
2596
  setFlag,
2593
- showImageWithDissolveTransition,
2597
+ showWithDissolveTransition,
2594
2598
  tickerDecorator
2595
2599
  };
2596
2600
  //# sourceMappingURL=index.mjs.map