forked from External/mage
Redesigned sorting handling of deck, sideboard and draft card area (keep sorting if and view if cards move).
This commit is contained in:
parent
d9d79e294d
commit
f3992bd2d5
15 changed files with 461 additions and 83 deletions
|
|
@ -338,7 +338,7 @@
|
|||
<Component id="cardCountLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cardCount" min="-2" pref="48" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="186" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="121" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
jButtonAddToSideboard.setEnabled(false);
|
||||
filterCards();
|
||||
chkPiles.setSelected(true);
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
public void loadSideboard(List<Card> sideboard, BigCard bigCard) {
|
||||
|
|
@ -180,7 +180,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
for (Card card: sideboard) {
|
||||
this.cards.add(card);
|
||||
}
|
||||
switchToGrid();
|
||||
filterCards();
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +328,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
if (currentView instanceof CardGrid && filteredCards.size() > CardGrid.MAX_IMAGES) {
|
||||
this.toggleViewMode();
|
||||
}
|
||||
this.currentView.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null, false);
|
||||
this.currentView.loadCards(new CardsView(filteredCards), SortSettingBase.getInstance(), chkPiles.isSelected(), bigCard, null, false);
|
||||
this.cardCount.setText(String.valueOf(filteredCards.size()));
|
||||
}
|
||||
finally {
|
||||
|
|
@ -845,13 +844,14 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy) {
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
SortSettingBase.getInstance().setSortBy((SortBy) cbSortBy.getSelectedItem());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy) {
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
|
||||
|
|
@ -1012,28 +1012,28 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy) {
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy) {
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy) {
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy) {
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
this.currentView.drawCards(SortSettingBase.getInstance(), chkPiles.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
public DeckArea() {
|
||||
initComponents();
|
||||
jSplitPane1.setOpaque(false);
|
||||
deckList.setSortSetting(SortSettingDeck.getInstance());
|
||||
sideboardList.setSortSetting(SortSettingSideboard.getInstance());
|
||||
deckList.setOpaque(false);
|
||||
sideboardList.setOpaque(false);
|
||||
deckList.setDisplayNoCopies(true);
|
||||
|
|
|
|||
|
|
@ -27,30 +27,6 @@
|
|||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.importer.DeckImporter;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.ICardGrid;
|
||||
import mage.client.constants.Constants.DeckEditorMode;
|
||||
import mage.client.dialog.AddLandDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.components.CardInfoPane;
|
||||
import mage.game.GameException;
|
||||
import mage.remote.Session;
|
||||
import mage.cards.Sets;
|
||||
import mage.view.CardView;
|
||||
import mage.view.SimpleCardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
|
|
@ -63,6 +39,37 @@ import java.util.Iterator;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.importer.DeckImporter;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.ICardGrid;
|
||||
import mage.client.constants.Constants.DeckEditorMode;
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.AddLandDialog;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.components.CardInfoPane;
|
||||
import mage.game.GameException;
|
||||
import mage.remote.Session;
|
||||
import mage.view.CardView;
|
||||
import mage.view.SimpleCardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -130,6 +137,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
case Sideboard:
|
||||
this.btnSubmit.setVisible(true);
|
||||
this.cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
||||
// TODO: take from preferences
|
||||
this.cardSelector.switchToGrid();
|
||||
|
||||
this.btnExit.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
if (!MageFrame.getSession().isTestMode()) {
|
||||
|
|
@ -276,7 +286,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
);
|
||||
// Set Sort from Preferences
|
||||
SortBy sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_BY, "Color"));
|
||||
deckArea.getDeckList().setSortBy(sortBy);
|
||||
refreshDeck();
|
||||
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import static mage.client.constants.Constants.SortBy.CASTING_COST;
|
||||
import static mage.client.constants.Constants.SortBy.COLOR;
|
||||
import static mage.client.constants.Constants.SortBy.COLOR_DETAILED;
|
||||
import static mage.client.constants.Constants.SortBy.NAME;
|
||||
import static mage.client.constants.Constants.SortBy.RARITY;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public abstract class SortSetting {
|
||||
|
||||
SortBy sortBy;
|
||||
int sortIndex;
|
||||
boolean ascending;
|
||||
|
||||
public void setSortBy(SortBy sortBy) {
|
||||
this.sortBy = sortBy;
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_SORT_BY, sortBy.toString());
|
||||
}
|
||||
|
||||
public void setSortIndex(int sortIndex) {
|
||||
this.sortIndex = sortIndex;
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_SORT_INDEX, Integer.toString(sortIndex));
|
||||
}
|
||||
|
||||
public void setAscending(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_SORT_ASCENDING, this.ascending ? "1":"0");
|
||||
}
|
||||
|
||||
public SortBy getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
public int getSortIndex() {
|
||||
return sortIndex;
|
||||
}
|
||||
|
||||
public boolean isAscending() {
|
||||
return ascending;
|
||||
}
|
||||
|
||||
public int convertSortByToIndex(SortBy sortBy) {
|
||||
switch(sortBy) {
|
||||
case NAME:
|
||||
return 1;
|
||||
case CASTING_COST:
|
||||
return 2;
|
||||
case COLOR:
|
||||
case COLOR_DETAILED:
|
||||
return 3;
|
||||
case RARITY:
|
||||
return 5;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public SortBy convertIndexToSortBy(int index) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return SortBy.NAME;
|
||||
case 2:
|
||||
return SortBy.CASTING_COST;
|
||||
case 3:
|
||||
return SortBy.COLOR;
|
||||
case 5:
|
||||
return SortBy.RARITY;
|
||||
default:
|
||||
return SortBy.UNSORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class SortSettingBase extends SortSetting {
|
||||
|
||||
private static SortSettingBase fInstance = new SortSettingBase();
|
||||
|
||||
public static SortSettingBase getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingBase() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BASE_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BASE_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BASE_SORT_INDEX, "1").equals("1");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class SortSettingDeck extends SortSetting {
|
||||
|
||||
private static SortSettingDeck fInstance = new SortSettingDeck();
|
||||
|
||||
public static SortSettingDeck getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingDeck() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DECK_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DECK_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DECK_SORT_INDEX, "1").equals("1");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SortSettingDraft extends SortSetting {
|
||||
|
||||
private static SortSettingDraft fInstance = new SortSettingDraft();
|
||||
|
||||
public static SortSettingDraft getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingDraft() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_INDEX, "1").equals("1");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class SortSettingSideboard extends SortSetting {
|
||||
|
||||
private static SortSettingSideboard fInstance = new SortSettingSideboard();
|
||||
|
||||
public static SortSettingSideboard getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingSideboard() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SIDEBOARD_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX, "1").equals("1");
|
||||
}
|
||||
}
|
||||
|
|
@ -28,11 +28,30 @@
|
|||
|
||||
package mage.client.deckeditor.table;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.CardEventSource;
|
||||
import mage.client.cards.ICardGrid;
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.deckeditor.SortSetting;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.Event;
|
||||
|
|
@ -45,16 +64,6 @@ import mage.view.CardsView;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Table Model for card list.
|
||||
*
|
||||
|
|
@ -79,16 +88,23 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
|
||||
private String column[] = { "", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set" };
|
||||
|
||||
private SortSetting sortSetting;
|
||||
private int recentSortedColumn;
|
||||
private boolean recentAscending;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
this.loadCards(showCards, sortBy, piles, bigCard, gameId, true);
|
||||
public void loadCards(CardsView showCards, SortSetting sortSetting, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
this.loadCards(showCards, sortSetting, piles, bigCard, gameId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId, boolean merge) {
|
||||
public void loadCards(CardsView showCards, SortSetting sortSetting, boolean piles, BigCard bigCard, UUID gameId, boolean merge) {
|
||||
if (this.sortSetting == null) {
|
||||
this.sortSetting = sortSetting;
|
||||
}
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
int landCount = 0;
|
||||
|
|
@ -164,8 +180,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
}
|
||||
}
|
||||
|
||||
sort(1, true);
|
||||
drawCards(sortBy, piles);
|
||||
sort(this.sortSetting.getSortIndex(), this.sortSetting.isAscending());
|
||||
drawCards(sortSetting, piles);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -258,7 +274,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
public void drawCards(SortSetting sortSetting, boolean piles) {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
|
@ -342,6 +358,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
if (recentSortedColumn == column) {
|
||||
asc = !recentAscending;
|
||||
}
|
||||
sortSetting.setSortIndex(column);
|
||||
sortSetting.setAscending(asc);
|
||||
sort(column, asc);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
|
@ -392,6 +410,14 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
return true;
|
||||
}
|
||||
|
||||
public int getRecentSortedColumn() {
|
||||
return recentSortedColumn;
|
||||
}
|
||||
|
||||
public boolean isRecentAscending() {
|
||||
return recentAscending;
|
||||
}
|
||||
|
||||
public void setDisplayNoCopies(boolean value) {
|
||||
this.displayNoCopies = value;
|
||||
}
|
||||
|
|
@ -404,4 +430,4 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
public int cardsSize() {
|
||||
return cards.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue