v1.2.0: added functionality for large buff indicators

This commit is contained in:
Evan Debenham 2022-01-19 20:15:42 -05:00
parent 689d3b1df5
commit 632ae6cca0
3 changed files with 20 additions and 12 deletions

View File

@ -101,7 +101,8 @@ public class BuffIndicator extends Component {
public static final int ANKH = 52;
public static final int NOINV = 53;
public static final int SIZE = 7;
public static final int SIZE_SMALL = 7;
public static final int SIZE_LARGE = 16;
private static BuffIndicator heroInstance;
@ -109,10 +110,13 @@ public class BuffIndicator extends Component {
private boolean needsRefresh;
private Char ch;
public BuffIndicator( Char ch ) {
private boolean large = false;
public BuffIndicator( Char ch, boolean large ) {
super();
this.ch = ch;
this.large = large;
if (ch == Dungeon.hero) {
heroInstance = this;
}
@ -146,11 +150,13 @@ public class BuffIndicator extends Component {
}
}
int size = large ? SIZE_LARGE : SIZE_SMALL;
//remove any icons no longer present
for (Buff buff : buffButtons.keySet().toArray(new Buff[0])){
if (!newBuffs.contains(buff)){
Image icon = buffButtons.get( buff ).icon;
icon.origin.set( SIZE / 2f );
icon.originToCenter();
icon.alpha(0.6f);
add( icon );
add( new AlphaTweener( icon, 0, 0.6f ) {
@ -175,7 +181,7 @@ public class BuffIndicator extends Component {
//add new icons
for (Buff buff : newBuffs) {
if (!buffButtons.containsKey(buff)) {
BuffButton icon = new BuffButton(buff);
BuffButton icon = new BuffButton(buff, large);
add(icon);
buffButtons.put( buff, icon );
}
@ -185,7 +191,8 @@ public class BuffIndicator extends Component {
int pos = 0;
for (BuffButton icon : buffButtons.values()){
icon.updateIcon();
icon.setRect(x + pos * (SIZE + 2), y, 9, 12);
//button areas are slightly oversized, especially on small buttons
icon.setRect(x + pos * (size + 2), y, size + 2, size + (large ? 2 : 5));
PixelScene.align(icon);
pos++;
}
@ -198,8 +205,9 @@ public class BuffIndicator extends Component {
//Todo maybe move into buff icon?
public Image grey;
public BuffButton(Buff buff ){
super( new BuffIcon(buff, false));
//TODO for large buffs there is room to have text instead of fading
public BuffButton( Buff buff, boolean large ){
super( new BuffIcon(buff, large));
this.buff = buff;
bringToFront(grey);

View File

@ -125,7 +125,7 @@ public class StatusPane extends Component {
level.hardlight( 0xFFFFAA );
add( level );
buffs = new BuffIndicator( Dungeon.hero );
buffs = new BuffIndicator( Dungeon.hero, false );
add( buffs );
}

View File

@ -60,7 +60,7 @@ public class WndInfoMob extends WndTitledMessage {
health.level(mob);
add( health );
buffs = new BuffIndicator( mob );
buffs = new BuffIndicator( mob, false );
add( buffs );
}
@ -80,7 +80,7 @@ public class WndInfoMob extends WndTitledMessage {
buffs.setPos(
name.right() + GAP-1,
name.bottom() - BuffIndicator.SIZE-2
name.bottom() - BuffIndicator.SIZE_SMALL-2
);
height = health.bottom();