v2.5.0: message windows can now dynamically scale their width
This commit is contained in:
+12
-3
@@ -27,19 +27,28 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
|||||||
|
|
||||||
public class WndMessage extends Window {
|
public class WndMessage extends Window {
|
||||||
|
|
||||||
private static final int WIDTH_P = 120;
|
private static final int WIDTH_MIN = 120;
|
||||||
private static final int WIDTH_L = 144;
|
private static final int WIDTH_MAX = 220;
|
||||||
private static final int MARGIN = 4;
|
private static final int MARGIN = 4;
|
||||||
|
|
||||||
public WndMessage( String text ) {
|
public WndMessage( String text ) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
int width = WIDTH_MIN;
|
||||||
|
|
||||||
RenderedTextBlock info = PixelScene.renderTextBlock( text, 6 );
|
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);
|
info.setPos(MARGIN, MARGIN);
|
||||||
add( info );
|
add( info );
|
||||||
|
|
||||||
|
while (PixelScene.landscape()
|
||||||
|
&& info.height() > 120
|
||||||
|
&& width < WIDTH_MAX){
|
||||||
|
width += 20;
|
||||||
|
info.maxWidth(width - MARGIN * 2);
|
||||||
|
}
|
||||||
|
|
||||||
resize(
|
resize(
|
||||||
(int)info.width() + MARGIN * 2,
|
(int)info.width() + MARGIN * 2,
|
||||||
(int)info.height() + MARGIN * 2 );
|
(int)info.height() + MARGIN * 2 );
|
||||||
|
|||||||
Reference in New Issue
Block a user