// Framework Plymouth Theme Script // Adapted from adi1090x plymouth-themes template // Original artwork credit: sniss https://community.frame.work/t/framework-fan-art/6626/39 // Scripting reference: ../SCRIPTING.md // Screen size screen.w = Window.GetWidth(0); screen.h = Window.GetHeight(0); screen.half.w = Window.GetWidth(0) / 2; screen.half.h = Window.GetHeight(0) / 2; // 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) -------------------------- // Frame count: 232 frames (0-231) frame_count = 232; // Load all animation frames for (i = 0; i < frame_count; i++) frame_image[i] = Image("progress-" + i + ".png"); frame_sprite = Sprite(); // Set image position (centered) frame_sprite.SetX(Window.GetX() + (Window.GetWidth(0) / 2 - frame_image[0].GetWidth() / 2)); frame_sprite.SetY(Window.GetY() + (Window.GetHeight(0) / 2 - frame_image[0].GetHeight() / 2)); progress = 0; fun refresh_callback () { // At 50 FPS refresh rate, advance 1 frame per refresh for ~4.6s full animation // (232 frames / 50 FPS = 4.64 seconds, ~3x faster than previous divisor of 3) frame_sprite.SetImage(frame_image[progress % frame_count]); progress++; } Plymouth.SetRefreshFunction (refresh_callback); //------------------------------------- Question prompt ------------------------------- fun DisplayQuestionCallback(prompt, entry) { question = null; answer = null; if (entry == "") entry = ""; 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 (LUKS) ------------------------ 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); //----------------------------------------- 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);