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
|
@Override
|
||||||
public Object showManaPool(final PlayerView player) {
|
public void showManaPool(final PlayerView player) {
|
||||||
return null; //not needed since mana pool icons are always visible
|
//not needed since mana pool icons are always visible
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
//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.base.Function;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
@@ -69,6 +70,8 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
private static HostedMatch hostedMatch;
|
private static HostedMatch hostedMatch;
|
||||||
private static MatchScreen view;
|
private static MatchScreen view;
|
||||||
|
|
||||||
|
private final Map<PlayerView, InfoTab> zonesToRestore = Maps.newHashMap();
|
||||||
|
|
||||||
public static MatchScreen getView() {
|
public static MatchScreen getView() {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -233,23 +236,27 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object showManaPool(final PlayerView player) {
|
public void showManaPool(final PlayerView player) {
|
||||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||||
final InfoTab oldSelectedTab = playerPanel.getSelectedTab();
|
final InfoTab selectedTab = playerPanel.getSelectedTab(), manaPoolTab = playerPanel.getManaPoolTab();
|
||||||
playerPanel.setSelectedTab(playerPanel.getManaPoolTab());
|
if (!manaPoolTab.equals(selectedTab)) {
|
||||||
return oldSelectedTab;
|
//if mana pool was selected previously, we don't need to switch back to anything
|
||||||
|
zonesToRestore.put(player, selectedTab);
|
||||||
|
}
|
||||||
|
playerPanel.setSelectedTab(manaPoolTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
public void hideManaPool(final PlayerView player) {
|
||||||
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
final VPlayerPanel playerPanel = view.getPlayerPanel(player);
|
||||||
if (zoneToRestore == playerPanel.getManaPoolTab()) {
|
// value may be null so explicit containsKey call is necessary
|
||||||
return; //if mana pool was selected previously, we don't need to switch back to anything
|
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(zoneToRestore);
|
||||||
}
|
|
||||||
playerPanel.setSelectedTab((InfoTab)zoneToRestore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public interface IGuiGame {
|
|||||||
void enableOverlay();
|
void enableOverlay();
|
||||||
void disableOverlay();
|
void disableOverlay();
|
||||||
void finishGame();
|
void finishGame();
|
||||||
Object showManaPool(PlayerView player);
|
void showManaPool(PlayerView player);
|
||||||
void hideManaPool(PlayerView player, Object zoneToRestore);
|
void hideManaPool(PlayerView player);
|
||||||
void updateStack();
|
void updateStack();
|
||||||
void updateZones(Iterable<PlayerZoneUpdate> zonesToUpdate);
|
void updateZones(Iterable<PlayerZoneUpdate> zonesToUpdate);
|
||||||
void updateSingleCard(CardView card);
|
void updateSingleCard(CardView card);
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
protected ManaCostBeingPaid manaCost;
|
protected ManaCostBeingPaid manaCost;
|
||||||
protected final SpellAbility saPaidFor;
|
protected final SpellAbility saPaidFor;
|
||||||
private final boolean wasFloatingMana;
|
private final boolean wasFloatingMana;
|
||||||
private final Object zoneToRestore;
|
|
||||||
private final Queue<Card> delaySelectCards = new LinkedList<Card>();
|
private final Queue<Card> delaySelectCards = new LinkedList<Card>();
|
||||||
|
|
||||||
private boolean bPaid = false;
|
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
|
//if player is floating mana, show mana pool to make it easier to use that mana
|
||||||
wasFloatingMana = !player.getManaPool().isEmpty();
|
wasFloatingMana = !player.getManaPool().isEmpty();
|
||||||
zoneToRestore = wasFloatingMana ? getController().getGui().showManaPool(PlayerView.get(player)) : null;
|
if (wasFloatingMana) {
|
||||||
|
getController().getGui().showManaPool(PlayerView.get(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
if (wasFloatingMana) { //hide mana pool if it was shown due to floating mana
|
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),
|
enableOverlay (Mode.SERVER),
|
||||||
disableOverlay (Mode.SERVER),
|
disableOverlay (Mode.SERVER),
|
||||||
finishGame (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),
|
hideManaPool (Mode.SERVER, Void.TYPE, PlayerView.class),
|
||||||
updateStack (Mode.SERVER),
|
updateStack (Mode.SERVER),
|
||||||
updateZones (Mode.SERVER, Void.TYPE, Iterable/*PlayerZoneUpdate*/.class),
|
updateZones (Mode.SERVER, Void.TYPE, Iterable/*PlayerZoneUpdate*/.class),
|
||||||
|
|||||||
@@ -117,14 +117,13 @@ public class NetGuiGame extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object showManaPool(final PlayerView player) {
|
public void showManaPool(final PlayerView player) {
|
||||||
send(ProtocolMethod.showManaPool, player);
|
send(ProtocolMethod.showManaPool, player);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
public void hideManaPool(final PlayerView player) {
|
||||||
send(ProtocolMethod.hideManaPool, player, zoneToRestore);
|
send(ProtocolMethod.hideManaPool, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user