source: trunk/debathena/config/plymouth-config/debathena/debathena.script @ 25870

Revision 25870, 7.2 KB checked in by tboning, 12 years ago (diff)
In plymouth-config: * Initial Release. (Trac: #145)
Line 
1# This is an example plymouth plugin script
2
3Window.SetBackgroundTopColor(0.0, 0.00, 0.00);
4Window.SetBackgroundBottomColor(0.4, 0.0, 0.14);
5
6#--------------------------------------- Logo ------------------------------------
7owl.image = Image("debathena.png");
8owl[0].sprite = Sprite(owl.image);
9owl_blink_time = 60;
10
11logo.image = Image("logo.png");
12logo.sprite = Sprite(logo.image);
13logo.sprite.SetZ (0);
14logo.opacity_angle = 0;
15
16owlX = (Window.GetX() + Window.GetWidth()  / 2 - owl.image.GetWidth()  / 2);
17owlY = (Window.GetY() + Window.GetHeight() / 2 - (owl.image.GetHeight() + logo.image.GetHeight() ) / 2);
18owl[0].sprite.SetZ(-10);
19owl[0].sprite.SetX(owlX);
20owl[0].sprite.SetY(owlY);
21
22logo.sprite.SetX (Window.GetX() + Window.GetWidth()  / 2 - logo.image.GetWidth()  / 2);
23logo.sprite.SetY (Window.GetY() + Window.GetHeight() / 2 - (logo.image.GetHeight() + owl.image.GetHeight() ) / 2 + owl.image.GetHeight() );
24
25#----------------------------------------- Owl Blinking --------------------------------
26
27owl[1].image = Image("debathena1.png");
28owl[2].image = Image("debathena2.png");
29owl[3].image = Image("debathena3.png");
30owl[4].image = Image("debathena4.png");
31owl[5].image = Image("debathena5.png");
32owl[6].image = Image("debathena6.png");
33owl[7].image = Image("debathena7.png");
34owl[8].image = Image("debathena8.png");
35
36for (index = 1; index <= 8; index++) {
37     owl[index].sprite = Sprite(owl[index].image);
38     owl[index].sprite.SetZ(index);
39     owl[index].sprite.SetX(owlX);
40     owl[index].sprite.SetY(owlY);
41     owl[index].sprite.SetOpacity(0);
42}
43
44fun Owl_Blink (t) {
45    fun Owl_Blink_helper (index, time, lowerlim, upperlim) {
46        if ((time < upperlim) * (time >= lowerlim)) {
47           owl[index].sprite.SetOpacity(1);
48        }
49        else {
50           owl[index].sprite.SetOpacity(0);
51        }
52    }
53    Owl_Blink_helper(8, t, -10, 3);
54    Owl_Blink_helper(0, t, 10, owl_blink_time + 2);
55    for (limit = 4; limit <=10; limit++) {
56       Owl_Blink_helper(11 - limit, t, limit-1, limit);
57    }
58}
59
60otime = 0;
61i = 1;
62spinTime = 0;
63fun refresh_callback ()
64  {
65   Owl_Blink(otime);
66   otime = otime + i;
67   if (otime > owl_blink_time)
68      i = -1;   
69   if (otime < 1)
70      i = 1;
71   spinTime++;
72   if (spinTime > 33) {
73      spinTime = spinTime - 33;
74   }
75   Spin(Math.Int(spinTime/3)+1);
76  }
77Plymouth.SetRefreshFunction (refresh_callback);
78#----------------------------------------- Spinner ---------------------------------
79spinner[1].image = Image("throbber-0001.png");
80spinner[2].image = Image("throbber-0002.png");
81spinner[3].image = Image("throbber-0003.png");
82spinner[4].image = Image("throbber-0004.png");
83spinner[5].image = Image("throbber-0005.png");
84spinner[6].image = Image("throbber-0006.png");
85spinner[7].image = Image("throbber-0007.png");
86spinner[8].image = Image("throbber-0008.png");
87spinner[9].image = Image("throbber-0009.png");
88spinner[10].image = Image("throbber-0010.png");
89spinner[11].image = Image("throbber-0011.png");
90spinner[12].image = Image("throbber-0012.png");
91
92spinnerX =  (Window.GetX() + Window.GetWidth()  / 2 - spinner[1].image.GetWidth()  / 2);
93spinnerY = (Window.GetY() + Window.GetHeight() / 2 + (logo.image.GetHeight() + owl.image.GetHeight() + spinner[1].image.GetHeight() ) / 2 );
94
95for (index = 1; index <= 12; index++) {
96   spinner[index].sprite = Sprite(spinner[index].image);
97   spinner[index].sprite.SetZ(0);
98   spinner[index].sprite.SetX(spinnerX);
99   spinner[index].sprite.SetY(spinnerY);
100   spinner[index].sprite.SetOpacity(1);
101}
102
103fun Spin (index) {
104    for (num = 1; num <=12; num++) {
105        spinner[num].sprite.SetOpacity(0);
106    }
107    spinner[index].sprite.SetOpacity(1);
108}
109
110#----------------------------------------- Dialogue --------------------------------
111
112status = "normal";
113
114fun dialog_setup()
115  {
116    local.box;
117    local.lock;
118    local.entry;
119   
120    box.image = Image("box.png");
121    lock.image = Image("lock.png");
122    entry.image = Image("entry.png");
123   
124    box.sprite = Sprite(box.image);
125    box.x = Window.GetX() + Window.GetWidth()  / 2 - box.image.GetWidth ()/2;
126    box.y = Window.GetY() + Window.GetHeight() / 2 - box.image.GetHeight()/2;
127    box.z = 10000;
128    box.sprite.SetPosition(box.x, box.y, box.z);
129   
130    lock.sprite = Sprite(lock.image);
131    lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2;
132    lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2;
133    lock.z = box.z + 1;
134    lock.sprite.SetPosition(lock.x, lock.y, lock.z);
135   
136    entry.sprite = Sprite(entry.image);
137    entry.x = lock.x + lock.image.GetWidth();
138    entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2;
139    entry.z = box.z + 1;
140    entry.sprite.SetPosition(entry.x, entry.y, entry.z);
141   
142    global.dialog.box = box;
143    global.dialog.lock = lock;
144    global.dialog.entry = entry;
145    global.dialog.bullet_image = Image("bullet.png");
146    dialog_opacity (1);
147  }
148   
149fun dialog_opacity(opacity)
150  {
151    dialog.box.sprite.SetOpacity (opacity);
152    dialog.lock.sprite.SetOpacity (opacity);
153    dialog.entry.sprite.SetOpacity (opacity);
154    for (index = 0; dialog.bullet[index]; index++)
155      {
156        dialog.bullet[index].sprite.SetOpacity(opacity);
157      }
158  }
159
160fun display_normal_callback ()
161  {
162    global.status = "normal";
163    if (global.dialog)
164      dialog_opacity (0);
165  }
166
167fun display_password_callback (prompt, bullets)
168  {
169    global.status = "password";
170    if (!global.dialog)
171        dialog_setup();
172    else
173        dialog_opacity(1);
174    for (index = 0; dialog.bullet[index] || index < bullets; index++)
175      {
176        if (!dialog.bullet[index])
177          {
178            dialog.bullet[index].sprite = Sprite(dialog.bullet_image);
179            dialog.bullet[index].x = dialog.entry.x + index * dialog.bullet_image.GetWidth();
180            dialog.bullet[index].y = dialog.entry.y + dialog.entry.image.GetHeight() / 2 - dialog.bullet_image.GetHeight() / 2;
181            dialog.bullet[index].z = dialog.entry.z + 1;
182            dialog.bullet[index].sprite.SetPosition(dialog.bullet[index].x, dialog.bullet[index].y, dialog.bullet[index].z);
183          }
184        if (index < bullets)
185          dialog.bullet[index].sprite.SetOpacity(1);
186        else
187          dialog.bullet[index].sprite.SetOpacity(0);
188      }
189  }
190
191Plymouth.SetDisplayNormalFunction(display_normal_callback);
192Plymouth.SetDisplayPasswordFunction(display_password_callback);
193
194#----------------------------------------- Quit --------------------------------
195
196fun quit_callback ()
197{
198  logo.sprite.SetOpacity (1);
199}
200
201Plymouth.SetQuitFunction(quit_callback);
202
203#----------------------------------------- Message --------------------------------
204
205message_sprites = [];
206message_sprite_count = 0;
207message_sprite_y = 10;
208
209fun display_message_callback (text)
210{
211  my_image = Image.Text(text, 1, 1, 1);
212  message_sprites[message_sprite_count] = Sprite(my_image);
213  message_sprites[message_sprite_count].SetPosition(10, message_sprite_y, 10000);
214  message_sprites[message_sprite_count].text = text;
215  message_sprite_count++;
216  message_sprite_y += my_image.GetHeight();
217}
218
219fun hide_message_callback (text)
220{
221  for (i = 0; i < message_sprite_count; i++)
222    {
223      if (message_sprites[i].text == text)
224        message_sprites[i] = NULL;
225    }
226}
227
228Plymouth.SetDisplayMessageFunction (display_message_callback);
229Plymouth.SetHideMessageFunction (hide_message_callback);
Note: See TracBrowser for help on using the repository browser.