mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Support updating floating card panels as the zones update
This commit is contained in:
@@ -91,6 +91,7 @@ import forge.toolbox.special.PhaseIndicator;
|
|||||||
import forge.toolbox.special.PhaseLabel;
|
import forge.toolbox.special.PhaseLabel;
|
||||||
import forge.util.ITriggerEvent;
|
import forge.util.ITriggerEvent;
|
||||||
import forge.view.arcane.CardPanel;
|
import forge.view.arcane.CardPanel;
|
||||||
|
import forge.view.arcane.FloatingCardArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs instance of match UI controller, used as a single point of
|
* 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();
|
PlayerView owner = kv.getKey();
|
||||||
ZoneType zt = kv.getValue();
|
ZoneType zt = kv.getValue();
|
||||||
|
|
||||||
if (zt == ZoneType.Command) {
|
switch (zt) {
|
||||||
getCommandFor(owner).getTabletop().setupPlayZone();
|
case Battlefield:
|
||||||
} else if (zt == ZoneType.Hand) {
|
getFieldViewFor(owner).getTabletop().setupPlayZone();
|
||||||
|
break;
|
||||||
|
case Hand:
|
||||||
VHand vHand = getHandFor(owner);
|
VHand vHand = getHandFor(owner);
|
||||||
if (null != vHand) {
|
if (vHand != null) {
|
||||||
vHand.getLayoutControl().updateHand();
|
vHand.getLayoutControl().updateHand();
|
||||||
}
|
}
|
||||||
getFieldViewFor(owner).getDetailsPanel().updateZones();
|
getFieldViewFor(owner).getDetailsPanel().updateZones();
|
||||||
} else if (zt == ZoneType.Battlefield) {
|
FloatingCardArea.refresh(owner, zt);
|
||||||
getFieldViewFor(owner).getTabletop().setupPlayZone();
|
break;
|
||||||
} else if (zt == ZoneType.Ante) {
|
case Command:
|
||||||
|
getCommandFor(owner).getTabletop().setupPlayZone();
|
||||||
|
break;
|
||||||
|
case Ante:
|
||||||
CAntes.SINGLETON_INSTANCE.update();
|
CAntes.SINGLETON_INSTANCE.update();
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
final VField vf = getFieldViewFor(owner);
|
final VField vf = getFieldViewFor(owner);
|
||||||
if (vf != null) {
|
if (vf != null) {
|
||||||
vf.getDetailsPanel().updateZones();
|
vf.getDetailsPanel().updateZones();
|
||||||
}
|
}
|
||||||
|
FloatingCardArea.refresh(owner, zt);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ public class FloatingCardArea extends CardArea {
|
|||||||
}
|
}
|
||||||
cardArea.showWindow();
|
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 PlayerView player;
|
||||||
private final ZoneType zone;
|
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
|
if (hasBeenShown) { return; } //don't change location this way if dialog has already been shown
|
||||||
super.setLocationRelativeTo(c);
|
super.setLocationRelativeTo(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVisible(boolean b0) {
|
||||||
|
if (isVisible() == b0) { return; }
|
||||||
|
super.setVisible(b0);
|
||||||
|
if (b0) {
|
||||||
|
refresh();
|
||||||
|
hasBeenShown = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
private boolean hasBeenShown;
|
private boolean hasBeenShown;
|
||||||
|
|
||||||
@@ -97,7 +113,6 @@ public class FloatingCardArea extends CardArea {
|
|||||||
player = player0;
|
player = player0;
|
||||||
zone = zone0;
|
zone = zone0;
|
||||||
setVertical(true);
|
setVertical(true);
|
||||||
refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showWindow() {
|
private void showWindow() {
|
||||||
@@ -113,10 +128,11 @@ public class FloatingCardArea extends CardArea {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
hasBeenShown = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
|
if (!window.isVisible()) { return; } //don't refresh while window hidden
|
||||||
|
|
||||||
List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||||
FCollectionView<CardView> cards = player.getCards(zone);
|
FCollectionView<CardView> cards = player.getCards(zone);
|
||||||
if (cards != null) {
|
if (cards != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user