11.stylix/modules/plymouth/theme.script
2022-10-06 12:36:16 +01:00

117 lines
3 KiB
Text

center_x = Window.GetWidth() / 2;
center_y = Window.GetHeight() / 2;
baseline_y = (Window.GetHeight() / 3) * 2;
### LOGO ###
logo.original_image = Image("logo.png");
if (logo.original_image.GetHeight() > 200) {
logo.ratio = logo.original_image.GetWidth() / logo.original_image.GetHeight();
logo.image = logo.original_image.Scale(Math.Int(200 * logo.ratio), 200);
} else {
logo.image = logo.original_image;
}
logo.sprite = Sprite(logo.image);
logo.sprite.SetPosition(
center_x - (logo.image.GetWidth() / 2),
center_y - (logo.image.GetHeight() / 2),
1
);
### PROGRESS ###
progress_background.width = 200;
progress_background.height = 6;
progress_background.original_image = Image("progress-background.png");
progress_background.image = progress_background.original_image.Scale(progress_background.width, progress_background.height);
progress_background.sprite = Sprite(progress_background.image);
progress_background.sprite.SetPosition(
center_x - (progress_background.width / 2),
baseline_y - (progress_background.height / 2),
1
);
progress_bar.width = 0;
progress_bar.max_width = progress_background.width;
progress_bar.height = progress_background.height;
progress_bar.original_image = Image("progress-bar.png");
progress_bar.sprite = Sprite();
progress_bar.sprite.SetPosition(
center_x - (progress_bar.max_width / 2),
baseline_y - (progress_bar.height / 2),
1
);
fun progress_callback (duration, progress) {
progress_bar.width = Math.Int(progress_background.width * progress);
if (progress_bar.image.GetWidth() != progress_bar.width) {
progress_bar.image = progress_bar.original_image.Scale(progress_bar.width, progress_bar.height);
progress_bar.sprite.SetImage(progress_bar.image);
}
}
Plymouth.SetBootProgressFunction(progress_callback);
### PASSWORD ###
prompt = null;
bullets = null;
bullet.image = Image.Text("•", 1, 1, 1);
fun password_callback (prompt_text, bullet_count) {
progress_background.sprite.SetOpacity(0);
progress_bar.sprite.SetOpacity(0);
prompt.image = Image.Text("Enter password", 1, 1, 1);
prompt.sprite = Sprite(prompt.image);
prompt.sprite.SetPosition(
center_x - (prompt.image.GetWidth() / 2),
baseline_y - prompt.image.GetHeight(),
1
);
total_width = bullet_count * bullet.image.GetWidth();
start_x = center_x - (total_width / 2);
bullets = null;
for (i = 0; i < bullet_count; i++) {
bullets[i].sprite = Sprite(bullet.image);
bullets[i].sprite.SetPosition(
start_x + (i * bullet.image.GetWidth()),
baseline_y + bullet.image.GetHeight(),
1
);
}
}
Plymouth.SetDisplayPasswordFunction(password_callback);
### NORMAL ###
fun normal_callback() {
prompt = null;
bullets = null;
progress_background.sprite.SetOpacity(1);
progress_bar.sprite.SetOpacity(1);
}
Plymouth.SetDisplayNormalFunction(normal_callback);
### QUIT ###
fun quit_callback () {
prompt = null;
bullets = null;
progress_background.sprite.SetOpacity(0);
progress_bar.sprite.SetOpacity(0);
}
Plymouth.SetQuitFunction(quit_callback);