v0.3.4: changed potion/scroll initials into icons

This commit is contained in:
Evan Debenham
2016-01-08 01:52:56 -05:00
committed by Evan Debenham
parent ff31a1f303
commit b29d71d2d8
29 changed files with 116 additions and 24 deletions
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
@@ -38,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Image;
import com.watabou.noosa.ui.Button;
public class ItemSlot extends Button {
@@ -54,6 +56,7 @@ public class ItemSlot extends Button {
protected BitmapText topLeft;
protected BitmapText topRight;
protected BitmapText bottomRight;
protected Image bottomRightIcon;
private static final String TXT_STRENGTH = ":%d";
private static final String TXT_TYPICAL_STR = "%d?";
@@ -130,6 +133,11 @@ public class ItemSlot extends Button {
bottomRight.x = x + (width - bottomRight.width());
bottomRight.y = y + (height - bottomRight.height());
}
if (bottomRightIcon != null) {
bottomRightIcon.x = x + (width - bottomRightIcon.width()) -1;
bottomRightIcon.y = y + (height - bottomRightIcon.height());
}
}
public void item( Item item ) {
@@ -189,16 +197,21 @@ public class ItemSlot extends Button {
bottomRight.measure();
bottomRight.hardlight( level > 0 ? UPGRADED : DEGRADED );
} else if (item instanceof Scroll || item instanceof Potion) {
if (item instanceof Scroll) bottomRight.text(((Scroll) item).initials());
else bottomRight.text(((Potion) item).initials());
bottomRight.text( null );
bottomRight.measure();
if (item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion
|| item instanceof PotionOfStrength || item instanceof PotionOfMight)
bottomRight.hardlight( UPGRADED );
else
bottomRight.hardlight( FADED );
Integer iconInt;
if (item instanceof Scroll){
iconInt = ((Scroll) item).initials();
} else {
iconInt = ((Potion) item).initials();
}
if (iconInt != null) {
bottomRightIcon = new Image(Assets.CONS_ICONS);
int left = iconInt*7;
int top = item instanceof Potion ? 0 : 8;
bottomRightIcon.frame(left, top, 7, 8);
add(bottomRightIcon);
}
} else {
bottomRight.text( null );
@@ -217,6 +230,7 @@ public class ItemSlot extends Button {
topLeft.alpha( alpha );
topRight.alpha( alpha );
bottomRight.alpha( alpha );
if (bottomRightIcon != null) bottomRightIcon.alpha( alpha );
}
public void showParams( boolean TL, boolean TR, boolean BR ) {