v2.0.2: more action ind. improvements, moved some info to new indicator
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
@@ -29,13 +29,17 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal.WarriorShield;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.DangerIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.GameMath;
|
||||
@@ -137,6 +141,8 @@ public class Berserk extends Buff implements ActionIndicator.Action {
|
||||
|
||||
if (power < 1f){
|
||||
ActionIndicator.clearAction(this);
|
||||
} else {
|
||||
ActionIndicator.refresh();
|
||||
}
|
||||
|
||||
if (power <= 0) {
|
||||
@@ -242,17 +248,21 @@ public class Berserk extends Buff implements ActionIndicator.Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
return new HeroIcon(HeroIcon.BERSERK);
|
||||
public int actionIcon() {
|
||||
return HeroIcon.BERSERK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
return null;
|
||||
public Visual secondaryVisual() {
|
||||
BitmapText txt = new BitmapText(PixelScene.pixelFont);
|
||||
txt.text((int) (power * 100) + "%");
|
||||
txt.hardlight(CharSprite.POSITIVE);
|
||||
txt.measure();
|
||||
return txt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
public int indicatorColor() {
|
||||
return 0x660000;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
@@ -46,7 +47,9 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndCombo;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Callback;
|
||||
@@ -175,23 +178,27 @@ public class Combo extends Buff implements ActionIndicator.Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
return new HeroIcon(HeroIcon.COMBO);
|
||||
public int actionIcon() {
|
||||
return HeroIcon.COMBO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
return null;
|
||||
public Visual secondaryVisual() {
|
||||
BitmapText txt = new BitmapText(PixelScene.pixelFont);
|
||||
txt.text( Integer.toString(count) );
|
||||
txt.hardlight(CharSprite.POSITIVE);
|
||||
txt.measure();
|
||||
return txt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
public int indicatorColor() {
|
||||
ComboMove best = getHighestMove();
|
||||
if (best == null) {
|
||||
return 0xDFDFDF;
|
||||
} else {
|
||||
//take the tint color and darken slightly to match buff icon
|
||||
int r = (int) ((best.tintColor & 0xFF) * 0.875f);
|
||||
int r = (int) ((best.tintColor >> 16) * 0.875f);
|
||||
int g = (int) (((best.tintColor >> 8) & 0xFF) * 0.875f);
|
||||
int b = (int) ((best.tintColor & 0xFF) * 0.875f);
|
||||
return (r << 16) + (g << 8) + b;
|
||||
|
||||
@@ -27,11 +27,15 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.GameMath;
|
||||
@@ -77,6 +81,8 @@ public class Momentum extends Buff implements ActionIndicator.Action {
|
||||
if (momentumStacks <= 0) {
|
||||
ActionIndicator.clearAction(this);
|
||||
if (freerunCooldown <= 0) detach();
|
||||
} else {
|
||||
ActionIndicator.refresh();
|
||||
}
|
||||
}
|
||||
movedLastTurn = false;
|
||||
@@ -123,12 +129,10 @@ public class Momentum extends Buff implements ActionIndicator.Action {
|
||||
|
||||
@Override
|
||||
public void tintIcon(Image icon) {
|
||||
if (freerunTurns > 0){
|
||||
if (freerunCooldown == 0){
|
||||
icon.hardlight(1,1,0);
|
||||
} else if (freerunCooldown > 0){
|
||||
icon.hardlight(0.5f,0.5f,1);
|
||||
} else {
|
||||
icon.hardlight(1f - (momentumStacks /10f),1,1f - (momentumStacks /10f));
|
||||
icon.hardlight(0.5f,0.5f,1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +143,7 @@ public class Momentum extends Buff implements ActionIndicator.Action {
|
||||
} else if (freerunCooldown > 0){
|
||||
return (freerunCooldown) / 30f;
|
||||
} else {
|
||||
return (10 - momentumStacks) / 10f;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +154,7 @@ public class Momentum extends Buff implements ActionIndicator.Action {
|
||||
} else if (freerunCooldown > 0){
|
||||
return Integer.toString(freerunCooldown);
|
||||
} else {
|
||||
return Integer.toString(momentumStacks);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,19 +210,21 @@ public class Momentum extends Buff implements ActionIndicator.Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
Image actionIco = new HeroIcon(HeroIcon.MOMENTUM);
|
||||
actionIco.hardlight(1, 1, 0);
|
||||
return actionIco;
|
||||
public int actionIcon() {
|
||||
return HeroIcon.MOMENTUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
return null;
|
||||
public Visual secondaryVisual() {
|
||||
BitmapText txt = new BitmapText(PixelScene.pixelFont);
|
||||
txt.text(Integer.toString((int)momentumStacks) );
|
||||
txt.hardlight(CharSprite.POSITIVE);
|
||||
txt.measure();
|
||||
return txt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
public int indicatorColor() {
|
||||
return 0x444444;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,14 +43,18 @@ import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMonkAbilities;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Callback;
|
||||
@@ -65,6 +69,8 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action {
|
||||
public float energy;
|
||||
public int cooldown;
|
||||
|
||||
private static final float MAX_COOLDOWN = 5;
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.MONK_ENERGY;
|
||||
@@ -74,8 +80,6 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action {
|
||||
public void tintIcon(Image icon) {
|
||||
if (cooldown > 0){
|
||||
icon.hardlight(0.33f, 0.33f, 1f);
|
||||
} else if (abilitiesEmpowered(Dungeon.hero)) {
|
||||
icon.tint(0.6f, 1f, 0.2f, 0.33f);
|
||||
} else {
|
||||
icon.resetColor();
|
||||
}
|
||||
@@ -83,12 +87,16 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action {
|
||||
|
||||
@Override
|
||||
public float iconFadePercent() {
|
||||
return Math.max(0, (energyCap() - energy)/ energyCap());
|
||||
return Math.max(0, cooldown/MAX_COOLDOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String iconTextDisplay() {
|
||||
return Integer.toString((int)energy);
|
||||
if (cooldown > 0){
|
||||
return Integer.toString(cooldown);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,6 +226,8 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action {
|
||||
|
||||
if (cooldown > 0 || energy < 1){
|
||||
ActionIndicator.clearAction(this);
|
||||
} else {
|
||||
ActionIndicator.refresh();
|
||||
}
|
||||
BuffIndicator.refreshHero();
|
||||
}
|
||||
@@ -243,22 +253,22 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
return new HeroIcon(HeroIcon.MONK_ABILITIES);
|
||||
public int actionIcon() {
|
||||
return HeroIcon.MONK_ABILITIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
return null;
|
||||
public Visual secondaryVisual() {
|
||||
BitmapText txt = new BitmapText(PixelScene.pixelFont);
|
||||
txt.text( Integer.toString((int)energy) );
|
||||
if (abilitiesEmpowered(Dungeon.hero)) txt.hardlight(CharSprite.POSITIVE);
|
||||
txt.measure();
|
||||
return txt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
if (abilitiesEmpowered(Dungeon.hero)){
|
||||
return 0xA0FF40;
|
||||
} else {
|
||||
return 0xA08840;
|
||||
}
|
||||
public int indicatorColor() {
|
||||
return 0xA08840;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,12 +34,16 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.PathFinder;
|
||||
@@ -183,25 +187,6 @@ public class Preparation extends Buff implements ActionIndicator.Action {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float iconFadePercent() {
|
||||
AttackLevel level = AttackLevel.getLvl(turnsInvis);
|
||||
if (level == AttackLevel.LVL_4){
|
||||
return 0;
|
||||
} else {
|
||||
float turnsForCur = level.turnsReq;
|
||||
float turnsForNext = AttackLevel.values()[level.ordinal()+1].turnsReq;
|
||||
turnsForNext -= turnsForCur;
|
||||
float turnsToNext = turnsInvis - turnsForCur;
|
||||
return Math.min(1, (turnsForNext - turnsToNext)/(turnsForNext));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String iconTextDisplay() {
|
||||
return Integer.toString(turnsInvis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = Messages.get(this, "desc");
|
||||
@@ -252,19 +237,28 @@ public class Preparation extends Buff implements ActionIndicator.Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
Image actionIco = new HeroIcon(HeroIcon.PREPARATION);
|
||||
public int actionIcon() {
|
||||
return HeroIcon.PREPARATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Visual primaryVisual() {
|
||||
Image actionIco = new HeroIcon(this);
|
||||
tintIcon(actionIco);
|
||||
return actionIco;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
return null;
|
||||
public Visual secondaryVisual() {
|
||||
BitmapText txt = new BitmapText(PixelScene.pixelFont);
|
||||
txt.text(Integer.toString(Math.min(9, turnsInvis)));
|
||||
txt.hardlight(CharSprite.POSITIVE);
|
||||
txt.measure();
|
||||
return txt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
public int indicatorColor() {
|
||||
return 0x444444;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,17 +114,12 @@ public class SnipersMark extends FlavourBuff implements ActionIndicator.Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
return new HeroIcon(HeroIcon.SNIPERS_MARK);
|
||||
public int actionIcon() {
|
||||
return HeroIcon.SNIPERS_MARK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
public int indicatorColor() {
|
||||
return 0x444444;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,10 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
@@ -548,10 +550,15 @@ public class MeleeWeapon extends Weapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image actionIcon() {
|
||||
public int actionIcon() {
|
||||
return HeroIcon.WEAPON_SWAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Visual primaryVisual() {
|
||||
Image ico;
|
||||
if (Dungeon.hero.belongings.weapon == null){
|
||||
ico = new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER);
|
||||
ico = new HeroIcon(this);
|
||||
} else {
|
||||
ico = new ItemSprite(Dungeon.hero.belongings.weapon);
|
||||
}
|
||||
@@ -560,10 +567,10 @@ public class MeleeWeapon extends Weapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image secondIcon() {
|
||||
public Visual secondaryVisual() {
|
||||
Image ico;
|
||||
if (Dungeon.hero.belongings.secondWep == null){
|
||||
ico = new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER);
|
||||
ico = new HeroIcon(this);
|
||||
} else {
|
||||
ico = new ItemSprite(Dungeon.hero.belongings.secondWep);
|
||||
}
|
||||
@@ -573,7 +580,7 @@ public class MeleeWeapon extends Weapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int actionColor() {
|
||||
public int indicatorColor() {
|
||||
return 0x5500BB;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Visual;
|
||||
|
||||
public class ActionIndicator extends Tag {
|
||||
|
||||
Image icon;
|
||||
Image secondIcon;
|
||||
Visual primaryVis;
|
||||
Visual secondVis;
|
||||
|
||||
public static Action action;
|
||||
public static ActionIndicator instance;
|
||||
@@ -60,44 +61,72 @@ public class ActionIndicator extends Tag {
|
||||
protected synchronized void layout() {
|
||||
super.layout();
|
||||
|
||||
if (icon != null){
|
||||
if (!flipped) icon.x = x + (SIZE - icon.width()) / 2f + 1;
|
||||
else icon.x = x + width - (SIZE + icon.width()) / 2f - 1;
|
||||
icon.y = y + (height - icon.height()) / 2f;
|
||||
PixelScene.align(icon);
|
||||
if (secondIcon != null){
|
||||
secondIcon.x = icon.center().x + 8 - secondIcon.width();
|
||||
secondIcon.y = icon.y + icon.height() - secondIcon.height();
|
||||
if (primaryVis != null){
|
||||
if (!flipped) primaryVis.x = x + (SIZE - primaryVis.width()) / 2f + 1;
|
||||
else primaryVis.x = x + width - (SIZE + primaryVis.width()) / 2f - 1;
|
||||
primaryVis.y = y + (height - primaryVis.height()) / 2f;
|
||||
PixelScene.align(primaryVis);
|
||||
if (secondVis != null){
|
||||
if (secondVis.width() > 16) secondVis.x = primaryVis.center().x - secondVis.width()/2f;
|
||||
else secondVis.x = primaryVis.center().x + 8 - secondVis.width();
|
||||
if (secondVis instanceof BitmapText){
|
||||
//need a special case here for text unfortunately
|
||||
secondVis.y = primaryVis.center().y + 8 - ((BitmapText) secondVis).baseLine();
|
||||
} else {
|
||||
secondVis.y = primaryVis.center().y + 8 - secondVis.height();
|
||||
}
|
||||
PixelScene.align(secondVis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean needsLayout = false;
|
||||
private boolean needsRefresh = false;
|
||||
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
super.update();
|
||||
|
||||
if (!Dungeon.hero.ready){
|
||||
if (icon != null) icon.alpha(0.5f);
|
||||
if (secondIcon != null) secondIcon.alpha(0.5f);
|
||||
} else {
|
||||
if (icon != null) icon.alpha(1f);
|
||||
if (secondIcon != null) secondIcon.alpha(1f);
|
||||
}
|
||||
|
||||
if (!visible && action != null){
|
||||
visible = true;
|
||||
refresh();
|
||||
needsRefresh = true;
|
||||
flash();
|
||||
} else {
|
||||
visible = action != null;
|
||||
}
|
||||
|
||||
if (needsLayout){
|
||||
|
||||
if (needsRefresh){
|
||||
if (primaryVis != null) {
|
||||
primaryVis.killAndErase();
|
||||
primaryVis = null;
|
||||
}
|
||||
if (secondVis != null){
|
||||
secondVis.killAndErase();
|
||||
secondVis = null;
|
||||
}
|
||||
if (action != null) {
|
||||
primaryVis = action.primaryVisual();
|
||||
add(primaryVis);
|
||||
|
||||
secondVis = action.secondaryVisual();
|
||||
if (secondVis != null){
|
||||
add(secondVis);
|
||||
}
|
||||
|
||||
needsRefresh = true;
|
||||
setColor(action.indicatorColor());
|
||||
}
|
||||
|
||||
layout();
|
||||
needsLayout = false;
|
||||
}
|
||||
|
||||
if (!Dungeon.hero.ready){
|
||||
if (primaryVis != null) primaryVis.alpha(0.5f);
|
||||
if (secondVis != null) secondVis.alpha(0.5f);
|
||||
} else {
|
||||
if (primaryVis != null) primaryVis.alpha(1f);
|
||||
if (secondVis != null) secondVis.alpha(1f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,44 +159,31 @@ public class ActionIndicator extends Tag {
|
||||
|
||||
public static void refresh(){
|
||||
if (instance != null){
|
||||
synchronized (instance) {
|
||||
if (instance.icon != null) {
|
||||
instance.icon.killAndErase();
|
||||
instance.icon = null;
|
||||
}
|
||||
if (instance.secondIcon != null){
|
||||
instance.secondIcon.killAndErase();
|
||||
instance.secondIcon = null;
|
||||
}
|
||||
if (action != null) {
|
||||
instance.icon = action.actionIcon();
|
||||
instance.add(instance.icon);
|
||||
|
||||
Image secondIco = action.secondIcon();
|
||||
if (secondIco != null){
|
||||
instance.secondIcon = secondIco;
|
||||
instance.add(instance.secondIcon);
|
||||
}
|
||||
|
||||
instance.needsLayout = true;
|
||||
instance.setColor(action.actionColor());
|
||||
}
|
||||
}
|
||||
instance.needsRefresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Action{
|
||||
public interface Action {
|
||||
|
||||
public String actionName();
|
||||
String actionName();
|
||||
|
||||
public Image actionIcon();
|
||||
default int actionIcon(){
|
||||
return HeroIcon.NONE;
|
||||
}
|
||||
|
||||
//TODO more variable than an icon maybe
|
||||
public Image secondIcon();
|
||||
//usually just a static icon, unless overridden
|
||||
default Visual primaryVisual(){
|
||||
return new HeroIcon(this);
|
||||
}
|
||||
|
||||
public int actionColor();
|
||||
//a smaller visual on the bottom-right, usually a tiny icon or bitmap text
|
||||
default Visual secondaryVisual(){
|
||||
return null; //no second visual by default
|
||||
}
|
||||
|
||||
public void doAction();
|
||||
int indicatorColor();
|
||||
|
||||
void doAction();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HeroIcon extends Image {
|
||||
private static final int SIZE = 16;
|
||||
|
||||
//transparent icon
|
||||
public static final int NONE = 31;
|
||||
public static final int NONE = 63;
|
||||
|
||||
//subclasses
|
||||
public static final int BERSERKER = 0;
|
||||
@@ -72,7 +72,8 @@ public class HeroIcon extends Image {
|
||||
public static final int PREPARATION = 34;
|
||||
public static final int MOMENTUM = 35;
|
||||
public static final int SNIPERS_MARK = 36;
|
||||
public static final int MONK_ABILITIES = 37;
|
||||
public static final int WEAPON_SWAP = 37;
|
||||
public static final int MONK_ABILITIES = 38;
|
||||
|
||||
public HeroIcon(HeroSubClass subCls){
|
||||
super( Assets.Interfaces.HERO_ICONS );
|
||||
@@ -90,13 +91,12 @@ public class HeroIcon extends Image {
|
||||
frame(film.get(abil.icon()));
|
||||
}
|
||||
|
||||
//TODO make this consistent with subclass and ability icons
|
||||
public HeroIcon(int icon){
|
||||
public HeroIcon(ActionIndicator.Action action){
|
||||
super( Assets.Interfaces.HERO_ICONS );
|
||||
if (film == null){
|
||||
film = new TextureFilm(texture, SIZE, SIZE);
|
||||
}
|
||||
frame(film.get(icon));
|
||||
frame(film.get(action.actionIcon()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user