narrat 0.7.0 → 0.7.1
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/CHANGELOG.md +4 -0
- package/lib/index.esm.js +88 -18
- package/lib/index.js +88 -18
- package/lib/utils/audio-loader.d.ts +2 -0
- package/lib/vm/renpy-vm.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version: 0.7.
|
|
1
|
+
// Version: 0.7.1 - April 26, 2022 12:31:17
|
|
2
2
|
import 'es6-promise/auto';
|
|
3
3
|
import { ref, reactive, readonly, defineComponent, openBlock, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, Fragment, renderList, createBlock, Transition, withCtx, renderSlot, createTextVNode, resolveComponent, toDisplayString, createVNode, TransitionGroup, createApp } from 'vue';
|
|
4
4
|
import { createLogger, createStore } from 'vuex';
|
|
@@ -4197,8 +4197,12 @@ async function loadAudio(key, config) {
|
|
|
4197
4197
|
function changeMusic(ctx, newMusic) {
|
|
4198
4198
|
if (ctx.state.audio.currentMusic) {
|
|
4199
4199
|
const oldMusic = getAudio(ctx.state.audio.currentMusic);
|
|
4200
|
+
const newMusicHowl = getAudio(newMusic);
|
|
4200
4201
|
if (oldMusic) {
|
|
4201
|
-
oldMusic
|
|
4202
|
+
if (oldMusic !== newMusicHowl) {
|
|
4203
|
+
// Stop the previous music if it's a different one
|
|
4204
|
+
oldMusic.stop();
|
|
4205
|
+
}
|
|
4202
4206
|
}
|
|
4203
4207
|
}
|
|
4204
4208
|
ctx.commit('setMusic', newMusic);
|
|
@@ -4217,6 +4221,24 @@ function playAudio(commit, key) {
|
|
|
4217
4221
|
}
|
|
4218
4222
|
function getAudio(key) {
|
|
4219
4223
|
return audio[key];
|
|
4224
|
+
}
|
|
4225
|
+
function stopAudio(commit, key) {
|
|
4226
|
+
const sound = getAudio(key);
|
|
4227
|
+
if (sound) {
|
|
4228
|
+
sound.stop();
|
|
4229
|
+
}
|
|
4230
|
+
else {
|
|
4231
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
function pauseAudio(commit, key) {
|
|
4235
|
+
const sound = getAudio(key);
|
|
4236
|
+
if (sound) {
|
|
4237
|
+
sound.pause();
|
|
4238
|
+
}
|
|
4239
|
+
else {
|
|
4240
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4241
|
+
}
|
|
4220
4242
|
}
|
|
4221
4243
|
|
|
4222
4244
|
function debounce(func, waitMilliseconds = 50, options = {}) {
|
|
@@ -4850,12 +4872,36 @@ async function runCommand(context, cmd, choices) {
|
|
|
4850
4872
|
});
|
|
4851
4873
|
return dispatch('nextLine');
|
|
4852
4874
|
case 'play':
|
|
4853
|
-
const
|
|
4854
|
-
if (
|
|
4855
|
-
changeMusic(context,
|
|
4875
|
+
const playOptions = cmd.options;
|
|
4876
|
+
if (playOptions.mode === 'music') {
|
|
4877
|
+
changeMusic(context, playOptions.audio);
|
|
4856
4878
|
}
|
|
4857
4879
|
else {
|
|
4858
|
-
playAudio(context.commit,
|
|
4880
|
+
playAudio(context.commit, playOptions.audio);
|
|
4881
|
+
}
|
|
4882
|
+
return dispatch('nextLine');
|
|
4883
|
+
case 'stop':
|
|
4884
|
+
const stopOptions = cmd.options;
|
|
4885
|
+
if (stopOptions.mode === 'music') {
|
|
4886
|
+
stopAudio(commit, context.state.audio.currentMusic);
|
|
4887
|
+
}
|
|
4888
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4889
|
+
stopAudio(commit, stopOptions.audio);
|
|
4890
|
+
}
|
|
4891
|
+
else {
|
|
4892
|
+
error(commit, `stop option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4893
|
+
}
|
|
4894
|
+
return dispatch('nextLine');
|
|
4895
|
+
case 'pause':
|
|
4896
|
+
const pauseOptions = cmd.options;
|
|
4897
|
+
if (pauseOptions.mode === 'music') {
|
|
4898
|
+
pauseAudio(commit, context.state.audio.currentMusic);
|
|
4899
|
+
}
|
|
4900
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4901
|
+
pauseAudio(commit, stopOptions.audio);
|
|
4902
|
+
}
|
|
4903
|
+
else {
|
|
4904
|
+
error(commit, `pause first option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4859
4905
|
}
|
|
4860
4906
|
return dispatch('nextLine');
|
|
4861
4907
|
case 'wait':
|
|
@@ -4942,7 +4988,7 @@ async function playerAnswered(context, choiceIndex) {
|
|
|
4942
4988
|
const dialog = {
|
|
4943
4989
|
speaker: 'player',
|
|
4944
4990
|
text: playerText,
|
|
4945
|
-
interactive:
|
|
4991
|
+
interactive: false,
|
|
4946
4992
|
};
|
|
4947
4993
|
commit('addDialog', { dialog });
|
|
4948
4994
|
if (newBranch) {
|
|
@@ -5022,9 +5068,10 @@ async function textCommand(commit, dialog) {
|
|
|
5022
5068
|
dialog,
|
|
5023
5069
|
});
|
|
5024
5070
|
}
|
|
5025
|
-
async function nextLine(
|
|
5071
|
+
async function nextLine(ctx) {
|
|
5072
|
+
const { state, getters, dispatch, commit } = ctx;
|
|
5026
5073
|
if (state.machine.stack.length === 0) {
|
|
5027
|
-
finishGame(
|
|
5074
|
+
finishGame(ctx);
|
|
5028
5075
|
return;
|
|
5029
5076
|
}
|
|
5030
5077
|
const machineHead = getters.machineHead;
|
|
@@ -5037,19 +5084,21 @@ async function nextLine({ state, getters, dispatch, commit, }) {
|
|
|
5037
5084
|
return dispatch('nextLine');
|
|
5038
5085
|
}
|
|
5039
5086
|
if (state.machine.stack.length === 0) {
|
|
5040
|
-
finishGame(
|
|
5087
|
+
finishGame(ctx);
|
|
5041
5088
|
}
|
|
5042
5089
|
else {
|
|
5043
5090
|
return dispatch('runLine');
|
|
5044
5091
|
}
|
|
5045
5092
|
}
|
|
5046
|
-
function finishGame(commit) {
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5093
|
+
function finishGame({ commit, state }) {
|
|
5094
|
+
if (state.options.debug) {
|
|
5095
|
+
commit('addDialog', {
|
|
5096
|
+
dialog: {
|
|
5097
|
+
speaker: 'game',
|
|
5098
|
+
text: '[DEBUG] Game Script is finished. This is the end of the game flow. This message only appears in debug mode.',
|
|
5099
|
+
},
|
|
5100
|
+
});
|
|
5101
|
+
}
|
|
5053
5102
|
}
|
|
5054
5103
|
|
|
5055
5104
|
function jump(ctx) {
|
|
@@ -5151,6 +5200,24 @@ function play(ctx) {
|
|
|
5151
5200
|
};
|
|
5152
5201
|
ctx.currentLine++;
|
|
5153
5202
|
}
|
|
5203
|
+
function stop(ctx) {
|
|
5204
|
+
const { command } = ctx;
|
|
5205
|
+
command.commandType = 'stop';
|
|
5206
|
+
command.options = {
|
|
5207
|
+
mode: command.args[0],
|
|
5208
|
+
audio: command.args[1],
|
|
5209
|
+
};
|
|
5210
|
+
ctx.currentLine++;
|
|
5211
|
+
}
|
|
5212
|
+
function pause(ctx) {
|
|
5213
|
+
const { command } = ctx;
|
|
5214
|
+
command.commandType = 'pause';
|
|
5215
|
+
command.options = {
|
|
5216
|
+
mode: command.args[0],
|
|
5217
|
+
audio: command.args[1],
|
|
5218
|
+
};
|
|
5219
|
+
ctx.currentLine++;
|
|
5220
|
+
}
|
|
5154
5221
|
function wait(ctx) {
|
|
5155
5222
|
const { command } = ctx;
|
|
5156
5223
|
command.commandType = 'wait';
|
|
@@ -5182,6 +5249,8 @@ const parserFunctions = {
|
|
|
5182
5249
|
set_button: setButton,
|
|
5183
5250
|
clear_dialog: clearDialog,
|
|
5184
5251
|
play,
|
|
5252
|
+
stop,
|
|
5253
|
+
pause,
|
|
5185
5254
|
wait,
|
|
5186
5255
|
text,
|
|
5187
5256
|
add_level,
|
|
@@ -5478,6 +5547,7 @@ function setupStore(options) {
|
|
|
5478
5547
|
},
|
|
5479
5548
|
notifications: {},
|
|
5480
5549
|
hudStats: {},
|
|
5550
|
+
options,
|
|
5481
5551
|
},
|
|
5482
5552
|
getters: {
|
|
5483
5553
|
machineHead(state) {
|
|
@@ -5732,7 +5802,7 @@ async function startApp(config, options) {
|
|
|
5732
5802
|
mousePos.x = e.clientX;
|
|
5733
5803
|
mousePos.y = e.clientY;
|
|
5734
5804
|
});
|
|
5735
|
-
console.log('%c Narrat game engine – 0.7.
|
|
5805
|
+
console.log('%c Narrat game engine – 0.7.1 - April 26, 2022 12:31:17', 'background: #222; color: #bada55');
|
|
5736
5806
|
const storeSetup = setupStore(options);
|
|
5737
5807
|
store$1 = storeSetup.store;
|
|
5738
5808
|
app = createApp(script$8, {
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version: 0.7.
|
|
1
|
+
// Version: 0.7.1 - April 26, 2022 12:31:17
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -4201,8 +4201,12 @@ async function loadAudio(key, config) {
|
|
|
4201
4201
|
function changeMusic(ctx, newMusic) {
|
|
4202
4202
|
if (ctx.state.audio.currentMusic) {
|
|
4203
4203
|
const oldMusic = getAudio(ctx.state.audio.currentMusic);
|
|
4204
|
+
const newMusicHowl = getAudio(newMusic);
|
|
4204
4205
|
if (oldMusic) {
|
|
4205
|
-
oldMusic
|
|
4206
|
+
if (oldMusic !== newMusicHowl) {
|
|
4207
|
+
// Stop the previous music if it's a different one
|
|
4208
|
+
oldMusic.stop();
|
|
4209
|
+
}
|
|
4206
4210
|
}
|
|
4207
4211
|
}
|
|
4208
4212
|
ctx.commit('setMusic', newMusic);
|
|
@@ -4221,6 +4225,24 @@ function playAudio(commit, key) {
|
|
|
4221
4225
|
}
|
|
4222
4226
|
function getAudio(key) {
|
|
4223
4227
|
return audio[key];
|
|
4228
|
+
}
|
|
4229
|
+
function stopAudio(commit, key) {
|
|
4230
|
+
const sound = getAudio(key);
|
|
4231
|
+
if (sound) {
|
|
4232
|
+
sound.stop();
|
|
4233
|
+
}
|
|
4234
|
+
else {
|
|
4235
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
function pauseAudio(commit, key) {
|
|
4239
|
+
const sound = getAudio(key);
|
|
4240
|
+
if (sound) {
|
|
4241
|
+
sound.pause();
|
|
4242
|
+
}
|
|
4243
|
+
else {
|
|
4244
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4245
|
+
}
|
|
4224
4246
|
}
|
|
4225
4247
|
|
|
4226
4248
|
function debounce(func, waitMilliseconds = 50, options = {}) {
|
|
@@ -4854,12 +4876,36 @@ async function runCommand(context, cmd, choices) {
|
|
|
4854
4876
|
});
|
|
4855
4877
|
return dispatch('nextLine');
|
|
4856
4878
|
case 'play':
|
|
4857
|
-
const
|
|
4858
|
-
if (
|
|
4859
|
-
changeMusic(context,
|
|
4879
|
+
const playOptions = cmd.options;
|
|
4880
|
+
if (playOptions.mode === 'music') {
|
|
4881
|
+
changeMusic(context, playOptions.audio);
|
|
4860
4882
|
}
|
|
4861
4883
|
else {
|
|
4862
|
-
playAudio(context.commit,
|
|
4884
|
+
playAudio(context.commit, playOptions.audio);
|
|
4885
|
+
}
|
|
4886
|
+
return dispatch('nextLine');
|
|
4887
|
+
case 'stop':
|
|
4888
|
+
const stopOptions = cmd.options;
|
|
4889
|
+
if (stopOptions.mode === 'music') {
|
|
4890
|
+
stopAudio(commit, context.state.audio.currentMusic);
|
|
4891
|
+
}
|
|
4892
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4893
|
+
stopAudio(commit, stopOptions.audio);
|
|
4894
|
+
}
|
|
4895
|
+
else {
|
|
4896
|
+
error(commit, `stop option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4897
|
+
}
|
|
4898
|
+
return dispatch('nextLine');
|
|
4899
|
+
case 'pause':
|
|
4900
|
+
const pauseOptions = cmd.options;
|
|
4901
|
+
if (pauseOptions.mode === 'music') {
|
|
4902
|
+
pauseAudio(commit, context.state.audio.currentMusic);
|
|
4903
|
+
}
|
|
4904
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4905
|
+
pauseAudio(commit, stopOptions.audio);
|
|
4906
|
+
}
|
|
4907
|
+
else {
|
|
4908
|
+
error(commit, `pause first option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4863
4909
|
}
|
|
4864
4910
|
return dispatch('nextLine');
|
|
4865
4911
|
case 'wait':
|
|
@@ -4946,7 +4992,7 @@ async function playerAnswered(context, choiceIndex) {
|
|
|
4946
4992
|
const dialog = {
|
|
4947
4993
|
speaker: 'player',
|
|
4948
4994
|
text: playerText,
|
|
4949
|
-
interactive:
|
|
4995
|
+
interactive: false,
|
|
4950
4996
|
};
|
|
4951
4997
|
commit('addDialog', { dialog });
|
|
4952
4998
|
if (newBranch) {
|
|
@@ -5026,9 +5072,10 @@ async function textCommand(commit, dialog) {
|
|
|
5026
5072
|
dialog,
|
|
5027
5073
|
});
|
|
5028
5074
|
}
|
|
5029
|
-
async function nextLine(
|
|
5075
|
+
async function nextLine(ctx) {
|
|
5076
|
+
const { state, getters, dispatch, commit } = ctx;
|
|
5030
5077
|
if (state.machine.stack.length === 0) {
|
|
5031
|
-
finishGame(
|
|
5078
|
+
finishGame(ctx);
|
|
5032
5079
|
return;
|
|
5033
5080
|
}
|
|
5034
5081
|
const machineHead = getters.machineHead;
|
|
@@ -5041,19 +5088,21 @@ async function nextLine({ state, getters, dispatch, commit, }) {
|
|
|
5041
5088
|
return dispatch('nextLine');
|
|
5042
5089
|
}
|
|
5043
5090
|
if (state.machine.stack.length === 0) {
|
|
5044
|
-
finishGame(
|
|
5091
|
+
finishGame(ctx);
|
|
5045
5092
|
}
|
|
5046
5093
|
else {
|
|
5047
5094
|
return dispatch('runLine');
|
|
5048
5095
|
}
|
|
5049
5096
|
}
|
|
5050
|
-
function finishGame(commit) {
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5097
|
+
function finishGame({ commit, state }) {
|
|
5098
|
+
if (state.options.debug) {
|
|
5099
|
+
commit('addDialog', {
|
|
5100
|
+
dialog: {
|
|
5101
|
+
speaker: 'game',
|
|
5102
|
+
text: '[DEBUG] Game Script is finished. This is the end of the game flow. This message only appears in debug mode.',
|
|
5103
|
+
},
|
|
5104
|
+
});
|
|
5105
|
+
}
|
|
5057
5106
|
}
|
|
5058
5107
|
|
|
5059
5108
|
function jump(ctx) {
|
|
@@ -5155,6 +5204,24 @@ function play(ctx) {
|
|
|
5155
5204
|
};
|
|
5156
5205
|
ctx.currentLine++;
|
|
5157
5206
|
}
|
|
5207
|
+
function stop(ctx) {
|
|
5208
|
+
const { command } = ctx;
|
|
5209
|
+
command.commandType = 'stop';
|
|
5210
|
+
command.options = {
|
|
5211
|
+
mode: command.args[0],
|
|
5212
|
+
audio: command.args[1],
|
|
5213
|
+
};
|
|
5214
|
+
ctx.currentLine++;
|
|
5215
|
+
}
|
|
5216
|
+
function pause(ctx) {
|
|
5217
|
+
const { command } = ctx;
|
|
5218
|
+
command.commandType = 'pause';
|
|
5219
|
+
command.options = {
|
|
5220
|
+
mode: command.args[0],
|
|
5221
|
+
audio: command.args[1],
|
|
5222
|
+
};
|
|
5223
|
+
ctx.currentLine++;
|
|
5224
|
+
}
|
|
5158
5225
|
function wait(ctx) {
|
|
5159
5226
|
const { command } = ctx;
|
|
5160
5227
|
command.commandType = 'wait';
|
|
@@ -5186,6 +5253,8 @@ const parserFunctions = {
|
|
|
5186
5253
|
set_button: setButton,
|
|
5187
5254
|
clear_dialog: clearDialog,
|
|
5188
5255
|
play,
|
|
5256
|
+
stop,
|
|
5257
|
+
pause,
|
|
5189
5258
|
wait,
|
|
5190
5259
|
text,
|
|
5191
5260
|
add_level,
|
|
@@ -5482,6 +5551,7 @@ function setupStore(options) {
|
|
|
5482
5551
|
},
|
|
5483
5552
|
notifications: {},
|
|
5484
5553
|
hudStats: {},
|
|
5554
|
+
options,
|
|
5485
5555
|
},
|
|
5486
5556
|
getters: {
|
|
5487
5557
|
machineHead(state) {
|
|
@@ -5736,7 +5806,7 @@ async function startApp(config, options) {
|
|
|
5736
5806
|
mousePos.x = e.clientX;
|
|
5737
5807
|
mousePos.y = e.clientY;
|
|
5738
5808
|
});
|
|
5739
|
-
console.log('%c Narrat game engine – 0.7.
|
|
5809
|
+
console.log('%c Narrat game engine – 0.7.1 - April 26, 2022 12:31:17', 'background: #222; color: #bada55');
|
|
5740
5810
|
const storeSetup = setupStore(options);
|
|
5741
5811
|
store$1 = storeSetup.store;
|
|
5742
5812
|
app = vue.createApp(script$8, {
|
|
@@ -10,3 +10,5 @@ export declare function loadAudio(key: string, config: AudioConfig | MusicConfig
|
|
|
10
10
|
export declare function changeMusic(ctx: ActionContext<State, State>, newMusic: string): void;
|
|
11
11
|
export declare function playAudio(commit: Commit, key: string): void;
|
|
12
12
|
export declare function getAudio(key: string): Howl | undefined;
|
|
13
|
+
export declare function stopAudio(commit: Commit, key: string): void;
|
|
14
|
+
export declare function pauseAudio(commit: Commit, key: string): void;
|
package/lib/vm/renpy-vm.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export declare function runCommand(context: ActionContext<State, State>, cmd: Pa
|
|
|
6
6
|
export declare function playerAnswered(context: ActionContext<State, State>, choiceIndex: number): Promise<void>;
|
|
7
7
|
export declare function runChoice(context: ActionContext<State, State>, cmd: Parser.Command): Promise<void>;
|
|
8
8
|
export declare function textCommand(commit: Commit, dialog: DialogKey): Promise<void>;
|
|
9
|
-
export declare function nextLine(
|
|
10
|
-
export declare function finishGame(commit:
|
|
9
|
+
export declare function nextLine(ctx: ActionContext<State, State>): Promise<any>;
|
|
10
|
+
export declare function finishGame({ commit, state }: ActionContext<State, State>): void;
|