Support updating floating card panels as the zones update

This commit is contained in:
drdev
2014-10-15 04:16:29 +00:00
parent 1fd2aadbde
commit 487e239857
2 changed files with 35 additions and 10 deletions

View File

@@ -91,6 +91,7 @@ import forge.toolbox.special.PhaseIndicator;
import forge.toolbox.special.PhaseLabel;
import forge.util.ITriggerEvent;
import forge.view.arcane.CardPanel;
import forge.view.arcane.FloatingCardArea;
/**
* Constructs instance of match UI controller, used as a single point of
@@ -278,23 +279,31 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
PlayerView owner = kv.getKey();
ZoneType zt = kv.getValue();
if (zt == ZoneType.Command) {
getCommandFor(owner).getTabletop().setupPlayZone();
} else if (zt == ZoneType.Hand) {
switch (zt) {
case Battlefield:
getFieldViewFor(owner).getTabletop().setupPlayZone();
break;
case Hand:
VHand vHand = getHandFor(owner);
if (null != vHand) {
if (vHand != null) {
vHand.getLayoutControl().updateHand();
}
getFieldViewFor(owner).getDetailsPanel().updateZones();
} else if (zt == ZoneType.Battlefield) {
getFieldViewFor(owner).getTabletop().setupPlayZone();
} else if (zt == ZoneType.Ante) {
FloatingCardArea.refresh(owner, zt);
break;
case Command:
getCommandFor(owner).getTabletop().setupPlayZone();
break;
case Ante:
CAntes.SINGLETON_INSTANCE.update();
} else {
break;
default:
final VField vf = getFieldViewFor(owner);
if (vf != null) {
vf.getDetailsPanel().updateZones();
}
FloatingCardArea.refresh(owner, zt);
break;
}
}
}

View File

@@ -57,6 +57,12 @@ public class FloatingCardArea extends CardArea {
}
cardArea.showWindow();
}
public static void refresh(PlayerView player, ZoneType zone) {
FloatingCardArea cardArea = floatingAreas.get(getKey(player, zone));
if (cardArea != null) {
cardArea.refresh();
}
}
private final PlayerView player;
private final ZoneType zone;
@@ -69,6 +75,16 @@ public class FloatingCardArea extends CardArea {
if (hasBeenShown) { return; } //don't change location this way if dialog has already been shown
super.setLocationRelativeTo(c);
}
@Override
public void setVisible(boolean b0) {
if (isVisible() == b0) { return; }
super.setVisible(b0);
if (b0) {
refresh();
hasBeenShown = true;
}
}
};
private boolean hasBeenShown;
@@ -97,7 +113,6 @@ public class FloatingCardArea extends CardArea {
player = player0;
zone = zone0;
setVertical(true);
refresh();
}
private void showWindow() {
@@ -113,10 +128,11 @@ public class FloatingCardArea extends CardArea {
});
}
window.setVisible(true);
hasBeenShown = true;
}
public void refresh() {
if (!window.isVisible()) { return; } //don't refresh while window hidden
List<CardPanel> cardPanels = new ArrayList<CardPanel>();
FCollectionView<CardView> cards = player.getCards(zone);
if (cards != null) {