From d9da252dd3aec21ea4f927eb9c4bd1c8f167f1bc Mon Sep 17 00:00:00 2001 From: Ryan Hughes <1630358+ryanrhughes@users.noreply.github.com> Date: Mon, 7 Jul 2025 23:20:50 -0400 Subject: [PATCH] Rearrange and simplify boot screen --- default/plymouth/omarchy.script | 131 ++++++++++++-------------------- 1 file changed, 48 insertions(+), 83 deletions(-) diff --git a/default/plymouth/omarchy.script b/default/plymouth/omarchy.script index cc63e87..d7b380c 100644 --- a/default/plymouth/omarchy.script +++ b/default/plymouth/omarchy.script @@ -9,81 +9,67 @@ logo.sprite.SetX (Window.GetX() + Window.GetWidth() / 2 - logo.image.GetWidth() logo.sprite.SetY (Window.GetY() + Window.GetHeight() / 2 - logo.image.GetHeight() / 2); logo.sprite.SetOpacity (1); + #----------------------------------------- Dialogue -------------------------------- -status = "normal"; +# Dialog elements - create once, reuse +lock.image = Image("lock.png"); +entry.image = Image("entry.png"); +bullet.image = Image("bullet.png"); -fun dialog_setup() - { - local.lock; - local.entry; - - lock.image = Image("lock.png"); - entry.image = Image("entry.png"); - - entry.sprite = Sprite(entry.image); - entry.x = Window.GetX() + Window.GetWidth()/2 - entry.image.GetWidth() / 2; - entry.y = logo.sprite.GetY() + logo.image.GetHeight() + 40; - entry.z = 10001; - entry.sprite.SetPosition(entry.x, entry.y, entry.z); - - lock.sprite = Sprite(lock.image); - lock.x = entry.x - lock.image.GetWidth() - 10; - lock.y = logo.sprite.GetY() + logo.image.GetHeight() + 40 + entry.image.GetHeight()/2 - lock.image.GetHeight()/2; - lock.z = 10001; - lock.sprite.SetPosition(lock.x, lock.y, lock.z); - - global.dialog.lock = lock; - global.dialog.entry = entry; - global.dialog.bullet_image = Image("bullet.png"); - dialog_opacity (1); - } - -fun dialog_opacity(opacity) - { - global.dialog.lock.sprite.SetOpacity (opacity); - global.dialog.entry.sprite.SetOpacity (opacity); - for (index = 0; global.dialog.bullet[index]; index++) - { - global.dialog.bullet[index].sprite.SetOpacity(opacity); - } - } +entry.sprite = Sprite(entry.image); +entry.x = Window.GetX() + Window.GetWidth()/2 - entry.image.GetWidth() / 2; +entry.y = logo.sprite.GetY() + logo.image.GetHeight() + 40; +entry.sprite.SetPosition(entry.x, entry.y, 10001); +entry.sprite.SetOpacity(0); + +lock.sprite = Sprite(lock.image); +lock.x = entry.x - lock.image.GetWidth() - 10; +lock.y = entry.y + entry.image.GetHeight()/2 - lock.image.GetHeight()/2; +lock.sprite.SetPosition(lock.x, lock.y, 10001); +lock.sprite.SetOpacity(0); + +# Bullet array +bullet.sprites = []; fun display_normal_callback () { - global.status = "normal"; - if (global.dialog) - dialog_opacity (0); + # Hide dialog + lock.sprite.SetOpacity(0); + entry.sprite.SetOpacity(0); + for (index = 0; bullet.sprites[index]; index++) + bullet.sprites[index].SetOpacity(0); + + # Show progress + progress_box.sprite.SetOpacity(1); + progress_bar.sprite.SetOpacity(1); } fun display_password_callback (prompt, bullets) { - global.status = "password"; + # Hide progress + progress_box.sprite.SetOpacity(0); + progress_bar.sprite.SetOpacity(0); - # Setup dialog if it doesn't exist - if (!global.dialog) - dialog_setup(); - else - dialog_opacity(1); + # Show dialog + lock.sprite.SetOpacity(1); + entry.sprite.SetOpacity(1); - # Clear all bullets first (user might hit backspace) - for (index = 0; global.dialog.bullet[index]; index++) - { - global.dialog.bullet[index].sprite.SetOpacity(0); - } + # Clear all bullets first + for (index = 0; bullet.sprites[index]; index++) + bullet.sprites[index].SetOpacity(0); # Create and show bullets for current password for (index = 0; index < bullets; index++) { - if (!global.dialog.bullet[index]) + if (!bullet.sprites[index]) { - global.dialog.bullet[index].sprite = Sprite(global.dialog.bullet_image); - global.dialog.bullet[index].x = global.dialog.entry.x + 10 + index * (global.dialog.bullet_image.GetWidth() + 5); - global.dialog.bullet[index].y = global.dialog.entry.y + global.dialog.entry.image.GetHeight() / 2 - global.dialog.bullet_image.GetHeight() / 2; - global.dialog.bullet[index].z = global.dialog.entry.z + 1; - global.dialog.bullet[index].sprite.SetPosition(global.dialog.bullet[index].x, global.dialog.bullet[index].y, global.dialog.bullet[index].z); + bullet.sprites[index] = Sprite(bullet.image); + bullet.x = entry.x + 10 + index * (bullet.image.GetWidth() + 5); + bullet.y = entry.y + entry.image.GetHeight() / 2 - bullet.image.GetHeight() / 2; + bullet.sprites[index].SetPosition(bullet.x, bullet.y, 10002); } - global.dialog.bullet[index].sprite.SetOpacity(1); + bullet.sprites[index].SetOpacity(1); } } @@ -96,7 +82,7 @@ progress_box.image = Image("progress_box.png"); progress_box.sprite = Sprite(progress_box.image); progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; -progress_box.y = Window.GetY() + Window.GetHeight() * 0.75 - progress_box.image.GetHeight() / 2; +progress_box.y = entry.y + entry.image.GetHeight() / 2 - progress_box.image.GetHeight() / 2; progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); progress_box.sprite.SetOpacity(0); @@ -104,37 +90,16 @@ progress_bar.original_image = Image("progress_bar.png"); progress_bar.sprite = Sprite(); progress_bar.x = Window.GetX() + Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2; -progress_bar.y = Window.GetY() + Window.GetHeight() / 2 * 1.5 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2; +progress_bar.y = progress_box.y + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2; progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); progress_bar.sprite.SetOpacity(0); -global.progress_visible = false; fun progress_callback (duration, progress) { - if (progress > 0.01) + if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) { - if (!global.progress_visible) - { - progress_box.sprite.SetOpacity(1); - progress_bar.sprite.SetOpacity(1); - global.progress_visible = true; - } - - if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) - { - progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth() * progress, progress_bar.original_image.GetHeight()); - progress_bar.sprite.SetImage (progress_bar.image); - } - } - else - { - # Hide progress bar when progress is 0 - if (global.progress_visible) - { - progress_box.sprite.SetOpacity(0); - progress_bar.sprite.SetOpacity(0); - global.progress_visible = false; - } + progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth() * progress, progress_bar.original_image.GetHeight()); + progress_bar.sprite.SetImage (progress_bar.image); } }