narrat 2.0.2 → 2.0.5
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/narrat.es.js +31 -14
- package/dist/narrat.es.js.map +1 -0
- package/dist/narrat.umd.js +71 -70
- package/dist/narrat.umd.js.map +1 -0
- package/dist/utils/save-helpers.d.ts +3 -0
- package/package.json +1 -1
package/dist/narrat.es.js
CHANGED
|
@@ -34291,7 +34291,6 @@ ws.exports.parseJSONPointer;
|
|
|
34291
34291
|
ws.exports.revertJSONPatch;
|
|
34292
34292
|
ws.exports.setIn;
|
|
34293
34293
|
ws.exports.updateIn;
|
|
34294
|
-
const SAVE_FILE = "gameSave";
|
|
34295
34294
|
const defaultConfig = {
|
|
34296
34295
|
gameTitle: "Narrat Game Example",
|
|
34297
34296
|
images: {
|
|
@@ -36696,8 +36695,9 @@ const useAudio = defineStore("audio", {
|
|
|
36696
36695
|
actions: {
|
|
36697
36696
|
stopMusic() {
|
|
36698
36697
|
if (this.currentMusic) {
|
|
36699
|
-
|
|
36698
|
+
const music = this.currentMusic;
|
|
36700
36699
|
this.currentMusic = void 0;
|
|
36700
|
+
stopAudio(music);
|
|
36701
36701
|
}
|
|
36702
36702
|
},
|
|
36703
36703
|
setMusic(music, soundId) {
|
|
@@ -36780,16 +36780,24 @@ async function changeMusic(newMusic) {
|
|
|
36780
36780
|
}, audioOptions.musicFadeOutTime * 1e3);
|
|
36781
36781
|
}
|
|
36782
36782
|
}
|
|
36783
|
+
let sound;
|
|
36784
|
+
let newId;
|
|
36785
|
+
if (newMusic) {
|
|
36786
|
+
sound = getAudio(newMusic);
|
|
36787
|
+
if (!sound) {
|
|
36788
|
+
throw new Error(`Could not find music ${newMusic}`);
|
|
36789
|
+
}
|
|
36790
|
+
sound.volume(0);
|
|
36791
|
+
newId = sound.play();
|
|
36792
|
+
sound.pause();
|
|
36793
|
+
audio2.setMusic(newMusic, newId);
|
|
36794
|
+
}
|
|
36783
36795
|
if (audio2.currentMusic) {
|
|
36784
36796
|
await timeout(audioOptions.musicFadeInDelay * 1e3);
|
|
36785
36797
|
}
|
|
36786
|
-
if (
|
|
36787
|
-
|
|
36788
|
-
|
|
36789
|
-
const newId = sound.play();
|
|
36790
|
-
sound.fade(0, 1, audioOptions.musicFadeInTime * 1e3, newId);
|
|
36791
|
-
audio2.setMusic(newMusic, newId);
|
|
36792
|
-
}
|
|
36798
|
+
if (sound && useAudio().musicHowlId === newId) {
|
|
36799
|
+
sound.play();
|
|
36800
|
+
sound.fade(0, 1, audioOptions.musicFadeInTime * 1e3, newId);
|
|
36793
36801
|
}
|
|
36794
36802
|
}
|
|
36795
36803
|
function playAudio(key) {
|
|
@@ -36805,9 +36813,13 @@ function getAudio(key) {
|
|
|
36805
36813
|
return audio[key];
|
|
36806
36814
|
}
|
|
36807
36815
|
function stopAudio(key) {
|
|
36808
|
-
|
|
36809
|
-
|
|
36810
|
-
|
|
36816
|
+
if (key === useAudio().currentMusic) {
|
|
36817
|
+
useAudio().stopMusic();
|
|
36818
|
+
} else {
|
|
36819
|
+
const sound = getAudio(key);
|
|
36820
|
+
if (sound) {
|
|
36821
|
+
sound.stop();
|
|
36822
|
+
}
|
|
36811
36823
|
}
|
|
36812
36824
|
}
|
|
36813
36825
|
function pauseAudio(key) {
|
|
@@ -36816,6 +36828,10 @@ function pauseAudio(key) {
|
|
|
36816
36828
|
sound.pause();
|
|
36817
36829
|
}
|
|
36818
36830
|
}
|
|
36831
|
+
const SAVE_FILE = "gameSave";
|
|
36832
|
+
function saveGame(object) {
|
|
36833
|
+
localStorage.setItem(SAVE_FILE, JSON.stringify(object));
|
|
36834
|
+
}
|
|
36819
36835
|
function randomId() {
|
|
36820
36836
|
return `${Date.now() - Math.floor(Math.random() * 99999999)}`;
|
|
36821
36837
|
}
|
|
@@ -38327,7 +38343,7 @@ const useMain = defineStore("main", {
|
|
|
38327
38343
|
inventory: inventoryStore.generateSaveData(),
|
|
38328
38344
|
quests: useQuests().generateSaveData()
|
|
38329
38345
|
};
|
|
38330
|
-
|
|
38346
|
+
saveGame(save);
|
|
38331
38347
|
},
|
|
38332
38348
|
setLoadedData(save) {
|
|
38333
38349
|
const screensStore = useScreens();
|
|
@@ -40790,7 +40806,7 @@ const stopCommand = new CommandPlugin("stop", playCommandArgs, async (cmd) => {
|
|
|
40790
40806
|
if (stopOptions.mode === "music") {
|
|
40791
40807
|
const audioStore = useAudio();
|
|
40792
40808
|
if (audioStore.currentMusic) {
|
|
40793
|
-
|
|
40809
|
+
useAudio().stopMusic();
|
|
40794
40810
|
}
|
|
40795
40811
|
} else if (stopOptions.mode === "sound" && stopOptions.audio) {
|
|
40796
40812
|
stopAudio(stopOptions.audio);
|
|
@@ -41474,3 +41490,4 @@ function addCommand(command) {
|
|
|
41474
41490
|
vm.addCommand(command);
|
|
41475
41491
|
}
|
|
41476
41492
|
export { CommandPlugin, NarratPlugin, addCommand, aspectRatioFit, generateParser, getConfig, registerPlugin, startApp };
|
|
41493
|
+
//# sourceMappingURL=narrat.es.js.map
|