Some more changes to GUI to better support high screen resolutions.

This commit is contained in:
LevelX2 2016-02-21 11:30:12 +01:00
parent a87bb6f5e6
commit e04c82a227
9 changed files with 129 additions and 71 deletions

View file

@ -39,11 +39,10 @@ import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.Listener;
import mage.view.AbilityView;
import mage.view.CardView;
@ -59,6 +58,8 @@ public class CardArea extends JPanel implements MouseListener {
private final javax.swing.JLayeredPane cardArea;
private final javax.swing.JScrollPane scrollPane;
private int yTextOffset;
private Dimension cardDimension;
private int verticalCardOffset;
/**
* Create the panel.
@ -68,7 +69,7 @@ public class CardArea extends JPanel implements MouseListener {
scrollPane = new JScrollPane();
add(scrollPane, BorderLayout.CENTER);
setGUISize();
cardArea = new JLayeredPane();
scrollPane.setViewportView(cardArea);
yTextOffset = 10;
@ -84,7 +85,25 @@ public class CardArea extends JPanel implements MouseListener {
}
}
public void loadCards(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
public void changeGUISize() {
setGUISize();
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
((CardPanel) component).setBounds(0, 0, cardDimension.width, cardDimension.height);
}
}
}
private void setGUISize() {
setCardDimension(GUISizeHelper.otherZonesCardDimension, GUISizeHelper.otherZonesCardVerticalOffset);
}
public void setCardDimension(Dimension dimension, int verticalCardOffset) {
this.cardDimension = dimension;
this.verticalCardOffset = verticalCardOffset;
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
this.reloaded = true;
cardArea.removeAll();
if (showCards != null && showCards.size() < 10) {
@ -92,7 +111,7 @@ public class CardArea extends JPanel implements MouseListener {
loadCardsFew(showCards, bigCard, gameId);
} else {
yTextOffset = 0;
loadCardsMany(showCards, bigCard, gameId, dimension);
loadCardsMany(showCards, bigCard, gameId);
}
cardArea.revalidate();
@ -100,11 +119,11 @@ public class CardArea extends JPanel implements MouseListener {
this.repaint();
}
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, UUID gameId) {
this.reloaded = true;
cardArea.removeAll();
yTextOffset = 0;
loadCardsMany(showCards, bigCard, gameId, dimension);
loadCardsMany(showCards, bigCard, gameId);
cardArea.revalidate();
this.revalidate();
@ -112,16 +131,15 @@ public class CardArea extends JPanel implements MouseListener {
}
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) {
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId, rectangle, dimension, Config.dimensions);
rectangle.translate(Config.dimensions.frameWidth, 0);
addCard(card, bigCard, gameId, rectangle);
rectangle.translate(cardDimension.width, 0);
}
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
cardArea.setPreferredSize(new Dimension(cardDimension.width * showCards.size(), cardDimension.height));
}
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension, CardDimensions cardDimensions) {
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (card instanceof AbilityView) {
CardView tmp = ((AbilityView) card).getSourceCard();
tmp.overrideRules(card.getRules());
@ -130,37 +148,37 @@ public class CardArea extends JPanel implements MouseListener {
tmp.setAbility(card); // cross-reference, required for ability picker
card = tmp;
}
MageCard cardPanel = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId, true);
MageCard cardPanel = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
cardPanel.setBounds(rectangle);
cardPanel.addMouseListener(this);
cardArea.add(cardPanel);
cardArea.moveToFront(cardPanel);
cardPanel.update(card);
cardPanel.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
cardPanel.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
cardPanel.setTextOffset(yTextOffset);
cardPanel.showCardTitle();
}
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId, CardDimensions cardDimensions) {
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) {
int rowsOfCards = 20;
int columns = 1;
if (showCards != null && showCards.size() > 0) {
Rectangle rectangle = new Rectangle(cardDimensions.frameWidth, cardDimensions.frameHeight);
Dimension dimension = new Dimension(cardDimensions.frameWidth, cardDimensions.frameHeight);
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
int count = 0;
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId, rectangle, dimension, cardDimensions);
if (count >= 20) {
rectangle.translate(cardDimensions.frameWidth, -400);
addCard(card, bigCard, gameId, rectangle);
if (count >= rowsOfCards) {
rectangle.translate(cardDimension.width, -(rowsOfCards * verticalCardOffset));
columns++;
count = 0;
} else {
rectangle.translate(0, 20);
rectangle.translate(0, verticalCardOffset);
count++;
}
}
}
cardArea.setPreferredSize(new Dimension(cardDimensions.frameWidth * columns, cardDimensions.frameHeight + 400));
cardArea.setPreferredSize(new Dimension(cardDimension.width * columns, cardDimension.height + (rowsOfCards * verticalCardOffset)));
}
public boolean isReloaded() {

View file

@ -4,6 +4,9 @@
<Properties>
<Property name="iconifiable" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.3),&#xa; (int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.2))" type="code"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
@ -23,22 +26,26 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cards" alignment="0" pref="163" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="cards" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cards" alignment="0" pref="67" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="cards" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="mage.client.cards.Cards" name="cards">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 25)" type="code"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CardInfoWindowDialog_cards"/>
</AuxValues>
</Component>
</SubComponents>
</Form>

View file

@ -33,6 +33,7 @@
*/
package mage.client.dialog;
import java.awt.Dimension;
import java.awt.Point;
import java.beans.PropertyVetoException;
import java.util.UUID;
@ -41,7 +42,6 @@ import javax.swing.SwingUtilities;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.SettingsManager;
@ -108,6 +108,7 @@ public class CardInfoWindowDialog extends MageDialog {
}
this.setTitelBarToolTip(name);
setGUISize();
}
public void cleanUp() {
@ -211,21 +212,25 @@ public class CardInfoWindowDialog extends MageDialog {
setIconifiable(true);
setResizable(true);
setPreferredSize(new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.3),
(int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.2)));
cards.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 25));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
);
pack();
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables

View file

@ -36,7 +36,6 @@ import java.util.UUID;
import javax.swing.JButton;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import mage.cards.CardDimensions;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.cards.CardArea;
@ -110,10 +109,10 @@ public class PickPileDialog extends MageDialog {
}
}
public void loadCards(String name, CardsView pile1, CardsView pile2, BigCard bigCard, CardDimensions dimension, UUID gameId) {
public void loadCards(String name, CardsView pile1, CardsView pile2, BigCard bigCard, UUID gameId) {
this.title = name;
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId);
this.pile2.loadCardsNarrow(pile2, bigCard, dimension, gameId);
this.pile1.loadCardsNarrow(pile1, bigCard, gameId);
this.pile2.loadCardsNarrow(pile2, bigCard, gameId);
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);

View file

@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
/*
* ShowCardsDialog.java
*
* Created on 3-Feb-2010, 8:59:11 PM
@ -41,7 +41,6 @@ import java.util.UUID;
import javax.swing.JLayeredPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import mage.cards.CardDimensions;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.cards.CardArea;
@ -69,6 +68,7 @@ public class ShowCardsDialog extends MageDialog {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
this.setModal(false);
}
@ -83,13 +83,23 @@ public class ShowCardsDialog extends MageDialog {
}
}
@Override
public void changeGUISize() {
setGUISize();
cardArea.changeGUISize();
}
private void setGUISize() {
}
public void loadCards(String name, CardsView showCards, BigCard bigCard,
CardDimensions dimension, UUID gameId, boolean modal, Map<String, Serializable> options,
UUID gameId, boolean modal, Map<String, Serializable> options,
JPopupMenu popupMenu, Listener<Event> eventListener) {
this.title = name;
this.setTitelBarToolTip(name);
cardArea.clearCardEventListeners();
cardArea.loadCards(showCards, bigCard, dimension, gameId);
cardArea.loadCards(showCards, bigCard, gameId);
if (options != null) {
if (options.containsKey("chosen")) {
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosen");
@ -145,7 +155,7 @@ public class ShowCardsDialog extends MageDialog {
setResizable(true);
getContentPane().setLayout(new java.awt.BorderLayout());
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
setGUISize();
pack();
}

View file

@ -102,7 +102,6 @@ import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.GameManager;
@ -196,6 +195,7 @@ public final class GamePanel extends javax.swing.JPanel {
private MageDialogState choiceWindowState;
private int feedbackAreaHeight;
private boolean initComponents;
private enum PopUpMenuType {
@ -208,11 +208,11 @@ public final class GamePanel extends javax.swing.JPanel {
private JPopupMenu popupMenuTriggerOrder;
public GamePanel() {
initComponents = true;
initComponents();
setGUISize();
initPopupMenuTriggerOrder();
//this.add(popupMenuTriggerOrder);
setGUISize();
pickNumber = new PickNumberDialog();
MageFrame.getDesktop().add(pickNumber, JLayeredPane.MODAL_LAYER);
@ -267,7 +267,9 @@ public final class GamePanel extends javax.swing.JPanel {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setGUISize();
if (!initComponents) {
setGUISize();
}
}
});
}
@ -277,6 +279,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
};
jPanel3.addComponentListener(componentAdapterPlayField);
initComponents = false;
}
private Map<String, JComponent> getUIComponents(JLayeredPane jLayeredPane) {
@ -350,15 +353,15 @@ public final class GamePanel extends javax.swing.JPanel {
}
public void changeGUISize() {
initComponents = true;
setGUISize();
stackObjects.changeGUISize();
feedbackPanel.changeGUISize();
handContainer.changeGUISize();
for (PlayAreaPanel playAreaPanel : players.values()) {
playAreaPanel.changeGUISize();
}
stackObjects.changeGUISize();
feedbackPanel.changeGUISize();
for (CardInfoWindowDialog cardInfoWindowDialog : exiles.values()) {
cardInfoWindowDialog.changeGUISize();
}
@ -371,8 +374,13 @@ public final class GamePanel extends javax.swing.JPanel {
for (CardInfoWindowDialog cardInfoWindowDialog : graveyardWindows.values()) {
cardInfoWindowDialog.changeGUISize();
}
for (ShowCardsDialog showCardsDialog : pickTarget) {
showCardsDialog.changeGUISize();
}
this.revalidate();
this.repaint();
initComponents = false;
}
private void setGUISize() {
@ -390,7 +398,7 @@ public final class GamePanel extends javax.swing.JPanel {
Dimension newDimension = new Dimension(jPanel3.getWidth() - newStackWidth, GUISizeHelper.handCardDimension.height + GUISizeHelper.scrollBarSize);
handContainer.setPreferredSize(newDimension);
handContainer.setMaximumSize(newDimension);
newDimension = new Dimension(newStackWidth, GUISizeHelper.handCardDimension.height + GUISizeHelper.scrollBarSize);
newDimension = new Dimension(newStackWidth, STACK_MIN_CARDS_OFFSET_Y + GUISizeHelper.handCardDimension.height + GUISizeHelper.scrollBarSize);
stackObjects.setPreferredSize(newDimension);
stackObjects.setMinimumSize(newDimension);
stackObjects.setMaximumSize(newDimension);
@ -399,6 +407,7 @@ public final class GamePanel extends javax.swing.JPanel {
pnlShortCuts.setMinimumSize(newDimension);
pnlShortCuts.setMaximumSize(newDimension);
GUISizeHelper.changePopupMenuFont(popupMenuTriggerOrder);
}
private void saveDividerLocations() {
@ -1179,7 +1188,7 @@ public final class GamePanel extends javax.swing.JPanel {
if (PopUpMenuType.TRIGGER_ORDER.equals(popupMenuType)) {
popupMenu = popupMenuTriggerOrder;
}
showCards.loadCards(title, cards, bigCard, Config.dimensionsEnlarged, gameId, required, options, popupMenu, getShowCardsEventListener(showCards));
showCards.loadCards(title, cards, bigCard, gameId, required, options, popupMenu, getShowCardsEventListener(showCards));
return showCards;
}
@ -1212,7 +1221,7 @@ public final class GamePanel extends javax.swing.JPanel {
public void pickPile(String message, CardsView pile1, CardsView pile2) {
hideAll();
PickPileDialog pickPileDialog = new PickPileDialog();
pickPileDialog.loadCards(message, pile1, pile2, bigCard, Config.dimensions, gameId);
pickPileDialog.loadCards(message, pile1, pile2, bigCard, gameId);
session.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
pickPileDialog.cleanUp();
pickPileDialog.removeDialog();

View file

@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
/*
* CombatGroup.java
*
* Created on Feb 10, 2010, 3:36:55 PM
@ -37,6 +37,7 @@ package mage.client.unusedFiles;
import java.util.UUID;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.client.util.GUISizeHelper;
import mage.view.CombatGroupView;
/**
@ -63,10 +64,12 @@ public class CombatGroup extends javax.swing.JPanel {
public void update(CombatGroupView combatGroup) {
this.lblDefender.setText(combatGroup.getDefenderName());
attackers.setCardDimension(GUISizeHelper.otherZonesCardDimension);
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId, true);
// attackers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
blockers.setCardDimension(GUISizeHelper.otherZonesCardDimension);
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId, true);
// blockers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
this.attackers.setVisible(true);
this.blockers.setVisible(true);
}

View file

@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
/*
* PlayerPanel.java
*
* Created on Nov 18, 2009, 3:01:31 PM
@ -39,7 +39,6 @@ import java.util.UUID;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.dialog.ShowCardsDialog;
import mage.client.util.Config;
import mage.remote.Session;
import mage.view.PlayerView;
@ -200,7 +199,7 @@ public class PlayerPanel extends javax.swing.JPanel {
if (graveyard == null) {
graveyard = new ShowCardsDialog();
}
graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false, null, null, null);
graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, gameId, false, null, null, null);
}//GEN-LAST:event_btnGraveActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables

View file

@ -64,6 +64,8 @@ public class GUISizeHelper {
public static int stackWidth;
public static Dimension otherZonesCardDimension;
public static int otherZonesCardVerticalOffset;
public static Dimension battlefieldCardDimension;
public static Dimension editorCardDimension;
@ -106,8 +108,8 @@ public class GUISizeHelper {
int dialogFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_DIALOG_FONT_SIZE, 14);
menuFont = new Font("Arial", 0, dialogFontSize);
gameRequestsFont = new Font("Arial", 0, dialogFontSize);
symbolDialogSize = dialogFontSize;
// used in the feedback area of the game panel
int feedbackFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FEEDBACK_AREA_SIZE, 14);
gameDialogAreaFontSizeBig = feedbackFontSize;
gameDialogAreaFontSizeTooltip = feedbackFontSize - 2;
@ -116,6 +118,7 @@ public class GUISizeHelper {
gameDialogAreaFont = new Font("Arial", 0, feedbackFontSize);
gameDialogButtonHeight = feedbackFontSize + 6;
gameDialogButtonWidth = feedbackFontSize * 2 + 40;
symbolDialogSize = feedbackFontSize;
int chatFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CHAT_FONT_SIZE, 14);
chatFont = new java.awt.Font("Arial", 0, chatFontSize);
@ -130,6 +133,11 @@ public class GUISizeHelper {
int otherZonesCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OTHER_ZONES_SIZE, 14);
otherZonesCardDimension = new Dimension(CARD_IMAGE_WIDTH * otherZonesCardSize / 42, CARD_IMAGE_HEIGHT * otherZonesCardSize / 42);
if (otherZonesCardSize > 29) {
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 8;
} else {
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10;
}
int battlefieldCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_SIZE, 14);
battlefieldCardDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldCardSize / 42, CARD_IMAGE_HEIGHT * battlefieldCardSize / 42);