@gamelearn/arcade-components 2.30.0 → 2.31.0
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
|
@@ -33,7 +33,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
33
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
34
|
var characterMs = 75;
|
|
35
35
|
var minMs = 1400;
|
|
36
|
-
var
|
|
36
|
+
var ConversationalProComponent = function ConversationalProComponent(_ref) {
|
|
37
37
|
var _background$img, _currentLineData$slot3, _currentMessage$text;
|
|
38
38
|
var keyboardControl = _ref.keyboardControl,
|
|
39
39
|
emitEvent = _ref.emitEvent,
|
|
@@ -277,6 +277,48 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
277
277
|
finishConversation();
|
|
278
278
|
}
|
|
279
279
|
}, [currentLineData.id, edges, edgesHistory, emitEvent, finishConversation, lastNodeId, lines]);
|
|
280
|
+
var decisionNotifyProgress = (0, _react.useCallback)(function (choice) {
|
|
281
|
+
if (isBranched) {
|
|
282
|
+
if (choice) {
|
|
283
|
+
var currentId = [3, 2, 1][choice.id];
|
|
284
|
+
var optionsEdges = edges.filter(function (edge) {
|
|
285
|
+
return edge.fromId === currentLineData.id;
|
|
286
|
+
});
|
|
287
|
+
var currentEdge = optionsEdges.find(function (edge) {
|
|
288
|
+
return parseInt(edge.fromPointIndex) === currentId;
|
|
289
|
+
});
|
|
290
|
+
if (currentEdge) {
|
|
291
|
+
var destinationEdge = lines.findIndex(function (l) {
|
|
292
|
+
return l.id === currentEdge.toId;
|
|
293
|
+
});
|
|
294
|
+
if (destinationEdge >= 0) {
|
|
295
|
+
emitEvent({
|
|
296
|
+
type: 'notifyProgress',
|
|
297
|
+
payload: {
|
|
298
|
+
line: destinationEdge
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
emitEvent({
|
|
304
|
+
type: 'saveNode'
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
var line = currentLine;
|
|
310
|
+
var maxLine = lines.length - 1;
|
|
311
|
+
if (line + 1 <= maxLine) {
|
|
312
|
+
var next = line + 1;
|
|
313
|
+
emitEvent({
|
|
314
|
+
type: 'notifyProgress',
|
|
315
|
+
payload: {
|
|
316
|
+
line: next
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}, [edges, lines, emitEvent, currentLine, currentLineData.id, isBranched]);
|
|
280
322
|
var handleClickNext = (0, _react.useCallback)(function (choice, reset) {
|
|
281
323
|
var isLast = false;
|
|
282
324
|
setTTsStart(false);
|
|
@@ -437,6 +479,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
437
479
|
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
438
480
|
required: !isBranched,
|
|
439
481
|
branched: isBranched,
|
|
482
|
+
onAddPoints: decisionNotifyProgress,
|
|
440
483
|
onFinish: handleClickNext,
|
|
441
484
|
keyboardControl: keyboardControl,
|
|
442
485
|
emitEvent: emitEvent,
|
|
@@ -485,10 +528,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
485
528
|
className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
|
|
486
529
|
}))))));
|
|
487
530
|
};
|
|
488
|
-
|
|
531
|
+
ConversationalProComponent.defaultProps = {
|
|
489
532
|
background: {},
|
|
490
533
|
emitEvent: function emitEvent() {},
|
|
491
534
|
soundActions: [function () {}, function () {}]
|
|
492
535
|
};
|
|
493
|
-
var _default =
|
|
536
|
+
var _default = ConversationalProComponent;
|
|
494
537
|
exports.default = _default;
|
|
@@ -36,6 +36,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
36
36
|
inheritProps = _props$inheritProps === void 0 ? {} : _props$inheritProps,
|
|
37
37
|
required = props.required,
|
|
38
38
|
question = props.question,
|
|
39
|
+
onAddPoints = props.onAddPoints,
|
|
39
40
|
_onFinish = props.onFinish,
|
|
40
41
|
branched = props.branched,
|
|
41
42
|
simplifiedOptions = props.simplifiedOptions;
|
|
@@ -93,6 +94,9 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
} else {
|
|
97
|
+
if (onAddPoints) {
|
|
98
|
+
onAddPoints(choice);
|
|
99
|
+
}
|
|
96
100
|
emitGameData(choice);
|
|
97
101
|
emitEvent({
|
|
98
102
|
type: 'addPoints',
|
|
@@ -385,6 +385,44 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
387
|
}, [handleBranchDirection, emitEvent, isBranched, lastLine, line, talkingCharacter]);
|
|
388
|
+
var decisionNotifyProgress = (0, _react.useCallback)(function (choice) {
|
|
389
|
+
if (isBranched) {
|
|
390
|
+
if (choice) {
|
|
391
|
+
var currentId = [3, 2, 1][choice.id];
|
|
392
|
+
var optionsEdges = edges.filter(function (edge) {
|
|
393
|
+
return edge.fromId === currentLineData.id;
|
|
394
|
+
});
|
|
395
|
+
var currentEdge = optionsEdges.find(function (edge) {
|
|
396
|
+
return parseInt(edge.fromPointIndex) === currentId;
|
|
397
|
+
});
|
|
398
|
+
if (currentEdge) {
|
|
399
|
+
var destinationEdge = lines.findIndex(function (l) {
|
|
400
|
+
return l.id === currentEdge.toId;
|
|
401
|
+
});
|
|
402
|
+
if (destinationEdge >= 0) {
|
|
403
|
+
emitEvent({
|
|
404
|
+
type: 'notifyProgress',
|
|
405
|
+
payload: {
|
|
406
|
+
line: destinationEdge
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
emitEvent({
|
|
412
|
+
type: 'saveNode'
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
} else if (line < lines.length - 1) {
|
|
417
|
+
var next = line + 1;
|
|
418
|
+
emitEvent({
|
|
419
|
+
type: 'notifyProgress',
|
|
420
|
+
payload: {
|
|
421
|
+
line: next
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}, [edges, line, lines, emitEvent, currentLineData.id, isBranched]);
|
|
388
426
|
var nextLine = (0, _react.useCallback)(function (choice, reset) {
|
|
389
427
|
lastTalking.current = _objectSpread({}, talkingCharacter);
|
|
390
428
|
setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
|
|
@@ -638,6 +676,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
638
676
|
},
|
|
639
677
|
required: !isBranched,
|
|
640
678
|
branched: isBranched,
|
|
679
|
+
onAddPoints: decisionNotifyProgress,
|
|
641
680
|
onFinish: nextLine,
|
|
642
681
|
emitEvent: emitEvent,
|
|
643
682
|
pause: pause,
|