mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
This commit is contained in:
parent
eafd28ca6d
commit
ee2741c7a7
2 changed files with 58 additions and 48 deletions
|
@ -72,7 +72,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||
|
||||
|
@ -353,61 +353,76 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
+ ((SessionHandler.getSession() != null && SessionHandler.isConnected()) ? SessionHandler.getVersionInfo() : NOT_CONNECTED_TEXT));
|
||||
}
|
||||
|
||||
private void updateTooltipContainerSizes() {
|
||||
JPanel cardPreviewContainer;
|
||||
BigCard bigCard;
|
||||
JPanel cardPreviewContainerRotated;
|
||||
BigCard bigCardRotated;
|
||||
try {
|
||||
cardPreviewContainer = (JPanel) UI.getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
||||
bigCard = (BigCard) UI.getComponent(MageComponents.CARD_PREVIEW_PANE);
|
||||
cardPreviewContainerRotated = (JPanel) UI.getComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED);
|
||||
bigCardRotated = (BigCard) UI.getComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.fatal("Can't update tooltip panel sizes");
|
||||
Thread.currentThread().interrupt();
|
||||
return;
|
||||
}
|
||||
|
||||
int height = GUISizeHelper.enlargedImageHeight;
|
||||
int width = (int) ((float) height * (float) 0.64);
|
||||
bigCard.setSize(width, height);
|
||||
cardPreviewContainer.setBounds(0, 0, width + 80, height + 30);
|
||||
bigCardRotated.setSize(height, width + 30);
|
||||
cardPreviewContainerRotated.setBounds(0, 0, height + 80, width + 100 + 30);
|
||||
}
|
||||
|
||||
private void addTooltipContainer() {
|
||||
final JEditorPane cardInfoPane = (JEditorPane) Plugins.instance.getCardInfoPane();
|
||||
JEditorPane cardInfoPane = (JEditorPane) Plugins.instance.getCardInfoPane();
|
||||
if (cardInfoPane == null) {
|
||||
LOGGER.fatal("Can't find card tooltip plugin");
|
||||
return;
|
||||
}
|
||||
cardInfoPane.setLocation(40, 40);
|
||||
cardInfoPane.setBackground(new Color(0, 0, 0, 0));
|
||||
UI.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
|
||||
|
||||
MageRoundPane popupContainer = new MageRoundPane();
|
||||
popupContainer.setLayout(null);
|
||||
|
||||
popupContainer.add(cardInfoPane);
|
||||
popupContainer.setVisible(false);
|
||||
|
||||
desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER);
|
||||
|
||||
UI.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
|
||||
UI.addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
|
||||
// preview panel normal
|
||||
|
||||
|
||||
JPanel cardPreviewContainer = new JPanel();
|
||||
cardPreviewContainer.setOpaque(false);
|
||||
cardPreviewContainer.setLayout(null);
|
||||
BigCard bigCard = new BigCard();
|
||||
int height = GUISizeHelper.enlargedImageHeight;
|
||||
int width = (int) ((float) height * (float) 0.64);
|
||||
bigCard.setSize(width, height);
|
||||
bigCard.setLocation(40, 40);
|
||||
bigCard.setBackground(new Color(0, 0, 0, 0));
|
||||
|
||||
cardPreviewContainer.add(bigCard);
|
||||
cardPreviewContainer.setVisible(false);
|
||||
cardPreviewContainer.setBounds(0, 0, width + 80, height + 30);
|
||||
|
||||
UI.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard);
|
||||
desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER);
|
||||
UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer);
|
||||
|
||||
desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER);
|
||||
BigCard bigCard = new BigCard();
|
||||
bigCard.setLocation(40, 40);
|
||||
bigCard.setBackground(new Color(0, 0, 0, 0));
|
||||
cardPreviewContainer.add(bigCard);
|
||||
UI.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard);
|
||||
|
||||
// preview panel rotated
|
||||
JPanel cardPreviewContainerRotated = new JPanel();
|
||||
cardPreviewContainerRotated.setOpaque(false);
|
||||
cardPreviewContainerRotated.setLayout(null);
|
||||
bigCard = new BigCard(true);
|
||||
bigCard.setSize(height, width + 30);
|
||||
bigCard.setLocation(40, 40);
|
||||
bigCard.setBackground(new Color(0, 0, 0, 0));
|
||||
cardPreviewContainerRotated.add(bigCard);
|
||||
cardPreviewContainerRotated.setVisible(false);
|
||||
cardPreviewContainerRotated.setBounds(0, 0, height + 80, width + 100 + 30);
|
||||
|
||||
UI.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCard);
|
||||
desktopPane.add(cardPreviewContainerRotated, JLayeredPane.POPUP_LAYER);
|
||||
UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated);
|
||||
|
||||
desktopPane.add(cardPreviewContainerRotated, JLayeredPane.POPUP_LAYER);
|
||||
|
||||
BigCard bigCardRotated = new BigCard(true);
|
||||
bigCardRotated.setLocation(40, 40);
|
||||
bigCardRotated.setBackground(new Color(0, 0, 0, 0));
|
||||
cardPreviewContainerRotated.add(bigCardRotated);
|
||||
UI.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCardRotated);
|
||||
|
||||
updateTooltipContainerSizes();
|
||||
}
|
||||
|
||||
private void setGUISizeTooltipContainer() {
|
||||
|
@ -1586,7 +1601,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
balloonTip.setFont(GUISizeHelper.balloonTooltipFont);
|
||||
|
||||
addTooltipContainer();
|
||||
updateTooltipContainerSizes();
|
||||
}
|
||||
|
||||
public void showWhatsNewDialog(boolean forceToShowPage) {
|
||||
|
|
|
@ -30,8 +30,8 @@ import java.awt.*;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
@ -154,24 +154,22 @@ public class MageActionCallback implements ActionCallback {
|
|||
|
||||
try {
|
||||
final Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||
Component popup2 = MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
|
||||
|
||||
((CardInfoPane) popup2).setCard(data.getCard(), popupContainer);
|
||||
|
||||
showPopup(popupContainer, popup2);
|
||||
|
||||
Component popupInfo = MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
|
||||
((CardInfoPane) popupInfo).setCard(data.getCard(), popupContainer);
|
||||
showPopup(popupContainer, popupInfo);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.warn(e.getMessage());
|
||||
LOGGER.error("Can't show card tooltip", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException {
|
||||
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (!popupTextWindowOpen
|
||||
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||
if (!popupTextWindowOpen || enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.getLocationOnScreen() == null) {
|
||||
data.setLocationOnScreen(data.getComponent().getLocationOnScreen());
|
||||
}
|
||||
|
@ -383,6 +381,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
ArrowUtil.drawArrowsForPairedCards(data, parentPoint);
|
||||
ArrowUtil.drawArrowsForBandedCards(data, parentPoint);
|
||||
ArrowUtil.drawArrowsForEnchantPlayers(data, parentPoint);
|
||||
|
||||
tooltipCard = data.getCard();
|
||||
showTooltipPopup(data, parentComponent, parentPoint);
|
||||
}
|
||||
|
@ -414,13 +413,9 @@ public class MageActionCallback implements ActionCallback {
|
|||
|
||||
@Override
|
||||
public void hideOpenComponents() {
|
||||
this.hideTooltipPopup();
|
||||
this.hideEnlargedCard();
|
||||
hideAll(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the text popup window
|
||||
*/
|
||||
public void hideTooltipPopup() {
|
||||
this.tooltipCard = null;
|
||||
if (tooltipPopup != null) {
|
||||
|
@ -433,11 +428,11 @@ public class MageActionCallback implements ActionCallback {
|
|||
if (SessionHandler.getSession() == null) {
|
||||
return;
|
||||
}
|
||||
// set enlarged card display to visible = false
|
||||
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||
popupContainer.setVisible(false);
|
||||
} catch (Exception e2) {
|
||||
LOGGER.warn("Can't set tooltip to visible = false", e2);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error("Can't hide card tooltip", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue