From cb6010f35c888e5767c5c4dadf05c16d56928d6c Mon Sep 17 00:00:00 2001 From: Valeria Fadeeva Date: Sat, 14 Oct 2023 23:34:41 +0500 Subject: [PATCH] Update --- dev/script.js | 28 +++++++++++++++++++++------- melawy-nier-a2/script.script | 28 +++++++++++++++++++++------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/dev/script.js b/dev/script.js index 8f224f4..17dc52a 100755 --- a/dev/script.js +++ b/dev/script.js @@ -390,7 +390,7 @@ function dialog_opacity(opacity) { dialog.hint.sprite.SetOpacity(opacity); - for(index = 0; dialog.bullet[index]; index++) { + for (index = 0; dialog.bullet[index]; index++) { dialog.bullet[index].sprite.SetOpacity(opacity); } } @@ -418,7 +418,7 @@ function display_password_callback(prompt_text, bullets) { dialog.hint.image = Image.Text(prompt_text, 0.5, 0.5, 0.5, 1, common_font); dialog.hint.sprite.SetImage(dialog.hint.image); - for(index = 0; dialog.bullet[index] || index < bullets; index++) { + for (index = 0; dialog.bullet[index] || index < bullets; index++) { if (!dialog.bullet[index]) { 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) @@ -518,7 +518,11 @@ function message_callback(prompt_text) { Plymouth.SetMessageFunction(message_callback); - +// высота 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%) message_sprite_.x = messages_box.x + Percent(5, messages_box.width); // позиция % по X message_sprite_.y = messages_box.y + Percent(10, messages_box.height); // позиция % по Y @@ -526,13 +530,23 @@ message_sprite_.y = messages_box.y + Percent(10, messages_box.height); // поз // LOG // NUM_SCROLL_LINES=20; //количество строк лога LINE_WIDTH=40; //ширина строк лога +LINE_HEIGHT=17; + +for (index = NUM_SCROLL_LINES; index > 0; index--) { + if ((NUM_SCROLL_LINES * LINE_HEIGHT) > messages_box.height) { + NUM_SCROLL_LINES=NUM_SCROLL_LINES-1; + } + else { + break; + } +} // Initialising text images and their positions // 20 is the height(including line spacing) of each line -for(i=0; i < NUM_SCROLL_LINES; i++) { +for (i=0; i < NUM_SCROLL_LINES; i++) { lines[i]= Image.Text("", 0.5, 0.5, 0.5, 1, common_font); //цвет строк message_sprite[i] = SpriteNew(); - message_sprite[i].SetPosition(message_sprite_.x, message_sprite_.y + (i * 17), 3); + message_sprite[i].SetPosition(message_sprite_.x, message_sprite_.y + (i * LINE_HEIGHT), 3); } //высота строк //отступ строк function StringLength(string) { @@ -550,7 +564,7 @@ function scroll_message_callback(text) { } // Shift message one up - for(i = 0; i < NUM_SCROLL_LINES - 1; i++) { + for (i = 0; i < NUM_SCROLL_LINES - 1; i++) { lines[i] = lines[i+1]; } @@ -558,7 +572,7 @@ function scroll_message_callback(text) { lines[i] = Image.Text(text, 0.5, 0.5, 0.5, 1, common_font); // Re-positioning the text images - for(i = 0; i < NUM_SCROLL_LINES; i++) { + for (i = 0; i < NUM_SCROLL_LINES; i++) { message_sprite[i].SetImage(lines[i]); } } diff --git a/melawy-nier-a2/script.script b/melawy-nier-a2/script.script index 2af27f1..1f61a19 100755 --- a/melawy-nier-a2/script.script +++ b/melawy-nier-a2/script.script @@ -390,7 +390,7 @@ fun dialog_opacity(opacity) { dialog.hint.sprite.SetOpacity(opacity); - for(index = 0; dialog.bullet[index]; index++) { + for (index = 0; dialog.bullet[index]; index++) { dialog.bullet[index].sprite.SetOpacity(opacity); } } @@ -418,7 +418,7 @@ fun display_password_callback(prompt_text, bullets) { dialog.hint.image = Image.Text(prompt_text, 0.5, 0.5, 0.5, 1, common_font); dialog.hint.sprite.SetImage(dialog.hint.image); - for(index = 0; dialog.bullet[index] || index < bullets; index++) { + for (index = 0; dialog.bullet[index] || index < bullets; index++) { if (!dialog.bullet[index]) { 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) @@ -518,7 +518,11 @@ fun message_callback(prompt_text) { Plymouth.SetMessageFunction(message_callback); - +// высота messages_box = 1080 - 40% (1080 * 0,4 = 432) +// высота всех сообщений = NUM_SCROLL_LINES (20) * (LINE_HEIGHT) 17 = 340 +// 10 процентов сверху от начала messages_box = 432 - 10% (432 * 0,1) = 432 - 43 = 389 +// конечная точка, где допустимо показывать сообщения = 389 - 43 (10% от высоты messages_box) = 346 +// если высота всех сообщений выше, чем высота (messages_box - 20%), то уменьшать количество строк, пока высота всех сообщений не быдет меньше messages_box message_sprite_.x = messages_box.x + Percent(5, messages_box.width); // позиция % по X message_sprite_.y = messages_box.y + Percent(10, messages_box.height); // позиция % по Y @@ -526,13 +530,23 @@ message_sprite_.y = messages_box.y + Percent(10, messages_box.height); // поз // LOG // NUM_SCROLL_LINES=20; //количество строк лога LINE_WIDTH=40; //ширина строк лога +LINE_HEIGHT=17; + +for (index = NUM_SCROLL_LINES; index > 0; index--) { + if ((NUM_SCROLL_LINES * LINE_HEIGHT) > messages_box.height) { + NUM_SCROLL_LINES=NUM_SCROLL_LINES-1; + } + else { + break; + } +} // Initialising text images and their positions // 20 is the height(including line spacing) of each line -for(i=0; i < NUM_SCROLL_LINES; i++) { +for (i=0; i < NUM_SCROLL_LINES; i++) { lines[i]= Image.Text("", 0.5, 0.5, 0.5, 1, common_font); //цвет строк message_sprite[i] = SpriteNew(); - message_sprite[i].SetPosition(message_sprite_.x, message_sprite_.y + (i * 17), 3); + message_sprite[i].SetPosition(message_sprite_.x, message_sprite_.y + (i * LINE_HEIGHT), 3); } //высота строк //отступ строк fun StringLength(string) { @@ -550,7 +564,7 @@ fun scroll_message_callback(text) { } // Shift message one up - for(i = 0; i < NUM_SCROLL_LINES - 1; i++) { + for (i = 0; i < NUM_SCROLL_LINES - 1; i++) { lines[i] = lines[i+1]; } @@ -558,7 +572,7 @@ fun scroll_message_callback(text) { lines[i] = Image.Text(text, 0.5, 0.5, 0.5, 1, common_font); // Re-positioning the text images - for(i = 0; i < NUM_SCROLL_LINES; i++) { + for (i = 0; i < NUM_SCROLL_LINES; i++) { message_sprite[i].SetImage(lines[i]); } }