@turnipxenon/pineapple 5.2.1 → 5.3.0-alpha.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/dist/assets/icons/cursor-chat.svg +46 -0
- package/dist/assets/icons/cursor-open-in-new.svg +8 -0
- package/dist/assets/icons/icon-open-in-new.svg +1 -0
- package/dist/components/dialog_manager/DialogManager.d.ts +8 -2
- package/dist/components/dialog_manager/DialogManager.d.ts.map +1 -1
- package/dist/components/dialog_manager/DialogManager.js +63 -11
- package/dist/components/dialog_manager/DialogManagerStore.d.ts +0 -3
- package/dist/components/dialog_manager/DialogManagerStore.d.ts.map +1 -1
- package/dist/components/dialog_manager/DialogManagerStore.js +1 -3
- package/dist/components/dialog_manager/DialogProcessor.d.ts.map +1 -1
- package/dist/components/dialog_manager/DialogProcessor.js +3 -2
- package/dist/components/dialog_manager/DialogUtils.js +2 -2
- package/dist/components/dialog_manager/IDialogManager.d.ts +4 -2
- package/dist/components/dialog_manager/IDialogManager.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/core/BTreeUtils.d.ts +2 -1
- package/dist/components/dialog_manager/behavior_tree/core/BTreeUtils.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/core/BTreeUtils.js +4 -3
- package/dist/components/dialog_manager/behavior_tree/expression/ExpressionArguments.d.ts +2 -0
- package/dist/components/dialog_manager/behavior_tree/expression/ExpressionArguments.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/expression/ExpressionEvaluator.d.ts +4 -2
- package/dist/components/dialog_manager/behavior_tree/expression/ExpressionEvaluator.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/expression/ExpressionEvaluator.js +8 -6
- package/dist/components/dialog_manager/behavior_tree/expression/OperandNode.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/expression/OperandNode.js +1 -1
- package/dist/components/dialog_manager/behavior_tree/expression/commands/VisitedCountCommand.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/expression/commands/VisitedCountCommand.js +1 -2
- package/dist/components/dialog_manager/behavior_tree/line_core/LineNodeArguments.d.ts +2 -0
- package/dist/components/dialog_manager/behavior_tree/line_core/LineNodeArguments.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/ElseIfNode.js +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/IfNode.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/IfNode.js +1 -2
- package/dist/components/dialog_manager/behavior_tree/line_processors/NormalLineProcessorNode.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/NormalLineProcessorNode.js +2 -3
- package/dist/components/dialog_manager/behavior_tree/line_processors/SetVariableNode.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/SetVariableNode.js +2 -3
- package/dist/components/dialog_manager/behavior_tree/line_processors/commands/DeclareCommand.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/commands/DeclareCommand.js +3 -2
- package/dist/components/dialog_manager/behavior_tree/line_processors/commands/JumpCommand.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/commands/JumpCommand.js +3 -2
- package/dist/components/dialog_manager/behavior_tree/line_processors/commands/UnvisitCommand.d.ts.map +1 -1
- package/dist/components/dialog_manager/behavior_tree/line_processors/commands/UnvisitCommand.js +2 -3
- package/dist/modules/parsnip/ParsnipBlockChildren.svelte +3 -0
- package/dist/modules/parsnip/ParsnipBlockChildren.svelte.d.ts.map +1 -1
- package/dist/modules/parsnip/ParsnipPhrasingChildren.svelte +15 -3
- package/dist/modules/parsnip/ParsnipPhrasingChildren.svelte.d.ts.map +1 -1
- package/dist/modules/parsnip/external-images/ParsnipImage.svelte +111 -0
- package/dist/modules/parsnip/external-images/ParsnipImage.svelte.d.ts +9 -0
- package/dist/modules/parsnip/external-images/ParsnipImage.svelte.d.ts.map +1 -0
- package/dist/modules/parsnip/external-images/ParsnipImageCollection.svelte +62 -0
- package/dist/modules/parsnip/external-images/ParsnipImageCollection.svelte.d.ts +9 -0
- package/dist/modules/parsnip/external-images/ParsnipImageCollection.svelte.d.ts.map +1 -0
- package/dist/modules/parsnip/external-images/externalImages.remote.d.ts +8 -0
- package/dist/modules/parsnip/external-images/externalImages.remote.d.ts.map +1 -0
- package/dist/modules/parsnip/external-images/externalImages.remote.js +50 -0
- package/dist/modules/parsnip/route-util/ParsnipBlog.svelte +2 -1
- package/dist/modules/parsnip/route-util/ParsnipBlog.svelte.d.ts.map +1 -1
- package/dist/modules/parsnip/route-util/slugPageServerLoad.d.ts.map +1 -1
- package/dist/modules/parsnip/route-util/slugPageServerLoad.js +21 -0
- package/dist/scripts/pineapple_fiber/PineappleFiberParser.d.ts.map +1 -1
- package/dist/scripts/pineapple_fiber/PineappleFiberParser.js +19 -0
- package/dist/scripts/pineapple_fiber/TutorialBroken.yarn +143 -0
- package/dist/styles/app.css +30 -2
- package/dist/test/DialogTestUtility.d.ts +8 -0
- package/dist/test/DialogTestUtility.d.ts.map +1 -0
- package/dist/test/DialogTestUtility.js +62 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +2 -0
- package/dist/types/pineapple_fiber/DialogDetail.d.ts +1 -0
- package/dist/types/pineapple_fiber/DialogDetail.d.ts.map +1 -1
- package/dist/types/pineapple_fiber/DialogVariableStore.d.ts.map +1 -1
- package/dist/types/pineapple_fiber/DialogVariableStore.js +41 -13
- package/dist/ui/elements/TextLink.svelte +1 -1
- package/dist/ui/elements/index.d.ts +1 -0
- package/dist/ui/elements/index.d.ts.map +1 -1
- package/dist/ui/elements/index.js +1 -0
- package/dist/ui/modules/NavigationMenu/NavigationControl.svelte +41 -10
- package/dist/ui/modules/NavigationMenu/NavigationControl.svelte.d.ts +3 -1
- package/dist/ui/modules/NavigationMenu/NavigationControl.svelte.d.ts.map +1 -1
- package/dist/ui/modules/NavigationMenu/NavigationMenu.svelte +130 -39
- package/dist/ui/modules/NavigationMenu/NavigationMenu.svelte.d.ts +3 -1
- package/dist/ui/modules/NavigationMenu/NavigationMenu.svelte.d.ts.map +1 -1
- package/dist/ui/modules/modals/general-settings/GeneralSettingsModal.svelte +21 -21
- package/dist/ui/modules/modals/general-settings/GeneralSettingsModal.svelte.d.ts +1 -1
- package/dist/ui/modules/modals/general-settings/GeneralSettingsModal.svelte.d.ts.map +1 -1
- package/dist/ui/modules/universal-overlay/DialogPanel.svelte +80 -6
- package/dist/ui/modules/universal-overlay/DialogPanel.svelte.d.ts.map +1 -1
- package/dist/ui/modules/universal-overlay/SettingsPanel.svelte +132 -75
- package/dist/ui/modules/universal-overlay/SettingsPanel.svelte.d.ts +4 -1
- package/dist/ui/modules/universal-overlay/SettingsPanel.svelte.d.ts.map +1 -1
- package/dist/ui/templates/SeaweedLayout/SeaweedLayout.svelte +0 -3
- package/dist/ui/templates/SeaweedLayout/SeaweedLayout.svelte.d.ts.map +1 -1
- package/dist/ui/templates/blog_template/BlogTemplate.svelte +7 -1
- package/dist/ui/templates/blog_template/BlogTemplateInner.svelte +33 -1
- package/dist/ui/templates/blog_template/BlogTemplateInner.svelte.d.ts.map +1 -1
- package/dist/ui/templates/index.d.ts +1 -0
- package/dist/ui/templates/index.d.ts.map +1 -1
- package/dist/ui/templates/index.js +2 -0
- package/dist/ui/templates/pinya-base/PinyaBase.svelte +1 -1
- package/dist/ui/templates/pinya-base/pinyaBaseRunes.svelte.d.ts +1 -0
- package/dist/ui/templates/pinya-base/pinyaBaseRunes.svelte.d.ts.map +1 -1
- package/dist/util/context/PineappleBaseContext.svelte +6 -2
- package/dist/util/context/PineappleBaseContext.svelte.d.ts.map +1 -1
- package/dist/util/context/pineappleBaseContextDefinitions.svelte.d.ts +2 -0
- package/dist/util/context/pineappleBaseContextDefinitions.svelte.d.ts.map +1 -1
- package/dist/util/context/pineappleBaseContextDefinitions.svelte.js +2 -0
- package/dist/util/localStore.svelte.d.ts +2 -0
- package/dist/util/localStore.svelte.d.ts.map +1 -1
- package/dist/util/localStore.svelte.js +2 -0
- package/dist/yarn/Tutorial.yarn +141 -0
- package/package.json +12 -7
- package/src/lib/styles/app.css +30 -2
- package/dist/assets/icons/chat-cursor.svg +0 -47
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
height="32px"
|
|
4
|
+
viewBox="0 -960 960 960"
|
|
5
|
+
width="32px"
|
|
6
|
+
version="1.1"
|
|
7
|
+
id="svg384"
|
|
8
|
+
sodipodi:docname="chat_FILL0_wght400_GRAD0_opsz48.svg"
|
|
9
|
+
inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
|
|
10
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
11
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
>
|
|
14
|
+
<defs
|
|
15
|
+
id="defs388"/>
|
|
16
|
+
<sodipodi:namedview
|
|
17
|
+
id="namedview386"
|
|
18
|
+
pagecolor="#ffffff"
|
|
19
|
+
bordercolor="#000000"
|
|
20
|
+
borderopacity="0.25"
|
|
21
|
+
inkscape:showpageshadow="2"
|
|
22
|
+
inkscape:pageopacity="0.0"
|
|
23
|
+
inkscape:pagecheckerboard="0"
|
|
24
|
+
inkscape:deskcolor="#d1d1d1"
|
|
25
|
+
showgrid="true"
|
|
26
|
+
inkscape:zoom="6.1650873"
|
|
27
|
+
inkscape:cx="12.084176"
|
|
28
|
+
inkscape:cy="16.220371"
|
|
29
|
+
inkscape:window-width="1920"
|
|
30
|
+
inkscape:window-height="1017"
|
|
31
|
+
inkscape:window-x="-8"
|
|
32
|
+
inkscape:window-y="-8"
|
|
33
|
+
inkscape:window-maximized="1"
|
|
34
|
+
inkscape:current-layer="svg384">
|
|
35
|
+
<inkscape:grid
|
|
36
|
+
type="xygrid"
|
|
37
|
+
id="grid390"/>
|
|
38
|
+
</sodipodi:namedview>
|
|
39
|
+
<path
|
|
40
|
+
transform="translate(540,-400) translate(-480,480)"
|
|
41
|
+
d="m 288.1745,-415.25889 h 250.17242 v -47.95638 H 288.1745 Z m 0,-103.90548 h 383.651 v -47.95638 h -383.651 z m 0,-103.90548 h 383.651 v -47.95638 h -383.651 z m -127.88367,462.77902 v -591.46196 q 0,-19.18255 14.38692,-33.56946 14.38691,-14.38692 33.56946,-14.38692 h 543.50558 q 19.18255,0 33.56946,14.38692 14.38692,14.38691 14.38692,33.56946 v 415.62191 q 0,19.18255 -14.38692,33.56947 -14.38691,14.38691 -33.56946,14.38691 H 288.1745 Z M 267.3934,-336.13088 H 751.75279 V -751.75279 H 208.24721 v 479.56375 z m -59.14619,0 v -415.62191 z"
|
|
42
|
+
fill="#fff"
|
|
43
|
+
id="path382"
|
|
44
|
+
style="stroke-width:40; stroke: #000; paint-order: stroke"/>
|
|
45
|
+
<polygon points="90,-870 90,-670 270,-830" fill="#000000"/>
|
|
46
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="32px" viewBox="0 -960 960 960" width="32px">
|
|
2
|
+
<!-- <rect x="0" y="-960" width="960" height="960" rx="160" fill="#B8A272" fill-opacity="0.85"/>-->
|
|
3
|
+
<polygon points="90,-870 90,-670 270,-830" fill="#000000"/>
|
|
4
|
+
<path fill="#fff"
|
|
5
|
+
transform="translate(520,-440) scale(0.9) translate(-480,480)"
|
|
6
|
+
d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"
|
|
7
|
+
style="stroke-width:40; stroke: #000; paint-order: stroke"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000000"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"/></svg>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DialogManager is the object we want to interact with in Svelte
|
|
3
3
|
*/
|
|
4
|
+
import { type DialogMapStore } from "../../types/pineapple_fiber/DialogVariableStore";
|
|
4
5
|
import type { DialogDetail } from "../../types/pineapple_fiber/DialogDetail";
|
|
5
6
|
import { DialogState } from "../../types/pineapple_fiber/DialogState";
|
|
6
7
|
import { DialogProcessor } from "./DialogProcessor";
|
|
@@ -27,6 +28,8 @@ export declare class DialogManager implements IDialogManager {
|
|
|
27
28
|
_setDialogChoiceMutex: boolean;
|
|
28
29
|
onSetDialogListeners: OnSetDialogChoiceCallback[];
|
|
29
30
|
enableDialogueOverlayCache: boolean;
|
|
31
|
+
updateRate: number;
|
|
32
|
+
dialogVariableStore: DialogMapStore;
|
|
30
33
|
constructor();
|
|
31
34
|
/**
|
|
32
35
|
* when users interact with the dialog, they can skip the transition like in a game
|
|
@@ -44,7 +47,7 @@ export declare class DialogManager implements IDialogManager {
|
|
|
44
47
|
* of node name conflicts
|
|
45
48
|
* @param newDialogTree
|
|
46
49
|
*/
|
|
47
|
-
setDialogTree: (newDialogTree: DialogDetail[]) => void;
|
|
50
|
+
setDialogTree: (newDialogTree: DialogDetail[], startingNode?: string) => void;
|
|
48
51
|
/**
|
|
49
52
|
* Remember to call this before SetDialogTree
|
|
50
53
|
* and unsubscribe during onDestroy
|
|
@@ -65,6 +68,7 @@ export declare class DialogManager implements IDialogManager {
|
|
|
65
68
|
* you can listen to this!
|
|
66
69
|
*/
|
|
67
70
|
setDialogChoice: (newMessage: DialogDetail | undefined) => void;
|
|
71
|
+
setDialogChoiceById: (dialogId: string) => void;
|
|
68
72
|
_setDialogChoice: () => void;
|
|
69
73
|
setDialogToDefault: () => void;
|
|
70
74
|
/**
|
|
@@ -79,7 +83,9 @@ export declare class DialogManager implements IDialogManager {
|
|
|
79
83
|
update: (timestamp: number) => void;
|
|
80
84
|
enableDialogOverlay(enable: boolean): void;
|
|
81
85
|
toggleDialogOverlay(): void;
|
|
82
|
-
parseAndSetDialogTree(dialogYarn: string): Promise<DialogDetail[]>;
|
|
86
|
+
parseAndSetDialogTree(dialogYarn: string, startingNode?: string): Promise<DialogDetail[]>;
|
|
87
|
+
extendDialogTree(dialogYarn: string, forceNode?: string): Promise<DialogDetail[]>;
|
|
88
|
+
setUpdateRate(newRate: number): void;
|
|
83
89
|
}
|
|
84
90
|
export declare const dialogManager: DialogManager;
|
|
85
91
|
//# sourceMappingURL=DialogManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogManager.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/DialogManager.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"DialogManager.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/DialogManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAExG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAiBrE,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAIpF,MAAM,MAAM,yBAAyB,GAAG,CAAC,UAAU,EAAE,YAAY,KAAK,IAAI,CAAC;AAE3E,qBAAa,aAAc,YAAW,cAAc;IACnD,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAa;IACxD,iBAAi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AE,SAAS,SAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAiBnF,aAAa,CAAC,OAAO,EAAE,MAAM;CAG7B;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
+
import { createNewMapStore } from "../../types/pineapple_fiber/DialogVariableStore";
|
|
13
14
|
import { writable } from "svelte/store";
|
|
14
15
|
import { DialogState } from "../../types/pineapple_fiber/DialogState";
|
|
15
16
|
import { tweened } from "svelte/motion";
|
|
@@ -24,14 +25,14 @@ import AresNeutral from "../../assets/characters/ares/ares_neutral.webp";
|
|
|
24
25
|
import AresSlightlyMad from "../../assets/characters/ares/ares_slightly_mad.webp";
|
|
25
26
|
import AresSurprised from "../../assets/characters/ares/ares_surprised.webp";
|
|
26
27
|
import AresYay from "../../assets/characters/ares/ares_yay.webp";
|
|
27
|
-
import { defaultDialogMessage,
|
|
28
|
+
import { defaultDialogMessage, enableUniversalOverlaySvelte4, } from "./DialogManagerStore";
|
|
28
29
|
import { DialogProcessor } from "./DialogProcessor";
|
|
29
30
|
import { parseYarn } from "../../scripts/pineapple_fiber/PineappleFiberParser";
|
|
30
31
|
const shouldDebugYarn = false;
|
|
31
32
|
export class DialogManager {
|
|
32
33
|
constructor() {
|
|
33
34
|
this.dialogMessageMap = new Map();
|
|
34
|
-
this.currentDialogTree =
|
|
35
|
+
this.currentDialogTree = defaultDialogMessage;
|
|
35
36
|
this.fullCurrentMessage = defaultDialogMessage[0].textContent;
|
|
36
37
|
this.currentMessageMeta = defaultDialogMessage[0];
|
|
37
38
|
this.currentMessage = writable("");
|
|
@@ -56,6 +57,7 @@ export class DialogManager {
|
|
|
56
57
|
this._setDialogChoiceMutex = false;
|
|
57
58
|
this.onSetDialogListeners = [];
|
|
58
59
|
this.enableDialogueOverlayCache = false;
|
|
60
|
+
this.updateRate = 40 / 1000;
|
|
59
61
|
/**
|
|
60
62
|
* when users interact with the dialog, they can skip the transition like in a game
|
|
61
63
|
* note that there is a cool down to this, check out skipNextActiveTime
|
|
@@ -82,7 +84,8 @@ export class DialogManager {
|
|
|
82
84
|
* of node name conflicts
|
|
83
85
|
* @param newDialogTree
|
|
84
86
|
*/
|
|
85
|
-
this.setDialogTree = (newDialogTree) => {
|
|
87
|
+
this.setDialogTree = (newDialogTree, startingNode = "") => {
|
|
88
|
+
var _a;
|
|
86
89
|
this.currentDialogTree = newDialogTree;
|
|
87
90
|
this.dialogMessageMap.clear();
|
|
88
91
|
newDialogTree.map((value) => {
|
|
@@ -102,7 +105,22 @@ export class DialogManager {
|
|
|
102
105
|
this.portraitMap.set(PortraitType.AresSurprised.toString(), AresSurprised);
|
|
103
106
|
this.portraitMap.set(PortraitType.AresYay.toString(), AresYay);
|
|
104
107
|
}
|
|
105
|
-
|
|
108
|
+
if (startingNode) {
|
|
109
|
+
const potentialStartingDialog = newDialogTree.find(t => t.dialogId === startingNode);
|
|
110
|
+
if (potentialStartingDialog) {
|
|
111
|
+
this.setDialogChoice(potentialStartingDialog);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.error("setDialogTree: Starting node not found");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if ((_a = newDialogTree[0].dialogId) === null || _a === void 0 ? void 0 : _a.includes("Setup")) {
|
|
119
|
+
this.setDialogChoice(newDialogTree[1]);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.setDialogChoice(newDialogTree[0]);
|
|
123
|
+
}
|
|
106
124
|
};
|
|
107
125
|
/**
|
|
108
126
|
* Remember to call this before SetDialogTree
|
|
@@ -142,6 +160,15 @@ export class DialogManager {
|
|
|
142
160
|
this._setDialogChoice();
|
|
143
161
|
}
|
|
144
162
|
};
|
|
163
|
+
this.setDialogChoiceById = (dialogId) => {
|
|
164
|
+
const potentialDialog = this.currentDialogTree.find(d => d.dialogId === dialogId);
|
|
165
|
+
if (potentialDialog) {
|
|
166
|
+
this.setDialogChoice(potentialDialog);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
console.error(`setDialogChoiceById: dialog id not found ${dialogId}`);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
145
172
|
this._setDialogChoice = () => {
|
|
146
173
|
var _a, _b;
|
|
147
174
|
const newMessage = this._setDialogChoiceQueue.shift();
|
|
@@ -173,12 +200,12 @@ export class DialogManager {
|
|
|
173
200
|
// save that we visited AND processed the node
|
|
174
201
|
if (this.currentMessageMeta.dialogId) {
|
|
175
202
|
const key = `+${this.currentMessageMeta.dialogId}`;
|
|
176
|
-
const value = Number(dialogVariableStore.getItem(key));
|
|
203
|
+
const value = Number(this.dialogVariableStore.getItem(key));
|
|
177
204
|
if (isNaN(value)) {
|
|
178
|
-
dialogVariableStore.setItem(key, "1");
|
|
205
|
+
this.dialogVariableStore.setItem(key, "1");
|
|
179
206
|
}
|
|
180
207
|
else {
|
|
181
|
-
dialogVariableStore.setItem(key, `${value + 1}`);
|
|
208
|
+
this.dialogVariableStore.setItem(key, `${value + 1}`);
|
|
182
209
|
}
|
|
183
210
|
}
|
|
184
211
|
// reloop this to process all messages
|
|
@@ -216,7 +243,7 @@ export class DialogManager {
|
|
|
216
243
|
}
|
|
217
244
|
// guard: skip if done or if not yet time to update
|
|
218
245
|
if (this.currentIndex > this.fullCurrentMessage.length ||
|
|
219
|
-
this.previousTimestamp + updateRate > timestamp) {
|
|
246
|
+
this.previousTimestamp + this.updateRate > timestamp) {
|
|
220
247
|
window.requestAnimationFrame(this.update);
|
|
221
248
|
return;
|
|
222
249
|
}
|
|
@@ -239,7 +266,13 @@ export class DialogManager {
|
|
|
239
266
|
++this.currentIndex;
|
|
240
267
|
window.requestAnimationFrame(this.update);
|
|
241
268
|
};
|
|
269
|
+
this.dialogVariableStore = createNewMapStore();
|
|
242
270
|
this.dialogProcessor = new DialogProcessor(this);
|
|
271
|
+
this.currentDialogTree.map((value) => {
|
|
272
|
+
if (value.dialogId) {
|
|
273
|
+
this.dialogMessageMap.set(value.dialogId, value);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
243
276
|
enableUniversalOverlaySvelte4.subscribe((value) => {
|
|
244
277
|
// todo: investigate why we cant put setDialogDefault inside the then clause
|
|
245
278
|
// ISSUE #82 https://github.com/TurnipXenon/pineapple/issues/82
|
|
@@ -267,14 +300,33 @@ export class DialogManager {
|
|
|
267
300
|
enableUniversalOverlaySvelte4.set(!this.enableDialogueOverlayCache);
|
|
268
301
|
}
|
|
269
302
|
;
|
|
270
|
-
parseAndSetDialogTree(
|
|
271
|
-
return __awaiter(this,
|
|
303
|
+
parseAndSetDialogTree(dialogYarn_1) {
|
|
304
|
+
return __awaiter(this, arguments, void 0, function* (dialogYarn, startingNode = "") {
|
|
305
|
+
return parseYarn(dialogYarn)
|
|
306
|
+
.then((dialogTree) => {
|
|
307
|
+
this.setDialogTree(dialogTree, startingNode);
|
|
308
|
+
return dialogTree;
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
extendDialogTree(dialogYarn_1) {
|
|
313
|
+
return __awaiter(this, arguments, void 0, function* (dialogYarn, forceNode = "") {
|
|
272
314
|
return parseYarn(dialogYarn)
|
|
273
315
|
.then((dialogTree) => {
|
|
274
|
-
|
|
316
|
+
this.currentDialogTree.push(...dialogTree);
|
|
317
|
+
if (forceNode) {
|
|
318
|
+
const potentialDialog = this.currentDialogTree.find(d => d.dialogId === forceNode);
|
|
319
|
+
if (!potentialDialog) {
|
|
320
|
+
console.error(`extendDialogTree: cannot find dialog ID: ${forceNode}`);
|
|
321
|
+
}
|
|
322
|
+
this.setDialogTree(this.currentDialogTree, forceNode);
|
|
323
|
+
}
|
|
275
324
|
return dialogTree;
|
|
276
325
|
});
|
|
277
326
|
});
|
|
278
327
|
}
|
|
328
|
+
setUpdateRate(newRate) {
|
|
329
|
+
this.updateRate = newRate;
|
|
330
|
+
}
|
|
279
331
|
}
|
|
280
332
|
export const dialogManager = new DialogManager();
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* DialogManagerStore is for variables that will be used as a Svelte store
|
|
3
3
|
* or is saved in local storage
|
|
4
4
|
*/
|
|
5
|
-
import type { DialogMapStore } from "../../types/pineapple_fiber/DialogVariableStore";
|
|
6
5
|
import type { DialogDetail } from "../../types/pineapple_fiber/DialogDetail";
|
|
7
6
|
/**
|
|
8
7
|
* Enables the dialogue overlay
|
|
@@ -23,7 +22,5 @@ import type { DialogDetail } from "../../types/pineapple_fiber/DialogDetail";
|
|
|
23
22
|
*/
|
|
24
23
|
export declare const enableUniversalOverlaySvelte4: import("svelte/store").Writable<boolean>;
|
|
25
24
|
export type OverlayType = 'dialog' | 'settings' | 'site-map';
|
|
26
|
-
export declare const dialogVariableStore: DialogMapStore;
|
|
27
|
-
export declare const updateRate: number;
|
|
28
25
|
export declare const defaultDialogMessage: DialogDetail[];
|
|
29
26
|
//# sourceMappingURL=DialogManagerStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogManagerStore.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/DialogManagerStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"DialogManagerStore.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/DialogManagerStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAE5E;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,6BAA6B,0CAAkB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAM7D,eAAO,MAAM,oBAAoB,EAAE,YAAY,EAK9C,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* DialogManagerStore is for variables that will be used as a Svelte store
|
|
3
3
|
* or is saved in local storage
|
|
4
4
|
*/
|
|
5
|
-
import { createNewMapStore } from "../../types/pineapple_fiber/DialogVariableStore";
|
|
6
5
|
import { writable } from "svelte/store";
|
|
7
6
|
/**
|
|
8
7
|
* Enables the dialogue overlay
|
|
@@ -24,11 +23,10 @@ import { writable } from "svelte/store";
|
|
|
24
23
|
export const enableUniversalOverlaySvelte4 = writable(false);
|
|
25
24
|
// todo: migrate all these stores to runes
|
|
26
25
|
// find a way to make sure we preserve *.ts file on several files
|
|
27
|
-
export const dialogVariableStore = createNewMapStore();
|
|
28
|
-
export const updateRate = 40 / 1000; // *at least* 40ms per letter
|
|
29
26
|
// todo: if we go through doing yarn to typescript, move this!
|
|
30
27
|
export const defaultDialogMessage = [
|
|
31
28
|
{
|
|
29
|
+
dialogId: `Default`,
|
|
32
30
|
textContent: `<p>I don't really have anything to say. Have you drank water? Or perhaps, you've checked out <a target="_blank" class="external-link" href="http://crouton.net">one of the best webpages</a> out there?`
|
|
33
31
|
}
|
|
34
32
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogProcessor.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/DialogProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAgB5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C;;GAEG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,cAAc,CAAoB;gBAE9B,aAAa,EAAE,cAAc;IAuBzC;;;OAGG;IACH,aAAa,GAAI,cAAc,YAAY,KAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"DialogProcessor.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/DialogProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAgB5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C;;GAEG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,cAAc,CAAoB;gBAE9B,aAAa,EAAE,cAAc;IAuBzC;;;OAGG;IACH,aAAa,GAAI,cAAc,YAAY,KAAG,MAAM,CAuBlD;CACF"}
|
|
@@ -23,7 +23,7 @@ export class DialogProcessor {
|
|
|
23
23
|
* @param dialogDetail
|
|
24
24
|
*/
|
|
25
25
|
this.processDialog = (dialogDetail) => {
|
|
26
|
-
if (!browser) {
|
|
26
|
+
if (!browser && !import.meta.env.VITEST) {
|
|
27
27
|
return ""; // don't process any line in the server
|
|
28
28
|
}
|
|
29
29
|
let currentState = new BehaviorState();
|
|
@@ -35,7 +35,8 @@ export class DialogProcessor {
|
|
|
35
35
|
const result = this.processingTree.process({
|
|
36
36
|
initState: currentState,
|
|
37
37
|
line: line_.trim(),
|
|
38
|
-
lineIndex: index
|
|
38
|
+
lineIndex: index,
|
|
39
|
+
dialogVariableStore: this.dialogManager.dialogVariableStore
|
|
39
40
|
});
|
|
40
41
|
currentState = result.nextState;
|
|
41
42
|
return result.renderedLine;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dialogManager } from "./DialogManager";
|
|
2
2
|
class _DialogUtils {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.isNodeVisited = (dialogId) => {
|
|
5
|
-
const value = Number(dialogVariableStore.getItem(`+${dialogId}`));
|
|
5
|
+
const value = Number(dialogManager.dialogVariableStore.getItem(`+${dialogId}`));
|
|
6
6
|
return !isNaN(value) && value > 0;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
@@ -4,6 +4,7 @@ import { DialogState } from "../../types/pineapple_fiber/DialogState";
|
|
|
4
4
|
import { type Tweened } from "svelte/motion";
|
|
5
5
|
import { DialogProcessor } from "./DialogProcessor";
|
|
6
6
|
import type { OnSetDialogChoiceCallback } from "./DialogManager";
|
|
7
|
+
import type { DialogMapStore } from "../../types/pineapple_fiber/DialogVariableStore";
|
|
7
8
|
export interface IDialogManager {
|
|
8
9
|
dialogMessageMap: Map<string, DialogDetail>;
|
|
9
10
|
currentDialogTree: DialogDetail[];
|
|
@@ -23,9 +24,10 @@ export interface IDialogManager {
|
|
|
23
24
|
_setDialogChoiceMutex: boolean;
|
|
24
25
|
onSetDialogListeners: OnSetDialogChoiceCallback[];
|
|
25
26
|
enableDialogueOverlayCache: boolean;
|
|
27
|
+
dialogVariableStore: DialogMapStore;
|
|
26
28
|
skipAnimation: () => void;
|
|
27
29
|
enableDialog: (shouldEnable: boolean) => void;
|
|
28
|
-
setDialogTree: (newDialogTree: DialogDetail[]) => void;
|
|
30
|
+
setDialogTree: (newDialogTree: DialogDetail[], startingNode?: string) => void;
|
|
29
31
|
subscribeToSetDialogChoice: (callback: OnSetDialogChoiceCallback) => void;
|
|
30
32
|
unsubscribeToSetDialogChoice: (callback: OnSetDialogChoiceCallback) => void;
|
|
31
33
|
setDialogChoice: (newMessage: (DialogDetail | undefined)) => void;
|
|
@@ -34,6 +36,6 @@ export interface IDialogManager {
|
|
|
34
36
|
update: (timestamp: number) => void;
|
|
35
37
|
enableDialogOverlay(enable: boolean): void;
|
|
36
38
|
toggleDialogOverlay(): void;
|
|
37
|
-
parseAndSetDialogTree(dialogYarn: string): Promise<DialogDetail[]>;
|
|
39
|
+
parseAndSetDialogTree(dialogYarn: string, startingNode?: string): Promise<DialogDetail[]>;
|
|
38
40
|
}
|
|
39
41
|
//# sourceMappingURL=IDialogManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDialogManager.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dialog_manager/IDialogManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAy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
4
|
* peek the top of a stack object with the assumption it's not an empty stack
|
|
@@ -7,7 +8,7 @@ declare class BTreeUtils {
|
|
|
7
8
|
*/
|
|
8
9
|
peek: <T>(stack: T[]) => T;
|
|
9
10
|
removeQuotes: (value: string) => string;
|
|
10
|
-
simplifyToken: (oldToken: string) => string;
|
|
11
|
+
simplifyToken: (oldToken: string, dialogVariableStore?: DialogMapStore) => string;
|
|
11
12
|
isTrue: (value: string) => boolean;
|
|
12
13
|
isFalse: (value: string) => boolean;
|
|
13
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BTreeUtils.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/core/BTreeUtils.ts"],"names":[],"mappings":"AAAA,cAAM,UAAU;IACf;;;;;OAKG;IACH,IAAI,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,KAAG,CAAC,CAEvB;IAEF,YAAY,GAAI,OAAO,MAAM,KAAG,MAAM,CAIpC;IAEF,aAAa,GAAI,UAAU,MAAM,KAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"BTreeUtils.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/core/BTreeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAErF,cAAM,UAAU;IACf;;;;;OAKG;IACH,IAAI,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,KAAG,CAAC,CAEvB;IAEF,YAAY,GAAI,OAAO,MAAM,KAAG,MAAM,CAIpC;IAEF,aAAa,GAAI,UAAU,MAAM,EAAE,sBAAsB,cAAc,KAAG,MAAM,CAW9E;IAEF,MAAM,GAAI,OAAO,MAAM,KAAG,OAAO,CAE/B;IAEF,OAAO,GAAI,OAAO,MAAM,KAAG,OAAO,CAEhC;CACF;AAED,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
|
@@ -14,13 +14,14 @@ class BTreeUtils {
|
|
|
14
14
|
.replace(/^"/, "") // remove possible " at the start: https://stackoverflow.com/a/2182602
|
|
15
15
|
.replace(/"$/, ""); // remove possible " at the end: https://stackoverflow.com/a/12249011
|
|
16
16
|
};
|
|
17
|
-
this.simplifyToken = (oldToken) => {
|
|
17
|
+
this.simplifyToken = (oldToken, dialogVariableStore) => {
|
|
18
|
+
var _a;
|
|
18
19
|
if (oldToken[0] == "$") {
|
|
19
|
-
const value =
|
|
20
|
+
const value = (_a = dialogVariableStore === null || dialogVariableStore === void 0 ? void 0 : dialogVariableStore.getItem(oldToken)) !== null && _a !== void 0 ? _a : null;
|
|
20
21
|
if (value) {
|
|
21
22
|
return value;
|
|
22
23
|
}
|
|
23
|
-
console.
|
|
24
|
+
console.log(`Value not found in dialog variable store: ${oldToken}`);
|
|
24
25
|
return "";
|
|
25
26
|
}
|
|
26
27
|
return btreeUtils.removeQuotes(oldToken);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ExpressionState } from "./ExpressionState";
|
|
2
|
+
import type { DialogMapStore } from "../../../../types/pineapple_fiber/DialogVariableStore";
|
|
2
3
|
export interface ExpressionArguments {
|
|
3
4
|
token: string;
|
|
4
5
|
initState: ExpressionState;
|
|
6
|
+
dialogVariableStore: DialogMapStore;
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=ExpressionArguments.d.ts.map
|
package/dist/components/dialog_manager/behavior_tree/expression/ExpressionArguments.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionArguments.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/expression/ExpressionArguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpressionArguments.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/expression/ExpressionArguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAC/G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAErF,MAAM,WAAW,mBAAmB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,eAAe,CAAC;IAC3B,mBAAmB,EAAE,cAAc,CAAC;CACpC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { ExpressionSelectorNode } from "./ExpressionSelectorNode";
|
|
2
|
+
import type { DialogMapStore } from "../../../../types/pineapple_fiber/DialogVariableStore";
|
|
2
3
|
declare class ExpressionEvaluator {
|
|
3
4
|
evaluatorTree: ExpressionSelectorNode;
|
|
4
5
|
isNumeric: (str: string) => boolean;
|
|
5
6
|
getPrecedence: (token: string) => number;
|
|
6
|
-
evaluateFreeform: (line: string, prefix: string) => string[];
|
|
7
|
+
evaluateFreeform: (line: string, prefix: string, dialogVariableStore: DialogMapStore) => string[];
|
|
7
8
|
/**
|
|
8
9
|
* evaluates a yarn if or elseif statement
|
|
9
10
|
* @param line is the current line being evaluated
|
|
10
11
|
* @param prefix is either "<<if" or "<<elseif"
|
|
12
|
+
* @param dialogVariableStore
|
|
11
13
|
*/
|
|
12
|
-
evaluate: (line: string, prefix: string) => boolean;
|
|
14
|
+
evaluate: (line: string, prefix: string, dialogVariableStore: DialogMapStore) => boolean;
|
|
13
15
|
}
|
|
14
16
|
export declare const expressionEvaluator: ExpressionEvaluator;
|
|
15
17
|
export {};
|
package/dist/components/dialog_manager/behavior_tree/expression/ExpressionEvaluator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionEvaluator.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/expression/ExpressionEvaluator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gFAAgF,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpressionEvaluator.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/expression/ExpressionEvaluator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gFAAgF,CAAC;AAIxH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAErF,cAAM,mBAAmB;IACxB,aAAa,yBAIV;IAGH,SAAS,GAAI,KAAK,MAAM,KAAG,OAAO,CAOhC;IAEF,aAAa,GAAI,OAAO,MAAM,KAAG,MAAM,CA+BrC;IAEF,gBAAgB,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,qBAAqB,cAAc,KAAG,MAAM,EAAE,CAkK9F;IAEF;;;;;OAKG;IACH,QAAQ,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,qBAAqB,cAAc,KAAG,OAAO,CAMrF;CACF;AAED,eAAO,MAAM,mBAAmB,qBAA4B,CAAC"}
|
|
@@ -51,8 +51,8 @@ class ExpressionEvaluator {
|
|
|
51
51
|
return -1;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
this.evaluateFreeform = (line, prefix) => {
|
|
55
|
-
if (!browser) {
|
|
54
|
+
this.evaluateFreeform = (line, prefix, dialogVariableStore) => {
|
|
55
|
+
if (!browser && !import.meta.env.VITEST) {
|
|
56
56
|
return []; // do not process when not in browser
|
|
57
57
|
}
|
|
58
58
|
// tokenize first!
|
|
@@ -198,7 +198,8 @@ class ExpressionEvaluator {
|
|
|
198
198
|
// console.log("Current token", token);
|
|
199
199
|
const result = this.evaluatorTree.process({
|
|
200
200
|
initState: currentState,
|
|
201
|
-
token: token
|
|
201
|
+
token: token,
|
|
202
|
+
dialogVariableStore
|
|
202
203
|
});
|
|
203
204
|
// console.log("Token evaluated with result", result.nextState.operandStack.toString());
|
|
204
205
|
currentState = result.nextState;
|
|
@@ -210,12 +211,13 @@ class ExpressionEvaluator {
|
|
|
210
211
|
* evaluates a yarn if or elseif statement
|
|
211
212
|
* @param line is the current line being evaluated
|
|
212
213
|
* @param prefix is either "<<if" or "<<elseif"
|
|
214
|
+
* @param dialogVariableStore
|
|
213
215
|
*/
|
|
214
|
-
this.evaluate = (line, prefix) => {
|
|
215
|
-
if (!browser) {
|
|
216
|
+
this.evaluate = (line, prefix, dialogVariableStore) => {
|
|
217
|
+
if (!browser && !import.meta.env.VITEST) {
|
|
216
218
|
return false; // do not process when not in browser
|
|
217
219
|
}
|
|
218
|
-
return String(btreeUtils.peek(this.evaluateFreeform(line, prefix))) === "true";
|
|
220
|
+
return String(btreeUtils.peek(this.evaluateFreeform(line, prefix, dialogVariableStore))) === "true";
|
|
219
221
|
};
|
|
220
222
|
}
|
|
221
223
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperandNode.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/expression/OperandNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gFAAgF,CAAC;AAC7H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6EAA6E,CAAC;AACvH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0EAA0E,CAAC;AAIjH;;;GAGG;AACH,qBAAa,WAAY,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,EAAE,mBAAmB,GAAG,gBAAgB;
|
|
1
|
+
{"version":3,"file":"OperandNode.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/expression/OperandNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gFAAgF,CAAC;AAC7H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6EAA6E,CAAC;AACvH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0EAA0E,CAAC;AAIjH;;;GAGG;AACH,qBAAa,WAAY,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,EAAE,mBAAmB,GAAG,gBAAgB;CASxD"}
|
|
@@ -6,7 +6,7 @@ import { btreeUtils } from "../core/BTreeUtils";
|
|
|
6
6
|
*/
|
|
7
7
|
export class OperandNode {
|
|
8
8
|
process(nodeArgs) {
|
|
9
|
-
nodeArgs.initState.operandStack.push(btreeUtils.simplifyToken(nodeArgs.token));
|
|
9
|
+
nodeArgs.initState.operandStack.push(btreeUtils.simplifyToken(nodeArgs.token, nodeArgs.dialogVariableStore));
|
|
10
10
|
return {
|
|
11
11
|
nextState: nodeArgs.initState,
|
|
12
12
|
status: BehaviorStatus.Success
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisitedCountCommand.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/components/dialog_manager/behavior_tree/expression/commands/VisitedCountCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mFAAmF,CAAC;AACrH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6EAA6E,CAAC;
|
|
1
|
+
{"version":3,"file":"VisitedCountCommand.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/components/dialog_manager/behavior_tree/expression/commands/VisitedCountCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mFAAmF,CAAC;AACrH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6EAA6E,CAAC;AAEvH;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,gBAAgB;IACxD,WAAW,GAAI,iBAAiB,MAAM,EAAE,EAAE,UAAU,mBAAmB,UAOrE;IAEF,gBAAgB,QAAO,MAAM,CAE3B;IAEF,QAAQ,QAAO,MAAM,CAEnB;CACF"}
|
package/dist/components/dialog_manager/behavior_tree/expression/commands/VisitedCountCommand.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CommandLogicNode } from "./CommandLogicNode";
|
|
2
|
-
import { dialogVariableStore } from "../../../DialogManagerStore";
|
|
3
2
|
/**
|
|
4
3
|
* Used for command like
|
|
5
4
|
* visited_count("node name here");
|
|
@@ -10,7 +9,7 @@ export class VisitedCountCommand extends CommandLogicNode {
|
|
|
10
9
|
constructor() {
|
|
11
10
|
super(...arguments);
|
|
12
11
|
this.doOperation = (currentOperands, nodeArgs) => {
|
|
13
|
-
const value = Number(dialogVariableStore.getItem(`+${currentOperands[0]}`));
|
|
12
|
+
const value = Number(nodeArgs.dialogVariableStore.getItem(`+${currentOperands[0]}`));
|
|
14
13
|
if (isNaN(value) || value === 0) {
|
|
15
14
|
nodeArgs.initState.operandStack.push("0");
|
|
16
15
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { BehaviorState } from "../line_processors/BehaviorState";
|
|
2
|
+
import type { DialogMapStore } from "../../../../types/pineapple_fiber/DialogVariableStore";
|
|
2
3
|
export interface LineNodeArguments {
|
|
3
4
|
line: string;
|
|
4
5
|
lineIndex: number;
|
|
5
6
|
initState: BehaviorState;
|
|
7
|
+
dialogVariableStore: DialogMapStore;
|
|
6
8
|
}
|
|
7
9
|
//# sourceMappingURL=LineNodeArguments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineNodeArguments.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/line_core/LineNodeArguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4EAA4E,CAAC;
|
|
1
|
+
{"version":3,"file":"LineNodeArguments.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/line_core/LineNodeArguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4EAA4E,CAAC;AAChH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAErF,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,aAAa,CAAC;IACzB,mBAAmB,EAAE,cAAc,CAAC;CACpC"}
|
|
@@ -34,7 +34,7 @@ export class ElseIfNode {
|
|
|
34
34
|
case IfMode.EvaluateNext:
|
|
35
35
|
// since all the previous evaluations were false,
|
|
36
36
|
// let's try evaluating this like the if statement
|
|
37
|
-
if (expressionEvaluator.evaluate(nodeArgs.line, "<<elseif")) {
|
|
37
|
+
if (expressionEvaluator.evaluate(nodeArgs.line, "<<elseif", nodeArgs.dialogVariableStore)) {
|
|
38
38
|
nodeArgs.initState.ifModeStack.pop();
|
|
39
39
|
nodeArgs.initState.ifModeStack.push(IfMode.Evaluated);
|
|
40
40
|
} // else: retain the EvaluateNext status
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IfNode.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/line_processors/IfNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0EAA0E,CAAC;AAClH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;AAGpH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yEAAyE,CAAC;AAIhH;;;;;GAKG;AACH,qBAAa,MAAO,YAAW,gBAAgB;IAC9C,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,kBAAkB;
|
|
1
|
+
{"version":3,"file":"IfNode.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/line_processors/IfNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0EAA0E,CAAC;AAClH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;AAGpH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yEAAyE,CAAC;AAIhH;;;;;GAKG;AACH,qBAAa,MAAO,YAAW,gBAAgB;IAC9C,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,kBAAkB;CAgCxD"}
|
|
@@ -20,7 +20,6 @@ export class IfNode {
|
|
|
20
20
|
const currentIfMode = btreeUtils.peek(nodeArgs.initState.ifModeStack);
|
|
21
21
|
if ([IfMode.EvaluateNext, IfMode.Ignore].includes(currentIfMode)) {
|
|
22
22
|
// skip! we found a nested if
|
|
23
|
-
console.log("Skipping if node because");
|
|
24
23
|
nodeArgs.initState.ifModeStack.push(IfMode.Ignore);
|
|
25
24
|
return {
|
|
26
25
|
renderedLine: "",
|
|
@@ -28,7 +27,7 @@ export class IfNode {
|
|
|
28
27
|
status: BehaviorStatus.Success
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
if (expressionEvaluator.evaluate(nodeArgs.line, "<<if")) {
|
|
30
|
+
if (expressionEvaluator.evaluate(nodeArgs.line, "<<if", nodeArgs.dialogVariableStore)) {
|
|
32
31
|
nodeArgs.initState.ifModeStack.push(IfMode.Evaluated);
|
|
33
32
|
}
|
|
34
33
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NormalLineProcessorNode.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/line_processors/NormalLineProcessorNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0EAA0E,CAAC;AAClH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;
|
|
1
|
+
{"version":3,"file":"NormalLineProcessorNode.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/dialog_manager/behavior_tree/line_processors/NormalLineProcessorNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0EAA0E,CAAC;AAClH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;AAEpH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yEAAyE,CAAC;AAEhH;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAC/D,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,kBAAkB;CAoCxD"}
|