diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index 51cc4888e..763ea1183 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -183,13 +183,11 @@ windows.wndstory.caves=These sparsely populated caves stretch down under the aba windows.wndstory.city=The Dwarven Metropolis was once the greatest of all dwarven city-states. In its heyday the dwarves built wondrous machines of metal and magic that allowed their city to expand rapidly.\n\nThen, one day, the city gates were barred and nobody heard from the dwarves again. The few who escaped the city as it closed told stories of a mad warlock who stole the throne, and the terrible magic he had learned to harness. windows.wndstory.halls=These deep halls of the Dwarven Metropolis have been twisted by dark magic. In the past these regions played host to the Dwarf King's court of elite warlocks, but now they seem to have been taken over by something even more sinister...\n\nAll sorts of horrific demonic creatures inhabit these halls, being lead by some terrible dark power. If the King of Dwarves wasn't the source of the spreading corruption, whatever is down here must be.\n\nTread carefully, very few adventurers have ever descended this far... -windows.wndtradeitem.sale=FOR SALE: %1$s - %2$dg windows.wndtradeitem.buy=Buy for %dg windows.wndtradeitem.steal=Steal with %d%% chance windows.wndtradeitem.sell=Sell for %dg windows.wndtradeitem.sell_1=Sell 1 for %dg windows.wndtradeitem.sell_all=Sell all for %dg -windows.wndtradeitem.cancel=Never mind windows.wndwandmaker.dust=Oh, I see you have the dust! Don't worry about the wraiths, I can deal with them. As I promised, you can choose one of my high quality wands. windows.wndwandmaker.ember=Oh, I see you have the embers! I do hope the fire elemental wasn't too much trouble. As I promised, you can choose one of my high quality wands. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 95f595eb2..4f17112de 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -680,7 +680,7 @@ public class Hero extends Char { Game.runOnRenderThread(new Callback() { @Override public void call() { - GameScene.show( new WndTradeItem( heap, true ) ); + GameScene.show( new WndTradeItem( heap ) ); } }); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java index eb1e4c392..9ce6d0d6b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java @@ -31,7 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndItem; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem; import com.watabou.noosa.audio.Sample; import java.util.ArrayList; @@ -69,7 +69,7 @@ public class BrokenSeal extends Item { curItem = this; GameScene.selectItem(armorSelector, WndBag.Mode.ARMOR, Messages.get(this, "prompt")); } else if (action.equals(AC_INFO)) { - GameScene.show(new WndItem(null, this, true)); + GameScene.show(new WndUseItem(null, this)); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 62ce1c816..c901229b4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -61,7 +61,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.IconTitle; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBlacksmith; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndItem; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem; import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest; import com.watabou.noosa.Game; import com.watabou.noosa.audio.Sample; @@ -127,7 +127,7 @@ public class DriedRose extends Artifact { if (action.equals(AC_SUMMON)) { - if (!Ghost.Quest.completed()) GameScene.show(new WndItem(null, this, true)); + if (!Ghost.Quest.completed()) GameScene.show(new WndUseItem(null, this)); else if (ghost != null) GLog.i( Messages.get(this, "spawned") ); else if (!isEquipped( hero )) GLog.i( Messages.get(Artifact.class, "need_to_equip") ); else if (charge != chargeCap) GLog.i( Messages.get(this, "no_charge") ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 28a32875b..6fc043b2f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -67,7 +67,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndItem; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; @@ -246,7 +246,7 @@ public class Potion extends Item { if (action.equals( AC_CHOOSE )){ - GameScene.show(new WndItem(null, this, true) ); + GameScene.show(new WndUseItem(null, this) ); } else if (action.equals( AC_DRINK )) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java index f88f7fe05..2c6303884 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -43,7 +43,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndItem; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.particles.Emitter; @@ -124,7 +124,7 @@ public class MagesStaff extends MeleeWeapon { } else if (action.equals(AC_ZAP)){ if (wand == null) { - GameScene.show(new WndItem(null, this, true)); + GameScene.show(new WndUseItem(null, this)); return; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 698109a5a..239ef5fe1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -1114,12 +1114,7 @@ public class GameScene extends PixelScene { } else if ( o instanceof Mob ){ GameScene.show(new WndInfoMob((Mob) o)); } else if ( o instanceof Heap ){ - Heap heap = (Heap)o; - if (heap.type == Heap.Type.FOR_SALE && heap.size() == 1 && heap.peek().price() > 0) { - GameScene.show(new WndTradeItem(heap, false)); - } else { - GameScene.show(new WndInfoItem(heap)); - } + GameScene.show(new WndInfoItem((Heap)o)); } else if ( o instanceof Plant ){ GameScene.show( new WndInfoPlant((Plant) o) ); } else if ( o instanceof Trap ){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index d86f91227..bd95d547d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -48,7 +48,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; -import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -452,7 +451,7 @@ public class WndBag extends WndTabbed { } else { - Game.scene().addToFront(new WndItem( WndBag.this, item ) ); + Game.scene().addToFront(new WndUseItem( WndBag.this, item ) ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java index 7ca3c8ad0..37a96bf8a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java @@ -31,9 +31,9 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndInfoItem extends Window { private static final float GAP = 2; - - 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; public WndInfoItem( Heap heap ) { @@ -56,19 +56,12 @@ public class WndInfoItem extends Window { private void fillFields( Heap heap ) { - int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P; - IconTitle titlebar = new IconTitle( heap ); titlebar.color( TITLE_COLOR ); - titlebar.setRect( 0, 0, width, 0 ); - add( titlebar ); RenderedTextBlock txtInfo = PixelScene.renderTextBlock( heap.info(), 6 ); - txtInfo.maxWidth(width); - txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP); - add( txtInfo ); - - resize( width, (int)(txtInfo.bottom() + 2) ); + + layoutFields(titlebar, txtInfo); } private void fillFields( Item item ) { @@ -79,19 +72,34 @@ public class WndInfoItem extends Window { } else if (item.levelKnown && item.level() < 0) { color = ItemSlot.DEGRADED; } - - int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P; IconTitle titlebar = new IconTitle( item ); titlebar.color( color ); - titlebar.setRect( 0, 0, width, 0 ); - add( titlebar ); RenderedTextBlock txtInfo = PixelScene.renderTextBlock( item.info(), 6 ); - txtInfo.maxWidth(width); - txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP); - add( txtInfo ); - resize( width, (int)(txtInfo.bottom() + 2) ); + layoutFields(titlebar, txtInfo); + } + + private void layoutFields(IconTitle title, RenderedTextBlock info){ + int width = WIDTH_MIN; + + info.maxWidth(width); + + //window can go out of the screen on landscape, so widen it as appropriate + while (PixelScene.landscape() + && info.height() > 100 + && width < WIDTH_MAX){ + width += 20; + info.maxWidth(width); + } + + title.setRect( 0, 0, width, 0 ); + add( title ); + + info.setPos(title.left(), title.bottom() + GAP); + add( info ); + + resize( width, (int)(info.bottom() + 2) ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java index c0f561c71..a80086f0e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java @@ -359,7 +359,7 @@ public class WndRanking extends WndTabbed { @Override protected void onClick() { - Game.scene().add( new WndItem( null, item ) ); + Game.scene().add( new WndInfoItem( item ) ); } } @@ -403,7 +403,7 @@ public class WndRanking extends WndTabbed { @Override protected void onClick() { - Game.scene().add(new WndItem(null, item)); + Game.scene().add(new WndInfoItem(item)); } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java index e8732b14a..356d419f4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java @@ -35,27 +35,25 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; -import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; -import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -public class WndTradeItem extends Window { - +public class WndTradeItem extends WndInfoItem { + private static final float GAP = 2; - private static final int WIDTH = 120; private static final int BTN_HEIGHT = 16; - + private WndBag owner; - + + //selling public WndTradeItem( final Item item, WndBag owner ) { - - super(); - + + super(item); + this.owner = owner; - - float pos = createDescription( item, false ); - + + float pos = height; + if (item.quantity() == 1) { - + RedButton btnSell = new RedButton( Messages.get(this, "sell", item.price()) ) { @Override protected void onClick() { @@ -63,13 +61,13 @@ public class WndTradeItem extends Window { hide(); } }; - btnSell.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT ); + btnSell.setRect( 0, pos + GAP, width, BTN_HEIGHT ); add( btnSell ); - + pos = btnSell.bottom(); - + } else { - + int priceAll= item.price(); RedButton btnSell1 = new RedButton( Messages.get(this, "sell_1", priceAll / item.quantity()) ) { @Override @@ -78,7 +76,7 @@ public class WndTradeItem extends Window { hide(); } }; - btnSell1.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT ); + btnSell1.setRect( 0, pos + GAP, width, BTN_HEIGHT ); add( btnSell1 ); RedButton btnSellAll = new RedButton( Messages.get(this, "sell_all", priceAll ) ) { @Override @@ -87,97 +85,74 @@ public class WndTradeItem extends Window { hide(); } }; - btnSellAll.setRect( 0, btnSell1.bottom() + GAP, WIDTH, BTN_HEIGHT ); + btnSellAll.setRect( 0, btnSell1.bottom() + 1, width, BTN_HEIGHT ); add( btnSellAll ); - + pos = btnSellAll.bottom(); - + } - - RedButton btnCancel = new RedButton( Messages.get(this, "cancel") ) { + + resize( width, (int)pos ); + } + + //buying + public WndTradeItem( final Heap heap ) { + + super(heap); + + Item item = heap.peek(); + + float pos = height; + + final int price = price( item ); + + RedButton btnBuy = new RedButton( Messages.get(this, "buy", price) ) { @Override protected void onClick() { hide(); + buy( heap ); } }; - btnCancel.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT ); - add( btnCancel ); - - resize( WIDTH, (int)btnCancel.bottom() ); - } - - public WndTradeItem( final Heap heap, boolean canBuy ) { - - super(); - - Item item = heap.peek(); - - float pos = createDescription( item, true ); - - final int price = price( item ); - - if (canBuy) { - - RedButton btnBuy = new RedButton( Messages.get(this, "buy", price) ) { + btnBuy.setRect( 0, pos + GAP, width, BTN_HEIGHT ); + btnBuy.enable( price <= Dungeon.gold ); + add( btnBuy ); + + pos = btnBuy.bottom(); + + final MasterThievesArmband.Thievery thievery = Dungeon.hero.buff(MasterThievesArmband.Thievery.class); + if (thievery != null && !thievery.isCursed()) { + final float chance = thievery.stealChance(price); + RedButton btnSteal = new RedButton(Messages.get(this, "steal", Math.min(100, (int) (chance * 100)))) { @Override protected void onClick() { - hide(); - buy( heap ); - } - }; - btnBuy.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT ); - btnBuy.enable( price <= Dungeon.gold ); - add( btnBuy ); + if (thievery.steal(price)) { + Hero hero = Dungeon.hero; + Item item = heap.pickUp(); + hide(); - RedButton btnCancel = new RedButton( Messages.get(this, "cancel") ) { - @Override - protected void onClick() { - hide(); - } - }; - - final MasterThievesArmband.Thievery thievery = Dungeon.hero.buff(MasterThievesArmband.Thievery.class); - if (thievery != null && !thievery.isCursed()) { - final float chance = thievery.stealChance(price); - RedButton btnSteal = new RedButton( Messages.get(this, "steal", Math.min(100, (int)(chance*100)))) { - @Override - protected void onClick() { - if(thievery.steal(price)){ - Hero hero = Dungeon.hero; - Item item = heap.pickUp(); - hide(); - - if (!item.doPickUp( hero )) { - Dungeon.level.drop( item, heap.pos ).sprite.drop(); - } - } else { - for (Mob mob : Dungeon.level.mobs){ - if (mob instanceof Shopkeeper) { - mob.yell(Messages.get(mob, "thief")); - ((Shopkeeper) mob).flee(); - break; - } - } - hide(); + if (!item.doPickUp(hero)) { + Dungeon.level.drop(item, heap.pos).sprite.drop(); } + } else { + for (Mob mob : Dungeon.level.mobs) { + if (mob instanceof Shopkeeper) { + mob.yell(Messages.get(mob, "thief")); + ((Shopkeeper) mob).flee(); + break; + } + } + hide(); } - }; - btnSteal.setRect(0, btnBuy.bottom() + GAP, WIDTH, BTN_HEIGHT); - add(btnSteal); + } + }; + btnSteal.setRect(0, pos + 1, width, BTN_HEIGHT); + add(btnSteal); - btnCancel.setRect( 0, btnSteal.bottom() + GAP, WIDTH, BTN_HEIGHT ); - } else - btnCancel.setRect( 0, btnBuy.bottom() + GAP, WIDTH, BTN_HEIGHT ); + pos = btnSteal.bottom(); - add( btnCancel ); - - resize( WIDTH, (int)btnCancel.bottom() ); - - } else { - - resize( WIDTH, (int)pos ); - } + + resize(width, (int) pos); } @Override @@ -191,35 +166,6 @@ public class WndTradeItem extends Window { } } - private float createDescription( Item item, boolean forSale ) { - - // Title - IconTitle titlebar = new IconTitle(); - titlebar.icon( new ItemSprite( item ) ); - titlebar.label( forSale ? - Messages.get(this, "sale", item.toString(), price( item ) ) : - Messages.titleCase( item.toString() ) ); - titlebar.setRect( 0, 0, WIDTH, 0 ); - add( titlebar ); - - // Upgraded / degraded - if (item.levelKnown) { - if (item.level() < 0) { - titlebar.color( ItemSlot.DEGRADED ); - } else if (item.level() > 0) { - titlebar.color( ItemSlot.UPGRADED ); - } - } - - // Description - RenderedTextBlock info = PixelScene.renderTextBlock( item.info(), 6 ); - info.maxWidth(WIDTH); - info.setPos(titlebar.left(), titlebar.bottom() + GAP); - add( info ); - - return info.bottom(); - } - private void sell( Item item ) { Hero hero = Dungeon.hero; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndUseItem.java similarity index 71% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndUseItem.java index fd9fc8755..1bd202fef 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndUseItem.java @@ -24,71 +24,33 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; -import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; -import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; -import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; -import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import java.util.ArrayList; -import java.util.Comparator; -public class WndItem extends Window { +public class WndUseItem extends WndInfoItem { - //only one wnditem can appear at a time - private static WndItem INSTANCE; + //only one wnduseitem can appear at a time + private static WndUseItem INSTANCE; private static final float BUTTON_HEIGHT = 16; private static final float GAP = 2; - private static final int WIDTH_MIN = 120; - private static final int WIDTH_MAX = 220; - - public WndItem( final WndBag owner, final Item item ){ - this( owner, item, owner != null ); - } - - public WndItem( final WndBag owner, final Item item , final boolean options ) { + public WndUseItem(final WndBag owner, final Item item ) { - super(); + super(item); if( INSTANCE != null ){ INSTANCE.hide(); } INSTANCE = this; - - int width = WIDTH_MIN; - - RenderedTextBlock info = PixelScene.renderTextBlock( item.info(), 6 ); - info.maxWidth(width); - - //info box can go out of the screen on landscape, so widen it - while (PixelScene.landscape() - && info.height() > 100 - && width < WIDTH_MAX){ - width += 20; - info.maxWidth(width); - } - - IconTitle titlebar = new IconTitle( item ); - titlebar.setRect( 0, 0, width, 0 ); - add( titlebar ); - - if (item.levelKnown && item.level() > 0) { - titlebar.color( ItemSlot.UPGRADED ); - } else if (item.levelKnown && item.level() < 0) { - titlebar.color( ItemSlot.DEGRADED ); - } - - info.setPos(titlebar.left(), titlebar.bottom() + GAP); - add( info ); - float y = info.top() + info.height() + GAP; + float y = height + GAP; - if (Dungeon.hero.isAlive() && options) { + if (Dungeon.hero.isAlive()) { ArrayList buttons = new ArrayList<>(); - for (final String action:item.actions( Dungeon.hero )) { + for (final String action : item.actions( Dungeon.hero )) { RedButton btn = new RedButton( Messages.get(item, "ac_" + action), 8 ) { @Override @@ -209,17 +171,5 @@ public class WndItem extends Window { INSTANCE = null; } } - - private static Comparator widthComparator = new Comparator() { - @Override - public int compare(RedButton lhs, RedButton rhs) { - if (lhs.width() < rhs.width()){ - return -1; - } else if (lhs.width() == rhs.width()){ - return 0; - } else { - return 1; - } - } - }; + }