From 5af417ed0bf74452b88da3951efa394bfdee0c4c Mon Sep 17 00:00:00 2001 From: Mark Langen Date: Tue, 4 Oct 2016 00:23:13 -0600 Subject: [PATCH] More Drag & Drop editor fixes * Fixed cards being blurry. The problem isn't completely fixed, but the fix will suffice in most cases. Card Images are only loaded in once, and the cards were loaded in initially at a small size instead of their eventual size after layout. Really they should reload images when resized, but I will tackle that later, and it's only noticable when significantly resizing cards within one usage of the editor anyways. * Removed some of the unneeded UI on the sideboard half of the DeckView so that componently are less likely to overlap at a small size. Not sure how to ideally handle this, as Swing doesn't really provide an elegant way to hide components at small sizes, and I'm sure the user would rather the components overlap than be unable to resize the window as small as they want due to a minimum size requirement. --- .../java/mage/client/cards/DragCardGrid.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java index a04d2e963c..24bb522b2e 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java @@ -1,36 +1,21 @@ package mage.client.cards; import mage.cards.MageCard; -import mage.cards.decks.Deck; import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardLayout; -import mage.cards.decks.importer.DeckImporterUtil; -import mage.cards.repository.CardInfo; -import mage.client.MageFrame; -import mage.client.deckeditor.DeckArea; import mage.client.dialog.PreferencesDialog; import mage.client.plugins.impl.Plugins; import mage.client.util.*; import mage.client.util.Event; import mage.constants.CardType; -import mage.game.GameException; import mage.view.CardView; import mage.view.CardsView; import org.apache.log4j.Logger; import org.mage.card.arcane.CardRenderer; import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import javax.swing.filechooser.FileFilter; import java.awt.*; import java.awt.event.*; -import java.io.File; -import java.io.IOException; -import java.io.Serializable; import java.util.*; import java.util.List; import java.util.regex.Matcher; @@ -367,6 +352,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg public void setRole(Role role) { this.role = role; + if (role == Role.SIDEBOARD) { + creatureCountLabel.setVisible(false); + landCountLabel.setVisible(false); + cardSizeSliderLabel.setVisible(false); + } else { + creatureCountLabel.setVisible(true); + landCountLabel.setVisible(true); + cardSizeSliderLabel.setVisible(true); + } updateCounts(); } @@ -502,6 +496,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg JPopupMenu sortPopup; JCheckBox separateCreaturesCb; + JSlider cardSizeSlider; + JLabel cardSizeSliderLabel; + Map sortButtons = new HashMap<>(); JLabel deckNameAndCountLabel; @@ -641,13 +638,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg toolbar.add(toolbarInner, BorderLayout.WEST); JPanel sliderPanel = new JPanel(new GridBagLayout()); sliderPanel.setOpaque(false); - final JSlider sizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 50); - sizeSlider.setOpaque(false); - sizeSlider.setPreferredSize(new Dimension(100, (int)sizeSlider.getPreferredSize().getHeight())); - sizeSlider.addChangeListener(e -> { - if (!sizeSlider.getValueIsAdjusting()) { + cardSizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 50); + cardSizeSlider.setOpaque(false); + cardSizeSlider.setPreferredSize(new Dimension(100, (int) cardSizeSlider.getPreferredSize().getHeight())); + cardSizeSlider.addChangeListener(e -> { + if (!cardSizeSlider.getValueIsAdjusting()) { // Fraction in [-1, 1] - float sliderFrac = ((float) (sizeSlider.getValue() - 50)) / 50; + float sliderFrac = ((float) (cardSizeSlider.getValue() - 50)) / 50; // Convert to frac in [0.5, 2.0] exponentially cardSizeMod = (float) Math.pow(2, sliderFrac); // Update grid @@ -655,8 +652,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg cardContent.repaint(); } }); - sliderPanel.add(new JLabel("Card Size:")); - sliderPanel.add(sizeSlider); + cardSizeSliderLabel = new JLabel("Card Size:"); + sliderPanel.add(cardSizeSliderLabel); + sliderPanel.add(cardSizeSlider); toolbar.add(sliderPanel, BorderLayout.EAST); this.add(toolbar, BorderLayout.NORTH); @@ -1143,7 +1141,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg updateCounts(); // Create the card view - final MageCard cardPanel = Plugins.getInstance().getMageCard(card, lastBigCard, new Dimension(100, 140), null, true, true); + final MageCard cardPanel = Plugins.getInstance().getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true); cardPanel.update(card); cardPanel.setTextOffset(0);