1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-13 01:09:53 -09:00
This commit is contained in:
Evan Kranzler 2019-04-05 17:40:31 -04:00
commit c3da15493a
3 changed files with 51 additions and 1 deletions
Mage.Client/src/main/java/mage/client
Mage.Sets/src/mage/cards/t

View file

@ -33,6 +33,18 @@ public class MageDialog extends javax.swing.JInternalFrame {
} }
public static boolean isModalDialogActivated() {
for (JInternalFrame frame : MageFrame.getDesktop().getAllFrames()) {
if (frame instanceof MageDialog) {
MageDialog md = (MageDialog) frame;
if (md.isVisible() && md.isModal()) {
return true;
}
}
}
return false;
}
public static void printFramesOrder(String name) { public static void printFramesOrder(String name) {
///* ///*
JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames(); JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames();

View file

@ -1615,6 +1615,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F8_PRESS", new AbstractAction() { this.getActionMap().put("F8_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnToggleMacroActionPerformed(actionEvent); btnToggleMacroActionPerformed(actionEvent);
} }
}); });
@ -1624,6 +1625,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F3_PRESS", new AbstractAction() { this.getActionMap().put("F3_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
restorePriorityActionPerformed(actionEvent); restorePriorityActionPerformed(actionEvent);
} }
}); });
@ -1651,6 +1653,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F4_PRESS", new AbstractAction() { this.getActionMap().put("F4_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnEndTurnActionPerformed(actionEvent); btnEndTurnActionPerformed(actionEvent);
} }
}); });
@ -1668,6 +1671,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F5_PRESS", new AbstractAction() { this.getActionMap().put("F5_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnUntilEndOfTurnActionPerformed(actionEvent); btnUntilEndOfTurnActionPerformed(actionEvent);
} }
}); });
@ -1677,6 +1681,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F6_PRESS", new AbstractAction() { this.getActionMap().put("F6_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnEndTurnSkipStackActionPerformed(actionEvent); btnEndTurnSkipStackActionPerformed(actionEvent);
} }
}); });
@ -1694,6 +1699,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F7_PRESS", new AbstractAction() { this.getActionMap().put("F7_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnUntilNextMainPhaseActionPerformed(actionEvent); btnUntilNextMainPhaseActionPerformed(actionEvent);
} }
}); });
@ -1711,6 +1717,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F9_PRESS", new AbstractAction() { this.getActionMap().put("F9_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnPassPriorityUntilNextYourTurnActionPerformed(actionEvent); btnPassPriorityUntilNextYourTurnActionPerformed(actionEvent);
} }
}); });
@ -1728,6 +1735,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F11_PRESS", new AbstractAction() { this.getActionMap().put("F11_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnSkipToEndStepBeforeYourTurnActionPerformed(actionEvent); btnSkipToEndStepBeforeYourTurnActionPerformed(actionEvent);
} }
}); });
@ -1745,6 +1753,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F10_PRESS", new AbstractAction() { this.getActionMap().put("F10_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
btnPassPriorityUntilStackResolvedActionPerformed(actionEvent); btnPassPriorityUntilStackResolvedActionPerformed(actionEvent);
} }
}); });
@ -1767,6 +1776,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("F2_PRESS", new AbstractAction() { this.getActionMap().put("F2_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
if (feedbackPanel != null) { if (feedbackPanel != null) {
feedbackPanel.pressOKYesOrDone(); feedbackPanel.pressOKYesOrDone();
} }
@ -1778,6 +1788,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("ENLARGE", new AbstractAction() { this.getActionMap().put("ENLARGE", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
ActionCallback callback = Plugins.instance.getActionCallback(); ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).enlargeCard(EnlargeMode.NORMAL); ((MageActionCallback) callback).enlargeCard(EnlargeMode.NORMAL);
} }
@ -1788,6 +1799,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("ENLARGE_SOURCE", new AbstractAction() { this.getActionMap().put("ENLARGE_SOURCE", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
ActionCallback callback = Plugins.instance.getActionCallback(); ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).enlargeCard(EnlargeMode.ALTERNATE); ((MageActionCallback) callback).enlargeCard(EnlargeMode.ALTERNATE);
} }
@ -1798,6 +1810,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("BIG_IMAGE", new AbstractAction() { this.getActionMap().put("BIG_IMAGE", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
imagePanelState = !imagePanelState; imagePanelState = !imagePanelState;
if (!imagePanelState) { if (!imagePanelState) {
jSplitPane0.resetToPreferredSizes(); jSplitPane0.resetToPreferredSizes();
@ -1813,6 +1826,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("USEFIRSTMANAABILITY", new AbstractAction() { this.getActionMap().put("USEFIRSTMANAABILITY", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_ON, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_ON, gameId, null);
setMenuStates( setMenuStates(
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
@ -1837,6 +1851,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("ENLARGE_RELEASE", new AbstractAction() { this.getActionMap().put("ENLARGE_RELEASE", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
ActionCallback callback = Plugins.instance.getActionCallback(); ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).hideEnlargedCard(); ((MageActionCallback) callback).hideEnlargedCard();
} }
@ -1847,6 +1862,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("USEFIRSTMANAABILITY_RELEASE", new AbstractAction() { this.getActionMap().put("USEFIRSTMANAABILITY_RELEASE", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (isUserImputActive()) return;
SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
setMenuStates( setMenuStates(
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
@ -2218,6 +2234,21 @@ public final class GamePanel extends javax.swing.JPanel {
updateSkipButtons(); updateSkipButtons();
} }
private boolean isChatInputUnderCursor(Point p) {
Component c = this.getComponentAt(p);
return gameChatPanel.getTxtMessageInputComponent().equals(c) || userChatPanel.getTxtMessageInputComponent().equals(c);
}
private boolean isChatInputActive() {
Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
return gameChatPanel.getTxtMessageInputComponent().equals(c) || userChatPanel.getTxtMessageInputComponent().equals(c);
}
private boolean isUserImputActive() {
// any imput or choose dialog active (need to disable skip buttons in dialogs and chat)
return MageDialog.isModalDialogActivated() || isChatInputActive();
}
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) { private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_END_STEP); skipButtons.activateSkipButton(KEY_CONTROL_END_STEP);
@ -2481,6 +2512,13 @@ public final class GamePanel extends javax.swing.JPanel {
boolean isActionEvent = false; boolean isActionEvent = false;
if (id == MouseEvent.MOUSE_PRESSED) { if (id == MouseEvent.MOUSE_PRESSED) {
isActionEvent = true; isActionEvent = true;
// clear chat focus on click
if (event instanceof MouseEvent) {
MouseEvent me = (MouseEvent) event;
if (isChatInputActive() && !isChatInputUnderCursor(me.getPoint())) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearFocusOwner();
}
}
} else if (id == KeyEvent.KEY_PRESSED) { } else if (id == KeyEvent.KEY_PRESSED) {
KeyEvent key = (KeyEvent) event; KeyEvent key = (KeyEvent) event;
int keyCode = key.getKeyCode(); int keyCode = key.getKeyCode();

View file

@ -54,7 +54,7 @@ public final class TaigamSidisisHand extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipDrawStepEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipDrawStepEffect()));
// At the beginning of your upkeep, look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard. // At the beginning of your upkeep, look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1), this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LookLibraryAndPickControllerEffect(new StaticValue(3), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false), TargetController.YOU, false)); StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false), TargetController.YOU, false));
// {B}, {T}, Exile X cards from your graveyard: Target creature gets -X/-X until end of turn. // {B}, {T}, Exile X cards from your graveyard: Target creature gets -X/-X until end of turn.