v0.3.3: fixed item windows going offscreen in landscape

This commit is contained in:
Evan Debenham
2015-11-27 22:37:44 -05:00
parent dd3f866205
commit c03cd90b79
3 changed files with 21 additions and 12 deletions
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
@@ -56,7 +57,8 @@ public class WndInfoItem extends Window {
private static final float GAP = 2;
private static final int WIDTH = 120;
private static final int WIDTH_P = 120;
private static final int WIDTH_L = 144;
public WndInfoItem( Heap heap ) {
@@ -126,20 +128,22 @@ public class WndInfoItem extends Window {
}
private void fillFields( int image, ItemSprite.Glowing glowing, int titleColor, String title, String info ) {
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( image, glowing ) );
titlebar.label( Utils.capitalize( title ), titleColor );
titlebar.setRect( 0, 0, WIDTH, 0 );
titlebar.setRect( 0, 0, width, 0 );
add( titlebar );
BitmapTextMultiline txtInfo = PixelScene.createMultiline( info, 6 );
txtInfo.maxWidth = WIDTH;
txtInfo.maxWidth = width;
txtInfo.measure();
txtInfo.x = titlebar.left();
txtInfo.y = titlebar.bottom() + GAP;
add( txtInfo );
resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) );
resize( width, (int)(txtInfo.y + txtInfo.height()) );
}
}