v2.5.0: message windows can now dynamically scale their width

This commit is contained in:
Evan Debenham
2024-09-01 17:01:25 -04:00
parent 85dcf0fcf9
commit 34028a2d74

View File

@@ -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 );