- Temporarily putting in the code that would use the original prompting method if running on LibGdx (mobile Forge) since mobile Forge has no way of showing the card to the player without going through the getGui().confirm method, which creates a custom card view and prompt there.

- Probably should be organized better (it's not very clean to branch out for a particular port in top-tier GUI code), but I'm not sure how to make this better. Please feel free to improve.
This commit is contained in:
Agetian
2017-01-24 15:05:01 +00:00
parent a4a3ad99eb
commit 65f129617c
3 changed files with 74 additions and 44 deletions

View File

@@ -110,7 +110,7 @@ public class InputConfirmMulligan extends InputSyncronizedBase {
} }
final CardView cView = c0.getView(); final CardView cView = c0.getView();
//pfps leave this as is for now - it is confirming during another confirm so it might need the popup //pfps leave this as is for now - it is confirming during another confirm so it might need the popup
if (isSerumPowder && getController().getGui().confirm(cView, "Use " + cView + "'s ability?")) { if (isSerumPowder && getController().getGui().confirm(cView, "Use " + cView + "'s ability?")) {
cardSelectLocked = true; cardSelectLocked = true;
ThreadUtil.invokeInGameThread(new Runnable() { ThreadUtil.invokeInGameThread(new Runnable() {

View File

@@ -11,6 +11,7 @@ import java.util.Map.Entry;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.GuiBase;
import forge.card.CardType; import forge.card.CardType;
import forge.game.Game; import forge.game.Game;
@@ -947,15 +948,18 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (cost.payCostFromSource()) { if (cost.payCostFromSource()) {
final int maxCounters = source.getCounters(cost.counter); final int maxCounters = source.getCounters(cost.counter);
if (amount.equals("All")) { if (amount.equals("All")) {
// final CardView view = CardView.get(ability.getHostCard()); if (GuiBase.getInterface().isLibgdxPort()) {
// if (!controller.getGui().confirm(view, "Remove all counters?")) { final CardView view = CardView.get(ability.getHostCard());
// return null; if (!controller.getGui().confirm(view, "Remove all counters?")) {
// } return null;
final InputConfirm inp = new InputConfirm(controller, "Remove all counters?", ability); }
inp.showAndWait(); } else {
if (!inp.getResult()) { final InputConfirm inp = new InputConfirm(controller, "Remove all counters?", ability);
return null; inp.showAndWait();
} if (!inp.getResult()) {
return null;
}
}
cntRemoved = maxCounters; cntRemoved = maxCounters;
} }
else if (c == null && "XChoice".equals(sVarAmount)) { else if (c == null && "XChoice".equals(sVarAmount)) {

View File

@@ -316,15 +316,18 @@ public class PlayerControllerHuman
} }
private final boolean assignDamageAsIfNotBlocked(final Card attacker) { private final boolean assignDamageAsIfNotBlocked(final Card attacker) {
if ( attacker.hasKeyword("CARDNAME assigns its combat damage as though it weren't blocked.") || if (attacker.hasKeyword("CARDNAME assigns its combat damage as though it weren't blocked.")
attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.") ) { || attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")) {
// return getGui().confirm(CardView.get(attacker), "Do you want to assign its combat damage as though it weren't blocked?"); if (GuiBase.getInterface().isLibgdxPort()) {
final InputConfirm inp = new InputConfirm(this, "Do you want to assign its combat damage as though it weren't blocked?", CardView.get(attacker)); return getGui().confirm(CardView.get(attacker), "Do you want to assign its combat damage as though it weren't blocked?");
inp.showAndWait(); } else {
return inp.getResult(); final InputConfirm inp = new InputConfirm(this, "Do you want to assign its combat damage as though it weren't blocked?", CardView.get(attacker));
} else { inp.showAndWait();
return false; return inp.getResult();
} }
} else {
return false;
}
} }
@Override @Override
@@ -494,27 +497,36 @@ public class PlayerControllerHuman
*/ */
@Override @Override
public boolean confirmAction(final SpellAbility sa, final PlayerActionConfirmMode mode, final String message) { public boolean confirmAction(final SpellAbility sa, final PlayerActionConfirmMode mode, final String message) {
// return getGui().confirm(CardView.get(sa.getHostCard()), message); if (GuiBase.getInterface().isLibgdxPort()) {
final InputConfirm inp = new InputConfirm(this, message, sa); return getGui().confirm(CardView.get(sa.getHostCard()), message);
inp.showAndWait(); } else {
return inp.getResult(); final InputConfirm inp = new InputConfirm(this, message, sa);
inp.showAndWait();
return inp.getResult();
}
} }
@Override @Override
public boolean confirmBidAction(final SpellAbility sa, final PlayerActionConfirmMode bidlife, public boolean confirmBidAction(final SpellAbility sa, final PlayerActionConfirmMode bidlife,
final String string, final int bid, final Player winner) { final String string, final int bid, final Player winner) {
// return getGui().confirm(CardView.get(sa.getHostCard()), string + " Highest Bidder " + winner); if (GuiBase.getInterface().isLibgdxPort()) {
final InputConfirm inp = new InputConfirm(this, string + " Highest Bidder " + winner, sa); return getGui().confirm(CardView.get(sa.getHostCard()), string + " Highest Bidder " + winner);
inp.showAndWait(); } else {
return inp.getResult(); final InputConfirm inp = new InputConfirm(this, string + " Highest Bidder " + winner, sa);
inp.showAndWait();
return inp.getResult();
}
} }
@Override @Override
public boolean confirmStaticApplication(final Card hostCard, final GameEntity affected, final String logic, final String message) { public boolean confirmStaticApplication(final Card hostCard, final GameEntity affected, final String logic, final String message) {
// return getGui().confirm(CardView.get(hostCard), message); if (GuiBase.getInterface().isLibgdxPort()) {
final InputConfirm inp = new InputConfirm(this, message, hostCard.getView()); return getGui().confirm(CardView.get(hostCard), message);
inp.showAndWait(); } else {
return inp.getResult(); final InputConfirm inp = new InputConfirm(this, message, hostCard.getView());
inp.showAndWait();
return inp.getResult();
}
} }
@Override @Override
@@ -659,11 +671,16 @@ public class PlayerControllerHuman
tempShowCard(c); tempShowCard(c);
getGui().setCard(c.getView()); getGui().setCard(c.getView());
// final boolean result = getGui().confirm(view, String.format("Put %s on the top or bottom of your library?", view), ImmutableList.of("Top", "Bottom"));
final InputConfirm inp = new InputConfirm(this, String.format("Put %s on the top or bottom of your library?", view), "Top", "Bottom", true, c.getView()); boolean result = false;
inp.showAndWait(); if (GuiBase.getInterface().isLibgdxPort()) {
final boolean result = inp.getResult(); result = getGui().confirm(view, String.format("Put %s on the top or bottom of your library?", view), ImmutableList.of("Top", "Bottom"));
endTempShowCards(); } else {
final InputConfirm inp = new InputConfirm(this, String.format("Put %s on the top or bottom of your library?", view), "Top", "Bottom", true, c.getView());
inp.showAndWait();
result = inp.getResult();
endTempShowCards();
}
return result; return result;
} }
@@ -1031,10 +1048,13 @@ public class PlayerControllerHuman
case LeftOrRight: labels = ImmutableList.of("Left", "Right"); break; case LeftOrRight: labels = ImmutableList.of("Left", "Right"); break;
default: labels = ImmutableList.copyOf(kindOfChoice.toString().split("Or")); default: labels = ImmutableList.copyOf(kindOfChoice.toString().split("Or"));
} }
// return getGui().confirm(CardView.get(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels); if (GuiBase.getInterface().isLibgdxPort()) {
final InputConfirm inp = new InputConfirm(this, question, labels.get(0), labels.get(1), defaultVal == null || defaultVal.booleanValue(), sa); return getGui().confirm(CardView.get(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels);
inp.showAndWait(); } else {
return inp.getResult(); final InputConfirm inp = new InputConfirm(this, question, labels.get(0), labels.get(1), defaultVal == null || defaultVal.booleanValue(), sa);
inp.showAndWait();
return inp.getResult();
}
} }
@Override @Override
@@ -1165,10 +1185,16 @@ public class PlayerControllerHuman
if (colorNames.size() > 2) { if (colorNames.size() > 2) {
return MagicColor.fromName(getGui().one(message, colorNames)); return MagicColor.fromName(getGui().one(message, colorNames));
} }
//final boolean confirmed = getGui().confirm(CardView.get(c), message, colorNames) ;
final InputConfirm inp = new InputConfirm(this, message, colorNames.get(0), colorNames.get(1), CardView.get(c)); boolean confirmed = false;
inp.showAndWait(); if (GuiBase.getInterface().isLibgdxPort()) {
final boolean confirmed = inp.getResult(); confirmed = getGui().confirm(CardView.get(c), message, colorNames) ;
} else {
final InputConfirm inp = new InputConfirm(this, message, colorNames.get(0), colorNames.get(1), CardView.get(c));
inp.showAndWait();
confirmed = inp.getResult();
}
final int idxChosen = confirmed ? 0 : 1; final int idxChosen = confirmed ? 0 : 1;
return MagicColor.fromName(colorNames.get(idxChosen)); return MagicColor.fromName(colorNames.get(idxChosen));
} }