mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Enable hyperlinks handling only in the game log window.
This commit is contained in:
parent
23e93f008a
commit
f95921cc73
3 changed files with 27 additions and 10 deletions
|
@ -351,6 +351,10 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
||||||
this.txtMessage.repaint();
|
this.txtMessage.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableHyperlinks() {
|
||||||
|
txtConversation.enableHyperlinks();
|
||||||
|
}
|
||||||
|
|
||||||
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
|
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
|
||||||
handleKeyTyped(evt);
|
handleKeyTyped(evt);
|
||||||
|
|
|
@ -39,10 +39,14 @@ public class ColorPane extends JEditorPane {
|
||||||
HTMLDocument doc = new HTMLDocument();
|
HTMLDocument doc = new HTMLDocument();
|
||||||
private int tooltipDelay;
|
private int tooltipDelay;
|
||||||
private int tooltipCounter;
|
private int tooltipCounter;
|
||||||
|
private boolean hyperlinkEnabled = false;
|
||||||
|
|
||||||
public ColorPane() {
|
public ColorPane() {
|
||||||
this.setEditorKit(kit);
|
this.setEditorKit(kit);
|
||||||
this.setDocument(doc);
|
this.setDocument(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHyperlinkHandlers() {
|
||||||
addHyperlinkListener(new HyperlinkListener() {
|
addHyperlinkListener(new HyperlinkListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +66,7 @@ public class ColorPane extends JEditorPane {
|
||||||
if (e.getEventType() == EventType.EXITED) {
|
if (e.getEventType() == EventType.EXITED) {
|
||||||
setPopupVisibility(container, false);
|
setPopupVisibility(container, false);
|
||||||
}
|
}
|
||||||
if (e.getEventType() == EventType.ENTERED) {
|
if (e.getEventType() == EventType.ENTERED && card != null) {
|
||||||
CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
|
CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
|
||||||
cardInfoPane.setCard(new CardView(card.getMockCard()), container);
|
cardInfoPane.setCard(new CardView(card.getMockCard()), container);
|
||||||
setPopupVisibility(container, true);
|
setPopupVisibility(container, true);
|
||||||
|
@ -76,7 +80,7 @@ public class ColorPane extends JEditorPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addMouseListener(new MouseAdapter() {
|
addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
|
@ -89,21 +93,22 @@ public class ColorPane extends JEditorPane {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPopupVisibility(final Component container, final boolean show)
|
private void setPopupVisibility(final Component container, final boolean show) throws InterruptedException {
|
||||||
throws InterruptedException {
|
|
||||||
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
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;
|
tooltipCounter += show ? 1 : -1;
|
||||||
if (tooltipCounter < 0) {
|
if (tooltipCounter < 0) {
|
||||||
tooltipCounter = 0;
|
tooltipCounter = 0;
|
||||||
}
|
}
|
||||||
|
if (tooltipCounter > 0) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
container.setVisible(tooltipCounter > 0);
|
container.setVisible(tooltipCounter > 0);
|
||||||
c.repaint();
|
c.repaint();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +136,9 @@ public class ColorPane extends JEditorPane {
|
||||||
|
|
||||||
public void append(String text) {
|
public void append(String text) {
|
||||||
try {
|
try {
|
||||||
text = text.replaceAll("(<font color=[^>]*>([^<]*)) (\\[[0-9a-fA-F]*\\])</font>", "<a href=\"#$2\">$1</a> $3");
|
if (hyperlinkEnabled) {
|
||||||
|
text = text.replaceAll("(<font color=[^>]*>([^<]*)) (\\[[0-9a-fA-F]*\\])</font>", "<a href=\"#$2\">$1</a> $3");
|
||||||
|
}
|
||||||
setEditable(true);
|
setEditable(true);
|
||||||
kit.insertHTML(doc, doc.getLength(), text, 0, 0, null);
|
kit.insertHTML(doc, doc.getLength(), text, 0, 0, null);
|
||||||
setEditable(false);
|
setEditable(false);
|
||||||
|
@ -163,4 +170,9 @@ public class ColorPane extends JEditorPane {
|
||||||
super.paintChildren(g);
|
super.paintChildren(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableHyperlinks(){
|
||||||
|
hyperlinkEnabled = true;
|
||||||
|
addHyperlinkHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1296,6 +1296,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
gameChatPanel.setConnectedChat(userChatPanel);
|
gameChatPanel.setConnectedChat(userChatPanel);
|
||||||
gameChatPanel.disableInput();
|
gameChatPanel.disableInput();
|
||||||
gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
|
gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
|
||||||
|
gameChatPanel.enableHyperlinks();
|
||||||
jSplitPane2 = new javax.swing.JSplitPane();
|
jSplitPane2 = new javax.swing.JSplitPane();
|
||||||
handContainer = new HandPanel();
|
handContainer = new HandPanel();
|
||||||
handCards = new HashMap<>();
|
handCards = new HashMap<>();
|
||||||
|
|
Loading…
Reference in a new issue