From 34028a2d74b1928b174902b5f36d3702a5017704 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 1 Sep 2024 17:01:25 -0400 Subject: [PATCH] v2.5.0: message windows can now dynamically scale their width --- .../shatteredpixeldungeon/windows/WndMessage.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java index f7c3656bd..a3819a45e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java @@ -27,19 +27,28 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndMessage extends Window { - private static final int WIDTH_P = 120; - private static final int WIDTH_L = 144; + private static final int WIDTH_MIN = 120; + private static final int WIDTH_MAX = 220; private static final int MARGIN = 4; public WndMessage( String text ) { super(); + + int width = WIDTH_MIN; RenderedTextBlock info = PixelScene.renderTextBlock( text, 6 ); - info.maxWidth((PixelScene.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2); + info.maxWidth(width - MARGIN * 2); info.setPos(MARGIN, MARGIN); add( info ); + while (PixelScene.landscape() + && info.height() > 120 + && width < WIDTH_MAX){ + width += 20; + info.maxWidth(width - MARGIN * 2); + } + resize( (int)info.width() + MARGIN * 2, (int)info.height() + MARGIN * 2 );