~ubuntu-branches/ubuntu/saucy/ubuntustudio-look/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/plymouth/themes/ubuntustudio-logo/ubuntustudio-logo.script

  • Committer: Bazaar Package Importer
  • Author(s): Scott Lavender
  • Date: 2011-01-22 09:04:25 UTC
  • Revision ID: james.westby@ubuntu.com-20110122090425-cu5y2jec14btcdjh
Tags: 0.39
* updated plymouth theme - thanks cory (LP: #706312)
* bumped standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#  ubuntustudio-logo.script - boot splash plugin
2
 
3
 
#  Copyright (C) 2009 Canonical Ltd.
4
 
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)
8
 
#  any later version.
9
 
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.
14
 
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
18
 
#  02111-1307, USA.
19
 
20
 
#  Written by: Ubuntu Studio Developers <ubuntu-studio-devel@lists.ubuntu.com>
21
 
#
22
 
#  Based on the example provided with the "script plugin" written by:
23
 
#              Charlie Brej   <cbrej@cs.man.ac.uk>
24
 
25
 
 
26
 
# Load the image of a icon
27
 
icon_image = Image("icon.png");
28
 
 
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();
32
 
 
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();
37
 
  }
38
 
else
39
 
  {  # Screen ratio is wider than image ratio, we will match the screen width
40
 
     scale_factor =  Window.GetWidth() / icon_image.GetWidth() * 0.25 ;
41
 
  }
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
45
 
 
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
50
 
 
51
 
 
52
 
# Add your code here
53
 
 
54
 
 
55
 
 
56
 
 
57
 
 
58
 
 
59
 
 
60
 
 
61
 
fun refresh_callback ()
62
 
  {
63
 
    # Currently we do nothing here
64
 
  }
65
 
  
66
 
Plymouth.SetRefreshFunction (refresh_callback);
67
 
 
68
 
#----------------------------------------- Dialogue --------------------------------
69
 
 
70
 
status = "normal";
71
 
 
72
 
fun dialog_setup()
73
 
  {
74
 
    local.box;
75
 
    local.lock;
76
 
    local.entry;
77
 
    
78
 
    box.image = Image("box.png");
79
 
    lock.image = Image("lock.png");
80
 
    entry.image = Image("entry.png");
81
 
    
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;
85
 
    box.z = 10000;
86
 
    box.sprite.SetPosition(box.x, box.y, box.z);
87
 
    
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;
91
 
    lock.z = box.z + 1;
92
 
    lock.sprite.SetPosition(lock.x, lock.y, lock.z);
93
 
    
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;
97
 
    entry.z = box.z + 1;
98
 
    entry.sprite.SetPosition(entry.x, entry.y, entry.z);
99
 
    
100
 
    global.dialog.box = box;
101
 
    global.dialog.lock = lock;
102
 
    global.dialog.entry = entry;
103
 
    global.dialog.bullet_image = Image("bullet.png");
104
 
    dialog_opacity (1);
105
 
  }
106
 
    
107
 
fun dialog_opacity(opacity)
108
 
  {
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++)
113
 
      {
114
 
        dialog.bullet[index].sprite.SetOpacity(opacity);
115
 
      }
116
 
  }
117
 
 
118
 
fun display_normal_callback ()
119
 
  {
120
 
    global.status = "normal";
121
 
    if (global.dialog)
122
 
      dialog_opacity (0);
123
 
  }
124
 
 
125
 
fun display_password_callback (prompt, bullets)
126
 
  {
127
 
    global.status = "password";
128
 
    if (!global.dialog)
129
 
        dialog_setup();
130
 
    else
131
 
        dialog_opacity(1);
132
 
    for (index = 0; dialog.bullet[index] || index < bullets; index++)
133
 
      {
134
 
        if (!dialog.bullet[index])
135
 
          {
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);
141
 
          }
142
 
        if (index < bullets)
143
 
          dialog.bullet[index].sprite.SetOpacity(1);
144
 
        else
145
 
          dialog.bullet[index].sprite.SetOpacity(0);
146
 
      }
147
 
  }
148
 
 
149
 
Plymouth.SetDisplayNormalFunction(display_normal_callback);
150
 
Plymouth.SetDisplayPasswordFunction(display_password_callback);
151
 
 
152
 
#----------------------------------------- Progress Bar --------------------------------
153
 
 
154
 
progress_box.image = Image("progress_box.png");
155
 
progress_box.sprite = Sprite(progress_box.image);
156
 
 
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);
160
 
 
161
 
progress_bar.original_image = Image("progress_bar.png");
162
 
progress_bar.sprite = Sprite();
163
 
 
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);
167
 
 
168
 
fun progress_callback (duration, progress)
169
 
  {
170
 
    if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress))
171
 
      {
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);
174
 
      }
175
 
  }
176
 
 
177
 
Plymouth.SetBootProgressFunction(progress_callback);
178
 
 
179
 
#----------------------------------------- Quit --------------------------------
180
 
 
181
 
fun quit_callback ()
182
 
{
183
 
}
184
 
 
185
 
Plymouth.SetQuitFunction(quit_callback);
186
 
 
187
 
#----------------------------------------- Message --------------------------------
188
 
 
189
 
message_sprite = Sprite();
190
 
message_sprite.SetPosition(10, 10, 10000);
191
 
 
192
 
fun message_callback (text)
193
 
{
194
 
  my_image = Image.Text(text, 1, 1, 1);
195
 
  message_sprite.SetImage(my_image);
196
 
}
197
 
 
198
 
Plymouth.SetMessageFunction(message_callback);