(dialog: string, clearDialog: string, character: string, animation: boolean)
| 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> { |
no test coverage detected