mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Have mobile game handle opening/closing mana pools itself
to improve compatibility with network play
This commit is contained in:
@@ -769,12 +769,12 @@ public final class CMatchUI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object showManaPool(final PlayerView player) {
|
||||
return null; //not needed since mana pool icons are always visible
|
||||
public void showManaPool(final PlayerView player) {
|
||||
//not needed since mana pool icons are always visible
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
||||
public void hideManaPool(final PlayerView player) {
|
||||
//not needed since mana pool icons are always visible
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
@@ -69,6 +70,8 @@ public class MatchController extends AbstractGuiGame {
|
||||
private static HostedMatch hostedMatch;
|
||||
private static MatchScreen view;
|
||||
|
||||
private final Map<PlayerView, InfoTab> zonesToRestore = Maps.newHashMap();
|
||||
|
||||
public static MatchScreen getView() {
|
||||
return view;
|
||||
}
|
||||
@@ -233,23 +236,27 @@ public class MatchController extends AbstractGuiGame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object showManaPool(final PlayerView player) {
|
||||
public void showManaPool(final PlayerView player) {
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||
final InfoTab oldSelectedTab = playerPanel.getSelectedTab();
|
||||
playerPanel.setSelectedTab(playerPanel.getManaPoolTab());
|
||||
return oldSelectedTab;
|
||||
final InfoTab selectedTab = playerPanel.getSelectedTab(), manaPoolTab = playerPanel.getManaPoolTab();
|
||||
if (!manaPoolTab.equals(selectedTab)) {
|
||||
//if mana pool was selected previously, we don't need to switch back to anything
|
||||
zonesToRestore.put(player, selectedTab);
|
||||
}
|
||||
playerPanel.setSelectedTab(manaPoolTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
||||
public void hideManaPool(final PlayerView player) {
|
||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||
if (zoneToRestore == playerPanel.getManaPoolTab()) {
|
||||
return; //if mana pool was selected previously, we don't need to switch back to anything
|
||||
// value may be null so explicit containsKey call is necessary
|
||||
final boolean doRestore = zonesToRestore.containsKey(player);
|
||||
final InfoTab zoneToRestore = zonesToRestore.remove(player);
|
||||
if (!playerPanel.getManaPoolTab().equals(playerPanel.getSelectedTab()) || !doRestore) {
|
||||
return; //if player switched away from mana pool already, don't change anything
|
||||
}
|
||||
if (playerPanel.getSelectedTab() != playerPanel.getManaPoolTab()) {
|
||||
return; //if player switch away from mana pool already, don't change anything
|
||||
}
|
||||
playerPanel.setSelectedTab((InfoTab)zoneToRestore);
|
||||
|
||||
playerPanel.setSelectedTab(zoneToRestore);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,8 +41,8 @@ public interface IGuiGame {
|
||||
void enableOverlay();
|
||||
void disableOverlay();
|
||||
void finishGame();
|
||||
Object showManaPool(PlayerView player);
|
||||
void hideManaPool(PlayerView player, Object zoneToRestore);
|
||||
void showManaPool(PlayerView player);
|
||||
void hideManaPool(PlayerView player);
|
||||
void updateStack();
|
||||
void updateZones(Iterable<PlayerZoneUpdate> zonesToUpdate);
|
||||
void updateSingleCard(CardView card);
|
||||
|
||||
@@ -39,7 +39,6 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
protected ManaCostBeingPaid manaCost;
|
||||
protected final SpellAbility saPaidFor;
|
||||
private final boolean wasFloatingMana;
|
||||
private final Object zoneToRestore;
|
||||
private final Queue<Card> delaySelectCards = new LinkedList<Card>();
|
||||
|
||||
private boolean bPaid = false;
|
||||
@@ -55,13 +54,15 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
|
||||
//if player is floating mana, show mana pool to make it easier to use that mana
|
||||
wasFloatingMana = !player.getManaPool().isEmpty();
|
||||
zoneToRestore = wasFloatingMana ? getController().getGui().showManaPool(PlayerView.get(player)) : null;
|
||||
if (wasFloatingMana) {
|
||||
getController().getGui().showManaPool(PlayerView.get(player));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
if (wasFloatingMana) { //hide mana pool if it was shown due to floating mana
|
||||
getController().getGui().hideManaPool(PlayerView.get(player), zoneToRestore);
|
||||
getController().getGui().hideManaPool(PlayerView.get(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public enum ProtocolMethod {
|
||||
enableOverlay (Mode.SERVER),
|
||||
disableOverlay (Mode.SERVER),
|
||||
finishGame (Mode.SERVER),
|
||||
showManaPool (Mode.SERVER, Object.class, PlayerView.class),
|
||||
showManaPool (Mode.SERVER, Void.TYPE, PlayerView.class),
|
||||
hideManaPool (Mode.SERVER, Void.TYPE, PlayerView.class),
|
||||
updateStack (Mode.SERVER),
|
||||
updateZones (Mode.SERVER, Void.TYPE, Iterable/*PlayerZoneUpdate*/.class),
|
||||
|
||||
@@ -117,14 +117,13 @@ public class NetGuiGame extends AbstractGuiGame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object showManaPool(final PlayerView player) {
|
||||
public void showManaPool(final PlayerView player) {
|
||||
send(ProtocolMethod.showManaPool, player);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
||||
send(ProtocolMethod.hideManaPool, player, zoneToRestore);
|
||||
public void hideManaPool(final PlayerView player) {
|
||||
send(ProtocolMethod.hideManaPool, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user