Window.SetBackgroundTopColor(0, 0, 0); Window.SetBackgroundBottomColor(0, 0, 0); fun dialog_setup() { local.box; local.lock; local.entry; box.image = Image("box.png"); lock.image = Image("lock.png"); entry.image = Image("entry.png"); box.sprite = Sprite(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.z = 10000; box.sprite.SetPosition(box.x, box.y, box.z); lock.sprite = Sprite(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.z = box.z + 1; lock.sprite.SetPosition(lock.x, lock.y, lock.z); entry.sprite = Sprite(entry.image); entry.x = lock.x + lock.image.GetWidth(); entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2; entry.z = box.z + 1; entry.sprite.SetPosition(entry.x, entry.y, entry.z); global.dialog.box = box; global.dialog.lock = lock; global.dialog.entry = entry; global.dialog.bullet_image = Image("bullet.png"); dialog_opacity (1); } fun dialog_opacity(opacity) { dialog.box.sprite.SetOpacity (opacity); dialog.lock.sprite.SetOpacity (opacity); dialog.entry.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); } fun display_password_callback (prompt, bullets) { global.status = "password"; if (!global.dialog) dialog_setup(); else dialog_opacity(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 + 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); } } Plymouth.SetDisplayNormalFunction(display_normal_callback); Plymouth.SetDisplayPasswordFunction(display_password_callback); duration = 100; distro.original_image = ImageNew("bg.png"); starting.original_image = ImageNew("bg.png"); stopping.original_image = ImageNew("bg.png"); mode = Plymouth.GetMode(); # Set the text colour in (rgb / 256) text_colour.red = 1.0; text_colour.green = 1.0; text_colour.blue = 1.0; # Tinted text #988592 tinted_text_colour.red = 0.59; tinted_text_colour.green = 0.52; tinted_text_colour.blue = 0.57; # Action Text - #ffffff - RGB 255 255 255 action_text_colour.red = 1.0; action_text_colour.green = 1.0; action_text_colour.blue = 1.0; # Orange - #ff4012 - RGB 255 64 18 debugsprite = Sprite(); debugsprite_bottom = Sprite(); debugsprite_lower = Sprite(); debugsprite_medium = Sprite(); # are we currently prompting for a password? prompt_active = 0; # General purpose function to create text fun WriteText (text, colour) { image = Image.Text (text, colour.red, colour.green, colour.blue); return image; } fun ImageToText (text) { image = WriteText (text, text_colour); return image; } fun ImageToTintedText (text) { image = WriteText (text, tinted_text_colour); return image; } fun ImageToActionText (text) { image = WriteText (text, action_text_colour); return image; } fun Debug(text) { debugsprite.SetImage(ImageToText (text)); } fun DebugBottom(text) { debugsprite_bottom.SetImage(ImageToText (text)); debugsprite_bottom.SetPosition(0, (Window.GetHeight (0) - 20), 1); } fun DebugLower(text) { debugsprite_lower.SetImage(ImageToText (text)); debugsprite_lower.SetPosition(0, (Window.GetHeight (0) - 40), 1); } fun DebugMedium(text) { debugsprite_medium.SetImage(ImageToText (text)); debugsprite_medium.SetPosition(0, (Window.GetHeight (0) - 60), 1); } fun TextYOffset() { local.y; local.text_height; local.min_height; # Put the 1st line below the logo + some spacing y = logo.y + logo.height + (progress_indicator.bullet_height * 7 ); # + logo_spacing; text_height = first_line_height * 7.5; min_height = Window.GetHeight(); if (y + text_height > min_height) y = min_height - text_height; if (y < progress_indicator.y + progress_indicator.height) return progress_indicator.y + progress_indicator.height; return y; } #------------------------------String functions------------------------------- # This is the equivalent for strstr() fun StringString(string, substring) { start = 0; while (String(string).CharAt (start)) { walk = 0; while (String(substring).CharAt (walk) == String(string).CharAt (start + walk) ) { walk++; if (!String(substring).CharAt (walk)) return start; } start++; } return NULL; } fun StringLength (string) { index = 0; while (String(string).CharAt(index)) index++; return index; } fun StringCopy (source, beginning, end) { local.destination = ""; for (index = beginning; ( ( (end == NULL) || (index <= end) ) && (String(source).CharAt(index)) ); index++) { local.destination += String(source).CharAt(index); } return local.destination; } fun StringReplace (source, pattern, replacement) { local.found = StringString(source, pattern); if (local.found == NULL) return source; local.new_string = StringCopy (source, 0, local.found - 1) + replacement + StringCopy (source, local.found + StringLength(pattern), NULL); return local.new_string; } # it makes sense to use it only for # numbers up to 100 fun StringToInteger (str) { int = -1; for (i=0; i<=100; i++) { if (i+"" == str) { int = i; break; } } return int; } #----------------------------------------------------------------------------- # Previous background colour # #300a24 --> 0.19, 0.04, 0.14 # New background colour # #2c001e --> 0.17, 0.00, 0.12 # Window.SetBackgroundTopColor (0.00, 0.00, 0.00); # Nice colour on top of the screen fading to Window.SetBackgroundBottomColor (0.00, 0.00, 0.00); # an equally nice colour on the bottom logo.image = Image (logo_filename); logo.sprite = Sprite (); logo.sprite.SetImage (logo.image); logo.width = logo.image.GetWidth (); logo.height = logo.image.GetHeight (); logo.x = Window.GetX () + Window.GetWidth () / 2 - logo.width / 2; logo.y = Window.GetY () + Window.GetHeight () / 2; # - logo.height; logo.z = 1000; logo.sprite.SetX (logo.x); logo.sprite.SetY (logo.y); logo.sprite.SetZ (logo.z); logo.sprite.SetOpacity (0); # Spacing below the logo - in pixels logo_spacing = logo.height * 4; background.image = background.original_image.Scale(Window.GetWidth() , Window.GetHeight()); background.sprite = SpriteNew(); background.sprite.SetImage(background.image); background.sprite.SetPosition(Window.GetX(), Window.GetY(), -12); background.sprite.SetOpacity(0); distro.image = distro.original_image.Scale(Window.GetWidth(), Window.GetHeight()); distro.sprite = SpriteNew(); distro.sprite.SetImage(distro.image); #distro.sprite.SetPosition(Window.GetX() + Window.GetWidth () / 2 - distro.image.GetWidth () / 2, Window.GetY() + Window.GetHeight () / 2 - distro.image.GetHeight () / 2, 2); distro.sprite.SetPosition(Window.GetX(), Window.GetY(), 2); distro.sprite.SetOpacity(0); starting.image = starting.original_image.Scale(Window.GetWidth() , Window.GetHeight()); starting.sprite = SpriteNew(); starting.sprite.SetImage(starting.image); #starting.sprite.SetPosition(Window.GetX() + Window.GetWidth () / 2 - starting.image.GetWidth () / 2, Window.GetY() + Window.GetHeight () / 2 - starting.image.GetHeight () / 2, 2); starting.sprite.SetPosition(Window.GetX(), Window.GetY(), 2); starting.sprite.SetOpacity(0); stopping.image = stopping.original_image.Scale(Window.GetWidth() , Window.GetHeight()); stopping.sprite = SpriteNew(); stopping.sprite.SetImage(stopping.image); #stopping.sprite.SetPosition(Window.GetX() + Window.GetWidth () / 2 - stopping.image.GetWidth () / 2, Window.GetY() + Window.GetHeight () / 2 - stopping.image.GetHeight () / 2, 2); stopping.sprite.SetPosition(Window.GetX(), Window.GetY(), 2); stopping.sprite.SetOpacity(0); distro.sprite.SetOpacity(0); if (mode == "boot") { distro.sprite.SetOpacity(1); starting.sprite.SetOpacity(0); } if (mode == "shutdown") { distro.sprite.SetOpacity(0); stopping.sprite.SetOpacity(0); } progress = 0.0; fun remap (val, imin, imax, omin, omax) { opaque = Math.Clamp(1 - ((((val - imin) / (imax - imin)) * (omax - omin)) + omin), 0, 1); return opaque; } message_notification[0].image = ImageToTintedText (""); message_notification[1].image = ImageToTintedText (""); fsck_notification.image = ImageToActionText (""); status = "normal"; progress_indicator.bullet_off = Image (progress_dot_off_filename); progress_indicator.bullet_on = Image (progress_dot_on_filename); progress_indicator.bullet_width = progress_indicator.bullet_off.GetWidth (); progress_indicator.bullet_height = progress_indicator.bullet_off.GetHeight (); progress_indicator.bullet_hspacing = progress_indicator.bullet_width * 1.1; progress_indicator.width = progress_indicator.bullet_width * 5; progress_indicator.height = progress_indicator.bullet_height; #progress_indicator.y = logo.y + logo.height + (logo.height / 4); progress_indicator.y = logo.y + Window.GetHeight () / 24; #was 15 progress_indicator.x = Window.GetX () + Window.GetWidth () / 2.04 - progress_indicator.width / 2; #2.04 was 2 # use a fixed string with ascending and descending stems to calibrate the # bounding box for the first message, so the messages below don't move up # and down according to *their* height. first_line_height = ImageToTintedText ("AfpqtM").GetHeight(); # if the user has a 640x480 or 800x600 display, we can't quite fit everything # (including passphrase prompts) with the target spacing, so scoot the text up # a bit if needed. top_of_the_text = TextYOffset(); #----------------------------------------- Progress Bar -------------------------------- # shutdown_bg.image = Image("progress_bg.png"); shutdown_bg.sprite = Sprite(shutdown_bg.image); shutdown_bg.x = Window.GetWidth() / 2 - progress_bg.image.GetWidth() / 2; shutdown_bg.y = Window.GetHeight() * 0.85 - progress_bg.image.GetHeight() / 2; shutdown_bg.sprite.SetPosition(shutdown_bg.x, shutdown_bg.y, 2); shutdown_box.image = Image("progress_box.png"); shutdown_box.sprite = Sprite(shutdown_box.image); shutdown_box.x = Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; shutdown_box.y = Window.GetHeight() * 0.85 - progress_box.image.GetHeight() / 2; shutdown_box.sprite.SetPosition(shutdown_box.x, shutdown_box.y, 4); shutdown_bar.original_image = Image("progress_bar.png"); shutdown_bar.sprite = Sprite(); shutdown_bar.x = Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2; shutdown_bar.y = Window.GetHeight() / 2 * 1.7 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2; shutdown_bar.sprite.SetPosition(shutdown_bar.x, shutdown_bar.y, 3); if (mode == "boot") { x_logo.sprite.SetOpacity(0); shutdown.sprite.SetOpacity(0); } if (mode == "shutdown") { x_logo.sprite.SetOpacity(0); shutdown.sprite.SetOpacity(0); } progress_bg.image = Image("progress_bg.png"); progress_bg.sprite = Sprite(progress_bg.image); progress_bg.x = Window.GetWidth() / 2 - progress_bg.image.GetWidth() / 2; progress_bg.y = Window.GetHeight() * 0.85 - progress_bg.image.GetHeight() / 2; progress_bg.sprite.SetPosition(progress_bg.x, progress_bg.y, 2); progress_box.image = Image("progress_box.png"); progress_box.sprite = Sprite(progress_box.image); progress_box.x = Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; progress_box.y = Window.GetHeight() * 0.85 - progress_box.image.GetHeight() / 2; progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 4); progress_bar.original_image = Image("progress_bar.png"); progress_bar.sprite = Sprite(); progress_bar.x = Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2; progress_bar.y = Window.GetHeight() / 2 * 1.7 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2; progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 3); fun progress_callback (duration, progress) { progress = (progress * 100) / 70; ####### default panjang progress : 27 global.progress = progress; 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_bar.original_image) * progress, progress_bar.original_image.GetHeight()); progress_bar.sprite.SetImage (progress_bar.image); } } Plymouth.SetBootProgressFunction(progress_callback); if (mode == "boot") { progress_box.sprite.SetOpacity(1); progress_bar.sprite.SetOpacity(1); progress_bg.sprite.SetOpacity(1); } if (mode == "shutdown") { shutdown_box.sprite.SetOpacity(0); shutdown_bar.sprite.SetOpacity(0); shutdown_bg.sprite.SetOpacity(0); } #----------------------------------------- Quit -------------------------------- fun quit_callback () { logo.sprite.SetOpacity (1); } Plymouth.SetQuitFunction(quit_callback); #----------------------------------------- Message -------------------------------- message_sprite = Sprite(); fun message_callback (text) { my_image = Image.Text(text, 1, 1, 1); message_sprite.SetImage(my_image); message_sprite.SetPosition(Window.GetX() + (Window.GetWidth() - my_image.GetWidth()) / 2, Window.GetY() + Window.GetHeight() * 0.93, 10); } Plymouth.SetMessageFunction(message_callback); #-----------------------------------------Refresh stuff -------------------------------- # # Calling Plymouth.SetRefreshFunction with a function will set that function to be # called up to 50 times every second, e.g. # # NOTE: if a refresh function is not set, Plymouth doesn't seem to be able to update # the screen correctly # fun refresh_callback () { # draw_logo (); # if (mode != "suspend" && mode != "resume") { # Window.SetBackgroundTopColor (rt, gt, bt); #gradient - darker at the top of screen Window.SetBackgroundTopColor (r, g, b); #no gradient Window.SetBackgroundBottomColor (r, g, b); } if (mode == "shutdown") { Window.SetBackgroundTopColor (0, 0, 0); #rgb 0.00, 0.11, 0.30 0, 28, 77 001c4d Window.SetBackgroundBottomColor (0, 0, 0); } # } Plymouth.SetRefreshFunction (refresh_callback); #----------------------------------------- Quit -------------------------------- # TODO: Maybe we should also hide any other dialog # Show the logo and make the progress indicator look full when on exit fun quit_callback () { logo.sprite.SetOpacity (0); switch_on_bullets (); } Plymouth.SetQuitFunction(quit_callback);