v0.3.3: fixed item windows going offscreen in landscape
This commit is contained in:
@@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.ShadowBox;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
import com.watabou.utils.Signal;
|
import com.watabou.utils.Signal;
|
||||||
|
|
||||||
|
//TODO: need to do a big consistency pass on windows now that text size is consistent (larger in many cases)
|
||||||
public class Window extends Group implements Signal.Listener<Key> {
|
public class Window extends Group implements Signal.Listener<Key> {
|
||||||
|
|
||||||
protected int width;
|
protected int width;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
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 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 ) {
|
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 ) {
|
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();
|
IconTitle titlebar = new IconTitle();
|
||||||
titlebar.icon( new ItemSprite( image, glowing ) );
|
titlebar.icon( new ItemSprite( image, glowing ) );
|
||||||
titlebar.label( Utils.capitalize( title ), titleColor );
|
titlebar.label( Utils.capitalize( title ), titleColor );
|
||||||
titlebar.setRect( 0, 0, WIDTH, 0 );
|
titlebar.setRect( 0, 0, width, 0 );
|
||||||
add( titlebar );
|
add( titlebar );
|
||||||
|
|
||||||
BitmapTextMultiline txtInfo = PixelScene.createMultiline( info, 6 );
|
BitmapTextMultiline txtInfo = PixelScene.createMultiline( info, 6 );
|
||||||
txtInfo.maxWidth = WIDTH;
|
txtInfo.maxWidth = width;
|
||||||
txtInfo.measure();
|
txtInfo.measure();
|
||||||
txtInfo.x = titlebar.left();
|
txtInfo.x = titlebar.left();
|
||||||
txtInfo.y = titlebar.bottom() + GAP;
|
txtInfo.y = titlebar.bottom() + GAP;
|
||||||
add( txtInfo );
|
add( txtInfo );
|
||||||
|
|
||||||
resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) );
|
resize( width, (int)(txtInfo.y + txtInfo.height()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
@@ -37,14 +38,17 @@ public class WndItem extends Window {
|
|||||||
|
|
||||||
private static final float GAP = 2;
|
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 WndItem( final WndBag owner, final Item item ) {
|
public WndItem( final WndBag owner, final Item item ) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
|
||||||
|
|
||||||
IconTitle titlebar = new IconTitle( item );
|
IconTitle titlebar = new IconTitle( item );
|
||||||
titlebar.setRect( 0, 0, WIDTH, 0 );
|
titlebar.setRect( 0, 0, width, 0 );
|
||||||
add( titlebar );
|
add( titlebar );
|
||||||
|
|
||||||
if (item.levelKnown && item.level() > 0) {
|
if (item.levelKnown && item.level() > 0) {
|
||||||
@@ -54,7 +58,7 @@ public class WndItem extends Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitmapTextMultiline info = PixelScene.createMultiline( item.info(), 6 );
|
BitmapTextMultiline info = PixelScene.createMultiline( item.info(), 6 );
|
||||||
info.maxWidth = WIDTH;
|
info.maxWidth = width;
|
||||||
info.measure();
|
info.measure();
|
||||||
info.x = titlebar.left();
|
info.x = titlebar.left();
|
||||||
info.y = titlebar.bottom() + GAP;
|
info.y = titlebar.bottom() + GAP;
|
||||||
@@ -75,14 +79,14 @@ public class WndItem extends Window {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
btn.setSize( Math.max( BUTTON_WIDTH, btn.reqWidth() ), BUTTON_HEIGHT );
|
btn.setSize( Math.max( BUTTON_WIDTH, btn.reqWidth() ), BUTTON_HEIGHT );
|
||||||
if (x + btn.width() > WIDTH) {
|
if (x + btn.width() > width) {
|
||||||
x = 0;
|
x = 0;
|
||||||
y += BUTTON_HEIGHT + GAP;
|
y += BUTTON_HEIGHT + GAP;
|
||||||
}
|
}
|
||||||
btn.setPos( x, y );
|
btn.setPos( x, y );
|
||||||
add( btn );
|
add( btn );
|
||||||
|
|
||||||
if (action == item.defaultAction) {
|
if (action.equals(item.defaultAction)) {
|
||||||
btn.textColor( TITLE_COLOR );
|
btn.textColor( TITLE_COLOR );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +94,6 @@ public class WndItem extends Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resize( WIDTH, (int)(y + (x > 0 ? BUTTON_HEIGHT : 0)) );
|
resize( width, (int)(y + (x > 0 ? BUTTON_HEIGHT : 0)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user