v1.2.0: added functionality for large buff indicators
This commit is contained in:
parent
689d3b1df5
commit
632ae6cca0
|
@ -101,18 +101,22 @@ public class BuffIndicator extends Component {
|
||||||
public static final int ANKH = 52;
|
public static final int ANKH = 52;
|
||||||
public static final int NOINV = 53;
|
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;
|
private static BuffIndicator heroInstance;
|
||||||
|
|
||||||
private LinkedHashMap<Buff, BuffButton> buffButtons = new LinkedHashMap<>();
|
private LinkedHashMap<Buff, BuffButton> buffButtons = new LinkedHashMap<>();
|
||||||
private boolean needsRefresh;
|
private boolean needsRefresh;
|
||||||
private Char ch;
|
private Char ch;
|
||||||
|
|
||||||
|
private boolean large = false;
|
||||||
|
|
||||||
public BuffIndicator( Char ch ) {
|
public BuffIndicator( Char ch, boolean large ) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.ch = ch;
|
this.ch = ch;
|
||||||
|
this.large = large;
|
||||||
if (ch == Dungeon.hero) {
|
if (ch == Dungeon.hero) {
|
||||||
heroInstance = this;
|
heroInstance = this;
|
||||||
}
|
}
|
||||||
|
@ -138,19 +142,21 @@ public class BuffIndicator extends Component {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void layout() {
|
protected void layout() {
|
||||||
|
|
||||||
ArrayList<Buff> newBuffs = new ArrayList<>();
|
ArrayList<Buff> newBuffs = new ArrayList<>();
|
||||||
for (Buff buff : ch.buffs()) {
|
for (Buff buff : ch.buffs()) {
|
||||||
if (buff.icon() != NONE) {
|
if (buff.icon() != NONE) {
|
||||||
newBuffs.add(buff);
|
newBuffs.add(buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int size = large ? SIZE_LARGE : SIZE_SMALL;
|
||||||
|
|
||||||
//remove any icons no longer present
|
//remove any icons no longer present
|
||||||
for (Buff buff : buffButtons.keySet().toArray(new Buff[0])){
|
for (Buff buff : buffButtons.keySet().toArray(new Buff[0])){
|
||||||
if (!newBuffs.contains(buff)){
|
if (!newBuffs.contains(buff)){
|
||||||
Image icon = buffButtons.get( buff ).icon;
|
Image icon = buffButtons.get( buff ).icon;
|
||||||
icon.origin.set( SIZE / 2f );
|
icon.originToCenter();
|
||||||
icon.alpha(0.6f);
|
icon.alpha(0.6f);
|
||||||
add( icon );
|
add( icon );
|
||||||
add( new AlphaTweener( icon, 0, 0.6f ) {
|
add( new AlphaTweener( icon, 0, 0.6f ) {
|
||||||
|
@ -175,7 +181,7 @@ public class BuffIndicator extends Component {
|
||||||
//add new icons
|
//add new icons
|
||||||
for (Buff buff : newBuffs) {
|
for (Buff buff : newBuffs) {
|
||||||
if (!buffButtons.containsKey(buff)) {
|
if (!buffButtons.containsKey(buff)) {
|
||||||
BuffButton icon = new BuffButton(buff);
|
BuffButton icon = new BuffButton(buff, large);
|
||||||
add(icon);
|
add(icon);
|
||||||
buffButtons.put( buff, icon );
|
buffButtons.put( buff, icon );
|
||||||
}
|
}
|
||||||
|
@ -185,7 +191,8 @@ public class BuffIndicator extends Component {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (BuffButton icon : buffButtons.values()){
|
for (BuffButton icon : buffButtons.values()){
|
||||||
icon.updateIcon();
|
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);
|
PixelScene.align(icon);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
@ -198,8 +205,9 @@ public class BuffIndicator extends Component {
|
||||||
//Todo maybe move into buff icon?
|
//Todo maybe move into buff icon?
|
||||||
public Image grey;
|
public Image grey;
|
||||||
|
|
||||||
public BuffButton(Buff buff ){
|
//TODO for large buffs there is room to have text instead of fading
|
||||||
super( new BuffIcon(buff, false));
|
public BuffButton( Buff buff, boolean large ){
|
||||||
|
super( new BuffIcon(buff, large));
|
||||||
this.buff = buff;
|
this.buff = buff;
|
||||||
|
|
||||||
bringToFront(grey);
|
bringToFront(grey);
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class StatusPane extends Component {
|
||||||
level.hardlight( 0xFFFFAA );
|
level.hardlight( 0xFFFFAA );
|
||||||
add( level );
|
add( level );
|
||||||
|
|
||||||
buffs = new BuffIndicator( Dungeon.hero );
|
buffs = new BuffIndicator( Dungeon.hero, false );
|
||||||
add( buffs );
|
add( buffs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class WndInfoMob extends WndTitledMessage {
|
||||||
health.level(mob);
|
health.level(mob);
|
||||||
add( health );
|
add( health );
|
||||||
|
|
||||||
buffs = new BuffIndicator( mob );
|
buffs = new BuffIndicator( mob, false );
|
||||||
add( buffs );
|
add( buffs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class WndInfoMob extends WndTitledMessage {
|
||||||
|
|
||||||
buffs.setPos(
|
buffs.setPos(
|
||||||
name.right() + GAP-1,
|
name.right() + GAP-1,
|
||||||
name.bottom() - BuffIndicator.SIZE-2
|
name.bottom() - BuffIndicator.SIZE_SMALL-2
|
||||||
);
|
);
|
||||||
|
|
||||||
height = health.bottom();
|
height = health.bottom();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user