OSDN Git Service

add some themes for plymouth
[serene/serenelinux-system-pkg.git] / serenelinux-plymouth / usr / share / plymouth / themes / serene-old / serene-logo.script
1 /*
2  * Related to the screen */
3  
4 screen_width = Window.GetWidth();
5 screen_height = Window.GetHeight();
6 screen_x = Window.GetX();
7 screen_y = Window.GetY();
8
9 /**/
10
11 /*
12  * Images, check bits per pixel
13  * and load images accordingly */
14
15 background_image = Image("wallpaper.png");
16 passw_dialog_input_image = Image("passw-dialog.png");
17 bullet_image = Image("test.png");
18
19 bpp = Window.GetBitsPerPixel();
20
21 if (bpp == 4) {
22
23         logotype_image = Image("logo_16bit.png");
24         progress_meter_image = Image("progress-meter_16bit.png");
25         progress_fade_image = Image("progress-fade_16bit.png");
26         fsck_progress_meter_image = Image("progress-meter_16bit.png");
27         fsck_progress_fade_image = Image("fsck-fade_16bit.png");
28
29 }
30 else {
31
32         logotype_image = Image("logo.png");
33         progress_meter_image = Image("progress-meter.png");
34         progress_fade_image = Image("progress-fade.png");
35         fsck_progress_meter_image = Image("progress-meter.png");
36         fsck_progress_fade_image = Image("fsck-fade.png");
37         
38 }
39
40 /**/
41
42 /*
43  * Sprites */
44
45 ratio = screen_height / screen_width;
46 background_ratio = background_image.GetHeight() / background_image.GetWidth();
47 factor = 0;
48
49 if (ratio > background_ratio) {
50
51         factor = screen_height / background_image.GetHeight();
52
53 }
54 else {
55         
56         factor = screen_width / background_image.GetWidth();
57         
58 }
59
60 scaled = background_image.Scale(background_image.GetWidth() * factor, background_image.GetHeight() * factor);
61 background_sprite = Sprite(scaled);
62 background_sprite.SetX(screen_x + screen_width / 2 - scaled.GetWidth() / 2);
63 background_sprite.SetY(screen_y + screen_height / 2 - scaled.GetHeight() / 2);
64
65 logotype_sprite = Sprite(logotype_image);
66
67 fsck_progress_meter_sprite = Sprite(fsck_progress_meter_image);
68 fsck_progress_fade_sprite = Sprite(fsck_progress_fade_image.Scale(1, fsck_progress_fade_image.GetHeight()));
69
70 passw_dialog_input_sprite = Sprite(passw_dialog_input_image);
71 passw_lbl_sprite = Sprite();
72
73 msg_label_sprite = Sprite();
74
75 /**/
76
77 /*
78  * Misc */
79
80 counter = 0;
81
82 fade_pos_x = (screen_width / 2) - (progress_meter_image.GetWidth() / 2);
83 fade_dir = 0; /* 0 = right, 1 = left */
84
85 fsck_running = 0;
86 fsck_dev_array;
87 fsck_dev_counter = 0;
88 fsck_fade_in_counter = 0;
89 fsck_done_fading = 0;
90
91 stars_array;
92 stars_n = 0;
93
94 //full_msg = "";
95 msgs_line = [NULL,NULL,NULL,NULL,NULL];
96
97 /**/
98
99 /*
100  * Debug related */
101  
102 debug = 0;
103 debug_sprite = Sprite();
104
105 fun debugOutput(str) {
106         
107         /*
108          * This will print to the top left corner */
109         debug_sprite.SetImage(Image.Text(str));
110         
111 }
112
113 /**/
114
115 /*
116  * Setup the graphics properties */
117 logotype_sprite.SetPosition(screen_x + (screen_width / 2) - (logotype_image.GetWidth() / 2), screen_y + (screen_height / 2) - (logotype_image.GetHeight() / 2));
118 fsck_progress_meter_sprite.SetPosition(screen_x + (screen_width / 2) - (progress_meter_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 25);
119 fsck_progress_fade_sprite.SetPosition(screen_x + (screen_width / 2) - (progress_meter_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 25);
120 fsck_progress_meter_sprite.SetOpacity(0);
121 fsck_progress_fade_sprite.SetOpacity(0);
122 passw_dialog_input_sprite.SetPosition(screen_x + (screen_width / 2) - (passw_dialog_input_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 70);
123 passw_dialog_input_sprite.SetOpacity(0);
124 passw_lbl_sprite.SetOpacity(0);
125
126 spin = 0;
127
128 /*
129  * this function only goes up to 100
130  * because thats all thats needed for
131  * the progress meter bar */
132 fun atoi(str) {
133    
134     int = -1;
135    
136     for (i = 0; i <= 100; i++) {
137     
138         if (i + "" == str) {
139             
140             int = i;
141             
142             break;
143         
144         }
145     
146     }
147     
148     return int;
149
150 }
151
152 /*
153  * This handler will/can be invoked
154  * 50 times per second.
155  * 
156  * According to the previous author of the
157  * splash script, without this callback
158  * the screen is not updated correctly */
159 spinner_sprite;
160 spinner;
161
162 fun refreshHandler() {
163         
164         if (spin < 3.14 * 2) {
165         
166                 spin = spin + 0.1;
167         
168         }
169         else {
170         
171                 spin = 0;
172         
173         }
174         
175         /* if fsck is running or the password is prompted, hide the spinner */
176         if (fsck_running == 1 || passw_dialog_input_sprite.GetOpacity() == 1) {
177         
178                 spinner_sprite.SetOpacity(0);
179         
180         } else {
181         
182                 spinner = Image("spinner.png");
183                 spinner = spinner.Rotate(spin);
184                 spinner_sprite = Sprite(spinner);
185                 spinner_sprite.SetPosition(screen_x + (screen_width / 2) - (spinner.GetWidth() / 2), screen_y + (screen_height / 2) - (spinner.GetHeight() / 2) + 80);  
186         
187         }
188         
189         if (fade_dir == 0) {
190                 
191                 counter++;
192                 
193                 if (counter >= 200) {
194                         
195                         fade_dir = 1;
196                 
197                 }
198                 
199         }
200         else {
201                 
202                 counter--;
203                 
204                 if (counter <= 0) {
205                         
206                         fade_dir = 0;
207                 
208                 }
209                 
210         }
211         
212         if ((fsck_running == 1) && (fsck_done_fading == 0)) {
213                 
214                 
215                 fsck_progress_meter_sprite.SetOpacity(fsck_fade_in_counter);
216                 fsck_progress_fade_sprite.SetOpacity(fsck_fade_in_counter);
217                 
218                 if (fsck_fade_in_counter < 1) {
219                 
220                         fsck_fade_in_counter+= 0.025;
221                 
222                 }
223                 else {
224                         
225                         fsck_done_fading = 1;
226                         
227                 }
228                 
229         }
230         
231 }
232
233 Plymouth.SetRefreshFunction (refreshHandler);
234
235 /**/
236
237 /*
238  * This function will display the password related information
239  * when being prompt with entering a password */
240 fun showPasswordHandler(prompt, stars) {
241         
242         if (passw_dialog_input_sprite.GetOpacity() == 0 && passw_lbl_sprite.GetOpacity() == 0) {
243                 
244                 passw_dialog_input_sprite.SetOpacity(1);
245                 passw_lbl_sprite.SetOpacity(1);
246                 
247         }
248         
249         tmp_prompt_image = Image.Text(prompt, 1, 1, 1);
250
251         passw_lbl_sprite.SetImage(tmp_prompt_image);
252         passw_lbl_sprite.SetPosition(screen_x + (screen_width / 2) - (tmp_prompt_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 50);
253         
254         for(i = 0; i < stars_n; i++)  {
255         
256                 stars_array[i] = NULL;
257         
258         }
259         
260         stars_n = 0;
261
262         for(i = 0; (i < stars) && (i < 15); i++) {
263                 
264                 stars_array[i] = Sprite(bullet_image);
265                 stars_array[i].SetPosition(screen_x + (((screen_width / 2) - (passw_dialog_input_image.GetWidth() / 2)) + (18 * i)) + 2, screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 75);
266                 stars_n++;
267                 
268         }
269         
270 }
271
272 Plymouth.SetDisplayPasswordFunction(showPasswordHandler);
273
274 /**/
275
276 fun displayNormalHandler() {
277
278         /*
279          * Hide the password dialog and the bullets */
280         
281         if (passw_dialog_input_sprite.GetOpacity() == 1) {
282                 
283                 passw_dialog_input_sprite.SetOpacity(0);
284                 
285         }
286         
287         if (passw_lbl_sprite.GetOpacity() == 1) {
288                 
289                 passw_lbl_sprite.SetOpacity(0);
290                 
291         }
292         
293         for(i = 0; i < stars_n; i++) {
294                 
295                 stars_array[i] = NULL;
296                 
297         }
298
299 }
300
301 Plymouth.SetDisplayNormalFunction(displayNormalHandler);
302
303 fun strlen(string) {
304     
305         i = 0;
306     
307         while (String(string).CharAt(i)) {
308         
309                 i++;
310     
311         }
312         
313         return i;
314
315 }
316
317 /*
318  * This function will display the most current message */
319 fun messageHandler(msg) {
320         
321         if ((msg == "") || !msg) {
322                 
323                 return 0;
324                 
325         }
326         
327         if (msg.SubString(0, 5) == "keys:") {
328         
329                 msg = msg.SubString(5, strlen(msg));
330         
331         }
332
333         # Get the message without the "fsckd-cancel-msg" prefix as we don't support i18n
334         if (msg.SubString(0, 17) == "fsckd-cancel-msg:")
335                 msg = msg.SubString(17, strlen(msg));
336         
337         //full_msg += msg + " ";
338         for(i = 4; i > 0; i--) {
339
340                 msgs_line[i] = msgs_line[i - 1];
341         
342         }
343         
344         msgs_line[0] = Sprite(Image.Text(msg, 1, 1, 1));
345         
346         dist = 1;
347         
348         for(i = 0; i < 5; i++) {
349
350                 if (msgs_line[i] != NULL) {
351
352                         msgs_line[i].SetPosition(screen_x + (screen_width / 2) - (msgs_line[i].GetImage().GetWidth() / 2), screen_y + (screen_height - msgs_line[i].GetImage().GetHeight()) - 20*dist);
353                         dist++;
354
355                 }
356
357         }
358
359 }
360
361 Plymouth.SetMessageFunction(messageHandler);
362
363 /**/
364
365 /*
366  * Handles the updates passed to the plymouth daemon
367  * for example the FSCK data */
368 fun statusHandler(status) {
369         
370         tmp_char;
371         status_array[0] = "";
372         elem_count = 0;
373         
374         for (i = 0; String(status).CharAt(i) != ""; i++) {
375         
376                 tmp_char = String(status).CharAt(i);
377                 
378                 if (tmp_char != ":") {
379                 
380                         status_array[elem_count] += tmp_char;
381                 
382                 }
383                 else {
384                         
385                         elem_count++;
386                         status_array[elem_count] = "";
387                         
388                 }
389                 
390         }
391
392         if (status_array[0] == "fsck") {
393         
394                 already_added = 0;
395                 
396                 if (fsck_running == 0) {
397                         
398                         /*
399                          * use the dedicated message handler for this
400                          * since there is no messages about fsck checks
401                          * currently... */
402                         messageHandler("Routine disk drive check.");
403                         
404                         fsck_running = 1;
405                         
406                 }
407                 
408                 for(i = 0; i < fsck_dev_counter; i++) {
409                         
410                         /* 
411                          * check if the device already exist and update
412                          * the progress only in that case */
413                         if (fsck_dev_array[i][0] == status_array[1]) {
414                                 
415                                 fsck_dev_array[i][1] = status_array[2]; /* progress */
416                                 already_added = 1;
417                         
418                         }
419                         
420                 }
421
422                 /*
423                  * if the device is not added, then add it */
424                 if (already_added == 0) {
425                         
426                         fsck_dev_array[fsck_dev_counter][0] = status_array[1]; /* device */
427                         fsck_dev_array[fsck_dev_counter][1] = status_array[2]; /* progress */
428                         fsck_dev_counter++;
429                         
430                 }
431         
432                 /*
433                  * update the progress */
434                 
435                 total = 0;
436                 
437                 for(i = 0; i < fsck_dev_counter; i++) {
438                         
439                         total += atoi(fsck_dev_array[i][1]);
440                         
441                 }
442
443                 if (fsck_dev_counter > 0) {
444                 
445                         /*
446                         *  display the total percentage */
447                         fsck_progress_fade_sprite.SetImage(fsck_progress_fade_image.Scale((fsck_progress_meter_image.GetWidth() / 100) * (total / fsck_dev_counter), fsck_progress_fade_image.GetHeight()));
448                 
449                 }
450                 
451                 /**/
452                 
453                 /*
454                  * if the total progress is at maximum, 
455                  * make the progress meter go away,
456                  * we might want to fade this out... */ 
457                 if (total == (100 * fsck_dev_counter)) {
458                         
459                         fsck_progress_meter_sprite.SetOpacity(0);
460                         fsck_progress_fade_sprite.SetOpacity(0);
461                 
462                 }
463         
464         }
465
466         # systemd-fsckd pass fsckd:<number_devices>:<progress>:<l10n_string>
467         if (status_array[0] == "fsckd") {
468                 fsck_running = 1;
469
470                 # remove ",x" as we only care about integers
471                 progress_str = status_array[2];
472                 progress = atoi(progress_str.SubString(0, strlen(progress_str) - 2));
473
474                 fsck_progress_fade_sprite.SetImage(fsck_progress_fade_image.Scale((fsck_progress_meter_image.GetWidth() / 100) * progress, fsck_progress_fade_image.GetHeight()));
475
476                 /*
477                  * if the total progress is at maximum, 
478                  * make the progress meter go away,
479                  * we might want to fade this out... */ 
480                 if (progress == 100) {
481                         fsck_progress_meter_sprite.SetOpacity(0);
482                         fsck_progress_fade_sprite.SetOpacity(0);
483                 }
484         }
485         
486 }
487
488 Plymouth.SetUpdateStatusFunction(statusHandler);
489
490 /**/