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

Method displayDialog

src/actions/Dialog.ts:361–399  ·  view source on GitHub ↗
(dialog: string, clearDialog: string, character: string, animation: boolean)

Source from the content-addressed store, hash-verified

359 }
360
361 async displayDialog(dialog: string, clearDialog: string, character: string, animation: boolean): Promise<void> {
362 if (this.nvl === false) {
363 const textBox = this.engine.element().find('[data-component="text-box"]').get(0) as any;
364
365 if (!textBox) {
366 this.engine.debug.error('Text box component not found');
367 return;
368 }
369
370 if (textBox.props?.mode === 'nvl' && this._cycle === 'Application' && this.engine.global('_restoring_state') === false) {
371 this.engine.history('nvl').push(textBox.content('dialog').html());
372 }
373
374 // NOTE: setProps does NOT trigger a re-render — it only updates the
375 // mode attribute on the element so CSS (text-box[mode="adv"]) applies.
376 // The type-writer child persists across mode changes by design.
377 textBox.setProps({ mode: 'adv' });
378
379 // Destroy any active NVL entry type-writers before clearing to prevent
380 // leaked animation frames from detached elements.
381 this.engine.element().find('[data-ui="say"] [data-spoke] type-writer').each((tw: any) => {
382 if (typeof tw.destroy === 'function') {
383 tw.destroy();
384 }
385 });
386
387 // Remove contents from the dialog area.
388 this.engine.element().find('[data-ui="say"]').html('');
389 this.engine.element().find('[data-component="text-box"]').data('speaking', character);
390
391 // Find the type-writer component inside the text-box (ADV mode has it)
392 const typeWriter = this.engine.element().find('[data-component="text-box"] type-writer').get(0) as TypeWriter | undefined;
393 if (typeWriter) {
394 typeWriter.setContent(dialog, animation);
395 }
396 } else {
397 this.displayNvlDialog(dialog, clearDialog, character, animation);
398 }
399 }
400
401
402 characterDialog(): Promise<void> {

Callers 2

characterDialogMethod · 0.95
applyMethod · 0.95

Calls 9

displayNvlDialogMethod · 0.95
globalMethod · 0.80
historyMethod · 0.80
setContentMethod · 0.80
getMethod · 0.65
eachMethod · 0.65
elementMethod · 0.45
contentMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected