mirror of
https://github.com/correl/mage.git
synced 2024-11-26 03:00:09 +00:00
New tooltips (support delayed displaying, mana and tap symbols, styled text).
This commit is contained in:
parent
1a945de4de
commit
94d883b5ba
7 changed files with 95 additions and 38 deletions
Binary file not shown.
|
@ -43,11 +43,14 @@ import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
import mage.components.CardInfoPane;
|
import mage.components.CardInfoPane;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -98,7 +101,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
cardSelector.getCardsList().removeCard(card.getId());
|
cardSelector.getCardsList().removeCard(card.getId());
|
||||||
}
|
}
|
||||||
if (cardInfoPane instanceof CardInfoPane) {
|
if (cardInfoPane instanceof CardInfoPane) {
|
||||||
((CardInfoPane)cardInfoPane).setCard(card);
|
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +181,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
||||||
if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
|
if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
|
||||||
cardInfoPane.setPreferredSize(new Dimension(170,230));
|
cardInfoPane.setPreferredSize(new Dimension(170,150));
|
||||||
cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||||
isShowCardInfo = true;
|
isShowCardInfo = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -456,4 +459,6 @@ class ImportFilter extends FileFilter {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "*.dec | *.mwDeck | *.txt";
|
return "*.dec | *.mwDeck | *.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,16 +1,13 @@
|
||||||
package mage.client.plugins.adapters;
|
package mage.client.plugins.adapters;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.Image;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.swing.Popup;
|
import javax.swing.*;
|
||||||
import javax.swing.PopupFactory;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
|
@ -25,6 +22,8 @@ import mage.client.util.DefaultActionCallback;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
import mage.client.util.gui.ArrowBuilder;
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
|
import mage.components.CardInfoPane;
|
||||||
|
import mage.utils.ThreadUtils;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
||||||
import org.jdesktop.swingx.JXPanel;
|
import org.jdesktop.swingx.JXPanel;
|
||||||
|
@ -32,12 +31,14 @@ import org.jdesktop.swingx.JXPanel;
|
||||||
public class MageActionCallback implements ActionCallback {
|
public class MageActionCallback implements ActionCallback {
|
||||||
|
|
||||||
private Popup popup;
|
private Popup popup;
|
||||||
|
private JPopupMenu jPopupMenu;
|
||||||
private BigCard bigCard;
|
private BigCard bigCard;
|
||||||
protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
||||||
protected static Session session = MageFrame.getSession();
|
protected static Session session = MageFrame.getSession();
|
||||||
private CardView popupCard;
|
private CardView popupCard;
|
||||||
private Thread t;
|
private Thread t;
|
||||||
private int state = 0;
|
private int state = 0;
|
||||||
|
private JComponent cardInfoPane;
|
||||||
|
|
||||||
public MageActionCallback() {
|
public MageActionCallback() {
|
||||||
}
|
}
|
||||||
|
@ -50,6 +51,9 @@ public class MageActionCallback implements ActionCallback {
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
}
|
}
|
||||||
|
if (cardInfoPane == null) {
|
||||||
|
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,6 +130,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
ie.printStackTrace();
|
ie.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
if (cardInfoPane == null) {
|
||||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||||
popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
||||||
popup.show();
|
popup.show();
|
||||||
|
@ -133,6 +138,34 @@ public class MageActionCallback implements ActionCallback {
|
||||||
popup.hide();
|
popup.hide();
|
||||||
popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
||||||
popup.show();
|
popup.show();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
ThreadUtils.threadPool2.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ThreadUtils.threadPool2.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(900);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
ie.printStackTrace();
|
||||||
|
}
|
||||||
|
if (!popupCard.equals(data.card)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||||
|
((CardInfoPane)cardInfoPane).setCard(data.card);
|
||||||
|
cardInfoPane.setSize(161, 221);
|
||||||
|
cardInfoPane.setPreferredSize(new Dimension(161, 221));
|
||||||
|
popup = factory.getPopup(data.component, cardInfoPane, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
||||||
|
popup.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,6 +205,9 @@ public class MageActionCallback implements ActionCallback {
|
||||||
if (popup != null) {
|
if (popup != null) {
|
||||||
popup.hide();
|
popup.hide();
|
||||||
}
|
}
|
||||||
|
if (jPopupMenu != null) {
|
||||||
|
jPopupMenu.setVisible(false);
|
||||||
|
}
|
||||||
ArrowBuilder.removeAllArrows();
|
ArrowBuilder.removeAllArrows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package mage.components;
|
package mage.components;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
import mage.view.CardView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Card info pane for displaying card rules.
|
* Card info pane for displaying card rules.
|
||||||
|
@ -9,6 +10,6 @@ import mage.cards.Card;
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public interface CardInfoPane {
|
public interface CardInfoPane {
|
||||||
public void setCard (final Card card);
|
public void setCard (final CardView card);
|
||||||
public boolean isCurrentCard (Card card);
|
public boolean isCurrentCard (CardView card);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.mage.card.arcane;
|
package mage.utils;
|
||||||
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
public class ThreadUtils {
|
public class ThreadUtils {
|
||||||
|
|
||||||
static public ThreadPoolExecutor threadPool;
|
static public ThreadPoolExecutor threadPool;
|
||||||
|
static public ThreadPoolExecutor threadPool2;
|
||||||
static private int threadCount;
|
static private int threadCount;
|
||||||
static {
|
static {
|
||||||
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||||
|
@ -24,6 +25,15 @@ public class ThreadUtils {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
threadPool.prestartAllCoreThreads();
|
threadPool.prestartAllCoreThreads();
|
||||||
|
threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||||
|
public Thread newThread (Runnable runnable) {
|
||||||
|
threadCount++;
|
||||||
|
Thread thread = new Thread(runnable, "TP2" + threadCount);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
threadPool2.prestartAllCoreThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void sleep (int millis) {
|
static public void sleep (int millis) {
|
|
@ -84,10 +84,10 @@ public class ManaSymbols {
|
||||||
|
|
||||||
static public synchronized String replaceSymbolsWithHTML (String value, boolean small) {
|
static public synchronized String replaceSymbolsWithHTML (String value, boolean small) {
|
||||||
if (small)
|
if (small)
|
||||||
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/small/$1$2.jpg' width=11 height=11>");
|
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/small/$1$2.jpg' alt='$1$2' width=11 height=11>");
|
||||||
else {
|
else {
|
||||||
value = value.replace("{slash}", "<img src='file:plugins/images/symbols/medium/slash.jpg' width=10 height=13>");
|
value = value.replace("{slash}", "<img src='file:plugins/images/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||||
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/medium/$1$2.jpg' width=13 height=13>");
|
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/medium/$1$2.jpg' alt='$1$2' width=13 height=13>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package org.mage.plugins.card.info;
|
package org.mage.plugins.card.info;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.components.CardInfoPane;
|
import mage.components.CardInfoPane;
|
||||||
import mage.utils.CardUtil;
|
import mage.utils.CardUtil;
|
||||||
|
import mage.utils.ThreadUtils;
|
||||||
|
import mage.view.CardView;
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
import org.mage.card.arcane.ThreadUtils;
|
|
||||||
import org.mage.card.arcane.UI;
|
import org.mage.card.arcane.UI;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -20,15 +20,16 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
|
|
||||||
private Card currentCard;
|
private CardView currentCard;
|
||||||
|
|
||||||
public CardInfoPaneImpl() {
|
public CardInfoPaneImpl() {
|
||||||
UI.setHTMLEditorKit(this);
|
UI.setHTMLEditorKit(this);
|
||||||
setEditable(false);
|
setEditable(false);
|
||||||
setBackground(Color.white);
|
setBackground(Color.white);
|
||||||
|
setSize(170, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCard (final Card card) {
|
public void setCard (final CardView card) {
|
||||||
if (card == null) return;
|
if (card == null) return;
|
||||||
if (isCurrentCard(card)) return;
|
if (isCurrentCard(card)) return;
|
||||||
currentCard = card;
|
currentCard = card;
|
||||||
|
@ -37,7 +38,11 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
public void run () {
|
public void run () {
|
||||||
if (!card.equals(currentCard)) return;
|
if (!card.equals(currentCard)) return;
|
||||||
|
|
||||||
String castingCost = UI.getDisplayManaCost(card.getManaCost().getText());
|
String manaCost = "";
|
||||||
|
for (String m : card.getManaCost()) {
|
||||||
|
manaCost += m;
|
||||||
|
}
|
||||||
|
String castingCost = UI.getDisplayManaCost(manaCost);
|
||||||
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, false);
|
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, false);
|
||||||
|
|
||||||
int symbolCount = 0;
|
int symbolCount = 0;
|
||||||
|
@ -111,13 +116,13 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
String pt = "";
|
String pt = "";
|
||||||
if (card.getCardType().contains(Constants.CardType.CREATURE)) {
|
if (CardUtil.isCreature(card)) {
|
||||||
pt = card.getPower() + "/" + card.getToughness();
|
pt = card.getPower() + "/" + card.getToughness();
|
||||||
} else if (card.getCardType().contains(Constants.CardType.PLANESWALKER)) {
|
} else if (CardUtil.isPlaneswalker(card)) {
|
||||||
pt = card.getLoyalty().toString();
|
pt = card.getLoyalty().toString();
|
||||||
}
|
}
|
||||||
if (pt.length() > 0) {
|
if (pt.length() > 0) {
|
||||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td>");
|
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%' valign='bottom'><tr><td>");
|
||||||
buffer.append("</td><td align='right'>");
|
buffer.append("</td><td align='right'>");
|
||||||
buffer.append("<b>");
|
buffer.append("<b>");
|
||||||
buffer.append(pt);
|
buffer.append(pt);
|
||||||
|
@ -131,7 +136,7 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
public void run () {
|
public void run () {
|
||||||
if (!card.equals(currentCard)) return;
|
if (!card.equals(currentCard)) return;
|
||||||
setText(buffer.toString());
|
setText(buffer.toString());
|
||||||
System.out.println(buffer.toString());
|
//System.out.println(buffer.toString());
|
||||||
setCaretPosition(0);
|
setCaretPosition(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -139,24 +144,24 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTypes(Card card) {
|
private String getTypes(CardView card) {
|
||||||
String types = "";
|
String types = "";
|
||||||
for (String superType : card.getSupertype()) {
|
for (String superType : card.getSuperTypes()) {
|
||||||
types += superType + " ";
|
types += superType + " ";
|
||||||
}
|
}
|
||||||
for (Constants.CardType cardType : card.getCardType()) {
|
for (Constants.CardType cardType : card.getCardTypes()) {
|
||||||
types += cardType.toString() + " ";
|
types += cardType.toString() + " ";
|
||||||
}
|
}
|
||||||
if (card.getSubtype().size() > 0) {
|
if (card.getSubTypes().size() > 0) {
|
||||||
types += "- ";
|
types += "- ";
|
||||||
}
|
}
|
||||||
for (String subType : card.getSubtype()) {
|
for (String subType : card.getSubTypes()) {
|
||||||
types += subType + " ";
|
types += subType + " ";
|
||||||
}
|
}
|
||||||
return types.trim();
|
return types.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCurrentCard (Card card) {
|
public boolean isCurrentCard (CardView card) {
|
||||||
return currentCard != null && card.equals(currentCard);
|
return currentCard != null && card.equals(currentCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue