mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Now 'new' is present in quest deckbuider too.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package forge.gui.deckeditor;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.card.CardPool;
|
||||
@@ -10,15 +9,25 @@ import forge.deck.Deck;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.Font;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
//import forge.quest.data.QuestBoosterPack;
|
||||
|
||||
/**
|
||||
@@ -41,9 +50,10 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
private JButton addButton = new JButton();
|
||||
private JButton removeButton = new JButton();
|
||||
private JButton analysisButton = new JButton();
|
||||
|
||||
private JLabel labelSortHint = new JLabel();
|
||||
|
||||
private QuestData questData;
|
||||
|
||||
|
||||
public void show(final Command exitCommand) {
|
||||
final Command exit = new Command() {
|
||||
@@ -58,17 +68,16 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
// do not change this!!!!
|
||||
this.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent ev) {
|
||||
public void windowClosing(final WindowEvent ev) {
|
||||
customMenu.close();
|
||||
}
|
||||
});
|
||||
|
||||
setup();
|
||||
|
||||
customMenu = new DeckEditorQuestMenu(this, exit);
|
||||
customMenu = new DeckEditorQuestMenu(questData, this, exit);
|
||||
this.setJMenuBar(customMenu);
|
||||
|
||||
forge.quest.data.QuestData questData = AllZone.getQuestData();
|
||||
Deck deck = null;
|
||||
|
||||
// open deck that the player used if QuestData has it
|
||||
@@ -85,7 +94,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
|
||||
CardPoolView bottomPool = deck.getMain();
|
||||
CardPool cardpool = new CardPool();
|
||||
cardpool.addAll(AllZone.getQuestData().getCards().getCardpool());
|
||||
cardpool.addAll(questData.getCards().getCardpool());
|
||||
|
||||
// remove bottom cards that are in the deck from the card pool
|
||||
cardpool.removeAll(bottomPool);
|
||||
@@ -98,7 +107,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
top.sort(3, true);// then sort by color
|
||||
|
||||
bottom.sort(1, true);
|
||||
}// show(Command)
|
||||
} // show(Command)
|
||||
|
||||
|
||||
/**
|
||||
@@ -116,6 +125,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Stats", 40, PresetColumns.fnStatsCompare, PresetColumns.fnStatsGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("New", 30, questData.getCards().fnNewCompare, questData.getCards().fnNewGet));
|
||||
// Add NEW column here
|
||||
|
||||
top.setup(columns, cardView);
|
||||
@@ -131,7 +141,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
// setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
} // setupAndDisplay()
|
||||
|
||||
public DeckEditorQuest() {
|
||||
public DeckEditorQuest(QuestData questData2) {
|
||||
questData = questData2;
|
||||
try {
|
||||
filterBoxes = new FilterCheckBoxes(false);
|
||||
top = new TableWithCards("All Cards", true);
|
||||
@@ -155,14 +166,14 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
if (!OldGuiNewGame.useLAFFonts.isSelected())
|
||||
removeButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
||||
removeButton.setText("Remove Card");
|
||||
removeButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
removeButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
removeButtonActionPerformed(e);
|
||||
}
|
||||
});
|
||||
addButton.setText("Add Card");
|
||||
addButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
addButtonActionPerformed(e);
|
||||
}
|
||||
});
|
||||
@@ -172,8 +183,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
addButton.setBounds(new Rectangle(23, 403, 146, 49));
|
||||
|
||||
analysisButton.setText("Deck Analysis");
|
||||
analysisButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
analysisButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
analysisButton_actionPerformed(e);
|
||||
}
|
||||
});
|
||||
@@ -276,9 +287,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
}
|
||||
|
||||
|
||||
public void addCheatCard(CardPrinted card) {
|
||||
public void addCheatCard(final CardPrinted card) {
|
||||
top.addCard(card);
|
||||
AllZone.getQuestData().getCards().getCardpool().add(card);
|
||||
questData.getCards().getCardpool().add(card);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.gui.deckeditor;
|
||||
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.card.CardRules;
|
||||
@@ -14,6 +13,7 @@ import forge.deck.DeckManager;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.ListChooser;
|
||||
import forge.quest.data.QuestData;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
@@ -44,10 +44,6 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
||||
/** Constant <code>serialVersionUID=-4052319220021158574L</code>. */
|
||||
private static final long serialVersionUID = -4052319220021158574L;
|
||||
|
||||
//this should be false in the public version
|
||||
//if true, the Quest Deck editor will let you edit the computer's decks
|
||||
private final boolean canEditComputerDecks;
|
||||
|
||||
/** Constant <code>deckEditorName="Deck Editor"</code>. */
|
||||
private static final String deckEditorName = "Deck Editor";
|
||||
|
||||
@@ -69,21 +65,12 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
||||
* @param d a {@link forge.gui.deckeditor.DeckDisplay} object.
|
||||
* @param exit a {@link forge.Command} object.
|
||||
*/
|
||||
public DeckEditorQuestMenu(final DeckDisplay d, final Command exit) {
|
||||
//is a file named "edit" in this directory
|
||||
//lame but it works, I don't like 2 versions of Forge floating around
|
||||
//one that lets you edit the AI decks and one that doesn't
|
||||
File f = new File("edit");
|
||||
if (f.exists()) {
|
||||
canEditComputerDecks = true;
|
||||
} else {
|
||||
canEditComputerDecks = false;
|
||||
}
|
||||
public DeckEditorQuestMenu(QuestData q, final DeckDisplay d, final Command exit) {
|
||||
|
||||
deckDisplay = d;
|
||||
d.setTitle(deckEditorName);
|
||||
questData = q;
|
||||
|
||||
questData = AllZone.getQuestData();
|
||||
d.setTitle(deckEditorName);
|
||||
|
||||
exitCommand = exit;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ public final class DeckEditorShop extends DeckEditorBase {
|
||||
top.setup(columns, cardView);
|
||||
|
||||
columnsBelow.add(new TableColumnInfo<CardPrinted>("#Dk", 30, fnDeckCompare, fnDeckGet));
|
||||
columnsBelow.add(new TableColumnInfo<CardPrinted>("New", 30, fnNewCompare, fnNewGet));
|
||||
columnsBelow.add(new TableColumnInfo<CardPrinted>("New", 30, questData.getCards().fnNewCompare, questData.getCards().fnNewGet));
|
||||
columnsBelow.add(new TableColumnInfo<CardPrinted>("Price", 40, fnPriceCompare, fnPriceGet));
|
||||
bottom.setup(columnsBelow, cardView);
|
||||
|
||||
@@ -303,16 +303,6 @@ public final class DeckEditorShop extends DeckEditorBase {
|
||||
Integer iValue = decksUsingMyCards.get(from.getKey());
|
||||
return iValue == null ? "" : iValue.toString();
|
||||
} };
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final Lambda1<Comparable, Entry<CardPrinted, Integer>> fnNewCompare =
|
||||
new Lambda1<Comparable, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Comparable apply(final Entry<CardPrinted, Integer> from) {
|
||||
return newCardsList.contains(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0);
|
||||
} };
|
||||
private final Lambda1<Object, Entry<CardPrinted, Integer>> fnNewGet =
|
||||
new Lambda1<Object, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Object apply(final Entry<CardPrinted, Integer> from) {
|
||||
return newCardsList.contains(from.getKey()) ? "NEW" : "";
|
||||
} };
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package forge.quest.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
|
||||
import forge.ReadBoosterPack;
|
||||
@@ -168,4 +170,19 @@ public final class QuestUtilCards {
|
||||
public void resetNewList() {
|
||||
q.newCardList.clear();
|
||||
}
|
||||
|
||||
// These functions provide a way to sort and compare cards in a table according to their new-ness
|
||||
// It might be a good idea to store them in a base class for both quest-mode deck editors
|
||||
// Maybe we should consider doing so later
|
||||
@SuppressWarnings("rawtypes")
|
||||
public final Lambda1<Comparable, Entry<CardPrinted, Integer>> fnNewCompare =
|
||||
new Lambda1<Comparable, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Comparable apply(final Entry<CardPrinted, Integer> from) {
|
||||
return q.newCardList.contains(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0);
|
||||
} };
|
||||
public final Lambda1<Object, Entry<CardPrinted, Integer>> fnNewGet =
|
||||
new Lambda1<Object, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Object apply(final Entry<CardPrinted, Integer> from) {
|
||||
return q.newCardList.contains(from.getKey()) ? "NEW" : "";
|
||||
} };
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
}
|
||||
};
|
||||
|
||||
DeckEditorQuest g = new DeckEditorQuest();
|
||||
DeckEditorQuest g = new DeckEditorQuest(AllZone.getQuestData());
|
||||
|
||||
g.show(exit);
|
||||
g.setVisible(true);
|
||||
|
||||
Reference in New Issue
Block a user