nTimeStartBootAnimation = @BOOT_ANIM_START_DELAY@; nBootAnimationFrames = 105; nBootAnimationLoopFrames = 45; nBootAnimationSpeed = 0.65; nShutdownAnimationFrames = 18; nShutdownAnimationSpeed = 1.2; nProgressClearScreen = @BOOT_PROGRESS_CLEAR@; x = 0; lasti = 0; loop = 0; bStartAnim = 0; bEnterPassword = 0; screen.x = Window.GetWidth(); screen.y = Window.GetHeight(); screen.hx = screen.x / 2; screen.hy = screen.y / 2; sBootAnim = Sprite(); background.sprite = Sprite(); maintext.sprite = Sprite(); branding.sprite = Sprite(); // Boot screen fun showBootText() { maintext.image = Image("maintext.png"); maintext.sprite = Sprite(maintext.image); maintext.sprite.SetX(screen.hx - (maintext.image.GetWidth() / 2)); maintext.sprite.SetY((screen.hy + 148) - maintext.image.GetHeight() / 2); } fun showBranding() { branding.image = Image("branding.png"); branding.sprite = Sprite(branding.image); branding.sprite.SetX(screen.hx - (branding.image.GetWidth() / 2)); branding.sprite.SetY((screen.hy + 341) - branding.image.GetHeight() / 2); } fun dummyRefreshFunction() { } fun bootClearScreen() { // dummy out the refresh function Plymouth.SetRefreshFunction(dummyRefreshFunction); // hide sprites maintext.sprite.SetOpacity(0); branding.sprite.SetOpacity(0); animation[lasti].sprite.SetOpacity(0); } fun showBootAnimation() { if (bStartAnim == 0) { return; } if (Math.Int(x / 2) < nBootAnimationFrames) { i = (Math.Int(x / 2)) % nBootAnimationFrames; } else { loopBegin = nBootAnimationFrames - nBootAnimationLoopFrames; i = loopBegin + (Math.Int(x / 2) - loopBegin) % nBootAnimationLoopFrames; } animation[i].sprite.SetX(screen.hx - animation[i].image.GetWidth() / 2); animation[i].sprite.SetY(screen.hy - animation[i].image.GetHeight() / 2); animation[i].sprite.SetZ(10); animation[lasti].sprite.SetOpacity(0); animation[i].sprite.SetOpacity(1); lasti = i; x += 1 * nBootAnimationSpeed; } // Shutdown screen fun showShutdownBackground() { background.image = Image("background-shutdown.png"); background.sprite = Sprite(background.image); background.sprite.SetX(screen.hx - (background.image.GetWidth() / 2)); background.sprite.SetY(screen.hy - (background.image.GetHeight() / 2)); background.sprite.SetZ(-2); } fun showBrandingShutdown() { branding.image = Image("branding-white.png"); branding.sprite = Sprite(branding.image); branding.sprite.SetX(screen.hx - (branding.image.GetWidth() / 2)); branding.sprite.SetY((screen.y - 48) - (branding.image.GetHeight() / 2)); } fun showShutdownAnimation() { i = (Math.Int(x / 2)) % nShutdownAnimationFrames; animation[i].sprite.SetX((screen.hx - 93) - animation[i].image.GetWidth() / 2); animation[i].sprite.SetY((screen.hy - 50) - animation[i].image.GetHeight() / 2); animation[i].sprite.SetZ(10); animation[lasti].sprite.SetOpacity(0); animation[i].sprite.SetOpacity(1); lasti = i; x += 1 * nShutdownAnimationSpeed; } // Password prompt fun dialog_setup() { local.entry; entry.image = Image("input-focus.png"); entry.sprite = Sprite(entry.image); entry.x = screen.hx - (entry.image.GetWidth() / 2); entry.y = screen.hy + 200; entry.sprite.SetPosition(entry.x, entry.y); global.dialog.entry = entry; global.dialog.bullet_image = Image("bullet.png"); setPasswordDialogOpacity(1); } fun setPasswordDialogOpacity(opacity) { dialog.entry.sprite.SetOpacity(opacity); for (index = 0; dialog.bullet[index]; index++) { dialog.bullet[index].sprite.SetOpacity(opacity); } } fun displayNormal() { global.bEnterPassword = 0; if (global.dialog) { setPasswordDialogOpacity(0); } } fun displayPassword (prompt, bullets) { if (global.bEnterPassword == 0) { if (!global.dialog) { dialog_setup(); } else { setPasswordDialogOpacity(1); } global.bEnterPassword = 1; } for (index = 0; dialog.bullet[index] || index < bullets; index++) { if (!dialog.bullet[index]) { dialog.bullet[index].sprite = Sprite(dialog.bullet_image); dialog.bullet[index].x = dialog.entry.x + 8 + index * dialog.bullet_image.GetWidth(); dialog.bullet[index].y = dialog.entry.y + dialog.entry.image.GetHeight() / 2 - dialog.bullet_image.GetHeight() / 2; dialog.bullet[index].z = dialog.entry.z + 1; dialog.bullet[index].sprite.SetPosition(dialog.bullet[index].x, dialog.bullet[index].y, dialog.bullet[index].z); } if (index < bullets) { dialog.bullet[index].sprite.SetOpacity(1); } else { dialog.bullet[index].sprite.SetOpacity(0); } } } // Misc fun bootProgress(time, progress) { if (bStartAnim == 0 && time > nTimeStartBootAnimation) { bStartAnim = 1; } if (progress > nProgressClearScreen) { bootClearScreen(); } } fun initBoot() { for (i = 0; i < nBootAnimationFrames; i++) { global.animation[i].image = Image("boot" + (i + 1) + ".png"); global.animation[i].sprite = Sprite(animation[i].image); global.animation[i].sprite.SetOpacity(0); } showBootText(); showBranding(); Plymouth.SetRefreshFunction(showBootAnimation); } fun initShutdown() { for (i = 0; i < nShutdownAnimationFrames; i++) { global.animation[i].image = Image("shutdown" + (i + 1) + ".png"); global.animation[i].sprite = Sprite(animation[i].image); global.animation[i].sprite.SetOpacity(0); } showShutdownBackground(); showBrandingShutdown(); Plymouth.SetRefreshFunction(showShutdownAnimation); } fun init() { if (Plymouth.GetMode() == "boot") { initBoot(); } else if (Plymouth.GetMode() == "shutdown") { initShutdown(); } Window.SetBackgroundTopColor(0, 0, 0); Window.SetBackgroundBottomColor(0, 0, 0); Plymouth.SetBootProgressFunction(bootProgress); Plymouth.SetDisplayNormalFunction(displayNormal); Plymouth.SetDisplayPasswordFunction(displayPassword); } init();