mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
fixed large hand cards + improved resizing
This commit is contained in:
parent
70421439f0
commit
e911f0b662
4 changed files with 28 additions and 21 deletions
|
|
@ -158,15 +158,19 @@ public class Cards extends javax.swing.JPanel {
|
|||
if (!isVisibleIfEmpty) {
|
||||
cardArea.setVisible(cards.size() > 0);
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension((int)(cards.size() * (getCardDimension().getWidth() + GAP_X)), (int)(getCardDimension().getHeight())));
|
||||
cardArea.revalidate();
|
||||
cardArea.repaint();
|
||||
sizeCards(getCardDimension());
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public void sizeCards(Dimension cardDimension) {
|
||||
cardArea.setPreferredSize(new Dimension((int)(cards.size() * (cardDimension.getWidth() + GAP_X)) + 5, (int)(cardDimension.getHeight()) + 20));
|
||||
cardArea.revalidate();
|
||||
cardArea.repaint();
|
||||
}
|
||||
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
|
|
@ -254,7 +258,8 @@ public class Cards extends javax.swing.JPanel {
|
|||
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
}
|
||||
layoutCards(cardDimension);
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ import mage.client.cards.BigCard;
|
|||
import mage.client.cards.Permanent;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.game.permanent.Battlefield;
|
||||
import mage.view.PermanentView;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
bigCard.setPreferredSize(bbDimension);
|
||||
pnlGameInfo.revalidate();
|
||||
pnlGameInfo.repaint();
|
||||
this.handContainer.sizeHand(0.6);
|
||||
this.handContainer.sizeHand(0.8, smallMode);
|
||||
for (PlayAreaPanel p: players.values()) {
|
||||
p.sizePlayer();
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
bigCard.setPreferredSize(bbDimension);
|
||||
pnlGameInfo.revalidate();
|
||||
pnlGameInfo.repaint();
|
||||
this.handContainer.sizeHand(1);
|
||||
this.handContainer.sizeHand(1, smallMode);
|
||||
for (PlayAreaPanel p: players.values()) {
|
||||
p.sizePlayer();
|
||||
}
|
||||
|
|
@ -840,23 +840,21 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
.addComponent(pnlGameInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0)
|
||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
);
|
||||
gl_jPanel3.setVerticalGroup(
|
||||
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(jPhases, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(pnlGameInfo, GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
|
||||
);
|
||||
jPanel3.setLayout(gl_jPanel3);
|
||||
|
||||
jPanel3.setMinimumSize(new Dimension(800, 600));
|
||||
jPanel3.setMinimumSize(new Dimension(600, 400));
|
||||
jSplitPane1.setLeftComponent(jPanel3);
|
||||
|
||||
gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
|
||||
|
|
|
|||
|
|
@ -22,14 +22,16 @@ import mage.view.SimpleCardsView;
|
|||
public class HandPanel extends JPanel {
|
||||
|
||||
private static final int CARD_WIDTH = 75;
|
||||
private static final double ASPECT_RATIO = 3.5 / 2.5;
|
||||
|
||||
private Dimension handCardDimensionBig;
|
||||
private boolean smallMode = false;
|
||||
private Dimension handCardDimensionBig;
|
||||
private Dimension handCardDimension;
|
||||
|
||||
public HandPanel() {
|
||||
double factor = 1;
|
||||
sizeHand(factor);
|
||||
initComponents();
|
||||
sizeHand(factor, false);
|
||||
}
|
||||
|
||||
public void initComponents() {
|
||||
|
|
@ -64,26 +66,29 @@ public class HandPanel extends JPanel {
|
|||
|
||||
public void loadCards(SimpleCardsView cards, BigCard bigCard, UUID gameId) {
|
||||
hand.loadCards(cards, bigCard, gameId);
|
||||
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * cards.size() + 5, getHandCardDimension().height + 20)); // for scroll
|
||||
hand.sizeCards(getHandCardDimension());
|
||||
}
|
||||
|
||||
private Dimension getHandCardDimension() {
|
||||
Preferences pref = MageFrame.getPreferences();
|
||||
String useBigCards = pref.get(PreferencesDialog.KEY_HAND_USE_BIG_CARDS, "false");
|
||||
if (useBigCards.equals("true")) {
|
||||
String useBigCards = MageFrame.getPreferences().get(PreferencesDialog.KEY_HAND_USE_BIG_CARDS, "false");
|
||||
if (!smallMode && useBigCards.equals("true")) {
|
||||
return handCardDimensionBig;
|
||||
}
|
||||
return handCardDimension;
|
||||
}
|
||||
|
||||
public void sizeHand(double factor) {
|
||||
public void sizeHand(double factor, boolean smallMode) {
|
||||
this.smallMode = smallMode;
|
||||
int width = (int)(factor * CARD_WIDTH);
|
||||
handCardDimension = new Dimension(CARD_WIDTH, (int)(CARD_WIDTH * 3.5f / 2.5f));
|
||||
handCardDimensionBig = new Dimension(CARD_WIDTH, (int)(width * 3.5f / 2.5f));
|
||||
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 javax.swing.JScrollPane jScrollPane1;
|
||||
private JScrollPane jScrollPane1;
|
||||
private Border emptyBorder = new EmptyBorder(0,0,0,0);
|
||||
private mage.client.cards.Cards hand;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue