plymouth: display password prompt text

This commit is contained in:
Marek Marczykowski-Górecki 2014-03-12 04:38:33 +01:00
parent fc4e6b3583
commit 74a74928bd

View File

@ -34,13 +34,16 @@ Plymouth.SetRefreshFunction (refresh_callback);
status = "normal";
fun dialog_setup()
fun dialog_setup(text)
{
local.box;
local.prompt;
local.lock;
local.entry;
box.image = Image("box.png");
prompt.text = text;
prompt.image = Image.Text(text, 1, 1, 1);
lock.image = Image("lock.png");
entry.image = Image("entry.png");
@ -50,19 +53,27 @@ fun dialog_setup()
box.z = 10000;
box.sprite.SetPosition(box.x, box.y, box.z);
prompt.sprite = Sprite(prompt.image);
prompt.x = box.x + box.image.GetWidth()/2 - prompt.image.GetWidth() / 2;
prompt.y = box.y + box.image.GetHeight()/2 - (prompt.image.GetHeight() + entry.image.GetHeight())/2;
prompt.z = box.z + 1;
prompt.sprite.SetPosition(prompt.x, prompt.y, prompt.z);
prompt.sprite.text = text;
lock.sprite = Sprite(lock.image);
lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2;
lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2;
lock.y = prompt.y + prompt.image.GetHeight() + (entry.image.GetHeight() - lock.image.GetHeight())/2;
lock.z = box.z + 1;
lock.sprite.SetPosition(lock.x, lock.y, lock.z);
entry.sprite = Sprite(entry.image);
entry.x = lock.x + lock.image.GetWidth();
entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2;
entry.y = prompt.y + prompt.image.GetHeight();
entry.z = box.z + 1;
entry.sprite.SetPosition(entry.x, entry.y, entry.z);
global.dialog.box = box;
global.dialog.prompt = prompt;
global.dialog.lock = lock;
global.dialog.entry = entry;
global.dialog.bullet_image = Image("bullet.png");
@ -72,6 +83,7 @@ fun dialog_setup()
fun dialog_opacity(opacity)
{
dialog.box.sprite.SetOpacity (opacity);
dialog.prompt.sprite.SetOpacity (opacity);
dialog.lock.sprite.SetOpacity (opacity);
dialog.entry.sprite.SetOpacity (opacity);
for (index = 0; dialog.bullet[index]; index++)
@ -91,9 +103,15 @@ fun display_password_callback (prompt, bullets)
{
global.status = "password";
if (!global.dialog)
dialog_setup();
else
dialog_opacity(1);
dialog_setup(prompt);
else {
if (global.dialog.prompt.text != prompt) {
dialog_opacity(0);
global.dialog = NULL;
dialog_setup(prompt);
} else
dialog_opacity(1);
}
for (index = 0; dialog.bullet[index] || index < bullets; index++)
{
if (!dialog.bullet[index])