Adding subtitles

I’m going to implement subtitles into BGECore Framework. I’m planing to do it with parsing .srt and .sub files and presenting them in a Label. I’m not sure if implement it as an effect (of the sequencer module), a behaviour, or a pure generic class.

So what are your thoughts about this? There is some reason why I should do it differently? Should I parse HTML tags too? Would you use it in your projects?

I do not think that anyone will care how you implement such an aspect. It is important how the aspect interacts with the game (usage).

How to setup your system (e.g. where to place what)?
How to reconfigure on-the-fly (e.g. change language)?
How to provide input (e.g. how to tell it to display what subtitle, when and how long)?
Is it for animation sequences only, or can it be used for interactive game flow too?
How to show multi-choice subtitles for dialogs?

Are .srt and .sub formats sufficient for a game?
They are keyed by a timestamp. Is that what you need?

Is .html sufficient for a game?
It is not keyed at all. It contains a lot more data than required. What tag elements do you want to use to extract subtitle information?

It will be part of BGECore. You install BGECore and done, you can use it. To initialize a subtitle from a scene behavior (it can be done anywere though) you do (if implemented as a behaviour):

subs = self.addBehavior(behavior.Subtitle, “MyLabelHere”)
subs.filepath = “dialog/subtitle.sub”
subs.seek = “12:10:200”

How to reconfigure on-the-fly (e.g. change language)?

You have one .sub file for language, so you just change the filepath during runtime.

How to provide input (e.g. how to tell it to display what subtitle, when and how long)?

It will have the appropriate methods for that. Something like “start_time” and “end_time”.

Is it for animation sequences only, or can it be used for interactive game flow too?
How to show multi-choice subtitles for dialogs?
Are .srt and .sub formats sufficient for a game?
They are keyed by a timestamp. Is that what you need?

It is for animation sequences or video, in any case things where the time is fixed. For example in an horror game you may hear someone talking while you play, that may need subtitles. I plan to add another system (different to this one) for interactive game text. That new system will not work with subtitle files but with 2 other formats. One will be a simple format I will do, the other will be “.rpy” format (so users of RenPy will be able to do VNs as they do now but with all the power of BGE). However that other system will be done after this one is finished, so it will take some time.

Is .html sufficient for a game?
It is not keyed at all. It contains a lot more data than required. What tag elements do you want to use to extract subtitle information?

I do not plan to use HTML files. The .srt format can include HTML tags for text formatting, that is what I may or may not implement.

EDIT: If you want to use it standalone (not as part of BGECore) I suppose that it won’t be too hard to port, however you will need to add some logic bricks and stuff in order for it to work. You will also lose text shadows, HTML formatting (if done) and anti-aliased text since all of these are BGECore features.

From what you describe it sounds like a reasonable concept.

The drawback I see is, that it seams you need a different system for the interactive part. But that should not be a big issue.

It’s done. After all I’ve implemented it as a generic class on the media module and not as a behaviour. The documentation can be found here: http://bgecore.royalwebhosting.net/media.html#core.media.Subtitles
And here a nice screenshot:


Nice !!!

Well since the subtitles are implemented I’ve started working on the interactive text. I will implement Ren’Py directly (since the quest system is already powerfull enough for simplier things). By now I’m able to parse basic scripts like:


define s = Character('Sylvie', color="#c8ffc8")
define m = Character('Me', color="#c8c8ff")

label start:
    "I'll ask her..."

    m "Um... will you..."
    m "Will you be my artist for a visual novel?"

    "Silence."
    "She is shocked, and then..."

    s "Sure, but what is a \"visual novel?\""

Next thing will be images and a tipewritter effect for labels. Maybe in a a few weeks having RenPy inside BGE will not be a dream.

Edit: Typewritter effect done.