Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Runtime/Views/ActionMarkupHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public interface IActionMarkupHandler
/// <param name="text">A <see cref="TMP_Text"/> object that the line is
/// being displayed in.</param>
/// <param name="cancellationToken">A cancellation token representing
/// whether the </param>
/// whether cancellation has been requested.</param>
/// <returns>A task that completes when the <see
/// cref="ActionMarkupHandler"/> has completed presenting this
/// character. Dialogue presenters will wait until this task is complete
Expand All @@ -85,7 +85,13 @@ public interface IActionMarkupHandler
/// <remarks>This method is an opportunity for a <see
/// cref="ActionMarkupHandler"/> to finalise its presentation after
/// all of the characters in the line have been presented.</remarks>
public void OnLineDisplayComplete();
/// <param name="cancellationToken">A cancellation token representing
/// whether cancellation has been requested.</param>
/// <returns>A task that completes when the <see
/// cref="ActionMarkupHandler"/> has completed presenting this
/// character. Dialogue presenters will wait until this task is complete
/// before proceeding to dismiss the line.</returns>
public YarnTask OnLineDisplayComplete(CancellationToken cancellationToken);

/// <summary>
/// Called right before the line will dismiss itself.
Expand Down Expand Up @@ -117,7 +123,7 @@ public abstract class ActionMarkupHandler : MonoBehaviour, IActionMarkupHandler
public abstract YarnTask OnCharacterWillAppear(int currentCharacterIndex, MarkupParseResult line, CancellationToken cancellationToken);

/// <inheritdoc/>
public abstract void OnLineDisplayComplete();
public abstract YarnTask OnLineDisplayComplete();

/// <inheritdoc/>
public abstract void OnLineWillDismiss();
Expand Down
4 changes: 3 additions & 1 deletion Runtime/Views/LineAdvancer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public YarnTask OnCharacterWillAppear(int currentCharacterIndex, MarkupParseResu
return YarnTask.CompletedTask;
}

public void OnLineDisplayComplete()
public YarnTask OnLineDisplayComplete(CancellationToken cancellationToken)
{
if (status == PresentationStatus.LineBegan)
{
Expand All @@ -779,6 +779,8 @@ public void OnLineDisplayComplete()
{
status = PresentationStatus.OptionsWaiting;
}

return YarnTask.CompletedTask;
}

public void OnLineWillDismiss()
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Views/LinePresenterButtonHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public override YarnTask OnCharacterWillAppear(int currentCharacterIndex, Markup
return YarnTask.CompletedTask;
}

public override void OnLineDisplayComplete()
public override YarnTask OnLineDisplayComplete()
{
return;
return YarnTask.CompletedTask;
}

public override void OnLineWillDismiss()
Expand Down
3 changes: 2 additions & 1 deletion Runtime/Views/PauseEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ namespace Yarn.Unity
public sealed class PauseEventProcessor : IActionMarkupHandler
{
private Dictionary<int, float> pauses = new();
public void OnLineDisplayComplete()
public YarnTask OnLineDisplayComplete(CancellationToken cancellationToken)
{
pauses.Clear();
return YarnTask.CompletedTask;
}

public void OnLineDisplayBegin(MarkupParseResult line, TMP_Text text)
Expand Down
8 changes: 4 additions & 4 deletions Runtime/Views/Typewriter/InstantTypewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Yarn.Unity
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
using Yarn.Markup;
Expand Down Expand Up @@ -75,10 +76,9 @@ await processor
Text.maxVisibleCharacters = visibleCharacterCount;

// Let each markup handler know the line has finished displaying
foreach (var markupHandler in ActionMarkupHandlers)
{
markupHandler.OnLineDisplayComplete();
}
await YarnTask.WhenAll(
ActionMarkupHandlers.Select(handler => handler.OnLineDisplayComplete(cancellationToken))
);
}

public void PrepareForContent(MarkupParseResult line)
Expand Down
8 changes: 4 additions & 4 deletions Runtime/Views/Typewriter/LetterTypewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Yarn.Unity
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
#if USE_TMP
Expand Down Expand Up @@ -105,10 +106,9 @@ await processor
}

// Let each markup handler know the line has finished displaying
foreach (var markupHandler in ActionMarkupHandlers)
{
markupHandler.OnLineDisplayComplete();
}
await YarnTask.WhenAll(
ActionMarkupHandlers.Select(handler => handler.OnLineDisplayComplete(cancellationToken))
);
}

public void PrepareForContent(Markup.MarkupParseResult line)
Expand Down
8 changes: 4 additions & 4 deletions Runtime/Views/Typewriter/WordTypewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Yarn.Unity
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
#if USE_TMP
Expand Down Expand Up @@ -131,10 +132,9 @@ await processor
}

// Let each markup handler know the line has finished displaying
foreach (var markupHandler in ActionMarkupHandlers)
{
markupHandler.OnLineDisplayComplete();
}
await YarnTask.WhenAll(
ActionMarkupHandlers.Select(handler => handler.OnLineDisplayComplete(cancellationToken))
);
}

public void PrepareForContent(Markup.MarkupParseResult line)
Expand Down