-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAltSideTitle.cs
79 lines (69 loc) · 2.36 KB
/
AltSideTitle.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Celeste;
using Celeste.Mod;
using Microsoft.Xna.Framework;
using Monocle;
using System.Collections;
namespace AltSidesHelper{
class AltSideTitle : Entity {
protected string[] text = new string[0];
protected float[] fade;
protected float[] offsets;
protected float offset;
public AltSideTitle(Session session) : base(){
AreaData areaData = AreaData.Get(session);
string name = areaData.SID.DialogKeyify();
if (Dialog.Has(name + "_altsides_remix_intro")) {
// look for a list: "{name}_altsides_remix_intro"
text = Dialog.Get(name + "_altsides_remix_intro").Split(new string[] { "{break}" }, System.StringSplitOptions.RemoveEmptyEntries);
}else{
// use the Everest format
// level, artist, album
text = new string[] {
Dialog.Get(areaData.Name) + " " + Dialog.Get(name + "_remix"),
Dialog.Get("remix_by") + " " + Dialog.Get(name + "_remix_artist"),
Dialog.Has(name + "_remix_album") ? Dialog.Get(name + "_remix_album") : Dialog.Get("remix_album")
};
}
fade = new float[text.Length];
offsets = new float[text.Length];
Tag = Tags.HUD;
Visible = true;
}
public IEnumerator EaseIn() {
for(int i = 0; i < text.Length; i++) {
Add(new Coroutine(FadeTo(i, 1f, 1f)));
yield return .2f;
}
yield return 1.6f;
}
public IEnumerator EaseOut() {
for(int i = 0; i < text.Length; i++) {
Add(new Coroutine(FadeTo(i, 0f, 1f)));
yield return .2f;
}
yield return 1.6f;
}
public override void Update() {
base.Update();
offset += Engine.DeltaTime * 32f;
}
public override void Render() {
Vector2 value = new Vector2(60f + offset, 800f - MathHelper.Max(text.Length * 60 - 180, 0));
for(int i = 0; i < text.Length; i++) {
string item = text[i];
ActiveFont.Draw(item, value + new Vector2(offsets[i], 60f * i), Color.White * fade[i]);
//Logger.Log("AltSidesHelper", $"Rendering \"{item}\" (no. {i}) with {fade[i]} colour and {offsets[i]} offset at {value + new Vector2(offsets[i], 60f * i)}");
}
}
private IEnumerator FadeTo(int index, float target, float duration) {
while((fade[index] = Calc.Approach(fade[index], target, Engine.DeltaTime / duration)) != target) {
if(target == 0f) {
offsets[index] = Ease.CubeIn(1f - fade[index]) * 32f;
} else {
offsets[index] = (0f - Ease.CubeIn(1f - fade[index])) * 32f;
}
yield return null;
}
}
}
}