diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 3492c94478..70e9ba435a 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -179,7 +179,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { private static long startTime; - private BalloonTip balloonTip; + private final BalloonTip balloonTip; /** * @return the session @@ -306,6 +306,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { // balloonTip = new BalloonTip(desktopPane, "", new ModernBalloonStyle(0, 0, Color.WHITE, Color.YELLOW, Color.BLUE), false); balloonTip = new BalloonTip(desktopPane, "", new EdgedBalloonStyle(Color.WHITE, Color.BLUE), false); balloonTip.setPositioner(new LeftAbovePositioner(0, 0)); + balloonTip.setVisible(false); mageToolbar.add(new javax.swing.JToolBar.Separator()); mageToolbar.add(createWindowsButton()); @@ -1272,6 +1273,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { CHATS.remove(chatId); } + public static Map getChatPanels() { + return CHATS; + } + public static void addGame(UUID gameId, GamePanel gamePanel) { GAMES.put(gameId, gamePanel); } diff --git a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.form b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.form index 70c347f063..0e82ed56e0 100644 --- a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.form +++ b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.form @@ -1,6 +1,6 @@ -
+ @@ -16,17 +16,16 @@ - - + + - - - - + + + @@ -35,7 +34,12 @@ - + + + + + + @@ -61,6 +65,18 @@ + + + + + + + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java index b096fef13c..1cca880714 100644 --- a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java +++ b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java @@ -26,7 +26,7 @@ * or implied, of BetaSteward_at_googlemail.com. */ -/* + /* * ChatPanel.java * * Created on 15-Dec-2009, 11:04:31 PM @@ -34,10 +34,13 @@ package mage.client.chat; import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; import java.awt.event.KeyEvent; import java.util.UUID; import javax.swing.JTextField; import mage.client.MageFrame; +import mage.client.util.FontSizeHelper; import mage.remote.Session; import mage.view.ChatMessage.MessageColor; import mage.view.ChatMessage.MessageType; @@ -119,7 +122,7 @@ public class ChatPanelBasic extends javax.swing.JPanel { public ChatPanelBasic() { initComponents(); setBackground(new Color(0, 0, 0, CHAT_ALPHA)); - + changeGUISize(FontSizeHelper.getChatFont()); if (jScrollPaneTxt != null) { jScrollPaneTxt.setBackground(new Color(0, 0, 0, CHAT_ALPHA)); jScrollPaneTxt.getViewport().setBackground(new Color(0, 0, 0, CHAT_ALPHA)); @@ -130,6 +133,24 @@ public class ChatPanelBasic extends javax.swing.JPanel { } + public void changeGUISize(Font font) { + txtConversation.setFont(font); + txtMessage.setFont(font); + if (jScrollPaneTxt != null) { + jScrollPaneTxt.setFont(font); + } + int height = 30; + if (font.getSize() > 20) { + height = 30 + Math.min(font.getSize() - 10, 30); + } + txtMessage.setMinimumSize(new Dimension(txtMessage.getWidth(), height)); + txtMessage.setMaximumSize(new Dimension(txtMessage.getWidth(), height)); + txtMessage.setPreferredSize(new Dimension(txtMessage.getWidth(), height)); + txtMessage.setSize(new Dimension(txtMessage.getWidth(), height)); + this.revalidate(); + this.repaint(); + } + public ChatType getChatType() { return chatType; } @@ -212,13 +233,7 @@ public class ChatPanelBasic extends javax.swing.JPanel { } protected String getColoredText(String color, String text) { - StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append(text); - sb.append(""); - return sb.toString(); + return "" + text + ""; } public String getText() { @@ -285,7 +300,8 @@ public class ChatPanelBasic extends javax.swing.JPanel { txtConversation = new mage.client.components.ColorPane(); txtMessage = new javax.swing.JTextField(); - jScrollPaneTxt.setBorder(null); + jScrollPaneTxt.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); + jScrollPaneTxt.setPreferredSize(new java.awt.Dimension(32767, 32767)); txtConversation.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); txtConversation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N @@ -294,6 +310,10 @@ public class ChatPanelBasic extends javax.swing.JPanel { txtConversation.setOpaque(false); jScrollPaneTxt.setViewportView(txtConversation); + txtMessage.setMaximumSize(new java.awt.Dimension(5000, 60)); + txtMessage.setMinimumSize(new java.awt.Dimension(6, 60)); + txtMessage.setName(""); // NOI18N + txtMessage.setPreferredSize(new java.awt.Dimension(6, 60)); txtMessage.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { txtMessageKeyTyped(evt); @@ -304,18 +324,15 @@ public class ChatPanelBasic extends javax.swing.JPanel { this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(txtMessage) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) - .addGap(0, 0, 0)) + .addComponent(jScrollPaneTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(txtMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE) .addGap(0, 0, 0) - .addComponent(txtMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0)) + .addComponent(txtMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); }// //GEN-END:initComponents diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form index dcbf9fe737..8c64527d2c 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form @@ -384,6 +384,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java index bac599ff4a..2a296082f6 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java @@ -26,7 +26,7 @@ * or implied, of BetaSteward_at_googlemail.com. */ -/* + /* * PreferencesDialog.java * * Created on 26.06.2011, 16:35:40 @@ -60,6 +60,7 @@ import javax.swing.border.Border; import javax.swing.filechooser.FileFilter; import mage.client.MageFrame; import mage.client.util.Config; +import mage.client.util.FontSizeHelper; import mage.client.util.ImageHelper; import mage.client.util.gui.BufferedImageBuilder; import static mage.constants.Constants.DEFAULT_AVATAR_ID; @@ -79,7 +80,7 @@ import org.apache.log4j.Logger; */ public class PreferencesDialog extends javax.swing.JDialog { - private static final Logger log = Logger.getLogger(PreferencesDialog.class); + private static final Logger LOGGER = Logger.getLogger(PreferencesDialog.class); public static final String KEY_HAND_USE_BIG_CARDS = "handUseBigCards"; public static final String KEY_SHOW_TOOLTIPS_DELAY = "showTooltipsDelay"; @@ -92,6 +93,8 @@ public class PreferencesDialog extends javax.swing.JDialog { public static final String KEY_GAME_CONFIRM_EMPTY_MANA_POOL = "gameConfirmEmptyManaPool"; public static final String KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER = "gameAskMoveToGraveORder"; + public static final String KEY_GUI_FONT_SIZE = "guiFontSize"; + public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave"; public static final String KEY_DRAFT_LOG_AUTO_SAVE = "draftLogAutoSave"; @@ -355,6 +358,10 @@ public class PreferencesDialog extends javax.swing.JDialog { main_gamelog = new javax.swing.JPanel(); cbGameLogAutoSave = new javax.swing.JCheckBox(); cbDraftLogAutoSave = new javax.swing.JCheckBox(); + tabGuiSize = new javax.swing.JPanel(); + guiSize_font = new javax.swing.JPanel(); + fontSizeLabel = new javax.swing.JLabel(); + sliderFontSize = new javax.swing.JSlider(); tabPhases = new javax.swing.JPanel(); jLabelHeadLine = new javax.swing.JLabel(); jLabelYourTurn = new javax.swing.JLabel(); @@ -395,7 +402,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(); + cbPreferedImageLanguage = new javax.swing.JComboBox<>(); labelPreferedImageLanguage = new javax.swing.JLabel(); panelBackgroundImages = new javax.swing.JPanel(); cbUseDefaultBackground = new javax.swing.JCheckBox(); @@ -447,7 +454,7 @@ public class PreferencesDialog extends javax.swing.JDialog { jPanel33 = new javax.swing.JPanel(); tabConnection = new javax.swing.JPanel(); lblProxyType = new javax.swing.JLabel(); - cbProxyType = new javax.swing.JComboBox(); + cbProxyType = new javax.swing.JComboBox<>(); pnlProxySettings = new javax.swing.JPanel(); pnlProxy = new javax.swing.JPanel(); lblProxyServer = new javax.swing.JLabel(); @@ -710,6 +717,43 @@ public class PreferencesDialog extends javax.swing.JDialog { tabsPanel.addTab("Main", tabMain); + guiSize_font.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Font")); + guiSize_font.setLayout(new java.awt.BorderLayout()); + + fontSizeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + fontSizeLabel.setText("Font Size"); + fontSizeLabel.setToolTipText("The size of the font used to display text."); + guiSize_font.add(fontSizeLabel, java.awt.BorderLayout.CENTER); + + sliderFontSize.setMajorTickSpacing(1); + sliderFontSize.setMaximum(30); + sliderFontSize.setMinimum(10); + sliderFontSize.setMinorTickSpacing(1); + sliderFontSize.setPaintLabels(true); + sliderFontSize.setPaintTicks(true); + sliderFontSize.setSnapToTicks(true); + sliderFontSize.setToolTipText("The time the appearance of the tooltip window for a card is delayed.
\nIf set to zero, the tooltip window won't be shown at all."); + guiSize_font.add(sliderFontSize, java.awt.BorderLayout.PAGE_START); + + javax.swing.GroupLayout tabGuiSizeLayout = new javax.swing.GroupLayout(tabGuiSize); + tabGuiSize.setLayout(tabGuiSizeLayout); + tabGuiSizeLayout.setHorizontalGroup( + tabGuiSizeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(tabGuiSizeLayout.createSequentialGroup() + .addContainerGap() + .addComponent(guiSize_font, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + tabGuiSizeLayout.setVerticalGroup( + tabGuiSizeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(tabGuiSizeLayout.createSequentialGroup() + .addContainerGap() + .addComponent(guiSize_font, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(332, Short.MAX_VALUE)) + ); + + tabsPanel.addTab("GUI Size", tabGuiSize); + jLabelHeadLine.setText("Choose phases your game will stop on if not skipped by a skip action (e.g. F6):"); jLabelYourTurn.setText("Your turn"); @@ -956,7 +1000,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); @@ -1950,6 +1994,12 @@ public class PreferencesDialog extends javax.swing.JDialog { save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.cbDraftLogAutoSave, KEY_DRAFT_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY); + // GUI Size + if (getCachedValue(KEY_GUI_FONT_SIZE, 14) != dialog.sliderFontSize.getValue()) { + save(prefs, dialog.sliderFontSize, KEY_GUI_FONT_SIZE, "true", "false", UPDATE_CACHE_POLICY); + FontSizeHelper.updateGUI(); + } + // Phases & Priority save(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU); save(prefs, dialog.checkBoxDrawYou, DRAW_YOU); @@ -2320,10 +2370,11 @@ public class PreferencesDialog extends javax.swing.JDialog { connection.setProxyPassword(password); } } else { - log.warn("host or\\and port are empty: host=" + host + ", port=" + port); + LOGGER.warn("host or\\and port are empty: host=" + host + ", port=" + port); } } } + /** * @param args the command line arguments */ @@ -2348,6 +2399,9 @@ public class PreferencesDialog extends javax.swing.JDialog { // Main & Phases loadPhases(prefs); + // Gui Size + loadGuiSize(prefs); + // Images loadImagesSettings(prefs); @@ -2415,6 +2469,10 @@ public class PreferencesDialog extends javax.swing.JDialog { } + private static void loadGuiSize(Preferences prefs) { + load(prefs, dialog.sliderFontSize, KEY_GUI_FONT_SIZE, "14"); + } + private static void loadImagesSettings(Preferences prefs) { String prop = prefs.get(KEY_CARD_IMAGES_USE_DEFAULT, "true"); if (prop.equals("true")) { @@ -2731,7 +2789,7 @@ public class PreferencesDialog extends javax.swing.JDialog { addAvatar(jPanel32, 32, false, false); } catch (Exception e) { - log.error(e, e); + LOGGER.error(e, e); } } @@ -2850,6 +2908,8 @@ public class PreferencesDialog extends javax.swing.JDialog { private javax.swing.JPanel connection_servers; private javax.swing.JCheckBox displayBigCardsInHand; private javax.swing.JButton exitButton; + private javax.swing.JLabel fontSizeLabel; + private javax.swing.JPanel guiSize_font; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; @@ -2910,10 +2970,12 @@ public class PreferencesDialog extends javax.swing.JDialog { private javax.swing.JCheckBox showAbilityPickerForced; private javax.swing.JCheckBox showCardName; private javax.swing.JCheckBox showPlayerNamesPermanently; + private javax.swing.JSlider sliderFontSize; private javax.swing.JPanel sounds_backgroundMusic; private javax.swing.JPanel sounds_clips; private javax.swing.JPanel tabAvatars; private javax.swing.JPanel tabConnection; + private javax.swing.JPanel tabGuiSize; private javax.swing.JPanel tabImages; private javax.swing.JPanel tabMain; private javax.swing.JPanel tabPhases; diff --git a/Mage.Client/src/main/java/mage/client/util/FontSizeHelper.java b/Mage.Client/src/main/java/mage/client/util/FontSizeHelper.java new file mode 100644 index 0000000000..b10e01b575 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/util/FontSizeHelper.java @@ -0,0 +1,29 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.client.util; + +import java.awt.Font; +import mage.client.MageFrame; +import mage.client.chat.ChatPanelBasic; +import mage.client.dialog.PreferencesDialog; + +/** + * + * @author LevelX2 + */ +public class FontSizeHelper { + + public static Font getChatFont() { + int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14); + return new java.awt.Font("Arial", 0, fontSize); + } + + public static void updateGUI() { + for (ChatPanelBasic chatPanel : MageFrame.getChatPanels().values()) { + chatPanel.changeGUISize(getChatFont()); + } + } +}