InputPayManaBase will execute input queue unlock from the same thread that was used to activate mana ability. No showMessage() will be called.

This commit is contained in:
Maxmtg
2013-05-27 17:50:40 +00:00
parent 99de2d6543
commit 8ccfad27cc
6 changed files with 32 additions and 12 deletions

View File

@@ -185,7 +185,10 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
public void run() {
HumanPlay.playSpellAbility(chosen.getActivatingPlayer(), chosen);
onManaAbilityPlayed(chosen);
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { showMessage(); } });
if( isAlredyPaid() ) {
done();
stopNonEdt();
}
}
};
game.getInputQueue().invokeGameAction(proc);
@@ -238,11 +241,11 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
player.getZone(ZoneType.Battlefield).updateObservers();
}
protected final void checkIfAlredyPaid() {
protected boolean isAlredyPaid() {
if (manaCost.isPaid()) {
bPaid = true;
done();
}
return bPaid;
}
protected void onManaAbilityPaid() {} // some inputs overload it

View File

@@ -85,6 +85,7 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
if (this.manaCost.isPaid()) {
this.done();
this.stop();
} else {
this.showMessage();
}
@@ -98,7 +99,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
}
player.getManaPool().clearManaPaid(this.saPaidFor, false);
bPaid = true;
this.stop();
}
/** {@inheritDoc} */
@@ -126,7 +126,10 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
}
showMessage(msg.toString());
checkIfAlredyPaid();
if( isAlredyPaid() ) {
done();
stop();
} else
showMessage(msg.toString());
}
}

View File

@@ -40,7 +40,6 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
// any mana tapabilities can't be used in payment as well as being tapped for convoke)
handleConvokedCards(false);
stop();
}
@Override
@@ -67,7 +66,10 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
}
showMessage(msg.toString());
checkIfAlredyPaid();
if( isAlredyPaid() ) {
done();
stop();
} else
showMessage(msg.toString());
}
}

View File

@@ -89,8 +89,6 @@ public class InputPayManaSimple extends InputPayManaBase {
handleConvokedCards(false);
}
stop();
}
/** {@inheritDoc} */
@@ -127,6 +125,7 @@ public class InputPayManaSimple extends InputPayManaBase {
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
this.done();
this.stop();
}
}

View File

@@ -102,6 +102,7 @@ public class InputPayManaX extends InputPayManaBase {
@Override
protected final void onOk() {
done();
this.stop();
}
@Override
@@ -116,6 +117,5 @@ public class InputPayManaX extends InputPayManaBase {
card.setXManaCostPaid(this.xPaid);
card.setColorsPaid(this.colorsPaid);
card.setSunburstValue(ColorSet.fromMask(this.colorsPaid).countColors());
this.stop();
}
}

View File

@@ -28,6 +28,7 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
protected final void stop() {
setFinished();
FThreads.invokeInNewThread(new Runnable() {
@Override
@@ -38,6 +39,18 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
}
});
}
// This version does not need to be ran from EDT.
protected final void stopNonEdt() {
FThreads.assertExecutedByEdt(false);
// ensure no clicks from EDT will be accepted
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { setFinished(); } });
// this will update input proxy, so there might be anything happening in the thread
getQueue().removeInput(InputSyncronizedBase.this);
cdlDone.countDown();
}
@Override
public final void selectButtonCancel() {