diff --git a/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java b/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java index 206f0cabd..b83d60a6b 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java @@ -34,12 +34,14 @@ public class TextureFilm { private int texWidth; private int texHeight; + + private SmartTexture texture; protected HashMap frames = new HashMap(); public TextureFilm( Object tx ) { - SmartTexture texture = TextureCache.get( tx ); + texture = TextureCache.get( tx ); texWidth = texture.width; texHeight = texture.height; @@ -53,7 +55,7 @@ public class TextureFilm { public TextureFilm( Object tx, int width, int height ) { - SmartTexture texture = TextureCache.get( tx ); + texture = TextureCache.get( tx ); texWidth = texture.width; texHeight = texture.height; @@ -72,6 +74,8 @@ public class TextureFilm { } public TextureFilm( TextureFilm atlas, Object key, int width, int height ) { + + texture = atlas.texture; texWidth = atlas.texWidth; texHeight = atlas.texHeight; @@ -95,14 +99,26 @@ public class TextureFilm { public void add( Object id, RectF rect ) { frames.put( id, rect ); } + + public void add( Object id, int left, int top, int right, int bottom){ + frames.put( id, texture.uvRect(left, top, right, bottom)); + } public RectF get( Object id ) { return frames.get( id ); } + + public float width( Object id ){ + return width( get( id ) ); + } public float width( RectF frame ) { return frame.width() * texWidth; } + + public float height( Object id ){ + return height( get( id ) ); + } public float height( RectF frame ) { return frame.height() * texHeight; diff --git a/core/src/main/assets/items.png b/core/src/main/assets/items.png index 477a7a11e..070ed849a 100644 Binary files a/core/src/main/assets/items.png and b/core/src/main/assets/items.png differ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index 9885394ad..81187771d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -53,6 +53,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Viscosity; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.particles.Emitter; import com.watabou.utils.Bundlable; @@ -319,7 +320,7 @@ public class Armor extends EquipableItem { public Emitter emitter() { if (seal == null) return super.emitter(); Emitter emitter = new Emitter(); - emitter.pos(10f, 6f); + emitter.pos(ItemSpriteSheet.film.width(image)/2f + 2f, ItemSpriteSheet.film.height(image)/3f); emitter.fillTarget = false; emitter.pour(Speck.factory( Speck.RED_LIGHT ), 0.6f); return emitter; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java index 8e27b63fe..862695332 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java @@ -47,8 +47,6 @@ public class ItemSprite extends MovieClip { private static final float DROP_INTERVAL = 0.4f; - protected static TextureFilm film; - public Heap heap; private Glowing glowing; @@ -67,25 +65,17 @@ public class ItemSprite extends MovieClip { public ItemSprite( Item item ) { super(Assets.ITEMS); - if (film == null) { - film = new TextureFilm( texture, SIZE, SIZE ); - } - view (item); } public ItemSprite( int image, Glowing glowing ) { super( Assets.ITEMS ); - if (film == null) { - film = new TextureFilm( texture, SIZE, SIZE ); - } - view(image, glowing); } public void originToCenter() { - origin.set(SIZE / 2); + origin.set(width / 2, height / 2); } public void link() { @@ -125,8 +115,8 @@ public class ItemSprite extends MovieClip { final int csize = DungeonTilemap.SIZE; return new PointF( - cell % Dungeon.level.width() * csize + (csize - SIZE) * 0.5f, - cell / Dungeon.level.width() * csize + (csize - SIZE) * 0.5f + cell % Dungeon.level.width() * csize + (csize - width()) * 0.5f, + cell / Dungeon.level.width() * csize + (csize - height()) - csize * 0.333f ); } @@ -187,7 +177,7 @@ public class ItemSprite extends MovieClip { public ItemSprite view( int image, Glowing glowing ) { if (this.emitter != null) this.emitter.killAndErase(); emitter = null; - frame( film.get( image ) ); + frame( ItemSpriteSheet.film.get( image ) ); if ((this.glowing = glowing) == null) { resetColor(); } @@ -195,7 +185,7 @@ public class ItemSprite extends MovieClip { } public void frame( int image ){ - frame( film.get( image )); + frame( ItemSpriteSheet.film.get( image )); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java index 651d8805f..4c9ed522c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java @@ -20,10 +20,15 @@ */ package com.shatteredpixel.shatteredpixeldungeon.sprites; +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.watabou.noosa.TextureFilm; + public class ItemSpriteSheet { private static final int WIDTH = 16; + public static TextureFilm film = new TextureFilm( Assets.ITEMS, 16, 16 ); + private static int xy(int x, int y){ x -= 1; y -= 1; return x + WIDTH*y; @@ -36,6 +41,10 @@ public class ItemSpriteSheet { public static final int ARMOR_HOLDER = PLACEHOLDERS+2; public static final int RING_HOLDER = PLACEHOLDERS+3; public static final int SOMETHING = PLACEHOLDERS+4; + static { + for (int i = PLACEHOLDERS; i < PLACEHOLDERS+8; i++) + assignItemRect(i, 16, 16); + } private static final int UNCOLLECTIBLE = xy(9, 1); //8 slots public static final int GOLD = UNCOLLECTIBLE+0; @@ -43,6 +52,13 @@ public class ItemSpriteSheet { public static final int PETAL = UNCOLLECTIBLE+2; public static final int SANDBAG = UNCOLLECTIBLE+3; public static final int DBL_BOMB = UNCOLLECTIBLE+4; + static{ + assignItemRect(GOLD, 15, 14); + assignItemRect(DEWDROP, 10, 10); + assignItemRect(PETAL, 8, 8); + assignItemRect(SANDBAG, 10, 10); + assignItemRect(DBL_BOMB, 14, 13); + } private static final int CONTAINERS = xy(1, 2); //16 slots public static final int BONES = CONTAINERS+0; @@ -52,6 +68,15 @@ public class ItemSpriteSheet { public static final int CHEST = CONTAINERS+4; public static final int LOCKED_CHEST = CONTAINERS+5; public static final int CRYSTAL_CHEST = CONTAINERS+6; + static{ + assignItemRect(BONES, 15, 14); + assignItemRect(REMAINS, 15, 14); + assignItemRect(TOMB, 14, 15); + assignItemRect(GRAVE, 14, 15); + assignItemRect(CHEST, 16, 15); + assignItemRect(LOCKED_CHEST, 16, 15); + assignItemRect(CRYSTAL_CHEST, 16, 15); + } private static final int SINGLE_USE = xy(1, 3); //32 slots public static final int ANKH = SINGLE_USE+0; @@ -69,6 +94,23 @@ public class ItemSpriteSheet { public static final int MASTERY = SINGLE_USE+12; public static final int KIT = SINGLE_USE+13; public static final int AMULET = SINGLE_USE+14; + static{ + assignItemRect(ANKH, 10, 16); + assignItemRect(STYLUS, 12, 13); + assignItemRect(WEIGHT, 14, 12); + assignItemRect(SEAL, 9, 15); + assignItemRect(TORCH, 12, 15); + assignItemRect(BEACON, 16, 15); + assignItemRect(BOMB, 10, 13); + assignItemRect(HONEYPOT, 14, 12); + assignItemRect(SHATTPOT, 14, 12); + assignItemRect(IRON_KEY, 8, 14); + assignItemRect(GOLDEN_KEY, 8, 14); + assignItemRect(SKELETON_KEY, 8, 14); + assignItemRect(MASTERY, 13, 16); + assignItemRect(KIT, 16, 15); + assignItemRect(AMULET, 16, 16); + } //32 free slots @@ -79,6 +121,12 @@ public class ItemSpriteSheet { public static final int RAPIER = WEP_TIER1+3; public static final int DAGGER = WEP_TIER1+4; public static final int MAGES_STAFF = WEP_TIER1+5; + static{ + assignItemRect(WORN_SHORTSWORD, 13, 13); + assignItemRect(KNUCKLEDUSTER, 15, 10); + assignItemRect(DAGGER, 12, 13); + assignItemRect(MAGES_STAFF, 15, 16); + } private static final int WEP_TIER2 = xy(9, 7); //8 slots public static final int SHORTSWORD = WEP_TIER2+0; @@ -86,6 +134,13 @@ public class ItemSpriteSheet { public static final int SPEAR = WEP_TIER2+2; public static final int QUARTERSTAFF = WEP_TIER2+3; public static final int DIRK = WEP_TIER2+4; + static{ + assignItemRect(SHORTSWORD, 13, 13); + assignItemRect(HAND_AXE, 12, 14); + assignItemRect(SPEAR, 16, 16); + assignItemRect(QUARTERSTAFF, 16, 16); + assignItemRect(DIRK, 13, 14); + } private static final int WEP_TIER3 = xy(1, 8); //8 slots public static final int SWORD = WEP_TIER3+0; @@ -94,6 +149,14 @@ public class ItemSpriteSheet { public static final int ROUND_SHIELD = WEP_TIER3+3; public static final int SAI = WEP_TIER3+4; public static final int WHIP = WEP_TIER3+5; + static{ + assignItemRect(SWORD, 14, 14); + assignItemRect(MACE, 15, 14); + assignItemRect(SCIMITAR, 13, 16); + assignItemRect(ROUND_SHIELD, 16, 16); + assignItemRect(SAI, 16, 16); + assignItemRect(WHIP, 14, 14); + } private static final int WEP_TIER4 = xy(9, 8); //8 slots public static final int LONGSWORD = WEP_TIER4+0; @@ -101,6 +164,13 @@ public class ItemSpriteSheet { public static final int FLAIL = WEP_TIER4+2; public static final int RUNIC_BLADE = WEP_TIER4+3; public static final int ASSASSINS_BLADE = WEP_TIER4+4; + static{ + assignItemRect(LONGSWORD, 15, 15); + assignItemRect(BATTLE_AXE, 16, 16); + assignItemRect(FLAIL, 14, 14); + assignItemRect(RUNIC_BLADE, 14, 14); + assignItemRect(ASSASSINS_BLADE, 14, 15); + } private static final int WEP_TIER5 = xy(1, 9); //8 slots public static final int GREATSWORD = WEP_TIER5+0; @@ -108,6 +178,13 @@ public class ItemSpriteSheet { public static final int GLAIVE = WEP_TIER5+2; public static final int GREATAXE = WEP_TIER5+3; public static final int GREATSHIELD = WEP_TIER5+4; + static{ + assignItemRect(GREATSWORD, 16, 16); + assignItemRect(WAR_HAMMER, 16, 16); + assignItemRect(GLAIVE, 16, 16); + assignItemRect(GREATAXE, 12, 16); + assignItemRect(GREATSHIELD, 12, 16); + } //8 free slots @@ -119,6 +196,15 @@ public class ItemSpriteSheet { public static final int CURARE_DART = MISSILE_WEP+4; public static final int JAVELIN = MISSILE_WEP+5; public static final int TOMAHAWK = MISSILE_WEP+6; + static{ + assignItemRect(DART, 15, 15); + assignItemRect(BOOMERANG, 14, 14); + assignItemRect(INCENDIARY_DART, 15, 15); + assignItemRect(SHURIKEN, 12, 12); + assignItemRect(CURARE_DART, 15, 15); + assignItemRect(JAVELIN, 16, 16); + assignItemRect(TOMAHAWK, 13, 13); + } private static final int ARMOR = xy(1, 11); //16 slots public static final int ARMOR_CLOTH = ARMOR+0; @@ -130,6 +216,17 @@ public class ItemSpriteSheet { public static final int ARMOR_MAGE = ARMOR+6; public static final int ARMOR_ROGUE = ARMOR+7; public static final int ARMOR_HUNTRESS = ARMOR+8; + static{ + assignItemRect(ARMOR_CLOTH, 15, 12); + assignItemRect(ARMOR_LEATHER, 14, 13); + assignItemRect(ARMOR_MAIL, 14, 12); + assignItemRect(ARMOR_SCALE, 14, 11); + assignItemRect(ARMOR_PLATE, 12, 12); + assignItemRect(ARMOR_WARRIOR, 12, 12); + assignItemRect(ARMOR_MAGE, 15, 15); + assignItemRect(ARMOR_ROGUE, 14, 12); + assignItemRect(ARMOR_HUNTRESS, 13, 15); + } //32 free slots @@ -147,6 +244,10 @@ public class ItemSpriteSheet { public static final int WAND_WARDING = WANDS+10; public static final int WAND_REGROWTH = WANDS+11; public static final int WAND_TRANSFUSION = WANDS+12; + static { + for (int i = WANDS; i < WANDS+16; i++) + assignItemRect(i, 14, 14); + } private static final int RINGS = xy(1, 15); //16 slots public static final int RING_GARNET = RINGS+0; @@ -161,6 +262,10 @@ public class ItemSpriteSheet { public static final int RING_QUARTZ = RINGS+9; public static final int RING_AGATE = RINGS+10; public static final int RING_DIAMOND = RINGS+11; + static { + for (int i = RINGS; i < RINGS+16; i++) + assignItemRect(i, 8, 10); + } private static final int ARTIFACTS = xy(1, 16); //32 slots public static final int ARTIFACT_CLOAK = ARTIFACTS+0; @@ -186,6 +291,31 @@ public class ItemSpriteSheet { public static final int ARTIFACT_ROSE1 = ARTIFACTS+20; public static final int ARTIFACT_ROSE2 = ARTIFACTS+21; public static final int ARTIFACT_ROSE3 = ARTIFACTS+22; + static{ + assignItemRect(ARTIFACT_CLOAK, 9, 15); + assignItemRect(ARTIFACT_ARMBAND, 16, 13); + assignItemRect(ARTIFACT_CAPE, 16, 14); + assignItemRect(ARTIFACT_TALISMAN, 15, 13); + assignItemRect(ARTIFACT_HOURGLASS, 13, 16); + assignItemRect(ARTIFACT_TOOLKIT, 15, 13); + assignItemRect(ARTIFACT_SPELLBOOK, 13, 16); + assignItemRect(ARTIFACT_BEACON, 16, 16); + assignItemRect(ARTIFACT_CHAINS, 16, 16); + assignItemRect(ARTIFACT_HORN1, 15, 15); + assignItemRect(ARTIFACT_HORN2, 15, 15); + assignItemRect(ARTIFACT_HORN3, 15, 15); + assignItemRect(ARTIFACT_HORN4, 15, 15); + assignItemRect(ARTIFACT_CHALICE1, 12, 15); + assignItemRect(ARTIFACT_CHALICE2, 12, 15); + assignItemRect(ARTIFACT_CHALICE3, 12, 15); + assignItemRect(ARTIFACT_SANDALS, 16, 5 ); + assignItemRect(ARTIFACT_SHOES, 16, 6 ); + assignItemRect(ARTIFACT_BOOTS, 16, 9 ); + assignItemRect(ARTIFACT_GREAVES, 16, 14); + assignItemRect(ARTIFACT_ROSE1, 14, 14); + assignItemRect(ARTIFACT_ROSE2, 14, 14); + assignItemRect(ARTIFACT_ROSE3, 14, 14); + } //32 free slots @@ -202,6 +332,10 @@ public class ItemSpriteSheet { public static final int SCROLL_BERKANAN = SCROLLS+9; public static final int SCROLL_ODAL = SCROLLS+10; public static final int SCROLL_TIWAZ = SCROLLS+11; + static { + for (int i = SCROLLS; i < SCROLLS+16; i++) + assignItemRect(i, 15, 14); + } private static final int POTIONS = xy(1, 21); //16 slots public static final int POTION_CRIMSON = POTIONS+0; @@ -216,6 +350,10 @@ public class ItemSpriteSheet { public static final int POTION_CHARCOAL = POTIONS+9; public static final int POTION_SILVER = POTIONS+10; public static final int POTION_IVORY = POTIONS+11; + static { + for (int i = POTIONS; i < POTIONS+16; i++) + assignItemRect(i, 10, 14); + } private static final int SEEDS = xy(1, 22); //16 slots public static final int SEED_ROTBERRY = SEEDS+0; @@ -230,6 +368,10 @@ public class ItemSpriteSheet { public static final int SEED_EARTHROOT = SEEDS+9; public static final int SEED_FADELEAF = SEEDS+10; public static final int SEED_BLANDFRUIT = SEEDS+11; + static{ + for (int i = SEEDS; i < SEEDS+16; i++) + assignItemRect(i, 10, 10); + } //32 free slots @@ -243,6 +385,17 @@ public class ItemSpriteSheet { public static final int PASTY = FOOD+6; public static final int PUMPKIN_PIE = FOOD+7; public static final int CANDY_CANE = FOOD+8; + static{ + assignItemRect(MEAT, 15, 11); + assignItemRect(STEAK, 15, 11); + assignItemRect(OVERPRICED, 14, 11); + assignItemRect(CARPACCIO, 15, 11); + assignItemRect(BLANDFRUIT, 9, 12); + assignItemRect(RATION, 16, 12); + assignItemRect(PASTY, 16, 11); + assignItemRect(PUMPKIN_PIE, 16, 12); + assignItemRect(CANDY_CANE, 13, 16); + } private static final int QUEST = xy(1, 26); //32 slots public static final int SKULL = QUEST+0; @@ -252,6 +405,16 @@ public class ItemSpriteSheet { public static final int PICKAXE = QUEST+4; public static final int ORE = QUEST+5; public static final int TOKEN = QUEST+6; + static{ + assignItemRect(SKULL, 16, 11); + assignItemRect(DUST, 12, 11); + assignItemRect(CANDLE, 12, 12); + assignItemRect(EMBER, 12, 11); + assignItemRect(PICKAXE, 14, 14); + assignItemRect(ORE, 15, 15); + assignItemRect(TOKEN, 12, 12); + + } private static final int BAGS = xy(1, 28); //16 slots public static final int VIAL = BAGS+0; @@ -259,7 +422,21 @@ public class ItemSpriteSheet { public static final int HOLDER = BAGS+2; public static final int BANDOLIER = BAGS+3; public static final int HOLSTER = BAGS+4; + static{ + assignItemRect(VIAL, 12, 12); + assignItemRect(POUCH, 14, 15); + assignItemRect(HOLDER, 16, 16); + assignItemRect(BANDOLIER, 15, 16); + assignItemRect(HOLSTER, 15, 16); + } //64 free slots + + private static void assignItemRect( int item, int width, int height){ + int x = (item % WIDTH) * WIDTH; + int y = (item / WIDTH) * WIDTH; + film.add( item, x, y, x+width, y+height); + } + } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MissileSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MissileSprite.java index 88e269f4a..f980a8ea1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MissileSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/MissileSprite.java @@ -34,42 +34,61 @@ public class MissileSprite extends ItemSprite implements Tweener.Listener { private Callback callback; - public MissileSprite() { - super(); - originToCenter(); - } - public void reset( int from, int to, Item item, Callback listener ) { - reset( DungeonTilemap.tileToWorld( from ), + revive(); + int image; + + if (item == null) view(image = 0, null); + else view(image = item.image(), item.glowing()); + + setup( DungeonTilemap.tileToWorld( from ), DungeonTilemap.tileToWorld( to ), - item, + image, listener); } public void reset( Visual from, Visual to, Item item, Callback listener ) { - reset( from.center(this), + revive(); + int image; + + if (item == null) view(image = 0, null); + else view(image = item.image(), item.glowing()); + + setup( from.center(this), to.center(this), - item, + image, listener); } public void reset( Visual from, int to, Item item, Callback listener ) { - reset( from.center(this), + revive(); + int image; + + if (item == null) view(image = 0, null); + else view(image = item.image(), item.glowing()); + + setup( from.center(this), DungeonTilemap.tileToWorld( to ), - item, + image, listener); } public void reset( PointF from, PointF to, Item item, Callback listener) { revive(); - int image; - if (item == null){ - view( image = 0, null);; - } else { - //no particle effects - view( image = item.image(), item.glowing() ); - } + + if (item == null) view(image = 0, null); + else view(image = item.image(), item.glowing()); + + setup( from, + to, + image, + listener ); + } + + private void setup( PointF from, PointF to, int image, Callback listener ){ + + originToCenter(); this.callback = listener; @@ -82,7 +101,7 @@ public class MissileSprite extends ItemSprite implements Tweener.Listener { || image == ItemSpriteSheet.CURARE_DART || image == ItemSpriteSheet.JAVELIN) { angularSpeed = 0; - angle = 135 - (float)(Math.atan2( d.x, d.y ) / 3.1415926 * 180); + angle = 135 - (float)(Math.atan2( d.y, d.x ) / 3.1415926 * 180); } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java index db13d8a45..6f9848e0d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java @@ -78,20 +78,23 @@ public class IconTitle extends Component { health.visible = !Float.isNaN( healthLvl ); - imIcon.x = x; - imIcon.y = y; + imIcon.x = x + (Math.max(0, 8 - imIcon.width()/2)); + imIcon.y = y + (Math.max(0, 8 - imIcon.height()/2)); - tfLabel.maxWidth((int)(width - (imIcon.x + imIcon.width() + GAP))); - tfLabel.setPos(imIcon.x + imIcon.width() + GAP, imIcon.height > tfLabel.height() ? - imIcon.y + (imIcon.height() - tfLabel.height()) / 2 : - imIcon.y); + int imWidth = (int)Math.max(imIcon.width(), 16); + int imHeight = (int)Math.max(imIcon.height(), 16); + + tfLabel.maxWidth((int)(width - (imWidth + GAP))); + tfLabel.setPos(x + imWidth + GAP, imHeight > tfLabel.height() ? + y +(imHeight - tfLabel.height()) / 2 : + y); PixelScene.align(tfLabel); if (health.visible) { - health.setRect( tfLabel.left(), Math.max( tfLabel.top() + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth(), 0 ); - height = health.bottom(); + health.setRect( tfLabel.left(), tfLabel.bottom(), tfLabel.maxWidth(), 0 ); + height = Math.max( imHeight, health.bottom() ); } else { - height = Math.max( imIcon.height(), tfLabel.height() ); + height = Math.max( imHeight, tfLabel.height() ); } }