forked from External/mage
Some more changes to GUI to better support high screen resolutions.
This commit is contained in:
parent
1c2faaadde
commit
7ef0a0a7f0
31 changed files with 745 additions and 518 deletions
|
|
@ -6,33 +6,23 @@ import javax.swing.*;
|
|||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.constants.Zone;
|
||||
import mage.view.CardsView;
|
||||
|
||||
public class HandPanel extends JPanel {
|
||||
|
||||
private static final int CARD_WIDTH = 75;
|
||||
private static final double ASPECT_RATIO = 3.5 / 2.5;
|
||||
private static final int HAND_MIN_CARDS_OFFSET_Y = -10;
|
||||
|
||||
private boolean smallMode = false;
|
||||
private Dimension handCardDimensionBig;
|
||||
private Dimension handCardDimension;
|
||||
|
||||
public HandPanel() {
|
||||
double factor = 1;
|
||||
initComponents();
|
||||
changeGUISize();
|
||||
sizeHand(factor, false);
|
||||
}
|
||||
|
||||
public void initComponents() {
|
||||
hand = new mage.client.cards.Cards(true);
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
hand.setMinOffsetY(HAND_MIN_CARDS_OFFSET_Y);
|
||||
hand.setCardDimension(GUISizeHelper.handCardDimension);
|
||||
|
||||
jPanel = new JPanel();
|
||||
jScrollPane1 = new JScrollPane(jPanel);
|
||||
|
|
@ -46,11 +36,11 @@ public class HandPanel extends JPanel {
|
|||
jPanel.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
|
||||
jPanel.setBorder(emptyBorder);
|
||||
jScrollPane1.setBorder(emptyBorder);
|
||||
jPanel.setBorder(EMPTY_BORDER);
|
||||
jScrollPane1.setBorder(EMPTY_BORDER);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(8);
|
||||
jScrollPane1.setViewportBorder(emptyBorder);
|
||||
jScrollPane1.setViewportBorder(EMPTY_BORDER);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(jScrollPane1, BorderLayout.CENTER);
|
||||
|
|
@ -58,7 +48,7 @@ public class HandPanel extends JPanel {
|
|||
hand.setHScrollSpeed(8);
|
||||
hand.setBackgroundColor(new Color(0, 0, 0, 0));
|
||||
hand.setVisibleIfEmpty(false);
|
||||
hand.setBorder(emptyBorder);
|
||||
hand.setBorder(EMPTY_BORDER);
|
||||
hand.setZone(Zone.HAND.toString());
|
||||
}
|
||||
|
||||
|
|
@ -71,36 +61,19 @@ public class HandPanel extends JPanel {
|
|||
}
|
||||
|
||||
private void setGUISize() {
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(FontSizeHelper.scrollBarSize, 0));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, FontSizeHelper.scrollBarSize));
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||
hand.setCardDimension(GUISizeHelper.handCardDimension);
|
||||
hand.changeGUISize();
|
||||
}
|
||||
|
||||
public void loadCards(CardsView cards, BigCard bigCard, UUID gameId) {
|
||||
hand.loadCards(cards, bigCard, gameId, true);
|
||||
hand.sizeCards(getHandCardDimension());
|
||||
}
|
||||
|
||||
private Dimension getHandCardDimension() {
|
||||
String useBigCards = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_HAND_USE_BIG_CARDS, "true");
|
||||
if (!smallMode && useBigCards.equals("true")) {
|
||||
return handCardDimensionBig;
|
||||
}
|
||||
return handCardDimension;
|
||||
}
|
||||
|
||||
public void sizeHand(double factor, boolean smallMode) {
|
||||
this.smallMode = smallMode;
|
||||
int width = (int) (factor * CARD_WIDTH);
|
||||
int bigWidth = (int) (Config.handScalingFactor * CARD_WIDTH);
|
||||
handCardDimension = new Dimension(width, (int) (width * ASPECT_RATIO));
|
||||
handCardDimensionBig = new Dimension(bigWidth, (int) (bigWidth * ASPECT_RATIO));
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
hand.sizeCards(getHandCardDimension());
|
||||
}
|
||||
|
||||
private JPanel jPanel;
|
||||
private JScrollPane jScrollPane1;
|
||||
private static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
|
||||
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
|
||||
private mage.client.cards.Cards hand;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue