- 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

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

View File

@@ -316,12 +316,15 @@ public class PlayerControllerHuman
}
private final boolean assignDamageAsIfNotBlocked(final Card attacker) {
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.") ) {
// return getGui().confirm(CardView.get(attacker), "Do you want to assign 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.")) {
if (GuiBase.getInterface().isLibgdxPort()) {
return getGui().confirm(CardView.get(attacker), "Do you want to assign its combat damage as though it weren't blocked?");
} else {
final InputConfirm inp = new InputConfirm(this, "Do you want to assign its combat damage as though it weren't blocked?", CardView.get(attacker));
inp.showAndWait();
return inp.getResult();
}
} else {
return false;
}
@@ -494,28 +497,37 @@ public class PlayerControllerHuman
*/
@Override
public boolean confirmAction(final SpellAbility sa, final PlayerActionConfirmMode mode, final String message) {
// return getGui().confirm(CardView.get(sa.getHostCard()), message);
if (GuiBase.getInterface().isLibgdxPort()) {
return getGui().confirm(CardView.get(sa.getHostCard()), message);
} else {
final InputConfirm inp = new InputConfirm(this, message, sa);
inp.showAndWait();
return inp.getResult();
}
}
@Override
public boolean confirmBidAction(final SpellAbility sa, final PlayerActionConfirmMode bidlife,
final String string, final int bid, final Player winner) {
// return getGui().confirm(CardView.get(sa.getHostCard()), string + " Highest Bidder " + winner);
if (GuiBase.getInterface().isLibgdxPort()) {
return getGui().confirm(CardView.get(sa.getHostCard()), string + " Highest Bidder " + winner);
} else {
final InputConfirm inp = new InputConfirm(this, string + " Highest Bidder " + winner, sa);
inp.showAndWait();
return inp.getResult();
}
}
@Override
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()) {
return getGui().confirm(CardView.get(hostCard), message);
} else {
final InputConfirm inp = new InputConfirm(this, message, hostCard.getView());
inp.showAndWait();
return inp.getResult();
}
}
@Override
public boolean confirmTrigger(final WrappedAbility wrapper, final Map<String, String> triggerParams, final boolean isMandatory) {
@@ -659,11 +671,16 @@ public class PlayerControllerHuman
tempShowCard(c);
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"));
boolean result = false;
if (GuiBase.getInterface().isLibgdxPort()) {
result = getGui().confirm(view, String.format("Put %s on the top or bottom of your library?", view), ImmutableList.of("Top", "Bottom"));
} 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();
final boolean result = inp.getResult();
result = inp.getResult();
endTempShowCards();
}
return result;
}
@@ -1031,11 +1048,14 @@ public class PlayerControllerHuman
case LeftOrRight: labels = ImmutableList.of("Left", "Right"); break;
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()) {
return getGui().confirm(CardView.get(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels);
} else {
final InputConfirm inp = new InputConfirm(this, question, labels.get(0), labels.get(1), defaultVal == null || defaultVal.booleanValue(), sa);
inp.showAndWait();
return inp.getResult();
}
}
@Override
public boolean chooseFlipResult(final SpellAbility sa, final Player flipper, final boolean[] results, final boolean call) {
@@ -1165,10 +1185,16 @@ public class PlayerControllerHuman
if (colorNames.size() > 2) {
return MagicColor.fromName(getGui().one(message, colorNames));
}
//final boolean confirmed = getGui().confirm(CardView.get(c), message, colorNames) ;
boolean confirmed = false;
if (GuiBase.getInterface().isLibgdxPort()) {
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();
final boolean confirmed = inp.getResult();
confirmed = inp.getResult();
}
final int idxChosen = confirmed ? 0 : 1;
return MagicColor.fromName(colorNames.get(idxChosen));
}