mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Improve Android zone restoration
This commit is contained in:
@@ -322,8 +322,9 @@ public class MatchController extends AbstractGuiGame {
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||
playersWithTargetables.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||
final InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||
ZoneType previousZone = playerPanel.getZoneByInfoTab(playerPanel.getSelectedTab());
|
||||
updates.add(new PlayerZoneUpdate(player, previousZone));
|
||||
if (zoneTab != null) {
|
||||
updates.add(new PlayerZoneUpdate(player, zoneType));
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
}
|
||||
}
|
||||
@@ -343,9 +344,12 @@ public class MatchController extends AbstractGuiGame {
|
||||
break;
|
||||
}
|
||||
|
||||
if (zone == null) { return; }
|
||||
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||
if (zone == null) {
|
||||
playerPanel.hideSelectedTab();
|
||||
continue;
|
||||
}
|
||||
|
||||
final InfoTab zoneTab = playerPanel.getZoneTab(zone);
|
||||
playerPanel.setSelectedTab(zoneTab);
|
||||
}
|
||||
|
||||
@@ -102,18 +102,32 @@ public class VPlayerPanel extends FContainer {
|
||||
return zoneTabs.get(zoneType);
|
||||
}
|
||||
|
||||
public ZoneType getZoneByInfoTab(InfoTab tab) {
|
||||
for(ZoneType zone : zoneTabs.keySet()) {
|
||||
if (zoneTabs.get(zone).equals(tab)) {
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSelectedZone(ZoneType zoneType) {
|
||||
setSelectedTab(zoneTabs.get(zoneType));
|
||||
}
|
||||
|
||||
public void hideSelectedTab() {
|
||||
if (selectedTab != null) {
|
||||
selectedTab.displayArea.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedTab(InfoTab selectedTab0) {
|
||||
if (selectedTab == selectedTab0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedTab != null) {
|
||||
selectedTab.displayArea.setVisible(false);
|
||||
}
|
||||
hideSelectedTab();
|
||||
|
||||
selectedTab = selectedTab0;
|
||||
|
||||
|
||||
@@ -14,11 +14,15 @@ public class PlayerZoneUpdate implements Serializable {
|
||||
private final Set<ZoneType> zones;
|
||||
|
||||
public PlayerZoneUpdate(final PlayerView player, final ZoneType zone) {
|
||||
if (player == null || zone == null) {
|
||||
if (player == null ) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.player = player;
|
||||
this.zones = EnumSet.of(zone);
|
||||
if (zone != null) {
|
||||
this.zones = EnumSet.of(zone);
|
||||
} else {
|
||||
this.zones = EnumSet.noneOf(ZoneType.class);
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerView getPlayer() {
|
||||
@@ -30,13 +34,13 @@ public class PlayerZoneUpdate implements Serializable {
|
||||
|
||||
void addZone(final ZoneType zone) {
|
||||
if (zone == null) {
|
||||
throw new NullPointerException();
|
||||
return;
|
||||
}
|
||||
zones.add(zone);
|
||||
}
|
||||
void add(final PlayerZoneUpdate other) {
|
||||
if (other == null) {
|
||||
throw new NullPointerException();
|
||||
return;
|
||||
}
|
||||
zones.addAll(other.getZones());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user