1 | # This is an example plymouth plugin script |
---|
2 | |
---|
3 | Window.SetBackgroundTopColor(0.0, 0.00, 0.00); |
---|
4 | Window.SetBackgroundBottomColor(0.4, 0.0, 0.14); |
---|
5 | |
---|
6 | #--------------------------------------- Logo ------------------------------------ |
---|
7 | owl.image = Image("debathena.png"); |
---|
8 | owl[0].sprite = Sprite(owl.image); |
---|
9 | owl_blink_time = 60; |
---|
10 | |
---|
11 | logo.image = Image("logo.png"); |
---|
12 | logo.sprite = Sprite(logo.image); |
---|
13 | logo.sprite.SetZ (0); |
---|
14 | logo.opacity_angle = 0; |
---|
15 | |
---|
16 | owlX = (Window.GetX() + Window.GetWidth() / 2 - owl.image.GetWidth() / 2); |
---|
17 | owlY = (Window.GetY() + Window.GetHeight() / 2 - (owl.image.GetHeight() + logo.image.GetHeight() ) / 2); |
---|
18 | owl[0].sprite.SetZ(-10); |
---|
19 | owl[0].sprite.SetX(owlX); |
---|
20 | owl[0].sprite.SetY(owlY); |
---|
21 | |
---|
22 | logo.sprite.SetX (Window.GetX() + Window.GetWidth() / 2 - logo.image.GetWidth() / 2); |
---|
23 | logo.sprite.SetY (Window.GetY() + Window.GetHeight() / 2 - (logo.image.GetHeight() + owl.image.GetHeight() ) / 2 + owl.image.GetHeight() ); |
---|
24 | |
---|
25 | #----------------------------------------- Owl Blinking -------------------------------- |
---|
26 | |
---|
27 | owl[1].image = Image("debathena1.png"); |
---|
28 | owl[2].image = Image("debathena2.png"); |
---|
29 | owl[3].image = Image("debathena3.png"); |
---|
30 | owl[4].image = Image("debathena4.png"); |
---|
31 | owl[5].image = Image("debathena5.png"); |
---|
32 | owl[6].image = Image("debathena6.png"); |
---|
33 | owl[7].image = Image("debathena7.png"); |
---|
34 | owl[8].image = Image("debathena8.png"); |
---|
35 | |
---|
36 | for (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 | |
---|
44 | fun 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 | |
---|
60 | otime = 0; |
---|
61 | i = 1; |
---|
62 | spinTime = 0; |
---|
63 | fun 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 | } |
---|
77 | Plymouth.SetRefreshFunction (refresh_callback); |
---|
78 | #----------------------------------------- Spinner --------------------------------- |
---|
79 | spinner[1].image = Image("throbber-0001.png"); |
---|
80 | spinner[2].image = Image("throbber-0002.png"); |
---|
81 | spinner[3].image = Image("throbber-0003.png"); |
---|
82 | spinner[4].image = Image("throbber-0004.png"); |
---|
83 | spinner[5].image = Image("throbber-0005.png"); |
---|
84 | spinner[6].image = Image("throbber-0006.png"); |
---|
85 | spinner[7].image = Image("throbber-0007.png"); |
---|
86 | spinner[8].image = Image("throbber-0008.png"); |
---|
87 | spinner[9].image = Image("throbber-0009.png"); |
---|
88 | spinner[10].image = Image("throbber-0010.png"); |
---|
89 | spinner[11].image = Image("throbber-0011.png"); |
---|
90 | spinner[12].image = Image("throbber-0012.png"); |
---|
91 | |
---|
92 | spinnerX = (Window.GetX() + Window.GetWidth() / 2 - spinner[1].image.GetWidth() / 2); |
---|
93 | spinnerY = (Window.GetY() + Window.GetHeight() / 2 + (logo.image.GetHeight() + owl.image.GetHeight() + spinner[1].image.GetHeight() ) / 2 ); |
---|
94 | |
---|
95 | for (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 | |
---|
103 | fun 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 | |
---|
112 | status = "normal"; |
---|
113 | |
---|
114 | fun 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 | |
---|
149 | fun 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 | |
---|
160 | fun display_normal_callback () |
---|
161 | { |
---|
162 | global.status = "normal"; |
---|
163 | if (global.dialog) |
---|
164 | dialog_opacity (0); |
---|
165 | } |
---|
166 | |
---|
167 | fun 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 | |
---|
191 | Plymouth.SetDisplayNormalFunction(display_normal_callback); |
---|
192 | Plymouth.SetDisplayPasswordFunction(display_password_callback); |
---|
193 | |
---|
194 | #----------------------------------------- Quit -------------------------------- |
---|
195 | |
---|
196 | fun quit_callback () |
---|
197 | { |
---|
198 | logo.sprite.SetOpacity (1); |
---|
199 | } |
---|
200 | |
---|
201 | Plymouth.SetQuitFunction(quit_callback); |
---|
202 | |
---|
203 | #----------------------------------------- Message -------------------------------- |
---|
204 | |
---|
205 | message_sprites = []; |
---|
206 | message_sprite_count = 0; |
---|
207 | message_sprite_y = 10; |
---|
208 | |
---|
209 | fun 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 | |
---|
219 | fun 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 | |
---|
228 | Plymouth.SetDisplayMessageFunction (display_message_callback); |
---|
229 | Plymouth.SetHideMessageFunction (hide_message_callback); |
---|