diff options
author | Donald Stewart <watersnowrock@gmail.com> | 2017-05-20 19:52:47 +0200 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-05-20 19:52:47 +0200 |
commit | 2fa1b9cb85364c4898ca9fe2e7301e3674936746 (patch) | |
tree | 867896e1a0b1798311782c6283eabbf3dad78519 /common | |
parent | 6a0cb2241a0fe6880de515af7335237e42c348f9 (diff) | |
download | theme-2fa1b9cb85364c4898ca9fe2e7301e3674936746.tar theme-2fa1b9cb85364c4898ca9fe2e7301e3674936746.tar.gz theme-2fa1b9cb85364c4898ca9fe2e7301e3674936746.tar.bz2 theme-2fa1b9cb85364c4898ca9fe2e7301e3674936746.tar.xz theme-2fa1b9cb85364c4898ca9fe2e7301e3674936746.zip |
Plymouth: Rework boot animation
Fixes mga#19860 for real.
Diffstat (limited to 'common')
-rw-r--r-- | common/plymouth/mga.script | 339 |
1 files changed, 116 insertions, 223 deletions
diff --git a/common/plymouth/mga.script b/common/plymouth/mga.script index 92311dc..32a4374 100644 --- a/common/plymouth/mga.script +++ b/common/plymouth/mga.script @@ -1,135 +1,79 @@ - - -# Mga splashy like theme - Window.GetMaxWidth = fun (){ - i = 0; - width = 0; - while (Window.GetWidth(i)){ - width = Math.Max(width, Window.GetWidth(i)); - i++; + i = 0; + width = 800; # minimum + while (Window.GetWidth(i)){ + width = Math.Max(width, Window.GetWidth(i)); + i++; } - return width; + return width; }; Window.GetMaxHeight = fun (){ - i = 0; - height = 0; - while (Window.GetHeight(i)){ - height = Math.Max(height, Window.GetHeight(i)); - i++; + i = 0; + height = 600; # minium + while (Window.GetHeight(i)){ + height = Math.Max(height, Window.GetHeight(i)); + i++; } - return height; + return height; }; if (Plymouth.GetMode() == "suspend" || Plymouth.GetMode() == "resume") { - background.original_image = ImageNew("suspend.png"); - Window.SetBackgroundTopColor(1, 0, 0); - Window.SetBackgroundBottomColor(0, 1, 0); + background.original_image = ImageNew("suspend.png"); + Window.SetBackgroundTopColor(0.000, 0.000, 0.000); + Window.SetBackgroundBottomColor(0.000, 0.000, 0.000); } else { - logo.original_image = ImageNew("logo.png"); - background.original_image = ImageNew("background.png"); - Window.SetBackgroundTopColor(0.234, 0.43, 0.705); - Window.SetBackgroundBottomColor(0.16, 0.25, 0.44); - - motif.original_image = ImageNew("shadow.png"); - motif.image = motif.original_image.Scale(motif.original_image.GetWidth() * Window.GetMaxWidth() / background.original_image.GetWidth(), motif.original_image.GetHeight() * Window.GetMaxHeight() / background.original_image.GetHeight()); - motif.sprite = SpriteNew(); - motif.sprite.SetImage(motif.image); - motif.sprite.SetOpacity(0); - motif.sprite.SetY((Window.GetMaxHeight() - motif.image.GetHeight()) / 2); - if (Plymouth.GetMode() == "shutdown") { - motif.opacity = 0; - } - else { - motif.opacity = 0; - } -} - -logo.image = logo.original_image.Scale(logo.original_image.GetWidth() , logo.original_image.GetHeight() ); -logo.sprite = SpriteNew(); -logo.sprite.SetImage(logo.image); -offsetx = Window.GetWidth() / 4 - 30 ; -offsety = Window.GetHeight() / 2 - logo.sprite.GetImage().GetHeight() / 2 ; -logo.sprite.SetX (offsetx ); #as bubble and logo image are same size, can be used throughout -logo.sprite.SetY (offsety ); -logo.opacity_angle = 0; - -progressbar2.original_image = ImageNew("bubble1.png"); -progressbar2.image = progressbar2.original_image.Scale(progressbar2.original_image.GetWidth() , progressbar2.original_image.GetHeight() ); -progressbar2.sprite = SpriteNew(); -progressbar2.sprite.SetImage(progressbar2.image); -progressbar2.sprite.SetX(offsetx ); -progressbar2.sprite.SetY(offsety ); -progressbar2.opacity_angle = 0; + background.original_image = ImageNew("background.png"); -progressbar3.original_image = ImageNew("bubble2.png"); -progressbar3.image = progressbar3.original_image.Scale(progressbar3.original_image.GetWidth() , progressbar3.original_image.GetHeight() ); -progressbar3.sprite = SpriteNew(); -progressbar3.sprite.SetImage(progressbar3.image); -progressbar3.sprite.SetX(offsetx ); -progressbar3.sprite.SetY(offsety ); -progressbar3.opacity_angle = 0; - -progressbar4.original_image = ImageNew("bubble3.png"); -progressbar4.image = progressbar4.original_image.Scale(progressbar4.original_image.GetWidth() , progressbar4.original_image.GetHeight() ); -progressbar4.sprite = SpriteNew(); -progressbar4.sprite.SetImage(progressbar4.image); -progressbar4.sprite.SetX(offsetx ); -progressbar4.sprite.SetY(offsety ); -progressbar4.opacity_angle = 0; - -progressbar5.original_image = ImageNew("bubble4.png"); -progressbar5.image = progressbar5.original_image.Scale(progressbar5.original_image.GetWidth() , progressbar5.original_image.GetHeight() ); -progressbar5.sprite = SpriteNew(); -progressbar5.sprite.SetImage(progressbar5.image); -progressbar5.sprite.SetX(offsetx ); -progressbar5.sprite.SetY(offsety ); -progressbar5.opacity_angle = 0; + Window.SetBackgroundTopColor(0.000, 0.000, 0.000); + Window.SetBackgroundBottomColor(0.000, 0.000, 0.000); + + for (i = 0; i < 5; i++) { + anim_images[i] = Image("progress-" + i + ".png"); + } -progressbar6.original_image = ImageNew("bubble5.png"); -progressbar6.image = progressbar6.original_image.Scale(progressbar6.original_image.GetWidth() , progressbar6.original_image.GetHeight() ); -progressbar6.sprite = SpriteNew(); -progressbar6.sprite.SetImage(progressbar6.image); -progressbar6.sprite.SetX(offsetx ); -progressbar6.sprite.SetY(offsety ); -progressbar6.opacity_angle = 0; + logo_image = Image("logo.png"); + logo_sprite = Sprite(logo_image); + offsetx = Window.GetMaxWidth() / 4 - 30 ; + offsety = Window.GetMaxHeight() / 2 - logo_image.GetHeight() / 2 ; + logo_sprite.SetX( offsetx ); + logo_sprite.SetY( offsety ); + + anim_sprite = Sprite(); + anim_sprite.SetX( offsetx ); + anim_sprite.SetY( offsety ); -if (Plymouth.GetMode() == "shutdown") { - progressbar9.sprite.SetOpacity(1); -} else { - progressbar1.sprite.SetOpacity(0); - progressbar2.sprite.SetOpacity(0); - progressbar3.sprite.SetOpacity(0); - progressbar4.sprite.SetOpacity(0); - progressbar5.sprite.SetOpacity(0); - progressbar6.sprite.SetOpacity(0); } +# for now we just take the image as it is - no up or down scaling +# scale_factor = 1; + background.image = background.original_image.Scale(Window.GetMaxWidth() , Window.GetMaxHeight()); + background.sprite = SpriteNew(); background.sprite.SetImage(background.image); -background.sprite.SetPosition(Window.GetX(), Window.GetY(), -10); + +background.sprite.SetX(Window.GetMaxWidth() / 2 - background.image.GetWidth() / 2); # Place in the centre +background.sprite.SetY(Window.GetMaxHeight() / 2 - background.image.GetHeight() / 2); +background.sprite.SetZ(-10000); # Place right at the back sprite_prompt = SpriteNew(); +progress = 0; fun refresh_callback () - { - if (status == "normal") - { - motif.sprite.SetOpacity(motif.opacity); - } +{ + if (status == "normal") { + progress++; + anim_sprite.SetImage(anim_images[Math.Int(progress / 33) % 5]); + } else - { - motif.sprite.SetOpacity(0); - } - - } + anim.sprite.SetOpacity(0); +} if (Plymouth.GetMode() != "suspend" && Plymouth.GetMode() != "resume") { - Plymouth.SetRefreshFunction (refresh_callback); + Plymouth.SetRefreshFunction (refresh_callback); } #----------------------------------------- Dialog -------------------------------- @@ -137,7 +81,7 @@ if (Plymouth.GetMode() != "suspend" && Plymouth.GetMode() != "resume") { status = "normal"; fun dialog_setup() - { +{ local.box; local.lock; local.entry; @@ -150,21 +94,21 @@ fun dialog_setup() box.sprite = SpriteNew(); box.sprite.SetImage(box.image); box.x = Window.GetX() + Window.GetWidth() / 2 - box.image.GetWidth()/2; - box.y = Window.GetY() + Window.GetHeight() / 2 - box.image.GetHeight()/2; + box.y = Window.GetY() + Window.GetHeight() - box.image.GetHeight() - 20 ; box.z = 10000; box.sprite.SetPosition(box.x, box.y, box.z); lock.sprite = SpriteNew(); lock.sprite.SetImage(lock.image); lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2; - lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2; + lock.y = box.y + box.image.GetHeight() - lock.image.GetHeight() - 20 ; lock.z = box.z + 1; lock.sprite.SetPosition(lock.x, lock.y, lock.z); entry.sprite = SpriteNew(); entry.sprite.SetImage(entry.image); entry.x = lock.x + lock.image.GetWidth(); - entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2; + entry.y = box.y + box.image.GetHeight() - entry.image.GetHeight() - 20; entry.z = box.z + 1; entry.sprite.SetPosition(entry.x, entry.y, entry.z); @@ -177,40 +121,41 @@ fun dialog_setup() global.dialog.bullet_image = ImageNew("bullet.png"); global.dialog.prompt_sprite = prompt_sprite; dialog_opacity (1); - } - +} + fun dialog_opacity(opacity) - { +{ dialog.box.sprite.SetOpacity(opacity); dialog.lock.sprite.SetOpacity(opacity); dialog.entry.sprite.SetOpacity(opacity); dialog.prompt_sprite.SetOpacity(opacity); for (index = 0; dialog.bullet[index]; index++) - { + { dialog.bullet[index].sprite.SetOpacity(opacity); - } - } + } +} fun display_normal_callback () - { +{ global.status = "normal"; if (global.dialog) - dialog_opacity (0); - } + dialog_opacity (0); +} fun display_password_callback (prompt, bullets) - { +{ global.status = "password"; if (!global.dialog) dialog_setup(); else dialog_opacity(1); - motif.sprite.SetOpacity(0); + + anim.sprite.SetOpacity(0); +# dialog.prompt_sprite.SetImage(Image.Text(prompt, 0.71764706, 0.90588235 , 0.58431373)); dialog.prompt_sprite.SetImage(Image.Text(prompt, 1, 1, 1)); for (index = 0; dialog.bullet[index] || index < bullets; index++) - { - + { if (!dialog.bullet[index]) { dialog.bullet[index].sprite = SpriteNew(); @@ -221,22 +166,26 @@ fun display_password_callback (prompt, bullets) 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); + dialog.bullet[index].sprite.SetOpacity(1); else - dialog.bullet[index].sprite.SetOpacity(0); - } - } + dialog.bullet[index].sprite.SetOpacity(0); + } +} fun display_message_callback (prompt) - { +{ -prompt = Image.Text(prompt, 1, 1, 1); -sprite_prompt.SetImage(prompt); -sprite_prompt.SetPosition(Window.GetX() + (Window.GetWidth() - prompt.GetWidth()) / 2, Window.GetY() + Window.GetHeight() * 0.93, 2); + #prompt = Image.Text(prompt, 0.71764706, 0.90588235, 0.58431373); + # Change the text to white for better readability + prompt = Image.Text(prompt, 1, 1, 1); + sprite_prompt.SetImage(prompt); + #sprite_prompt.SetPosition(Window.GetX() + (Window.GetWidth() - prompt.GetWidth()) / 2, Window.GetY() + Window.GetHeight() * 0.93, 2); + sprite_prompt.SetPosition(Window.GetX() + (Window.GetWidth() - prompt.GetWidth()) / 2, Window.GetY() + 20, 2); } /* instantiate dialog at startup, to ensure all icons are loaded in memory before initrd is unmounted, in case /usr isn't mounted yet */ -dialog_setup(); dialog_opacity(0); +dialog_setup(); +dialog_opacity(0); Plymouth.SetDisplayNormalFunction(display_normal_callback); Plymouth.SetDisplayPasswordFunction(display_password_callback); Plymouth.SetMessageFunction(display_message_callback); @@ -244,109 +193,53 @@ Plymouth.SetMessageFunction(display_message_callback); #----------------------------------------- Progress Bar -------------------------------- if (Plymouth.GetMode() == "suspend" || Plymouth.GetMode() == "resume") { - progress_box.original_image = ImageNew("progress_box_background.png"); - progress_box.image = progress_box.original_image.Scale(Window.GetMaxWidth() * 0.44, progress_box.original_image.GetHeight()); - progress_box.edge = ImageNew("progress_box_edge.png"); - progress_box.left_edge_sprite = SpriteNew(); - progress_box.right_edge_sprite = SpriteNew(); - progress_box.sprite = SpriteNew(); - progress_box.sprite.SetImage(progress_box.image); - progress_box.left_edge_sprite.SetImage(progress_box.edge); - progress_box.right_edge_sprite.SetImage(progress_box.edge); - - progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; - progress_box.y = Window.GetY() + Window.GetHeight() * 0.86 - progress_box.image.GetHeight() / 2; - - progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); - progress_box.left_edge_sprite.SetPosition(progress_box.x-1, progress_box.y, 0); - progress_box.right_edge_sprite.SetPosition(progress_box.x + progress_box.image.GetWidth() , progress_box.y, 0); - - progress_bar.original_image = ImageNew("progress_bar.png"); - progress_bar.sprite = SpriteNew(); - - progress_bar.sprite.SetPosition(progress_box.x + 1, progress_box.y + 2, 1); + progress_box.original_image = ImageNew("progress_box_background.png"); + progress_box.image = progress_box.original_image.Scale(Window.GetMaxWidth() * 0.44, progress_box.original_image.GetHeight()); + progress_box.edge = ImageNew("progress_box_edge.png"); + progress_box.left_edge_sprite = SpriteNew(); + progress_box.right_edge_sprite = SpriteNew(); + progress_box.sprite = SpriteNew(); + progress_box.sprite.SetImage(progress_box.image); + progress_box.left_edge_sprite.SetImage(progress_box.edge); + progress_box.right_edge_sprite.SetImage(progress_box.edge); + + progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; + progress_box.y = Window.GetY() + Window.GetHeight() * 0.86 - progress_box.image.GetHeight() / 2; + + progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); + progress_box.left_edge_sprite.SetPosition(progress_box.x-1, progress_box.y, 0); + progress_box.right_edge_sprite.SetPosition(progress_box.x + progress_box.image.GetWidth() , progress_box.y, 0); + + progress_bar.original_image = ImageNew("progress_bar.png"); + progress_bar.sprite = SpriteNew(); + + progress_bar.sprite.SetPosition(progress_box.x + 1, progress_box.y + 2, 1); } fun progress_callback (duration, progress) - { -if (Plymouth.GetMode() == "suspend" || Plymouth.GetMode() == "resume") { - motif.opacity = progress; - new_width = (progress_box.image.GetWidth() - 2) * progress; - if (progress_bar.image.GetWidth() != Math.Int (new_width)) - { - progress_bar.image = progress_bar.original_image.Scale(new_width, progress_bar.original_image.GetHeight()); - progress_bar.sprite.SetImage(progress_bar.image); - } - } - - if (Plymouth.GetMode() == "shutdown") { - #motif.opacity = progress; - if ( progress > 0.1 ) { - progressbar6.sprite.SetOpacity(1); - } - if ( progress > 0.25 ) { - progressbar5.sprite.SetOpacity(1); - progressbar6.sprite.SetOpacity(0); - } - if ( progress > 0.4 ) { - progressbar4.sprite.SetOpacity(1); - progressbar5.sprite.SetOpacity(0); - progressbar6.sprite.SetOpacity(0); - } - if ( progress > 0.55 ) { - progressbar3.sprite.SetOpacity(1); - progressbar4.sprite.SetOpacity(0); - progressbar5.sprite.SetOpacity(0); - progressbar6.sprite.SetOpacity(0); - } - if ( progress > 0.7 ) { - progressbar2.sprite.SetOpacity(1); - progressbar3.sprite.SetOpacity(0); - progressbar4.sprite.SetOpacity(0); - progressbar5.sprite.SetOpacity(0); - progressbar6.sprite.SetOpacity(0); - } - if ( progress > 0.85 ) { - progressbar1.sprite.SetOpacity(1); - progressbar2.sprite.SetOpacity(0); - progressbar3.sprite.SetOpacity(0); - progressbar4.sprite.SetOpacity(0); - progressbar5.sprite.SetOpacity(0); - progressbar6.sprite.SetOpacity(0); - } - } - else { - #motif.opacity = 1 - progress; - if ( progress > 0.1 ) { - progressbar1.sprite.SetOpacity(1); - } - if ( progress > 0.25 ) { - progressbar2.sprite.SetOpacity(1); - } - if ( progress > 0.4 ) { - progressbar3.sprite.SetOpacity(1); - } - if ( progress > 0.55 ) { - progressbar4.sprite.SetOpacity(1); - } - if ( progress > 0.7 ) { - progressbar5.sprite.SetOpacity(1); +{ + if (Plymouth.GetMode() == "suspend" || Plymouth.GetMode() == "resume") { + new_width = (progress_box.image.GetWidth() - 2) * progress; + if (progress_bar.image.GetWidth() != Math.Int (new_width)) + { + progress_bar.image = progress_bar.original_image.Scale(new_width, progress_bar.original_image.GetHeight()); + progress_bar.sprite.SetImage(progress_bar.image); + } } - if ( progress > 0.85 ) { - progressbar6.sprite.SetOpacity(1); + else { + # Be super careful with opacity. All values are modded by 1, + # so if we go above 1 we will begin fading in again. } - } - } +} Plymouth.SetBootProgressFunction(progress_callback); - + #----------------------------------------- Quit -------------------------------- fun quit_callback () { - if (Plymouth.GetMode() == "shutdown") { - motif.sprite.SetOpacity(0); - } + anim.sprite.SetOpacity (0); } Plymouth.SetQuitFunction(quit_callback); + |