mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Updates for Android
This commit is contained in:
@@ -5,7 +5,6 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.assets.FSkinImage;
|
||||
@@ -44,6 +43,7 @@ import forge.match.AbstractGuiGame;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.model.FModel;
|
||||
import forge.player.PlayerZoneUpdate;
|
||||
import forge.player.PlayerZoneUpdates;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.views.VAssignDamage;
|
||||
@@ -307,40 +307,47 @@ public class MatchController extends AbstractGuiGame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZones(final Collection<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
public PlayerZoneUpdates openZones(PlayerView controller, final Collection<ZoneType> zones, final Map<PlayerView, Object> playersWithTargetables) {
|
||||
PlayerZoneUpdates updates = new PlayerZoneUpdates();
|
||||
if (zones.size() == 1) {
|
||||
final ZoneType zoneType = zones.iterator().next();
|
||||
switch (zoneType) {
|
||||
case Battlefield:
|
||||
case Command:
|
||||
players.clear(); //clear since no zones need to be restored
|
||||
return true; //Battlefield is always open
|
||||
playersWithTargetables.clear(); //clear since no zones need to be restored
|
||||
default:
|
||||
//open zone tab for given zone if needed
|
||||
boolean result = true;
|
||||
for (final PlayerView player : players.keySet()) {
|
||||
for (final PlayerView player : playersWithTargetables.keySet()) {
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||
players.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||
playersWithTargetables.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||
final InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||
if (zoneTab == null) {
|
||||
result = false;
|
||||
} else {
|
||||
if (zoneTab != null) {
|
||||
updates.add(new PlayerZoneUpdate(player, zoneType));
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return updates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreOldZones(final Map<PlayerView, Object> playersToRestoreZonesFor) {
|
||||
for (final Entry<PlayerView, Object> player : playersToRestoreZonesFor.entrySet()) {
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player.getKey());
|
||||
if (player.getValue() == null || player.getValue() instanceof InfoTab) {
|
||||
playerPanel.setSelectedTab((InfoTab) player.getValue());
|
||||
public void restoreOldZones(PlayerView playerView, PlayerZoneUpdates playerZoneUpdates) {
|
||||
for(PlayerZoneUpdate update : playerZoneUpdates) {
|
||||
PlayerView player = update.getPlayer();
|
||||
|
||||
ZoneType zone = null;
|
||||
for(ZoneType type : update.getZones()) {
|
||||
zone = type;
|
||||
break;
|
||||
}
|
||||
|
||||
if (zone == null) { return; }
|
||||
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||
final InfoTab zoneTab = playerPanel.getZoneTab(zone);
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +388,7 @@ public class MatchController extends AbstractGuiGame {
|
||||
|
||||
@Override
|
||||
public void hideZones(final PlayerView controller, final Iterable<PlayerZoneUpdate> zonesToUpdate) {
|
||||
view.hideZones(controller, zonesToUpdate);
|
||||
view.hideZones(controller, zonesToUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.menu.FDropDown;
|
||||
import forge.menu.FMenuItem;
|
||||
import forge.menu.FMenuTab;
|
||||
import forge.menu.FPopupMenu;
|
||||
import forge.player.PlayerZoneUpdates;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.screens.match.TargetingOverlay;
|
||||
import forge.toolbox.FCardPanel;
|
||||
@@ -55,6 +56,7 @@ public class VStack extends FDropDown {
|
||||
private StackInstanceDisplay activeItem;
|
||||
private StackItemView activeStackInstance;
|
||||
private Map<PlayerView, Object> playersWithValidTargets;
|
||||
private PlayerZoneUpdates restorablePlayerZones = null;
|
||||
|
||||
private int stackSize;
|
||||
|
||||
@@ -70,6 +72,8 @@ public class VStack extends FDropDown {
|
||||
private void revealTargetZones() {
|
||||
if (activeStackInstance == null) { return; }
|
||||
|
||||
PlayerView player = MatchController.instance.getCurrentPlayer();
|
||||
|
||||
final Set<ZoneType> zones = new HashSet<>();
|
||||
playersWithValidTargets = new HashMap<>();
|
||||
for (final CardView c : activeStackInstance.getTargetCards()) {
|
||||
@@ -79,14 +83,15 @@ public class VStack extends FDropDown {
|
||||
}
|
||||
}
|
||||
if (zones.isEmpty() || playersWithValidTargets.isEmpty()) { return; }
|
||||
MatchController.instance.openZones(zones, playersWithValidTargets);
|
||||
restorablePlayerZones = MatchController.instance.openZones(player, zones, playersWithValidTargets);
|
||||
}
|
||||
|
||||
//restore old zones when active stack instance changes
|
||||
private void restoreOldZones() {
|
||||
if (playersWithValidTargets == null) { return; }
|
||||
MatchController.instance.restoreOldZones(playersWithValidTargets);
|
||||
playersWithValidTargets = null;
|
||||
if (restorablePlayerZones == null) { return; }
|
||||
PlayerView player = MatchController.instance.getCurrentPlayer();
|
||||
MatchController.instance.restoreOldZones(player, restorablePlayerZones);
|
||||
restorablePlayerZones = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user