From 783a828cded851d19689280a04978c1bf7f6c19f Mon Sep 17 00:00:00 2001 From: drmDev Date: Sat, 5 Mar 2016 06:10:54 -0500 Subject: [PATCH 1/5] User requested condense trigger ability text for Tuktuk Scrapper --- Mage.Sets/src/mage/sets/worldwake/TuktukScrapper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/worldwake/TuktukScrapper.java b/Mage.Sets/src/mage/sets/worldwake/TuktukScrapper.java index 2a22757c2e..e5e90bb5f1 100644 --- a/Mage.Sets/src/mage/sets/worldwake/TuktukScrapper.java +++ b/Mage.Sets/src/mage/sets/worldwake/TuktukScrapper.java @@ -113,7 +113,12 @@ class TuktukScrapperTriggeredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Whenever {this} or another Ally enters the battlefield under your control, you may destroy target artifact. If that artifact is put into a graveyard this way, {this} deals damage to that artifact's controller equal to the number of Allies you control."; + + // originally returned fullText, user reported that because the trigger text is so lengthy, they cannot click Yes/No buttons + //String fullText = "Whenever {this} or another Ally enters the battlefield under your control, you may destroy target artifact. If that artifact is put into a graveyard this way, {this} deals damage to that artifact's controller equal to the number of Allies you control."; + String condensedText = "Whenever {this} or another Ally you enters the battlefield under your control, you may destroy target artifact. If you do, {this} deals damage to that controller equal to the number of Allies you control."; + + return condensedText; } } From 98c291be7b9152aa1f9d81eb5ad721e7026811f4 Mon Sep 17 00:00:00 2001 From: rkfg Date: Sun, 6 Mar 2016 01:45:56 +0300 Subject: [PATCH 2/5] Protect tooltip counter from going negative forever. --- .../mage/client/components/ColorPane.java | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/components/ColorPane.java b/Mage.Client/src/main/java/mage/client/components/ColorPane.java index 02abda5675..a5a0dc107f 100644 --- a/Mage.Client/src/main/java/mage/client/components/ColorPane.java +++ b/Mage.Client/src/main/java/mage/client/components/ColorPane.java @@ -5,6 +5,8 @@ import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Point; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import javax.swing.JEditorPane; import javax.swing.JPanel; @@ -83,20 +85,36 @@ public class ColorPane extends JEditorPane { }); } - private void setPopupVisibility(final Point location, final Component container, final boolean show) - throws InterruptedException { - final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (location != null) { - container.setLocation(location); - } - tooltipCounter += show ? 1 : -1; - container.setVisible(tooltipCounter > 0); - c.repaint(); - } - }); + }); + + addMouseListener(new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + tooltipCounter = 1; // will decrement and become effectively zero on leaving the pane + try { + setPopupVisibility(null, MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER), false); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + }); + } + + private void setPopupVisibility(final Point location, final Component container, final boolean show) + throws InterruptedException { + final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (location != null) { + container.setLocation(location); + } + tooltipCounter += show ? 1 : -1; + if (tooltipCounter < 0) { + tooltipCounter = 0; + } + container.setVisible(tooltipCounter > 0); + c.repaint(); } }); } From 768b004d3eeaf49bdc86b522e8b546de8dc2cd76 Mon Sep 17 00:00:00 2001 From: rkfg Date: Sun, 6 Mar 2016 02:41:23 +0300 Subject: [PATCH 3/5] Fix race condition on tooltip resize in EDT. CardInfoPane.setCard() performs the tooltip resize, initially it's of zero width and height. The resize happens in the EDT but location is calculated in the thread pool's thread, i.e. before the first resize. Because of that the first time the tooltip appears it may be partially off-screen, nothing fatal but looks ugly. Now all calculations are moved to EDT as well and they're guaranteed to happen after the resize. --- .../mage/client/components/ColorPane.java | 27 +++++++------------ .../plugins/adapters/MageActionCallback.java | 21 +++++++-------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/components/ColorPane.java b/Mage.Client/src/main/java/mage/client/components/ColorPane.java index a5a0dc107f..deb15736e7 100644 --- a/Mage.Client/src/main/java/mage/client/components/ColorPane.java +++ b/Mage.Client/src/main/java/mage/client/components/ColorPane.java @@ -4,6 +4,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; +import java.awt.MouseInfo; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -59,23 +60,12 @@ public class ColorPane extends JEditorPane { try { final Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER); if (e.getEventType() == EventType.EXITED) { - setPopupVisibility(null, container, false); + setPopupVisibility(container, false); } if (e.getEventType() == EventType.ENTERED) { CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE); cardInfoPane.setCard(new CardView(card.getMockCard()), container); - Point mousePosition = MageFrame.getDesktop().getMousePosition(); - int popupY = 0; - if (mousePosition == null) { // switched to another window - popupY = getLocationOnScreen().y; - } else { - popupY = mousePosition.y; - } - Point location = new Point(getLocationOnScreen().x - container.getWidth(), popupY); - Component parentComponent = MageFrame.getInstance(); - location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), - container, parentComponent); - setPopupVisibility(location, container, true); + setPopupVisibility(container, true); } } catch (InterruptedException e1) { e1.printStackTrace(); @@ -92,7 +82,7 @@ public class ColorPane extends JEditorPane { public void mouseExited(MouseEvent e) { tooltipCounter = 1; // will decrement and become effectively zero on leaving the pane try { - setPopupVisibility(null, MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER), false); + setPopupVisibility(MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER), false); } catch (InterruptedException e1) { e1.printStackTrace(); } @@ -100,15 +90,16 @@ public class ColorPane extends JEditorPane { }); } - private void setPopupVisibility(final Point location, final Component container, final boolean show) + private void setPopupVisibility(final Component container, final boolean show) throws InterruptedException { final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - if (location != null) { - container.setLocation(location); - } + Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y); + Component parentComponent = MageFrame.getInstance(); + location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent); + container.setLocation(location); tooltipCounter += show ? 1 : -1; if (tooltipCounter < 0) { tooltipCounter = 0; diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index 015280b3d3..356b5090bc 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -182,24 +182,14 @@ public class MageActionCallback implements ActionCallback { ((CardInfoPane) popup2).setCard(data.card, popupContainer); - if (data.locationOnScreen == null) { - data.locationOnScreen = data.component.getLocationOnScreen(); - } - - Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40); - location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, popup2, parentComponent); - location.translate(-parentPoint.x, -parentPoint.y); - - ThreadUtils.sleep(200); - - showPopup(popupContainer, location); + showPopup(popupContainer, popup2); } catch (InterruptedException e) { LOGGER.warn(e.getMessage()); } } - public void showPopup(final Component popupContainer, final Point location) throws InterruptedException { + public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException { final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE); SwingUtilities.invokeLater(new Runnable() { @Override @@ -207,6 +197,13 @@ public class MageActionCallback implements ActionCallback { if (!popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) { return; } + if (data.locationOnScreen == null) { + data.locationOnScreen = data.component.getLocationOnScreen(); + } + + Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40); + location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent); + location.translate(-parentPoint.x, -parentPoint.y); popupContainer.setLocation(location); popupContainer.setVisible(true); c.repaint(); From 5fe67bda4c284f6daf9db2d644ee14f8d0823082 Mon Sep 17 00:00:00 2001 From: rkfg Date: Sun, 6 Mar 2016 02:55:30 +0300 Subject: [PATCH 4/5] Remove unneded import. --- .../main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java index 1d2e242aa2..b8d6ed8bc1 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java @@ -8,7 +8,6 @@ import mage.client.util.GUISizeHelper; import mage.client.util.gui.GuiDisplayUtil; import mage.client.util.gui.GuiDisplayUtil.TextLines; import mage.components.CardInfoPane; -import mage.utils.ThreadUtils; import mage.view.CardView; import org.mage.card.arcane.UI; From bb89c8a4e89c8526cd0d57bfc81d05224d8ad091 Mon Sep 17 00:00:00 2001 From: rkfg Date: Sun, 6 Mar 2016 03:07:55 +0300 Subject: [PATCH 5/5] Fix startup script for Linux. --- Utils/release/startMage.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utils/release/startMage.sh b/Utils/release/startMage.sh index a8093bff50..a737503b04 100644 --- a/Utils/release/startMage.sh +++ b/Utils/release/startMage.sh @@ -1,5 +1,5 @@ #!/bin/sh -cd ./client +cd ./mage-client ./startClient.sh -cd ../server -./startServer.sh \ No newline at end of file +cd ../mage-server +./startServer.sh