Forum rules - please read before posting.

Is there an OnStopSpeechScrollText?

Been playing with the OnStartSpeech and OnStopSpeech delegates.

My Speech system is setup to keep the Speech Window on the screen until the user dismisses it. The speech is also set up to scroll the text into the window.

As such, OnStopSpeech only fires once the user dismisses the window.  Is there a way to listen for text to stop scrolling?

Two fold, trying to set up a "prompt" that shows the user that they can press a button to continue, and to work on lipsynching (Which, effectively, continues until the window is dismissed. Not the behaviour I'd like)

Comments

  • Not currently, but one could perhaps be added.  This would likely get fired whenever the scrolling features - whether due to player interverntion, or it ending naturally.
  • Okay!  Well, I've gone ahead and made myself these new delegates and set them up. I think I found the appropriate spots. If I've missed any, feel free to add more.

    First, open up Scripts\Managers\EventManagers.cs

    Goto line 63, or directly after the "Speech" section, after the function Call_OnStopSpeech, add this:

            /* A delegate for the OnStartSpeechScroll event */
    public delegate void Delegate_StartSpeechScroll(AC.Char speakingCharacter);
    /* An event triggered whenever the scroll text starts typing */
    public static event Delegate_StartSpeechScroll OnStartSpeechScroll;
    /* A delegate for the OnStopSpeechScroll event */
    public delegate void Delegate_StopSpeechScroll(AC.Char speakingCharacter);
    /* An event triggered whenever the scroll text finishes typing, but before the window is dismissed */
    public static event Delegate_StopSpeechScroll OnStopSpeechScroll;


    ///
    /// Triggers the OnStartSpeechScroll event.
    ///
    /// The character who is speaking. If null, the line is considered to be a narration
    public void Call_OnStartSpeechScroll (AC.Char speakingCharacter)
    {
    if (OnStartSpeechScroll != null)
    {
    OnStartSpeechScroll(speakingCharacter);
    }
    }

    ///
    /// Triggers the OnStopSpeechScroll event.
    ///
    /// The character who is speaking. If null, the line is considered to be a narration
    public void Call_OnStopSpeechScroll (AC.Char speakingCharacter)
    {
    if (OnStopSpeechScroll != null)
    {
    OnStopSpeechScroll(speakingCharacter);
    }
    }

    Next, open Scripts\Speech\Speech.cs, goto line: 298 and after displayText ="" add:
    KickStarter.eventManager.Call_OnStartSpeechScroll(_speaker);


    Find scrollAmount += KickStarter.speechManager.textScrollSpeed / 100f / log.fullText.Length; then directly below it, within the curly braces and underneath scrollAmount = 1f; around line: 352 add:

    KickStarter.eventManager.Call_OnStopSpeechScroll(speaker);


    Now, look for the first instance of if (KickStarter.speechManager.endScrollBeforeSkip && CanScroll () && displayText != log.fullText) (around line 539), directly below displayText = log.fullText; add:

    KickStarter.eventManager.Call_OnStopSpeechScroll(speaker);


    And lastly, find the second instance of if (KickStarter.speechManager.endScrollBeforeSkip && CanScroll () && displayText != log.fullText) (around line 583), then directly ABOVE while (gapIndex < speechGaps.Count && speechGaps[gapIndex].waitTime >= 0) add:

    KickStarter.eventManager.Call_OnStopSpeechScroll(speaker);
    ... There! I hope that works for you. I don't know what all people would require for arguments, so I set the default to be AC.Char, or the current speaker. (*shrugs*)

    Hopefully you'll find that useful. ^^  Guess this can go into the Extending section, now...
  • Slight amendment to the locations of two KickStarter calls above...

    The second KickStarter.eventManager.Call_OnStopSpeechScroll(speaker); around line 352, I forgot to take into account that sometimes the scrollAmount would be exactly 1f, so it wouldn't trigger. So instead of placing it inside the curly braces, below the if (scrollAmount > 1f) { [...] }, add a new statement:
                            if (scrollAmount == 1f)
    { // Theoretically this will only trigger once
    KickStarter.eventManager.Call_OnStopSpeechScroll(speaker);
    }

    And instead of the last one near line 583, instead of above the while (gapIndex etc) ,  place it above the if (speechGaps.Count > 0 && speechGaps.Count > gapIndex) directly above it.  I forgot that the previous location was explicitly for scrolling text with gaps.


  • Thanks for posting!  I believe there'll be a little more to it so far as the stop event goes, but I'll go over this all the same and see what can be incorporated officially.
  • Sorry to bump this topic, but thank you so much for implementing an official version of this! ^^
  • You're welcome, it's a useful addition.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.