v0.3.3: adjusted wndOptions to be wider in landscape

This commit is contained in:
Evan Debenham 2015-12-17 00:58:16 -05:00
parent 66ee082503
commit a6db02535f

View File

@ -20,6 +20,7 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
@ -27,22 +28,26 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
public class WndOptions extends Window { public class WndOptions extends Window {
private static final int WIDTH = 120; private static final int WIDTH_P = 120;
private static final int WIDTH_L = 144;
private static final int MARGIN = 2; private static final int MARGIN = 2;
private static final int BUTTON_HEIGHT = 20; private static final int BUTTON_HEIGHT = 20;
public WndOptions( String title, String message, String... options ) { public WndOptions( String title, String message, String... options ) {
super(); super();
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 ); BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 );
tfTitle.hardlight( TITLE_COLOR ); tfTitle.hardlight( TITLE_COLOR );
tfTitle.x = tfTitle.y = MARGIN; tfTitle.x = tfTitle.y = MARGIN;
tfTitle.maxWidth = WIDTH - MARGIN * 2; tfTitle.maxWidth = width - MARGIN * 2;
tfTitle.measure(); tfTitle.measure();
add( tfTitle ); add( tfTitle );
BitmapTextMultiline tfMesage = PixelScene.createMultiline( message, 6 ); BitmapTextMultiline tfMesage = PixelScene.createMultiline( message, 6 );
tfMesage.maxWidth = WIDTH - MARGIN * 2; tfMesage.maxWidth = width - MARGIN * 2;
tfMesage.measure(); tfMesage.measure();
tfMesage.x = MARGIN; tfMesage.x = MARGIN;
tfMesage.y = tfTitle.y + tfTitle.height() + MARGIN; tfMesage.y = tfTitle.y + tfTitle.height() + MARGIN;
@ -59,13 +64,13 @@ public class WndOptions extends Window {
onSelect( index ); onSelect( index );
} }
}; };
btn.setRect( MARGIN, pos, WIDTH - MARGIN * 2, BUTTON_HEIGHT ); btn.setRect( MARGIN, pos, width - MARGIN * 2, BUTTON_HEIGHT );
add( btn ); add( btn );
pos += BUTTON_HEIGHT + MARGIN; pos += BUTTON_HEIGHT + MARGIN;
} }
resize( WIDTH, (int)pos ); resize( width, (int)pos );
} }
protected void onSelect( int index ) {}; protected void onSelect( int index ) {};