Skip to content
Damnae edited this page Aug 23, 2016 · 12 revisions

Lyrics

storybrew can help with making a lyrics storyboard by loading subtitle files and automatically generating text sprites. You can find an example of this in scripts/Lyrics.cs

Loading subtitles

Subtitles can be loaded in your script with the following method:

var subtitles = LoadSubtitles(path);

Where path points to a .srt file in your project's folder (not mapset!). This is a standard subtitle file that can be made with a tool like aegisub. These subtitles contain multiple lines that can be accessed this way:

foreach (var line in subtitles.Lines)

Each line has Text, StartTime and EndTime` properties.

Generating text sprites

First, you need to declare a font:

var font = LoadFont(spritesPath, new FontDescription() {
    FontPath = "Verdana",
    FontSize = 26,
});

Then you can use it to build text sprites:

var texture = font.GetTexture("Some text");
var sprite = layer.CreateSprite(texture.Path, OsbOrigin.Centre, new Vector2(320, 400));

And by using the previously loaded subtitles, you can display your lyrics :

foreach (var line in subtitles.Lines)
{
    var texture = font.GetTexture(line.Text);
    var sprite = layer.CreateSprite(texture.Path, OsbOrigin.Centre, new Vector2(320, SubtitleY));
    sprite.Fade(line.StartTime - 200, line.StartTime, 0, 1);
    sprite.Fade(line.EndTime - 200, line.EndTime, 1, 0);
}

Clone this wiki locally