Support showing energy counters under life (if no poison counters)

This commit is contained in:
drdev
2016-09-27 02:41:06 +00:00
parent 7af61405f5
commit 8d46065168

View File

@@ -333,6 +333,7 @@ public class VPlayerPanel extends FContainer {
private class LifeLabel extends FDisplayObject { private class LifeLabel extends FDisplayObject {
private int life = player.getLife(); private int life = player.getLife();
private int poisonCounters = player.getCounters(CounterType.POISON); private int poisonCounters = player.getCounters(CounterType.POISON);
private int energyCounters = player.getCounters(CounterType.ENERGY);
private String lifeStr = String.valueOf(life); private String lifeStr = String.valueOf(life);
private LifeLabel() { private LifeLabel() {
@@ -359,6 +360,8 @@ public class VPlayerPanel extends FContainer {
poisonCounters = player.getCounters(CounterType.POISON); poisonCounters = player.getCounters(CounterType.POISON);
} }
energyCounters = player.getCounters(CounterType.ENERGY);
//when gui player loses life, vibrate device for a length of time based on amount of life lost //when gui player loses life, vibrate device for a length of time based on amount of life lost
if (vibrateDuration > 0 && MatchController.instance.isLocalPlayer(player) && if (vibrateDuration > 0 && MatchController.instance.isLocalPlayer(player) &&
FModel.getPreferences().getPrefBoolean(FPref.UI_VIBRATE_ON_LIFE_LOSS)) { FModel.getPreferences().getPrefBoolean(FPref.UI_VIBRATE_ON_LIFE_LOSS)) {
@@ -375,7 +378,7 @@ public class VPlayerPanel extends FContainer {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
if (poisonCounters == 0) { if (poisonCounters == 0 && energyCounters == 0) {
g.drawText(lifeStr, LIFE_FONT, INFO_FORE_COLOR, 0, 0, getWidth(), getHeight(), false, HAlignment.CENTER, true); g.drawText(lifeStr, LIFE_FONT, INFO_FORE_COLOR, 0, 0, getWidth(), getHeight(), false, HAlignment.CENTER, true);
} }
else { else {
@@ -384,9 +387,15 @@ public class VPlayerPanel extends FContainer {
float textWidth = getWidth() - textStart; float textWidth = getWidth() - textStart;
g.drawImage(FSkinImage.QUEST_LIFE, 0, 0, halfHeight, halfHeight); g.drawImage(FSkinImage.QUEST_LIFE, 0, 0, halfHeight, halfHeight);
g.drawText(lifeStr, INFO_FONT, INFO_FORE_COLOR, textStart, 0, textWidth, halfHeight, false, HAlignment.CENTER, true); g.drawText(lifeStr, INFO_FONT, INFO_FORE_COLOR, textStart, 0, textWidth, halfHeight, false, HAlignment.CENTER, true);
if (poisonCounters > 0) { //prioritize showing poison counters over energy counters
g.drawImage(FSkinImage.POISON, 0, halfHeight, halfHeight, halfHeight); g.drawImage(FSkinImage.POISON, 0, halfHeight, halfHeight, halfHeight);
g.drawText(String.valueOf(poisonCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, HAlignment.CENTER, true); g.drawText(String.valueOf(poisonCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, HAlignment.CENTER, true);
} }
else {
g.drawImage(FSkinImage.ENERGY, 0, halfHeight, halfHeight, halfHeight);
g.drawText(String.valueOf(energyCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, HAlignment.CENTER, true);
}
}
} }
} }