Sizable GUI - game dialog area elements resize now.

This commit is contained in:
LevelX2 2016-02-20 02:31:47 +01:00
parent e15807b9ed
commit 249d709cc7
4 changed files with 40 additions and 28 deletions

View file

@ -97,11 +97,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
} }
private void setGUISize() { private void setGUISize() {
btnLeft.setFont(GUISizeHelper.gameDialogAreaFont);
btnRight.setFont(GUISizeHelper.gameDialogAreaFont);
btnSpecial.setFont(GUISizeHelper.gameDialogAreaFont);
btnUndo.setFont(GUISizeHelper.gameDialogAreaFont);
helper.changeGUISize(); helper.changeGUISize();
} }

View file

@ -380,9 +380,8 @@ public final class GamePanel extends javax.swing.JPanel {
jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize); jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize);
jSplitPane2.setDividerSize(GUISizeHelper.dividerBarSize); jSplitPane2.setDividerSize(GUISizeHelper.dividerBarSize);
feedbackAreaHeight = GUISizeHelper.gameDialogAreaFontSizeBig + GUISizeHelper.gameDialogAreaFontSizeSmall + GUISizeHelper.gameDialogAreaButtonHigh + 50; feedbackAreaHeight = GUISizeHelper.gameDialogAreaFontSizeBig + GUISizeHelper.gameDialogAreaFontSizeSmall + GUISizeHelper.gameDialogAreaButtonHigh + 60;
helper.setPreferredSize(new Dimension(100, feedbackAreaHeight)); helper.setPreferredSize(new Dimension(100, feedbackAreaHeight));
stackObjects.setCardDimension(GUISizeHelper.handCardDimension); stackObjects.setCardDimension(GUISizeHelper.handCardDimension);
int newStackWidth = jPanel3.getWidth() * GUISizeHelper.stackWidth / 100; int newStackWidth = jPanel3.getWidth() * GUISizeHelper.stackWidth / 100;
if (newStackWidth < 360) { if (newStackWidth < 360) {

View file

@ -30,7 +30,7 @@ package mage.client.game;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridBagLayout; import java.awt.FlowLayout;
import java.awt.Point; import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -69,9 +69,9 @@ public class HelperPanel extends JPanel {
private javax.swing.JButton btnRight; private javax.swing.JButton btnRight;
private javax.swing.JButton btnSpecial; private javax.swing.JButton btnSpecial;
private javax.swing.JButton btnUndo; private javax.swing.JButton btnUndo;
//private javax.swing.JButton btnEndTurn; //private javax.swing.JButton btnEndTurn;
//private javax.swing.JButton btnStopTimer; //private javax.swing.JButton btnStopTimer;
private MageTextArea textArea; private MageTextArea textArea;
JPanel buttonContainer; JPanel buttonContainer;
@ -114,52 +114,66 @@ public class HelperPanel extends JPanel {
} }
private void setGUISize() { private void setGUISize() {
buttonContainer.setPreferredSize(new Dimension(100, GUISizeHelper.gameDialogAreaFont.getSize() + 10)); buttonContainer.setPreferredSize(new Dimension(getWidth(), GUISizeHelper.gameDialogButtonHeight + 20));
buttonContainer.setMinimumSize(new Dimension(160, GUISizeHelper.gameDialogButtonHeight + 20));
buttonContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, GUISizeHelper.gameDialogButtonHeight + 20));
Dimension buttonDimension = new Dimension(GUISizeHelper.gameDialogButtonWidth, GUISizeHelper.gameDialogButtonHeight);
btnLeft.setFont(GUISizeHelper.gameDialogAreaFont); btnLeft.setFont(GUISizeHelper.gameDialogAreaFont);
btnRight.setFont(GUISizeHelper.gameDialogAreaFont); btnRight.setFont(GUISizeHelper.gameDialogAreaFont);
btnSpecial.setFont(GUISizeHelper.gameDialogAreaFont); btnSpecial.setFont(GUISizeHelper.gameDialogAreaFont);
btnUndo.setFont(GUISizeHelper.gameDialogAreaFont); btnUndo.setFont(GUISizeHelper.gameDialogAreaFont);
if (message != null) {
int pos = this.message.indexOf("font-size:");
if (pos > 0) {
String newMessage = this.message.substring(0, pos + 10) + GUISizeHelper.gameDialogAreaFontSizeBig + this.message.substring(pos + 12);
pos = this.message.indexOf("font-size:", pos + 10);
if (pos > 0) {
newMessage = this.message.substring(0, pos + 10) + GUISizeHelper.gameDialogAreaFontSizeSmall + this.message.substring(pos + 12);
}
setBasicMessage(newMessage);
}
}
GUISizeHelper.changePopupMenuFont(popupMenuAskNo); GUISizeHelper.changePopupMenuFont(popupMenuAskNo);
GUISizeHelper.changePopupMenuFont(popupMenuAskYes); GUISizeHelper.changePopupMenuFont(popupMenuAskYes);
revalidate();
repaint();
} }
private void initComponents() { private void initComponents() {
initPopupMenuTriggerOrder(); initPopupMenuTriggerOrder();
setBackground(new Color(0, 0, 0, 100)); setBackground(new Color(0, 0, 0, 100));
//setLayout(new GridBagLayout()); // setBorder(new LineBorder(Color.WHITE, 1));
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
setOpaque(false); setOpaque(false);
buttonContainer = new JPanel();
// buttonContainer.setBorder(new LineBorder(Color.RED, 1));
buttonContainer.setPreferredSize(new Dimension(100, 30));
buttonContainer.setMinimumSize(new Dimension(20, 20));
buttonContainer.setMaximumSize(new Dimension(2000, 100));
buttonContainer.setLayout(new GridBagLayout());
buttonContainer.setOpaque(false);
JPanel jPanel = new JPanel();
textArea = new MageTextArea(); textArea = new MageTextArea();
// textArea.setBorder(new LineBorder(Color.GREEN, 1));
textArea.setText("<Empty>"); textArea.setText("<Empty>");
add(textArea);
jPanel.setOpaque(false); buttonContainer = new JPanel();
jPanel.setBackground(new Color(0, 0, 0, 80)); // buttonContainer.setBorder(new LineBorder(Color.RED, 1));
jPanel.add(textArea); buttonContainer.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 0));
add(jPanel); buttonContainer.setOpaque(false);
add(buttonContainer); add(buttonContainer);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
btnSpecial = new JButton("Special"); btnSpecial = new JButton("Special");
btnSpecial.setVisible(false); btnSpecial.setVisible(false);
buttonContainer.add(btnSpecial); buttonContainer.add(btnSpecial);
btnLeft = new JButton("OK"); btnLeft = new JButton("OK");
btnLeft.setVisible(false); btnLeft.setVisible(false);
buttonContainer.add(btnLeft); buttonContainer.add(btnLeft);
btnRight = new JButton("Cancel"); btnRight = new JButton("Cancel");
btnRight.setVisible(false); btnRight.setVisible(false);
buttonContainer.add(btnRight); buttonContainer.add(btnRight);
btnUndo = new JButton("Undo"); btnUndo = new JButton("Undo");
btnUndo.setVisible(false); btnUndo.setVisible(false);
buttonContainer.add(btnUndo); buttonContainer.add(btnUndo);

View file

@ -57,6 +57,8 @@ public class GUISizeHelper {
public static int gameDialogAreaFontSizeSmall = 11; public static int gameDialogAreaFontSizeSmall = 11;
public static int gameDialogAreaButtonHigh = 16; public static int gameDialogAreaButtonHigh = 16;
public static Font gameDialogAreaFont = new java.awt.Font("Arial", 0, 12); public static Font gameDialogAreaFont = new java.awt.Font("Arial", 0, 12);
public static int gameDialogButtonHeight;
public static int gameDialogButtonWidth;
public static Dimension handCardDimension; public static Dimension handCardDimension;
public static int stackWidth; public static int stackWidth;
@ -111,7 +113,9 @@ public class GUISizeHelper {
gameDialogAreaFontSizeTooltip = feedbackFontSize - 2; gameDialogAreaFontSizeTooltip = feedbackFontSize - 2;
gameDialogAreaFontSizeSmall = (feedbackFontSize / 2) + 2; gameDialogAreaFontSizeSmall = (feedbackFontSize / 2) + 2;
gameDialogAreaButtonHigh = feedbackFontSize; gameDialogAreaButtonHigh = feedbackFontSize;
gameDialogAreaFont = new Font("Arial", 0, dialogFontSize); gameDialogAreaFont = new Font("Arial", 0, feedbackFontSize);
gameDialogButtonHeight = feedbackFontSize + 6;
gameDialogButtonWidth = feedbackFontSize * 2 + 40;
int chatFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CHAT_FONT_SIZE, 14); int chatFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CHAT_FONT_SIZE, 14);
chatFont = new java.awt.Font("Arial", 0, chatFontSize); chatFont = new java.awt.Font("Arial", 0, chatFontSize);