1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-07 17:00:08 -09:00

* Added preference option to set the size of the enlarged image popup window.

This commit is contained in:
LevelX2 2016-08-02 12:00:36 +02:00
parent 88e8894b29
commit a0fbcddeb9
5 changed files with 633 additions and 339 deletions

View file

@ -33,7 +33,6 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
@ -234,19 +233,20 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
// support multiple mage panes
Object source = event.getSource();
if(source instanceof Component) {
Component component = (Component)source;
while(component != null) {
if(component instanceof MagePane) {
frame = (MagePane)component;
if (source instanceof Component) {
Component component = (Component) source;
while (component != null) {
if (component instanceof MagePane) {
frame = (MagePane) component;
break;
}
component = component.getParent();
}
}
if(frame != null)
if (frame != null) {
frame.handleEvent(event);
}
}
/**
@ -281,9 +281,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
{
Object value = UIManager.get("SplitPane.ancestorInputMap");
if(value instanceof InputMap) {
InputMap map = (InputMap)value;
for(int vk = KeyEvent.VK_F2; vk <= KeyEvent.VK_F12; ++vk) {
if (value instanceof InputMap) {
InputMap map = (InputMap) value;
for (int vk = KeyEvent.VK_F2; vk <= KeyEvent.VK_F12; ++vk) {
map.remove(KeyStroke.getKeyStroke(vk, 0));
}
}
@ -452,7 +452,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (cardInfoPane == null) {
return;
}
// cardInfoPane.setSize(Constants.TOOLTIP_WIDTH_MIN, Constants.TOOLTIP_HEIGHT_MIN);
cardInfoPane.setLocation(40, 40);
cardInfoPane.setBackground(new Color(0, 0, 0, 0));
@ -461,9 +460,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
popupContainer.add(cardInfoPane);
popupContainer.setVisible(false);
// popupContainer.setBounds(0, 0,
// Constants.TOOLTIP_WIDTH_MIN + Constants.TOOLTIP_BORDER_WIDTH,
// Constants.TOOLTIP_HEIGHT_MIN + Constants.TOOLTIP_BORDER_WIDTH);
desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER);
@ -474,13 +470,15 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
cardPreviewContainer.setOpaque(false);
cardPreviewContainer.setLayout(null);
BigCard bigCard = new BigCard();
bigCard.setSize(320, 500);
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, 320 + 80, 500 + 30);
cardPreviewContainer.setBounds(0, 0, width + 80, height + 30);
UI.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard);
UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer);
@ -492,12 +490,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
cardPreviewContainerRotated.setOpaque(false);
cardPreviewContainerRotated.setLayout(null);
bigCard = new BigCard(true);
bigCard.setSize(500, 350);
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, 500 + 80, 420 + 30);
cardPreviewContainerRotated.setBounds(0, 0, height + 80, width + 100 + 30);
UI.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCard);
UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated);
@ -506,6 +504,28 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
private void setGUISizeTooltipContainer() {
try {
int height = GUISizeHelper.enlargedImageHeight;
int width = (int) ((float) height * (float) 0.64);
JPanel cardPreviewContainer = (JPanel) UI.getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
cardPreviewContainer.setBounds(0, 0, width + 80, height + 30);
BigCard bigCard = (BigCard) UI.getComponent(MageComponents.CARD_PREVIEW_PANE);
bigCard.setSize(width, height);
JPanel cardPreviewContainerRotated = (JPanel) UI.getComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED);
cardPreviewContainerRotated.setBounds(0, 0, height + 80, width + 100 + 30);
BigCard bigCardRotated = (BigCard) UI.getComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED);
bigCardRotated.setSize(height, width + 30);
} catch (Exception e) {
LOGGER.warn("Error while changing tooltip container size.", e);
}
}
private void setBackground() {
if (liteMode || grayMode) {
return;
@ -1116,11 +1136,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (setActive) {
setActive(tablesPane);
} else // if other panel was already shown, mamke sure it's topmost again
{
if (topPanebefore != null) {
if (topPanebefore != null) {
setActive(topPanebefore);
}
}
}
public void hideGames() {
@ -1504,6 +1522,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void changeGUISize() {
ImageCaches.flush();
setGUISize();
setGUISizeTooltipContainer();
Plugins.getInstance().changeGUISize();
CountryUtil.changeGUISize();
for (Component component : desktopPane.getComponents()) {
@ -1557,6 +1578,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
balloonTip.setFont(GUISizeHelper.balloonTooltipFont);
addTooltipContainer();
}
}

View file

@ -7,8 +7,8 @@ import javax.swing.JButton;
public class MageUI {
private final Map<MageComponents, Component> ui = new EnumMap<MageComponents, Component>(MageComponents.class);
private final Map<MageComponents, Object> sync = new EnumMap<MageComponents, Object>(MageComponents.class);
private final Map<MageComponents, Component> ui = new EnumMap<>(MageComponents.class);
private final Map<MageComponents, Object> sync = new EnumMap<>(MageComponents.class);
public JButton getButton(MageComponents name) throws InterruptedException {
//System.out.println("request for " + name);
@ -63,7 +63,7 @@ public class MageUI {
if (sync.containsKey(name)) {
synchronized (sync.get(name)) {
//System.out.println("notifyAll - " + name);
sync.get(name).notifyAll();
sync.get(name).notifyAll();
}
}
}
@ -80,7 +80,7 @@ public class MageUI {
ui.put(name, component);
if (sync.containsKey(name)) {
synchronized (sync.get(name)) {
sync.get(name).notifyAll();
sync.get(name).notifyAll();
}
}
}
@ -96,7 +96,7 @@ public class MageUI {
while (!j.isEnabled()) {
Thread.sleep(10);
}
Thread t = new Thread(new Runnable() {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
j.doClick();

View file

@ -98,6 +98,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_GUI_CARD_HAND_SIZE = "guiCardHandSize";
public static final String KEY_GUI_CARD_EDITOR_SIZE = "guiCardEditorSize";
public static final String KEY_GUI_CARD_OFFSET_SIZE = "guiCardOffsetSize";
public static final String KEY_GUI_ENLARGED_IMAGE_SIZE = "guiEnlargedImageSize";
public static final String KEY_GUI_STACK_WIDTH = "guiStackWidth";
public static final String KEY_GUI_TOOLTIP_SIZE = "guiTooltipSize";
@ -392,6 +393,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
labelEditorCardSize = new javax.swing.JLabel();
sliderEditorCardOffset = new javax.swing.JSlider();
labelEditorCardOffset = new javax.swing.JLabel();
sliderEnlargedImageSize = new javax.swing.JSlider();
labelEnlargedImageSize = new javax.swing.JLabel();
guiSizeGame = new javax.swing.JPanel();
sliderCardSizeHand = new javax.swing.JSlider();
labelCardSizeHand = new javax.swing.JLabel();
@ -447,7 +450,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
btnBrowseImageLocation = new javax.swing.JButton();
cbCheckForNewImages = new javax.swing.JCheckBox();
cbSaveToZipFiles = new javax.swing.JCheckBox();
cbPreferedImageLanguage = new javax.swing.JComboBox<String>();
cbPreferedImageLanguage = new javax.swing.JComboBox<>();
labelPreferedImageLanguage = new javax.swing.JLabel();
labelNumberOfDownloadThreads = new javax.swing.JLabel();
cbNumberOfDownloadThreads = new javax.swing.JComboBox();
@ -505,7 +508,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtURLServerList = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
lblProxyType = new javax.swing.JLabel();
cbProxyType = new javax.swing.JComboBox<ProxyType>();
cbProxyType = new javax.swing.JComboBox<>();
pnlProxySettings = new javax.swing.JPanel();
pnlProxy = new javax.swing.JPanel();
lblProxyServer = new javax.swing.JLabel();
@ -559,7 +562,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(main_cardLayout.createSequentialGroup()
.add(6, 6, 6)
.add(main_cardLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(tooltipDelayLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 308, Short.MAX_VALUE)
.add(tooltipDelayLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, showCardName)
.add(tooltipDelay, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
@ -912,6 +915,35 @@ public class PreferencesDialog extends javax.swing.JDialog {
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
guiSizeBasic.add(labelEditorCardOffset, gridBagConstraints);
sliderEnlargedImageSize.setMajorTickSpacing(5);
sliderEnlargedImageSize.setMaximum(50);
sliderEnlargedImageSize.setMinimum(10);
sliderEnlargedImageSize.setMinorTickSpacing(1);
sliderEnlargedImageSize.setPaintLabels(true);
sliderEnlargedImageSize.setPaintTicks(true);
sliderEnlargedImageSize.setSnapToTicks(true);
sliderEnlargedImageSize.setToolTipText("<HTML>The size of the image shown for the card your mouse pointer<br>is located over while you turn the mouse wheel ");
sliderEnlargedImageSize.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderEnlargedImageSize.setMinimumSize(new java.awt.Dimension(150, 40));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
guiSizeBasic.add(sliderEnlargedImageSize, gridBagConstraints);
labelEnlargedImageSize.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
labelEnlargedImageSize.setText("Enlarged image (mouse wheel)");
labelEnlargedImageSize.setToolTipText("<HTML>The size of the image shown for the card your mouse pointer<br>is located over while you turn the mouse wheel\n");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.ipadx = 3;
gridBagConstraints.ipady = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
guiSizeBasic.add(labelEnlargedImageSize, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
@ -1391,7 +1423,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
labelPreferedImageLanguage.setText("Prefered image language:");
labelPreferedImageLanguage.setFocusable(false);
@ -1429,7 +1461,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(org.jdesktop.layout.GroupLayout.LEADING, cbSaveToZipFiles))
.add(40, 40, 40)
.add(cbPreferedImageLanguage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(0, 142, Short.MAX_VALUE)))
.add(0, 251, Short.MAX_VALUE)))
.addContainerGap())
);
panelCardImagesLayout.setVerticalGroup(
@ -1453,7 +1485,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(panelCardImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(cbPreferedImageLanguage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(labelPreferedImageLanguage))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(48, Short.MAX_VALUE))
);
panelBackgroundImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Background images setting:"));
@ -1575,7 +1607,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabImagesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabImagesLayout.createSequentialGroup()
.addContainerGap()
.add(panelCardImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 231, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(panelCardImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(panelBackgroundImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(90, Short.MAX_VALUE))
@ -2188,7 +2220,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(connection_serversLayout.createSequentialGroup()
.add(141, 141, 141)
.add(jLabel17)))
.addContainerGap(67, Short.MAX_VALUE))
.addContainerGap(111, Short.MAX_VALUE))
);
connection_serversLayout.setVerticalGroup(
connection_serversLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -2374,7 +2406,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(exitButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(6, 6, 6))
.add(tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 584, Short.MAX_VALUE)
.add(tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -2428,6 +2460,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.sliderEditorCardOffset, KEY_GUI_CARD_OFFSET_SIZE, "true", "false", UPDATE_CACHE_POLICY);
sizeGUIChanged = true;
}
if (getCachedValue(KEY_GUI_ENLARGED_IMAGE_SIZE, 20) != dialog.sliderEnlargedImageSize.getValue()) {
save(prefs, dialog.sliderEnlargedImageSize, KEY_GUI_ENLARGED_IMAGE_SIZE, "true", "false", UPDATE_CACHE_POLICY);
sizeGUIChanged = true;
}
if (getCachedValue(KEY_GUI_STACK_WIDTH, 30) != dialog.sliderStackWidth.getValue()) {
save(prefs, dialog.sliderStackWidth, KEY_GUI_STACK_WIDTH, "true", "false", UPDATE_CACHE_POLICY);
sizeGUIChanged = true;
@ -2941,6 +2977,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.sliderCardSizeHand, KEY_GUI_CARD_HAND_SIZE, "14");
load(prefs, dialog.sliderEditorCardSize, KEY_GUI_CARD_EDITOR_SIZE, "14");
load(prefs, dialog.sliderEditorCardOffset, KEY_GUI_CARD_OFFSET_SIZE, "14");
load(prefs, dialog.sliderEnlargedImageSize, KEY_GUI_ENLARGED_IMAGE_SIZE, "20");
load(prefs, dialog.sliderStackWidth, KEY_GUI_STACK_WIDTH, "14");
load(prefs, dialog.sliderDialogFont, KEY_GUI_DIALOG_FONT_SIZE, "14");
load(prefs, dialog.sliderTooltipSize, KEY_GUI_TOOLTIP_SIZE, "14");
@ -3437,6 +3474,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JLabel labelDialogFont;
private javax.swing.JLabel labelEditorCardOffset;
private javax.swing.JLabel labelEditorCardSize;
private javax.swing.JLabel labelEnlargedImageSize;
private javax.swing.JLabel labelGameFeedback;
private javax.swing.JLabel labelNumberOfDownloadThreads;
private javax.swing.JLabel labelPreferedImageLanguage;
@ -3470,6 +3508,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JSlider sliderDialogFont;
private javax.swing.JSlider sliderEditorCardOffset;
private javax.swing.JSlider sliderEditorCardSize;
private javax.swing.JSlider sliderEnlargedImageSize;
private javax.swing.JSlider sliderFontSize;
private javax.swing.JSlider sliderGameFeedbackArea;
private javax.swing.JSlider sliderStackWidth;

View file

@ -74,6 +74,7 @@ public class GUISizeHelper {
public static Dimension editorCardDimension;
public static int editorCardOffsetSize;
public static int enlargedImageHeight;
public static int getTableRowHeight() {
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_TABLE_FONT_SIZE, 14);
@ -153,6 +154,8 @@ public class GUISizeHelper {
int editorCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_EDITOR_SIZE, 14);
editorCardDimension = new Dimension(CARD_IMAGE_WIDTH * editorCardSize / 42, CARD_IMAGE_HEIGHT * editorCardSize / 42);
editorCardOffsetSize = 2 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OFFSET_SIZE, 14) - 10;
enlargedImageHeight = 25 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_ENLARGED_IMAGE_SIZE, 20);
}
public static void changePopupMenuFont(JPopupMenu popupMenu) {