@gamelearn/arcade-components 1.22.1 → 1.22.9
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/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -61,25 +61,30 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
61
61
|
lodSettings = _ref.lodSettings,
|
|
62
62
|
autoPlay = _ref.autoPlay;
|
|
63
63
|
|
|
64
|
-
var _useState = (0, _react.useState)(
|
|
64
|
+
var _useState = (0, _react.useState)(false),
|
|
65
65
|
_useState2 = _slicedToArray(_useState, 2),
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
mounted = _useState2[0],
|
|
67
|
+
setMounted = _useState2[1];
|
|
68
68
|
|
|
69
|
-
var _useState3 = (0, _react.useState)(
|
|
69
|
+
var _useState3 = (0, _react.useState)(true),
|
|
70
70
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
started = _useState4[0],
|
|
72
|
+
setStarted = _useState4[1];
|
|
73
73
|
|
|
74
|
-
var _useState5 = (0, _react.useState)(
|
|
74
|
+
var _useState5 = (0, _react.useState)(!!autoPlay),
|
|
75
75
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
automatic = _useState6[0],
|
|
77
|
+
setAutomatic = _useState6[1];
|
|
78
78
|
|
|
79
|
-
var _useState7 = (0, _react.useState)(
|
|
79
|
+
var _useState7 = (0, _react.useState)(false),
|
|
80
80
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
audioFailed = _useState8[0],
|
|
82
|
+
setAudioFailed = _useState8[1];
|
|
83
|
+
|
|
84
|
+
var _useState9 = (0, _react.useState)(0),
|
|
85
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
86
|
+
currentLine = _useState10[0],
|
|
87
|
+
setCurrentLine = _useState10[1];
|
|
83
88
|
|
|
84
89
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
85
90
|
playSound = _soundActions[0];
|
|
@@ -95,10 +100,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
95
100
|
decision = currentLineData.decision;
|
|
96
101
|
var isBranched = !!edges;
|
|
97
102
|
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
previousLineWasDecision =
|
|
101
|
-
setPreviousLineWasDecision =
|
|
103
|
+
var _useState11 = (0, _react.useState)(false),
|
|
104
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
105
|
+
previousLineWasDecision = _useState12[0],
|
|
106
|
+
setPreviousLineWasDecision = _useState12[1];
|
|
102
107
|
|
|
103
108
|
var isVoiceOver = voiceOver || currentLineData.type === 'conversationalNarration';
|
|
104
109
|
var isDecision = decision || currentLineData.type === 'conversationalDecision';
|
|
@@ -279,7 +284,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
279
284
|
}
|
|
280
285
|
|
|
281
286
|
setStarted(true);
|
|
282
|
-
}, [currentLine, currentLineData, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
|
|
287
|
+
}, [currentLine, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
|
|
283
288
|
|
|
284
289
|
var handleClickBack = function handleClickBack() {
|
|
285
290
|
setStarted(false);
|
|
@@ -340,7 +345,27 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
340
345
|
return function () {
|
|
341
346
|
stop();
|
|
342
347
|
};
|
|
343
|
-
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed]);
|
|
348
|
+
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines]); // Calculate start node
|
|
349
|
+
|
|
350
|
+
(0, _react.useEffect)(function () {
|
|
351
|
+
if (isBranched && !mounted) {
|
|
352
|
+
var startNodes = lines.filter(function (node) {
|
|
353
|
+
return !edges.find(function (edge) {
|
|
354
|
+
return edge.toId === node.id;
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
if (startNodes.length) {
|
|
359
|
+
var initialNode = startNodes[0];
|
|
360
|
+
var newInitiaIndexlNode = lines.indexOf(initialNode);
|
|
361
|
+
|
|
362
|
+
if (newInitiaIndexlNode >= 0) {
|
|
363
|
+
setMounted(true);
|
|
364
|
+
setCurrentLine(newInitiaIndexlNode);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}, [edges, isBranched, lines, mounted]);
|
|
344
369
|
|
|
345
370
|
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
346
371
|
required: !isBranched,
|
|
@@ -102,8 +102,13 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
102
102
|
|
|
103
103
|
var _useState7 = (0, _react.useState)(false),
|
|
104
104
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
mounted = _useState8[0],
|
|
106
|
+
setMounted = _useState8[1];
|
|
107
|
+
|
|
108
|
+
var _useState9 = (0, _react.useState)(false),
|
|
109
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
110
|
+
audioFailed = _useState10[0],
|
|
111
|
+
setAudioFailed = _useState10[1];
|
|
107
112
|
|
|
108
113
|
var _useThree = (0, _fiber.useThree)(function (state) {
|
|
109
114
|
return [state.camera, state.scene];
|
|
@@ -147,10 +152,10 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
147
152
|
});
|
|
148
153
|
}, [emitEvent]);
|
|
149
154
|
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
previousLineWasDecision =
|
|
153
|
-
setPreviousLineWasDecision =
|
|
155
|
+
var _useState11 = (0, _react.useState)(false),
|
|
156
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
157
|
+
previousLineWasDecision = _useState12[0],
|
|
158
|
+
setPreviousLineWasDecision = _useState12[1];
|
|
154
159
|
|
|
155
160
|
var isVoiceOver = voiceOver || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalNarration';
|
|
156
161
|
var isDecision = decision || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalDecision';
|
|
@@ -327,7 +332,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
327
332
|
} else {
|
|
328
333
|
finishConversation();
|
|
329
334
|
}
|
|
330
|
-
}, [currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
|
|
335
|
+
}, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
|
|
331
336
|
|
|
332
337
|
var manualBackLine = function manualBackLine() {
|
|
333
338
|
setAutomatic(false);
|
|
@@ -337,8 +342,28 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
337
342
|
var manualNextLine = function manualNextLine() {
|
|
338
343
|
setAutomatic(false);
|
|
339
344
|
nextLine();
|
|
340
|
-
}; //
|
|
345
|
+
}; // Calculate start node
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
(0, _react.useEffect)(function () {
|
|
349
|
+
if (isBranched && !mounted) {
|
|
350
|
+
var startNodes = lines.filter(function (node) {
|
|
351
|
+
return !edges.find(function (edge) {
|
|
352
|
+
return edge.toId === node.id;
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
if (startNodes.length) {
|
|
357
|
+
var initialNode = startNodes[0];
|
|
358
|
+
var newInitiaIndexlNode = lines.indexOf(initialNode);
|
|
341
359
|
|
|
360
|
+
if (newInitiaIndexlNode >= 0) {
|
|
361
|
+
setMounted(true);
|
|
362
|
+
changeLine(newInitiaIndexlNode);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}, [edges, isBranched, lines, mounted]); // Position bubble over talking character/and switch emotions
|
|
342
367
|
|
|
343
368
|
(0, _react.useEffect)(function () {
|
|
344
369
|
if (isDecision) {
|