| 20 | import forge.toolbox.FDisplayObject; |
| 21 | |
| 22 | public class VManaPool extends VDisplayArea { |
| 23 | private static FSkinColor getForeColor() { |
| 24 | if (Forge.isMobileAdventureMode) |
| 25 | return FSkinColor.get(Colors.ADV_CLR_TEXT); |
| 26 | return FSkinColor.get(Colors.CLR_TEXT); |
| 27 | } |
| 28 | |
| 29 | private static final FSkinFont FONT = FSkinFont.get(16); |
| 30 | |
| 31 | private final PlayerView player; |
| 32 | private final List<ManaLabel> manaLabels = new ArrayList<>(); |
| 33 | private int totalMana; |
| 34 | |
| 35 | public VManaPool(PlayerView player0) { |
| 36 | player = player0; |
| 37 | |
| 38 | addManaLabel(FSkinProp.IMG_MANA_COLORLESS, (byte) ManaAtom.COLORLESS); |
| 39 | addManaLabel(FSkinProp.IMG_MANA_W, MagicColor.WHITE); |
| 40 | addManaLabel(FSkinProp.IMG_MANA_U, MagicColor.BLUE); |
| 41 | addManaLabel(FSkinProp.IMG_MANA_B, MagicColor.BLACK); |
| 42 | addManaLabel(FSkinProp.IMG_MANA_R, MagicColor.RED); |
| 43 | addManaLabel(FSkinProp.IMG_MANA_G, MagicColor.GREEN); |
| 44 | } |
| 45 | |
| 46 | private void addManaLabel(FSkinProp prop, byte colorCode) { |
| 47 | manaLabels.add(add(new ManaLabel(Forge.getAssets().images().get(prop), colorCode))); |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public int getCount() { |
| 52 | return totalMana; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public void update() { |
| 57 | totalMana = 0; |
| 58 | for (ManaLabel label : manaLabels) { |
| 59 | int colorCount = player.getMana(label.colorCode); |
| 60 | totalMana += colorCount; |
| 61 | label.text = Integer.toString(colorCount); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) { |
| 67 | float x = 0; |
| 68 | float y = 0; |
| 69 | |
| 70 | if (Forge.isLandscapeMode() && (!Forge.altZoneTabs || !"Horizontal".equalsIgnoreCase(Forge.altZoneTabMode))) { |
| 71 | float labelWidth = visibleWidth / 2; |
| 72 | float labelHeight = visibleHeight / 3; |
| 73 | |
| 74 | int count = 0; |
| 75 | for (ManaLabel label : manaLabels) { |
| 76 | label.setBounds(x, y, labelWidth, labelHeight); |
| 77 | if (++count % 2 == 0) { |
| 78 | x = 0; |
| 79 | y += labelHeight; |