| | | |
| 1 | 1 | | # This is a modified version of the example plymouth plugin script |
| 3 | 3 | | screen_width = Window.GetWidth(); |
| 4 | 4 | | screen_height = Window.GetHeight(); |
| 6 | 6 | | Window.SetBackgroundTopColor(0, 0, 0); |
| 7 | + | Window.SetBackgro# This is a modified version of the example plymouth plugin script |
| 9 | + | screen_width = Window.GetWidth(); |
| 10 | + | screen_height = Window.GetHeight(); |
| 12 | + | Window.SetBackgroundTopColor(0, 0, 0); |
| 7 | | - | Window.SetBackgroundBottomColor(0, 0, 0); |
| 9 | + | screen_width = Window.GetWidth(); |
| 10 | + | screen_height = Window.GetHeight(); |
| 12 | + | Window.SetBackgroundTopColor(0, 0, 0); |
| 13 | + | Window.SetBackgroundBottomColor(0, 0, 0); |
| 9 | | - | # screen width logo image was made to look best on |
| 10 | | - | logo_image_original_screen_width = 1024; |
| 11 | | - | logo_scale_factor = screen_width / logo_image_original_screen_width; |
| 12 | + | Window.SetBackgroundTopColor(0, 0, 0); |
| 13 | + | Window.SetBackgroundBottomColor(0, 0, 0); |
| 15 | + | # screen width logo image was made to look best on |
| 16 | + | logo_image_original_screen_width = 1024; |
| 17 | + | logo_scale_factor = screen_width / logo_image_original_screen_width; |
| 13 | 19 | | #logo.image = Image("special://logo"); |
| 14 | 20 | | logo.original_image = Image ("crunchbang-logo.png"); |
| 15 | 21 | | logo_width = logo.original_image.GetWidth() * logo_scale_factor; |
| 16 | 22 | | logo_height = logo.original_image.GetHeight() * logo_scale_factor; |
| 17 | 23 | | logo.image = logo.original_image.Scale(logo_width, logo_height); |
| 18 | 24 | | logo.sprite = Sprite(logo.image); |
| 19 | 25 | | logo.opacity_angle = 0; |
| 22 | 28 | | fun refresh_callback () |
| 23 | 29 | | { |
| 24 | 30 | | if (status == "normal") |
| 25 | 31 | | { |
| 26 | 32 | | logo.opacity_angle += ((2 * 3.14) / 50) * 0.5; # 0.5 HZ |
| 27 | 33 | | min_opacity = 0.3; |
| 28 | 34 | | opacity = (Math.Cos(logo.opacity_angle) + 1) / 2; |
| 29 | 35 | | opacity *= 1 - min_opacity; |
| 30 | 36 | | opacity += min_opacity; |
| 31 | 37 | | logo.sprite.SetX (Window.GetX() + screen_width / 2 - logo_width / 2); |
| 32 | 38 | | logo.sprite.SetY (Window.GetY() + screen_height / 2 - logo_height / 2); |
| 33 | 39 | | logo.sprite.SetOpacity (opacity); |
| 34 | 40 | | } |
| 35 | 41 | | else |
| 36 | 42 | | { |
| 37 | 43 | | logo.sprite.SetX (0); |
| 38 | 44 | | logo.sprite.SetY (0); |
| 39 | 45 | | logo.sprite.SetOpacity (1); |
| 40 | 46 | | } |
| 41 | 47 | | } |
| 43 | 49 | | Plymouth.SetRefreshFunction (refresh_callback); |
| 45 | 51 | | status = "normal"; |
| 47 | 53 | | #----------------------------------------- Progress Bar -------------------------------- |
| 48 | 54 | | progress_box_height = (logo_height * 0.1); |
| 49 | 55 | | progress_box_width = (screen_width * 0.4); |
| 51 | 57 | | progress_box.original_image = Image("progress_box.png"); |
| 52 | 58 | | progress_box.image = progress_box.original_image.Scale(progress_box_width, progress_box_height); |
| 53 | 59 | | progress_box.sprite = Sprite(progress_box.image); |
| 55 | 61 | | progress_box.x = Window.GetX() + screen_width / 2 - progress_box_width / 2; |
| 56 | 62 | | progress_box.y = Window.GetY() + screen_height / 2 + logo_height / 2 + progress_box_height * 5; |
| 57 | 63 | | progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); |
| 59 | 65 | | progress_bar.original_image = Image("progress_bar.png"); |
| 60 | 66 | | progress_bar.image = progress_bar.original_image.Scale(0, progress_box_height); |
| 61 | 67 | | progress_bar.sprite = Sprite(); |
| 63 | 69 | | progress_bar.x = progress_box.x; |
| 64 | 70 | | progress_bar.y = progress_box.y; |
| 65 | 71 | | progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); |
| 67 | 73 | | # "progress * 3" for bar width is a hack which should be unnecessary |
| 68 | 74 | | fun progress_callback (duration, progress) |
| 69 | 75 | | { |
| 70 | 76 | | # I don't understand the purpose of this line, but changed it anyway |
| 71 | 77 | | # if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) |
| 72 | 78 | | if (progress_bar.image.GetWidth () != Math.Int (progress_box_width * progress)) |
| 73 | 79 | | { |
| 74 | 80 | | progress_bar.image = progress_bar.original_image.Scale(progress_box_width * progress * 3, progress_box_height); |
| 75 | 81 | | progress_bar.sprite.SetImage (progress_bar.image); |
| 76 | 82 | | } |
| 77 | 83 | | } |
| 79 | 85 | | Plymouth.SetBootProgressFunction(progress_callback); |
| 81 | 87 | | #----------------------------------------- Status Update -------------------------------- |
| 83 | 89 | | NUM_SCROLL_LINES = 5; |
| 84 | 90 | | LINE_WIDTH = 55; |
| 85 | 91 | | # width of one character |
| 86 | 92 | | CHAR_WIDTH = 7; |
| 87 | 93 | | # height of one character |
| 88 | 94 | | CHAR_HEIGHT = 10; |
| 90 | 96 | | fun StringLength(string) { |
| 91 | 97 | | index = 0; |
| 92 | 98 | | str = String(string); |
| 93 | 99 | | while(str.CharAt(index)) index++; |
| 94 | 100 | | return index; |
| 95 | 101 | | } |
| 97 | 103 | | // Initialising text images and their positions |
| 98 | | - | // 20 is the height (including line spacing) of each line |
| 104 | + | // CHAR_HEIGHT * 2 is the height (including line spacing) of each line |
| 99 | 105 | | for (i=0; i < NUM_SCROLL_LINES; i++) { |
| 100 | 106 | | lines[i]= Image.Text(""); |
| 101 | 107 | | message_sprite[i] = Sprite(); |
| 102 | 108 | | message_sprite[i].SetX (Window.GetX() + (screen_width / 2 ) - (LINE_WIDTH * CHAR_WIDTH / 2)); |
| 103 | 109 | | message_sprite[i].SetY (Window.GetY() + (screen_height / 2) + (logo_height /2) +(logo_height * 1.2)+ (i * CHAR_HEIGHT * 2) ); |
| 104 | 110 | | message_sprite[i].SetZ (10000); |
| 105 | 111 | | } |
| 108 | 114 | | fun scroll_message_callback(text) { |
| 110 | 116 | | // Truncate the message if too long |
| 111 | 117 | | if (StringLength(text) > LINE_WIDTH) { |
| 112 | 118 | | text = text.SubString(0, LINE_WIDTH - 3); |
| 113 | 119 | | text += "..."; |
| 114 | 120 | | } |
| 116 | 122 | | // Shift messages one up |
| 117 | 123 | | for (i = 0; i < NUM_SCROLL_LINES - 1; i++) { |
| 118 | 124 | | lines[i] = lines[i+1]; |
| 119 | 125 | | } |
| 121 | 127 | | // Create the image for the latest message |
| 122 | | - | # original script had "lines[i]" |
| 128 | + | # i is a global variable here? It needs to be equal to NUM_SCROLL_LINES - 1 |
| 123 | | - | lines[4] = Image.Text( text, 0.5, 0.5, 0.5); |
| 129 | + | lines[i] = Image.Text( text, 0.5, 0.5, 0.5); |
| 125 | 131 | | // Re-allocate the text images to sprites |
| 126 | 132 | | for (i = 0; i < NUM_SCROLL_LINES; i++) { |
| 127 | 133 | | message_sprite[i].SetImage(lines[i]); |
| 128 | 134 | | } |
| 129 | 135 | | } |
| 131 | 137 | | Plymouth.SetUpdateStatusFunction(scroll_message_callback); |
| 133 | 139 | | # messages get added to updates |
| 134 | 140 | | Plymouth.SetMessageFunction(scroll_message_callback); |
| 136 | 142 | | #----------------------------------------- Quit -------------------------------- |
| 138 | 144 | | fun quit_callback () |
| 139 | 145 | | { |
| 140 | 146 | | logo.sprite.SetOpacity (1); |
| 141 | 147 | | progress_bar.image = progress_bar.original_image.Scale(progress_box_width, progress_box_height); |
| 142 | 148 | | progress_bar.sprite.SetImage(progress_bar.image); |
| 143 | 149 | | } |
| 145 | 151 | | Plymouth.SetQuitFunction(quit_callback); |
| 153 | + | undBottomColor(0, 0, 0); |
| 155 | + | # screen width logo image was made to look best on |
| 156 | + | logo_image_original_screen_width = 1024; |
| 157 | + | logo_scale_factor = screen_width / logo_image_original_screen_width; |
| 159 | + | #logo.image = Image("special://logo"); |
| 160 | + | logo.original_image = Image ("crunchbang-logo.png"); |
| 161 | + | logo_width = logo.original_image.GetWidth() * logo_scale_factor; |
| 162 | + | logo_height = logo.original_image.GetHeight() * logo_scale_factor; |
| 163 | + | logo.image = logo.original_image.Scale(logo_width, logo_height); |
| 164 | + | logo.sprite = Sprite(logo.image); |
| 165 | + | logo.opacity_angle = 0; |
| 168 | + | fun refresh_callback () |
| 169 | + | { |
| 170 | + | if (status == "normal") |
| 171 | + | { |
| 172 | + | logo.opacity_angle += ((2 * 3.14) / 50) * 0.5; # 0.5 HZ |
| 173 | + | min_opacity = 0.3; |
| 174 | + | opacity = (Math.Cos(logo.opacity_angle) + 1) / 2; |
| 175 | + | opacity *= 1 - min_opacity; |
| 176 | + | opacity += min_opacity; |
| 177 | + | logo.sprite.SetX (Window.GetX() + screen_width / 2 - logo_width / 2); |
| 178 | + | logo.sprite.SetY (Window.GetY() + screen_height / 2 - logo_height / 2); |
| 179 | + | logo.sprite.SetOpacity (opacity); |
| 180 | + | } |
| 181 | + | else |
| 182 | + | { |
| 183 | + | logo.sprite.SetX (0); |
| 184 | + | logo.sprite.SetY (0); |
| 185 | + | logo.sprite.SetOpacity (1); |
| 186 | + | } |
| 187 | + | } |
| 189 | + | Plymouth.SetRefreshFunction (refresh_callback); |
| 191 | + | status = "normal"; |
| 193 | + | #----------------------------------------- Progress Bar -------------------------------- |
| 194 | + | progress_box_height = (logo_height * 0.1); |
| 195 | + | progress_box_width = (screen_width * 0.4); |
| 197 | + | progress_box.original_image = Image("progress_box.png"); |
| 198 | + | progress_box.image = progress_box.original_image.Scale(progress_box_width, progress_box_height); |
| 199 | + | progress_box.sprite = Sprite(progress_box.image); |
| 201 | + | progress_box.x = Window.GetX() + screen_width / 2 - progress_box_width / 2; |
| 202 | + | progress_box.y = Window.GetY() + screen_height / 2 + logo_height / 2 + progress_box_height * 5; |
| 203 | + | progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); |
| 205 | + | progress_bar.original_image = Image("progress_bar.png"); |
| 206 | + | progress_bar.image = progress_bar.original_image.Scale(0, progress_box_height); |
| 207 | + | progress_bar.sprite = Sprite(); |
| 209 | + | progress_bar.x = progress_box.x; |
| 210 | + | progress_bar.y = progress_box.y; |
| 211 | + | progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); |
| 213 | + | # "progress * 3" for bar width is a hack which should be unnecessary |
| 214 | + | fun progress_callback (duration, progress) |
| 215 | + | { |
| 216 | + | # I don't understand the purpose of this line, but changed it anyway |
| 217 | + | # if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) |
| 218 | + | if (progress_bar.image.GetWidth () != Math.Int (progress_box_width * progress)) |
| 219 | + | { |
| 220 | + | progress_bar.image = progress_bar.original_image.Scale(progress_box_width * progress * 3, progress_box_height); |
| 221 | + | progress_bar.sprite.SetImage (progress_bar.image); |
| 222 | + | } |
| 223 | + | } |
| 225 | + | Plymouth.SetBootProgressFunction(progress_callback); |
| 227 | + | #----------------------------------------- Status Update -------------------------------- |
| 229 | + | NUM_SCROLL_LINES = 5; |
| 230 | + | LINE_WIDTH = 55; |
| 231 | + | # width of one character |
| 232 | + | CHAR_WIDTH = 7; |
| 233 | + | # height of one character |
| 234 | + | CHAR_HEIGHT = 10; |
| 236 | + | fun StringLength(string) { |
| 237 | + | index = 0; |
| 238 | + | str = String(string); |
| 239 | + | while(str.CharAt(index)) index++; |
| 240 | + | return index; |
| 241 | + | } |
| 243 | + | // Initialising text images and their positions |
| 244 | + | // 20 is the height (including line spacing) of each line |
| 245 | + | for (i=0; i < NUM_SCROLL_LINES; i++) { |
| 246 | + | lines[i]= Image.Text(""); |
| 247 | + | message_sprite[i] = Sprite(); |
| 248 | + | message_sprite[i].SetX (Window.GetX() + (screen_width / 2 ) - (LINE_WIDTH * CHAR_WIDTH / 2)); |
| 249 | + | message_sprite[i].SetY (Window.GetY() + (screen_height / 2) + (logo_height /2) +(logo_height * 1.2)+ (i * CHAR_HEIGHT * 2) ); |
| 250 | + | message_sprite[i].SetZ (10000); |
| 251 | + | } |
| 254 | + | fun scroll_message_callback(text) { |
| 256 | + | // Truncate the message if too long |
| 257 | + | if (StringLength(text) > LINE_WIDTH) { |
| 258 | + | text = text.SubString(0, LINE_WIDTH - 3); |
| 259 | + | text += "..."; |
| 260 | + | } |
| 262 | + | // Shift messages one up |
| 263 | + | for (i = 0; i < NUM_SCROLL_LINES - 1; i++) { |
| 264 | + | lines[i] = lines[i+1]; |
| 265 | + | } |
| 267 | + | // Create the image for the latest message |
| 268 | + | # original script had "lines[i]" |
| 269 | + | lines[4] = Image.Text( text, 0.5, 0.5, 0.5); |
| 271 | + | // Re-allocate the text images to sprites |
| 272 | + | for (i = 0; i < NUM_SCROLL_LINES; i++) { |
| 273 | + | message_sprite[i].SetImage(lines[i]); |
| 274 | + | } |
| 275 | + | } |
| 277 | + | Plymouth.SetUpdateStatusFunction(scroll_message_callback); |
| 279 | + | # messages get added to updates |
| 280 | + | Plymouth.SetMessageFunction(scroll_message_callback); |
| 282 | + | #----------------------------------------- Quit -------------------------------- |
| 284 | + | fun quit_callback () |
| 285 | + | { |
| 286 | + | logo.sprite.SetOpacity (1); |
| 287 | + | progress_bar.image = progress_bar.original_image.Scale(progress_box_width, progress_box_height); |
| 288 | + | progress_bar.sprite.SetImage(progress_bar.image); |
| 289 | + | } |
| 291 | + | Plymouth.SetQuitFunction(quit_callback); |