mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
InputPayMana now executes only updateMessage in EDT when it's not paid
This commit is contained in:
@@ -20,6 +20,7 @@ import forge.game.player.HumanPlay;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
|
import forge.view.ButtonUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -188,7 +189,8 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
if( isAlredyPaid() ) {
|
if( isAlredyPaid() ) {
|
||||||
done();
|
done();
|
||||||
stopNonEdt();
|
stopNonEdt();
|
||||||
}
|
} else
|
||||||
|
FThreads.invokeInEdtLater(new Runnable() { @Override public void run(){ updateMessage(); }});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
game.getInputQueue().invokeGameAction(proc);
|
game.getInputQueue().invokeGameAction(proc);
|
||||||
@@ -248,8 +250,23 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
return bPaid;
|
return bPaid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void showMessage() {
|
||||||
|
if ( isFinished() ) return;
|
||||||
|
ButtonUtil.enableOnlyCancel();
|
||||||
|
|
||||||
|
if( isAlredyPaid() ) {
|
||||||
|
done();
|
||||||
|
stop();
|
||||||
|
} else
|
||||||
|
updateMessage();
|
||||||
|
}
|
||||||
|
|
||||||
protected void onManaAbilityPaid() {} // some inputs overload it
|
protected void onManaAbilityPaid() {} // some inputs overload it
|
||||||
protected abstract void done();
|
protected abstract void done();
|
||||||
|
protected abstract void updateMessage();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import forge.card.mana.ManaCost;
|
|||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.view.ButtonUtil;
|
|
||||||
|
|
||||||
//if cost is paid, Command.execute() is called
|
//if cost is paid, Command.execute() is called
|
||||||
|
|
||||||
@@ -109,12 +108,11 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
|
|||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/* (non-Javadoc)
|
||||||
|
* @see forge.control.input.InputPayManaBase#updateMessage()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void showMessage() {
|
protected void updateMessage() {
|
||||||
if ( isFinished() ) return;
|
|
||||||
|
|
||||||
ButtonUtil.enableOnlyCancel();
|
|
||||||
final StringBuilder msg = new StringBuilder(this.message + "Pay Mana Cost: " + this.manaCost);
|
final StringBuilder msg = new StringBuilder(this.message + "Pay Mana Cost: " + this.manaCost);
|
||||||
if (this.phyLifeToLose > 0) {
|
if (this.phyLifeToLose > 0) {
|
||||||
msg.append(" (");
|
msg.append(" (");
|
||||||
@@ -125,11 +123,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
|
|||||||
if (this.manaCost.containsPhyrexianMana()) {
|
if (this.manaCost.containsPhyrexianMana()) {
|
||||||
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
||||||
}
|
}
|
||||||
|
showMessage(msg.toString());
|
||||||
if( isAlredyPaid() ) {
|
|
||||||
done();
|
|
||||||
stop();
|
|
||||||
} else
|
|
||||||
showMessage(msg.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import forge.Card;
|
|||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.view.ButtonUtil;
|
|
||||||
|
|
||||||
public class InputPayManaOfCostPayment extends InputPayManaBase {
|
public class InputPayManaOfCostPayment extends InputPayManaBase {
|
||||||
|
|
||||||
@@ -48,11 +47,7 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void updateMessage() {
|
||||||
public void showMessage() {
|
|
||||||
if ( isFinished() ) return; //
|
|
||||||
|
|
||||||
ButtonUtil.enableOnlyCancel();
|
|
||||||
final String displayMana = manaCost.toString().replace("X", "").trim();
|
final String displayMana = manaCost.toString().replace("X", "").trim();
|
||||||
|
|
||||||
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + displayMana);
|
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + displayMana);
|
||||||
@@ -66,10 +61,6 @@ public class InputPayManaOfCostPayment extends InputPayManaBase {
|
|||||||
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isAlredyPaid() ) {
|
showMessage(msg.toString());
|
||||||
done();
|
|
||||||
stop();
|
|
||||||
} else
|
|
||||||
showMessage(msg.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ public class InputPayManaSimple extends InputPayManaBase {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
|
|
||||||
|
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
|
||||||
|
|
||||||
if (this.phyLifeToLose > 0) {
|
if (this.phyLifeToLose > 0) {
|
||||||
player.payLife(this.phyLifeToLose, this.originalCard);
|
player.payLife(this.phyLifeToLose, this.originalCard);
|
||||||
}
|
}
|
||||||
@@ -109,6 +112,20 @@ public class InputPayManaSimple extends InputPayManaBase {
|
|||||||
|
|
||||||
ButtonUtil.enableOnlyCancel();
|
ButtonUtil.enableOnlyCancel();
|
||||||
|
|
||||||
|
|
||||||
|
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
|
||||||
|
this.done();
|
||||||
|
this.stop();
|
||||||
|
} else
|
||||||
|
updateMessage();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.control.input.InputPayManaBase#updateMessage()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void updateMessage() {
|
||||||
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + this.manaCost.toString());
|
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + this.manaCost.toString());
|
||||||
if (this.phyLifeToLose > 0) {
|
if (this.phyLifeToLose > 0) {
|
||||||
msg.append(" (");
|
msg.append(" (");
|
||||||
@@ -122,11 +139,6 @@ public class InputPayManaSimple extends InputPayManaBase {
|
|||||||
|
|
||||||
// has its own variant of checkIfPaid
|
// has its own variant of checkIfPaid
|
||||||
showMessage(msg.toString());
|
showMessage(msg.toString());
|
||||||
if (this.manaCost.isPaid() && !new ManaCostBeingPaid(this.originalManaCost).isPaid()) {
|
|
||||||
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
|
|
||||||
this.done();
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,11 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
} else {
|
} else {
|
||||||
ButtonUtil.enableAllFocusOk();
|
ButtonUtil.enableAllFocusOk();
|
||||||
}
|
}
|
||||||
|
updateMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateMessage() {
|
||||||
StringBuilder msg = new StringBuilder("Pay X Mana Cost for ");
|
StringBuilder msg = new StringBuilder("Pay X Mana Cost for ");
|
||||||
msg.append(saPaidFor.getSourceCard().getName()).append("\n").append(this.xPaid);
|
msg.append(saPaidFor.getSourceCard().getName()).append("\n").append(this.xPaid);
|
||||||
msg.append(" Paid so far.");
|
msg.append(" Paid so far.");
|
||||||
|
|||||||
Reference in New Issue
Block a user