-
Notifications
You must be signed in to change notification settings - Fork 4
/
arch-beat.script
131 lines (110 loc) · 4.04 KB
/
arch-beat.script
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Screen size
screen.w = Window.GetWidth();
screen.h = Window.GetHeight();
screen.half.w = Window.GetWidth() / 2;
screen.half.h = Window.GetHeight() / 2;
// Logo
logo.image = Image("logo.png");
logo.originalImage = Image("logo.png");
logo.sprite = Sprite();
// Progress bar
loading.image = Image("progress.png");
loading.originalImage = Image("progress.png");
loading.sprite = Sprite();
loading.sprite.SetY(screen.h - 1);
loading.sprite.SetX(0);
// Question prompt
question = null;
answer = null;
// Message
message = null;
// Password prompt
bullets = null;
prompt = null;
bullet.image = Image.Text("*", 1, 1, 1);
// Flow
state.status = "play";
state.time = 0.0;
//--------------------------------- Refresh (Logo animation) --------------------------
fun RefreshCallback() {
if (state.status == "play")
speed = 5;
else
speed = 1;
if (Plymouth.GetMode() == "shutdown")
opacity = 1 - global.progress * 3;
else
opacity = 1;
sin = Math.Sin(state.time * speed) * 0.05;
if (sin < 0)
sin *= 2;
s = Math.Abs(sin) + 0.3;
logo.image = logo.originalImage.Scale(
logo.originalImage.GetWidth() * s,
logo.originalImage.GetHeight() * s
);
logo.sprite.SetImage(logo.image);
logo.sprite.SetX(screen.half.w - logo.image.GetWidth() / 2);
logo.sprite.SetY(screen.half.h - logo.image.GetHeight() / 2);
logo.sprite.SetOpacity(opacity);
loading.image = loading.originalImage.Scale(global.progress * screen.w, 1);
loading.sprite.SetImage(loading.image);
}
Plymouth.SetRefreshFunction(RefreshCallback);
//------------------------------------- Password prompt -------------------------------
fun DisplayQuestionCallback(prompt, entry) {
question = null;
answer = null;
if (entry == "")
entry = "<answer>";
question.image = Image.Text(prompt, 1, 1, 1);
question.sprite = Sprite(question.image);
question.sprite.SetX(screen.half.w - question.image.GetWidth() / 2);
question.sprite.SetY(screen.h - 4 * question.image.GetHeight());
answer.image = Image.Text(entry, 1, 1, 1);
answer.sprite = Sprite(answer.image);
answer.sprite.SetX(screen.half.w - answer.image.GetWidth() / 2);
answer.sprite.SetY(screen.h - 2 * answer.image.GetHeight());
}
Plymouth.SetDisplayQuestionFunction(DisplayQuestionCallback);
//------------------------------------- Password prompt -------------------------------
fun DisplayPasswordCallback(nil, bulletCount) {
state.status = "pause";
totalWidth = bulletCount * bullet.image.GetWidth();
startPos = screen.half.w - totalWidth / 2;
prompt.image = Image.Text("enter password:", 1, 1, 1);
prompt.sprite = Sprite(prompt.image);
prompt.sprite.SetX(screen.half.w - prompt.image.GetWidth() / 2);
prompt.sprite.SetY(screen.h - 4 * prompt.image.GetHeight());
// Clear all bullets (user might hit backspace)
bullets = null;
for (i = 0; i < bulletCount; i++) {
bullets[i].sprite = Sprite(bullet.image);
bullets[i].sprite.SetX(startPos + i * bullet.image.GetWidth());
bullets[i].sprite.SetY(screen.h - 2 * bullet.image.GetHeight());
}
}
Plymouth.SetDisplayPasswordFunction(DisplayPasswordCallback);
//--------------------------- Normal display (unset all text) ----------------------
fun DisplayNormalCallback() {
state.status = "play";
bullets = null;
prompt = null;
message = null;
question = null;
answer = null;
}
Plymouth.SetDisplayNormalFunction(DisplayNormalCallback);
//----------------------------------------- Progress --------------------------------
fun ProgressCallback(duration, progress) {
global.progress = progress;
state.time = duration;
}
Plymouth.SetBootProgressFunction(ProgressCallback);
//----------------------------------------- Message --------------------------------
fun MessageCallback(text) {
message.image = Image.Text(text, 1, 1, 1);
message.sprite = Sprite(message.image);
message.sprite.SetPosition(screen.half.w - message.image.GetWidth() / 2, message.image.GetHeight());
}
Plymouth.SetMessageFunction(MessageCallback);