-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackground.cs
33 lines (27 loc) · 1022 Bytes
/
Background.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using StorybrewCommon.Scripting;
using StorybrewCommon.Storyboarding;
using System.Linq;
namespace StorybrewScripts
{
public class Background : StoryboardObjectGenerator
{
[Configurable]
public string BackgroundPath = "";
[Configurable]
public int StartTime = 0;
[Configurable]
public int EndTime = 0;
[Configurable]
public double Opacity = 0.2;
public override void Generate()
{
if (BackgroundPath == "") BackgroundPath = Beatmap.BackgroundPath ?? string.Empty;
if (StartTime == EndTime) EndTime = (int)(Beatmap.HitObjects.LastOrDefault()?.EndTime ?? AudioDuration);
var bitmap = GetMapsetBitmap(BackgroundPath);
var bg = GetLayer("").CreateSprite(BackgroundPath, OsbOrigin.Centre);
bg.Scale(StartTime, 480.0f / bitmap.Height);
bg.Fade(StartTime - 300, StartTime, 0, Opacity);
bg.Fade(EndTime, EndTime + 500, Opacity, 0);
}
}
}