forked from External/mage
Merge pull request 'master' (#35) from External/mage:master into master
Some checks failed
/ build_release (push) Has been cancelled
Some checks failed
/ build_release (push) Has been cancelled
Reviewed-on: #35
This commit is contained in:
commit
e176b4a5bd
379 changed files with 5417 additions and 4608 deletions
|
|
@ -18,10 +18,8 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -258,7 +256,7 @@ public class CardArea extends JPanel implements CardEventProducer {
|
|||
this.reloaded = false;
|
||||
}
|
||||
|
||||
public void selectCards(List<UUID> selected) {
|
||||
public void selectCards(Set<UUID> selected) {
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard) component;
|
||||
|
|
@ -269,7 +267,7 @@ public class CardArea extends JPanel implements CardEventProducer {
|
|||
}
|
||||
}
|
||||
|
||||
public void markCards(List<UUID> marked) {
|
||||
public void markCards(Set<UUID> marked) {
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard) component;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.client.deckeditor;
|
||||
|
||||
import mage.cards.decks.importer.MtgaImporter;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.dialog.MageDialog;
|
||||
import mage.util.DeckUtil;
|
||||
|
|
@ -20,11 +21,18 @@ import java.util.Optional;
|
|||
public class DeckImportClipboardDialog extends MageDialog {
|
||||
|
||||
private static final String FORMAT_TEXT =
|
||||
"// Example:\n" +
|
||||
"//1 Library of Congress\n" +
|
||||
"//1 Cryptic Gateway\n" +
|
||||
"//1 Azami, Lady of Scrolls\n" +
|
||||
"// NB: This is slow as, and will lock your screen :)\n" +
|
||||
"// MTGO format example:\n" +
|
||||
"// 1 Library of Congress\n" +
|
||||
"// 3 Cryptic Gateway\n" +
|
||||
"//\n" +
|
||||
"// MTGA, moxfield, archidekt format example:\n" +
|
||||
"// Deck\n" +
|
||||
"// 4 Accumulated Knowledge (A25) 40\n" +
|
||||
"// 2 Adarkar Wastes (EOC) 147\n" +
|
||||
"// Commander\n" +
|
||||
"// 1 Grizzly Bears\n" +
|
||||
"//\n" +
|
||||
"// Importing deck can take some time to finish\n" +
|
||||
"\n" +
|
||||
"// Your current clipboard:\n" +
|
||||
"\n";
|
||||
|
|
@ -68,17 +76,19 @@ public class DeckImportClipboardDialog extends MageDialog {
|
|||
}
|
||||
|
||||
private void onOK() {
|
||||
String decklist = editData.getText();
|
||||
decklist = decklist.replace(FORMAT_TEXT, "");
|
||||
String importData = editData.getText();
|
||||
importData = importData.replace(FORMAT_TEXT, "").trim();
|
||||
|
||||
// find possible data format
|
||||
String tempDeckPath;
|
||||
// This dialog also accepts a paste in .mtga format
|
||||
if (decklist.startsWith("Deck\n")) { // An .mtga list always starts with the first line being "Deck". This kind of paste is processed as .mtga
|
||||
tempDeckPath = DeckUtil.writeTextToTempFile("cbimportdeck", ".mtga", decklist);
|
||||
if (MtgaImporter.isMTGA(importData)) {
|
||||
// MTGA or Moxfield
|
||||
tempDeckPath = DeckUtil.writeTextToTempFile("cbimportdeck", ".mtga", importData);
|
||||
} else {
|
||||
// If the paste is not .mtga format, it's processed as plaintext
|
||||
tempDeckPath = DeckUtil.writeTextToTempFile(decklist);
|
||||
// text
|
||||
tempDeckPath = DeckUtil.writeTextToTempFile(importData);
|
||||
}
|
||||
|
||||
if (this.callback != null) {
|
||||
callback.onImportDone(tempDeckPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,11 +100,11 @@
|
|||
cardArea.loadCards(showCards, bigCard, gameId);
|
||||
if (options != null) {
|
||||
if (options.containsKey("chosenTargets")) {
|
||||
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosenTargets");
|
||||
java.util.Set<UUID> chosenCards = (java.util.Set<UUID>) options.get("chosenTargets");
|
||||
cardArea.selectCards(chosenCards);
|
||||
}
|
||||
if (options.containsKey("possibleTargets")) {
|
||||
java.util.List<UUID> choosableCards = (java.util.List<UUID>) options.get("possibleTargets");
|
||||
java.util.Set<UUID> choosableCards = (java.util.Set<UUID>) options.get("possibleTargets");
|
||||
cardArea.markCards(choosableCards);
|
||||
}
|
||||
if (options.containsKey("queryType") && options.get("queryType") == QueryType.PICK_ABILITY) {
|
||||
|
|
|
|||
|
|
@ -218,17 +218,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
});
|
||||
}
|
||||
|
||||
public List<UUID> getPossibleTargets() {
|
||||
if (options != null && options.containsKey("possibleTargets")) {
|
||||
return (List<UUID>) options.get("possibleTargets");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<UUID> getChosenTargets() {
|
||||
if (options != null && options.containsKey("chosenTargets")) {
|
||||
return new HashSet<>((List<UUID>) options.get("chosenTargets"));
|
||||
return (Set<UUID>) options.get("chosenTargets");
|
||||
} else {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ import java.io.BufferedReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
|
@ -93,7 +90,9 @@ public class XmageURLConnection {
|
|||
initDefaultProxy();
|
||||
|
||||
try {
|
||||
URL url = new URL(this.url);
|
||||
// convert utf8 url to ascii format (e.g. url encode)
|
||||
URI uri = new URI(this.url);
|
||||
URL url = new URL(uri.toASCIIString());
|
||||
|
||||
// proxy settings
|
||||
if (this.proxy != null) {
|
||||
|
|
@ -107,7 +106,7 @@ public class XmageURLConnection {
|
|||
this.connection.setReadTimeout(CONNECTION_READING_TIMEOUT_MS);
|
||||
|
||||
initDefaultHeaders();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
this.connection = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue