]>
Commit | Line | Data |
---|---|---|
3ae5efe3 MT |
1 | /*############################################################################# |
2 | # # | |
3 | # IPFire - An Open Source Firewall Solution # | |
4 | # Copyright (C) 2011 IPFire development team # | |
5 | # # | |
6 | # This program is free software: you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation, either version 3 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # This program is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
18 | # # | |
19 | #############################################################################*/ | |
20 | ||
21 | if ( Plymouth.GetMode () == "boot" ) { | |
22 | /* At the start, we show our logo with a throbber. */ | |
23 | ||
24 | Window.SetBackgroundTopColor (0.52, 0.02, 0.00); | |
25 | Window.SetBackgroundBottomColor (0.00, 0.00, 0.00); | |
26 | ||
27 | logo.image = Image("logo.png"); | |
28 | logo.sprite = Sprite(logo.image); | |
29 | logo.sprite.SetX (Window.GetWidth() / 2 - logo.image.GetWidth() / 2); | |
30 | logo.sprite.SetY (Window.GetHeight() / 2 - logo.image.GetHeight() / 2); | |
31 | logo.sprite.SetZ (10000); | |
32 | progress = 0; | |
33 | ||
34 | progress_box.image = Image("throbber-" + progress + ".png"); | |
35 | progress_box.sprite = Sprite(); | |
36 | progress_box.x = Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; | |
37 | progress_box.y = Window.GetHeight() * 0.85 - progress_box.image.GetHeight() / 2; | |
38 | progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); | |
39 | progress_box.sprite.SetImage(progress_box.image); | |
40 | ||
41 | } else { | |
42 | /* In every other case we just want the logo. */ | |
43 | ||
44 | Window.SetBackgroundTopColor (0.52, 0.02, 0.00); | |
45 | Window.SetBackgroundBottomColor (0.00, 0.00, 0.00); | |
46 | ||
47 | logo.image = Image("logo.png"); | |
48 | logo.sprite = Sprite(logo.image); | |
49 | logo.opacity = 1; | |
50 | } | |
51 | ||
52 | /* This function gets called continuosly by Plymouth, up to 50 times a second */ | |
53 | fun refresh () { | |
54 | /* Again at startup we want a throbber */ | |
55 | ||
56 | mode = Plymouth.GetMode (); | |
57 | if (status == "normal" && mode == "boot" ) { | |
58 | progress++; | |
59 | ||
60 | if (progress >= 99) | |
61 | progress = 0; | |
62 | ||
63 | new_progress_box.image = Image("throbber-" + progress / 3 + ".png"); | |
64 | progress_box.sprite.SetImage(new_progress_box.image); | |
65 | progress_box.sprite.SetOpacity(1); | |
66 | } | |
67 | ||
68 | /* If we're in startup mode but status is not "normal" it probably means that | |
69 | * some event is taking place, possibly a request for password, or maybe | |
70 | * something failed, in any case we should just hide our throbber */ | |
71 | ||
72 | else if (status != "normal" && mode == "boot" ) { | |
73 | progress_box.sprite.SetOpacity(0); | |
74 | } | |
75 | ||
76 | /* If we've gotten here it means the system is shutting down, restarting, | |
77 | * suspending, resuming from suspend or we just don't know wtf's going on. :-D | |
78 | * | |
79 | * In any mode other than startup we just want to display a light logo | |
80 | * on a dark background not only to differentiate it from startup but also to | |
81 | * allow the user to read any messages printed by Plymouth */ | |
82 | ||
83 | else { | |
84 | logo.sprite.SetX (Window.GetWidth() / 2 - logo.image.GetWidth() / 2); | |
85 | logo.sprite.SetY (Window.GetHeight() / 2 - logo.image.GetHeight() / 2); | |
86 | logo.opacity -= 0.005; | |
87 | logo.sprite.SetOpacity(logo.opacity); | |
88 | } | |
89 | } | |
90 | ||
91 | Plymouth.SetRefreshFunction (refresh); | |
92 | ||
93 | /* Dialogue */ | |
94 | ||
95 | status = "normal"; | |
96 | ||
97 | fun dialog_setup() { | |
98 | local.box; | |
99 | local.lock; | |
100 | local.entry; | |
101 | ||
102 | box.image = Image("box.png"); | |
103 | lock.image = Image("lock.png"); | |
104 | entry.image = Image("entry.png"); | |
105 | ||
106 | box.sprite = Sprite(box.image); | |
107 | box.x = Window.GetWidth() / 2 - box.image.GetWidth ()/2; | |
108 | box.y = Window.GetHeight() / 2 - box.image.GetHeight()/2; | |
109 | box.z = 10000; | |
110 | box.sprite.SetPosition(box.x, box.y, box.z); | |
111 | ||
112 | lock.sprite = Sprite(lock.image); | |
113 | lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2; | |
114 | lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2; | |
115 | lock.z = box.z + 1; | |
116 | lock.sprite.SetPosition(lock.x, lock.y, lock.z); | |
117 | ||
118 | entry.sprite = Sprite(entry.image); | |
119 | entry.x = lock.x + lock.image.GetWidth(); | |
120 | entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2; | |
121 | entry.z = box.z + 1; | |
122 | entry.sprite.SetPosition(entry.x, entry.y, entry.z); | |
123 | ||
124 | global.dialog.box = box; | |
125 | global.dialog.lock = lock; | |
126 | global.dialog.entry = entry; | |
127 | global.dialog.bullet_image = Image("bullet.png"); | |
128 | dialog_opacity (1); | |
129 | } | |
130 | ||
131 | fun dialog_opacity(opacity) { | |
132 | dialog.box.sprite.SetOpacity (opacity); | |
133 | dialog.lock.sprite.SetOpacity (opacity); | |
134 | dialog.entry.sprite.SetOpacity (opacity); | |
135 | ||
136 | for (index = 0; dialog.bullet[index]; index++) { | |
137 | dialog.bullet[index].sprite.SetOpacity(opacity); | |
138 | } | |
139 | } | |
140 | ||
141 | fun display_normal_callback () { | |
142 | global.status = "normal"; | |
143 | if (global.dialog) | |
144 | dialog_opacity (0); | |
145 | } | |
146 | ||
147 | fun display_password_callback (prompt, bullets) { | |
148 | global.status = "password"; | |
149 | if (!global.dialog) | |
150 | dialog_setup(); | |
151 | else | |
152 | dialog_opacity(1); | |
153 | ||
154 | for (index = 0; dialog.bullet[index] || index < bullets; index++) { | |
155 | if (!dialog.bullet[index]) { | |
156 | dialog.bullet[index].sprite = Sprite(dialog.bullet_image); | |
157 | dialog.bullet[index].x = dialog.entry.x + index * dialog.bullet_image.GetWidth(); | |
158 | dialog.bullet[index].y = dialog.entry.y + dialog.entry.image.GetHeight() / 2 - dialog.bullet_image.GetHeight() / 2; | |
159 | dialog.bullet[index].z = dialog.entry.z + 1; | |
160 | dialog.bullet[index].sprite.SetPosition(dialog.bullet[index].x, dialog.bullet[index].y, dialog.bullet[index].z); | |
161 | } | |
162 | if (index < bullets) | |
163 | dialog.bullet[index].sprite.SetOpacity(1); | |
164 | else | |
165 | dialog.bullet[index].sprite.SetOpacity(0); | |
166 | } | |
167 | } | |
168 | ||
169 | Plymouth.SetDisplayNormalFunction(display_normal_callback); | |
170 | Plymouth.SetDisplayPasswordFunction(display_password_callback); | |
171 | ||
172 | /* Quit */ | |
173 | ||
174 | fun quit_callback () { | |
175 | logo.sprite.SetOpacity (1); | |
176 | } | |
177 | ||
178 | Plymouth.SetQuitFunction(quit_callback); | |
179 | ||
180 | /* Message */ | |
181 | ||
182 | message_sprite = Sprite(); | |
183 | message_sprite.SetPosition(10, 10, 10000); | |
184 | ||
185 | fun message_callback (text) { | |
186 | my_image = Image.Text(text, 1, 1, 1); | |
187 | message_sprite.SetImage(my_image); | |
188 | } | |
189 | ||
190 | Plymouth.SetMessageFunction(message_callback); |