2023-05-06 21:33:20 +05:00
/ *
2023-05-12 18:40:45 +05:00
Theme Name : Melawy Lera Sugar
2023-05-06 21:33:20 +05:00
Version : 1.0
Description : My theme
Author : Valeria Fadeeva - https : //github.com/Valeria-Fadeeva
Date : 2023.04 . 04
License : GNU AFFERO GENERAL PUBLIC LICENSE , see < http : //www.gnu.org/licenses/>
* /
Window . GetMaxWidth = function ( ) {
i = 0 ;
width = 0 ;
while ( Window . GetWidth ( i ) ) {
width = Math . Max ( width , Window . GetWidth ( i ) ) ;
i ++ ;
}
return width ;
} ;
Window . GetMaxHeight = function ( ) {
i = 0 ;
height = 0 ;
while ( Window . GetHeight ( i ) ) {
height = Math . Max ( height , Window . GetHeight ( i ) ) ;
i ++ ;
}
return height ;
} ;
Percent = function ( perc , pixels ) {
result = Math . Int ( Math . Abs ( Math . Int ( pixels ) ) / 100 * Math . Abs ( Math . Int ( perc ) ) ) ;
return result ;
} ;
Limit = function ( width , height , perc ) {
local . this ;
this . width = width ;
this . height = height ;
this . perc = perc ;
this . GetWidth = function ( ) {
width = Percent ( this . perc , this . width ) ;
return width ;
} ;
this . GetHeight = function ( ) {
height = Percent ( this . perc , this . height ) ;
return height ;
} ;
return this ;
} ;
ScaleImage = function ( image1 , image2 ) {
img1 . width = image1 . GetWidth ( ) ;
img1 . height = image1 . GetHeight ( ) ;
img1 . ratio = img1 . width / img1 . height ;
img2 . width = image2 . GetWidth ( ) ;
img2 . height = image2 . GetHeight ( ) ;
img2 . ratio = img2 . width / img2 . height ;
if ( img1 . ratio == 1 || ( img1 . width < 200 && img1 . height < 200 ) ) {
img1 . scaled = image1 . Scale ( img2 . width , img2 . height ) ;
return img1 . scaled ;
}
if ( img1 . width == img2 . width && img1 . height == img2 . height ) {
return image1 ;
}
if ( img2 . ratio < img1 . ratio ) {
factor = img2 . height / img1 . height ;
} else {
factor = img2 . width / img1 . width ;
}
img1 . scaled = image1 . Scale ( img1 . width * factor , img1 . height * factor ) ;
return img1 . scaled ;
} ;
FitIntoDimensions = function ( image1 , image2 ) {
img1 . width = image1 . GetWidth ( ) ;
img1 . height = image1 . GetHeight ( ) ;
img2 . width = image2 . GetWidth ( ) ;
img2 . height = image2 . GetHeight ( ) ;
ma = Math . Max ( img1 . width , img2 . height ) ;
mi = Math . Min ( img1 . height , img2 . height ) ;
factor = ma / mi ;
img1 . fit = image1 . Scale ( Math . Int ( img1 . width / factor ) , Math . Int ( img1 . height / factor ) ) ;
} ;
SetSpriteImage = function ( asset , x , y , z ) {
local . sprite = Sprite ( ) ;
sprite . image = Image ( asset ) ;
sprite . width = sprite . image . GetWidth ( ) ;
sprite . height = sprite . image . GetHeight ( ) ;
sprite . SetImage ( sprite . image ) ;
sprite . SetPosition ( x , y , z ) ;
return sprite ;
} ;
// TEXT
2023-05-16 18:47:54 +05:00
common _font = "Noto Sans Mono Regular 10" ;
progressfont = "Noto Sans Mono Regular 12" ;
link _font = "Noto Sans Italic 16" ;
2023-05-06 21:33:20 +05:00
starting _text = "Starting up..." ;
bye _text = "System is shutting down" ;
progress _t = 0 ;
x0 = Window . GetX ( ) ;
y0 = Window . GetY ( ) ;
z0 = Window . GetZ ( ) ;
Window . SetBackgroundTopColor ( 0 , 0 , 0 ) ;
Window . SetBackgroundBottomColor ( 0 , 0 , 0 ) ;
screen . width = Window . GetMaxWidth ( ) ;
screen . height = Window . GetMaxHeight ( ) ;
// BACKGROUND
background . image = Image ( "BACKGROUND.png" ) ;
background . image = ScaleImage ( background . image , Limit ( screen . width , screen . height , 100 ) ) ;
background . width = background . image . GetWidth ( ) ;
background . height = background . image . GetHeight ( ) ;
background . x = x0 + screen . width / 2 - background . width / 2 ;
background . y = y0 + screen . height / 2 - background . height / 2 ;
//background.x = x0;
//background.y = y0;
background . sprite = SpriteNew ( ) ;
background . sprite . SetImage ( background . image ) ;
background . sprite . SetPosition ( background . x , background . y , 0 ) ;
background . sprite . SetOpacity ( 1 ) ;
2023-07-01 14:28:22 +05:00
// SIDE BACKGROUND
side _panel . image = Image ( "SIDE_BACKGROUND2.png" ) ;
side _panel . image = side _panel . image . Scale ( Percent ( 25 , screen . width ) , Percent ( 100 , screen . height ) ) ;
2023-05-06 21:33:20 +05:00
2023-07-01 14:28:22 +05:00
side _panel . width = side _panel . image . GetWidth ( ) ;
side _panel . height = side _panel . image . GetHeight ( ) ;
2023-05-06 21:33:20 +05:00
2023-07-01 14:28:22 +05:00
side _panel . x = x0 ;
side _panel . y = y0 ;
2023-05-06 21:33:20 +05:00
2023-07-01 14:28:22 +05:00
side _panel . sprite = Sprite ( side _panel . image ) ;
side _panel . sprite . SetPosition ( side _panel . x , side _panel . y , 1 ) ;
side _panel . sprite . SetOpacity ( 0.75 ) ;
// MESSAGES BOX
messages _box . image = Image ( "MESSAGES_BOX.png" ) ;
messages _box . image = messages _box . image . Scale ( Percent ( 80 , side _panel . width ) , Percent ( 40 , side _panel . height ) ) ;
messages _box . width = messages _box . image . GetWidth ( ) ;
messages _box . height = messages _box . image . GetHeight ( ) ;
messages _box . x = Percent ( 50 , side _panel . width ) - messages _box . width / 2 ;
messages _box . y = Percent ( 45 , side _panel . height ) - messages _box . height ;
messages _box . sprite = Sprite ( messages _box . image ) ;
messages _box . sprite . SetPosition ( messages _box . x , messages _box . y , 2 ) ;
messages _box . sprite . SetOpacity ( 1 ) ;
2023-05-06 21:33:20 +05:00
// Sise Logo
side _logo . image = Image ( "Melawy_Linux_640x320.png" ) ;
side _logo . image = ScaleImage ( side _logo . image , Limit ( screen . width , screen . height , 20 ) ) ;
side _logo . width = side _logo . image . GetWidth ( ) ;
side _logo . height = side _logo . image . GetHeight ( ) ;
2023-07-01 14:28:22 +05:00
side _logo . x = ( side _panel . width - side _logo . width ) / 2 ;
side _logo . y = side _panel . height - side _panel . height * 0.25 ;
2023-05-06 21:33:20 +05:00
side _logo . sprite = Sprite ( side _logo . image ) ;
2023-05-08 17:37:11 +05:00
side _logo . sprite . SetPosition ( side _logo . x , side _logo . y , 2 ) ;
2023-05-06 21:33:20 +05:00
side _logo . sprite . SetOpacity ( 1 ) ;
// **************************************** //
2023-05-16 18:47:54 +05:00
project _link . image = Image . Text ( "https://github.com/Melawy" , 0.5 , 0.5 , 0.5 , 1 , link _font ) ;
2023-05-06 21:33:20 +05:00
project _link . width = project _link . image . GetWidth ( ) ;
project _link . height = project _link . image . GetHeight ( ) ;
project _link . sprite = Sprite ( project _link . image ) ;
2023-07-01 14:28:22 +05:00
project _link . x = ( side _panel . width - project _link . width ) / 2 ;
2023-05-06 21:33:20 +05:00
project _link . y = side _logo . y + side _logo . height ;
2023-05-08 17:37:11 +05:00
project _link . sprite . SetPosition ( project _link . x , project _link . y , 2 ) ;
2023-05-06 21:33:20 +05:00
project _link . sprite . SetOpacity ( 1 ) ;
// **************************************** //
// LOGO
logo . image = Image ( "MAIN_LOGO.png" ) ;
logo . image = FitIntoDimensions ( logo . image , Limit ( screen . width , screen . height , 35 ) ) ;
logo . sprite = Sprite ( logo . image ) ;
logo . x = screen . width / 2 - logo . image . GetWidth ( ) / 2 ; // позиция логотипа X
logo . y = Percent ( 10 , screen . height ) ; // позиция логотипа Y
logo . sprite . SetPosition ( logo . x , logo . y , 2 ) ;
logo . sprite . SetOpacity ( 1 ) ;
2023-05-08 17:37:11 +05:00
// PROGRESS FORM
progress _form . image = Image ( "PROGRESS_FORM.png" ) ;
2023-07-01 14:28:22 +05:00
progress _form . image = progress _form . image . Scale ( Percent ( 80 , side _panel . width ) , Percent ( 10 , side _panel . height ) ) ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
progress _form . width = progress _form . image . GetWidth ( ) ;
progress _form . height = progress _form . image . GetHeight ( ) ;
2023-05-06 21:33:20 +05:00
2023-07-01 14:28:22 +05:00
progress _form . x = Percent ( 50 , side _panel . width ) - progress _form . width / 2 ;
progress _form . y = Percent ( 75 , side _panel . height ) - progress _form . height ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
progress _form . sprite = Sprite ( progress _form . image ) ;
progress _form . sprite . SetPosition ( progress _form . x , progress _form . y , 2 ) ;
2023-05-12 18:40:45 +05:00
progress _form . sprite . SetOpacity ( 1 ) ;
2023-05-06 21:33:20 +05:00
// SPINNER
spinner . image = Image ( "SPINNER.png" ) ;
spinner . image = spinner . image . Scale ( Percent ( 1 , screen . width ) , Percent ( 1 , screen . width ) ) ;
spinner . width = spinner . image . GetWidth ( ) ;
spinner . height = spinner . image . GetHeight ( ) ;
2023-06-19 21:52:52 +05:00
spinner . x = progress _form . x + progress _form . width - Percent ( 10 , progress _form . width ) ;
spinner . y = progress _form . y + Percent ( 10 , progress _form . height ) ;
2023-05-06 21:33:20 +05:00
spinner . sprite = Sprite ( spinner . image ) ;
2023-05-08 17:37:11 +05:00
spinner . sprite . SetPosition ( spinner . x , spinner . y , 3 ) ; // позиция за или перед
2023-05-06 21:33:20 +05:00
// PROGRESS TEXT
2023-07-01 14:28:22 +05:00
progress _text . image = Image . Text ( progress _t + "%" , 0.5 , 0.5 , 0.5 , 1 , progressfont ) ;
2023-05-06 21:33:20 +05:00
progress _text . width = progress _text . image . GetWidth ( ) ;
progress _text . height = progress _text . image . GetHeight ( ) ;
2023-06-19 21:52:52 +05:00
progress _text . x = progress _form . x + Percent ( 5 , progress _form . width ) ; // позиция % по X
progress _text . y = progress _form . y + Percent ( 10 , progress _form . height ) ; // позиция % по Y
2023-05-06 21:33:20 +05:00
progress _text . sprite = SpriteNew ( ) ;
2023-05-08 17:37:11 +05:00
progress _text . sprite . SetPosition ( progress _text . x , progress _text . y , 3 ) ;
2023-05-06 21:33:20 +05:00
// PROGRESS BOX
progress _box . image = Image ( "PROGRESS_BOX.png" ) ;
2023-05-08 17:37:11 +05:00
progress _box . image = progress _box . image . Scale ( Percent ( 90 , progress _form . width ) , Percent ( 15 , progress _form . height ) ) ;
2023-05-06 21:33:20 +05:00
progress _box . width = progress _box . image . GetWidth ( ) ;
progress _box . height = progress _box . image . GetHeight ( ) ;
2023-05-08 17:37:11 +05:00
progress _box . x = progress _form . x + ( progress _form . width - progress _box . width ) / 2 ;
progress _box . y = progress _form . y + ( progress _form . height - progress _box . height ) / 2 ;
2023-05-06 21:33:20 +05:00
progress _box . sprite = Sprite ( progress _box . image ) ;
2023-05-08 17:37:11 +05:00
progress _box . sprite . SetPosition ( progress _box . x , progress _box . y , 3 ) ;
2023-05-06 21:33:20 +05:00
// PROGRESS BAR
progress _bar . original _image = Image ( "PROGRESS_BAR.png" ) ;
2023-05-08 17:37:11 +05:00
progress _bar . original _image = progress _bar . original _image . Scale ( Percent ( 90 , progress _form . width ) , Percent ( 15 , progress _form . height ) ) ;
2023-05-06 21:33:20 +05:00
progress _bar . width = progress _bar . original _image . GetWidth ( ) ;
progress _bar . height = progress _bar . original _image . GetHeight ( ) ;
2023-05-08 17:37:11 +05:00
progress _bar . x = progress _form . x + ( progress _form . width - progress _bar . original _image . GetWidth ( ) ) / 2 ;
progress _bar . y = progress _form . y + ( progress _form . height - progress _bar . original _image . GetHeight ( ) ) / 2 ;
2023-05-06 21:33:20 +05:00
progress _bar . sprite = Sprite ( ) ;
2023-05-08 17:37:11 +05:00
progress _bar . sprite . SetPosition ( progress _bar . x , progress _bar . y , 4 ) ;
2023-05-06 21:33:20 +05:00
// PROGRESS FADE
progress _fade . image = Image ( "PROGRESS_FADE.png" ) ;
2023-05-08 17:37:11 +05:00
progress _fade . image = progress _fade . image . Scale ( Percent ( 10 , progress _form . width ) , Percent ( 15 , progress _form . height ) ) ;
2023-05-06 21:33:20 +05:00
progress _fade . width = progress _fade . image . GetWidth ( ) ;
progress _fade . height = progress _fade . image . GetHeight ( ) ;
progress _fade . sprite = Sprite ( progress _fade . image ) ;
fade _dir = 0 ; // 0 = right, 1 = left
counter = 0 ;
max _counter = progress _box . width - progress _fade . width ;
2023-07-01 14:28:22 +05:00
2023-05-06 21:33:20 +05:00
function progress _callback ( duration , progress ) {
if ( progress _bar . image . GetWidth ( ) != Math . Int ( progress _bar . original _image . GetWidth ( ) * progress ) ) {
progress _bar . image = progress _bar . original _image . Scale ( progress _bar . original _image . GetWidth ( progress _bar . original _image ) * progress , progress _bar . original _image . GetHeight ( ) ) ;
progress _bar . sprite . SetImage ( progress _bar . image ) ;
f = Math . Int ( progress _bar . image . GetWidth ( ) / progress _bar . original _image . GetWidth ( ) * 100 ) ;
2023-07-01 14:28:22 +05:00
progress _t . image = Image . Text ( f + "%" , 0.5 , 0.5 , 0.5 , 1 , progressfont ) ;
2023-05-06 21:33:20 +05:00
progress _text . sprite . SetImage ( progress _t . image ) ;
}
}
Plymouth . SetBootProgressFunction ( progress _callback ) ;
2023-07-01 14:28:22 +05:00
2023-05-06 21:33:20 +05:00
// DIALOG
status = "normal" ;
//count = 0;
function dialog _setup ( ) {
2023-05-08 17:37:11 +05:00
local . box _form ;
2023-05-06 21:33:20 +05:00
local . lock ;
local . entry ;
2023-05-16 18:47:54 +05:00
local . hint ;
local . bullet _i ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
box _form . image = Image ( "BOX.png" ) ;
2023-07-01 14:28:22 +05:00
box _form . image = box _form . image . Scale ( Percent ( 80 , side _panel . width ) , Percent ( 10 , side _panel . height ) ) ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
box _form . width = box _form . image . GetWidth ( ) ;
box _form . height = box _form . image . GetHeight ( ) ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
box _form . x = progress _form . x ;
2023-07-01 14:28:22 +05:00
box _form . y = progress _form . y - box _form . height - Percent ( 1 , side _panel . height ) ;
2023-05-08 17:37:11 +05:00
box _form . z = 10000 ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
box _form . sprite = Sprite ( box _form . image ) ;
box _form . sprite . SetPosition ( box _form . x , box _form . y , box _form . z ) ;
2023-05-12 18:40:45 +05:00
box _form . sprite . SetOpacity ( 1 ) ;
2023-05-06 21:33:20 +05:00
entry . image = Image ( "ENTRY.png" ) ;
2023-05-08 17:37:11 +05:00
entry . image = entry . image . Scale ( Percent ( 90 , box _form . width ) , Percent ( 33 , box _form . height ) ) ;
2023-05-06 21:33:20 +05:00
entry . width = entry . image . GetWidth ( ) ;
entry . height = entry . image . GetHeight ( ) ;
2023-05-08 17:37:11 +05:00
entry . x = box _form . x + box _form . width / 2 - entry . width / 2 ;
entry . y = box _form . y + box _form . height / 2 - entry . height / 2 ;
entry . z = box _form . z + 1 ;
2023-05-06 21:33:20 +05:00
entry . sprite = Sprite ( entry . image ) ;
entry . sprite . SetPosition ( entry . x , entry . y , entry . z ) ;
lock . image = Image ( "LOCK.png" ) ;
lock . image = lock . image . Scale ( Percent ( 95 , entry . height ) , Percent ( 95 , entry . height ) ) ;
lock . width = lock . image . GetWidth ( ) ;
lock . height = lock . image . GetHeight ( ) ;
lock . x = entry . x + entry . width - lock . width - ( entry . height - lock . height ) ;
lock . y = entry . y + entry . height / 2 - lock . height / 2 ;
2023-05-08 17:37:11 +05:00
lock . z = box _form . z + 2 ;
2023-05-06 21:33:20 +05:00
lock . sprite = Sprite ( lock . image ) ;
lock . sprite . SetPosition ( lock . x , lock . y , lock . z ) ;
2023-05-16 18:47:54 +05:00
hint . sprite = SpriteNew ( ) ;
2023-06-19 21:52:52 +05:00
hint . sprite . SetPosition ( entry . x , box _form . y + Percent ( 5 , box _form . height ) , box _form . z + 1 ) ;
2023-05-16 18:47:54 +05:00
bullet _i . image = Image ( "BULLET.png" ) ;
bullet _i . image = bullet _i . image . Scale ( Percent ( 50 , entry . height ) , Percent ( 50 , entry . height ) ) ;
bullet _i . width = bullet _i . image . GetWidth ( ) ;
bullet _i . height = bullet _i . image . GetHeight ( ) ;
2023-05-06 21:33:20 +05:00
2023-05-08 17:37:11 +05:00
global . dialog . box _form = box _form ;
2023-05-06 21:33:20 +05:00
global . dialog . lock = lock ;
global . dialog . entry = entry ;
2023-05-16 18:47:54 +05:00
global . dialog . hint = hint ;
global . dialog . bullet _i = bullet _i ;
2023-05-06 21:33:20 +05:00
dialog _opacity ( 1 ) ;
}
function dialog _opacity ( opacity ) {
if ( opacity == 0 ) {
2023-05-08 17:37:11 +05:00
dialog . box _form . sprite . SetOpacity ( opacity ) ;
2023-05-06 21:33:20 +05:00
dialog . lock . sprite . SetOpacity ( opacity ) ;
dialog . entry . sprite . SetOpacity ( opacity ) ;
}
else {
dialog . lock . sprite . SetOpacity ( opacity ) ;
dialog . entry . sprite . SetOpacity ( opacity ) ;
}
2023-05-16 18:47:54 +05:00
dialog . hint . sprite . SetOpacity ( opacity ) ;
2023-05-06 21:33:20 +05:00
2023-10-14 23:37:24 +05:00
for ( index = 0 ; dialog . bullet [ index ] ; index ++ ) {
2023-05-06 21:33:20 +05:00
dialog . bullet [ index ] . sprite . SetOpacity ( opacity ) ;
}
}
2023-05-16 18:47:54 +05:00
2023-05-06 21:33:20 +05:00
function display _normal _callback ( ) {
global . status = "normal" ;
if ( global . dialog )
dialog _opacity ( 0 ) ;
}
2023-05-16 18:47:54 +05:00
Plymouth . SetDisplayNormalFunction ( display _normal _callback ) ;
2023-07-01 14:28:22 +05:00
2023-05-16 18:47:54 +05:00
function display _password _callback ( prompt _text , bullets ) {
2023-05-06 21:33:20 +05:00
global . status = "password" ;
if ( ! global . dialog )
dialog _setup ( ) ;
else
dialog _opacity ( 1 ) ;
2023-07-01 14:28:22 +05:00
dialog . hint . image = Image . Text ( prompt _text , 0.5 , 0.5 , 0.5 , 1 , common _font ) ;
2023-05-16 18:47:54 +05:00
dialog . hint . sprite . SetImage ( dialog . hint . image ) ;
2023-05-06 21:33:20 +05:00
2023-10-14 23:37:24 +05:00
for ( index = 0 ; dialog . bullet [ index ] || index < bullets ; index ++ ) {
2023-05-06 21:33:20 +05:00
if ( ! dialog . bullet [ index ] ) {
2023-05-16 18:47:54 +05:00
dialog . bullet [ index ] . sprite = Sprite ( dialog . bullet _i . image ) ;
dialog . bullet [ index ] . x = dialog . entry . x + index * dialog . bullet _i . width / 0.9 - dialog . entry . height * - 0.2 ; // отступ точки от точки и от поля(modified)
dialog . bullet [ index ] . y = dialog . entry . y + ( dialog . entry . height - dialog . bullet _i . height ) / 2 ;
2023-05-06 21:33:20 +05:00
dialog . bullet [ index ] . z = dialog . entry . z + 1 ;
dialog . bullet [ index ] . sprite . SetPosition ( dialog . bullet [ index ] . x , dialog . bullet [ index ] . y , dialog . bullet [ index ] . z ) ;
}
if ( index < bullets )
dialog . bullet [ index ] . sprite . SetOpacity ( 1 ) ;
else
dialog . bullet [ index ] . sprite . SetOpacity ( 0 ) ;
}
}
Plymouth . SetDisplayPasswordFunction ( display _password _callback ) ;
2023-05-16 18:47:54 +05:00
2023-05-06 21:33:20 +05:00
time = 1 ;
function refreshHandler ( ) {
if ( global . status == "normal" && Plymouth . GetMode ( ) == "boot" ) {
progress _fade . sprite . SetOpacity ( 0 ) ; // полностью прозрачный
progress _bar . sprite . SetOpacity ( 1 ) ;
2023-05-16 18:47:54 +05:00
text . image = Image . Text ( starting _text , 0.5 , 0.5 , 0.5 , 1 , common _font ) ;
2023-05-06 21:33:20 +05:00
text . sprite = Sprite ( text . image ) ;
text . x = progress _box . x ;
text . y = progress _box . y - progress _text . image . GetHeight ( ) * 2 ;
2023-07-01 14:28:22 +05:00
text . sprite . SetPosition ( text . x , text . y , 3 ) ;
2023-05-06 21:33:20 +05:00
}
else {
progress _fade . sprite . SetOpacity ( 1 ) ;
progress _bar . sprite . SetOpacity ( 0 ) ;
2023-05-16 18:47:54 +05:00
text _end . image = Image . Text ( bye _text , 0.5 , 0.5 , 0.5 , 1 , common _font ) ;
2023-05-06 21:33:20 +05:00
text _end . sprite = Sprite ( text _end . image ) ;
text _end . x = progress _box . x ;
text _end . y = progress _box . y - progress _text . image . GetHeight ( ) * 2 ;
2023-07-01 14:28:22 +05:00
text _end . sprite . SetPosition ( text _end . x , text _end . y , 3 ) ;
2023-05-06 21:33:20 +05:00
}
progress _fade . x = progress _bar . x ;
progress _fade . y = progress _bar . y ;
2023-05-08 17:37:11 +05:00
progress _fade . sprite . SetPosition ( counter + progress _fade . x , progress _fade . y , 4 ) ;
2023-05-06 21:33:20 +05:00
if ( fade _dir == 0 ) {
counter ++ ;
if ( counter >= max _counter ) {
fade _dir = 1 ;
}
}
else {
counter -- ;
if ( counter <= 0 ) {
fade _dir = 0 ;
}
}
/* if fsck is running or the password is prompted, hide the spinner */
if ( fsck _running == 1 || passw _dialog _input _sprite . GetOpacity ( ) == 1 ) {
spinner . sprite . SetOpacity ( 0 ) ;
}
else {
spinner . sprite . SetOpacity ( 1 ) ;
time ++ ;
theta = time / ( Math . Pi * 2 ) ;
spinner . sprite . SetImage ( spinner . image . Rotate ( theta ) ) ;
}
if ( ( fsck _running == 1 ) && ( fsck _done _fading == 0 ) ) {
fsck _progress _meter _sprite . SetOpacity ( fsck _fade _in _counter ) ;
fsck _progress _fade _sprite . SetOpacity ( fsck _fade _in _counter ) ;
if ( fsck _fade _in _counter < 1 ) {
fsck _fade _in _counter += 0.025 ;
}
else {
fsck _done _fading = 1 ;
}
}
}
Plymouth . SetRefreshFunction ( refreshHandler ) ;
2023-05-16 18:47:54 +05:00
2023-07-01 14:28:22 +05:00
message _status . sprite = SpriteNew ( ) ;
2023-05-06 21:33:20 +05:00
2023-05-16 18:47:54 +05:00
function message _callback ( prompt _text ) {
2023-07-01 14:28:22 +05:00
message _status . image = Image . Text ( prompt _text , 0.5 , 0.5 , 0.5 , 1 , common _font ) ;
message _status . sprite . SetImage ( message _status . image ) ;
message _status . height = message _status . image . GetHeight ( ) ;
message _status . x = messages _box . x + Percent ( 5 , messages _box . width ) ;
message _status . y = messages _box . y + messages _box . height - Percent ( 7 , messages _box . height ) ;
message _status . sprite . SetPosition ( message _status . x , message _status . y , 3 ) ;
message _status . sprite . SetOpacity ( 1 ) ;
2023-05-06 21:33:20 +05:00
}
Plymouth . SetMessageFunction ( message _callback ) ;
2023-10-14 23:37:24 +05:00
// высота messages_box = screen.height - 40% (1080 * 0,4 = 432)
// высота всех сообщений = NUM_SCROLL_LINES (20) * (LINE_HEIGHT) 17 = 340
// 10 процентов сверху от начала messages_box.x = 432 - 10% (432 * 0,1) = 432 - 43 = 389
// конечная точка, где допустимо показывать сообщения = 389 - 43 (10% от высоты messages_box.x) = 346
// если высота всех сообщений выше, чем высота (messages_box.height - 20%), то уменьшать количество строк, пока высота всех сообщений не быдет меньше (messages_box.height - 20%)
2023-07-01 14:28:22 +05:00
2023-10-15 02:29:52 +05:00
padding _top _bottom = Percent ( 10 , messages _box . height ) ;
padding _left _right = Percent ( 5 , messages _box . width ) ;
message _sprite _ . x = messages _box . x + padding _top _bottom ; // позиция % по X
message _sprite _ . y = messages _box . y + ; // позиция % по Y
2023-07-01 14:28:22 +05:00
// LOG //
NUM _SCROLL _LINES = 20 ; //количество строк лога
LINE _WIDTH = 40 ; //ширина строк лога
2023-10-14 23:37:24 +05:00
LINE _HEIGHT = 17 ;
for ( index = NUM _SCROLL _LINES ; index > 0 ; index -- ) {
2023-10-15 02:29:52 +05:00
if ( ( NUM _SCROLL _LINES * LINE _HEIGHT ) > ( messages _box . height - ( padding _top _bottom * 2 ) ) ) {
2023-10-14 23:37:24 +05:00
NUM _SCROLL _LINES = NUM _SCROLL _LINES - 1 ;
}
else {
break ;
}
}
2023-07-01 14:28:22 +05:00
2023-05-06 21:33:20 +05:00
// Initialising text images and their positions
// 20 is the height(including line spacing) of each line
2023-10-14 23:37:24 +05:00
for ( i = 0 ; i < NUM _SCROLL _LINES ; i ++ ) {
2023-05-16 18:47:54 +05:00
lines [ i ] = Image . Text ( "" , 0.5 , 0.5 , 0.5 , 1 , common _font ) ; //цвет строк
2023-05-06 21:33:20 +05:00
message _sprite [ i ] = SpriteNew ( ) ;
2023-10-14 23:37:24 +05:00
message _sprite [ i ] . SetPosition ( message _sprite _ . x , message _sprite _ . y + ( i * LINE _HEIGHT ) , 3 ) ;
2023-05-06 21:33:20 +05:00
} //высота строк //отступ строк
function StringLength ( string ) {
index = 0 ;
str = String ( string ) ;
while ( str . CharAt ( index ) ) index ++ ;
return index ;
}
function scroll _message _callback ( text ) {
// Truncate the message if too long
if ( StringLength ( text ) > LINE _WIDTH ) {
text = text . SubString ( 0 , LINE _WIDTH - 3 ) ;
text += "..." ;
}
// Shift message one up
2023-10-14 23:37:24 +05:00
for ( i = 0 ; i < NUM _SCROLL _LINES - 1 ; i ++ ) {
2023-05-06 21:33:20 +05:00
lines [ i ] = lines [ i + 1 ] ;
}
// Create the image for the latest message
2023-05-16 18:47:54 +05:00
lines [ i ] = Image . Text ( text , 0.5 , 0.5 , 0.5 , 1 , common _font ) ;
2023-05-06 21:33:20 +05:00
// Re-positioning the text images
2023-10-14 23:37:24 +05:00
for ( i = 0 ; i < NUM _SCROLL _LINES ; i ++ ) {
2023-05-06 21:33:20 +05:00
message _sprite [ i ] . SetImage ( lines [ i ] ) ;
}
}
Plymouth . SetUpdateStatusFunction ( scroll _message _callback ) ;
2023-07-01 14:28:22 +05:00
2023-05-06 21:33:20 +05:00
// QUIT
function quit _callback ( ) {
progress _fade . sprite . SetOpacity ( 1 ) ;
progress _bar . sprite . SetOpacity ( 0 ) ;
if ( Plymouth . GetMode ( ) == "shutdown" ) {
logo . sprite . SetOpacity ( 0 ) ;
}
}
Plymouth . SetQuitFunction ( quit _callback ) ;