Custom Speech Render

Started by Ryan Timothy B, Wed 26/06/2013 23:34:48

Previous topic - Next topic

Ryan Timothy B

Just like the Custom dialog rendering, perhaps having a Custom Speech rendering function.

Just as a quick suggestion to make it similar to the dialog rendering (not that I like this function name, but whatever way you all fancy):
Code: ags
function speech_render(SpeechRenderingInfo *info) {
  // show your own GUI, Overlay, etc, giving a custom way of drawing the speech text to screen
  
  // having access to this stuff: 
    // info.Text to access the text being Said  <-- the text passed with the Say function
    // info.AudioFile  <-- the audofile passed with the Say function
    // info.Delay   <-- the delay that AGS would've had if it were using its own function
    // etc
}

This way for example, when you call Character.Say, this custom speech rendering script will intercept it allowing you to do anything you please without working with AGSs default speech functions. Also this way, you can still have all the AGS abilities of creating voice acting scripts and such whereas now where you currently wouldn't with a custom Say function.

Crimson Wizard

+1 :).

In fact, I was thinking about three functions:
"speech_begin" - allows to preset/precreate stuff;
"speech_render" - for drawing and changing speech data real-time;
"speech_end" - a place to release all dynamic stuff / hide GUIs etc.

For example:
1. In speech_begin show Gui with a wrappable label.
2. In speech_render add a letter to simulate runtime typing.
3. In speech_end hide Gui.

Also, if user is allowed to create SpeechStyle items in game, he may have several speech-styles to choose from, or even set SpeechStyle for a particular character.
In this case those function may also receive SpeechStyle pointer as second parameter; or, going OO way, these functions may be event handlers of a SpeechStyle object.

Ryan Timothy B

#2
Should you need a begin, render and end though? I was thinking of it being like this:

Code: ags
function speech_render(SpeechRenderingInfo *info) {
  gSpeech.Visible = true;
  lSpeechLabel.Text = info.Text;
  // play sound
  if (info.Audio != null) {  // I haven't worked with Audio in a long time, so the following code may be wrong
    info.Audio.Play();
    while (info.Audio.IsPlaying) Wait(1);  // of course not forgetting about skipping text if audio is playing, I got lazy to type it
  } else WaitMouseKey(info.Delay);
  gSpeech.Visible = false;
}


Hmm.. Now that I've had time to think of it, someone isn't forced to actually use begin or end if all they wanted to do was what I wrote above. Someone may not want to render their own speech, but they may want a GUI to pop up during each speech call. It's not a bad idea actually.

monkey0506

This is in the wrong forum. It belongs in Engine Development, not Editor development.

Crimson Wizard

#4
I just want to add, I said three functions because I was considering an option to run speech in non-blocking (asynchronous) fashion.
Though I don't know yet how to organize this. Maybe blocking speech could run only in speech_begin (with Wait() calls) and then set some "end" flag, while "speech_render" (or "speech_play") could be called in a way like repeatedly_execute once in a tick until speech is over (timed out or skipped).
This would allow any dynamic changes on speech lines (non-blocking way), like dynamically typed letters, floating portraits, other screen effects.


PS. monkey, you may as well put "#1 Crimson Wizard basher" in your text. :)

SMF spam blocked by CleanTalk