mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
gui: deck editor - improved popup menu naming, added commander hint to sideboard, fixed generate/random deck dialog on cancel, removed outdated logs;
This commit is contained in:
parent
ec34380bed
commit
b315b46871
6 changed files with 23 additions and 18 deletions
|
|
@ -647,8 +647,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
private boolean separateCreatures = true;
|
||||
|
||||
public enum Role {
|
||||
MAINDECK("Maindeck"),
|
||||
SIDEBOARD("Sideboard");
|
||||
MAINDECK("Main deck"),
|
||||
SIDEBOARD("Sideboard/commander");
|
||||
|
||||
Role(String name) {
|
||||
this.name = name;
|
||||
|
|
@ -1955,21 +1955,21 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
private void showCardRightClickMenu(@SuppressWarnings("unused") final CardView card, MouseEvent e) {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
JMenuItem hide = new JMenuItem("Hide");
|
||||
JMenuItem hide = new JMenuItem("Hide (hidden in sideboard)");
|
||||
hide.addActionListener(e2 -> hideSelection());
|
||||
menu.add(hide);
|
||||
|
||||
JMenuItem invertSelection = new JMenuItem("Invert Selection");
|
||||
JMenuItem invertSelection = new JMenuItem("Invert selection");
|
||||
invertSelection.addActionListener(e2 -> invertSelection());
|
||||
menu.add(invertSelection);
|
||||
|
||||
JMenuItem chooseMatching = new JMenuItem("Choose Matching");
|
||||
JMenuItem chooseMatching = new JMenuItem("Select same cards");
|
||||
chooseMatching.addActionListener(e2 -> chooseMatching());
|
||||
menu.add(chooseMatching);
|
||||
|
||||
// Show 'Duplicate Selection' for FREE_BUILDING
|
||||
if (this.mode == Constants.DeckEditorMode.FREE_BUILDING) {
|
||||
JMenuItem duplicateSelection = new JMenuItem("Duplicate Selection");
|
||||
JMenuItem duplicateSelection = new JMenuItem("Duplicate selected cards");
|
||||
duplicateSelection.addActionListener(e2 -> duplicateSelection());
|
||||
menu.add(duplicateSelection);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,17 +37,16 @@ public final class DeckGenerator {
|
|||
/**
|
||||
* Builds a deck out of the selected block/set/format.
|
||||
*
|
||||
* @return a path to the generated deck.
|
||||
* @return a path to the generated deck or null on canceled
|
||||
*/
|
||||
public static String generateDeck() {
|
||||
|
||||
genDialog = new DeckGeneratorDialog();
|
||||
if (genDialog.getSelectedColors() != null) {
|
||||
Deck deck = buildDeck();
|
||||
return genDialog.saveDeck(deck);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
// If the deck couldn't be generated or the user cancelled, repopulate the deck selection with its cached value
|
||||
return PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, null);
|
||||
}
|
||||
|
||||
protected static Deck buildDeck() {
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
deckList.setRole(DragCardGrid.Role.MAINDECK);
|
||||
sideboardList.setRole(DragCardGrid.Role.SIDEBOARD);
|
||||
|
||||
// card actions in main
|
||||
// When a selection happens in one pane, deselect the selection in the other
|
||||
deckList.addDragCardGridListener(new DragCardGrid.DragCardGridListener() {
|
||||
@Override
|
||||
|
|
@ -121,6 +122,8 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
// card actions in sideboard
|
||||
sideboardList.addDragCardGridListener(new DragCardGrid.DragCardGridListener() {
|
||||
@Override
|
||||
public void cardsSelected() {
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@
|
|||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/card_panel.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Random"/>
|
||||
<Property name="text" type="java.lang.String" value="Generate"/>
|
||||
<Property name="iconTextGap" type="int" value="1"/>
|
||||
<Property name="name" type="java.lang.String" value="btnGenDeck" noResource="true"/>
|
||||
</Properties>
|
||||
|
|
|
|||
|
|
@ -290,11 +290,10 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private Card retrieveTemporaryCard(SimpleCardView cardView) {
|
||||
Card card = temporaryCards.get(cardView.getId());
|
||||
if (card == null) {
|
||||
// Need to make a new card
|
||||
Logger.getLogger(DeckEditorPanel.class).info("Retrieve " + cardView.getCardNumber() + " Failed");
|
||||
// need to make a new card (example: on duplicate, on show hidden cards)
|
||||
card = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber()).createCard();
|
||||
} else {
|
||||
// Only need a temporary card once
|
||||
// restore temp card (example: after drag to new zone)
|
||||
temporaryCards.remove(cardView.getId());
|
||||
}
|
||||
return card;
|
||||
|
|
@ -1014,7 +1013,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
});
|
||||
|
||||
btnGenDeck.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/card_panel.png"))); // NOI18N
|
||||
btnGenDeck.setText("Random");
|
||||
btnGenDeck.setText("Generate");
|
||||
btnGenDeck.setIconTextGap(1);
|
||||
btnGenDeck.setName("btnGenDeck"); // NOI18N
|
||||
btnGenDeck.addActionListener(new java.awt.event.ActionListener() {
|
||||
|
|
@ -1470,6 +1469,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
try {
|
||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
String path = DeckGenerator.generateDeck();
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
deck = Deck.load(DeckImporter.importDeckFromFile(path, false), true, true);
|
||||
} catch (GameException ex) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading generated deck", JOptionPane.ERROR_MESSAGE);
|
||||
|
|
|
|||
|
|
@ -58,10 +58,11 @@ public class NewPlayerPanel extends javax.swing.JPanel {
|
|||
|
||||
protected void generateDeck() {
|
||||
String path = DeckGenerator.generateDeck();
|
||||
if (path != null) {
|
||||
this.txtPlayerDeck.setText(path);
|
||||
MageFrame.getPreferences().put("defaultDeckPath", path);
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
this.txtPlayerDeck.setText(path);
|
||||
MageFrame.getPreferences().put("defaultDeckPath", path);
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue