narrat 2.0.1 → 2.0.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/narrat.es.js +42 -23
- 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: {
|
|
@@ -36780,16 +36779,24 @@ async function changeMusic(newMusic) {
|
|
|
36780
36779
|
}, audioOptions.musicFadeOutTime * 1e3);
|
|
36781
36780
|
}
|
|
36782
36781
|
}
|
|
36782
|
+
let sound;
|
|
36783
|
+
let newId;
|
|
36784
|
+
if (newMusic) {
|
|
36785
|
+
sound = getAudio(newMusic);
|
|
36786
|
+
if (!sound) {
|
|
36787
|
+
throw new Error(`Could not find music ${newMusic}`);
|
|
36788
|
+
}
|
|
36789
|
+
sound.volume(0);
|
|
36790
|
+
newId = sound.play();
|
|
36791
|
+
sound.pause();
|
|
36792
|
+
audio2.setMusic(newMusic, newId);
|
|
36793
|
+
}
|
|
36783
36794
|
if (audio2.currentMusic) {
|
|
36784
36795
|
await timeout(audioOptions.musicFadeInDelay * 1e3);
|
|
36785
36796
|
}
|
|
36786
|
-
if (
|
|
36787
|
-
|
|
36788
|
-
|
|
36789
|
-
const newId = sound.play();
|
|
36790
|
-
sound.fade(0, 1, audioOptions.musicFadeInTime * 1e3, newId);
|
|
36791
|
-
audio2.setMusic(newMusic, newId);
|
|
36792
|
-
}
|
|
36797
|
+
if (sound && useAudio().musicHowlId === newId) {
|
|
36798
|
+
sound.play();
|
|
36799
|
+
sound.fade(0, 1, audioOptions.musicFadeInTime * 1e3, newId);
|
|
36793
36800
|
}
|
|
36794
36801
|
}
|
|
36795
36802
|
function playAudio(key) {
|
|
@@ -36805,9 +36812,13 @@ function getAudio(key) {
|
|
|
36805
36812
|
return audio[key];
|
|
36806
36813
|
}
|
|
36807
36814
|
function stopAudio(key) {
|
|
36808
|
-
|
|
36809
|
-
|
|
36810
|
-
|
|
36815
|
+
if (key === useAudio().currentMusic) {
|
|
36816
|
+
useAudio().stopMusic();
|
|
36817
|
+
} else {
|
|
36818
|
+
const sound = getAudio(key);
|
|
36819
|
+
if (sound) {
|
|
36820
|
+
sound.stop();
|
|
36821
|
+
}
|
|
36811
36822
|
}
|
|
36812
36823
|
}
|
|
36813
36824
|
function pauseAudio(key) {
|
|
@@ -36816,6 +36827,10 @@ function pauseAudio(key) {
|
|
|
36816
36827
|
sound.pause();
|
|
36817
36828
|
}
|
|
36818
36829
|
}
|
|
36830
|
+
const SAVE_FILE = "gameSave";
|
|
36831
|
+
function saveGame(object) {
|
|
36832
|
+
localStorage.setItem(SAVE_FILE, JSON.stringify(object));
|
|
36833
|
+
}
|
|
36819
36834
|
function randomId() {
|
|
36820
36835
|
return `${Date.now() - Math.floor(Math.random() * 99999999)}`;
|
|
36821
36836
|
}
|
|
@@ -38327,7 +38342,7 @@ const useMain = defineStore("main", {
|
|
|
38327
38342
|
inventory: inventoryStore.generateSaveData(),
|
|
38328
38343
|
quests: useQuests().generateSaveData()
|
|
38329
38344
|
};
|
|
38330
|
-
|
|
38345
|
+
saveGame(save);
|
|
38331
38346
|
},
|
|
38332
38347
|
setLoadedData(save) {
|
|
38333
38348
|
const screensStore = useScreens();
|
|
@@ -40022,17 +40037,20 @@ const _sfc_main$1 = defineComponent({
|
|
|
40022
40037
|
{
|
|
40023
40038
|
id: "skills",
|
|
40024
40039
|
cssId: "skills-menu-button",
|
|
40025
|
-
text: "Skills"
|
|
40040
|
+
text: "Skills",
|
|
40041
|
+
condition: () => this.showSkills
|
|
40026
40042
|
},
|
|
40027
40043
|
{
|
|
40028
40044
|
id: "inventory",
|
|
40029
40045
|
cssId: "inventory-menu-button",
|
|
40030
|
-
text: "Items"
|
|
40046
|
+
text: "Items",
|
|
40047
|
+
condition: () => this.showInventory
|
|
40031
40048
|
},
|
|
40032
40049
|
{
|
|
40033
40050
|
id: "quests",
|
|
40034
40051
|
cssId: "quests-menu-button",
|
|
40035
|
-
text: "Quests"
|
|
40052
|
+
text: "Quests",
|
|
40053
|
+
condition: () => this.showQuests
|
|
40036
40054
|
}
|
|
40037
40055
|
],
|
|
40038
40056
|
activeMenu: false
|
|
@@ -40079,18 +40097,18 @@ const _sfc_main$1 = defineComponent({
|
|
|
40079
40097
|
},
|
|
40080
40098
|
computed: {
|
|
40081
40099
|
buttonsToShow() {
|
|
40082
|
-
return this.buttons.
|
|
40083
|
-
if (button.condition) {
|
|
40084
|
-
return button.condition();
|
|
40085
|
-
} else {
|
|
40086
|
-
return true;
|
|
40087
|
-
}
|
|
40088
|
-
}).map((button) => {
|
|
40100
|
+
return this.buttons.map((button) => {
|
|
40089
40101
|
const buttonData = getConfig().menuButtons[button.id] || {};
|
|
40090
40102
|
return {
|
|
40091
40103
|
...button,
|
|
40092
40104
|
...buttonData
|
|
40093
40105
|
};
|
|
40106
|
+
}).filter((button) => {
|
|
40107
|
+
if (button.condition) {
|
|
40108
|
+
return button.condition();
|
|
40109
|
+
} else {
|
|
40110
|
+
return true;
|
|
40111
|
+
}
|
|
40094
40112
|
});
|
|
40095
40113
|
},
|
|
40096
40114
|
showSkills() {
|
|
@@ -40787,7 +40805,7 @@ const stopCommand = new CommandPlugin("stop", playCommandArgs, async (cmd) => {
|
|
|
40787
40805
|
if (stopOptions.mode === "music") {
|
|
40788
40806
|
const audioStore = useAudio();
|
|
40789
40807
|
if (audioStore.currentMusic) {
|
|
40790
|
-
|
|
40808
|
+
useAudio().stopMusic();
|
|
40791
40809
|
}
|
|
40792
40810
|
} else if (stopOptions.mode === "sound" && stopOptions.audio) {
|
|
40793
40811
|
stopAudio(stopOptions.audio);
|
|
@@ -41471,3 +41489,4 @@ function addCommand(command) {
|
|
|
41471
41489
|
vm.addCommand(command);
|
|
41472
41490
|
}
|
|
41473
41491
|
export { CommandPlugin, NarratPlugin, addCommand, aspectRatioFit, generateParser, getConfig, registerPlugin, startApp };
|
|
41492
|
+
//# sourceMappingURL=narrat.es.js.map
|