MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / apply

Method apply

src/actions/Dialog.ts:442–478  ·  view source on GitHub ↗
({ updateLog = true } = {})

Source from the content-addressed store, hash-verified

440 }
441
442 override async apply({ updateLog = true } = {}): Promise<void> {
443 try {
444 const dialogLog = this.engine.component('dialog-log') as { instances?: () => { each: (cb: (instance: { write: (data: { id: string; character: string; dialog: string }) => void }) => void) => void } } | undefined;
445 if (typeof dialogLog !== 'undefined' && dialogLog.instances) {
446 if (this._cycle === 'Application' && updateLog === true) {
447 dialogLog.instances().each((instance) => instance.write({
448 id: this.id,
449 character: this.character,
450 dialog: this.clearDialog
451 }));
452 }
453 }
454 } catch (e) {
455 this.engine.debug.error(e);
456 }
457
458 const textBoxElement = this.engine.element().find('[data-component="text-box"]').get(0) as TextBoxComponent | undefined;
459 if (textBoxElement?.state?.hidden === true) {
460 FancyError.show('action:dialog:textbox_hidden', {
461 statement: `<code class='language=javascript'>"${this._statement}"</code>`,
462 label: this.engine.state('label'),
463 step: this.engine.state('step')
464 });
465 }
466
467 if (typeof this.character !== 'undefined') {
468 this._handleCustomClasses(textBoxElement);
469 (textBoxElement as any)?.show();
470 return this.characterDialog();
471 } else if (this.id === 'centered') {
472 return this.displayCenteredDialog(this.dialog, this.clearDialog, this.id, this.engine.setting('CenteredTypeAnimation'));
473 } else {
474 this._handleCustomClasses(textBoxElement);
475 (textBoxElement as any)?.show();
476 return this.displayDialog(this.dialog, this.clearDialog, '_narrator', this.engine.setting('NarratorTypeAnimation'));
477 }
478 }
479
480 override async didApply(): Promise<ActionApplyResult> {
481 this.engine.global('_dialog_pending_revert', true);

Callers 1

revertMethod · 0.95

Calls 13

_handleCustomClassesMethod · 0.95
characterDialogMethod · 0.95
displayCenteredDialogMethod · 0.95
displayDialogMethod · 0.95
componentMethod · 0.80
writeMethod · 0.80
stateMethod · 0.80
settingMethod · 0.80
eachMethod · 0.65
getMethod · 0.65
instancesMethod · 0.45
elementMethod · 0.45

Tested by

no test coverage detected