-
Notifications
You must be signed in to change notification settings - Fork 861
Feature: Set card editions as favorite (for deck importing purposes) #14070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -568,6 +568,8 @@ public interface DragCardGridListener { | |
|
|
||
| void duplicateCards(Collection<CardView> cards); | ||
|
|
||
| void markCardsAsFavorite(Collection<CardView> cards); | ||
|
|
||
| void invertCardSelection(Collection<CardView> cards); | ||
|
|
||
| void showAll(); | ||
|
|
@@ -1181,6 +1183,13 @@ private void duplicateSelection() { | |
| } | ||
| } | ||
|
|
||
| private void markAsFavorite() { | ||
| Collection<CardView> toFave = dragCardList(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must have menu to add single card to favorite or whole set to favorite. |
||
| for (DragCardGridListener l : listeners) { | ||
| l.markCardsAsFavorite(toFave); | ||
| } | ||
| } | ||
|
|
||
| private void invertSelection() { | ||
| Collection<CardView> toInvert = allCards; | ||
| for (DragCardGridListener l : listeners) { | ||
|
|
@@ -1980,6 +1989,10 @@ private void showCardRightClickMenu(@SuppressWarnings("unused") final CardView c | |
| JMenuItem duplicateSelection = new JMenuItem("Duplicate selected cards"); | ||
| duplicateSelection.addActionListener(e2 -> duplicateSelection()); | ||
| menu.add(duplicateSelection); | ||
|
|
||
| JMenuItem markAsFavorite = new JMenuItem("Mark selected card editions as favorite"); | ||
| markAsFavorite.addActionListener(e2 -> markAsFavorite()); | ||
| menu.add(markAsFavorite); | ||
| } | ||
| menu.show(e.getComponent(), e.getX(), e.getY()); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -759,6 +759,7 @@ private void importFromFile(java.awt.event.ActionEvent evt) { | |
| MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR)); | ||
| try { | ||
| DeckImporter importer = DeckImporter.getDeckImporter(file.getPath()); | ||
| importer.setPreferences(MageFrame.getPreferences()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must change the logic: import original cards, press right click to add/remove/apply favorite sets/cards versions. Do not modify import code with hidden features.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Import feature must import original cards and do not modify it by hidden logic without user notification/interaction. Deck editor has full access to deck and cards data, so you can modify it from a deck editor, no needs in import code. Look for code example in oldVersionDeck method.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UX logic for a user:
|
||
|
|
||
| if (importer != null) { | ||
| StringBuilder errorMessages = new StringBuilder(); | ||
|
|
@@ -822,7 +823,13 @@ private void importFromClipboardWithAppend(ActionEvent evt) { | |
| StringBuilder errorMessages = new StringBuilder(); | ||
| MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR)); | ||
| try { | ||
| Deck deckToAppend = Deck.load(DeckImporter.importDeckFromFile(tempDeckPath, errorMessages, false), true, true); | ||
| DeckImporter deckImporter = DeckImporter.getDeckImporter(tempDeckPath); | ||
| DeckCardLists deckCardLists = new DeckCardLists(); | ||
| if (deckImporter != null) { | ||
| deckImporter.setPreferences(MageFrame.getPreferences()); | ||
| deckCardLists = deckImporter.importDeck(tempDeckPath, errorMessages, false); | ||
| } | ||
| Deck deckToAppend = Deck.load(deckCardLists, true, true); | ||
| processAndShowImportErrors(errorMessages); | ||
| this.deck = Deck.append(deckToAppend, this.deck); | ||
| refreshDeck(false, true); | ||
|
|
@@ -924,7 +931,14 @@ private boolean loadDeck(String file, boolean saveAutoFixedFile) { | |
| MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR)); | ||
| try { | ||
| StringBuilder errorMessages = new StringBuilder(); | ||
| Deck newDeck = Deck.load(DeckImporter.importDeckFromFile(file, errorMessages, saveAutoFixedFile), true, true); | ||
| DeckImporter deckImporter = DeckImporter.getDeckImporter(file); | ||
| DeckCardLists deckCardLists = new DeckCardLists(); | ||
| if (deckImporter != null) { | ||
| deckImporter.setPreferences(MageFrame.getPreferences()); | ||
| deckCardLists = deckImporter.importDeck(file, errorMessages, saveAutoFixedFile); | ||
| } | ||
|
|
||
| Deck newDeck = Deck.load(deckCardLists, true, true); | ||
| processAndShowImportErrors(errorMessages); | ||
|
|
||
| if (newDeck != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ public final class MagePreferences { | |
| private static final String KEY_PASSWORD = "password"; | ||
| private static final String KEY_EMAIL = "email"; | ||
| private static final String KEY_AUTO_CONNECT = "autoConnect"; | ||
| private static final String KEY_FAVORITE_CARD_PREFIX = "favoriteCard"; | ||
| private static final String NODE_KEY_IGNORE_LIST = "ignoreListString"; | ||
| private static final String NODE_KEY_RESTORE_SESSIONS_LIST = "restoreSessionsListString"; | ||
|
|
||
|
|
@@ -115,6 +116,26 @@ public static void setAutoConnect(boolean autoConnect) { | |
| prefs().putBoolean(KEY_AUTO_CONNECT, autoConnect); | ||
| } | ||
|
|
||
| public static String getFavoriteCardNumber(String cardName) { | ||
| String setAndNumber = prefs().get(prefixedKey(KEY_FAVORITE_CARD_PREFIX, cardName), ""); | ||
| if (setAndNumber != null && !setAndNumber.equals("")) { | ||
| return setAndNumber.split("##")[1]; | ||
| } | ||
| return ""; | ||
| } | ||
|
|
||
| public static String getFavoriteCardSet(String cardName) { | ||
| String setAndNumber = prefs().get(prefixedKey(KEY_FAVORITE_CARD_PREFIX, cardName), ""); | ||
| if (setAndNumber != null && !setAndNumber.equals("")) { | ||
| return setAndNumber.split("##")[0]; | ||
| } | ||
| return ""; | ||
| } | ||
|
|
||
| public static void setFavoriteCard(String cardName, String cardNumber, String setCode) { | ||
| prefs().put(prefixedKey(KEY_FAVORITE_CARD_PREFIX, cardName), setCode + "##" + cardNumber); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t like to use a java prefs to store user defined data. There are popular bugs with settings/data lost, e.g. after system java update. Current logic with subfolder and one record per card is fine anyway. p.s. Images folder with additional text files can be more useful in the future like favorite_image_sets.txt and favorite_image_cards.txt And it will allow easy review and edit for a users. |
||
| } | ||
|
|
||
| public static void addIgnoredUser(String serverAddress, String username) { | ||
| ignoreListNode(serverAddress).putBoolean(username, true); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be renamed to FavoriteImage here and other places, there are plans to add favorite cards list with fast access to it from deck editor. It’s not same as favorite images.