1
# ubuntustudio-logo.script - boot splash plugin
3
# Copyright (C) 2009 Canonical Ltd.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2, or (at your option)
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
# Written by: Ubuntu Studio Developers <ubuntu-studio-devel@lists.ubuntu.com>
22
# Based on the example provided with the "script plugin" written by:
23
# Charlie Brej <cbrej@cs.man.ac.uk>
26
# Load the image of a icon
27
icon_image = Image("icon.png");
29
# Getting screen ratio to set icon image scale ration
30
screen_ratio = Window.GetHeight() / Window.GetWidth();
31
icon_image_ratio = icon_image.GetHeight() / icon_image.GetWidth();
33
# Scaling icon image by deciding if height or width ratio controls
34
if (screen_ratio > icon_image_ratio)
35
{ # Screen ratio is taller than image ratio, we will match the screen height
36
scale_factor = Window.GetHeight() / icon_image.GetHeight();
39
{ # Screen ratio is wider than image ratio, we will match the screen width
40
scale_factor = Window.GetWidth() / icon_image.GetWidth() * 0.25 ;
42
scaled_icon_image = icon_image.Scale(icon_image.GetWidth() * scale_factor,
43
icon_image.GetHeight() * scale_factor);
44
icon_sprite = Sprite(scaled_icon_image); # Create the a sprite using the scaled icon image
46
# Setting image location to center of screen
47
icon_sprite.SetX(Window.GetWidth() / 2 - scaled_icon_image.GetWidth() / 2); # Place in the center
48
icon_sprite.SetY(Window.GetHeight() / 2 - scaled_icon_image.GetHeight() / 2 - Window.GetHeight() * 0.125); # Placed in center and moved up and additional 1/8 of the total screen height
49
icon_sprite.SetZ(-10000); # Place right at the back
61
fun refresh_callback ()
63
# Currently we do nothing here
66
Plymouth.SetRefreshFunction (refresh_callback);
68
#----------------------------------------- Dialogue --------------------------------
78
box.image = Image("box.png");
79
lock.image = Image("lock.png");
80
entry.image = Image("entry.png");
82
box.sprite = Sprite(box.image);
83
box.x = Window.GetWidth() / 2 - box.image.GetWidth ()/2;
84
box.y = Window.GetHeight() / 2 - box.image.GetHeight()/2;
86
box.sprite.SetPosition(box.x, box.y, box.z);
88
lock.sprite = Sprite(lock.image);
89
lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2;
90
lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2;
92
lock.sprite.SetPosition(lock.x, lock.y, lock.z);
94
entry.sprite = Sprite(entry.image);
95
entry.x = lock.x + lock.image.GetWidth();
96
entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2;
98
entry.sprite.SetPosition(entry.x, entry.y, entry.z);
100
global.dialog.box = box;
101
global.dialog.lock = lock;
102
global.dialog.entry = entry;
103
global.dialog.bullet_image = Image("bullet.png");
107
fun dialog_opacity(opacity)
109
dialog.box.sprite.SetOpacity (opacity);
110
dialog.lock.sprite.SetOpacity (opacity);
111
dialog.entry.sprite.SetOpacity (opacity);
112
for (index = 0; dialog.bullet[index]; index++)
114
dialog.bullet[index].sprite.SetOpacity(opacity);
118
fun display_normal_callback ()
120
global.status = "normal";
125
fun display_password_callback (prompt, bullets)
127
global.status = "password";
132
for (index = 0; dialog.bullet[index] || index < bullets; index++)
134
if (!dialog.bullet[index])
136
dialog.bullet[index].sprite = Sprite(dialog.bullet_image);
137
dialog.bullet[index].x = dialog.entry.x + index * dialog.bullet_image.GetWidth();
138
dialog.bullet[index].y = dialog.entry.y + dialog.entry.image.GetHeight() / 2 - dialog.bullet_image.GetHeight() / 2;
139
dialog.bullet[index].z = dialog.entry.z + 1;
140
dialog.bullet[index].sprite.SetPosition(dialog.bullet[index].x, dialog.bullet[index].y, dialog.bullet[index].z);
143
dialog.bullet[index].sprite.SetOpacity(1);
145
dialog.bullet[index].sprite.SetOpacity(0);
149
Plymouth.SetDisplayNormalFunction(display_normal_callback);
150
Plymouth.SetDisplayPasswordFunction(display_password_callback);
152
#----------------------------------------- Progress Bar --------------------------------
154
progress_box.image = Image("progress_box.png");
155
progress_box.sprite = Sprite(progress_box.image);
157
progress_box.x = Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2;
158
progress_box.y = Window.GetHeight() * 0.75 - progress_box.image.GetHeight() / 2;
159
progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 1);
161
progress_bar.original_image = Image("progress_bar.png");
162
progress_bar.sprite = Sprite();
164
progress_bar.x = Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2;
165
progress_bar.y = Window.GetHeight() / 2 * 1.5 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2;
166
progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 0);
168
fun progress_callback (duration, progress)
170
if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress))
172
progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth(progress_bar.original_image) * progress, progress_bar.original_image.GetHeight());
173
progress_bar.sprite.SetImage (progress_bar.image);
177
Plymouth.SetBootProgressFunction(progress_callback);
179
#----------------------------------------- Quit --------------------------------
185
Plymouth.SetQuitFunction(quit_callback);
187
#----------------------------------------- Message --------------------------------
189
message_sprite = Sprite();
190
message_sprite.SetPosition(10, 10, 10000);
192
fun message_callback (text)
194
my_image = Image.Text(text, 1, 1, 1);
195
message_sprite.SetImage(my_image);
198
Plymouth.SetMessageFunction(message_callback);