()
| 553 | IDeckController deckController = this.getDeckController(); |
| 554 | return new FPopupMenu() { |
| 555 | @Override |
| 556 | protected void buildMenu() { |
| 557 | final Localizer localizer = Forge.getLocalizer(); |
| 558 | if (allowAddBasic()) |
| 559 | addItem(new FMenuItem(localizer.getMessage("lblAddBasicLands"), FSkinImage.LANDLOGO, e -> showAddBasicLandsDialog())); |
| 560 | if (showAddExtraSectionOption()) { |
| 561 | addItem(new FMenuItem(localizer.getMessage("lblAddDeckSection"), FSkinImage.CHAOS, e -> { |
| 562 | List<String> options = hiddenExtraSections.stream().map(DeckSection::getLocalizedName).collect(Collectors.toList()); |
| 563 | GuiChoose.oneOrNone(localizer.getMessage("lblAddDeckSectionSelect"), options, result -> { |
| 564 | if (result == null || !options.contains(result)) |
| 565 | return; |
| 566 | DeckSection newSection = hiddenExtraSections.get(options.indexOf(result)); |
| 567 | showExtraSectionTab(newSection); |
| 568 | filterCatalogForExtraSection(newSection); |
| 569 | getCatalogPage().scheduleRefresh(); |
| 570 | setSelectedPage(getCatalogPage()); |
| 571 | }); |
| 572 | })); |
| 573 | } |
| 574 | if (editorConfig.hasInfiniteCardPool() || editorConfig.usePlayerInventory()) { |
| 575 | addItem(new FMenuItem(localizer.getMessage("lblImportFromClipboard"), Forge.hdbuttons ? FSkinImage.HDIMPORT : FSkinImage.OPEN, e -> { |
| 576 | FDeckImportDialog dialog = new FDeckImportDialog(deck, FDeckEditor.this.editorConfig); |
| 577 | if(editorConfig.usePlayerInventory()) |
| 578 | dialog.setFreePrintConverter(FDeckEditor.this::supplyPrintForImporter); |
| 579 | dialog.setImportBannedCards(!FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)); |
| 580 | dialog.setCallback(importedDeck -> { |
| 581 | if (deck != null && importedDeck.hasName()) { |
| 582 | deck.setName(importedDeck.getName()); |
| 583 | setHeaderText(importedDeck.getName()); |
| 584 | } |
| 585 | switch (dialog.getImportBehavior()) { |
| 586 | case REPLACE_CURRENT: |
| 587 | for(DeckSectionPage page : pagesBySection.values()) { |
| 588 | if(importedDeck.has(page.deckSection)) { |
| 589 | page.setCards(importedDeck.get(page.deckSection)); |
| 590 | if(hiddenExtraSections.contains(page.deckSection)) |
| 591 | showExtraSectionTab(page.deckSection); |
| 592 | } |
| 593 | else |
| 594 | page.setCards(new CardPool()); |
| 595 | } |
| 596 | break; |
| 597 | case CREATE_NEW: |
| 598 | deckController.setDeck(importedDeck); |
| 599 | break; |
| 600 | case MERGE: |
| 601 | for (Entry<DeckSection, CardPool> section : importedDeck) { |
| 602 | DeckSectionPage page = getPageForSection(section.getKey()); |
| 603 | if (page != null) |
| 604 | page.addCards(section.getValue()); |
| 605 | } |
| 606 | } |
| 607 | }); |
| 608 | dialog.initParse(); |
| 609 | dialog.show(); |
| 610 | setSelectedPage(getMainDeckPage()); //select main deck page if needed so main deck if visible below dialog |
| 611 | })); |
| 612 | if (allowSaveAs()) |
no test coverage detected