@gamelearn/arcade-components 2.30.0 → 2.31.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/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);
|
|
@@ -434,21 +476,27 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
434
476
|
}
|
|
435
477
|
}, [edges, isBranched, lines, mounted, progress === null || progress === void 0 ? void 0 : progress.line]);
|
|
436
478
|
keyboardControl(isDecision || disableBackButton ? null : manualClickBack, isDecision ? null : manualClickNext);
|
|
437
|
-
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
438
|
-
required: !isBranched,
|
|
439
|
-
branched: isBranched,
|
|
440
|
-
onFinish: handleClickNext,
|
|
441
|
-
keyboardControl: keyboardControl,
|
|
442
|
-
emitEvent: emitEvent,
|
|
443
|
-
soundActions: soundActions,
|
|
444
|
-
inheritProps: {
|
|
445
|
-
characters: currentCharacters,
|
|
446
|
-
background: background,
|
|
447
|
-
flex: leftWithSlots ? leftWithSlots.flex : true,
|
|
448
|
-
slots: !leftWithSlots ? [] : leftWithSlots.slots
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
479
|
if (isDecision) {
|
|
480
|
+
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
481
|
+
decisionNumber: lines.filter(function (l) {
|
|
482
|
+
return l.decision;
|
|
483
|
+
}).findIndex(function (l) {
|
|
484
|
+
return l.id === lines[currentLine].id;
|
|
485
|
+
}) + 1,
|
|
486
|
+
required: !isBranched,
|
|
487
|
+
branched: isBranched,
|
|
488
|
+
onAddPoints: decisionNotifyProgress,
|
|
489
|
+
onFinish: handleClickNext,
|
|
490
|
+
keyboardControl: keyboardControl,
|
|
491
|
+
emitEvent: emitEvent,
|
|
492
|
+
soundActions: soundActions,
|
|
493
|
+
inheritProps: {
|
|
494
|
+
characters: currentCharacters,
|
|
495
|
+
background: background,
|
|
496
|
+
flex: leftWithSlots ? leftWithSlots.flex : true,
|
|
497
|
+
slots: !leftWithSlots ? [] : leftWithSlots.slots
|
|
498
|
+
}
|
|
499
|
+
});
|
|
452
500
|
return /*#__PURE__*/_react.default.createElement(_decisionComponent.default, decisionPayload);
|
|
453
501
|
}
|
|
454
502
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -485,10 +533,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
485
533
|
className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
|
|
486
534
|
}))))));
|
|
487
535
|
};
|
|
488
|
-
|
|
536
|
+
ConversationalProComponent.defaultProps = {
|
|
489
537
|
background: {},
|
|
490
538
|
emitEvent: function emitEvent() {},
|
|
491
539
|
soundActions: [function () {}, function () {}]
|
|
492
540
|
};
|
|
493
|
-
var _default =
|
|
541
|
+
var _default = ConversationalProComponent;
|
|
494
542
|
exports.default = _default;
|
|
@@ -34,8 +34,10 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
34
34
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
35
|
var _props$inheritProps = props.inheritProps,
|
|
36
36
|
inheritProps = _props$inheritProps === void 0 ? {} : _props$inheritProps,
|
|
37
|
+
decisionNumber = props.decisionNumber,
|
|
37
38
|
required = props.required,
|
|
38
39
|
question = props.question,
|
|
40
|
+
onAddPoints = props.onAddPoints,
|
|
39
41
|
_onFinish = props.onFinish,
|
|
40
42
|
branched = props.branched,
|
|
41
43
|
simplifiedOptions = props.simplifiedOptions;
|
|
@@ -77,7 +79,10 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
77
79
|
var emitGameData = function emitGameData(choice) {
|
|
78
80
|
emitEvent({
|
|
79
81
|
type: 'decisionJournal',
|
|
80
|
-
payload:
|
|
82
|
+
payload: {
|
|
83
|
+
choice: choice,
|
|
84
|
+
decisionNumber: decisionNumber
|
|
85
|
+
}
|
|
81
86
|
});
|
|
82
87
|
};
|
|
83
88
|
var onNext = function onNext(choice) {
|
|
@@ -93,6 +98,9 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
93
98
|
});
|
|
94
99
|
}
|
|
95
100
|
} else {
|
|
101
|
+
if (onAddPoints) {
|
|
102
|
+
onAddPoints(choice);
|
|
103
|
+
}
|
|
96
104
|
emitGameData(choice);
|
|
97
105
|
emitEvent({
|
|
98
106
|
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]));
|
|
@@ -632,12 +670,18 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
632
670
|
var container = document.querySelector('.screens--container');
|
|
633
671
|
if (isDecision) {
|
|
634
672
|
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
673
|
+
decisionNumber: lines.filter(function (l) {
|
|
674
|
+
return l.decision;
|
|
675
|
+
}).findIndex(function (l) {
|
|
676
|
+
return l.id === currentLineData.id;
|
|
677
|
+
}) + 1,
|
|
635
678
|
inheritProps: {
|
|
636
679
|
slots: [],
|
|
637
680
|
disableBackground: true
|
|
638
681
|
},
|
|
639
682
|
required: !isBranched,
|
|
640
683
|
branched: isBranched,
|
|
684
|
+
onAddPoints: decisionNotifyProgress,
|
|
641
685
|
onFinish: nextLine,
|
|
642
686
|
emitEvent: emitEvent,
|
|
643
687
|
pause: pause,
|