mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Fixed a bug for loading selected view from java prefs. Minor formatting.
This commit is contained in:
parent
39d67eec8a
commit
30b738b3ad
1 changed files with 40 additions and 27 deletions
|
|
@ -34,19 +34,8 @@
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import mage.Constants.CardType;
|
|
||||||
import mage.cards.MageCard;
|
|
||||||
import mage.client.constants.Constants.SortBy;
|
|
||||||
import mage.client.deckeditor.table.TableModel;
|
|
||||||
import mage.client.deckeditor.table.UpdateCountsCallback;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
|
||||||
import mage.client.util.*;
|
|
||||||
import mage.client.util.Event;
|
|
||||||
import mage.view.CardView;
|
|
||||||
import mage.view.CardsView;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
@ -56,7 +45,19 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import mage.Constants.CardType;
|
||||||
|
import mage.cards.MageCard;
|
||||||
|
import mage.client.constants.Constants.SortBy;
|
||||||
|
import mage.client.deckeditor.table.TableModel;
|
||||||
|
import mage.client.deckeditor.table.UpdateCountsCallback;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
import mage.client.util.*;
|
||||||
|
import mage.client.util.Event;
|
||||||
|
import mage.view.CardView;
|
||||||
|
import mage.view.CardsView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -79,7 +80,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
initComponents();
|
initComponents();
|
||||||
makeTransparent();
|
makeTransparent();
|
||||||
initListViewComponents();
|
initListViewComponents();
|
||||||
currentView = mainModel; // by default we use List View
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void makeTransparent() {
|
public void makeTransparent() {
|
||||||
|
|
@ -109,8 +109,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||||
|
|
||||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_PILES_TOGGLE, "cardView").equals("listView")) {
|
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_VIEW, "cardView").equals("listView")) {
|
||||||
jScrollPane1.setViewportView(mainTable);
|
jScrollPane1.setViewportView(mainTable);
|
||||||
|
currentView = mainModel;
|
||||||
cbSortBy.setEnabled(false);
|
cbSortBy.setEnabled(false);
|
||||||
chkPiles.setEnabled(false);
|
chkPiles.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -156,7 +157,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
|
|
||||||
public List<Integer> asList(final int[] is) {
|
public List<Integer> asList(final int[] is) {
|
||||||
List<Integer> list = new ArrayList<Integer>();
|
List<Integer> list = new ArrayList<Integer>();
|
||||||
for (int i : is) list.add(i);
|
for (int i : is) {
|
||||||
|
list.add(i);
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +178,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redrawCards() {
|
private void redrawCards() {
|
||||||
if (cards == null) cards = new CardsView();
|
if (cards == null) {
|
||||||
|
cards = new CardsView();
|
||||||
|
}
|
||||||
currentView.loadCards(cards, null, false, bigCard, gameId);
|
currentView.loadCards(cards, null, false, bigCard, gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,7 +197,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
cardArea.removeAll();
|
cardArea.removeAll();
|
||||||
if (cards != null && cards.size() > 0) {
|
if (cards != null && cards.size() > 0) {
|
||||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||||
int count = 0;
|
|
||||||
List<CardView> sortedCards = new ArrayList<CardView>(cards.values());
|
List<CardView> sortedCards = new ArrayList<CardView>(cards.values());
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
case NAME:
|
case NAME:
|
||||||
|
|
@ -214,8 +218,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
CardView lastCard = null;
|
CardView lastCard = null;
|
||||||
for (CardView card: sortedCards) {
|
for (CardView card: sortedCards) {
|
||||||
if (chkPiles.isSelected()) {
|
if (chkPiles.isSelected()) {
|
||||||
if (lastCard == null)
|
if (lastCard == null) {
|
||||||
lastCard = card;
|
lastCard = card;
|
||||||
|
}
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
case NAME:
|
case NAME:
|
||||||
if (!card.getName().equals(lastCard.getName())) {
|
if (!card.getName().equals(lastCard.getName())) {
|
||||||
|
|
@ -250,20 +255,24 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
}
|
}
|
||||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||||
addCard(card, bigCard, gameId, rectangle);
|
addCard(card, bigCard, gameId, rectangle);
|
||||||
if (card.getCardTypes().contains(CardType.LAND))
|
if (card.getCardTypes().contains(CardType.LAND)) {
|
||||||
landCount++;
|
landCount++;
|
||||||
if (card.getCardTypes().contains(CardType.CREATURE))
|
}
|
||||||
|
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||||
creatureCount++;
|
creatureCount++;
|
||||||
|
}
|
||||||
curRow++;
|
curRow++;
|
||||||
lastCard = card;
|
lastCard = card;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||||
addCard(card, bigCard, gameId, rectangle);
|
addCard(card, bigCard, gameId, rectangle);
|
||||||
if (card.getCardTypes().contains(CardType.LAND))
|
if (card.getCardTypes().contains(CardType.LAND)) {
|
||||||
landCount++;
|
landCount++;
|
||||||
if (card.getCardTypes().contains(CardType.CREATURE))
|
}
|
||||||
|
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||||
creatureCount++;
|
creatureCount++;
|
||||||
|
}
|
||||||
curColumn++;
|
curColumn++;
|
||||||
if (curColumn == numColumns) {
|
if (curColumn == numColumns) {
|
||||||
curColumn = 0;
|
curColumn = 0;
|
||||||
|
|
@ -493,15 +502,19 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
e.consume();
|
e.consume();
|
||||||
Object obj = e.getSource();
|
Object obj = e.getSource();
|
||||||
if (obj instanceof Card) {
|
if (obj instanceof Card) {
|
||||||
if (e.isShiftDown())
|
if (e.isShiftDown()) {
|
||||||
cardEventSource.shiftDoubleClick(((Card)obj).getOriginal(), "shift-double-click");
|
cardEventSource.shiftDoubleClick(((Card)obj).getOriginal(), "shift-double-click");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
cardEventSource.doubleClick(((Card)obj).getOriginal(), "double-click");
|
cardEventSource.doubleClick(((Card)obj).getOriginal(), "double-click");
|
||||||
|
}
|
||||||
} else if (obj instanceof MageCard) {
|
} else if (obj instanceof MageCard) {
|
||||||
if (e.isShiftDown())
|
if (e.isShiftDown()) {
|
||||||
cardEventSource.shiftDoubleClick(((MageCard)obj).getOriginal(), "shift-double-click");
|
cardEventSource.shiftDoubleClick(((MageCard)obj).getOriginal(), "shift-double-click");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "double-click");
|
cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "double-click");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue